mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-31 10:49:09 +00:00
sets Subscription doc status in before_save
This commit is contained in:
@@ -27,3 +27,18 @@ class Subscriptions(Document):
|
|||||||
|
|
||||||
def set_current_invoice_end(self):
|
def set_current_invoice_end(self):
|
||||||
self.current_invoice_end = get_last_day(self.current_invoice_start)
|
self.current_invoice_end = get_last_day(self.current_invoice_start)
|
||||||
|
|
||||||
|
def before_save(self):
|
||||||
|
self.set_status()
|
||||||
|
|
||||||
|
def set_status(self):
|
||||||
|
if self.is_trialling():
|
||||||
|
self.status = 'Trialling'
|
||||||
|
elif self.status == 'Past Due' and self.is_past_grace_period():
|
||||||
|
self.status = 'Canceled' if cint(SUBSCRIPTION_SETTINGS.cancel_after_grace) else 'Unpaid'
|
||||||
|
elif self.current_invoice_is_past_due():
|
||||||
|
self.status = 'Past Due'
|
||||||
|
elif self.is_new_subscription():
|
||||||
|
self.status = 'Active'
|
||||||
|
# todo: then generate new invoice
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user