From 1562e9b8282311364f04d1676ae13407f77ce6bf Mon Sep 17 00:00:00 2001 From: Nishka Gosalia Date: Wed, 17 Dec 2025 14:44:24 +0530 Subject: [PATCH] fix: Disallow due date to be before the posting date in Quotation --- erpnext/controllers/accounts_controller.py | 4 +++- erpnext/selling/doctype/quotation/test_quotation.py | 5 +++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/erpnext/controllers/accounts_controller.py b/erpnext/controllers/accounts_controller.py index f80cf4aaf53..f134f588ed8 100644 --- a/erpnext/controllers/accounts_controller.py +++ b/erpnext/controllers/accounts_controller.py @@ -2707,7 +2707,9 @@ class AccountsController(TransactionBase): for d in self.get("payment_schedule"): d.validate_from_to_dates("discount_date", "due_date") - if self.doctype == "Sales Order" and getdate(d.due_date) < getdate(self.transaction_date): + if self.doctype in ["Sales Order", "Quotation"] 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( d.idx diff --git a/erpnext/selling/doctype/quotation/test_quotation.py b/erpnext/selling/doctype/quotation/test_quotation.py index 069843518d7..d0813762ac4 100644 --- a/erpnext/selling/doctype/quotation/test_quotation.py +++ b/erpnext/selling/doctype/quotation/test_quotation.py @@ -52,6 +52,11 @@ class TestQuotation(IntegrationTestCase): self.assertEqual(qo.get("items")[0].qty, 11) self.assertEqual(qo.get("items")[-1].rate, 100) + def test_disallow_due_date_before_transaction_date(self): + qo = make_quotation(qty=3, do_not_submit=1) + qo.payment_schedule[0].due_date = add_days(qo.transaction_date, -2) + self.assertRaises(frappe.ValidationError, qo.save) + def test_update_child_disallow_rate_change(self): qo = make_quotation(qty=4) trans_item = json.dumps(