From 6041f5cb8cce8005e95886d6d9a8258835914107 Mon Sep 17 00:00:00 2001 From: Faris Ansari Date: Thu, 8 Feb 2018 13:33:52 +0530 Subject: [PATCH] [hotfix] Advance Total validation --- erpnext/controllers/taxes_and_totals.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/erpnext/controllers/taxes_and_totals.py b/erpnext/controllers/taxes_and_totals.py index 0e35cb89e6..699e1c608f 100644 --- a/erpnext/controllers/taxes_and_totals.py +++ b/erpnext/controllers/taxes_and_totals.py @@ -415,13 +415,15 @@ class calculate_taxes_and_totals(object): self.doc.total_advance = flt(total_allocated_amount, self.doc.precision("total_advance")) + grand_total = self.doc.rounded_total or self.doc.grand_total + if self.doc.party_account_currency == self.doc.currency: - invoice_total = flt(self.doc.grand_total - flt(self.doc.write_off_amount), + invoice_total = flt(grand_total - flt(self.doc.write_off_amount), self.doc.precision("grand_total")) else: base_write_off_amount = flt(flt(self.doc.write_off_amount) * self.doc.conversion_rate, self.doc.precision("base_write_off_amount")) - invoice_total = flt(self.doc.grand_total * self.doc.conversion_rate, + invoice_total = flt(grand_total * self.doc.conversion_rate, self.doc.precision("grand_total")) - base_write_off_amount if invoice_total > 0 and self.doc.total_advance > invoice_total: