Files
notifications-api/app/billing/billing_schemas.py
T

47 lines
1.4 KiB
Python
Raw Normal View History

2018-05-08 12:09:29 +01:00
from datetime import datetime
from app.enums import NotificationType
create_or_update_free_sms_fragment_limit_schema = {
2022-04-08 17:05:59 +01:00
"$schema": "http://json-schema.org/draft-07/schema#",
"description": "POST annual billing schema",
"type": "object",
"title": "Create",
"properties": {
2022-02-25 12:01:20 +00:00
"free_sms_fragment_limit": {"type": "integer", "minimum": 0},
},
2023-08-29 14:54:30 -07:00
"required": ["free_sms_fragment_limit"],
}
2018-05-08 12:09:29 +01:00
def serialize_ft_billing_remove_emails(rows):
return [
{
"month": (datetime.strftime(row.month, "%B")),
"notification_type": row.notification_type,
"chargeable_units": row.chargeable_units,
"notifications_sent": row.notifications_sent,
"rate": float(row.rate),
2022-04-20 17:14:17 +01:00
"cost": float(row.cost),
"free_allowance_used": row.free_allowance_used,
2022-04-26 17:56:17 +01:00
"charged_units": row.charged_units,
2018-05-08 12:09:29 +01:00
}
for row in rows
if row.notification_type != NotificationType.EMAIL
]
def serialize_ft_billing_yearly_totals(rows):
return [
{
"notification_type": row.notification_type,
"chargeable_units": row.chargeable_units,
"notifications_sent": row.notifications_sent,
"rate": float(row.rate),
2022-04-20 17:14:17 +01:00
"cost": float(row.cost),
"free_allowance_used": row.free_allowance_used,
2022-04-26 17:56:17 +01:00
"charged_units": row.charged_units,
}
for row in rows
]