diff --git a/app/controllers/origami/discounts_controller.rb b/app/controllers/origami/discounts_controller.rb index cf723fd6..2e94fe1c 100755 --- a/app/controllers/origami/discounts_controller.rb +++ b/app/controllers/origami/discounts_controller.rb @@ -161,7 +161,7 @@ class Origami::DiscountsController < BaseOrigamiController sale = Sale.find(sale_id) # Check for Card Payment - is_card_payment = SaleItem.get_sale_payments_by_card(sale.sale_payments) + is_card_payment = SalePayment.get_sale_payments_by_card(sale.sale_payments) if is_card_payment != true account_types = Account.where("discount=?",true) diff --git a/app/models/sale_item.rb b/app/models/sale_item.rb index a757b7fd..f6470a71 100755 --- a/app/models/sale_item.rb +++ b/app/models/sale_item.rb @@ -145,17 +145,6 @@ class SaleItem < ApplicationRecord return price,type end - # Check for Card Payment - def self.get_sale_payments_by_card(sale_payments) - - # Check for Card Payment - sale_payments.each do |sp| - if sp.payment_method == "jcb" || sp.payment_method == "mpu" || sp.payment_method == "visa" || sp.payment_method == "master" - return true; - end - end - - end # def self.get_overall_discount(sale_id) # price = 0.0 # item=SaleItem.where("product_code=?", sale_id) diff --git a/app/models/sale_payment.rb b/app/models/sale_payment.rb index cb6b1249..7840817e 100755 --- a/app/models/sale_payment.rb +++ b/app/models/sale_payment.rb @@ -155,6 +155,16 @@ class SalePayment < ApplicationRecord end + # Check for Card Payment + def self.get_sale_payments_by_card(sale_payments) + # Check for Card Payment + sale_payments.each do |sp| + if sp.payment_method == "jcb" || sp.payment_method == "mpu" || sp.payment_method == "visa" || sp.payment_method == "master" + return true; + end + end + end + private def cash_payment payment_status = false @@ -497,8 +507,6 @@ class SalePayment < ApplicationRecord end - - private def generate_custom_id self.sale_payment_id = SeedGenerator.generate_id(self.class.name, "SPI") diff --git a/app/views/origami/visa/index.html.erb b/app/views/origami/visa/index.html.erb index d50853b4..dead9527 100755 --- a/app/views/origami/visa/index.html.erb +++ b/app/views/origami/visa/index.html.erb @@ -167,7 +167,7 @@ $.ajax({ type: "POST", url: "/origami/" + sale_id + "/member_discount", - data: {'sale_id':sale_id, 'sub_total':sub_total,'is_card':false }, + data: {'sale_id':sale_id, 'sub_total':sub_total,'is_card':true }, // success:function(result){ // } });