mirror of
https://github.com/GSA/notifications-api.git
synced 2025-12-20 07:21:13 -05:00
Add "free_allowance_units" to service usage APIs
This represents the number of chargeable_units that were actually free due to the free allowance - they won't be included in "cost". Although the existing calculations in Admin [^1][^2] will still be correct with a change in SMS rates - it's cost that's the problem - it makes sense to have all the knowledge about calculating usage consistently in these two APIs. Note that the Integer casting is covered by the API-level tests in test_rest. [^1]:474d7dfda8/app/main/views/dashboard.py (L490)[^2]:c63660d56d/app/main/views/dashboard.py (L350)
This commit is contained in:
@@ -24,6 +24,7 @@ def serialize_ft_billing_remove_emails(rows):
|
||||
"rate": float(row.rate),
|
||||
"postage": row.postage,
|
||||
"cost": float(row.cost),
|
||||
"free_allowance_used": row.free_allowance_used,
|
||||
}
|
||||
for row in rows
|
||||
if row.notification_type != 'email'
|
||||
@@ -42,6 +43,7 @@ def serialize_ft_billing_yearly_totals(rows):
|
||||
# TEMPORARY: while we migrate to "cost" in the Admin app
|
||||
"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,
|
||||
}
|
||||
for row in rows
|
||||
]
|
||||
|
||||
Reference in New Issue
Block a user