Credit payment

This commit is contained in:
Phyo
2017-06-27 12:05:45 +06:30
parent b5518c2ddb
commit f8062cec64

View File

@@ -97,7 +97,7 @@ class SalePayment < ApplicationRecord
sale_data.sale_payments.each do |sale_payment|
others = others + sale_payment.payment_amount
end
redeem_prices = sale_data.grand_total -others
redeem_prices = sale_data.grand_total - others
# Control for Paypar Cloud
begin
response = HTTParty.post(url,
@@ -232,11 +232,19 @@ class SalePayment < ApplicationRecord
self.sale.amount_changed = self.sale.amount_received.to_f - self.sale.grand_total.to_f
all_received_amount = 0.0
sObj = Sale.find(self.sale_id)
is_credit = 0
sObj.sale_payments.each do |spay|
all_received_amount += spay.payment_amount.to_f
if spay.payment_method == "creditnote"
is_credit = 1
end
end
if (self.sale.grand_total <= all_received_amount)
self.sale.payment_status = "paid"
if is_credit == 0
self.sale.payment_status = "paid"
else
self.sale.payment_status = "outstanding"
end
self.sale.sale_status = "completed"
self.sale.save!
table_update_status(sObj)