fix: update 'current_invoice_end' after processing invoice (#28278)

This commit is contained in:
Saqib 2021-11-09 14:16:38 +05:30 committed by GitHub
parent 34f5283c17
commit 4a3cef6436
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -519,8 +519,6 @@ class Subscription(Document):
2. Change the `Subscription` status to 'Past Due Date'
3. Change the `Subscription` status to 'Cancelled'
"""
if getdate() > getdate(self.current_invoice_end) and self.is_prepaid_to_invoice():
self.update_subscription_period(add_days(self.current_invoice_end, 1))
if not self.is_current_invoice_generated(self.current_invoice_start, self.current_invoice_end) \
and (self.is_postpaid_to_invoice() or self.is_prepaid_to_invoice()):
@ -528,6 +526,9 @@ class Subscription(Document):
prorate = frappe.db.get_single_value('Subscription Settings', 'prorate')
self.generate_invoice(prorate)
if getdate() > getdate(self.current_invoice_end) and self.is_prepaid_to_invoice():
self.update_subscription_period(add_days(self.current_invoice_end, 1))
if self.cancel_at_period_end and getdate() > getdate(self.current_invoice_end):
self.cancel_subscription_at_period_end()