SQA feedback

This commit is contained in:
phyusin
2018-03-19 19:34:34 +06:30
parent 25b6458450
commit bf84392ef8
13 changed files with 289 additions and 129 deletions

View File

@@ -325,6 +325,7 @@ class SalePayment < ApplicationRecord
sObj = Sale.find(self.sale_id)
is_credit = 0
is_foc = 0
is_cash = false
sObj.sale_payments.each do |spay|
all_received_amount += spay.payment_amount.to_f
if spay.payment_method == "creditnote"
@@ -333,8 +334,12 @@ class SalePayment < ApplicationRecord
if spay.payment_method == "foc"
is_foc = 1
end
if spay.payment_method.to_s == "cash"
is_cash = true
end
end
if (self.sale.grand_total <= all_received_amount)
if (self.sale.grand_total <= all_received_amount) && is_cash
if is_credit == 0
self.sale.payment_status = "paid"
else
@@ -374,11 +379,15 @@ class SalePayment < ApplicationRecord
end
self.sale.save!
table_update_status(sObj)
if check_foc
table_update_status(sObj)
update_shift
elsif paid_amount.to_f > 0 #|| paid_amount != "0.0"
table_update_status(sObj)
update_shift
elsif is_cash && paid_amount.to_f == 0
table_update_status(sObj)
update_shift
end
end