From 82048cf3cef4e004b0ba30d3fb28a1081246401e Mon Sep 17 00:00:00 2001 From: Ameya Shenoy Date: Fri, 23 Feb 2018 16:33:28 +0530 Subject: [PATCH] verify payment entry amount is positive (#13066) * verify payment entry amount is positive * Update sales_invoice.py * Update sales_invoice.py --- erpnext/accounts/doctype/sales_invoice/sales_invoice.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py index 2af30e1956..ee16e4c64a 100644 --- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py +++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py @@ -101,6 +101,8 @@ class SalesInvoice(SellingController): self.set_billing_hours_and_amount() self.update_timesheet_billing_for_project() self.set_status() + if self.is_pos and not self.is_return: + self.verify_payment_amount_is_positive() def before_save(self): set_account_for_mode_of_payment(self) @@ -903,6 +905,11 @@ class SalesInvoice(SellingController): project.update_billed_amount() project.save() + def verify_payment_amount_is_positive(self): + for entry in self.payments: + if entry.amount < 0: + frappe.throw(_("Row #{0} (Payment Table): Amount must be positive").format(entry.idx)) + def get_list_context(context=None): from erpnext.controllers.website_list_for_contact import get_list_context list_context = get_list_context(context)