From f1d5c33fda896e679cd691371e663ba9862e24a6 Mon Sep 17 00:00:00 2001 From: Pea Tyczynska Date: Tue, 18 Jan 2022 17:38:46 +0000 Subject: [PATCH 1/4] Rename sms_fragments to sms_chargeable_units This field caused some confusion and lots of unnecessary work to our colleague because of unclear name. The field was named sms_fragments, where in fact the value of the field is: those sms fragments that go above free allowance multiplied by the rate multiplier. The new name was chosen through consultation with colleagues who use billing report the most. --- app/main/views/platform_admin.py | 6 +++--- tests/app/main/views/test_platform_admin.py | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/app/main/views/platform_admin.py b/app/main/views/platform_admin.py index f1b007a72..db5ec765f 100644 --- a/app/main/views/platform_admin.py +++ b/app/main/views/platform_admin.py @@ -279,8 +279,8 @@ def get_billing_report(): end_date = form.end_date.data headers = [ "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" + "sms_cost", "sms_chargeable_units", "total_letters", "letter_cost", "letter_breakdown", + "purchase_order_number", "contact_names", "contact_email_addresses", "billing_reference" ] try: result = billing_api_client.get_data_for_billing_report(start_date, end_date) @@ -294,7 +294,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["total_letters"], r["letter_cost"], r["letter_breakdown"].strip(), + r["sms_cost"], r["sms_chargeable_units"], 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 b5674f2fc..4c19466e5 100644 --- a/tests/app/main/views/test_platform_admin.py +++ b/tests/app/main/views/test_platform_admin.py @@ -935,7 +935,7 @@ def test_get_billing_report_when_calls_api_and_download_data( 'service_id': '48e82ac0-c8c4-4e46-8712-c83c35a94006', 'service_name': 'a - with sms and letter', 'sms_cost': 0, - 'sms_fragments': 0, + 'sms_chargeable_units': 0, 'purchase_order_number': 'PO1234', 'contact_names': 'Anne, Marie, Josh', 'contact_email_addresses': 'billing@example.com, accounts@example.com', @@ -956,10 +956,10 @@ def test_get_billing_report_when_calls_api_and_download_data( ) assert response.get_data(as_text=True) == ( - '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' + + 'organisation_id,organisation_name,service_id,service_name,sms_cost,sms_chargeable_units' + + ',total_letters,letter_cost,letter_breakdown,purchase_order_number,contact_names,contact_email_addresses' + - '\r\n' + + ',billing_reference\r\n' + '7832a1be-a1f0-4f2a-982f-05adfd3d6354,' + 'Org for a - with sms and letter,' + From eadf32410b8b89b7854d2331143b00b929db295c Mon Sep 17 00:00:00 2001 From: Pea Tyczynska Date: Tue, 25 Jan 2022 17:43:28 +0000 Subject: [PATCH 2/4] Add guidance to billing report page Following a team cuddle where we checked how different people interpret the billing report. We found that some things about the report are ambiguous and that it would be helpful to have some guidance on the page where the report can be downloaded, --- .../platform-admin/get-billing-report.html | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/app/templates/views/platform-admin/get-billing-report.html b/app/templates/views/platform-admin/get-billing-report.html index 068122389..d5ecdfcc2 100644 --- a/app/templates/views/platform-admin/get-billing-report.html +++ b/app/templates/views/platform-admin/get-billing-report.html @@ -17,4 +17,22 @@ {{ page_footer('Download report') }} {% endcall %} +

+ Guidance for interpreting the report +

+

+ Billing report shows data for period between start date and end date, inclusive of both dates. +

+

+ Explanation for more confusing column names in the report: +

+ + {% endblock %} From feb2657040cd6634d78f12021a8593baa8c8fd6d Mon Sep 17 00:00:00 2001 From: Pea Tyczynska Date: Fri, 28 Jan 2022 14:27:21 +0000 Subject: [PATCH 3/4] Change formatting for guidance from list to table. Also rewrite some of the guidance following content review. Co-authored-by: karlchillmaid --- app/main/views/platform_admin.py | 6 +-- .../platform-admin/get-billing-report.html | 38 +++++++++++-------- 2 files changed, 26 insertions(+), 18 deletions(-) diff --git a/app/main/views/platform_admin.py b/app/main/views/platform_admin.py index db5ec765f..22731c58a 100644 --- a/app/main/views/platform_admin.py +++ b/app/main/views/platform_admin.py @@ -294,9 +294,9 @@ def get_billing_report(): rows = [ [ r["organisation_id"], r["organisation_name"], r["service_id"], r["service_name"], - r["sms_cost"], r["sms_chargeable_units"], 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") + r["sms_cost"], r["sms_chargeable_units"], 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") ] for r in result ] diff --git a/app/templates/views/platform-admin/get-billing-report.html b/app/templates/views/platform-admin/get-billing-report.html index d5ecdfcc2..0a07f1aee 100644 --- a/app/templates/views/platform-admin/get-billing-report.html +++ b/app/templates/views/platform-admin/get-billing-report.html @@ -1,5 +1,6 @@ {% extends "views/platform-admin/_base_template.html" %} {% from "components/form.html" import form_wrapper %} +{% from "components/table.html" import mapping_table, row, text_field %} {% block per_page_title %} Billing Report @@ -18,21 +19,28 @@ {% endcall %}

- Guidance for interpreting the report + Data included in the report

-

- Billing report shows data for period between start date and end date, inclusive of both dates. -

-

- Explanation for more confusing column names in the report: -

-
    -
  • sms cost - cost accrued by a service through sending text messages after they run out of free allowance
  • -
  • sms chargeable units - sms fragments that go over free allowance multiplied by rate multiplier (so higher costs of sending international SMS are taken into consideration)
  • -
  • letter cost - cost accrued by a service through sending letters (number of letters * numbers of paper sheets * postage)
  • -
  • letter breakdown - amount and cost of letters sent by a service for each postage class
  • -
  • purchase order number, contact names, contact email addresses, billing reference - this data is manually filled in by us based on the information we get from services. You can help by filling it in (on Service Settings page)
  • - -
+
+ {% call mapping_table( + caption='Descriptions of billing report data', + field_headings=['Name', 'Description'], + field_headings_visible=True, + caption_visible=False + ) %} + {% for message_length, charge in [ + ('sms cost', 'The total cost of text messages sent after a service has used its free allowance.'), + ('sms chargeable units', 'The number of fragments sent after a service has used its free allowance. This number takes into account the cost multiplier for sending international text messages.'), + ('letter cost', 'The total cost of letters sent by a service.'), + ('letter breakdown', 'The number and cost of letters sent by a service, grouped by postage.'), + ('purchase order number, contact names, contact email addresses and billing reference', 'We add this data manually based on the information we get from services. You can help by adding it to the service settings page.'), + ] %} + {% call row() %} + {{ text_field(message_length) }} + {{ text_field(charge | safe) }} + {% endcall %} + {% endfor %} + {% endcall %} +
{% endblock %} From 9862acd7ee38ea79f0407805292d657bc70322df Mon Sep 17 00:00:00 2001 From: Pea Tyczynska Date: Fri, 28 Jan 2022 15:43:58 +0000 Subject: [PATCH 4/4] Hint that report is inclusive of both start date and end date Bu changing labels for date input fields. --- app/main/forms.py | 5 +++++ app/main/views/platform_admin.py | 3 ++- app/templates/views/platform-admin/get-billing-report.html | 6 +++--- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/app/main/forms.py b/app/main/forms.py index fd0e85f50..df00bcd9b 100644 --- a/app/main/forms.py +++ b/app/main/forms.py @@ -1962,6 +1962,11 @@ class RequiredDateFilterForm(StripWhitespaceForm): end_date = GovukDateField("End Date") +class BillingReportDateFilterForm(StripWhitespaceForm): + start_date = GovukDateField("First day covered by report") + end_date = GovukDateField("Last day covered by report") + + class SearchByNameForm(StripWhitespaceForm): search = GovukSearchField( diff --git a/app/main/views/platform_admin.py b/app/main/views/platform_admin.py index 22731c58a..37d97e9e2 100644 --- a/app/main/views/platform_admin.py +++ b/app/main/views/platform_admin.py @@ -18,6 +18,7 @@ from app import ( from app.extensions import redis_client from app.main import main from app.main.forms import ( + BillingReportDateFilterForm, ClearCacheForm, DateFilterForm, RequiredDateFilterForm, @@ -272,7 +273,7 @@ def notifications_sent_by_service(): @main.route("/platform-admin/reports/usage-for-all-services", methods=['GET', 'POST']) @user_is_platform_admin def get_billing_report(): - form = RequiredDateFilterForm() + form = BillingReportDateFilterForm() if form.validate_on_submit(): start_date = form.start_date.data diff --git a/app/templates/views/platform-admin/get-billing-report.html b/app/templates/views/platform-admin/get-billing-report.html index 0a07f1aee..8e77016d1 100644 --- a/app/templates/views/platform-admin/get-billing-report.html +++ b/app/templates/views/platform-admin/get-billing-report.html @@ -13,8 +13,8 @@ {% call form_wrapper() %} - {{ form.start_date(param_extensions={"hint": {"text": "Enter start date in format YYYY-MM-DD"}}) }} - {{ form.end_date(param_extensions={"hint": {"text": "Enter end date in format YYYY-MM-DD"}}) }} + {{ form.start_date(param_extensions={"hint": {"text": "Use the format YYYY-MM-DD"}}) }} + {{ form.end_date(param_extensions={"hint": {"text": "Use the format YYYY-MM-DD"}}) }} {{ page_footer('Download report') }} {% endcall %} @@ -32,7 +32,7 @@ ('sms cost', 'The total cost of text messages sent after a service has used its free allowance.'), ('sms chargeable units', 'The number of fragments sent after a service has used its free allowance. This number takes into account the cost multiplier for sending international text messages.'), ('letter cost', 'The total cost of letters sent by a service.'), - ('letter breakdown', 'The number and cost of letters sent by a service, grouped by postage.'), + ('letter breakdown', 'The number of letters sent by a service, grouped by postage and unit cost.'), ('purchase order number, contact names, contact email addresses and billing reference', 'We add this data manually based on the information we get from services. You can help by adding it to the service settings page.'), ] %} {% call row() %}