fix: incorrect payment amount in the payment terms if the sales invoice has the advance amount

This commit is contained in:
Rohit Waghchaure 2019-05-09 19:50:00 +05:30
parent 77bf60e1ac
commit 4a267b9340

View File

@ -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: