From 78ecd6b1e8db8d65820698b3a833356660d4d1a7 Mon Sep 17 00:00:00 2001 From: yarzar_code Date: Wed, 26 Aug 2020 15:36:04 +0630 Subject: [PATCH] receipt bill pdf fixed --- .../foodcourt/orders_controller.rb | 2 +- .../foodcourt/second_display_controller.rb | 2 +- app/models/printer/receipt_printer.rb | 2 +- app/pdf/receipt_bill_pdf.rb | 49 ++++++------------- app/views/foodcourt/payments/show.html.erb | 2 +- config/secrets.yml | 2 +- 6 files changed, 21 insertions(+), 38 deletions(-) diff --git a/app/controllers/foodcourt/orders_controller.rb b/app/controllers/foodcourt/orders_controller.rb index 65d53d15..829c435a 100755 --- a/app/controllers/foodcourt/orders_controller.rb +++ b/app/controllers/foodcourt/orders_controller.rb @@ -220,7 +220,7 @@ class Foodcourt::OrdersController < BaseFoodcourtController #bill channel if ENV["SERVER_MODE"] == 'cloud' - from = request.subdomain + "." + request.domain + from = request.host else from = "" end diff --git a/app/controllers/foodcourt/second_display_controller.rb b/app/controllers/foodcourt/second_display_controller.rb index e180ed1d..c28ce0ec 100644 --- a/app/controllers/foodcourt/second_display_controller.rb +++ b/app/controllers/foodcourt/second_display_controller.rb @@ -16,7 +16,7 @@ class Foodcourt::SecondDisplayController < BaseFoodcourtController tax_profiles = nil end if ENV["SERVER_MODE"] == 'cloud' - from = request.subdomain + "." + request.domain + from = request.host else from = "" end diff --git a/app/models/printer/receipt_printer.rb b/app/models/printer/receipt_printer.rb index f7c48fe0..855e0ece 100755 --- a/app/models/printer/receipt_printer.rb +++ b/app/models/printer/receipt_printer.rb @@ -90,7 +90,7 @@ class Printer::ReceiptPrinter < Printer::PrinterWorker end #Bill Receipt Print - def print_receipt_bill(printer_settings, kbz_pay_status, qr_code, 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,other_amount,latest_order_no,card_balance_amount,order_reservation) + def print_receipt_bill(printer_settings, kbz_pay_status, qr_code, cashier_terminal, 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, other_amount, latest_order_no, card_balance_amount, order_reservation = nil, transaction_ref = nil) if Lookup.collection_of('print_settings').none? { |x| x == ["ActionCable", "1"] } #Use CUPS service #Generate PDF diff --git a/app/pdf/receipt_bill_pdf.rb b/app/pdf/receipt_bill_pdf.rb index 9da6a58b..07841f7f 100755 --- a/app/pdf/receipt_bill_pdf.rb +++ b/app/pdf/receipt_bill_pdf.rb @@ -482,57 +482,40 @@ class ReceiptBillPdf < Prawn::Document where sa.sale_id='#{sale_data.sale_id}')) = 0 THEN payment_method!='creditnote' ELSE 1 END) AND sale_id = ?", sale_data.sale_id) .group("payment_method") -<<<<<<< HEAD end - sale_payments.each do |payment| - y_position = cursor - if payment.payment_method == "paypar" - bounding_box([0,y_position], :width =>self.item_description_width, :height => self.item_height) do - text "Redeem Payment", :size => self.item_font_size,:align => :left - end - elsif printed_status == 'credit_payment' - text "#{payment.payment_method.capitalize} Payment on #{payment.updated_at.strftime('%d-%m-%Y')}", :left_margin => -10, :size => self.item_font_size,:align => :left - else - payment_method = payment.payment_method.capitalize - if payment.payment_method == "paymal" - payment_method ='Card' - end - bounding_box([0,y_position], :width =>self.item_description_width, :height => self.item_height) do - text "#{payment_method} Payment", :size => self.item_font_size,:align => :left - end - end -======= - end ->>>>>>> r-1902001-01 - sale_payments.each do |payment| y_position = cursor if payment.payment_method == "paypar" bounding_box([0,y_position], :width =>self.item_description_width, :height => self.item_height) do text "Redeem Payment", :size => self.item_font_size,:align => :left - end - elsif printed_status == 'credit_payment' - text "#{payment.payment_method.capitalize} Payment on #{payment.updated_at.strftime('%d-%m-%Y')}", :left_margin => -10, :size => self.item_font_size,:align => :left + end + elsif printed_status == 'credit_payment' + text "#{payment.payment_method.capitalize} Payment on #{payment.updated_at.strftime('%d-%m-%Y')}", :left_margin => -10, :size => self.item_font_size,:align => :left else - bounding_box([0,y_position], :width =>self.item_description_width, :height => self.item_height) do - text "#{payment.payment_method.capitalize} Payment", :size => self.item_font_size,:align => :left + payment_method = payment.payment_method.capitalize + if payment.payment_method == "paymal" + payment_method ='Card' + end + bounding_box([0, y_position], :width =>self.item_description_width, :height => self.item_height) do + text "#{payment_method} Payment", :size => self.item_font_size, :align => :left end end - bounding_box([self.item_description_width,y_position], :width =>self.label_width) do - text "#{number_format(payment.payment_amount, :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right + bounding_box([self.item_description_width, y_position], :width =>self.label_width) do + text "#{number_format(payment.payment_amount, :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size, :align => :right end move_down line_move end + if sale_data.amount_received > 0 y_position = cursor move_down line_move - bounding_box([0,y_position], :width =>self.item_description_width, :height => self.item_height) do - text "Change Amount", :size => self.item_font_size,:align => :left + bounding_box([0, y_position], :width =>self.item_description_width, :height => self.item_height) do + text "Change Amount", :size => self.item_font_size, :align => :left end - bounding_box([self.item_description_width,y_position], :width =>self.label_width) do - text "#{number_format(sale_data.amount_changed, :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right + bounding_box([self.item_description_width, y_position], :width =>self.label_width) do + text "#{number_format(sale_data.amount_changed, :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size, :align => :right end # move_down line_move end diff --git a/app/views/foodcourt/payments/show.html.erb b/app/views/foodcourt/payments/show.html.erb index e87ae1de..b55a83d0 100755 --- a/app/views/foodcourt/payments/show.html.erb +++ b/app/views/foodcourt/payments/show.html.erb @@ -1297,7 +1297,7 @@ $(document).ready(function(){ type: 'POST', url: ajax_url, data: "remark="+ remark + "&sale_id=" + sale_id+ "&access_code=" + access_code, - success: function (result) {result + success: function (result) { customer_display_view(null,"reload"); // For Server Print - from jade if ($("#server_mode").val() == "cloud") { diff --git a/config/secrets.yml b/config/secrets.yml index ea9d1f03..9fe66eb0 100755 --- a/config/secrets.yml +++ b/config/secrets.yml @@ -13,7 +13,7 @@ development: secret_key_base: b61d85f8ed2a1a9e0eeece3443b3e8f838d002cc1d9f32115d8e93db920e2957adfedc57501d44741211538f3108b742cdeada87d5bfae796c53da1f90a3cd61 sx_provision_url: connect.smartsales.asia/api #connect.smartsales.dev/api #connect.smartsales.asia/api #provision.zsai.ws/api - server_mode: cloud + server_mode: application cipher_type: AES-256-CBC sx_key: Wh@t1$C2L