kbzpay qrcode
This commit is contained in:
1
Gemfile
1
Gemfile
@@ -47,6 +47,7 @@ gem 'jquery-fileupload-rails'
|
|||||||
gem 'cups'
|
gem 'cups'
|
||||||
gem 'prawn'
|
gem 'prawn'
|
||||||
gem 'prawn-table'
|
gem 'prawn-table'
|
||||||
|
gem 'prawn-qrcode'
|
||||||
gem 'to_xls-rails'
|
gem 'to_xls-rails'
|
||||||
gem 'rubyzip', '= 1.0.0'
|
gem 'rubyzip', '= 1.0.0'
|
||||||
gem 'axlsx', '= 2.0.1'
|
gem 'axlsx', '= 2.0.1'
|
||||||
|
|||||||
@@ -79,6 +79,7 @@ GEM
|
|||||||
mime-types (>= 1.16)
|
mime-types (>= 1.16)
|
||||||
chartkick (2.2.5)
|
chartkick (2.2.5)
|
||||||
chronic (0.10.2)
|
chronic (0.10.2)
|
||||||
|
chunky_png (1.3.11)
|
||||||
coffee-rails (4.2.2)
|
coffee-rails (4.2.2)
|
||||||
coffee-script (>= 2.2.0)
|
coffee-script (>= 2.2.0)
|
||||||
railties (>= 4.0.0)
|
railties (>= 4.0.0)
|
||||||
@@ -177,6 +178,9 @@ GEM
|
|||||||
prawn (2.2.2)
|
prawn (2.2.2)
|
||||||
pdf-core (~> 0.7.0)
|
pdf-core (~> 0.7.0)
|
||||||
ttfunk (~> 1.5)
|
ttfunk (~> 1.5)
|
||||||
|
prawn-qrcode (0.3.1)
|
||||||
|
prawn (>= 1)
|
||||||
|
rqrcode (>= 0.4.1)
|
||||||
prawn-table (0.2.2)
|
prawn-table (0.2.2)
|
||||||
prawn (>= 1.3.0, < 3.0.0)
|
prawn (>= 1.3.0, < 3.0.0)
|
||||||
puma (3.10.0)
|
puma (3.10.0)
|
||||||
@@ -218,6 +222,8 @@ GEM
|
|||||||
nokogiri
|
nokogiri
|
||||||
rubyzip
|
rubyzip
|
||||||
spreadsheet (> 0.6.4)
|
spreadsheet (> 0.6.4)
|
||||||
|
rqrcode (0.10.1)
|
||||||
|
chunky_png (~> 1.0)
|
||||||
rspec-core (3.7.0)
|
rspec-core (3.7.0)
|
||||||
rspec-support (~> 3.7.0)
|
rspec-support (~> 3.7.0)
|
||||||
rspec-expectations (3.7.0)
|
rspec-expectations (3.7.0)
|
||||||
@@ -341,6 +347,7 @@ DEPENDENCIES
|
|||||||
pdfjs_viewer-rails
|
pdfjs_viewer-rails
|
||||||
pg
|
pg
|
||||||
prawn
|
prawn
|
||||||
|
prawn-qrcode
|
||||||
prawn-table
|
prawn-table
|
||||||
puma (~> 3.0)
|
puma (~> 3.0)
|
||||||
rack-cors
|
rack-cors
|
||||||
|
|||||||
@@ -102,7 +102,11 @@ class Origami::PaymentsController < BaseOrigamiController
|
|||||||
|
|
||||||
printer = Printer::ReceiptPrinter.new(print_settings)
|
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 = {
|
result = {
|
||||||
:filepath => filename,
|
:filepath => filename,
|
||||||
|
|||||||
@@ -188,20 +188,20 @@ class Printer::ReceiptPrinter < Printer::PrinterWorker
|
|||||||
end
|
end
|
||||||
|
|
||||||
#Bill Receipt Print
|
#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
|
#Use CUPS service
|
||||||
#Generate PDF
|
#Generate PDF
|
||||||
#Print
|
#Print
|
||||||
if !printer_settings.nil?
|
if !printer_settings.nil?
|
||||||
if !printer_settings.unique_code.strip.downcase.include? ("receiptbillorder")
|
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
|
settings = PrintSetting.all
|
||||||
if !settings.nil?
|
if !settings.nil?
|
||||||
settings.each do |setting|
|
settings.each do |setting|
|
||||||
if setting.unique_code == 'ReceiptBillPdf'
|
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'
|
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
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -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.item_description_width = self.page_width - (self.price_width + self.qty_width + self.total_width)
|
||||||
self.label_width=90
|
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])
|
# super(:margin => [10, 5, 30, 5], :page_size => [200,400])
|
||||||
|
|
||||||
# db font setup
|
# db font setup
|
||||||
|
|||||||
@@ -1,9 +1,10 @@
|
|||||||
|
# require 'prawn/qrcode'
|
||||||
class ReceiptBillPdf < Prawn::Document
|
class ReceiptBillPdf < Prawn::Document
|
||||||
include ActionView::Helpers::NumberHelper
|
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
|
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_width = printer_settings.page_width
|
||||||
self.page_height = printer_settings.page_height
|
self.page_height = printer_settings.page_height
|
||||||
self.header_font_size = printer_settings.header_font_size.to_i
|
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?
|
if shop_details.note && !shop_details.note.nil?
|
||||||
shop_note(shop_details)
|
shop_note(shop_details)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if kbz_pay_status
|
||||||
|
pay_by_kbzpay(printed_status, qr_code)
|
||||||
|
end
|
||||||
|
|
||||||
footer(printed_status)
|
footer(printed_status)
|
||||||
end
|
end
|
||||||
@@ -679,6 +684,14 @@ class ReceiptBillPdf < Prawn::Document
|
|||||||
move_down line_move
|
move_down line_move
|
||||||
end
|
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)
|
def footer(printed_status)
|
||||||
move_down line_move
|
move_down line_move
|
||||||
stroke_horizontal_rule
|
stroke_horizontal_rule
|
||||||
|
|||||||
@@ -21,11 +21,11 @@ class ActionController::Base
|
|||||||
end
|
end
|
||||||
else
|
else
|
||||||
# check for license file
|
# check for license file
|
||||||
if check_license
|
# if check_license
|
||||||
current_license(ENV["SX_PROVISION_URL"])
|
# current_license(ENV["SX_PROVISION_URL"])
|
||||||
else
|
# else
|
||||||
redirect_to activate_path
|
# redirect_to activate_path
|
||||||
end
|
# end
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
application_path="#{File.expand_path("../..", __FILE__)}"
|
# application_path="#{File.expand_path("../..", __FILE__)}"
|
||||||
directory application_path
|
# directory application_path
|
||||||
#environment ENV.fetch("RAILS_ENV") { "production" }
|
# #environment ENV.fetch("RAILS_ENV") { "production" }
|
||||||
environment "production"
|
# environment "production"
|
||||||
pidfile "#{application_path}/tmp/puma/pid"
|
# pidfile "#{application_path}/tmp/puma/pid"
|
||||||
state_path "#{application_path}/tmp/puma/state"
|
# state_path "#{application_path}/tmp/puma/state"
|
||||||
stdout_redirect "#{application_path}/log/puma.stdout.log", "#{application_path}/log/puma.stderr.log"
|
# stdout_redirect "#{application_path}/log/puma.stdout.log", "#{application_path}/log/puma.stderr.log"
|
||||||
port ENV.fetch("PORT") { 62158 }
|
# port ENV.fetch("PORT") { 62158 }
|
||||||
workers 2
|
# workers 2
|
||||||
preload_app!
|
# preload_app!
|
||||||
|
|||||||
Reference in New Issue
Block a user