From fa152214552e37236ff927e35ed09d016933a26c Mon Sep 17 00:00:00 2001 From: Deepesh Garg Date: Mon, 28 Nov 2022 19:22:35 +0530 Subject: [PATCH] fix: Auto repeat date validations --- erpnext/controllers/accounts_controller.py | 4 ++++ erpnext/controllers/buying_controller.py | 1 + erpnext/controllers/selling_controller.py | 1 + 3 files changed, 6 insertions(+) diff --git a/erpnext/controllers/accounts_controller.py b/erpnext/controllers/accounts_controller.py index 1849e8b3b5..dc42a89df7 100644 --- a/erpnext/controllers/accounts_controller.py +++ b/erpnext/controllers/accounts_controller.py @@ -239,6 +239,10 @@ class AccountsController(TransactionBase): else: item.set(field_map.get(self.doctype), default_deferred_account) + def validate_auto_repeat_subscription_dates(self): + if getdate(self.from_date) > getdate(self.to_date): + frappe.throw(_("To Date cannot be before From Date"), title=_("Invalid Auto Repeat Date")) + def validate_deferred_start_and_end_date(self): for d in self.items: if d.get("enable_deferred_revenue") or d.get("enable_deferred_expense"): diff --git a/erpnext/controllers/buying_controller.py b/erpnext/controllers/buying_controller.py index 48fe7cb083..051460474a 100644 --- a/erpnext/controllers/buying_controller.py +++ b/erpnext/controllers/buying_controller.py @@ -41,6 +41,7 @@ class BuyingController(SubcontractingController): self.validate_from_warehouse() self.set_supplier_address() self.validate_asset_return() + self.validate_auto_repeat_subscription_dates() if self.doctype == "Purchase Invoice": self.validate_purchase_receipt_if_update_stock() diff --git a/erpnext/controllers/selling_controller.py b/erpnext/controllers/selling_controller.py index e8e9076975..f4276802b7 100644 --- a/erpnext/controllers/selling_controller.py +++ b/erpnext/controllers/selling_controller.py @@ -40,6 +40,7 @@ class SellingController(StockController): self.set_customer_address() self.validate_for_duplicate_items() self.validate_target_warehouse() + self.validate_auto_repeat_subscription_dates() def set_missing_values(self, for_validate=False):