Add "charged_units" to service usage APIs

This can be calculated from the "free_allowance_used" field and the
"chargeable_units" field, but having it included separately is more
convenient as it can be used directly in Admin [^1].

[^1]: 417e7370bb/app/templates/views/usage.html (L38-L39)
This commit is contained in:
Ben Thorner
2022-04-26 17:56:17 +01:00
parent 555868c442
commit ebaef4b57b
4 changed files with 28 additions and 0 deletions

View File

@@ -25,6 +25,7 @@ def serialize_ft_billing_remove_emails(rows):
"postage": row.postage,
"cost": float(row.cost),
"free_allowance_used": row.free_allowance_used,
"charged_units": row.charged_units,
}
for row in rows
if row.notification_type != 'email'
@@ -44,6 +45,7 @@ def serialize_ft_billing_yearly_totals(rows):
"letter_total": float(row.billable_units * row.rate) if row.notification_type == 'letter' else 0,
"cost": float(row.cost),
"free_allowance_used": row.free_allowance_used,
"charged_units": row.charged_units,
}
for row in rows
]