Merge pull request #4137 from alphagov/rename_column_in_billing_report

Rename sms_fragments to sms_chargeable_units
This commit is contained in:
Pea Tyczynska
2022-02-01 17:01:03 +00:00
committed by GitHub
4 changed files with 44 additions and 12 deletions

View File

@@ -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(

View File

@@ -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
]

View File

@@ -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 @@
</h1>
{% 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 %}
<h2 class="heading-medium">
Data included in the report
</h2>
<div class="bottom-gutter-3-2">
{% 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 <a class="govuk-link govuk-link--no-visited-state" href="https://www.notifications.service.gov.uk/pricing#international-numbers">sending international text messages</a>.'),
('letter cost', 'The total cost of letters sent by a service.'),
('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() %}
{{ text_field(message_length) }}
{{ text_field(charge | safe) }}
{% endcall %}
{% endfor %}
{% endcall %}
</div>
{% endblock %}

View File

@@ -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,' +