mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-08-11 09:28:27 -04:00
Add letters to usage page.
Before this goes live need to only show letters on usage if the service has the permission.
This commit is contained in:
@@ -337,6 +337,11 @@ def calculate_usage(usage, free_sms_fragment_limit):
|
||||
emails = [breakdown["billing_units"] for breakdown in usage if breakdown['notification_type'] == 'email']
|
||||
emails_sent = 0 if len(emails) == 0 else emails[0]
|
||||
|
||||
letters = [(breakdown["billing_units"], breakdown['letter_total']) for breakdown in usage if
|
||||
breakdown['notification_type'] == 'letter']
|
||||
letter_sent = 0 if len(letters) == 0 else letters[0][0]
|
||||
letter_cost = 0 if len(letters) == 0 else letters[0][1]
|
||||
|
||||
return {
|
||||
'emails_sent': emails_sent,
|
||||
'sms_free_allowance': sms_free_allowance,
|
||||
@@ -344,6 +349,8 @@ def calculate_usage(usage, free_sms_fragment_limit):
|
||||
'sms_allowance_remaining': max(0, (sms_free_allowance - sms_sent)),
|
||||
'sms_chargeable': max(0, sms_sent - sms_free_allowance),
|
||||
'sms_rate': sms_rate,
|
||||
'letter_sent': letter_sent,
|
||||
'letter_cost': letter_cost
|
||||
}
|
||||
|
||||
|
||||
@@ -409,10 +416,16 @@ def get_free_paid_breakdown_for_billable_units(year, free_sms_fragment_limit, bi
|
||||
free_sms_fragment_limit, cumulative, previous_cumulative,
|
||||
[billing_month for billing_month in sms_units if billing_month['month'] == month]
|
||||
)
|
||||
letter_billing = [(x['billing_units'], x['rate']) for x in letter_units if x['month'] == month]
|
||||
letter_billing = [(x['billing_units'], x['rate'], (x['billing_units'] * x['rate']))
|
||||
for x in letter_units if x['month'] == month]
|
||||
letter_total = 0
|
||||
for x in letter_billing:
|
||||
letter_total += x[2]
|
||||
letter_cumulative += letter_total
|
||||
yield {
|
||||
'name': month,
|
||||
# 'total': sms + letter
|
||||
'letter_total': letter_total,
|
||||
'letter_cumulative': letter_cumulative,
|
||||
'paid': breakdown['paid'],
|
||||
'free': breakdown['free'],
|
||||
'letters': letter_billing
|
||||
|
||||
Reference in New Issue
Block a user