Merge pull request #5130 from anandpdoshi/fix/validate-pos-paid-amount

[fix] POS paid amount validation using grand total
This commit is contained in:
Anand Doshi
2016-04-04 15:22:51 +05:30
2 changed files with 20 additions and 18 deletions

View File

@@ -375,7 +375,7 @@ class SalesInvoice(SellingController):
frappe.throw(_("Cash or Bank Account is mandatory for making payment entry")) frappe.throw(_("Cash or Bank Account is mandatory for making payment entry"))
if flt(self.paid_amount) + flt(self.write_off_amount) \ if flt(self.paid_amount) + flt(self.write_off_amount) \
- flt(self.base_grand_total) > 1/(10**(self.precision("base_grand_total") + 1)): - flt(self.grand_total) > 1/(10**(self.precision("grand_total") + 1)):
frappe.throw(_("""Paid amount + Write Off Amount can not be greater than Grand Total""")) frappe.throw(_("""Paid amount + Write Off Amount can not be greater than Grand Total"""))

View File

@@ -419,6 +419,8 @@ class calculate_taxes_and_totals(object):
return return
self.doc.round_floats_in(self.doc, ["grand_total", "total_advance", "write_off_amount"]) self.doc.round_floats_in(self.doc, ["grand_total", "total_advance", "write_off_amount"])
self._set_in_company_currency(self.doc, ['write_off_amount'])
if self.doc.party_account_currency == self.doc.currency: if self.doc.party_account_currency == self.doc.currency:
total_amount_to_pay = flt(self.doc.grand_total - self.doc.total_advance total_amount_to_pay = flt(self.doc.grand_total - self.doc.total_advance
- flt(self.doc.write_off_amount), self.doc.precision("grand_total")) - flt(self.doc.write_off_amount), self.doc.precision("grand_total"))