Sum up usage for an whole organisation

We invoice on a per organisation basis, so it’s useful to know the per
organisation figures without needing to do any spreadsheet-fu.
This commit is contained in:
Chris Hill-Scott
2020-02-27 15:21:08 +00:00
parent 4d89d36847
commit bd9e127e57
4 changed files with 48 additions and 12 deletions

View File

@@ -125,10 +125,14 @@ def add_organisation_from_nhs_local_service(service_id):
@main.route("/organisations/<uuid:org_id>", methods=['GET'])
@user_has_permissions()
def organisation_dashboard(org_id):
services = current_organisation.services_and_usage()
services = current_organisation.services_and_usage()['services']
return render_template(
'views/organisations/organisation/index.html',
services=services
services=services,
**{
f'total_{key}': sum(service[key] for service in services)
for key in ('emails_sent', 'sms_cost', 'letter_cost')
}
)

View File

@@ -11,8 +11,34 @@
Usage
</h1>
<div class="grid-row">
<div class="column-one-third">
{{ big_number(
total_emails_sent,
label='emails sent',
smaller=True
) }}
</div>
<div class="column-one-third">
{{ big_number(
total_sms_cost,
'spent on text messages',
currency="£",
smaller=True
) }}
</div>
<div class="column-one-third">
{{ big_number(
total_letter_cost,
'spent on letters',
currency="£",
smaller=True
) }}
</div>
</div>
<ul>
{% for service in services['services'] %}
{% for service in services %}
<li class="browse-list-item">
<a href="{{ url_for('main.usage', service_id=service.service_id) }}" class="govuk-link govuk-link--no-visited-state browse-list-link">{{ service.service_name }}</a>
</li>