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 f1b007a72..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,15 +273,15 @@ 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 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,9 +295,9 @@ 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.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 068122389..8e77016d1 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 @@ -12,9 +13,34 @@ {% 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 %} +