diff --git a/erpnext/controllers/accounts_controller.py b/erpnext/controllers/accounts_controller.py index 1849e8b3b5..b7a80c1019 100644 --- a/erpnext/controllers/accounts_controller.py +++ b/erpnext/controllers/accounts_controller.py @@ -239,6 +239,14 @@ class AccountsController(TransactionBase): else: item.set(field_map.get(self.doctype), default_deferred_account) + def validate_auto_repeat_subscription_dates(self): + if ( + self.get("from_date") + and self.get("to_date") + and 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 88d2f0687d..965335b1a3 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):