From 9164162a9e80e685bb596d4f9eb87573125d8ede Mon Sep 17 00:00:00 2001 From: ravibharathi656 Date: Fri, 19 Sep 2025 16:23:26 +0530 Subject: [PATCH] fix(subscription): include days before --- .../doctype/subscription/subscription.py | 49 ++++++++----------- 1 file changed, 21 insertions(+), 28 deletions(-) diff --git a/erpnext/accounts/doctype/subscription/subscription.py b/erpnext/accounts/doctype/subscription/subscription.py index 4770df89351..2f83f974789 100644 --- a/erpnext/accounts/doctype/subscription/subscription.py +++ b/erpnext/accounts/doctype/subscription/subscription.py @@ -490,11 +490,18 @@ class Subscription(Document): if prorate is None: prorate = False + prorate_factor = 1 if prorate: prorate_factor = get_prorata_factor( self.current_invoice_end, self.current_invoice_start, - cint(self.generate_invoice_at == "Beginning of the current subscription period"), + cint( + self.generate_invoice_at + in [ + "Beginning of the current subscription period", + "Days before the current subscription period", + ] + ), ) items = [] @@ -511,33 +518,19 @@ class Subscription(Document): deferred = frappe.db.get_value("Item", item_code, deferred_field) - if not prorate: - item = { - "item_code": item_code, - "qty": plan.qty, - "rate": get_plan_rate( - plan.plan, - plan.qty, - party, - self.current_invoice_start, - self.current_invoice_end, - ), - "cost_center": plan_doc.cost_center, - } - else: - item = { - "item_code": item_code, - "qty": plan.qty, - "rate": get_plan_rate( - plan.plan, - plan.qty, - party, - self.current_invoice_start, - self.current_invoice_end, - prorate_factor, - ), - "cost_center": plan_doc.cost_center, - } + item = { + "item_code": item_code, + "qty": plan.qty, + "rate": get_plan_rate( + plan.plan, + plan.qty, + party, + self.current_invoice_start, + self.current_invoice_end, + prorate_factor, + ), + "cost_center": plan_doc.cost_center, + } if deferred: item.update(