From b948f10209e534eb06e374f467d74805741918cc Mon Sep 17 00:00:00 2001 From: Zoey Date: Wed, 26 Jun 2019 12:05:37 +0630 Subject: [PATCH] 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"