Browse Source

fix: reorder updation of end date

develop
hrwx 3 years ago
parent
commit
0f03b19109
  1. 6
      erpnext/accounts/doctype/subscription/subscription.py
  2. 39
      erpnext/accounts/doctype/subscription/test_subscription.py

6
erpnext/accounts/doctype/subscription/subscription.py

@ -542,8 +542,7 @@ class Subscription(Document):
else:
self.set_status_grace_period()
if getdate() > getdate(self.current_invoice_end):
self.update_subscription_period(add_days(self.current_invoice_end, 1))
update_subscription = True if getdate() > getdate(self.current_invoice_end) else False
# 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()
@ -551,6 +550,9 @@ class Subscription(Document):
prorate = frappe.db.get_single_value('Subscription Settings', 'prorate')
self.generate_invoice(prorate)
if update_subscription:
self.update_subscription_period(add_days(self.current_invoice_end, 1))
@staticmethod
def is_paid(invoice):
"""

39
erpnext/accounts/doctype/subscription/test_subscription.py

@ -20,6 +20,43 @@ from erpnext.accounts.doctype.subscription.subscription import get_prorata_facto
def create_plan():
if not frappe.db.exists('UOM', {"name": '_Test UOM'}):
frappe.get_doc({
"doctype": "UOM",
"uom_name": "_Test UOM"
}).insert()
if not frappe.db.exists('Item Group', {"name": '_Test Item Group Desktops'}):
frappe.get_doc({
"doctype": "Item Group",
"is_group": 0,
"item_group_name": "_Test Item Group Desktops",
"parent_item_group": "All Item Groups"
}).insert()
if not frappe.db.exists('Item', {"item_name": '_Test Non Stock Item'}):
frappe.get_doc({
"description": "_Test Non Stock Item 7",
"doctype": "Item",
"has_batch_no": 0,
"has_serial_no": 0,
"inspection_required": 0,
"is_stock_item": 0,
"is_sub_contracted_item": 0,
"item_code": "_Test Non Stock Item",
"item_group": "_Test Item Group Desktops",
"item_name": "_Test Non Stock Item",
"stock_uom": "_Test UOM",
"gst_hsn_code": "999800",
"item_defaults": [{
"company": "_Test Company",
"default_warehouse": "Finished Goods - _TC",
"expense_account": "Gegenkonto zu Konto 9260 - 9268 - _TC",
"income_account": "Kurzfristige Rückstellungen - _TC"
}]
}).insert()
if not frappe.db.exists('Subscription Plan', '_Test Plan Name'):
plan = frappe.new_doc('Subscription Plan')
plan.plan_name = '_Test Plan Name'
@ -619,7 +656,7 @@ class TestSubscription(unittest.TestCase):
# subscription
subscription.process()
self.assertEqual(len(subscription.invoices), 2)
self.assertEqual(len(subscription.invoices), 1)
def test_subscription_without_generate_invoice_past_due(self):
subscription = frappe.new_doc('Subscription')

Loading…
Cancel
Save