customize close cashier

This commit is contained in:
phyusin
2018-02-26 11:36:13 +06:30
5 changed files with 529 additions and 8 deletions

View File

@@ -22,14 +22,14 @@ 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)
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 = CloseCashierPdf.new(printer_settings,shift_sale,shop_details,sale_taxes,other_payment,amount,discount,member_discount)
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)

View File

@@ -135,6 +135,27 @@ class ShiftSale < ApplicationRecord
end
def self.get_total_dinein(shift)
query = Sale.select("sum(sales.grand_total) as total_dinein_amount")
.joins("JOIN customers as c ON c.customer_id = sales.customer_id")
.where('shift_sale_id =? and sales.sale_status = "completed" and c.customer_type = "Dinein" and c.membership_id is null',shift.id)
.first()
end
def self.get_total_takeway(shift)
query = Sale.select("sum(sales.grand_total) as total_takeway_amount")
.joins("JOIN customers as c ON c.customer_id = sales.customer_id")
.where('shift_sale_id =? and sales.sale_status = "completed" and c.customer_type = "Takeaway" and c.membership_id is null',shift.id)
.first()
end
def self.get_total_other_charges(shift)
query = SaleItem.select("sum(sale_items.qty * sale_items.unit_price) as total_other_charges_amount")
.joins("JOIN sales as s ON s.sale_id = sale_items.sale_id")
.where('shift_sale_id =? and s.sale_status = "completed" and sale_items.product_code = "Other Charges" and sale_items.item_instance_code is null',shift.id)
.first()
end
def self.search(filter,from,to)
if filter.blank?
keyword = ''