From 4f067085e73caca988d6625e7f74b245aff7cfac Mon Sep 17 00:00:00 2001 From: ravibharathi656 Date: Mon, 6 Oct 2025 12:12:27 +0530 Subject: [PATCH] test: add invoice generation before period with prorate (cherry picked from commit b452e06b82756d91e062f1906e0eb8408a4abd03) --- .../doctype/subscription/test_subscription.py | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/erpnext/accounts/doctype/subscription/test_subscription.py b/erpnext/accounts/doctype/subscription/test_subscription.py index b1e5653e8da..1d906fb9276 100644 --- a/erpnext/accounts/doctype/subscription/test_subscription.py +++ b/erpnext/accounts/doctype/subscription/test_subscription.py @@ -8,6 +8,7 @@ from frappe.utils.data import ( add_days, add_months, add_to_date, + add_years, cint, date_diff, flt, @@ -555,6 +556,33 @@ class TestSubscription(FrappeTestCase): subscription.reload() self.assertEqual(len(subscription.invoices), 0) + def test_invoice_generation_days_before_subscription_period_with_prorate(self): + settings = frappe.get_single("Subscription Settings") + settings.prorate = 1 + settings.save() + + create_plan( + plan_name="_Test Plan Name 5", + cost=1000, + billing_interval="Year", + billing_interval_count=1, + currency="INR", + ) + + start_date = add_days(nowdate(), 2) + + subscription = create_subscription( + start_date=start_date, + party_type="Supplier", + party="_Test Supplier", + generate_invoice_at="Days before the current subscription period", + generate_new_invoices_past_due_date=1, + number_of_days=2, + plans=[{"plan": "_Test Plan Name 5", "qty": 1}], + ) + subscription.process(nowdate()) + self.assertEqual(len(subscription.invoices), 1) + def make_plans(): create_plan(plan_name="_Test Plan Name", cost=900, currency="INR")