Fix incorrect chargeable_units column

This was added to migrate away from the vague "billing_units" field,
but without fixing the inconsistent data behind it:

- For emails and letters, "billing_units" was just the number sent.

- For SMS, "billing_units" really was the chargeable_units.

To avoid confusion we need two fields to represent the original mix
of data - this exposes "notifications_sent" in both APIs.
This commit is contained in:
Ben Thorner
2022-04-26 18:18:36 +01:00
parent 2bdaeabbaa
commit 99b2b4642e
4 changed files with 19 additions and 6 deletions

View File

@@ -178,6 +178,7 @@ def test_get_yearly_usage_by_monthly_from_ft_billing(admin_request, notify_db_se
assert letter_row["cost"] == 9.9
assert letter_row["free_chargeable_units"] == 0
assert letter_row["charged_units"] == 30
assert letter_row["notifications_sent"] == 30
assert sms_row["month"] == "April"
assert sms_row["notification_type"] == "sms"
@@ -189,6 +190,7 @@ def test_get_yearly_usage_by_monthly_from_ft_billing(admin_request, notify_db_se
assert sms_row["cost"] == 4.212
assert sms_row["free_chargeable_units"] == 4
assert sms_row["charged_units"] == 26
assert sms_row["notifications_sent"] == 30
def set_up_yearly_data():
@@ -263,6 +265,7 @@ def test_get_yearly_billing_usage_summary_from_ft_billing(admin_request, notify_
assert json_response[0]['cost'] == 0
assert json_response[0]['free_chargeable_units'] == 0
assert json_response[0]['charged_units'] == 275
assert json_response[0]['notifications_sent'] == 275
assert json_response[1]['notification_type'] == 'letter'
assert json_response[1]['billing_units'] == 275
@@ -272,6 +275,7 @@ def test_get_yearly_billing_usage_summary_from_ft_billing(admin_request, notify_
assert json_response[1]['cost'] == 90.75
assert json_response[1]['free_chargeable_units'] == 0
assert json_response[1]['charged_units'] == 275
assert json_response[1]['notifications_sent'] == 275
assert json_response[2]['notification_type'] == 'sms'
assert json_response[2]['billing_units'] == 825
@@ -281,3 +285,4 @@ def test_get_yearly_billing_usage_summary_from_ft_billing(admin_request, notify_
assert json_response[2]['cost'] == 13.3002
assert json_response[2]['free_chargeable_units'] == 4
assert json_response[2]['charged_units'] == 821
assert json_response[2]['notifications_sent'] == 825

View File

@@ -489,7 +489,7 @@ def test_fetch_monthly_billing_for_year_variable_rates(notify_db_session):
assert results[1].notification_type == 'letter'
assert results[1].notifications_sent == 1
assert results[1].billable_units == 1
assert results[1].chargeable_units == 1
assert results[1].chargeable_units == 2
assert results[1].rate == Decimal('0.36')
assert results[1].cost == Decimal('0.36')
assert results[1].free_chargeable_units == 0
@@ -614,7 +614,7 @@ def test_fetch_billing_totals_for_year_variable_rates(notify_db_session):
assert results[1].notification_type == 'letter'
assert results[1].notifications_sent == 1
assert results[1].billable_units == 1
assert results[1].chargeable_units == 1
assert results[1].chargeable_units == 2
assert results[1].rate == Decimal('0.36')
assert results[1].cost == Decimal('0.36')
assert results[1].free_chargeable_units == 0