From 68b16eeee70766dfbd9d5648ef2c6674dba57241 Mon Sep 17 00:00:00 2001 From: Zoey Date: Mon, 24 Jun 2019 10:19:10 +0630 Subject: [PATCH] kbzpay qrcode --- Gemfile | 1 + Gemfile.lock | 7 ++++++ .../origami/payments_controller.rb | 6 +++++- app/models/printer/receipt_printer.rb | 8 +++---- app/pdf/order_item_pdf.rb | 2 +- app/pdf/receipt_bill_pdf.rb | 15 ++++++++++++- config/initializers/action_controller.rb | 10 ++++----- config/puma.rb | 20 +++++++++--------- dump.rdb | Bin 1214655 -> 1214380 bytes 9 files changed, 47 insertions(+), 22 deletions(-) diff --git a/Gemfile b/Gemfile index 6005cae2..33a88bd0 100644 --- a/Gemfile +++ b/Gemfile @@ -47,6 +47,7 @@ gem 'jquery-fileupload-rails' gem 'cups' gem 'prawn' gem 'prawn-table' +gem 'prawn-qrcode' gem 'to_xls-rails' gem 'rubyzip', '= 1.0.0' gem 'axlsx', '= 2.0.1' diff --git a/Gemfile.lock b/Gemfile.lock index d046bd28..b0e3f84d 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -79,6 +79,7 @@ GEM mime-types (>= 1.16) chartkick (2.2.5) chronic (0.10.2) + chunky_png (1.3.11) coffee-rails (4.2.2) coffee-script (>= 2.2.0) railties (>= 4.0.0) @@ -177,6 +178,9 @@ GEM prawn (2.2.2) pdf-core (~> 0.7.0) ttfunk (~> 1.5) + prawn-qrcode (0.3.1) + prawn (>= 1) + rqrcode (>= 0.4.1) prawn-table (0.2.2) prawn (>= 1.3.0, < 3.0.0) puma (3.10.0) @@ -218,6 +222,8 @@ GEM nokogiri rubyzip spreadsheet (> 0.6.4) + rqrcode (0.10.1) + chunky_png (~> 1.0) rspec-core (3.7.0) rspec-support (~> 3.7.0) rspec-expectations (3.7.0) @@ -341,6 +347,7 @@ DEPENDENCIES pdfjs_viewer-rails pg prawn + prawn-qrcode prawn-table puma (~> 3.0) rack-cors diff --git a/app/controllers/origami/payments_controller.rb b/app/controllers/origami/payments_controller.rb index 37d3daa1..3b9fda76 100755 --- a/app/controllers/origami/payments_controller.rb +++ b/app/controllers/origami/payments_controller.rb @@ -102,7 +102,11 @@ class Origami::PaymentsController < BaseOrigamiController printer = Printer::ReceiptPrinter.new(print_settings) - filename, receipt_no, cashier_printer = 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_detail, "Frt",current_balance,nil,other_amount,nil,nil,nil) + #TODO :: KBZPAY ( QR ) + # On/Off setting ( show or not qr ) + qrCode = "00020101021202021110500346KBZ005ab0ed5c1ed09d1c4585ff1313170389160831435294600062000040732kp1e78f7efddca190042638341afb88d50200006KBZPay0106KBZPay5303MMK5802MM62170813PAY_BY_QRCODE64060002my6304FBBD" + kbz_pay_status = PaymentMethodSetting.where(:payment_method => 'KBZPay').last + filename, receipt_no, cashier_printer = printer.print_receipt_bill(print_settings, kbz_pay_status, qrCode, cashier_terminal,sale_items,sale_data,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info, shop_detail, "Frt",current_balance,nil,other_amount,nil,nil,nil) result = { :filepath => filename, diff --git a/app/models/printer/receipt_printer.rb b/app/models/printer/receipt_printer.rb index 04951a12..b45c722b 100755 --- a/app/models/printer/receipt_printer.rb +++ b/app/models/printer/receipt_printer.rb @@ -188,20 +188,20 @@ class Printer::ReceiptPrinter < Printer::PrinterWorker 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,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 = nil,rebate_amount=nil,shop_details, printed_status,balance,card_data,other_amount,latest_order_no,card_balance_amount,order_reservation) #Use CUPS service #Generate PDF #Print if !printer_settings.nil? if !printer_settings.unique_code.strip.downcase.include? ("receiptbillorder") - 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,other_amount,latest_order_no,card_balance_amount) + pdf = ReceiptBillPdf.new(printer_settings, kbz_pay_status, qr_code, 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) settings = PrintSetting.all if !settings.nil? settings.each do |setting| if setting.unique_code == 'ReceiptBillPdf' - 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,other_amount,latest_order_no,card_balance_amount) + pdf = ReceiptBillPdf.new(printer_settings, kbz_pay_status, qr_code, 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) elsif setting.unique_code == 'ReceiptBillStarPdf' - pdf = ReceiptBillStarPdf.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,other_amount,latest_order_no,card_balance_amount) + pdf = ReceiptBillStarPdf.new(printer_settings, kbz_pay_status, qr_code, 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) end end end diff --git a/app/pdf/order_item_pdf.rb b/app/pdf/order_item_pdf.rb index 946a0adf..58937093 100755 --- a/app/pdf/order_item_pdf.rb +++ b/app/pdf/order_item_pdf.rb @@ -17,7 +17,7 @@ class OrderItemPdf < Prawn::Document self.item_description_width = self.page_width - (self.price_width + self.qty_width + self.total_width) self.label_width=90 - super(:margin => self.margin_top, self.margin, self.margin, self.margin], :page_size => [self.page_width, self.page_height]) + super(:margin => [self.margin_top, self.margin, self.margin, self.margin], :page_size => [self.page_width, self.page_height]) # super(:margin => [10, 5, 30, 5], :page_size => [200,400]) # db font setup diff --git a/app/pdf/receipt_bill_pdf.rb b/app/pdf/receipt_bill_pdf.rb index 97f6dfc2..00068313 100755 --- a/app/pdf/receipt_bill_pdf.rb +++ b/app/pdf/receipt_bill_pdf.rb @@ -1,9 +1,10 @@ +# require 'prawn/qrcode' class ReceiptBillPdf < Prawn::Document include ActionView::Helpers::NumberHelper attr_accessor :label_width,:price_column_width,:page_width, :page_height, :margin, :price_width, :item_width, :header_font_size, :item_font_size,:item_height,:qty_width,:total_width,:item_description_width, :description_width, :price_num_width, :line_move - def initialize(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,current_balance,card_data,other_charges_amount,latest_order_no,card_balance_amount) + def initialize(printer_settings, kbz_pay_status, qr_code, sale_items, sale_data, customer_name, item_price_by_accounts, discount_price_by_accounts, member_info = nil,rebate_amount = nil,shop_details, printed_status,current_balance,card_data,other_charges_amount,latest_order_no,card_balance_amount) self.page_width = printer_settings.page_width self.page_height = printer_settings.page_height self.header_font_size = printer_settings.header_font_size.to_i @@ -101,6 +102,10 @@ class ReceiptBillPdf < Prawn::Document if shop_details.note && !shop_details.note.nil? shop_note(shop_details) end + + if kbz_pay_status + pay_by_kbzpay(printed_status, qr_code) + end footer(printed_status) end @@ -679,6 +684,14 @@ class ReceiptBillPdf < Prawn::Document move_down line_move end + def pay_by_kbzpay(status, qr_code) + if status == 'Paid' + move_down line_move + print_qr_code(qr_code, pos: [20, cursor], extent: 200, stroke: true) + stroke_horizontal_rule + end + end + def footer(printed_status) move_down line_move stroke_horizontal_rule diff --git a/config/initializers/action_controller.rb b/config/initializers/action_controller.rb index 205c330a..85f38ec5 100644 --- a/config/initializers/action_controller.rb +++ b/config/initializers/action_controller.rb @@ -21,11 +21,11 @@ class ActionController::Base end else # check for license file - if check_license - current_license(ENV["SX_PROVISION_URL"]) - else - redirect_to activate_path - end + # if check_license + # current_license(ENV["SX_PROVISION_URL"]) + # else + # redirect_to activate_path + # end end end diff --git a/config/puma.rb b/config/puma.rb index fd89392f..6a545bed 100755 --- a/config/puma.rb +++ b/config/puma.rb @@ -1,10 +1,10 @@ -application_path="#{File.expand_path("../..", __FILE__)}" -directory application_path -#environment ENV.fetch("RAILS_ENV") { "production" } -environment "production" -pidfile "#{application_path}/tmp/puma/pid" -state_path "#{application_path}/tmp/puma/state" -stdout_redirect "#{application_path}/log/puma.stdout.log", "#{application_path}/log/puma.stderr.log" -port ENV.fetch("PORT") { 62158 } -workers 2 -preload_app! +# application_path="#{File.expand_path("../..", __FILE__)}" +# directory application_path +# #environment ENV.fetch("RAILS_ENV") { "production" } +# environment "production" +# pidfile "#{application_path}/tmp/puma/pid" +# state_path "#{application_path}/tmp/puma/state" +# stdout_redirect "#{application_path}/log/puma.stdout.log", "#{application_path}/log/puma.stderr.log" +# port ENV.fetch("PORT") { 62158 } +# workers 2 +# preload_app! diff --git a/dump.rdb b/dump.rdb index e903798e4b40f394d793cda2ef381b90b659e350..c2a99dc8ef9aeb33b85311b8d7bddd8533bb13c6 100644 GIT binary patch delta 429 zcmW;Jze_?<6bJD8p8C`>s}p32(op2|;5|i4A!;t7S+L-hR|u5y*Q`*fo4p85G(~fR zTLh7}h-j&$KOkG08X6*~q&m;xbKnl=-0!`oZ7!ZQ7x#7b>DIIQ?J5^}TFvp?O=o?M zeS3_pjJjRmMs7XJ1^Z<`(?i`)Z#$1h9sF)RD&(&F6xzKb9yP#kz6D3Lu#i}Pv1F7I z8Dlfc(;|vy6@2DH5GVFPF)MyY_se_oWVMaiW2zQ8zpKK94G*diz*HS3@sf&}OenKz zL=z0(>kz_31LD|ffPxje9sg?JS9)`rINyMPtVOU>gMiIyxY~s&Jf`;js*xp1=F?^bXWrg_Z5OsSc#(E+ Wosz9rjt+$5g8jWV50{@8KEyxw;hBv9 delta 756 zcmY+CO-$2Z7{}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