216 lines
7.0 KiB
Ruby
Executable File
216 lines
7.0 KiB
Ruby
Executable File
class Printer::ReceiptPrinter < Printer::PrinterWorker
|
|
|
|
def print_receipt(receipt_no)
|
|
#Use CUPS service
|
|
#Generate PDF
|
|
#Print
|
|
order_slim_pdf = Lookup.collection_of("print_settings") #print_settings with name:OrderSlimPdf
|
|
pdf = OrderItemPdf.new
|
|
if !order_slim_pdf.empty?
|
|
order_slim_pdf.each do |order_item_slim|
|
|
if order_item_slim[0] == 'OrderSlimPdf'
|
|
if order_item_slim[1] == '1'
|
|
pdf = OrderItemSlimPdf.new
|
|
else
|
|
pdf = OrderItemPdf.new
|
|
end
|
|
end
|
|
end
|
|
end
|
|
pdf.render_file "tmp/order_item_queue_#{order_id}_#{order_item_id}" + ".pdf"
|
|
self.print("tmp/receipt.pdf")
|
|
end
|
|
|
|
def print_receipt_payment_by_card(booking_id)
|
|
#Use CUPS service
|
|
#Generate PDF
|
|
#Print
|
|
filename = "tmp/order_summary_#{booking_id}" + ".pdf"
|
|
order_slim_pdf = Lookup.collection_of("print_settings") #print_settings with name:OrderSlimPdf
|
|
pdf = OrderSummaryPdf.new
|
|
if !order_slim_pdf.empty?
|
|
order_slim_pdf.each do |order_summary_slim|
|
|
if order_summary_slim[0] == 'OrderSlimPdf'
|
|
if order_summary_slim[1] == '1'
|
|
pdf = OrderSummarySlimPdf.new
|
|
else
|
|
pdf = OrderSummaryPdf.new
|
|
end
|
|
end
|
|
end
|
|
end
|
|
pdf.render_file filename
|
|
|
|
self.print(filename)
|
|
end
|
|
|
|
def print_receipt_payment_by_account(sale_id)
|
|
#Use CUPS service
|
|
#Generate PDF
|
|
#Print
|
|
order_slim_pdf = Lookup.collection_of("print_settings") #print_settings with name:OrderSlimPdf
|
|
filename = "tmp/order_summary_#{booking_id}" + ".pdf"
|
|
pdf = OrderSummaryPdf.new
|
|
if !order_slim_pdf.empty?
|
|
order_slim_pdf.each do |order_summary_slim|
|
|
if order_summary_slim[0] == 'OrderSlimPdf'
|
|
if order_summary_slim[1] == '1'
|
|
pdf = OrderSummarySlimPdf.new
|
|
else
|
|
pdf = OrderSummaryPdf.new
|
|
end
|
|
end
|
|
end
|
|
end
|
|
pdf.render_file filename
|
|
|
|
self.print(filename)
|
|
end
|
|
|
|
def print_receipt_payment_by_vochure(sale_id)
|
|
#Use CUPS service
|
|
#Generate PDF
|
|
#Print
|
|
order_slim_pdf = Lookup.collection_of("print_settings") #print_settings with name:OrderSlimPdf
|
|
filename = "tmp/order_summary_#{booking_id}" + ".pdf"
|
|
pdf = OrderSummaryPdf.new
|
|
if !order_slim_pdf.empty?
|
|
order_slim_pdf.each do |order_summary_slim|
|
|
if order_summary_slim[0] == 'OrderSlimPdf'
|
|
if order_summary_slim[1] == '1'
|
|
pdf = OrderSummarySlimPdf.new
|
|
else
|
|
pdf = OrderSummaryPdf.new
|
|
end
|
|
end
|
|
end
|
|
end
|
|
pdf.render_file filename
|
|
|
|
self.print(filename)
|
|
end
|
|
|
|
def print_receipt_payment_by_giftcard(sale_id)
|
|
#Use CUPS service
|
|
#Generate PDF
|
|
#Print
|
|
order_slim_pdf = Lookup.collection_of("print_settings") #print_settings with name:OrderSlimPdf
|
|
filename = "tmp/order_summary_#{booking_id}" + ".pdf"
|
|
pdf = OrderSummaryPdf.new
|
|
if !order_slim_pdf.empty?
|
|
order_slim_pdf.each do |order_summary_slim|
|
|
if order_summary_slim[0] == 'OrderSlimPdf'
|
|
if order_summary_slim[1] == '1'
|
|
pdf = OrderSummarySlimPdf.new
|
|
else
|
|
pdf = OrderSummaryPdf.new
|
|
end
|
|
end
|
|
end
|
|
end
|
|
pdf.render_file filename
|
|
|
|
self.print(filename)
|
|
end
|
|
|
|
def print_receipt_payment_by_foc(sale_id)
|
|
#Use CUPS service
|
|
#Generate PDF
|
|
#Print
|
|
order_slim_pdf = Lookup.collection_of("print_settings") #print_settings with name:OrderSlimPdf
|
|
filename = "tmp/order_summary_#{booking_id}" + ".pdf"
|
|
pdf = OrderSummaryPdf.new
|
|
if !order_slim_pdf.empty?
|
|
order_slim_pdf.each do |order_summary_slim|
|
|
if order_summary_slim[0] == 'OrderSlimPdf'
|
|
if order_summary_slim[1] == '1'
|
|
pdf = OrderSummarySlimPdf.new
|
|
else
|
|
pdf = OrderSummaryPdf.new
|
|
end
|
|
end
|
|
end
|
|
end
|
|
pdf.render_file filename
|
|
|
|
self.print(filename)
|
|
end
|
|
|
|
#Bill Receipt Print
|
|
def print_receipt_bill(printer_settings,cashier_terminal,sale_items,sale_data, customer_name, item_price_by_accounts, discount_price_by_accounts, member_info = nil,rebate_amount=nil,shop_details, printed_status,balance,card_data)
|
|
#Use CUPS service
|
|
#Generate PDF
|
|
#Print
|
|
receipt_bill_a5_pdf = Lookup.collection_of("print_settings") #print_settings with name:ReceiptBillA5Pdf
|
|
if !receipt_bill_a5_pdf.empty?
|
|
receipt_bill_a5_pdf.each do |receipt_bilA5|
|
|
if receipt_bilA5[0] == 'ReceiptBillA5Pdf'
|
|
if receipt_bilA5[1] == '1'
|
|
pdf = ReceiptBillA5Pdf.new(printer_settings, sale_items, sale_data, customer_name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details,printed_status,balance,card_data)
|
|
else
|
|
pdf = ReceiptBillPdf.new(printer_settings, sale_items, sale_data, customer_name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details,printed_status,balance,card_data)
|
|
end
|
|
end
|
|
end
|
|
else
|
|
pdf = ReceiptBillPdf.new(printer_settings, sale_items, sale_data, customer_name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details,printed_status,balance,card_data)
|
|
end
|
|
# print as print copies in printer setting
|
|
count = printer_settings.print_copies
|
|
|
|
# override print copies for print worker loop
|
|
print_settings.print_copies = 1
|
|
print_settings.save!
|
|
|
|
begin
|
|
if count == 1
|
|
pdf.render_file "tmp/receipt_bill_#{sale_data.receipt_no}.pdf"
|
|
self.print("tmp/receipt_bill_#{sale_data.receipt_no}.pdf", cashier_terminal.printer_name)
|
|
else
|
|
pdf.render_file "tmp/receipt_bill_#{sale_data.receipt_no}_#{count}.pdf"
|
|
self.print("tmp/receipt_bill_#{sale_data.receipt_no}_#{count}.pdf", cashier_terminal.printer_name)
|
|
end
|
|
|
|
count -= 1
|
|
end until count == 0
|
|
end
|
|
|
|
# stock check
|
|
def print_stock_check_result(print_settings,stockcheck, stockcheck_items,checker_name, shop_details)
|
|
pdf = StockResultPdf.new(print_settings,stockcheck, stockcheck_items,checker_name, shop_details)
|
|
pdf.render_file "tmp/print_stock_check_result.pdf"
|
|
self.print("tmp/print_stock_check_result.pdf")
|
|
end
|
|
|
|
#Queue No Print
|
|
def print_queue_no(printer_settings,queue)
|
|
#Use CUPS service
|
|
#Generate PDF
|
|
#Print
|
|
pdf = QueueNoPdf.new(printer_settings,queue)
|
|
pdf.render_file "tmp/print_queue_no.pdf"
|
|
self.print("tmp/print_queue_no.pdf")
|
|
end
|
|
|
|
#Bill Receipt Print
|
|
def print_crm_order(booking,order_items,setting)
|
|
#Use CUPS service
|
|
#Generate PDF
|
|
#Print
|
|
pdf = CrmOrderPdf.new(booking,order_items,setting)
|
|
pdf.render_file "tmp/print_crm_order.pdf"
|
|
self.print("tmp/print_crm_order.pdf")
|
|
end
|
|
|
|
#Queue No Print
|
|
def print_call_waiter(printer_settings,table,time,shop_detail)
|
|
#Use CUPS service
|
|
#Generate PDF
|
|
#Print
|
|
pdf = CallWaiterPdf.new(printer_settings,table,time,shop_detail)
|
|
pdf.render_file "tmp/print_call_waiter.pdf"
|
|
self.print("tmp/print_call_waiter.pdf")
|
|
end
|
|
|
|
end
|