From bd9e127e57a7700bcca5fcbecd072db4fdcb0007 Mon Sep 17 00:00:00 2001 From: Chris Hill-Scott Date: Thu, 27 Feb 2020 15:21:08 +0000 Subject: [PATCH] Sum up usage for an whole organisation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We invoice on a per organisation basis, so it’s useful to know the per organisation figures without needing to do any spreadsheet-fu. --- app/main/views/organisations.py | 8 ++++-- .../organisations/organisation/index.html | 28 ++++++++++++++++++- .../views/organisations/test_organisation.py | 22 +++++++++------ tests/app/test_navigation.py | 2 +- 4 files changed, 48 insertions(+), 12 deletions(-) diff --git a/app/main/views/organisations.py b/app/main/views/organisations.py index 05b4fec6d..43959dabd 100644 --- a/app/main/views/organisations.py +++ b/app/main/views/organisations.py @@ -125,10 +125,14 @@ def add_organisation_from_nhs_local_service(service_id): @main.route("/organisations/", 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') + } ) diff --git a/app/templates/views/organisations/organisation/index.html b/app/templates/views/organisations/organisation/index.html index 45ca65a66..31c70be72 100644 --- a/app/templates/views/organisations/organisation/index.html +++ b/app/templates/views/organisations/organisation/index.html @@ -11,8 +11,34 @@ Usage +
+
+ {{ big_number( + total_emails_sent, + label='emails sent', + smaller=True + ) }} +
+
+ {{ big_number( + total_sms_cost, + 'spent on text messages', + currency="£", + smaller=True + ) }} +
+
+ {{ big_number( + total_letter_cost, + 'spent on letters', + currency="£", + smaller=True + ) }} +
+
+