codacy tinzz
diff --git a/erpnext/accounts/doctype/subscriptions/subscriptions.py b/erpnext/accounts/doctype/subscriptions/subscriptions.py
index 02a30a8..a193e69 100644
--- a/erpnext/accounts/doctype/subscriptions/subscriptions.py
+++ b/erpnext/accounts/doctype/subscriptions/subscriptions.py
@@ -305,7 +305,7 @@
)
elif plan_items:
- prorate_factor = self.get_prorata_factor(self.current_invoice_end, self.current_invoice_start)
+ prorate_factor = get_prorata_factor(self.current_invoice_end, self.current_invoice_start)
item_names = frappe.db.sql(
'select item as item_code, cost * %s as rate from `tabSubscription Plan` where name in %s',
@@ -331,7 +331,7 @@
def process_for_active(self):
"""
Called by `process` if the status of the `Subscription` is 'Active'.
-
+
The possible outcomes of this method are:
1. Generate a new invoice
2. Change the `Subscription` status to 'Past Due Date'
@@ -421,19 +421,20 @@
else:
frappe.throw(_('You cannot restart a Subscription that is not cancelled.'))
- def get_prorata_factor(self, period_end, period_start):
- diff = flt(date_diff(nowdate(), period_start) + 1)
- plan_days = flt(date_diff(period_end, period_start) + 1)
- prorate_factor = diff / plan_days
-
- return prorate_factor
-
def get_precision(self):
invoice = self.get_current_invoice()
if invoice:
return invoice.precision('grand_total')
+def get_prorata_factor(period_end, period_start):
+ diff = flt(date_diff(nowdate(), period_start) + 1)
+ plan_days = flt(date_diff(period_end, period_start) + 1)
+ prorate_factor = diff / plan_days
+
+ return prorate_factor
+
+
def process_all():
"""
Task to updates the status of all `Subscription` apart from those that are cancelled
diff --git a/erpnext/accounts/doctype/subscriptions/test_subscriptions.py b/erpnext/accounts/doctype/subscriptions/test_subscriptions.py
index b290f00..5e44197 100644
--- a/erpnext/accounts/doctype/subscriptions/test_subscriptions.py
+++ b/erpnext/accounts/doctype/subscriptions/test_subscriptions.py
@@ -6,6 +6,7 @@
import unittest
import frappe
+from erpnext.accounts.doctype.subscriptions.subscriptions import get_prorata_factor
from frappe.utils.data import nowdate, add_days, add_to_date, add_months, date_diff, flt
@@ -297,7 +298,7 @@
self.assertEqual(
flt(
- subscription.get_prorata_factor(subscription.current_invoice_end, subscription.current_invoice_start),
+ get_prorata_factor(subscription.current_invoice_end, subscription.current_invoice_start),
2),
flt(prorate_factor, 2)
)