mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-09-09 16:39:49 -04:00
Reuse helper function to filter usage rows
I've also dispensed with the "units" terminology here, which didn't represent the "rows" returned by the API.
This commit is contained in:
@@ -406,18 +406,19 @@ def get_usage_breakdown_by_type(usage, notification_type):
|
|||||||
|
|
||||||
def get_monthly_usage_breakdown(year, free_sms_fragment_limit, monthly_usage):
|
def get_monthly_usage_breakdown(year, free_sms_fragment_limit, monthly_usage):
|
||||||
cumulative = 0
|
cumulative = 0
|
||||||
sms_units = [x for x in monthly_usage if x['notification_type'] == 'sms']
|
sms = get_usage_breakdown_by_type(monthly_usage, 'sms')
|
||||||
letter_units = [x for x in monthly_usage if x['notification_type'] == 'letter']
|
letters = get_usage_breakdown_by_type(monthly_usage, 'letter')
|
||||||
|
|
||||||
for month in get_months_for_financial_year(year):
|
for month in get_months_for_financial_year(year):
|
||||||
previous_cumulative = cumulative
|
previous_cumulative = cumulative
|
||||||
monthly_usage = get_sum_billing_units(sms_units, month)
|
monthly_usage = get_sum_billing_units(sms, month)
|
||||||
cumulative += monthly_usage
|
cumulative += monthly_usage
|
||||||
breakdown = get_free_paid_breakdown_for_month(
|
breakdown = get_free_paid_breakdown_for_month(
|
||||||
free_sms_fragment_limit, cumulative, previous_cumulative,
|
free_sms_fragment_limit, cumulative, previous_cumulative,
|
||||||
[billing_month for billing_month in sms_units if billing_month['month'] == month]
|
[billing_month for billing_month in sms if billing_month['month'] == month]
|
||||||
)
|
)
|
||||||
|
|
||||||
letter_units_for_month = [x for x in letter_units if x['month'] == month]
|
letter_units_for_month = [x for x in letters if x['month'] == month]
|
||||||
letter_billing = format_letter_details_for_month(letter_units_for_month)
|
letter_billing = format_letter_details_for_month(letter_units_for_month)
|
||||||
|
|
||||||
letter_total = 0
|
letter_total = 0
|
||||||
|
|||||||
Reference in New Issue
Block a user