Files
notifications-admin/app/templates/views/usage.html
Ben Thorner e0aa51c306 Use new "cost" field in usage APIs
The previous, manual calculation could be incorrect depending on
which SMS rates the free allowance was attributed to.

The new field also supersedes the old "letter_total" bolt-on so we
can get cost information consistently for both types.
2022-04-27 17:06:12 +01:00

143 lines
5.0 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
{% from "components/big-number.html" import big_number %}
{% from "components/table.html" import list_table, field, hidden_field_heading, row_heading, text_field %}
{% from "components/page-header.html" import page_header %}
{% from "components/pill.html" import pill %}
{% extends "withnav_template.html" %}
{% block service_page_title %}
Usage
{% endblock %}
{% block maincolumn_content %}
{{ page_header('Usage', size='medium') }}
<div class="bottom-gutter">
{{ pill(years, selected_year, big_number_args={'smallest': True}) }}
</div>
<div id='pill-selected-item'>
<div class='govuk-grid-row'>
<div class='govuk-grid-column-one-third'>
<h2 class='heading-small'>Emails</h2>
<div class="keyline-block">
{{ big_number(emails_sent, 'sent', smaller=True) }}
{{ big_number("Unlimited", 'free allowance', smaller=True) }}
</div>
</div>
<div class='govuk-grid-column-one-third'>
<h2 class='heading-small'>Text messages</h2>
<div class="keyline-block">
{{ big_number(sms_sent, 'sent', smaller=True) }}
{{ big_number(sms_free_allowance, 'free allowance', smaller=True) }}
{% if sms_free_allowance > 0 %}
{{ big_number(sms_allowance_remaining, 'free allowance remaining', smaller=True) }}
{% endif %}
{% if sms_chargeable %}
{{ big_number(
sms_chargeable,
'at {:.2f} pence per message'.format(sms_rate * 100),
smaller=True
) }}
{% endif %}
</div>
</div>
<div class='govuk-grid-column-one-third'>
<h2 class='heading-small'>Letters</h2>
<div class="keyline-block">
{{ big_number(letter_sent, 'sent', smaller=True) }}
</div>
</div>
</div>
<div class='govuk-grid-row'>
<div class='govuk-grid-column-one-third'>
<div class="keyline-block">
&nbsp;
</div>
</div>
<div class='govuk-grid-column-one-third'>
<div class="keyline-block">
{{ big_number(
sms_cost,
'spent',
currency="£",
smaller=True
) }}
</div>
</div>
<div class='govuk-grid-column-one-third'>
<div class="keyline-block">
{{ big_number(
letter_cost,
'spent',
currency="£",
smaller=True
) }}
</div>
</div>
</div>
{% if months %}
<div class="dashboard-table usage-table body-copy-table">
{% call(month, row_index) list_table(
months,
caption="Total spend",
caption_visible=False,
empty_message='',
field_headings=[
'By month',
hidden_field_heading('Cost'),
],
field_headings_visible=True
) %}
{% call row_heading() %}
{{ month.name }}
{% endcall %}
{% call field(align='left') %}
{{ big_number(
(month.sms_rate * month.sms_paid_count) + month.letter_total,
currency="£",
smallest=True
) }}
<ul>
{% if month.sms_free_count %}
<li class="tabular-numbers">{{ month.sms_free_count|format_thousands }} free {{ month.sms_free_count|message_count_label('sms', suffix='') }}</li>
{% endif %}
{% if month.sms_paid_count %}
<li class="tabular-numbers">{{ month.sms_paid_count|message_count('sms') }} at
{{- ' {:.2f}p'.format(month.sms_rate * 100) }}</li>
{% endif %}
{% for letter in month.letters%}
{% if letter.billing_units %}
<li class="tabular-numbers">{{ "{:,} {}".format(letter.billing_units, letter.postage_description) }} {{ letter.billing_units|message_count_label('letter', suffix='') }} at
{{ letter.rate | format_number_in_pounds_as_currency }}</li>
{% endif %}
{% endfor %}
{% if not (month.sms_free_count or month.sms_paid_count or month.letters) %}
<li aria-hidden="true"></li>
{% endif %}
</ul>
{% endcall %}
{% endcall %}
</div>
{% endif %}
</div>
<div class="govuk-grid-row">
<div class="govuk-grid-column-one-third">
<p class="align-with-heading-copy">
Financial year ends 31&nbsp;March
</p>
</div>
<div class="govuk-grid-column-two-thirds">
<p class="align-with-heading-copy">
What counts as 1 text message?<br />
See <a class="govuk-link govuk-link--no-visited-state" href="{{ url_for('.pricing') }}">pricing</a>.
</p>
</div>
</div>
{% endblock %}