Letter have multliple rates, the agregate number was not taking that into account for the usage page.

This commit is contained in:
Rebecca Law
2018-05-22 17:37:48 +01:00
parent 9bba6f08a4
commit cd09c391e8
3 changed files with 12 additions and 3 deletions

View File

@@ -389,8 +389,8 @@ def calculate_usage(usage, free_sms_fragment_limit):
letters = [(breakdown["billing_units"], breakdown['letter_total']) for breakdown in usage if
breakdown['notification_type'] == 'letter']
letter_sent = 0 if len(letters) == 0 else letters[0][0]
letter_cost = 0 if len(letters) == 0 else letters[0][1]
letter_sent = sum(row[0] for row in letters)
letter_cost = sum(row[1] for row in letters)
return {
'emails_sent': emails_sent,

View File

@@ -777,11 +777,12 @@ def test_usage_page_with_letters(
assert 'April' in table
assert 'February' in table
assert 'March' in table
assert '£18.94' in table
assert '£20.59' in table
assert '140 free text messages' in table
assert '£20.30' in table
assert '1,230 text messages at 1.65p' in table
assert '10 letters at 31p' in table
assert '5 letters at 33p' in table
def test_usage_page_with_year_argument(

View File

@@ -2288,6 +2288,14 @@ def mock_get_billable_units(mocker):
'notification_type': 'letter',
'rate': 0.31,
'billing_units': 10
},
{
'month': 'February',
'international': False,
'rate_multiplier': 1,
'notification_type': 'letter',
'rate': 0.33,
'billing_units': 5
}
]