From c1bfc280b739698c52becb60a84cd5bff7183bfb Mon Sep 17 00:00:00 2001 From: Katie Smith Date: Fri, 11 Jun 2021 11:08:33 +0100 Subject: [PATCH] Add total_letters to the billing report This adds an extra column to the report that can be downloaded from `platform-admin/reports/usage-for-all-services`. --- app/main/views/platform_admin.py | 4 ++-- tests/app/main/views/test_platform_admin.py | 4 +++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/app/main/views/platform_admin.py b/app/main/views/platform_admin.py index 0c7a319a0..6f69de299 100644 --- a/app/main/views/platform_admin.py +++ b/app/main/views/platform_admin.py @@ -282,7 +282,7 @@ def get_billing_report(): end_date = form.end_date.data headers = [ "organisation_id", "organisation_name", "service_id", "service_name", - "sms_cost", "sms_fragments", "letter_cost", "letter_breakdown", "purchase_order_number", + "sms_cost", "sms_fragments", "total_letters", "letter_cost", "letter_breakdown", "purchase_order_number", "contact_names", "contact_email_addresses", "billing_reference" ] try: @@ -297,7 +297,7 @@ def get_billing_report(): rows = [ [ r["organisation_id"], r["organisation_name"], r["service_id"], r["service_name"], - r["sms_cost"], r["sms_fragments"], r["letter_cost"], r["letter_breakdown"].strip(), + r["sms_cost"], r["sms_fragments"], r["total_letters"], r["letter_cost"], r["letter_breakdown"].strip(), r.get("purchase_order_number"), r.get("contact_names"), r.get("contact_email_addresses"), r.get("billing_reference") ] diff --git a/tests/app/main/views/test_platform_admin.py b/tests/app/main/views/test_platform_admin.py index c1ac2bff6..1d34636ff 100644 --- a/tests/app/main/views/test_platform_admin.py +++ b/tests/app/main/views/test_platform_admin.py @@ -851,6 +851,7 @@ def test_get_billing_report_when_calls_api_and_download_data(platform_admin_clie "app.main.views.platform_admin.billing_api_client.get_data_for_billing_report", return_value=[{ 'letter_breakdown': '6 second class letters at 45p\n2 first class letters at 35p\n', + 'total_letters': 8, 'letter_cost': 3.4, 'organisation_id': '7832a1be-a1f0-4f2a-982f-05adfd3d6354', 'organisation_name': 'Org for a - with sms and letter', @@ -875,7 +876,7 @@ def test_get_billing_report_when_calls_api_and_download_data(platform_admin_clie ) assert response.get_data(as_text=True) == ( - 'organisation_id,organisation_name,service_id,service_name,sms_cost,sms_fragments,letter_cost' + + 'organisation_id,organisation_name,service_id,service_name,sms_cost,sms_fragments,total_letters,letter_cost' + ',letter_breakdown,purchase_order_number,contact_names,contact_email_addresses,billing_reference' + '\r\n' + @@ -886,6 +887,7 @@ def test_get_billing_report_when_calls_api_and_download_data(platform_admin_clie 'a - with sms and letter,' + '0,' + '0,' + + '8,' + '3.4,' + '"6 second class letters at 45p' + '\n' +