mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-26 08:24:47 +00:00
enhancement: ensure subscription is cancelled before attempting to restart
This commit is contained in:
@@ -410,11 +410,14 @@ class Subscriptions(Document):
|
|||||||
subscription and the `Subscription` will lose all the history of generated invoices
|
subscription and the `Subscription` will lose all the history of generated invoices
|
||||||
it has.
|
it has.
|
||||||
"""
|
"""
|
||||||
self.status = 'Active'
|
if self.status == 'Canceled':
|
||||||
self.db_set('start', nowdate())
|
self.status = 'Active'
|
||||||
self.update_subscription_period(nowdate())
|
self.db_set('start', nowdate())
|
||||||
self.invoices = []
|
self.update_subscription_period(nowdate())
|
||||||
self.save()
|
self.invoices = []
|
||||||
|
self.save()
|
||||||
|
else:
|
||||||
|
frappe.throw(_('You cannot restart a Subscription that is not cancelled.'))
|
||||||
|
|
||||||
|
|
||||||
def process_all():
|
def process_all():
|
||||||
|
|||||||
@@ -447,3 +447,13 @@ class TestSubscriptions(unittest.TestCase):
|
|||||||
settings.cancel_after_grace = default_grace_period_action
|
settings.cancel_after_grace = default_grace_period_action
|
||||||
settings.save()
|
settings.save()
|
||||||
subscription.delete()
|
subscription.delete()
|
||||||
|
|
||||||
|
def test_restart_active_subscription(self):
|
||||||
|
subscription = frappe.new_doc('Subscriptions')
|
||||||
|
subscription.subscriber = '_Test Customer'
|
||||||
|
subscription.append('plans', {'plan': '_Test Plan Name'})
|
||||||
|
subscription.save()
|
||||||
|
|
||||||
|
self.assertRaises(frappe.ValidationError, subscription.restart_subscription)
|
||||||
|
|
||||||
|
subscription.delete()
|
||||||
|
|||||||
Reference in New Issue
Block a user