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')
}
)