From 79d8eb94ef9a7a6a6b23c23e81da77d1409e8a6e Mon Sep 17 00:00:00 2001 From: Zoey Date: Wed, 26 Jun 2019 11:42:51 +0630 Subject: [PATCH 01/12] kbzpay --- .../api/payment/callback_controller.rb | 3 + .../origami/payments_controller.rb | 114 +++++++++++------- .../origami/table_invoices_controller.rb | 2 +- .../reports/payment_method_controller.rb | 2 +- app/models/kbz_pay.rb | 107 +++++++++++++--- app/models/payment.rb | 6 + app/models/sale.rb | 3 + app/models/sale_payment.rb | 60 +++++++-- app/pdf/receipt_bill_pdf.rb | 4 +- app/views/origami/home/show.html.erb | 20 +++ app/views/origami/payments/show.html.erb | 24 +++- app/views/reports/dailysale/index.html.erb | 14 +++ app/views/reports/dailysale/index.xls.erb | 12 ++ .../reports/payment_method/index.html.erb | 6 +- .../reports/payment_method/index.xls.erb | 6 +- config/routes.rb | 1 + dump.rdb | Bin 1214380 -> 1214755 bytes 17 files changed, 306 insertions(+), 78 deletions(-) create mode 100644 app/models/payment.rb diff --git a/app/controllers/api/payment/callback_controller.rb b/app/controllers/api/payment/callback_controller.rb index c2acb4d8..89162fc4 100644 --- a/app/controllers/api/payment/callback_controller.rb +++ b/app/controllers/api/payment/callback_controller.rb @@ -9,6 +9,9 @@ class Api::Payment::CallbackController < Api::ApiController total_amount = params[:Request][:total_amount] if trade_status == "PAY_SUCCESS" merch_order_id = params[:Request][:merch_order_id] + + 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, 'kbzpay', merch_order_id) + render json: JSON.generate({:status => status, :message => "Can't Rebate coz of Sever Error ", :filename => filename, :receipt_no => sale_receipt_no, :printer_name => printer_name}) end end diff --git a/app/controllers/origami/payments_controller.rb b/app/controllers/origami/payments_controller.rb index 35610936..6c487d66 100755 --- a/app/controllers/origami/payments_controller.rb +++ b/app/controllers/origami/payments_controller.rb @@ -105,14 +105,17 @@ class Origami::PaymentsController < BaseOrigamiController #TODO :: KBZPAY ( QR ) # On/Off setting ( show or not qr ) # qrCode = "00020101021202021110500346KBZ005ab0ed5c1ed09d1c4585ff1313170389160831435294600062000040732kp1e78f7efddca190042638341afb88d50200006KBZPay0106KBZPay5303MMK5802MM62170813PAY_BY_QRCODE64060002my6304FBBD" - kbz_pay_setting = PaymentMethodSetting.where(:payment_method => 'KBZPay').last + kbz_pay_setting = PaymentMethodSetting.where(:payment_method => KbzPay::KBZ_PAY).last status = false qr = nil if !kbz_pay_setting.nil? if kbz_pay_setting.is_active == true - status, qr = KbzPay.pay(sale_data.grand_total, sale_data.receipt_no) + sale_payment = SalePayment.new + sale_payment.process_kbz_payment(sale_id, sale_data.grand_total, 0, 'pending') + + status, qr = KbzPay.pay(sale_data.grand_total, sale_payment.sale_payment_id) end end @@ -124,6 +127,8 @@ class Origami::PaymentsController < BaseOrigamiController :printer_url => print_settings.api_settings } + # status, qr = KbzPay.query(sale_payment.sale_payment_id) + # Mobile Print render :json => result.to_json # end @@ -137,6 +142,7 @@ class Origami::PaymentsController < BaseOrigamiController tax_type = params[:tax_type] path = request.fullpath latest_order_no = nil + is_kbz = params[:is_kbz] if(Sale.exists?(sale_id)) saleObj = Sale.find(sale_id) @@ -158,12 +164,22 @@ class Origami::PaymentsController < BaseOrigamiController end #end rounding adjustment - sale_payment = SalePayment.new - if path.include? ("credit_payment") - sale_payment.process_payment(saleObj, current_user, cash, "cash", nil, true) - else - sale_payment.process_payment(saleObj, current_user, cash, "cash") + # if pay_from = 'kbzpay' + # salePayment = SalePayment.find(sale_payment_id) + # salePayment.process_kbz_payment(salePayment.sale_id, sale_data.grand_total, cash, 'paid') + # else + # sp = SalePayment.where('sale_id=? and payment_method=? and payment_status=?', sale_id, 'kbzpay', 'paid').last + if sp.nil? #is_kbz + Rails.logger.info '################ CASH PAYMENT #################' + sale_payment = SalePayment.new + if path.include? ("credit_payment") + sale_payment.process_payment(saleObj, current_user, cash, "cash", nil, true) + else + sale_payment.process_payment(saleObj, current_user, cash, "cash") + end end + + # end if !path.include? ("credit_payment") rebate_amount = nil @@ -233,7 +249,7 @@ class Origami::PaymentsController < BaseOrigamiController end #orders print out - if params[:type] == "quick_service" + if type == "quick_service" booking = Booking.find_by_sale_id(sale_id) if booking.dining_facility_id.to_i>0 table_id = booking.dining_facility_id @@ -284,13 +300,22 @@ 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, "Paid",current_balance,card_data,other_amount,latest_order_no,card_balance_amount,nil) - render json: JSON.generate({:status => saleObj.rebate_status, :message => "Can't Rebate coz of Sever Error ", :filename => filename, :receipt_no => sale_receipt_no, :printer_name => printer_name}) - #end 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) + render json: JSON.generate({:status => saleObj.rebate_status, :message => "Can't Rebate coz of Sever Error ", :filename => filename, :receipt_no => sale_receipt_no, :printer_name => printer_name}) end + # def kbz_query + # sale_id = params[:sale_id] + # table_id = params[:table_id] + # sp = SalePayment.where('sale_id=?', sale_id).last + # status, table_id = KbzPay.query(sp.sale_payment_id) + # render json: JSON.generate({:status => status, :table_id => table_id, :message => @message}) + # end + def show display_type = Lookup.find_by_lookup_type("display_type") if !display_type.nil? && display_type.value.to_i ==2 @@ -317,6 +342,7 @@ class Origami::PaymentsController < BaseOrigamiController if Sale.exists?(sale_id) @cash = 0.0 + @kbz_pay_amount = 0.0 @other = 0.0 @ppamount = 0.0 @visacount= 0.0 @@ -341,6 +367,9 @@ class Origami::PaymentsController < BaseOrigamiController @pdf_view = @lookup_pdf.value end + amount = SalePayment.get_kbz_pay_amount(sale_id, current_user) + @kbz_pay_amount += amount.to_f + #for changable on/off @changable_tax = true lookup_changable_tax = Lookup.collection_of('changable_tax') @@ -463,39 +492,40 @@ class Origami::PaymentsController < BaseOrigamiController else @sale_payment_data = SalePayment.get_sale_payments(@sale_data) end - @sale_payment_data.each do |spay| - if spay.payment_method == "cash" - @cash += spay.payment_amount - end - if spay.payment_method !="creditnote" - @other_payment += spay.payment_amount - end + @sale_payment_data.each do |spay| + if spay.payment_method == "cash" + @cash += spay.payment_amount + end + if spay.payment_method !="creditnote" + @other_payment += spay.payment_amount + end + + if spay.payment_method == "mpu" + @other += spay.payment_amount + elsif spay.payment_method == "paypar" + @ppamount += spay.payment_amount + elsif spay.payment_method == "visa" + @visacount += spay.payment_amount + elsif spay.payment_method == "jcb" + @jcbcount += spay.payment_amount + elsif spay.payment_method == "master" + @mastercount += spay.payment_amount + elsif spay.payment_method == "unionpay" + @unionpaycount += spay.payment_amount + elsif spay.payment_method == "JunctionPay" + @junctionpaycount += spay.payment_amount + elsif spay.payment_method == "creditnote" + @credit += spay.payment_amount + elsif spay.payment_method == "paymal" + @paymalcount += spay.payment_amount + elsif spay.payment_method == "alipay" + @alipaycount += spay.payment_amount + elsif spay.payment_method == "dinga" + @dingacount += spay.payment_amount + elsif spay.payment_method == "giftvoucher" + @giftvouchercount += spay.payment_amount + end - if spay.payment_method == "mpu" - @other += spay.payment_amount - elsif spay.payment_method == "paypar" - @ppamount += spay.payment_amount - elsif spay.payment_method == "visa" - @visacount += spay.payment_amount - elsif spay.payment_method == "jcb" - @jcbcount += spay.payment_amount - elsif spay.payment_method == "master" - @mastercount += spay.payment_amount - elsif spay.payment_method == "unionpay" - @unionpaycount += spay.payment_amount - elsif spay.payment_method == "JunctionPay" - @junctionpaycount += spay.payment_amount - elsif spay.payment_method == "creditnote" - @credit += spay.payment_amount - elsif spay.payment_method == "paymal" - @paymalcount += spay.payment_amount - elsif spay.payment_method == "alipay" - @alipaycount += spay.payment_amount - elsif spay.payment_method == "dinga" - @dingacount += spay.payment_amount - elsif spay.payment_method == "giftvoucher" - @giftvouchercount += spay.payment_amount - end end end end diff --git a/app/controllers/origami/table_invoices_controller.rb b/app/controllers/origami/table_invoices_controller.rb index 0e94c7c4..7082e44c 100755 --- a/app/controllers/origami/table_invoices_controller.rb +++ b/app/controllers/origami/table_invoices_controller.rb @@ -30,7 +30,7 @@ class Origami::TableInvoicesController < BaseOrigamiController end def show - puts 'Catch me if you can.......................' + # puts 'Catch me if you can.......................' @table = DiningFacility.find(params[:table_id]) @membership = MembershipSetting::MembershipSetting @payment_methods = PaymentMethodSetting.all diff --git a/app/controllers/reports/payment_method_controller.rb b/app/controllers/reports/payment_method_controller.rb index 659b51e4..414c4e07 100644 --- a/app/controllers/reports/payment_method_controller.rb +++ b/app/controllers/reports/payment_method_controller.rb @@ -2,7 +2,7 @@ class Reports::PaymentMethodController < BaseReportController # authorize_resource :class => false def index - @payments = [["All Payment",''],["Cash Payment","cash"], ["Credit Payment","creditnote"], + @payments = [["All Payment",''],["Cash Payment","cash"], ["KBZ Payment", KbzPay::KBZ_PAY], ["Credit Payment","creditnote"], ["FOC Payment","foc"], ["MPU Payment","mpu"], ["Visa Payment","visa"], ["Master Payment","master"], ["JCB Payment","jcb"],["UnionPay Payment","unionpay"], ["Alipay Payment","alipay"],["Paymal Payment", "paymal"],["Dinga Payment","dinga"], diff --git a/app/models/kbz_pay.rb b/app/models/kbz_pay.rb index 2fb740f2..c342a035 100644 --- a/app/models/kbz_pay.rb +++ b/app/models/kbz_pay.rb @@ -1,5 +1,7 @@ class KbzPay + KBZ_PAY = 'KBZPay' + def self.pay(amount, receipt_no) datetime = DateTime.now.strftime("%d%m%Y%H%M") @@ -14,26 +16,28 @@ class KbzPay kbz_callback_url = "https://staging-v2.doemal.com/api/v3/ordering/kbz_callback" nounce_str = SecureRandom.base64(32).first(32).upcase - params = "appid="+kbz_app_id+"&merch_code="+kbz_merch_code+"&merch_order_id="+receipt_no.to_s+"&method="+kbz_method+"&nonce_str="+nounce_str.to_s+"¬ify_url="+ kbz_callback_url + "×tamp="+datetime+"&total_amount="+amount.to_s+"&trade_type="+kbz_trade_type+"&trans_currency="+ kbz_currency+"&version="+kbz_version+"&key="+kbz_api_key + params = "appid="+kbz_app_id+"&merch_code="+kbz_merch_code+"&merch_order_id="+receipt_no.to_s+"&method="+kbz_method+"&nonce_str="+nounce_str.to_s+"¬ify_url="+ kbz_callback_url + "&timeout_express=20m×tamp="+datetime+"&total_amount="+amount.to_s+"&trade_type="+kbz_trade_type+"&trans_currency="+ kbz_currency+"&version="+kbz_version+"&key="+kbz_api_key Rails.logger.info params sign = Digest::SHA256.hexdigest(params) - str = {"timestamp": datetime, - "method": kbz_method, - "notify_url": kbz_callback_url, - "nonce_str": nounce_str.to_s, - "sign_type": "SHA256", - "sign": sign, - "version": kbz_version, - "biz_content": { - "merch_order_id": receipt_no, - "merch_code": kbz_merch_code, - "appid": kbz_app_id, - "trade_type": kbz_trade_type, - "total_amount": amount.to_s, - "trans_currency": kbz_currency - } - } + str = { + "timestamp": datetime, + "method": kbz_method, + "notify_url": kbz_callback_url, + "nonce_str": nounce_str.to_s, + "sign_type": "SHA256", + "sign": sign, + "version": kbz_version, + "biz_content": { + "merch_order_id": receipt_no, + "merch_code": kbz_merch_code, + "appid": kbz_app_id, + "trade_type": kbz_trade_type, + "total_amount": amount.to_s, + "timeout_express": "20m", + "trans_currency": kbz_currency + } + } result = HTTParty.post(kbz_provider_url, :body => { :Request => str}.to_json, @@ -51,4 +55,71 @@ class KbzPay end -end + def self.query(receipt_no, current_user) + amount = 0 + datetime = DateTime.now.strftime("%d%m%Y%H%M") + kbz_app_id = "kp1e78f7efddca190042638341afb88d" + kbz_merch_code = "200004" + kbz_method = 'kbz.payment.queryorder' + kbz_trade_type = "APP" + kbz_api_key = "code2lab123456" + kbz_version = "1.0" + kbz_provider_url = "http://api.kbzpay.com/payment/gateway/uat/queryorder" + kbz_currency = "MMK" + kbz_callback_url = "https://staging-v2.doemal.com/api/v3/ordering/kbz_callback" + nounce_str = SecureRandom.base64(32).first(32).upcase + + params = "appid="+kbz_app_id+"&merch_code="+kbz_merch_code+"&merch_order_id="+receipt_no.to_s+"&method="+kbz_method+"&nonce_str="+nounce_str.to_s+"×tamp="+datetime+"&version="+kbz_version+"&key="+kbz_api_key + + Rails.logger.info params + sign = Digest::SHA256.hexdigest(params) + str = {"timestamp": datetime, + "method": kbz_method, + "nonce_str": nounce_str.to_s, + "sign_type": "SHA256", + "sign": sign, + "version": kbz_version, + "biz_content": { + "merch_order_id": receipt_no, + "merch_code": kbz_merch_code, + "appid": kbz_app_id + } + } + + result = HTTParty.post(kbz_provider_url, + :body => { :Request => str}.to_json, + :headers => { 'Content-Type' => 'application/json', 'Accept' => 'application/json' } + ) + Rails.logger.info result + Rails.logger.info "........................." + if result['Response']['result'] == "SUCCESS" + if result['Response']['trade_status'] == "PAY_SUCCESS" + merch_order_id = result['Response']['merch_order_id'] + cash = result['Response']['total_amount'] + + sp = SalePayment.find(merch_order_id) + if !sp.nil? + if sp.payment_status == 'pending' + saleObj = Sale.find(sp.sale_id) + if sp.process_payment(saleObj, current_user, cash, KbzPay::KBZ_PAY) + amount = cash + end + end + end + + # return true, "successfully paid by KBZ PAY" + elsif result['Response']['trade_status'] == "PAY_FAILED" + + # return false, "pay failed by KBZ PAY" + elsif result['Response']['trade_status'] == "WAIT_PAY" + # return false , "Waiting to pay by KBZ PAY" + end + else + #FAIL result + # return false, "pay by KBZ PAY has failed" + end + + return amount + end + +end \ No newline at end of file diff --git a/app/models/payment.rb b/app/models/payment.rb new file mode 100644 index 00000000..8635cbdb --- /dev/null +++ b/app/models/payment.rb @@ -0,0 +1,6 @@ +class Payment + + # def self.pay(getCloudDomain, cash, sale_id, member_info, type, tax_type, path, latest_order_no, shop_detail, current_user, pay_from, sale_payment_id) + + # end +end \ No newline at end of file diff --git a/app/models/sale.rb b/app/models/sale.rb index b6f98b2a..779c21c6 100644 --- a/app/models/sale.rb +++ b/app/models/sale.rb @@ -921,6 +921,7 @@ def self.daily_sales_list(from,to) AND DATE_FORMAT(CONVERT_TZ(s.receipt_date,'+00:00','+06:30'),'%Y-%m-%d') = DATE_FORMAT(CONVERT_TZ(sales.receipt_date,'+00:00','+06:30'),'%Y-%m-%d')" payments_total = Sale.select("CAST((CONVERT_TZ(sales.receipt_date,'+00:00','+06:30')) AS DATE) as sale_date, + SUM(case when (sale_payments.payment_method='KBZPay') then sale_payments.payment_amount else 0 end) as kbzpay_amount, SUM(case when (sale_payments.payment_method='mpu') then sale_payments.payment_amount else 0 end) as mpu_amount, SUM(case when (sale_payments.payment_method='master') then sale_payments.payment_amount else 0 end) as master_amount, SUM(case when (sale_payments.payment_method='visa') then sale_payments.payment_amount else 0 end) as visa_amount, @@ -970,6 +971,7 @@ def self.daily_sales_list(from,to) :paypar_amount => pay.paypar_amount, :unionpay_amount => pay.unionpay_amount, :alipay_amount => pay.alipay_amount, + :kbzpay_amount => pay.kbzpay_amount, :paymal_amount => pay.paymal_amount, :dinga_amount => pay.dinga_amount, :junctionpay_amount => pay.junctionpay_amount, @@ -1453,6 +1455,7 @@ def self.get_payment_method_by_shift(shift_sale_range,shift,from,to,payment_type SUM(case when (sale_payments.payment_method='paypar') then sale_payments.payment_amount else 0 end) as paypar_amount, SUM(case when (sale_payments.payment_method='unionpay') then sale_payments.payment_amount else 0 end) as unionpay_amount, SUM(case when (sale_payments.payment_method='alipay') then sale_payments.payment_amount else 0 end) as alipay_amount, + SUM(case when (sale_payments.payment_method='KBZPay') then sale_payments.payment_amount else 0 end) as kbzpay_amount, SUM(case when (sale_payments.payment_method='paymal') then sale_payments.payment_amount else 0 end) as paymal_amount, SUM(case when (sale_payments.payment_method='dinga') then sale_payments.payment_amount else 0 end) as dinga_amount, SUM(case when (sale_payments.payment_method='JunctionPay') then sale_payments.payment_amount else 0 end) as junctionpay_amount, diff --git a/app/models/sale_payment.rb b/app/models/sale_payment.rb index 1cfb53f3..d0943cab 100755 --- a/app/models/sale_payment.rb +++ b/app/models/sale_payment.rb @@ -29,6 +29,37 @@ class SalePayment < ApplicationRecord end end + def self.get_kbz_pay_amount(sale_id, current_user) + amount = 0 + sale_payment = SalePayment.where('sale_id=? and payment_status!=?', sale_id, 'dead').last + if !sale_payment.nil? + if sale_payment.payment_status == 'pending' + amount = KbzPay.query(sale_payment.id, current_user) + elsif sale_payment.payment_status == 'paid' + amount = sale_payment.payment_amount + end + end + + return amount + end + + def process_kbz_payment(sale_id, grand_total, pay_amount, status) + if status == 'pending' + SalePayment.where("sale_id=? and payment_method=? and payment_status=?", sale_id, KbzPay::KBZ_PAY, 'pending').update_all(:payment_status => 'dead') + end + + self.sale_id = sale_id + self.payment_method = KbzPay::KBZ_PAY + self.payment_amount = self.payment_amount.to_i + pay_amount.to_i + if grand_total > 0 + self.outstanding_amount = grand_total.to_i - pay_amount.to_i + else + self.outstanding_amount = self.outstanding_amount.to_i - pay_amount.to_i + end + self.payment_status = status + return self.save + end + def process_payment(invoice, action_by, cash_amount, payment_method,remark=nil,payment_for=false) self.sale = invoice self.received_amount = cash_amount @@ -90,8 +121,8 @@ class SalePayment < ApplicationRecord payment_status,membership_data = dinga_payment when "GiftVoucher" payment_status = giftvoucher_payment - when "KbzPay" - payment_status = giftvoucher_payment + when KbzPay::KBZ_PAY + payment_status = kbz_payment else puts "it was something else" end @@ -346,6 +377,7 @@ class SalePayment < ApplicationRecord end payment_status = false + self.payment_method = "cash" self.payment_amount = self.received_amount if !payment_for @@ -354,8 +386,10 @@ class SalePayment < ApplicationRecord credit_sale_payment = SalePayment.get_credit_total_left(self.sale_id)[0] ? SalePayment.get_credit_total_left(self.sale_id)[0].payment_amount.to_f : 0 ###need to calculate creditnote total in here self.outstanding_amount = credit_sale_payment - self.received_amount.to_f end + self.payment_status = "paid" payment_status = self.save! + if !payment_for sale_update_payment_status(self.received_amount,status) end @@ -586,11 +620,13 @@ class SalePayment < ApplicationRecord def kbz_payment payment_status = false - status, response = KbzPay.pay(amount, receipt_no) - if status - payment_status = true - return - end + self.payment_amount = self.received_amount + self.payment_reference = self.payment_reference + self.outstanding_amount = self.sale.grand_total.to_f - self.received_amount.to_f + self.payment_status = "paid" + payment_status = self.save! + sale_update_payment_status(self.received_amount) + return payment_status end def sale_update_payment_status(paid_amount,check_foc = false) @@ -602,6 +638,7 @@ class SalePayment < ApplicationRecord sObj = Sale.find(self.sale_id) is_credit = 0 is_foc = 0 + is_kbz_pay = 0 method_status = false sObj.sale_payments.each do |spay| all_received_amount += spay.payment_amount.to_f @@ -611,7 +648,10 @@ class SalePayment < ApplicationRecord if spay.payment_method == "foc" is_foc = 1 end - if spay.payment_method == "cash" || spay.payment_method == "foc" || spay.payment_method == "creditnote" + if spay.payment_method == KbzPay::KBZ_PAY + is_kbz_pay = 1 + end + if spay.payment_method == "cash" || spay.payment_method == "foc" || spay.payment_method == "creditnote" || spay.payment_method == 'kbzpay' method_status = true end end @@ -629,6 +669,10 @@ class SalePayment < ApplicationRecord self.sale.payment_status = "foc" end + if is_kbz_pay > 0 + self.sale.payment_status = 'paid' + end + self.sale.sale_status = "completed" if MembershipSetting.find_by_rebate(1) && is_foc == 0 && is_credit == 0 diff --git a/app/pdf/receipt_bill_pdf.rb b/app/pdf/receipt_bill_pdf.rb index 445a3f84..9a1b64e5 100755 --- a/app/pdf/receipt_bill_pdf.rb +++ b/app/pdf/receipt_bill_pdf.rb @@ -689,9 +689,9 @@ class ReceiptBillPdf < Prawn::Document if status == 'Frt' move_down line_move move_down line_move - text "KBZ Pay", :size => self.header_font_size+2, :align => :center + text "Scan to pay with KBZ Pay", :size => self.header_font_size, :align => :center move_down line_move - print_qr_code(qr_code, pos: [30, cursor], extent: 160, stroke: false, dot: 1000) + print_qr_code(qr_code, pos: [39, cursor], extent: 161, stroke: false, dot: 1000) # stroke_horizontal_rule move_down line_move end diff --git a/app/views/origami/home/show.html.erb b/app/views/origami/home/show.html.erb index eff2812b..03fe1943 100755 --- a/app/views/origami/home/show.html.erb +++ b/app/views/origami/home/show.html.erb @@ -540,6 +540,8 @@ + + @@ -1072,6 +1074,24 @@ } }); + // $('#kbz_query').on('click', function(){ + // var sale_id = $('#sale_id').val(); + // var dining_id = "<%= @dining.id %>"; + // // window.location.href = '/origami/payment/kbz_query/'+ sale_id; + // $.ajax({ + // type: 'POST', + // data: 'table_id='+dining_id, + // url: '/origami/payment/kbz_query/'+sale_id, + // success: function(result){ + // if (result.status == true) { + // window.location.href = '/origami'; + // }else{ + // location.reload() + // } + // } + // }) + // }) + // Bill Request $('#request_bills').click(function () { var order_id = $('#save_order_id').attr('data-order'); diff --git a/app/views/origami/payments/show.html.erb b/app/views/origami/payments/show.html.erb index 6c86805b..ab62eb7e 100755 --- a/app/views/origami/payments/show.html.erb +++ b/app/views/origami/payments/show.html.erb @@ -201,7 +201,14 @@ <% else %> <% end %> - <% if @other == 0.0 && @ppamount == 0.0 && @visacount == 0.0 && @jcbcount == 0.0 && @mastercount == 0.0 && @unionpaycount == 0.0 && @alipaycount == 0.0 && @paymalcount == 0.0 && @junctionpaycount == 0.0 && @dingacount == 0.0 && @giftvouchercount == 0.0 %> + <% if @kbz_pay_amount > 0.0 %> +
+
Other Payments (KBZ Pay)
+
+ <%= number_with_precision(@kbz_pay_amount, precision: precision.to_i) rescue number_with_precision(0, precision: precision.to_i) %> +
+
+ <% elsif @other == 0.0 && @ppamount == 0.0 && @visacount == 0.0 && @jcbcount == 0.0 && @mastercount == 0.0 && @unionpaycount == 0.0 && @alipaycount == 0.0 && @paymalcount == 0.0 && @junctionpaycount == 0.0 && @dingacount == 0.0 && @giftvouchercount == 0.0 %>
Other Payments
@@ -400,6 +407,10 @@ + <% if current_login_employee.role == "cashier" %> @@ -782,6 +793,10 @@ $(document).ready(function(){ }); + $("#refresh").on('click', function(){ + window.location.reload(); + }) + if(localStorage.getItem("cash") == null || localStorage.getItem("cash") == 'null'){ } @@ -867,6 +882,11 @@ $(document).ready(function(){ var cash = $('#cash').text(); var credit = $('#credit').text(); var card = $('#card').text(); + var kbz_amt = "<%= @kbz_pay_amount %>"; + var is_kbz = false; + if (kbz_amt > 0) { + is_kbz = true + } var tax_type = localStorage.getItem("tax_type") ? localStorage.getItem("tax_type") : 'all'; if (credit <= 0 && (!location.pathname.includes("credit_payment"))) { @@ -884,7 +904,7 @@ $(document).ready(function(){ $.ajax({type: "POST", url: url, - data: "cash="+ cash + "&sale_id=" + sale_id + "&type=" + cashier_type + "&tax_type=" + tax_type, + data: "cash="+ cash + "&sale_id=" + sale_id + "&type=" + cashier_type + "&tax_type=" + tax_type + "&is_kbz=" + is_kbz, success:function(result){ /* start delete receipt no in first bill*/ if(($("#receipt_no").html()!=undefined) && ($("#receipt_no").html()!="")){ diff --git a/app/views/reports/dailysale/index.html.erb b/app/views/reports/dailysale/index.html.erb index d72be97c..5f7e35e0 100755 --- a/app/views/reports/dailysale/index.html.erb +++ b/app/views/reports/dailysale/index.html.erb @@ -45,6 +45,9 @@ <% if @payment_methods.include? ("UNIONPAY") %> <%= t("views.right_panel.detail.unionpay_sales") %> <% end %> + <% if @payment_methods.include? ("KBZPay") %> + <%= t("views.right_panel.detail.kbzpay_sales") %> + <% end %> <% if @payment_methods.include? ("Alipay") %> <%= t("views.right_panel.detail.alipay_sales") %> <% end %> @@ -104,6 +107,7 @@ <% credit = 0 %> <% foc = 0 %> <% discount = 0 %> + <% kbzpay = 0 %> <% total = 0 %> <% grand_total = 0 %> <% old_grand_total = 0 %> @@ -125,6 +129,7 @@ <% credit += sale[:credit_amount] %> <% foc += sale[:foc_amount] %> <% discount += sale[:total_discount] %> + <% kbzpay += sale[:kbzpay_amount] %> <% total += sale[:grand_total].to_f + sale[:rounding_adj].to_f %> <% grand_total += sale[:grand_total].to_f %> <% old_grand_total += sale[:old_grand_total].to_f %> @@ -151,6 +156,9 @@ <% if @payment_methods.include? ("Alipay") %> <%= number_with_precision(sale[:alipay_amount], precision:precision.to_i,delimiter:delimiter) rescue '-'%> <% end %> + <% if @payment_methods.include? ("KBZPay") %> + <%= number_with_precision(sale[:kbzpay_amount], precision:precision.to_i,delimiter:delimiter) rescue '-'%> + <% end %> <% if @payment_methods.include? ("PAYMAL") %> <%= number_with_precision(sale[:paymal_amount], precision:precision.to_i,delimiter:delimiter) rescue '-'%> <% end %> @@ -216,6 +224,12 @@ <% end %> <%= number_with_precision(alipay, precision:precision.to_i,delimiter:delimiter) rescue '-'%> <% end %> + <% if @payment_methods.include? ("KBZPay") %> + <% if !request.user_agent.include? "Mobile" %> + <% colspan += 1 %> + <% end %> + <%= number_with_precision(kbzpay, precision:precision.to_i,delimiter:delimiter) rescue '-'%> + <% end %> <% if @payment_methods.include? ("PAYMAL") %> <% if !request.user_agent.include? "Mobile" %> <% colspan += 1 %> diff --git a/app/views/reports/dailysale/index.xls.erb b/app/views/reports/dailysale/index.xls.erb index d441e48e..45e0264d 100755 --- a/app/views/reports/dailysale/index.xls.erb +++ b/app/views/reports/dailysale/index.xls.erb @@ -33,6 +33,9 @@ <% if @payment_methods.include? ("UNIONPAY") %> <%= t("views.right_panel.detail.unionpay_sales") %> <% end %> + <% if @payment_methods.include? ("KBZPay") %> + <%= t("views.right_panel.detail.kbzpay_sales") %> + <% end %> <% if @payment_methods.include? ("Alipay") %> <%= t("views.right_panel.detail.alipay_sales") %> <% end %> @@ -92,6 +95,7 @@ <% credit = 0 %> <% foc = 0 %> <% discount = 0 %> + <% kbzpay = 0 %> <% total = 0 %> <% grand_total = 0 %> <% old_grand_total = 0 %> @@ -113,6 +117,7 @@ <% credit += sale[:credit_amount] %> <% foc += sale[:foc_amount] %> <% discount += sale[:total_discount] %> + <% kbzpay += sale[:kbzpay_amount] %> <% total += sale[:grand_total].to_f + sale[:rounding_adj].to_f %> <% grand_total += sale[:grand_total].to_f %> <% old_grand_total += sale[:old_grand_total].to_f %> @@ -139,6 +144,9 @@ <% if @payment_methods.include? ("Alipay") %> <%= number_with_delimiter(sprintf("%.2f",sale[:alipay_amount]),delimiter => ',') rescue '-'%> <% end %> + <% if @payment_methods.include? ("KBZPay") %> + <%= number_with_precision(sale[:kbzpay_amount], precision:precision.to_i,delimiter:delimiter) rescue '-'%> + <% end %> <% if @payment_methods.include? ("PAYMAL") %> <%= number_with_delimiter(sprintf("%.2f",sale[:paymal_amount]),delimiter => ',') rescue '-'%> <% end %> @@ -192,6 +200,10 @@ <% colspan += 1 %> <%= number_with_delimiter(sprintf("%.2f",alipay),delimiter => ',') rescue '-'%> <% end %> + <% if @payment_methods.include? ("KBZPay") %> + <% colspan += 1 %> + <%= number_with_delimiter(sprintf("%.2f",kbzpay),delimiter => ',') rescue '-'%> + <% end %> <% if @payment_methods.include? ("PAYMAL") %> <% colspan += 1 %> <%= number_with_delimiter(sprintf("%.2f",paymal),delimiter => ',') rescue '-'%> diff --git a/app/views/reports/payment_method/index.html.erb b/app/views/reports/payment_method/index.html.erb index f805bd08..8dd47a94 100755 --- a/app/views/reports/payment_method/index.html.erb +++ b/app/views/reports/payment_method/index.html.erb @@ -46,7 +46,8 @@ <%= t("views.right_panel.detail.jcb_sales") %> <%= t("views.right_panel.detail.unionpay_sales") %> <%= t("views.right_panel.detail.alipay_sales") %> - <%= t("views.right_panel.detail.paymal_sales") %> + <%= t("views.right_panel.detail.kbzpay_sales") %> + <%= t("views.right_panel.detail.dinga_sales") %> <%= t("views.right_panel.detail.junctionpay_sales") %> <%= t("views.right_panel.detail.redeem_sales") %> @@ -78,7 +79,8 @@ <%= number_with_precision(sale[:jcb_amount], precision: precision.to_i ,delimiter: delimiter) rescue '-' %> <%= number_with_precision(sale[:unionpay_amount], precision: precision.to_i ,delimiter: delimiter) rescue '-' %> <%= number_with_precision(sale[:alipay_amount], precision: precision.to_i ,delimiter: delimiter) rescue '-' %> - <%= number_with_precision(sale[:paymal_amount], precision: precision.to_i ,delimiter: delimiter) rescue '-' %> + <%= number_with_precision(sale[:kbzpay_amount], precision: precision.to_i ,delimiter: delimiter) rescue '-' %> + <%= number_with_precision(sale[:dinga_amount], precision: precision.to_i ,delimiter: delimiter) rescue '-' %> <%= number_with_precision(sale[:junctionpay_amount], precision: precision.to_i ,delimiter: delimiter) rescue '-' %> <%= number_with_precision(sale[:paypar_amount], precision: precision.to_i ,delimiter: delimiter) rescue '-' %> diff --git a/app/views/reports/payment_method/index.xls.erb b/app/views/reports/payment_method/index.xls.erb index 047df5f9..723a9ffd 100755 --- a/app/views/reports/payment_method/index.xls.erb +++ b/app/views/reports/payment_method/index.xls.erb @@ -33,7 +33,8 @@ <%= t("views.right_panel.detail.jcb_sales") %> <%= t("views.right_panel.detail.unionpay_sales") %> <%= t("views.right_panel.detail.alipay_sales") %> - <%= t("views.right_panel.detail.paymal_sales") %> + <%= t("views.right_panel.detail.kbzpay_sales") %> + <%= t("views.right_panel.detail.dinga_sales") %> <%= t("views.right_panel.detail.junctionpay_sales") %> <%= t("views.right_panel.detail.redeem_sales") %> @@ -65,7 +66,8 @@ <%= number_with_precision(sale[:jcb_amount], precision: precision.to_i ,delimiter: delimiter) rescue '-' %> <%= number_with_precision(sale[:unionpay_amount], precision: precision.to_i ,delimiter: delimiter) rescue '-' %> <%= number_with_precision(sale[:alipay_amount], precision: precision.to_i ,delimiter: delimiter) rescue '-' %> - <%= number_with_precision(sale[:paymal_amount], precision: precision.to_i ,delimiter: delimiter) rescue '-' %> + <%= number_with_precision(sale[:kbzpay_amount], precision: precision.to_i ,delimiter: delimiter) rescue '-' %> + <%= number_with_precision(sale[:dinga_amount], precision: precision.to_i ,delimiter: delimiter) rescue '-' %> <%= number_with_precision(sale[:junctionpay_amount], precision: precision.to_i ,delimiter: delimiter) rescue '-' %> <%= number_with_precision(sale[:paypar_amount], precision: precision.to_i ,delimiter: delimiter) rescue '-' %> diff --git a/config/routes.rb b/config/routes.rb index 797d7c98..fa085c5a 100755 --- a/config/routes.rb +++ b/config/routes.rb @@ -221,6 +221,7 @@ scope "(:locale)", locale: /en|mm/ do post 'payment/:type/foc' => 'payments#foc', :defaults => {:format => 'json'} post 'payment/cash' => 'payments#create' + # post 'payment/kbz_query/:sale_id' => 'payments#kbz_query', :defaults => {:format => 'json'} post 'payment/mpu' => "mpu#create" post 'payment/jcb' => "jcb#create" post 'payment/master' => "master#create" diff --git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xKzoW=^ePgjm!Ujc@_ z@;%vGiDm?WD>T+gfhug_u*u!CuO{4 ztbrc?D|OiJ8_)EB|FT$-6kg+_Xy|!rI}YZ`YOW}kXg>10K2`%1=#Geq7Ob`Pw<$4t+gb8D+F%e7+W)r3sQ-`U?Y`!Ja@W@C& zV@2;l0k)95I|QP8sqm0v$MN*y2V3H{g@lwj*sTc?*DaZGNr>}`Y4NCZJ+=6>xY|l9 vEGPL5#n(GQ={_qSDz0v8RDDF$R({$>D{Ju> Date: Wed, 26 Jun 2019 12:05:37 +0630 Subject: [PATCH 02/12] kbzpay --- app/controllers/origami/payments_controller.rb | 5 ++--- app/models/sale_payment.rb | 9 +++++++-- config/puma.rb | 2 +- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/app/controllers/origami/payments_controller.rb b/app/controllers/origami/payments_controller.rb index 4224629b..1311ef7c 100755 --- a/app/controllers/origami/payments_controller.rb +++ b/app/controllers/origami/payments_controller.rb @@ -102,7 +102,6 @@ class Origami::PaymentsController < BaseOrigamiController printer = Printer::ReceiptPrinter.new(print_settings) - #TODO :: KBZPAY ( QR ) # On/Off setting ( show or not qr ) # qrCode = "00020101021202021110500346KBZ005ab0ed5c1ed09d1c4585ff1313170389160831435294600062000040732kp1e78f7efddca190042638341afb88d50200006KBZPay0106KBZPay5303MMK5802MM62170813PAY_BY_QRCODE64060002my6304FBBD" @@ -169,8 +168,8 @@ class Origami::PaymentsController < BaseOrigamiController # salePayment = SalePayment.find(sale_payment_id) # salePayment.process_kbz_payment(salePayment.sale_id, sale_data.grand_total, cash, 'paid') # else - # sp = SalePayment.where('sale_id=? and payment_method=? and payment_status=?', sale_id, 'kbzpay', 'paid').last - if sp.nil? #is_kbz + sp = SalePayment.where('sale_id=? and payment_method=? and payment_status=?', sale_id, 'kbzpay', 'paid').last + if is_kbz == 'false' Rails.logger.info '################ CASH PAYMENT #################' sale_payment = SalePayment.new if path.include? ("credit_payment") diff --git a/app/models/sale_payment.rb b/app/models/sale_payment.rb index d0943cab..21e8fda6 100755 --- a/app/models/sale_payment.rb +++ b/app/models/sale_payment.rb @@ -31,7 +31,7 @@ class SalePayment < ApplicationRecord def self.get_kbz_pay_amount(sale_id, current_user) amount = 0 - sale_payment = SalePayment.where('sale_id=? and payment_status!=?', sale_id, 'dead').last + sale_payment = SalePayment.where('sale_id=? and payment_method=? and payment_status!=?', sale_id, KbzPay::KBZ_PAY, 'dead').last if !sale_payment.nil? if sale_payment.payment_status == 'pending' amount = KbzPay.query(sale_payment.id, current_user) @@ -631,6 +631,7 @@ class SalePayment < ApplicationRecord def sale_update_payment_status(paid_amount,check_foc = false) #update amount_outstanding + Rails.logger.info '####### SALE UPDATE PAYMENT STATUS #######' self.sale.amount_received = self.sale.amount_received.to_f + paid_amount.to_f self.sale.save! self.sale.amount_changed = self.sale.amount_received.to_f - self.sale.grand_total.to_f @@ -656,6 +657,10 @@ class SalePayment < ApplicationRecord end end + Rails.logger.info self.sale.grand_total + Rails.logger.info all_received_amount + Rails.logger.info '@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@' + if (self.sale.grand_total <= all_received_amount) && method_status if is_credit == 0 self.sale.payment_status = "paid" @@ -669,7 +674,7 @@ class SalePayment < ApplicationRecord self.sale.payment_status = "foc" end - if is_kbz_pay > 0 + if is_kbz_pay == 1 self.sale.payment_status = 'paid' end diff --git a/config/puma.rb b/config/puma.rb index a0dae8b3..fd89392f 100755 --- a/config/puma.rb +++ b/config/puma.rb @@ -1,6 +1,6 @@ application_path="#{File.expand_path("../..", __FILE__)}" directory application_path -environment ENV.fetch("RAILS_ENV") { "production" } +#environment ENV.fetch("RAILS_ENV") { "production" } environment "production" pidfile "#{application_path}/tmp/puma/pid" state_path "#{application_path}/tmp/puma/state" From 2e306a6339b0820c0e7c96147a73cd80e6100a11 Mon Sep 17 00:00:00 2001 From: Zoey Date: Wed, 26 Jun 2019 12:18:17 +0630 Subject: [PATCH 03/12] kbz pay fixed --- .../origami/payments_controller.rb | 2 +- app/models/sale_payment.rb | 7 +------ config/initializers/action_controller.rb | 10 +++++----- config/puma.rb | 20 +++++++++---------- 4 files changed, 17 insertions(+), 22 deletions(-) diff --git a/app/controllers/origami/payments_controller.rb b/app/controllers/origami/payments_controller.rb index 1311ef7c..560b43f3 100755 --- a/app/controllers/origami/payments_controller.rb +++ b/app/controllers/origami/payments_controller.rb @@ -168,7 +168,7 @@ class Origami::PaymentsController < BaseOrigamiController # salePayment = SalePayment.find(sale_payment_id) # salePayment.process_kbz_payment(salePayment.sale_id, sale_data.grand_total, cash, 'paid') # else - sp = SalePayment.where('sale_id=? and payment_method=? and payment_status=?', sale_id, 'kbzpay', 'paid').last + # sp = SalePayment.where('sale_id=? and payment_method=? and payment_status=?', sale_id, 'kbzpay', 'paid').last if is_kbz == 'false' Rails.logger.info '################ CASH PAYMENT #################' sale_payment = SalePayment.new diff --git a/app/models/sale_payment.rb b/app/models/sale_payment.rb index 21e8fda6..db44dd10 100755 --- a/app/models/sale_payment.rb +++ b/app/models/sale_payment.rb @@ -631,7 +631,6 @@ class SalePayment < ApplicationRecord def sale_update_payment_status(paid_amount,check_foc = false) #update amount_outstanding - Rails.logger.info '####### SALE UPDATE PAYMENT STATUS #######' self.sale.amount_received = self.sale.amount_received.to_f + paid_amount.to_f self.sale.save! self.sale.amount_changed = self.sale.amount_received.to_f - self.sale.grand_total.to_f @@ -652,15 +651,11 @@ class SalePayment < ApplicationRecord if spay.payment_method == KbzPay::KBZ_PAY is_kbz_pay = 1 end - if spay.payment_method == "cash" || spay.payment_method == "foc" || spay.payment_method == "creditnote" || spay.payment_method == 'kbzpay' + if spay.payment_method == "cash" || spay.payment_method == "foc" || spay.payment_method == "creditnote" || spay.payment_method == KbzPay::KBZ_PAY method_status = true end end - Rails.logger.info self.sale.grand_total - Rails.logger.info all_received_amount - Rails.logger.info '@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@' - if (self.sale.grand_total <= all_received_amount) && method_status if is_credit == 0 self.sale.payment_status = "paid" 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! From 52a375f2a4e15701f3a7f228232b260c0c6145ea Mon Sep 17 00:00:00 2001 From: Zoey Date: Wed, 26 Jun 2019 13:35:27 +0630 Subject: [PATCH 04/12] kbzpay payment updated --- .../origami/payments_controller.rb | 4 +++- app/models/sale_payment.rb | 7 ++++++- app/models/shift_sale.rb | 1 + app/pdf/close_cashier_pdf.rb | 10 ++++++++++ config/initializers/action_controller.rb | 10 +++++----- config/puma.rb | 20 +++++++++---------- 6 files changed, 35 insertions(+), 17 deletions(-) diff --git a/app/controllers/origami/payments_controller.rb b/app/controllers/origami/payments_controller.rb index 560b43f3..ec8a6958 100755 --- a/app/controllers/origami/payments_controller.rb +++ b/app/controllers/origami/payments_controller.rb @@ -168,7 +168,7 @@ class Origami::PaymentsController < BaseOrigamiController # salePayment = SalePayment.find(sale_payment_id) # salePayment.process_kbz_payment(salePayment.sale_id, sale_data.grand_total, cash, 'paid') # else - # sp = SalePayment.where('sale_id=? and payment_method=? and payment_status=?', sale_id, 'kbzpay', 'paid').last + sp = SalePayment.where('sale_id=? and payment_method=? and payment_status=?', sale_id, 'kbzpay', 'paid').last if is_kbz == 'false' Rails.logger.info '################ CASH PAYMENT #################' sale_payment = SalePayment.new @@ -177,6 +177,8 @@ class Origami::PaymentsController < BaseOrigamiController else sale_payment.process_payment(saleObj, current_user, cash, "cash") end + else + sp.kbz_edit_sale_payment(sp.received_amount.to_f, current_user) end # end diff --git a/app/models/sale_payment.rb b/app/models/sale_payment.rb index db44dd10..53d9f1cc 100755 --- a/app/models/sale_payment.rb +++ b/app/models/sale_payment.rb @@ -177,6 +177,11 @@ class SalePayment < ApplicationRecord end + def kbz_edit_sale_payment(amt, action_by) + self.action_by = action_by + sale_update_payment_status(amt) + end + def self.get_paypar_account(url,token,membership_id,campaign_type_id,merchant_uid,auth_token) # Control for Paypar Cloud begin @@ -625,7 +630,7 @@ class SalePayment < ApplicationRecord self.outstanding_amount = self.sale.grand_total.to_f - self.received_amount.to_f self.payment_status = "paid" payment_status = self.save! - sale_update_payment_status(self.received_amount) + # sale_update_payment_status(self.received_amount) return payment_status end diff --git a/app/models/shift_sale.rb b/app/models/shift_sale.rb index 59294700..1749e1b8 100755 --- a/app/models/shift_sale.rb +++ b/app/models/shift_sale.rb @@ -157,6 +157,7 @@ class ShiftSale < ApplicationRecord SUM(case when (sale_payments.payment_method='jcb') then (sale_payments.payment_amount) else 0 end) as jcb_amount, SUM(case when (sale_payments.payment_method='unionpay') then (sale_payments.payment_amount) else 0 end) as unionpay_amount, SUM(case when (sale_payments.payment_method='alipay') then (sale_payments.payment_amount) else 0 end) as alipay_amount, + SUM(case when (sale_payments.payment_method='KBZPay') then (sale_payments.payment_amount) else 0 end) as kbzpay_amount, SUM(case when (sale_payments.payment_method='dinga') then (sale_payments.payment_amount) else 0 end) as dinga_amount, SUM(case when (sale_payments.payment_method='giftvoucher') then (sale_payments.payment_amount) else 0 end) as giftvoucher_amount, SUM(case when (sale_payments.payment_method='JunctionPay') then (sale_payments.payment_amount) else 0 end) as junctionpay_amount, diff --git a/app/pdf/close_cashier_pdf.rb b/app/pdf/close_cashier_pdf.rb index 9ff2f17a..d4564291 100755 --- a/app/pdf/close_cashier_pdf.rb +++ b/app/pdf/close_cashier_pdf.rb @@ -244,6 +244,16 @@ class CloseCashierPdf < Prawn::Document end end + if other.kbzpay_amount && other.kbzpay_amount.to_f > 0 + y_position = cursor + bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do + text "KBZ Payment :", :size => self.item_font_size, :align => :right + end + bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do + text "#{ number_with_precision(other.kbzpay_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right + end + end + if other.junctionpay_amount && other.junctionpay_amount.to_f > 0 y_position = cursor bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do diff --git a/config/initializers/action_controller.rb b/config/initializers/action_controller.rb index 85f38ec5..205c330a 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 6a545bed..fd89392f 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! From 74b758e163099dcd929686d52df6dda00757316d Mon Sep 17 00:00:00 2001 From: Zoey Date: Thu, 27 Jun 2019 10:43:30 +0630 Subject: [PATCH 05/12] KBZPay Receipt Pdf modified --- app/controllers/origami/sx queries.txt | 14 ++++++++++++++ app/pdf/receipt_bill_pdf.rb | 8 +++++--- dump.rdb | Bin 1214755 -> 1216399 bytes 3 files changed, 19 insertions(+), 3 deletions(-) create mode 100644 app/controllers/origami/sx queries.txt diff --git a/app/controllers/origami/sx queries.txt b/app/controllers/origami/sx queries.txt new file mode 100644 index 00000000..efae4797 --- /dev/null +++ b/app/controllers/origami/sx queries.txt @@ -0,0 +1,14 @@ +truncate bookings; +truncate booking_orders; +truncate orders; +truncate order_items; +truncate assigned_order_items; +truncate sale_orders; +truncate sales; +truncate sale_items; +truncate sale_audits; +truncate sale_taxes; +truncate sale_payments; +truncate shift_sales; +update dining_facilities set status='available'; +update cashier_terminals set is_currently_login=0; diff --git a/app/pdf/receipt_bill_pdf.rb b/app/pdf/receipt_bill_pdf.rb index 9a1b64e5..451c055b 100755 --- a/app/pdf/receipt_bill_pdf.rb +++ b/app/pdf/receipt_bill_pdf.rb @@ -105,7 +105,7 @@ class ReceiptBillPdf < Prawn::Document end if kbz_pay_status - pay_by_kbzpay(printed_status, qr_code) + kbzpay_qr_generator(printed_status, qr_code) end footer(printed_status) @@ -685,14 +685,16 @@ class ReceiptBillPdf < Prawn::Document move_down line_move end - def pay_by_kbzpay(status, qr_code) + def kbzpay_qr_generator(status, qr_code) if status == 'Frt' move_down line_move move_down line_move text "Scan to pay with KBZ Pay", :size => self.header_font_size, :align => :center move_down line_move print_qr_code(qr_code, pos: [39, cursor], extent: 161, stroke: false, dot: 1000) - # stroke_horizontal_rule + move_down line_move + text "This QR code will be expired after 20 minutes.", :size => self.item_font_size, :align => :center + move_down line_move move_down line_move end end diff --git a/dump.rdb b/dump.rdb index 81aade48f1e5b2e3f3331e0ea90c86399ad78d74..715250ee5aab0a2de87fbf6aea31bbccf333d11b 100644 GIT binary patch delta 2690 zcmb`JTWs4@7{{H&PH$TZX6xE@-OgOt+AYcKmmVngOf8l?aX5SWm}O*rhH| zzieDS`(a2NnEq}xi(E{#WpjEilF*YWY`Sr$aER@$oMk#`k$0)eH%xEk6=nsELQru& zF0&oZZDqE9DZ|(}XHPVpiQN#(SHAT<3j%^HLJg^5Rh1Per~r6u8$80KaW<=uMkgyl z@A{FCz=4uhrDi=w4xDS+jt$E;Bau>*{}wBEvz5<8Pf&@qE2^HUDs`OJBq)nuO80w) z4G@gJLy4s;sASc{mtOU0VF7__y+|tH>)w0!{N{79Gch@~xAKDbiTRZvRZ<`Tt+s91 z!}BW%ywj-Uhgv0{HdS!ac+LQ;rxAN(7U?0lz6(w8Bv71pe%k?N(1L;NtR(@ zLvY~nhUtOW2c46gkK@8XvjR zXW|r&uA+8>9&ZMZS1IIntulwW!fq}IcL%w8J8+SloyS3LUmoW%IO#WWLeHmi;9>8c zqzT#?Iid6M1n>rAQ5AR*3q{!wrMRg9P%5u9hxHs65oAS>C8($H5j_=Y7exJ+g4^2Wb)}awtRmMg1*t@ew+bP5a7GUumN&j zp!9=#O0m;sk&4Z1qHc=r0zJN30IKxeGf&b;lLcYs0zGVymIQB5YN?&{9lfdaykCMy zQRTw@uiv}p^Lo>b$KLx7B#H#Zjmg}^P@O}{q#GPM2#57^9DIaBZlt*ZqWNEdI57v} zXahutq{yZYO{FO40yGT+#W5tet4CiemAn7IK^9S1g1p8navj9Zst>dxjTggEQ50ST zYyJ?fML4Yc3l2pB;wb_mzJNo4aDW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z<(oyTREC9M2Ti-scSoBRa_QVRXo&1bH1%CF4$>OXfSdxdtm`_TT<5xud$a;Q&-yBR z0$rj$ZeHX^$BjDiCwf3_%CL2EBA8(mMV5f3UZ%;THoq-Oyq~^!mRrav4Z&XYYvkl6HWXAQBdrjIt|0IeYQ$5-Qe|3DO zNlD8pKVea!;wRZfLLP4o6}Q)kSw@p|Ev<~*x&F(SYm#Qp#~x>rO`#mWg-J<44d=wrtRc1d9q$YQ(DDi@_6ipu^;ROPy8Rg^Npl+}SQ#J5kq=t2);%v8Re%ZQRL zN^(Fh+XsJ}ZCs^PQPz-V?c&o$HvbM3-i;F<NR_HZXCZq# zyO=yFeC>FC)v7?j6l@2HiS@!p%NNW>p|qwcASD4+&luV^VYpP_KWN6%=vbngi`!1s zuDLF(+M|Lgqce$}@%I`M#?THHugb-jHx9f_T5lx%JIAALasc(RJ(RNl!{|BoBMKfmcGGWqxJ*?#~t6HC(o From 29ef6c17f910e846500d77b9f91268cb710b3a64 Mon Sep 17 00:00:00 2001 From: Zoey Date: Thu, 27 Jun 2019 10:52:25 +0630 Subject: [PATCH 06/12] before pull --- app/controllers/origami/sx queries.txt | 14 -------------- 1 file changed, 14 deletions(-) delete mode 100644 app/controllers/origami/sx queries.txt diff --git a/app/controllers/origami/sx queries.txt b/app/controllers/origami/sx queries.txt deleted file mode 100644 index efae4797..00000000 --- a/app/controllers/origami/sx queries.txt +++ /dev/null @@ -1,14 +0,0 @@ -truncate bookings; -truncate booking_orders; -truncate orders; -truncate order_items; -truncate assigned_order_items; -truncate sale_orders; -truncate sales; -truncate sale_items; -truncate sale_audits; -truncate sale_taxes; -truncate sale_payments; -truncate shift_sales; -update dining_facilities set status='available'; -update cashier_terminals set is_currently_login=0; From 49917c352c244ba49fd3b32833f2b81ff7498cc2 Mon Sep 17 00:00:00 2001 From: NyanLinHtut Date: Thu, 27 Jun 2019 13:51:02 +0630 Subject: [PATCH 07/12] add show subtotal+service charges in receipt bill --- README.md | 6 + .../channels/second_display_view.js | 4 +- app/pdf/receipt_bill_pdf.rb | 166 ++++++++++++------ 3 files changed, 117 insertions(+), 59 deletions(-) diff --git a/README.md b/README.md index d3f2199f..4d7f8a11 100755 --- a/README.md +++ b/README.md @@ -287,6 +287,12 @@ For Online Order Receipt Setting For Close Cashier Print Settings settings/lookups => {type:close_cashier_print, name:CloseCashierPrint, value: {0 or 1} } +For Second Display View Setting +settings/lookups => {type:display_type, name: Display Type, value: 2} + +For show total and service charges in receipt bill +settings/lookups => {type:show_sub_total_and_service_charges, name:Show Sub Total and Service charges, value: {0 or 1}} + * ToDo list 1. Migration diff --git a/app/assets/javascripts/channels/second_display_view.js b/app/assets/javascripts/channels/second_display_view.js index 721b098f..2e32201e 100644 --- a/app/assets/javascripts/channels/second_display_view.js +++ b/app/assets/javascripts/channels/second_display_view.js @@ -40,6 +40,7 @@ App.checkin = App.cable.subscriptions.create('SecondDisplayViewChannel', { // } d_option = items[i].opt; + console.log(d_option) if (items[i].click_type != "add_icon"){ option_name = "-"+items[i].options; data_option = items[i].options ; @@ -54,7 +55,8 @@ App.checkin = App.cable.subscriptions.create('SecondDisplayViewChannel', { $(item_row).each(function(j){ var item_code = $(item_row[j]).attr('data-code'); var instance_code = $(item_row[j]).attr('data-instance-code'); - var r_option = $(item_row[j]).attr('data-options'); + var r_option = $(item_row[j]).attr('data-opt'); + console.log(r_option) if (item_code == items[i].item_code && instance_code == items[i].instance_code && r_option==d_option) { if (qty > 1) { qty = parseInt($(item_row[j]).children('#item_qty').text()) + qty; diff --git a/app/pdf/receipt_bill_pdf.rb b/app/pdf/receipt_bill_pdf.rb index 97f6dfc2..aef43ce9 100755 --- a/app/pdf/receipt_bill_pdf.rb +++ b/app/pdf/receipt_bill_pdf.rb @@ -2,7 +2,7 @@ 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) self.page_width = printer_settings.page_width self.page_height = printer_settings.page_height @@ -101,7 +101,7 @@ class ReceiptBillPdf < Prawn::Document if shop_details.note && !shop_details.note.nil? shop_note(shop_details) end - + footer(printed_status) end @@ -129,7 +129,7 @@ class ReceiptBillPdf < Prawn::Document text "OrderNo : #{ latest_order_no }", :size => self.header_font_size,:align => :left end move_down line_move - + # move_down 2 y_position = cursor bounding_box([0,y_position], :width =>self.description_width + self.price_num_width, :height => self.item_height) do @@ -146,7 +146,7 @@ class ReceiptBillPdf < Prawn::Document y_position = cursor bounding_box([0, y_position], :width =>self.label_width, :height => self.item_height) do text "W: #{sale_data.requested_by}" , :size => self.item_font_size, :align => :left - end + end bounding_box([self.label_width - 2,y_position], :width =>self.label_width, :height => self.item_height) do text "C: #{sale_data.cashier_name}", :size => self.item_font_size,:align => :right end @@ -164,7 +164,7 @@ class ReceiptBillPdf < Prawn::Document end # bounding_box([self.item_description_width,y_position], :width =>self.label_width+5) do - # text "(#{ sale_data.bookings[0].checkin_at.utc.getlocal.strftime('%I:%M %p') } + # text "(#{ sale_data.bookings[0].checkin_at.utc.getlocal.strftime('%I:%M %p') } # - #{ sale_data.bookings[0].checkin_at.utc.getlocal.strftime('%I:%M %p') })" , # :size => self.item_font_size,:align => :right # end @@ -201,7 +201,7 @@ class ReceiptBillPdf < Prawn::Document end def add_line_item_row(sale_items,precision,delimiter) - + if precision.to_i > 0 item_name_width = (self.item_width+self.price_width) item_qty_front_width = (self.item_width+self.price_width) + 5 @@ -218,18 +218,18 @@ class ReceiptBillPdf < Prawn::Document y_position = cursor move_down line_move - sub_total = 0.0 + @sub_total = 0.0 total_qty = 0.0 show_price = Lookup.find_by_lookup_type("show_price") sale_items.each do |item| - # check for item not to show - + # check for item not to show + if item.status != 'Discount' && item.qty > 0 if !show_price.nil? && show_price.value.to_i > 0 && item.price == 0 - total_qty += item.qty + total_qty += item.qty else if item.price != 0 - total_qty += item.qty + total_qty += item.qty end end end @@ -242,13 +242,13 @@ class ReceiptBillPdf < Prawn::Document # total_price = -item.price #item.qty*item.unit_price - comment for room charges # price = -item.unit_price # else - sub_total += item.price #(item.qty*item.unit_price) - comment for room charges + @sub_total += item.price #(item.qty*item.unit_price) - comment for room charges qty = item.qty total_price = item.price #item.qty*item.unit_price - comment for room charges price = item.unit_price - + # end - + if !show_price.nil? && show_price.value.to_i>0 item_row(item,precision,delimiter,product_name,price,qty ,total_price) @@ -257,7 +257,7 @@ class ReceiptBillPdf < Prawn::Document item_row(item,precision,delimiter,product_name,price,qty ,total_price) end end - + end stroke_horizontal_rule @@ -268,7 +268,7 @@ class ReceiptBillPdf < Prawn::Document text "Sub Total", :size => self.item_font_size,:align => :left end text_box "#{number_with_precision(total_qty, :precision => precision.to_i)}", :at =>[item_qty_front_width,y_position], :width => item_qty_end_width, :size => self.item_font_size, :align => :center, :overflow => :shrink_to_fix - text_box "#{number_with_precision(sub_total, :precision => precision.to_i, :delimiter => delimiter)}", :at =>[item_total_front_width,y_position], :width =>item_total_end_width, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix + text_box "#{number_with_precision(@sub_total, :precision => precision.to_i, :delimiter => delimiter)}", :at =>[item_total_front_width,y_position], :width =>item_total_end_width, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix end def item_row(item,precision,delimiter,product_name,price,qty ,total_price) @@ -291,10 +291,10 @@ class ReceiptBillPdf < Prawn::Document bounding_box([0,y_position], :width =>self.item_width) do text "#{product_name}", :size => self.item_font_size,:align => :left end - # text_box "#{product_name}", :at =>[0,y_position], :width => self.item_width, :size => self.item_font_size - text_box "#{number_with_precision(price, :precision => precision.to_i, :delimiter => delimiter)}", :at =>[self.item_width,y_position], :width => self.price_width, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix - text_box "#{number_with_precision(qty, :precision => precision.to_i)}", :at =>[item_qty_front_width,y_position], :width => item_qty_end_width, :size => self.item_font_size, :align => :center, :overflow => :shrink_to_fix - text_box "#{number_with_precision(total_price, :precision => precision.to_i, :delimiter => delimiter)}", :at =>[item_total_front_width,y_position], :width =>item_total_end_width, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix + # text_box "#{product_name}", :at =>[0,y_position], :width => self.item_width, :size => self.item_font_size + text_box "#{number_with_precision(price, :precision => precision.to_i, :delimiter => delimiter)}", :at =>[self.item_width,y_position], :width => self.price_width, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix + text_box "#{number_with_precision(qty, :precision => precision.to_i)}", :at =>[item_qty_front_width,y_position], :width => item_qty_end_width, :size => self.item_font_size, :align => :center, :overflow => :shrink_to_fix + text_box "#{number_with_precision(total_price, :precision => precision.to_i, :delimiter => delimiter)}", :at =>[item_total_front_width,y_position], :width =>item_total_end_width, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix if show_alt_name if !(item.product_alt_name).empty? @@ -326,23 +326,73 @@ class ReceiptBillPdf < Prawn::Document bounding_box([self.item_description_width,y_position], :width =>self.label_width) do text "( #{number_with_precision(sale_data.total_discount, :precision => precision.to_i, :delimiter => delimiter)} )" , :size => self.item_font_size,:align => :right end - + @Service_Tax_Desc = "" + @Service_Tax_amount = 0 + @Service_Tax_Rate = 0 + @Com_Tax_Desc = "" + @Com_Tax_Amount = 0 + @Com_Tax_Rate = 0 if sale_data.sale_taxes.length > 0 incl_tax = "" if sale_data.tax_type == "inclusive" incl_tax = "Incl." end - sale_data.sale_taxes.each do |st| - move_down line_move - y_position = cursor + find_lookup = Lookup.find_by_lookup_type('show_sub_total_and_service_charges') + if find_lookup.value == '1' + sale_data.sale_taxes.each do |st| + if (st.tax_name.include? "Service") + @Service_Tax_Desc = st.tax_name + @Service_Tax_amount = number_with_precision(st.tax_payable_amount, :precision => precision.to_i, :delimiter => delimiter) + if incl_tax + @Service_Tax_Rate = st.tax_rate.to_i + end + end + if (st.tax_name.include? "Commercial") + @Com_Tax_Desc = st.tax_name + @Com_Tax_Amount = number_with_precision(st.tax_payable_amount, :precision => precision.to_i, :delimiter => delimiter) + if incl_tax + @Com_Tax_Rate = st.tax_rate.to_i + end + end + end + move_down line_move + y_position = cursor + bounding_box([0,y_position], :width =>self.item_description_width, :height => self.item_height) do + text "#{ @Service_Tax_Desc } (#{incl_tax} #{ @Service_Tax_Rate }%)", :size => self.item_font_size,:align => :left + end + bounding_box([self.item_description_width,y_position], :width =>self.label_width) do + text "#{number_with_precision(@Service_Tax_amount, :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right + end + move_down line_move + y_position = cursor + stroke_horizontal_rule + bounding_box([0,y_position], :width =>self.item_description_width, :height => self.item_height) do + text "Sub Total + #{@Service_Tax_Desc}", :size => self.item_font_size,:align => :left + end + bounding_box([self.item_description_width,y_position], :width =>self.label_width) do + text "#{@Service_Tax_amount.to_i + @sub_total.to_i}" , :size => self.item_font_size,:align => :right + end + move_down line_move + y_position = cursor + bounding_box([0,y_position], :width =>self.item_description_width, :height => self.item_height) do + text "#{ @Com_Tax_Desc } (#{incl_tax} #{ @Com_Tax_Rate.to_i }%)", :size => self.item_font_size,:align => :left + end + bounding_box([self.item_description_width,y_position], :width =>self.label_width) do + text "#{number_with_precision(@Com_Tax_Amount, :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right + end + else + sale_data.sale_taxes.each do |st| + move_down line_move + y_position = cursor - bounding_box([0,y_position], :width =>self.item_description_width, :height => self.item_height) do - text "#{ st.tax_name } (#{incl_tax} #{ st.tax_rate.to_i }%)", :size => self.item_font_size,:align => :left - end - bounding_box([self.item_description_width,y_position], :width =>self.label_width) do - text "#{number_with_precision(st.tax_payable_amount, :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right - end + bounding_box([0,y_position], :width =>self.item_description_width, :height => self.item_height) do + text "#{ st.tax_name } (#{incl_tax} #{ st.tax_rate.to_i }%)", :size => self.item_font_size,:align => :left + end + bounding_box([self.item_description_width,y_position], :width =>self.label_width) do + text "#{number_with_precision(st.tax_payable_amount, :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right + end + end end else @@ -367,7 +417,7 @@ class ReceiptBillPdf < Prawn::Document end bounding_box([self.item_description_width,y_position], :width =>self.label_width) do text "#{sale_data.rounding_adjustment}", :size => self.item_font_size,:align => :right - end + end end move_down line_move @@ -380,11 +430,11 @@ class ReceiptBillPdf < Prawn::Document text "#{number_with_precision(sale_data.grand_total, :precision => precision.to_i, :delimiter => delimiter)}" , :style => :bold, :size => self.header_font_size,:align => :right end move_down line_move - - sale_payment(sale_data,precision,delimiter) + + sale_payment(sale_data,precision,delimiter) end - def sale_payment(sale_data,precision,delimiter) + def sale_payment(sale_data,precision,delimiter) stroke_horizontal_rule #move_down line_move sql = "SELECT SUM(payment_amount) @@ -416,13 +466,13 @@ class ReceiptBillPdf < Prawn::Document text "#{payment.payment_method.capitalize} 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_with_precision(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 + 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 @@ -437,7 +487,7 @@ class ReceiptBillPdf < Prawn::Document # show member information def member_info(member_info,customer_name,rebate_amount,sale_data,precision,delimiter,current_balance) - if rebate_amount != nil + if rebate_amount != nil if rebate_amount["status"] == true stroke_horizontal_rule total = 0 @@ -466,8 +516,8 @@ class ReceiptBillPdf < Prawn::Document bounding_box([self.item_description_width,y_position], :width =>self.label_width) do text "#{number_with_precision(res["deposit"], :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right end - - end + + end # Total Rebate Amount if birthday if res["receipt_no"]== sale_data.receipt_no && res["account_status"]== "RebatebonusAccount" && res["status"]== "Rebate" rebate_balance = rebate_balance + res["deposit"] @@ -479,7 +529,7 @@ class ReceiptBillPdf < Prawn::Document bounding_box([self.item_description_width,y_position], :width =>self.label_width) do text "#{number_with_precision(res["deposit"], :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right end - end + end #end Total rebate if birthday end @@ -502,7 +552,7 @@ class ReceiptBillPdf < Prawn::Document text "#{number_with_precision(current_balance, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size,:align => :right end end - + end end @@ -512,7 +562,7 @@ class ReceiptBillPdf < Prawn::Document if res["accountable_type"] == "RebateAccount" || res["accountable_type"] == "RebatebonusAccount" total_balance = total_balance + res["balance"] - + end end move_down line_move @@ -524,7 +574,7 @@ class ReceiptBillPdf < Prawn::Document text "#{number_with_precision(total_balance, :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right end end - + end def customer(customer_name) @@ -554,7 +604,7 @@ class ReceiptBillPdf < Prawn::Document end bounding_box([self.item_description_width,y_position], :width =>self.label_width) do text "(" + "#{ number_with_precision(ipa[:price], :precision => precision.to_i, :delimiter => delimiter) }" + ")" , :size => self.item_font_size,:align => :right - end + end move_down line_move end end @@ -571,7 +621,7 @@ class ReceiptBillPdf < Prawn::Document bounding_box([self.label_width,y_position], :width =>self.item_description_width) do text "#{number_with_precision(ipa[:price], :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right end - move_down line_move + move_down line_move end end @@ -583,7 +633,7 @@ class ReceiptBillPdf < Prawn::Document bounding_box([self.label_width,y_position], :width =>self.item_description_width) do text "#{number_with_precision(other_amount, :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right end - move_down line_move + move_down line_move end #individual payment per person @@ -623,17 +673,17 @@ class ReceiptBillPdf < Prawn::Document JOIN sale_audits sa ON SUBSTRING_INDEX(sa.remark,'||',1)=sale_payment_id where sa.sale_id='#{sale_data.sale_id}')) = 0 - THEN payment_method!='creditnote' ELSE 1 END) AND sale_id = ?", sale_data.sale_id).each do |payment| + THEN payment_method!='creditnote' ELSE 1 END) AND sale_id = ?", sale_data.sale_id).each do |payment| if payment.payment_method == "creditnote" y_position = cursor stroke_horizontal_rule - + bounding_box([self.label_width,y_position], :width =>self.item_description_width) do move_down 70 stroke_horizontal_rule end - + bounding_box([self.label_width,y_position], :width =>self.item_description_width) do move_down 73 text "Approved By" , :size => self.item_font_size,:align => :center @@ -650,7 +700,7 @@ class ReceiptBillPdf < Prawn::Document move_down 70 stroke_horizontal_rule end - + if sale_data.payment_status == "foc" bounding_box([self.label_width,y_position], :width =>self.item_description_width) do move_down 73 @@ -661,9 +711,9 @@ class ReceiptBillPdf < Prawn::Document move_down 73 text "Approved By" , :size => self.item_font_size,:align => :center end - end + end end - + end def shop_note(shop) @@ -673,8 +723,8 @@ class ReceiptBillPdf < Prawn::Document move_down line_move y_position = cursor - - text "#{shop.note}", :size => self.item_font_size, :align => :left + + text "#{shop.note}", :size => self.item_font_size, :align => :left move_down line_move end @@ -688,10 +738,10 @@ class ReceiptBillPdf < Prawn::Document y_position = cursor bounding_box([0, y_position], :width =>self.label_width) do text "#{printed_status}",:style => :bold, :size => header_font_size,:align => :left - end + end bounding_box([self.item_description_width,y_position], :width =>self.item_description_width, :height => self.item_height) do text "Thank You! See you Again", :left_margin => -5, :size => self.item_font_size,:align => :left - end + end move_down line_move end @@ -729,7 +779,7 @@ class ReceiptBillPdf < Prawn::Document y_position = cursor bounding_box([0, y_position], :width =>self.label_width) do text "Card Balance: ",:style => :bold, :size => header_font_size,:align => :left - end + end bounding_box([self.item_description_width,y_position], :width =>self.label_width) do text "#{card_balance_amount}" , :size => self.item_font_size,:align => :right end @@ -753,4 +803,4 @@ class ReceiptBillPdf < Prawn::Document end return status end -end \ No newline at end of file +end From 0872ce50510a44b9448c1d8a7315d081d832b6be Mon Sep 17 00:00:00 2001 From: Myat Zin Wai Maw Date: Fri, 28 Jun 2019 14:36:21 +0630 Subject: [PATCH 08/12] fix conflict --- app/pdf/receipt_bill_pdf.rb | 7 ------- 1 file changed, 7 deletions(-) diff --git a/app/pdf/receipt_bill_pdf.rb b/app/pdf/receipt_bill_pdf.rb index d6c1fc13..4d1bd875 100755 --- a/app/pdf/receipt_bill_pdf.rb +++ b/app/pdf/receipt_bill_pdf.rb @@ -4,13 +4,9 @@ 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 -<<<<<<< HEAD - 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) ->>>>>>> 29ef6c17f910e846500d77b9f91268cb710b3a64 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 @@ -109,13 +105,10 @@ class ReceiptBillPdf < Prawn::Document shop_note(shop_details) end -<<<<<<< HEAD -======= if kbz_pay_status kbzpay_qr_generator(printed_status, qr_code) end ->>>>>>> 29ef6c17f910e846500d77b9f91268cb710b3a64 footer(printed_status) end From aca0c390c9f7d4a64fe13237c0b7ad5a198e49a6 Mon Sep 17 00:00:00 2001 From: NyanLinHtut Date: Mon, 1 Jul 2019 11:11:44 +0630 Subject: [PATCH 09/12] insert looktype for receipt bill --- README.md | 4 +-- app/pdf/receipt_bill_pdf.rb | 58 +++++++++++++++++-------------------- 2 files changed, 28 insertions(+), 34 deletions(-) diff --git a/README.md b/README.md index 4d7f8a11..9df29b68 100755 --- a/README.md +++ b/README.md @@ -290,8 +290,8 @@ settings/lookups => {type:close_cashier_print, name:CloseCashierPrint, value: {0 For Second Display View Setting settings/lookups => {type:display_type, name: Display Type, value: 2} -For show total and service charges in receipt bill -settings/lookups => {type:show_sub_total_and_service_charges, name:Show Sub Total and Service charges, value: {0 or 1}} +For show total before tax in receipt bill +settings/lookups => {type:show_total_before_tax, name:Show Total Before Tax, value: {0 or 1}} * ToDo list diff --git a/app/pdf/receipt_bill_pdf.rb b/app/pdf/receipt_bill_pdf.rb index d6c1fc13..b95c8e57 100755 --- a/app/pdf/receipt_bill_pdf.rb +++ b/app/pdf/receipt_bill_pdf.rb @@ -4,13 +4,8 @@ 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 -<<<<<<< HEAD - 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) ->>>>>>> 29ef6c17f910e846500d77b9f91268cb710b3a64 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 @@ -109,13 +104,6 @@ class ReceiptBillPdf < Prawn::Document shop_note(shop_details) end -<<<<<<< HEAD -======= - if kbz_pay_status - kbzpay_qr_generator(printed_status, qr_code) - end - ->>>>>>> 29ef6c17f910e846500d77b9f91268cb710b3a64 footer(printed_status) end @@ -340,60 +328,66 @@ class ReceiptBillPdf < Prawn::Document bounding_box([self.item_description_width,y_position], :width =>self.label_width) do text "( #{number_with_precision(sale_data.total_discount, :precision => precision.to_i, :delimiter => delimiter)} )" , :size => self.item_font_size,:align => :right end - @Service_Tax_Desc = "" - @Service_Tax_amount = 0 - @Service_Tax_Rate = 0 - @Com_Tax_Desc = "" - @Com_Tax_Amount = 0 - @Com_Tax_Rate = 0 + + service_tax_desc = "" + service_tax_amount = 0 + service_tax_rate = 0 + com_tax_desc = "" + com_tax_amount = 0 + com_tax_rate = 0 if sale_data.sale_taxes.length > 0 incl_tax = "" if sale_data.tax_type == "inclusive" incl_tax = "Incl." end - find_lookup = Lookup.find_by_lookup_type('show_sub_total_and_service_charges') - if find_lookup.value == '1' + find_lookup = Lookup.find_by_lookup_type('show_total_before_tax') + if find_lookup.nil? || find_lookup == nil + lookup = Lookup.new(lookup_type: 'show_total_before_tax', name: 'Show Total Before Tax', value: '0') + lookup.save + end + check_lookup_type = Lookup.find_by_lookup_type('show_total_before_tax') + if check_lookup_type.value == '1' sale_data.sale_taxes.each do |st| if (st.tax_name.include? "Service") - @Service_Tax_Desc = st.tax_name - @Service_Tax_amount = number_with_precision(st.tax_payable_amount, :precision => precision.to_i, :delimiter => delimiter) + service_tax_desc = st.tax_name + service_tax_amount = number_with_precision(st.tax_payable_amount, :precision => precision.to_i, :delimiter => delimiter) if incl_tax - @Service_Tax_Rate = st.tax_rate.to_i + service_tax_rate = st.tax_rate.to_i end end if (st.tax_name.include? "Commercial") - @Com_Tax_Desc = st.tax_name - @Com_Tax_Amount = number_with_precision(st.tax_payable_amount, :precision => precision.to_i, :delimiter => delimiter) + com_tax_desc = st.tax_name + com_tax_amount = number_with_precision(st.tax_payable_amount, :precision => precision.to_i, :delimiter => delimiter) if incl_tax - @Com_Tax_Rate = st.tax_rate.to_i + com_tax_rate = st.tax_rate.to_i end end end move_down line_move y_position = cursor bounding_box([0,y_position], :width =>self.item_description_width, :height => self.item_height) do - text "#{ @Service_Tax_Desc } (#{incl_tax} #{ @Service_Tax_Rate }%)", :size => self.item_font_size,:align => :left + text "#{ service_tax_desc } (#{incl_tax} #{ service_tax_rate }%)", :size => self.item_font_size,:align => :left end bounding_box([self.item_description_width,y_position], :width =>self.label_width) do - text "#{number_with_precision(@Service_Tax_amount, :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right + text "#{number_with_precision(service_tax_amount, :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right end move_down line_move y_position = cursor stroke_horizontal_rule bounding_box([0,y_position], :width =>self.item_description_width, :height => self.item_height) do - text "Sub Total + #{@Service_Tax_Desc}", :size => self.item_font_size,:align => :left + text "Total Before Tax", :size => self.item_font_size,:align => :left end bounding_box([self.item_description_width,y_position], :width =>self.label_width) do - text "#{@Service_Tax_amount.to_i + @sub_total.to_i}" , :size => self.item_font_size,:align => :right + text "#{service_tax_amount.to_i + @sub_total.to_i}" , :size => self.item_font_size,:align => :right end move_down line_move y_position = cursor bounding_box([0,y_position], :width =>self.item_description_width, :height => self.item_height) do - text "#{ @Com_Tax_Desc } (#{incl_tax} #{ @Com_Tax_Rate.to_i }%)", :size => self.item_font_size,:align => :left + text "#{ com_tax_desc } (#{incl_tax} #{ com_tax_rate.to_i }%)", :size => self.item_font_size,:align => :left end bounding_box([self.item_description_width,y_position], :width =>self.label_width) do - text "#{number_with_precision(@Com_Tax_Amount, :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right + text "#{number_with_precision(com_tax_amount, :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right end else sale_data.sale_taxes.each do |st| From b7368314c5b3ecb35fe5d1245e0b446b6e2aa4c7 Mon Sep 17 00:00:00 2001 From: Zoey Date: Wed, 3 Jul 2019 13:49:54 +0630 Subject: [PATCH 10/12] print receipt bill --- app/controllers/api/bill_controller.rb | 2 +- app/controllers/oqs/print_controller.rb | 4 ++-- .../origami/payments_controller.rb | 4 ++-- .../origami/request_bills_controller.rb | 2 +- app/controllers/origami/void_controller.rb | 2 +- .../origami/waste_spoile_controller.rb | 2 +- .../transactions/sales_controller.rb | 2 +- app/models/order_reservation.rb | 2 +- config/puma.rb | 20 +++++++++--------- dump.rdb | Bin 1216399 -> 1222866 bytes 10 files changed, 20 insertions(+), 20 deletions(-) diff --git a/app/controllers/api/bill_controller.rb b/app/controllers/api/bill_controller.rb index 214e1300..1614bb1e 100755 --- a/app/controllers/api/bill_controller.rb +++ b/app/controllers/api/bill_controller.rb @@ -131,7 +131,7 @@ class Api::BillController < Api::ApiController #member_info = Customer.get_member_account(customer) # printer = Printer::ReceiptPrinter.new(print_settings) - # printer.print_receipt_bill(print_settings,@sale_items,@sale_data,customer.name, item_price_by_accounts, member_info, shop_details) + # printer.print_receipt_bill(print_settings, false, nil,@sale_items,@sale_data,customer.name, item_price_by_accounts, member_info, shop_details) end def request_bill diff --git a/app/controllers/oqs/print_controller.rb b/app/controllers/oqs/print_controller.rb index abf20018..751e1c01 100755 --- a/app/controllers/oqs/print_controller.rb +++ b/app/controllers/oqs/print_controller.rb @@ -51,7 +51,7 @@ class Oqs::PrintController < ApplicationController ai.save end - # 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) + # filename, receipt_no, cashier_printer = printer.print_receipt_bill(print_settings, false, nil,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) if ENV["SERVER_MODE"] == "cloud" result = { :filepath => filename, @@ -119,7 +119,7 @@ class Oqs::PrintController < ApplicationController ai.save end - # 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) + # filename, receipt_no, cashier_printer = printer.print_receipt_bill(print_settings, false, nil,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) if ENV["SERVER_MODE"] == "cloud" result = { :filepath => filename, diff --git a/app/controllers/origami/payments_controller.rb b/app/controllers/origami/payments_controller.rb index ec8a6958..45cb7c51 100755 --- a/app/controllers/origami/payments_controller.rb +++ b/app/controllers/origami/payments_controller.rb @@ -617,7 +617,7 @@ class Origami::PaymentsController < BaseOrigamiController other_amount = SaleItem.calculate_other_charges(saleObj.sale_items) printer = Printer::ReceiptPrinter.new(print_settings) - filename, receipt_no, cashier_printer = printer.print_receipt_bill(print_settings,cashier_terminal,saleObj.sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_detail, "Re-print",current_balance,card_data,other_amount,latest_order_no,card_balance_amount,nil) + filename, receipt_no, cashier_printer = printer.print_receipt_bill(print_settings, false, nil,cashier_terminal,saleObj.sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_detail, "Re-print",current_balance,card_data,other_amount,latest_order_no,card_balance_amount,nil) result = { :status => true, @@ -716,7 +716,7 @@ class Origami::PaymentsController < BaseOrigamiController printer = Printer::ReceiptPrinter.new(print_settings) - filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings,cashier_terminal,saleObj.sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_detail, "FOC",nil,nil,other_amount,nil,nil,nil) + filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings, false, nil,cashier_terminal,saleObj.sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_detail, "FOC",nil,nil,other_amount,nil,nil,nil) result = { :status => true, :filepath => filename, diff --git a/app/controllers/origami/request_bills_controller.rb b/app/controllers/origami/request_bills_controller.rb index 422e1372..9905ebaf 100755 --- a/app/controllers/origami/request_bills_controller.rb +++ b/app/controllers/origami/request_bills_controller.rb @@ -120,7 +120,7 @@ class Origami::RequestBillsController < ApplicationController # printer = Printer::ReceiptPrinter.new(print_settings) - # printer.print_receipt_bill(print_settings,@sale_items,@sale_data,customer.name, item_price_by_accounts,member_info,shop_details) + # printer.print_receipt_bill(print_settings, false, nil,@sale_items,@sale_data,customer.name, item_price_by_accounts,member_info,shop_details) end end diff --git a/app/controllers/origami/void_controller.rb b/app/controllers/origami/void_controller.rb index 75bb7074..980fd6bd 100755 --- a/app/controllers/origami/void_controller.rb +++ b/app/controllers/origami/void_controller.rb @@ -148,7 +148,7 @@ class Origami::VoidController < BaseOrigamiController discount_price_by_accounts = SaleItem.get_discount_price_by_accounts(sale.sale_items) other_amount = SaleItem.calculate_other_charges(sale.sale_items) printer = Printer::ReceiptPrinter.new(print_settings) - filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings,cashier_terminal,sale.sale_items,sale,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details, "VOID",current_balance,nil,other_amount,nil,nil,nil) + filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings, false, nil,cashier_terminal,sale.sale_items,sale,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details, "VOID",current_balance,nil,other_amount,nil,nil,nil) result = { :filepath => filename, :printer_model => print_settings.brand_name, diff --git a/app/controllers/origami/waste_spoile_controller.rb b/app/controllers/origami/waste_spoile_controller.rb index 92720467..2d4c9367 100755 --- a/app/controllers/origami/waste_spoile_controller.rb +++ b/app/controllers/origami/waste_spoile_controller.rb @@ -122,7 +122,7 @@ class Origami::WasteSpoileController < BaseOrigamiController discount_price_by_accounts = SaleItem.get_discount_price_by_accounts(sale.sale_items) other_amount = SaleItem.calculate_other_charges(sale.sale_items) printer = Printer::ReceiptPrinter.new(print_settings) - filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings,cashier_terminal,sale.sale_items,sale,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details, remark,current_balance,nil,other_amount,nil,nil,nil) + filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings, false, nil,cashier_terminal,sale.sale_items,sale,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details, remark,current_balance,nil,other_amount,nil,nil,nil) result = { :filepath => filename, :printer_model => print_settings.brand_name, diff --git a/app/controllers/transactions/sales_controller.rb b/app/controllers/transactions/sales_controller.rb index 24c76b1d..e8a2d9e4 100755 --- a/app/controllers/transactions/sales_controller.rb +++ b/app/controllers/transactions/sales_controller.rb @@ -364,7 +364,7 @@ class Transactions::SalesController < ApplicationController other_amount = SaleItem.calculate_other_charges(sale.sale_items) #other charges printer = Printer::ReceiptPrinter.new(print_settings) - filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings,cashier_terminal,sale.sale_items,sale,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details, "VOID",current_balance,nil,other_amount,nil,nil,nil) + filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings, false, nil,cashier_terminal,sale.sale_items,sale,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details, "VOID",current_balance,nil,other_amount,nil,nil,nil) result = { :filepath => filename, :printer_model => print_settings.brand_name, diff --git a/app/models/order_reservation.rb b/app/models/order_reservation.rb index c75ad748..0be86204 100644 --- a/app/models/order_reservation.rb +++ b/app/models/order_reservation.rb @@ -203,7 +203,7 @@ class OrderReservation < ApplicationRecord other_amount = SaleItem.calculate_other_charges(saleObj.sale_items) printer = Printer::ReceiptPrinter.new(print_settings) - filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings,cashier_terminal,saleObj.sale_items,saleObj,saleObj.customer.name, item_price_by_accounts, discount_price_by_accounts, nil,nil,shop_detail, "Paid",nil,nil,other_amount,nil,nil, order_reservation) + filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings, false, nil,cashier_terminal,saleObj.sale_items,saleObj,saleObj.customer.name, item_price_by_accounts, discount_price_by_accounts, nil,nil,shop_detail, "Paid",nil,nil,other_amount,nil,nil, order_reservation) #receipt bill pdf setting result = {:status=> true, 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 715250ee5aab0a2de87fbf6aea31bbccf333d11b..f575419122eefaddf2cff507571b792afbec895d 100644 GIT binary patch delta 7134 zcmai3X`EbDmA~)R(w**CogkPP!1Q~yb@iINFMvr`Dji7DA&5F|h`NPAl)h>*duYcg>(Cz@e`hjy#je=DEVwjopcl~# z{ilqb>6E{)!Fq1lSm3N2yQy=<*skR#r^O)FV}7nY_W9+nNKx4s`$K1?t8@2N{#9or z{>7KZQ6m`homFFhTAm&AoKwcWyZn{QWCNY}!64gu%b4YynuRy0M%?;wl^UeDf$Z#+ z?}*0Z@bNTWty-*!ECe7!Hgaj4l|~m<>8i{!RvP}+x7N%SAHPx?|PfN^5t(H zTi>y=K9v2-JKTzW$;FYoe3hc1^20C+1rAvpU@3KAA{@DHcL=e*DvsXjUzIm8QABjo%#C(3iRlm}RB1t{oXK%F z#VFR*(Pniq!wn}m^v>?0A|VNr4EssQW8QQ|Erz{OOB3%oOG{WC=GB#?)LTUN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 11/12] kbz pay method --- .../origami/payments_controller.rb | 8 ++++---- app/models/kbz_pay.rb | 14 ++++++++----- config/puma.rb | 20 +++++++++---------- 3 files changed, 23 insertions(+), 19 deletions(-) diff --git a/app/controllers/origami/payments_controller.rb b/app/controllers/origami/payments_controller.rb index 370e9e85..b15062d6 100755 --- a/app/controllers/origami/payments_controller.rb +++ b/app/controllers/origami/payments_controller.rb @@ -105,17 +105,17 @@ class Origami::PaymentsController < BaseOrigamiController #TODO :: KBZPAY ( QR ) # On/Off setting ( show or not qr ) # qrCode = "00020101021202021110500346KBZ005ab0ed5c1ed09d1c4585ff1313170389160831435294600062000040732kp1e78f7efddca190042638341afb88d50200006KBZPay0106KBZPay5303MMK5802MM62170813PAY_BY_QRCODE64060002my6304FBBD" - kbz_pay_setting = PaymentMethodSetting.where(:payment_method => KbzPay::KBZ_PAY).last + kbz_pay_method = PaymentMethodSetting.where(:payment_method => KbzPay::KBZ_PAY).last status = false qr = nil - if !kbz_pay_setting.nil? - if kbz_pay_setting.is_active == true + if !kbz_pay_method.nil? + if kbz_pay_method.is_active == true sale_payment = SalePayment.new sale_payment.process_kbz_payment(sale_id, sale_data.grand_total, 0, 'pending') - status, qr = KbzPay.pay(sale_data.grand_total, sale_payment.sale_payment_id) + status, qr = KbzPay.pay(sale_data.grand_total, sale_payment.sale_payment_id, kbz_pay_method.gateway_url, kbz_pay_method.auth_token, kbz_pay_method.merchant_account_id, kbz_pay_method.additional_parameters) end end diff --git a/app/models/kbz_pay.rb b/app/models/kbz_pay.rb index c342a035..90fbac14 100644 --- a/app/models/kbz_pay.rb +++ b/app/models/kbz_pay.rb @@ -2,16 +2,20 @@ class KbzPay KBZ_PAY = 'KBZPay' - def self.pay(amount, receipt_no) + def self.pay(amount, receipt_no, url, key, app_id, code) datetime = DateTime.now.strftime("%d%m%Y%H%M") - kbz_app_id = "kp1e78f7efddca190042638341afb88d" - kbz_merch_code = "200004" + kbz_app_id = app_id + kbz_merch_code = code + # kbz_app_id = "kp1e78f7efddca190042638341afb88d" + # kbz_merch_code = "200004" kbz_method = 'kbz.payment.precreate' kbz_trade_type = "PAY_BY_QRCODE" - kbz_api_key = "code2lab123456" + kbz_api_key = key + # kbz_api_key = "code2lab123456" kbz_version = "1.0" - kbz_provider_url = "http://api.kbzpay.com/payment/gateway/uat/precreate" + kbz_provider_url = url + # kbz_provider_url = "http://api.kbzpay.com/payment/gateway/uat/precreate" kbz_currency = "MMK" kbz_callback_url = "https://staging-v2.doemal.com/api/v3/ordering/kbz_callback" nounce_str = SecureRandom.base64(32).first(32).upcase diff --git a/config/puma.rb b/config/puma.rb index 6a545bed..fd89392f 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! From 57d2da094d37b73e704994cc03cc484b996650d7 Mon Sep 17 00:00:00 2001 From: Zoey Date: Thu, 4 Jul 2019 10:04:17 +0630 Subject: [PATCH 12/12] prefix --- app/models/sale_order.rb | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/app/models/sale_order.rb b/app/models/sale_order.rb index e3b86f02..3e4fc085 100755 --- a/app/models/sale_order.rb +++ b/app/models/sale_order.rb @@ -33,13 +33,8 @@ class SaleOrder < ApplicationRecord private def generate_sale_order_id - prefix = "SOI" - if ENV["SERVER_MODE"] == 'cloud' - prefix = "CSOI" - end - - self.class.name - saleOrderId = SeedGenerator.generate_id(self.class.name, prefix) + # self.class.name + saleOrderId = SeedGenerator.generate_id(self.class.name, 'SOI') self.sale_order_id = saleOrderId end end