enhancement: do nothing if cancel_sbscription is called for cancelled subscription

This commit is contained in:
tundebabzy 2018-03-03 07:39:44 +01:00
parent d43422c18e
commit 79a01561d5

View File

@ -396,13 +396,14 @@ class Subscriptions(Document):
This sets the subscription as cancelled. It will stop invoices from being generated This sets the subscription as cancelled. It will stop invoices from being generated
but it will not affect already created invoices. but it will not affect already created invoices.
""" """
to_generate_invoice = True if self.status == 'Active' else False if self.status != 'Canceled':
to_prorate = frappe.db.get_single_value('Subscription Settings', 'prorate') to_generate_invoice = True if self.status == 'Active' else False
self.status = 'Canceled' to_prorate = frappe.db.get_single_value('Subscription Settings', 'prorate')
self.cancelation_date = nowdate() self.status = 'Canceled'
if to_generate_invoice: self.cancelation_date = nowdate()
self.generate_invoice(prorate=to_prorate) if to_generate_invoice:
self.save() self.generate_invoice(prorate=to_prorate)
self.save()
def restart_subscription(self): def restart_subscription(self):
""" """