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

@@ -25,6 +25,7 @@ def serialize_ft_billing_remove_emails(rows):
"cost": float(row.cost),
"free_chargeable_units": row.free_chargeable_units,
"charged_units": row.charged_units,
"notifications_sent": row.notifications_sent,
}
for row in rows
if row.notification_type != 'email'
@@ -44,6 +45,7 @@ def serialize_ft_billing_yearly_totals(rows):
"cost": float(row.cost),
"free_chargeable_units": row.free_chargeable_units,
"charged_units": row.charged_units,
"notifications_sent": row.notifications_sent,
}
for row in rows
]