Merge pull request #23966 from deepeshgarg007/unpaid_subscription_fix

fix: Invoice generation for Unpaid subscriptions
This commit is contained in:
Deepesh Garg
2020-12-02 20:03:42 +05:30
committed by GitHub
2 changed files with 19 additions and 3 deletions

View File

@@ -13,6 +13,7 @@
"cancelation_date", "cancelation_date",
"trial_period_start", "trial_period_start",
"trial_period_end", "trial_period_end",
"generate_new_invoices_past_due_date",
"column_break_11", "column_break_11",
"current_invoice_start", "current_invoice_start",
"current_invoice_end", "current_invoice_end",
@@ -183,8 +184,7 @@
"fieldname": "invoices", "fieldname": "invoices",
"fieldtype": "Table", "fieldtype": "Table",
"label": "Invoices", "label": "Invoices",
"options": "Subscription Invoice", "options": "Subscription Invoice"
"read_only": 1
}, },
{ {
"collapsible": 1, "collapsible": 1,
@@ -195,9 +195,16 @@
{ {
"fieldname": "dimension_col_break", "fieldname": "dimension_col_break",
"fieldtype": "Column Break" "fieldtype": "Column Break"
},
{
"default": "0",
"description": "New invoices will be generated as per schedule even if current invoices are unpaid or past due date",
"fieldname": "generate_new_invoices_past_due_date",
"fieldtype": "Check",
"label": "Generate New Invoices Past Due Date"
} }
], ],
"modified": "2020-08-27 23:30:02.504042", "modified": "2020-11-29 22:46:14.879289",
"modified_by": "Administrator", "modified_by": "Administrator",
"module": "Accounts", "module": "Accounts",
"name": "Subscription", "name": "Subscription",

View File

@@ -408,6 +408,15 @@ class Subscription(Document):
else: else:
self.set_status_grace_period() self.set_status_grace_period()
if getdate() > getdate(self.current_invoice_end):
self.update_subscription_period(add_days(self.current_invoice_end, 1))
# Generate invoices periodically even if current invoice are unpaid
if self.generate_new_invoices_past_due_date and not self.is_current_invoice_generated() and (self.is_postpaid_to_invoice()
or self.is_prepaid_to_invoice()):
prorate = frappe.db.get_single_value('Subscription Settings', 'prorate')
self.generate_invoice(prorate)
@staticmethod @staticmethod
def is_not_outstanding(invoice): def is_not_outstanding(invoice):
""" """