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 e903798e..c2a99dc8 100644 Binary files a/dump.rdb and b/dump.rdb differ