From 63991886964d8430a4a06b032b477808ffcf7e24 Mon Sep 17 00:00:00 2001 From: Aung Myo Date: Fri, 12 Jan 2018 09:23:41 +0630 Subject: [PATCH] update customer and ability --- app/models/ability.rb | 10 +++++----- app/models/customer.rb | 8 ++++++-- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/app/models/ability.rb b/app/models/ability.rb index 02b2618f..e6cdf9c3 100755 --- a/app/models/ability.rb +++ b/app/models/ability.rb @@ -104,11 +104,11 @@ class Ability can :index, :other_charge can :create, :other_charge - can :index, :discount - can :create, :discount - can :remove_discount_items, :discount - can :remove_all_discount, :discount - can :member_discount, :discount + # can :index, :discount + # can :create, :discount + # can :remove_discount_items, :discount + # can :remove_all_discount, :discount + # can :member_discount, :discount can :first_bill, :payment can :show, :payment diff --git a/app/models/customer.rb b/app/models/customer.rb index c228e3e6..949093ea 100755 --- a/app/models/customer.rb +++ b/app/models/customer.rb @@ -146,9 +146,10 @@ class Customer < ApplicationRecord if sale.customer.membership_id response = self.rebat(Sale.find(sale.sale_id)) #record an payment in sale-audit + if !response.nil? remark = "UPdate Rebate Response - #{response} for Customer #{sale.customer_id} Sale Id [#{sale.sale_id}]| pay amount -> #{sale.amount_received} " sale_audit = SaleAudit.record_paymal(sale.sale_id, remark, 1) - + end if response["status"] == true status = sale.update_attributes(rebate_status: "true") end @@ -159,8 +160,9 @@ class Customer < ApplicationRecord def self.rebat(sObj) rebate_prices,campaign_method = SaleItem.calculate_rebate_by_account(sObj.sale_items) generic_customer_id = sObj.customer.membership_id - if generic_customer_id.present? + + if generic_customer_id.present? paypar = sObj.sale_payments payparcost = 0 credit = 0 @@ -171,6 +173,7 @@ class Customer < ApplicationRecord end if pp.payment_method == "creditnote" credit = 1 + sObj.update_attributes(rebate_status: nil) end end # overall_dis = SaleItem.get_overall_discount(sObj.id) @@ -287,6 +290,7 @@ class Customer < ApplicationRecord end end else + puts "no Response" response = { "status": "no_member", "message": "Not membership"} end end