mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-08-18 21:49:37 -04:00
Support variable rates for annual usage stats
Note: I've removed the pricing assertion in the "0_free_allowance" test as it's covered elsewhere - the value of the test is really to check that we don't show the remainder if there never was any.
This commit is contained in:
@@ -328,8 +328,6 @@ def get_dashboard_totals(statistics):
|
||||
|
||||
def get_annual_usage_breakdown(usage, free_sms_fragment_limit):
|
||||
sms = get_usage_breakdown_by_type(usage, 'sms')
|
||||
# this relies on the assumption: only one SMS rate per financial year.
|
||||
sms_rate = 0 if len(sms) == 0 else sms[0].get("rate", 0)
|
||||
sms_chargeable_units = sum(row['chargeable_units'] for row in sms)
|
||||
sms_free_allowance = free_sms_fragment_limit
|
||||
sms_cost = sum(row['cost'] for row in sms)
|
||||
@@ -346,9 +344,8 @@ def get_annual_usage_breakdown(usage, free_sms_fragment_limit):
|
||||
'sms_free_allowance': sms_free_allowance,
|
||||
'sms_sent': sms_chargeable_units,
|
||||
'sms_allowance_remaining': max(0, (sms_free_allowance - sms_chargeable_units)),
|
||||
'sms_charged': max(0, sms_chargeable_units - sms_free_allowance),
|
||||
'sms_cost': sms_cost,
|
||||
'sms_rate': sms_rate,
|
||||
'sms_breakdown': sms,
|
||||
'letter_sent': letters_sent,
|
||||
'letter_cost': letters_cost
|
||||
}
|
||||
|
||||
@@ -33,13 +33,15 @@
|
||||
{% if sms_free_allowance > 0 %}
|
||||
{{ big_number(sms_allowance_remaining, 'free allowance remaining', smaller=True) }}
|
||||
{% endif %}
|
||||
{% if sms_charged %}
|
||||
{{ big_number(
|
||||
sms_charged,
|
||||
'at {:.2f} pence per message'.format(sms_rate * 100),
|
||||
smaller=True
|
||||
) }}
|
||||
{% endif %}
|
||||
{% for row in sms_breakdown %}
|
||||
{% if row.charged_units > 0 %}
|
||||
{{ big_number(
|
||||
row.charged_units,
|
||||
'at {:.2f} pence per message'.format(row.rate * 100),
|
||||
smaller=True
|
||||
) }}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
<div class='govuk-grid-column-one-third'>
|
||||
|
||||
Reference in New Issue
Block a user