codacy tinzz
This commit is contained in:
parent
fbdd5d30e9
commit
2379451b68
@ -305,7 +305,7 @@ class Subscriptions(Document):
|
||||
)
|
||||
|
||||
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',
|
||||
@ -421,18 +421,19 @@ class Subscriptions(Document):
|
||||
else:
|
||||
frappe.throw(_('You cannot restart a Subscription that is not cancelled.'))
|
||||
|
||||
def get_prorata_factor(self, period_end, period_start):
|
||||
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 get_precision(self):
|
||||
invoice = self.get_current_invoice()
|
||||
if invoice:
|
||||
return invoice.precision('grand_total')
|
||||
|
||||
|
||||
def process_all():
|
||||
"""
|
||||
|
@ -6,6 +6,7 @@ from __future__ import unicode_literals
|
||||
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 @@ class TestSubscriptions(unittest.TestCase):
|
||||
|
||||
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)
|
||||
)
|
||||
|
Loading…
x
Reference in New Issue
Block a user