Credit payment
This commit is contained in:
@@ -97,7 +97,7 @@ class SalePayment < ApplicationRecord
|
|||||||
sale_data.sale_payments.each do |sale_payment|
|
sale_data.sale_payments.each do |sale_payment|
|
||||||
others = others + sale_payment.payment_amount
|
others = others + sale_payment.payment_amount
|
||||||
end
|
end
|
||||||
redeem_prices = sale_data.grand_total -others
|
redeem_prices = sale_data.grand_total - others
|
||||||
# Control for Paypar Cloud
|
# Control for Paypar Cloud
|
||||||
begin
|
begin
|
||||||
response = HTTParty.post(url,
|
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
|
self.sale.amount_changed = self.sale.amount_received.to_f - self.sale.grand_total.to_f
|
||||||
all_received_amount = 0.0
|
all_received_amount = 0.0
|
||||||
sObj = Sale.find(self.sale_id)
|
sObj = Sale.find(self.sale_id)
|
||||||
|
is_credit = 0
|
||||||
sObj.sale_payments.each do |spay|
|
sObj.sale_payments.each do |spay|
|
||||||
all_received_amount += spay.payment_amount.to_f
|
all_received_amount += spay.payment_amount.to_f
|
||||||
|
if spay.payment_method == "creditnote"
|
||||||
|
is_credit = 1
|
||||||
|
end
|
||||||
end
|
end
|
||||||
if (self.sale.grand_total <= all_received_amount)
|
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.sale_status = "completed"
|
||||||
self.sale.save!
|
self.sale.save!
|
||||||
table_update_status(sObj)
|
table_update_status(sObj)
|
||||||
|
|||||||
Reference in New Issue
Block a user