Credit note Rebate Prevent

This commit is contained in:
Phyo
2017-07-02 14:20:23 +06:30
parent a86ac10e83
commit 70668e4264
2 changed files with 9 additions and 3 deletions

View File

@@ -306,16 +306,22 @@ class SalePayment < ApplicationRecord
if generic_customer_id != nil || generic_customer_id != "" || generic_customer_id != 0
paypar = sObj.sale_payments
payparcost = 0
credit = 0
paypar.each do |pp|
if pp.payment_method == "paypar"
payparcost = payparcost + pp.payment_amount
elsif pp.payment_method == "creditnote"
credit = 1
end
end
# overall_dis = SaleItem.get_overall_discount(sObj.id)
overall_dis = sObj.total_discount
total_amount = rebate_prices - payparcost - overall_dis
if total_amount > 0
if credit == 1
total_amount = 0
end
if total_amount >= 0
receipt_no = sObj.receipt_no
membership = MembershipSetting.find_by_membership_type("paypar_url")
memberaction = MembershipAction.find_by_membership_type("rebate")