mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-07-27 03:09:11 -04:00
Finish migration from billing_units to API fields
This is now only used for letters and represents the number sent [^1]. We could use the chargeable_units field, but using "_sent" is more consistent with the annual attributes [^2]. In fact, chargeable_units isn't actually used anywhere, but I've kept it in the test data as it is part of the real API and helps clarify the other values for SMS - free vs. charged. Note: for SMS I've used an arbitrary "1234" for "chargeable_units" to indicate it's not used and may be different to the number sent - for SMS it's related to the number of fragments. [^1]:bb62d22f25/app/dao/fact_billing_dao.py (L339)[^2]:3a1ac189ff/app/main/views/dashboard.py (L339)
This commit is contained in:
@@ -442,7 +442,7 @@ def format_letter_details_for_month(letter_units_for_month):
|
||||
rate_group = list(rate_group)
|
||||
|
||||
letter_details = LetterDetails(
|
||||
sent=sum(x['billing_units'] for x in rate_group),
|
||||
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),
|
||||
postage_description=rate_group[0]['postage']
|
||||
|
||||
@@ -1106,7 +1106,8 @@ def test_usage_page_displays_letters_ordered_by_postage(
|
||||
'month': 'April',
|
||||
'notification_type': 'letter',
|
||||
'rate': 0.5,
|
||||
'billing_units': 1,
|
||||
'chargeable_units': 1,
|
||||
'notifications_sent': 1,
|
||||
'postage': 'second',
|
||||
'letter_cost': 0.5,
|
||||
},
|
||||
@@ -1114,7 +1115,8 @@ def test_usage_page_displays_letters_ordered_by_postage(
|
||||
'month': 'April',
|
||||
'notification_type': 'letter',
|
||||
'rate': 1,
|
||||
'billing_units': 1,
|
||||
'chargeable_units': 1,
|
||||
'notifications_sent': 1,
|
||||
'postage': 'europe',
|
||||
'letter_cost': 1,
|
||||
},
|
||||
@@ -1122,7 +1124,8 @@ def test_usage_page_displays_letters_ordered_by_postage(
|
||||
'month': 'April',
|
||||
'notification_type': 'letter',
|
||||
'rate': 1,
|
||||
'billing_units': 2,
|
||||
'chargeable_units': 2,
|
||||
'notifications_sent': 2,
|
||||
'postage': 'rest-of-word',
|
||||
'letter_cost': 2,
|
||||
},
|
||||
@@ -1130,7 +1133,8 @@ def test_usage_page_displays_letters_ordered_by_postage(
|
||||
'month': 'April',
|
||||
'notification_type': 'letter',
|
||||
'rate': 1.5,
|
||||
'billing_units': 7,
|
||||
'chargeable_units': 7,
|
||||
'notifications_sent': 7,
|
||||
'postage': 'europe',
|
||||
'letter_cost': 11.5,
|
||||
},
|
||||
@@ -1138,7 +1142,8 @@ def test_usage_page_displays_letters_ordered_by_postage(
|
||||
'month': 'April',
|
||||
'notification_type': 'letter',
|
||||
'rate': 0.3,
|
||||
'billing_units': 3,
|
||||
'chargeable_units': 3,
|
||||
'notifications_sent': 3,
|
||||
'postage': 'second',
|
||||
'letter_cost': 0.9,
|
||||
},
|
||||
@@ -1146,7 +1151,8 @@ def test_usage_page_displays_letters_ordered_by_postage(
|
||||
'month': 'April',
|
||||
'notification_type': 'letter',
|
||||
'rate': 0.5,
|
||||
'billing_units': 1,
|
||||
'chargeable_units': 1,
|
||||
'notifications_sent': 1,
|
||||
'postage': 'first',
|
||||
'letter_cost': 0.5,
|
||||
},
|
||||
@@ -1183,7 +1189,8 @@ def test_usage_page_displays_letters_split_by_month_and_postage(
|
||||
'month': 'April',
|
||||
'notification_type': 'letter',
|
||||
'rate': 0.5,
|
||||
'billing_units': 1,
|
||||
'chargeable_units': 1,
|
||||
'notifications_sent': 1,
|
||||
'postage': 'second',
|
||||
'letter_cost': 0.5,
|
||||
},
|
||||
@@ -1191,7 +1198,8 @@ def test_usage_page_displays_letters_split_by_month_and_postage(
|
||||
'month': 'April',
|
||||
'notification_type': 'letter',
|
||||
'rate': 1,
|
||||
'billing_units': 1,
|
||||
'chargeable_units': 1,
|
||||
'notifications_sent': 1,
|
||||
'postage': 'europe',
|
||||
'letter_cost': 1,
|
||||
},
|
||||
@@ -1199,7 +1207,8 @@ def test_usage_page_displays_letters_split_by_month_and_postage(
|
||||
'month': 'May',
|
||||
'notification_type': 'letter',
|
||||
'rate': 1,
|
||||
'billing_units': 7,
|
||||
'chargeable_units': 7,
|
||||
'notifications_sent': 7,
|
||||
'postage': 'europe',
|
||||
'letter_cost': 7,
|
||||
},
|
||||
@@ -1207,7 +1216,8 @@ def test_usage_page_displays_letters_split_by_month_and_postage(
|
||||
'month': 'May',
|
||||
'notification_type': 'letter',
|
||||
'rate': 0.5,
|
||||
'billing_units': 3,
|
||||
'chargeable_units': 3,
|
||||
'notifications_sent': 3,
|
||||
'postage': 'second',
|
||||
'letter_cost': 1.5,
|
||||
},
|
||||
@@ -1215,7 +1225,8 @@ def test_usage_page_displays_letters_split_by_month_and_postage(
|
||||
'month': 'May',
|
||||
'notification_type': 'letter',
|
||||
'rate': 0.7,
|
||||
'billing_units': 1,
|
||||
'chargeable_units': 1,
|
||||
'notifications_sent': 1,
|
||||
'postage': 'first',
|
||||
'letter_cost': 0.7,
|
||||
},
|
||||
@@ -1665,7 +1676,8 @@ def test_get_monthly_usage_breakdown(now, expected_number_of_months):
|
||||
'rate_multiplier': 1,
|
||||
'notification_type': 'sms',
|
||||
'rate': 1.65,
|
||||
'billing_units': 100000,
|
||||
'chargeable_units': 100000,
|
||||
'notifications_sent': 1234,
|
||||
'sms_charged': 0,
|
||||
'sms_free_allowance_used': 100000,
|
||||
'sms_cost': 0,
|
||||
@@ -1676,7 +1688,8 @@ def test_get_monthly_usage_breakdown(now, expected_number_of_months):
|
||||
'rate_multiplier': 1,
|
||||
'notification_type': 'sms',
|
||||
'rate': 1.65,
|
||||
'billing_units': 100000,
|
||||
'chargeable_units': 100000,
|
||||
'notifications_sent': 1234,
|
||||
'sms_charged': 0,
|
||||
'sms_free_allowance_used': 100000,
|
||||
'sms_cost': 0,
|
||||
@@ -1687,7 +1700,8 @@ def test_get_monthly_usage_breakdown(now, expected_number_of_months):
|
||||
'rate_multiplier': 1,
|
||||
'notification_type': 'sms',
|
||||
'rate': 1.71,
|
||||
'billing_units': 100000,
|
||||
'chargeable_units': 100000,
|
||||
'notifications_sent': 1234,
|
||||
'sms_charged': 50000,
|
||||
'sms_free_allowance_used': 50000,
|
||||
'sms_cost': 85500,
|
||||
@@ -1698,7 +1712,8 @@ def test_get_monthly_usage_breakdown(now, expected_number_of_months):
|
||||
'rate_multiplier': 1,
|
||||
'notification_type': 'sms',
|
||||
'rate': 1.71,
|
||||
'billing_units': 2000,
|
||||
'chargeable_units': 2000,
|
||||
'notifications_sent': 1234,
|
||||
'sms_charged': 2000,
|
||||
'sms_free_allowance_used': 0,
|
||||
'sms_cost': 3420,
|
||||
|
||||
@@ -2362,7 +2362,8 @@ def mock_get_monthly_usage_for_service(mocker):
|
||||
'month': 'March',
|
||||
'notification_type': 'sms',
|
||||
'rate': 0.017,
|
||||
'billing_units': 1230,
|
||||
'chargeable_units': 1230,
|
||||
'notifications_sent': 1234,
|
||||
'postage': 'none',
|
||||
'sms_charged': 1230,
|
||||
'sms_free_allowance_used': 0,
|
||||
@@ -2373,7 +2374,8 @@ def mock_get_monthly_usage_for_service(mocker):
|
||||
'month': 'February',
|
||||
'notification_type': 'sms',
|
||||
'rate': 0.0165,
|
||||
'billing_units': 1100,
|
||||
'chargeable_units': 1100,
|
||||
'notifications_sent': 1234,
|
||||
'postage': 'none',
|
||||
'sms_charged': 960,
|
||||
'sms_free_allowance_used': 140,
|
||||
@@ -2384,7 +2386,8 @@ def mock_get_monthly_usage_for_service(mocker):
|
||||
'month': 'February',
|
||||
'notification_type': 'letter',
|
||||
'rate': 0.31,
|
||||
'billing_units': 10,
|
||||
'chargeable_units': 10,
|
||||
'notifications_sent': 10,
|
||||
'postage': 'second',
|
||||
'sms_charged': 0,
|
||||
'sms_free_allowance_used': 0,
|
||||
@@ -2395,7 +2398,8 @@ def mock_get_monthly_usage_for_service(mocker):
|
||||
'month': 'February',
|
||||
'notification_type': 'letter',
|
||||
'rate': 0.33,
|
||||
'billing_units': 5,
|
||||
'chargeable_units': 5,
|
||||
'notifications_sent': 5,
|
||||
'postage': 'first',
|
||||
'sms_charged': 0,
|
||||
'sms_free_allowance_used': 0,
|
||||
@@ -2406,7 +2410,8 @@ def mock_get_monthly_usage_for_service(mocker):
|
||||
'month': 'February',
|
||||
'notification_type': 'letter',
|
||||
'rate': 0.84,
|
||||
'billing_units': 3,
|
||||
'chargeable_units': 3,
|
||||
'notifications_sent': 3,
|
||||
'postage': 'europe',
|
||||
'sms_charged': 0,
|
||||
'sms_free_allowance_used': 0,
|
||||
@@ -2417,7 +2422,8 @@ def mock_get_monthly_usage_for_service(mocker):
|
||||
'month': 'February',
|
||||
'notification_type': 'letter',
|
||||
'rate': 0.84,
|
||||
'billing_units': 7,
|
||||
'chargeable_units': 7,
|
||||
'notifications_sent': 7,
|
||||
'postage': 'rest-of-world',
|
||||
'sms_charged': 0,
|
||||
'sms_free_allowance_used': 0,
|
||||
@@ -2428,7 +2434,8 @@ def mock_get_monthly_usage_for_service(mocker):
|
||||
'month': 'April',
|
||||
'notification_type': 'sms',
|
||||
'rate': 0.017,
|
||||
'billing_units': 249860,
|
||||
'chargeable_units': 249860,
|
||||
'notifications_sent': 1234,
|
||||
'postage': 'none',
|
||||
'sms_charged': 0,
|
||||
'sms_free_allowance_used': 249860,
|
||||
|
||||
Reference in New Issue
Block a user