print bill by cashier zone

This commit is contained in:
Yan
2017-10-23 18:39:05 +06:30
parent 707cae4cf8
commit c61c7ac98f
3 changed files with 31 additions and 7 deletions

View File

@@ -10,7 +10,7 @@ class Api::BillController < Api::ApiController
table = 0 table = 0
if (params[:booking_id]) if (params[:booking_id])
booking = Booking.find(params[:booking_id]) booking = Booking.find(params[:booking_id])
# for Job # for Multiple Cashier by Zone
table = DiningFacility.find(booking.dining_facility_id) table = DiningFacility.find(booking.dining_facility_id)
cashier_zone = CashierTerminalByZone.find_by_zone_id(table.zone_id) cashier_zone = CashierTerminalByZone.find_by_zone_id(table.zone_id)

View File

@@ -9,8 +9,19 @@ class Origami::PaymentsController < BaseOrigamiController
sale_items = SaleItem.where("sale_id=?",sale_id) sale_items = SaleItem.where("sale_id=?",sale_id)
member_info = nil member_info = nil
# Print for First Bill to Customer # For Cashier by Zone
bookings = Booking.find_by_sale_id(sale_id)
if bookings.count > 1
# for Multiple Cashier by Zone
table = DiningFacility.find(bookings[0].dining_facility_id)
else
table = DiningFacility.find(bookings.dining_facility_id)
end
cashier_zone = CashierTerminalByZone.find_by_zone_id(table.zone_id)
cashier_terminal = CashierTerminal.find(cashier_zone.cashier_terminal_id)
# Print for First Bill to Customer
unique_code = "ReceiptBillPdf" unique_code = "ReceiptBillPdf"
#shop detail #shop detail
shop_details = Shop.find(1) shop_details = Shop.find(1)
@@ -33,7 +44,7 @@ class Origami::PaymentsController < BaseOrigamiController
printer = Printer::ReceiptPrinter.new(print_settings) printer = Printer::ReceiptPrinter.new(print_settings)
printer.print_receipt_bill(print_settings,sale_items,sale_data,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info, shop_details, "Frt") printer.print_receipt_bill(print_settings,cashier_terminal,sale_items,sale_data,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info, shop_details, "Frt")
end end
def create def create
@@ -49,6 +60,19 @@ class Origami::PaymentsController < BaseOrigamiController
render json: JSON.generate({:status => saleObj.rebate_status, :message => "Can't Rebate coz of Sever Error "}) render json: JSON.generate({:status => saleObj.rebate_status, :message => "Can't Rebate coz of Sever Error "})
rebate_amount = nil rebate_amount = nil
# For Cashier by Zone
bookings = Booking.find_by_sale_id(sale_id)
if bookings.count > 1
# for Multiple Cashier by Zone
table = DiningFacility.find(bookings[0].dining_facility_id)
else
table = DiningFacility.find(bookings.dining_facility_id)
end
cashier_zone = CashierTerminalByZone.find_by_zone_id(table.zone_id)
cashier_terminal = CashierTerminal.find(cashier_zone.cashier_terminal_id)
# For Print
unique_code = "ReceiptBillPdf" unique_code = "ReceiptBillPdf"
customer= Customer.find(saleObj.customer_id) customer= Customer.find(saleObj.customer_id)
@@ -68,7 +92,7 @@ class Origami::PaymentsController < BaseOrigamiController
discount_price_by_accounts = SaleItem.get_discount_price_by_accounts(saleObj.sale_items) discount_price_by_accounts = SaleItem.get_discount_price_by_accounts(saleObj.sale_items)
printer = Printer::ReceiptPrinter.new(print_settings) printer = Printer::ReceiptPrinter.new(print_settings)
printer.print_receipt_bill(print_settings,saleObj.sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details, "Paid") printer.print_receipt_bill(print_settings,cashier_terminal,saleObj.sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details, "Paid")
end end
end end

View File

@@ -65,7 +65,7 @@ class Printer::ReceiptPrinter < Printer::PrinterWorker
end end
#Bill Receipt Print #Bill Receipt Print
def print_receipt_bill(printer_settings,sale_items,sale_data, customer_name, item_price_by_accounts, discount_price_by_accounts, member_info = nil,rebate_amount=nil,shop_details, printed_status) 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)
#Use CUPS service #Use CUPS service
#Generate PDF #Generate PDF
#Print #Print
@@ -77,10 +77,10 @@ class Printer::ReceiptPrinter < Printer::PrinterWorker
begin begin
if count == 1 if count == 1
pdf.render_file "tmp/receipt_bill_#{sale_data.receipt_no}.pdf" pdf.render_file "tmp/receipt_bill_#{sale_data.receipt_no}.pdf"
self.print("tmp/receipt_bill_#{sale_data.receipt_no}.pdf") self.print("tmp/receipt_bill_#{sale_data.receipt_no}.pdf", cashier_terminal.printer_name)
else else
pdf.render_file "tmp/receipt_bill_#{sale_data.receipt_no}_#{count}.pdf" pdf.render_file "tmp/receipt_bill_#{sale_data.receipt_no}_#{count}.pdf"
self.print("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 end
count -= 1 count -= 1