close cashier total foc fixed

This commit is contained in:
yarzar_code
2020-06-15 13:26:34 +06:30
parent a7f9fc1199
commit 160c43699e
2 changed files with 8 additions and 11 deletions

View File

@@ -643,18 +643,14 @@ class SalePayment < ApplicationRecord
is_foc = sale_payments.any? { |x| x.payment_method == "foc" } || check_foc
if is_foc
total_payment_amount = 0.0
else
total_payment_amount = sale_payments.sum(&:payment_amount)
end
sale.amount_received = sale.amount_received.to_f + paid_amount.to_f
sale.amount_changed = total_payment_amount - sale.grand_total.to_f
if is_foc
sale.amount_received = 0.0
sale.amount_changed = 0.0
sale.payment_status = 'foc'
sale.sale_status = 'completed'
elsif sale.grand_total <= total_payment_amount && sale.sale_status == "new"
elsif sale.grand_total <= sale_payments.sum(&:payment_amount) && sale.sale_status == "new"
sale.amount_received = sale.amount_received + paid_amount
sale.amount_changed = sale_payments.sum(&:payment_amount) - sale.grand_total
sale.payment_status = "paid"
if is_credit
sale.payment_status = "outstanding"