diff --git a/app/controllers/origami/shifts_controller.rb b/app/controllers/origami/shifts_controller.rb index e05922fd..1647ba37 100755 --- a/app/controllers/origami/shifts_controller.rb +++ b/app/controllers/origami/shifts_controller.rb @@ -61,7 +61,21 @@ class Origami::ShiftsController < BaseOrigamiController end if ENV["SERVER_MODE"] != "cloud" #no print in cloud server + + close_cashier_pdf = Lookup.collection_of("print_settings") unique_code = "CloseCashierPdf" + + if !close_cashier_pdf.empty? + close_cashier_pdf.each do |close_cashier| + if close_cashier[0] == 'CloseCashierCustomisePdf' + if close_cashier[1] == '1' + unique_code="CloseCashierCustomisePdf" + else + unique_code="CloseCashierPdf" + end + end + end + end shop_details = Shop.find(1) #get tax shift_obj = ShiftSale.where('id =?',@shift.id) @@ -79,7 +93,7 @@ class Origami::ShiftsController < BaseOrigamiController # get printer info print_settings = PrintSetting.find_by_unique_code(unique_code) - + #byebug printer = Printer::CashierStationPrinter.new(print_settings) printer.print_close_cashier(print_settings,cashier_terminal,@shift,shop_details,@sale_taxes,@other_payment,@total_amount_by_account,@total_discount_by_account,@total_member_discount,@total_dinein,@total_takeway,@total_other_charges) diff --git a/app/models/printer/cashier_station_printer.rb b/app/models/printer/cashier_station_printer.rb index dcdbc696..1e040dee 100755 --- a/app/models/printer/cashier_station_printer.rb +++ b/app/models/printer/cashier_station_printer.rb @@ -22,16 +22,43 @@ class Printer::CashierStationPrinter < Printer::PrinterWorker # end #Bill Receipt Print + # def print_close_cashier(printer_settings,cashier_terminal,shift_sale,shop_details,sale_taxes,other_payment,amount,discount,member_discount,total_dinein,total_takeway,total_other_charges) + # #Use CUPS service + # #Generate PDF + # #Print + # cashier = shift_sale.employee.name + # shift_name = shift_sale.shift_started_at.utc.getlocal.strftime("%d-%m-%Y %I:%M %p") + "_" + shift_sale.shift_closed_at.utc.getlocal.strftime("%d-%m-%Y %I:%M %p") + + # pdf = CloseCashierCustomisePdf.new(printer_settings,shift_sale,shop_details,sale_taxes,other_payment,amount,discount,member_discount,total_dinein,total_takeway,total_other_charges) + # filename = "tmp/close_cashier_#{cashier}_#{shift_name}.pdf" + # pdf.render_file filename + # self.print(filename, cashier_terminal.printer_name) + # end + def print_close_cashier(printer_settings,cashier_terminal,shift_sale,shop_details,sale_taxes,other_payment,amount,discount,member_discount,total_dinein,total_takeway,total_other_charges) + #Use CUPS service #Generate PDF #Print cashier = shift_sale.employee.name shift_name = shift_sale.shift_started_at.utc.getlocal.strftime("%d-%m-%Y %I:%M %p") + "_" + shift_sale.shift_closed_at.utc.getlocal.strftime("%d-%m-%Y %I:%M %p") - + filename = "tmp/close_cashier_#{cashier}_#{shift_name}.pdf" pdf = CloseCashierCustomisePdf.new(printer_settings,shift_sale,shop_details,sale_taxes,other_payment,amount,discount,member_discount,total_dinein,total_takeway,total_other_charges) - filename = "tmp/close_cashier_#{cashier}_#{shift_name}.pdf" + close_cashier_pdf = Lookup.collection_of("print_settings") #print_settings with name:CloseCashierPdf + + if !close_cashier_pdf.empty? + close_cashier_pdf.each do |close_cashier| + if close_cashier[0] == 'CloseCashierCustomisePdf' + if close_cashier[1] == '1' + pdf = CloseCashierCustomisePdf.new(printer_settings,shift_sale,shop_details,sale_taxes,other_payment,amount,discount,member_discount,total_dinein,total_takeway,total_other_charges) + else + pdf = CloseCashierPdf.new(printer_settings,shift_sale,shop_details,sale_taxes,other_payment,amount,discount,member_discount,total_dinein,total_takeway,total_other_charges) + end + end + end + end pdf.render_file filename + self.print(filename, cashier_terminal.printer_name) end #sqa diff --git a/app/pdf/close_cashier_customise_pdf.rb b/app/pdf/close_cashier_customise_pdf.rb index cd9d7b3b..65089a74 100644 --- a/app/pdf/close_cashier_customise_pdf.rb +++ b/app/pdf/close_cashier_customise_pdf.rb @@ -416,7 +416,7 @@ class CloseCashierCustomisePdf < Prawn::Document #end total amount by Account #start total other charges amount - if total_other_charges > 0 + if total_other_charges.present? y_position = cursor bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do text "Total Other Charges :", :size => self.item_font_size, :align => :right