diff --git a/app/main/views/dashboard.py b/app/main/views/dashboard.py index e58eba8a7..43fd5f773 100644 --- a/app/main/views/dashboard.py +++ b/app/main/views/dashboard.py @@ -398,12 +398,12 @@ def get_monthly_usage_breakdown(year, monthly_usage): for month in get_months_for_financial_year(year): monthly_sms = [row for row in sms if row['month'] == month] - sms_free_allowance_used = sum(row['sms_free_allowance_used'] for row in monthly_sms) - sms_cost = sum(row['sms_cost'] for row in monthly_sms) - sms_breakdown = [row for row in monthly_sms if row['sms_charged']] + sms_free_allowance_used = sum(row['free_allowance_used'] for row in monthly_sms) + sms_cost = sum(row['cost'] for row in monthly_sms) + sms_breakdown = [row for row in monthly_sms if row['charged_units']] monthly_letters = [row for row in letters if row['month'] == month] - letter_cost = sum(row['letter_cost'] for row in monthly_letters) + letter_cost = sum(row['cost'] for row in monthly_letters) letter_breakdown = get_monthly_usage_breakdown_for_letters(monthly_letters) yield { @@ -436,7 +436,7 @@ def get_monthly_usage_breakdown_for_letters(monthly_letters): yield { "sent": sum(x['notifications_sent'] for x in rate_group), "rate": rate_group[0]['rate'], - "cost": sum(x['letter_cost'] for x in rate_group), + "cost": sum(x['cost'] for x in rate_group), "postage_description": get_monthly_usage_postage_description(rate_group[0]) } diff --git a/app/templates/views/usage.html b/app/templates/views/usage.html index c0def3336..4bd7f6c77 100644 --- a/app/templates/views/usage.html +++ b/app/templates/views/usage.html @@ -108,7 +108,7 @@
  • {{ item.sms_free_allowance_used|format_thousands }} free {{ item.sms_free_count|message_count_label('sms', suffix='') }}
  • {% endif %} {% for sms in item.sms_breakdown %} -
  • {{ sms.sms_charged|message_count('sms') }} at +
  • {{ sms.charged_units|message_count('sms') }} at {{- ' {:.2f}p'.format(sms.rate * 100) }}
  • {% endfor %} {% for letter in item.letter_breakdown %} diff --git a/tests/conftest.py b/tests/conftest.py index 6e0e4f51d..5f01240c8 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -2365,10 +2365,9 @@ def mock_get_monthly_usage_for_service(mocker): 'chargeable_units': 1230, 'notifications_sent': 1234, 'postage': 'none', - 'sms_charged': 1230, - 'sms_free_allowance_used': 0, - 'sms_cost': 20.91, - 'letter_cost': 0, + 'charged_units': 1230, + 'free_allowance_used': 0, + 'cost': 20.91, }, { 'month': 'February', @@ -2377,10 +2376,9 @@ def mock_get_monthly_usage_for_service(mocker): 'chargeable_units': 33, 'notifications_sent': 1234, 'postage': 'none', - 'sms_charged': 33, - 'sms_free_allowance_used': 0, - 'sms_cost': 0.561, - 'letter_cost': 0, + 'charged_units': 33, + 'free_allowance_used': 0, + 'cost': 0.561, }, { 'month': 'February', @@ -2389,10 +2387,9 @@ def mock_get_monthly_usage_for_service(mocker): 'chargeable_units': 1100, 'notifications_sent': 1234, 'postage': 'none', - 'sms_charged': 960, - 'sms_free_allowance_used': 140, - 'sms_cost': 15.84, - 'letter_cost': 0, + 'charged_units': 960, + 'free_allowance_used': 140, + 'cost': 15.84, }, { 'month': 'February', @@ -2401,10 +2398,9 @@ def mock_get_monthly_usage_for_service(mocker): 'chargeable_units': 10, 'notifications_sent': 10, 'postage': 'second', - 'sms_charged': 0, - 'sms_free_allowance_used': 0, - 'sms_cost': 0, - 'letter_cost': 3.1, + 'charged_units': 10, + 'free_allowance_used': 0, + 'cost': 3.1, }, { 'month': 'February', @@ -2413,10 +2409,9 @@ def mock_get_monthly_usage_for_service(mocker): 'chargeable_units': 5, 'notifications_sent': 5, 'postage': 'first', - 'sms_charged': 0, - 'sms_free_allowance_used': 0, - 'sms_cost': 0, - 'letter_cost': 1.65, + 'charged_units': 5, + 'free_allowance_used': 0, + 'cost': 1.65, }, { 'month': 'February', @@ -2425,10 +2420,9 @@ def mock_get_monthly_usage_for_service(mocker): 'chargeable_units': 3, 'notifications_sent': 3, 'postage': 'europe', - 'sms_charged': 0, - 'sms_free_allowance_used': 0, - 'sms_cost': 0, - 'letter_cost': 2.52, + 'charged_units': 3, + 'free_allowance_used': 0, + 'cost': 2.52, }, { 'month': 'February', @@ -2437,10 +2431,9 @@ def mock_get_monthly_usage_for_service(mocker): 'chargeable_units': 7, 'notifications_sent': 7, 'postage': 'rest-of-world', - 'sms_charged': 0, - 'sms_free_allowance_used': 0, - 'sms_cost': 0, - 'letter_cost': 5.88, + 'charged_units': 7, + 'free_allowance_used': 0, + 'cost': 5.88, }, { 'month': 'April', @@ -2449,10 +2442,9 @@ def mock_get_monthly_usage_for_service(mocker): 'chargeable_units': 249860, 'notifications_sent': 1234, 'postage': 'none', - 'sms_charged': 0, - 'sms_free_allowance_used': 249860, - 'sms_cost': 0, - 'letter_cost': 0, + 'charged_units': 0, + 'free_allowance_used': 249860, + 'cost': 0, }, ]