fixed receipt bill pdf with action cable

This commit is contained in:
NyanLinHtut
2020-08-21 11:24:10 +06:30
parent 5dfdc7353e
commit b3ab999962
5 changed files with 112 additions and 151 deletions

View File

@@ -132,14 +132,6 @@ class Origami::PaymentsController < BaseOrigamiController
)
end
# For Print
# if ENV["SERVER_MODE"] != "cloud" #no print in cloud server
if Lookup.collection_of("print_settings").any? { |x| x == ["ReceiptBillA5Pdf", "1"] } #print_settings with name:ReceiptBillA5Pdf
unique_code = "ReceiptBillA5Pdf"
else
unique_code = PrintSetting.where("unique_code REGEXP ?", "receipt.*bill.*pdf").first.unique_code
end
customer = saleObj.customer
# get member information
@@ -197,12 +189,17 @@ class Origami::PaymentsController < BaseOrigamiController
card_balance_amount = SaleAudit.getCardBalanceAmount(sale_id)
# get printer info
print_settings = PrintSetting.find_by_unique_code(unique_code)
if type.strip.downcase == 'doemal_order'
print_settings = PrintSetting.where(unique_code: 'ReceiptBillOrderPdf').first
else
print_settings = PrintSetting.where("unique_code REGEXP ?", "receipt.*bill.*pdf").first
end
# Calculate Food and Beverage Total
item_price_by_accounts = SaleItem.calculate_price_by_accounts(saleObj.sale_items)
discount_price_by_accounts = SaleItem.get_discount_price_by_accounts(saleObj.sale_items)
other_amount = SaleItem.calculate_other_charges(sale_items)
credit_pdf = Lookup.find_by_lookup_type("credit_pdf")
if (path.include? ("credit_payment")) && !credit_pdf.nil? && credit_pdf.value.to_i == 1
printed_status = 'credit_payment'
else
@@ -211,13 +208,10 @@ class Origami::PaymentsController < BaseOrigamiController
printer = Printer::ReceiptPrinter.new(print_settings)
filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings, false, nil, cashier_terminal,sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_detail, printed_status,current_balance,card_data,other_amount,latest_order_no,card_balance_amount,nil)
#end
if !saleObj.nil?
# InventoryJob.perform_now(self.id)
# InventoryDefinition.calculate_product_count(saleObj)
end
# if !saleObj.nil?
# InventoryJob.perform_now(self.id)
# InventoryDefinition.calculate_product_count(saleObj)
# end
end
# status, filename, sale_receipt_no, printer_name = Payment.pay(getCloudDomain, cash, sale_id, member_info, type, tax_type, path, latest_order_no, shop_detail, current_user, nil, nil)
@@ -610,32 +604,11 @@ class Origami::PaymentsController < BaseOrigamiController
cashier_type = params[:type]
if cashier_type.strip.downcase == "doemal_order"
unique_code = "ReceiptBillOrderPdf"
print_settings = PrintSetting.where(unique_code: 'ReceiptBillOrderPdf').first
else
receipt_bill_a5_pdf = Lookup.collection_of("print_settings") #print_settings with name:ReceiptBillA5Pdf
unique_code = "ReceiptBillPdf"
print_settings = PrintSetting.all
if !print_settings.nil?
print_settings.each do |setting|
if setting.unique_code == 'ReceiptBillPdf'
unique_code = "ReceiptBillPdf"
elsif setting.unique_code == 'ReceiptBillStarPdf'
unique_code = "ReceiptBillStarPdf"
end
end
end
if !receipt_bill_a5_pdf.empty?
receipt_bill_a5_pdf.each do |receipt_bilA5|
if receipt_bilA5[0] == 'ReceiptBillA5Pdf'
if receipt_bilA5[1] == '1'
unique_code = "ReceiptBillA5Pdf"
# else
# unique_code = "ReceiptBillPdf"
end
end
end
end
print_settings = PrintSetting.where("unique_code REGEXP ?", "receipt.*bill.*pdf").first
end
# get printer info
print_settings = PrintSetting.find_by_unique_code(unique_code)
printer = Printer::ReceiptPrinter.new(print_settings)