From be1b871c534a3089753bdc0ec428183bacea17a2 Mon Sep 17 00:00:00 2001 From: tunde Date: Sat, 19 Aug 2017 08:21:44 +0100 Subject: [PATCH] modify validation if doc has payment term schedule --- erpnext/controllers/accounts_controller.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/erpnext/controllers/accounts_controller.py b/erpnext/controllers/accounts_controller.py index 346c4aaa6c7..c5390ffe47e 100644 --- a/erpnext/controllers/accounts_controller.py +++ b/erpnext/controllers/accounts_controller.py @@ -44,7 +44,9 @@ class AccountsController(TransactionBase): self.set_total_in_words() if self.doctype in ("Sales Invoice", "Purchase Invoice") and not self.is_return: - self.validate_payment_schedule() + if self.get("payment_schedule"): + self.set_due_date() + self.validate_payment_schedule() self.validate_due_date() self.validate_advance_entries() @@ -626,6 +628,9 @@ class AccountsController(TransactionBase): else: self.due_date = max([d.due_date for d in self.get("payment_schedule")]) + def set_due_date(self): + self.due_date = max([d.due_date for d in self.get("payment_schedule")]) + def validate_payment_schedule(self): if self.due_date and getdate(self.due_date) < getdate(self.posting_date): frappe.throw(_("Due Date cannot be before posting date")) @@ -641,7 +646,6 @@ class AccountsController(TransactionBase): frappe.throw(_("Total Payment Amount in Payment Schdule must be equal to Grand Total")) - @frappe.whitelist() def get_tax_rate(account_head): return frappe.db.get_value("Account", account_head, ["tax_rate", "account_name"], as_dict=True)