fix usage page sms rate calculation

usage page used to make the assumption that the first row of the usage
stats would always be SMS. This now isn't always the case, so make sure
when working out the rate, it only looks at sms rows. Specifically, it
takes the rate from the first stats row. This makes a big assumption
that all the rows will have the same rate per financial year.
This commit is contained in:
Leo Hemsted
2018-05-17 10:31:21 +01:00
parent 32c2fb5b31
commit 3097fb75ee
2 changed files with 7 additions and 4 deletions

View File

@@ -2181,6 +2181,8 @@ def mock_get_template_statistics_for_template(mocker, service_one):
def mock_get_usage(mocker, service_one, fake_uuid):
def _get_usage(service_id, year=None):
return [
{"international": False, "rate": 0.00, "notification_type": "email",
"rate_multiplier": None, "billing_units": 1000},
{"international": False, "rate": 0.0165, "rate_multiplier": 1,
"notification_type": "sms", "billing_units": 251500},
{"international": True, "rate": 0.0165, "rate_multiplier": 1,
@@ -2189,8 +2191,6 @@ def mock_get_usage(mocker, service_one, fake_uuid):
"notification_type": "sms", "billing_units": 150},
{"international": True, "rate": 0.0165, "rate_multiplier": 3,
"notification_type": "sms", "billing_units": 30},
{"international": False, "rate": 0.0165, "notification_type": "email",
"rate_multiplier": None, "billing_units": 1000}
]
return mocker.patch(