mirror of
https://github.com/GSA/notifications-api.git
synced 2026-08-19 14:08:47 -04:00
Add "cost" field to monthly usage API
This starts to replace the calculation in Admin [^1] and, similar
to the yearly API, also correctly attributes free allowance when
we have a rate change during a month.
[^1]: 474d7dfda8/app/templates/views/usage.html (L98)
This commit is contained in:
@@ -22,6 +22,7 @@ def serialize_ft_billing_remove_emails(rows):
|
||||
"chargeable_units": row.chargeable_units,
|
||||
"rate": float(row.rate),
|
||||
"postage": row.postage,
|
||||
"cost": float(row.cost),
|
||||
}
|
||||
for row in rows
|
||||
if row.notification_type != 'email'
|
||||
|
||||
@@ -244,6 +244,7 @@ def fetch_monthly_billing_for_year(service_id, year):
|
||||
query.c.rate.label("rate"),
|
||||
query.c.postage.label("postage"),
|
||||
query.c.notification_type.label("notification_type"),
|
||||
func.sum(query.c.cost).label("cost"),
|
||||
).group_by(
|
||||
query.c.rate,
|
||||
query.c.notification_type,
|
||||
|
||||
Reference in New Issue
Block a user