Files
sx-fc/app/models/printer/cashier_station_printer.rb
2020-06-08 10:13:55 +06:30

105 lines
4.8 KiB
Ruby
Executable File

class Printer::CashierStationPrinter < Printer::PrinterWorker
def print_open_cashier(receipt_no)
time = DateTime.now
#Use CUPS service
#Generate PDF
#Print
pdf = CashierStationOpening.new
pdf.render_file "tmp/cashier_station_#{order_id}_closing_#{time}.pdf"
#no print in cloud server
if ENV["SERVER_MODE"] != "cloud"
self.print("tmp/cashier_station_#{order_id}_closing_#{time}.pdf")
end
end
# def print_close_cashier(receipt_no)
# #Use CUPS service
# #Generate PDF
# time = DateTime.now
# #Print
# pdf = CashierStationClosing.new
# pdf.render_file "tmp/cashier_station_#{order_id}_closing_#{time}.pdf"
# self.print("tmp/receipt.pdf")
# 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, sale_items, total_other_charges_info,shop_details,sale_taxes,other_payment,amount,discount,member_discount,total_dinein,total_takeway,total_other_charges,total_waste,total_spoile,total_credit_payments,payment_methods)
if !sale_items.blank? or !sale_items.nil?
@account_cate_count = Hash.new {|hash, key| hash[key] = 0}
sale_items.each {|acc_cate| @account_cate_count[acc_cate.account_id] += 1}
@menu_cate_count = Hash.new {|hash, key| hash[key] = 0}
sale_items.each {|cate| @menu_cate_count[cate.menu_category_id] += 1}
@totalByAccount = Hash.new {|hash, key| hash[key] = 0}
sale_items.each {|acc| @totalByAccount[acc.account_id] += acc.grand_total}
end
#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 = CloseCashierPdf.new(printer_settings,shift_sale, sale_items, total_other_charges_info, @account_cate_count, @menu_cate_count, @totalByAccount, shop_details,sale_taxes,other_payment,amount,discount,member_discount,total_dinein,total_takeway,total_other_charges,total_waste,total_spoile,total_credit_payments,payment_methods)
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,total_waste,total_spoile,total_credit_payments)
else
pdf = CloseCashierPdf.new(printer_settings,shift_sale, sale_items, total_other_charges_info, @account_cate_count, @menu_cate_count, @totalByAccount, shop_details,sale_taxes,other_payment,amount,discount,member_discount,total_dinein,total_takeway,total_other_charges,total_waste,total_spoile,total_credit_payments,payment_methods)
end
end
end
end
pdf.render_file filename
#no print in cloud server
if ENV["SERVER_MODE"] != "cloud"
self.print(filename, cashier_terminal.printer_name)
end
end
def print_sale_items_report(print_settings, shop_details, period_name, type, account, from_date, to_date, shift_name, sale_items, total_other_charges)
filename = "tmp/reports_sale_items.pdf"
if print_settings.unique_code == "SaleItemsPdf"
pdf = SaleItemsPdf.new(print_settings, shop_details, period_name, type, account, from_date, to_date, shift_name, sale_items, total_other_charges)
puts 'Printing!!!!'
end
if print_settings.unique_code == "SaleItemsStarPdf"
pdf = SaleItemsStarPdf.new(print_settings, shop_details, period_name, type, account, from_date, to_date, shift_name, sale_items, total_other_charges)
puts 'PrintingStar!!!!'
end
pdf.render_file filename
#no print in cloud server
if ENV["SERVER_MODE"] != "cloud"
self.print(filename, print_settings.printer_name)
end
end
#sqa
end