mirror of
https://github.com/GSA/notifications-api.git
synced 2025-12-20 15:31:15 -05:00
Refactor billing_schemas to use list comprehension
This commit is contained in:
@@ -12,30 +12,27 @@ create_or_update_free_sms_fragment_limit_schema = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
def serialize_ft_billing_remove_emails(data):
|
def serialize_ft_billing_remove_emails(rows):
|
||||||
results = []
|
return [
|
||||||
billed_notifications = [x for x in data if x.notification_type != 'email']
|
{
|
||||||
for notification in billed_notifications:
|
"month": (datetime.strftime(row.month, "%B")),
|
||||||
json_result = {
|
"notification_type": row.notification_type,
|
||||||
"month": (datetime.strftime(notification.month, "%B")),
|
"billing_units": row.billable_units,
|
||||||
"notification_type": notification.notification_type,
|
"rate": float(row.rate),
|
||||||
"billing_units": notification.billable_units,
|
"postage": row.postage,
|
||||||
"rate": float(notification.rate),
|
|
||||||
"postage": notification.postage,
|
|
||||||
}
|
}
|
||||||
results.append(json_result)
|
for row in rows
|
||||||
return results
|
if row.notification_type != 'email'
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
def serialize_ft_billing_yearly_totals(data):
|
def serialize_ft_billing_yearly_totals(rows):
|
||||||
yearly_totals = []
|
return [
|
||||||
for total in data:
|
{
|
||||||
json_result = {
|
"notification_type": row.notification_type,
|
||||||
"notification_type": total.notification_type,
|
"billing_units": row.billable_units,
|
||||||
"billing_units": total.billable_units,
|
"rate": float(row.rate),
|
||||||
"rate": float(total.rate),
|
"letter_total": float(row.billable_units * row.rate) if row.notification_type == 'letter' else 0,
|
||||||
"letter_total": float(total.billable_units * total.rate) if total.notification_type == 'letter' else 0
|
|
||||||
}
|
}
|
||||||
yearly_totals.append(json_result)
|
for row in rows
|
||||||
|
]
|
||||||
return yearly_totals
|
|
||||||
|
|||||||
Reference in New Issue
Block a user