change hardcoded payment methods

This commit is contained in:
NyanLinHtut
2020-06-08 10:13:55 +06:30
parent 51932b8a86
commit 98ca01533e
16 changed files with 302 additions and 646 deletions

View File

@@ -11,7 +11,7 @@ class SalePayment < ApplicationRecord
attr_accessor :received_amount, :card_payment_reference, :voucher_no, :giftcard_no, :customer_id, :external_payment_status,:action_by
scope :credits, -> { where(payment_method: 'creditnote') }
scope :cards, -> { where(payment_method: ['mpu', 'visa', 'master', 'jcb', 'unionpay', 'alipay', 'paymal', 'dinga', 'JunctionPay', 'giftvoucher']) }
scope :cards, -> { where(payment_method: PaymentMethodSetting.where("is_active='1'").pluck("payment_method")) }
def self.sync_sale_payment_records(sale_payments)
if !sale_payments.nil?
@@ -364,10 +364,16 @@ class SalePayment < ApplicationRecord
# Check for Card Payment
def self.get_sale_payments_by_card(sale_payments)
# Check for Card Payment
payment_methods = SalePayment.where.not(payment_method: ['cash', 'creditnote', 'foc']).distinct.pluck(:payment_method)
sale_payments.each do |sp|
if sp.payment_method == "jcb" || sp.payment_method == "mpu" || sp.payment_method == "visa" || sp.payment_method == "master" || sp.payment_method == "unionpay" || sp.payment_method == "alipay"
return true;
payment_methods.each do |m|
if sp.payment_method == m
return true;
end
end
# if sp.payment_method == "jcb" || sp.payment_method == "mpu" || sp.payment_method == "visa" || sp.payment_method == "master" || sp.payment_method == "unionpay" || sp.payment_method == "alipay"
# return true;
# end
end
end