Merge pull request #17546 from rohitwaghchaure/incorrect_payment_amount_if_advance_amount_in_si_develop
fix: incorrect payment amount in the payment terms if the sales invoice has the advance amount
This commit is contained in:
commit
39be1d43bc
@ -402,9 +402,9 @@ class TestPurchaseInvoice(unittest.TestCase):
|
||||
|
||||
pi.save()
|
||||
pi.submit()
|
||||
self.assertEqual(pi.payment_schedule[0].payment_amount, 756.15)
|
||||
self.assertEqual(pi.payment_schedule[0].payment_amount, 606.15)
|
||||
self.assertEqual(pi.payment_schedule[0].due_date, pi.posting_date)
|
||||
self.assertEqual(pi.payment_schedule[1].payment_amount, 756.15)
|
||||
self.assertEqual(pi.payment_schedule[1].payment_amount, 606.15)
|
||||
self.assertEqual(pi.payment_schedule[1].due_date, add_days(pi.posting_date, 30))
|
||||
|
||||
pi.load_from_db()
|
||||
|
@ -787,6 +787,9 @@ class AccountsController(TransactionBase):
|
||||
if self.doctype in ("Sales Invoice", "Purchase Invoice"):
|
||||
grand_total = grand_total - flt(self.write_off_amount)
|
||||
|
||||
if self.get("total_advance"):
|
||||
grand_total -= self.get("total_advance")
|
||||
|
||||
if not self.get("payment_schedule"):
|
||||
if self.get("payment_terms_template"):
|
||||
data = get_payment_terms(self.payment_terms_template, posting_date, grand_total)
|
||||
@ -832,6 +835,9 @@ class AccountsController(TransactionBase):
|
||||
total = flt(total, self.precision("grand_total"))
|
||||
|
||||
grand_total = flt(self.get("rounded_total") or self.grand_total, self.precision('grand_total'))
|
||||
if self.get("total_advance"):
|
||||
grand_total -= self.get("total_advance")
|
||||
|
||||
if self.doctype in ("Sales Invoice", "Purchase Invoice"):
|
||||
grand_total = grand_total - flt(self.write_off_amount)
|
||||
if total != grand_total:
|
||||
|
Loading…
x
Reference in New Issue
Block a user