modify validation if doc has payment term schedule

This commit is contained in:
tunde 2017-08-19 08:21:44 +01:00
parent 4c5efa3dec
commit be1b871c53

View File

@ -44,6 +44,8 @@ class AccountsController(TransactionBase):
self.set_total_in_words() self.set_total_in_words()
if self.doctype in ("Sales Invoice", "Purchase Invoice") and not self.is_return: if self.doctype in ("Sales Invoice", "Purchase Invoice") and not self.is_return:
if self.get("payment_schedule"):
self.set_due_date()
self.validate_payment_schedule() self.validate_payment_schedule()
self.validate_due_date() self.validate_due_date()
self.validate_advance_entries() self.validate_advance_entries()
@ -626,6 +628,9 @@ class AccountsController(TransactionBase):
else: else:
self.due_date = max([d.due_date for d in self.get("payment_schedule")]) 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): def validate_payment_schedule(self):
if self.due_date and getdate(self.due_date) < getdate(self.posting_date): if self.due_date and getdate(self.due_date) < getdate(self.posting_date):
frappe.throw(_("Due Date cannot be before 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.throw(_("Total Payment Amount in Payment Schdule must be equal to Grand Total"))
@frappe.whitelist() @frappe.whitelist()
def get_tax_rate(account_head): def get_tax_rate(account_head):
return frappe.db.get_value("Account", account_head, ["tax_rate", "account_name"], as_dict=True) return frappe.db.get_value("Account", account_head, ["tax_rate", "account_name"], as_dict=True)