From f4b7fa898054eae432bf72659e684e82ed76eb06 Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Thu, 9 Jan 2025 18:51:27 +0100 Subject: [PATCH] feat: validate discount date in payment schedule (backport #44646) (#44726) Co-authored-by: barredterra <14891507+barredterra@users.noreply.github.com> --- erpnext/controllers/accounts_controller.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/erpnext/controllers/accounts_controller.py b/erpnext/controllers/accounts_controller.py index 15748868510..fa26fea3bf0 100644 --- a/erpnext/controllers/accounts_controller.py +++ b/erpnext/controllers/accounts_controller.py @@ -2188,6 +2188,9 @@ class AccountsController(TransactionBase): return for d in self.get("payment_schedule"): + if d.due_date and d.discount_date: + d.validate_from_to_dates("discount_date", "due_date") + if self.doctype == "Sales Order" and getdate(d.due_date) < getdate(self.transaction_date): frappe.throw( _("Row {0}: Due Date in the Payment Terms table cannot be before Posting Date").format(