From 00c9e20df3bb88a78825b58afa13c94f5fa86c36 Mon Sep 17 00:00:00 2001 From: Jatin3128 Date: Thu, 18 Dec 2025 16:01:08 +0530 Subject: [PATCH] fix(subscription): add cancellation and date validation --- erpnext/accounts/doctype/subscription/subscription.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/erpnext/accounts/doctype/subscription/subscription.py b/erpnext/accounts/doctype/subscription/subscription.py index c96a95ec1e7..68303bccdfd 100644 --- a/erpnext/accounts/doctype/subscription/subscription.py +++ b/erpnext/accounts/doctype/subscription/subscription.py @@ -561,6 +561,17 @@ class Subscription(Document): self.current_invoice_start, self.current_invoice_end ) and self.can_generate_new_invoice(posting_date): self.generate_invoice(posting_date=posting_date) + if self.end_date: + next_start = add_days(self.current_invoice_end, 1) + + if getdate(next_start) > getdate(self.end_date): + if self.cancel_at_period_end: + self.cancel_subscription() + else: + self.set_subscription_status(posting_date=posting_date) + + self.save() + return self.update_subscription_period(add_days(self.current_invoice_end, 1)) elif posting_date and getdate(posting_date) > getdate(self.current_invoice_end): self.update_subscription_period()