Rename monthly helper function to match annual one

This commit is contained in:
Ben Thorner
2022-04-29 16:29:09 +01:00
parent 4ab7e3ceec
commit ca2ff00931
2 changed files with 9 additions and 8 deletions

View File

@@ -139,7 +139,7 @@ def usage(service_id):
return render_template(
'views/usage.html',
months=list(get_free_paid_breakdown_for_billable_units(
months=list(get_monthly_usage_breakdown(
year,
free_sms_allowance,
units
@@ -404,10 +404,10 @@ def get_usage_breakdown_by_type(usage, notification_type):
return [row for row in usage if row['notification_type'] == notification_type]
def get_free_paid_breakdown_for_billable_units(year, free_sms_fragment_limit, billing_units):
def get_monthly_usage_breakdown(year, free_sms_fragment_limit, monthly_usage):
cumulative = 0
sms_units = [x for x in billing_units if x['notification_type'] == 'sms']
letter_units = [x for x in billing_units if x['notification_type'] == 'letter']
sms_units = [x for x in monthly_usage if x['notification_type'] == 'sms']
letter_units = [x for x in monthly_usage if x['notification_type'] == 'letter']
for month in get_months_for_financial_year(year):
previous_cumulative = cumulative
monthly_usage = get_sum_billing_units(sms_units, month)

View File

@@ -12,7 +12,7 @@ from app.main.views.dashboard import (
aggregate_template_usage,
format_monthly_stats_to_list,
get_dashboard_totals,
get_free_paid_breakdown_for_billable_units,
get_monthly_usage_breakdown,
get_tuples_of_financial_years,
)
from tests import (
@@ -1576,10 +1576,10 @@ def test_aggregate_status_types(dict_in, expected_failed, expected_requested):
(freeze_time("2017-01-01 11:09:00.061258"), 10)
]
)
def test_get_free_paid_breakdown_for_billable_units(now, expected_number_of_months):
def test_get_monthly_usage_breakdown(now, expected_number_of_months):
sms_allowance = 250000
with now:
billing_units = get_free_paid_breakdown_for_billable_units(
breakdown = get_monthly_usage_breakdown(
2016, sms_allowance, [
{
'month': 'April', 'international': False, 'rate_multiplier': 1,
@@ -1599,7 +1599,8 @@ def test_get_free_paid_breakdown_for_billable_units(now, expected_number_of_mont
},
]
)
assert list(billing_units) == [
assert list(breakdown) == [
{
'sms_free_count': 100000,
'name': 'April',