[fix] Advance adjustment in invoice cannot be greater than grand total

This commit is contained in:
Nabin Hait
2016-02-08 11:06:55 +05:30
parent 45805622e4
commit 289ffb788c
3 changed files with 28 additions and 3 deletions

View File

@@ -397,6 +397,16 @@ class calculate_taxes_and_totals(object):
for adv in self.doc.get("advances")])
self.doc.total_advance = flt(total_allocated_amount, self.doc.precision("total_advance"))
if self.doc.party_account_currency == self.doc.currency:
invoice_total = self.doc.grand_total
else:
invoice_total = flt(self.doc.grand_total * self.doc.conversion_rate,
self.doc.precision("grand_total"))
if self.doc.total_advance > invoice_total:
frappe.throw(_("Advance amount cannot be greater than {0} {1}")
.format(self.doc.party_account_currency, invoice_total))
if self.doc.docstatus == 0:
self.calculate_outstanding_amount()