Added a new endpoint for yearly usage totals using ft_billing.

This commit is contained in:
Rebecca Law
2018-05-11 16:25:16 +01:00
parent 99d1357c37
commit d98581cfe6
6 changed files with 193 additions and 43 deletions

View File

@@ -1,5 +1,6 @@
from datetime import datetime
create_or_update_free_sms_fragment_limit_schema = {
"$schema": "http://json-schema.org/draft-04/schema#",
"description": "POST annual billing schema",
@@ -24,3 +25,17 @@ def serialize_ft_billing_remove_emails(data):
}
results.append(json_result)
return results
def serialize_ft_billing_yearly_totals(data):
yearly_totals = []
for total in data:
json_result = {
"notification_type": total.notification_type,
"billing_units": total.billable_units,
"rate": float(total.rate),
"letter_total": float(total.billable_units * total.rate) if total.notification_type == 'letter' else 0
}
yearly_totals.append(json_result)
return yearly_totals