mirror of
https://github.com/frappe/erpnext.git
synced 2026-06-02 19:59:12 +00:00
fix: reorder updation of end date
(cherry picked from commit 0f03b19109)
This commit is contained in:
@@ -538,8 +538,7 @@ class Subscription(Document):
|
|||||||
else:
|
else:
|
||||||
self.set_status_grace_period()
|
self.set_status_grace_period()
|
||||||
|
|
||||||
if getdate() > getdate(self.current_invoice_end):
|
update_subscription = True if getdate() > getdate(self.current_invoice_end) else False
|
||||||
self.update_subscription_period(add_days(self.current_invoice_end, 1))
|
|
||||||
|
|
||||||
# Generate invoices periodically even if current invoice are unpaid
|
# 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()
|
if self.generate_new_invoices_past_due_date and not self.is_current_invoice_generated() and (self.is_postpaid_to_invoice()
|
||||||
@@ -547,6 +546,9 @@ class Subscription(Document):
|
|||||||
prorate = frappe.db.get_single_value('Subscription Settings', 'prorate')
|
prorate = frappe.db.get_single_value('Subscription Settings', 'prorate')
|
||||||
self.generate_invoice(prorate)
|
self.generate_invoice(prorate)
|
||||||
|
|
||||||
|
if update_subscription:
|
||||||
|
self.update_subscription_period(add_days(self.current_invoice_end, 1))
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def is_paid(invoice):
|
def is_paid(invoice):
|
||||||
"""
|
"""
|
||||||
|
|||||||
@@ -20,6 +20,43 @@ from erpnext.accounts.doctype.subscription.subscription import get_prorata_facto
|
|||||||
|
|
||||||
|
|
||||||
def create_plan():
|
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'):
|
if not frappe.db.exists('Subscription Plan', '_Test Plan Name'):
|
||||||
plan = frappe.new_doc('Subscription Plan')
|
plan = frappe.new_doc('Subscription Plan')
|
||||||
plan.plan_name = '_Test Plan Name'
|
plan.plan_name = '_Test Plan Name'
|
||||||
@@ -619,7 +656,7 @@ class TestSubscription(unittest.TestCase):
|
|||||||
# subscription
|
# subscription
|
||||||
|
|
||||||
subscription.process()
|
subscription.process()
|
||||||
self.assertEqual(len(subscription.invoices), 2)
|
self.assertEqual(len(subscription.invoices), 1)
|
||||||
|
|
||||||
def test_subscription_without_generate_invoice_past_due(self):
|
def test_subscription_without_generate_invoice_past_due(self):
|
||||||
subscription = frappe.new_doc('Subscription')
|
subscription = frappe.new_doc('Subscription')
|
||||||
|
|||||||
Reference in New Issue
Block a user