Rename usage report to billing report

Because only services with bills to pay are included, and
we started including billing details.

Also rename endpoints and file names to match this.
This commit is contained in:
Pea Tyczynska
2021-03-15 18:04:01 +00:00
parent 95f46ced8a
commit 38cfee6390
6 changed files with 17 additions and 17 deletions

View File

@@ -274,7 +274,7 @@ def notifications_sent_by_service():
@main.route("/platform-admin/reports/usage-for-all-services", methods=['GET', 'POST'])
@user_is_platform_admin
def usage_for_all_services():
def get_billing_report():
form = RequiredDateFilterForm()
if form.validate_on_submit():
@@ -286,7 +286,7 @@ def usage_for_all_services():
"contact_names", "contact_email_addresses", "billing_reference"
]
result = billing_api_client.get_usage_for_all_services(start_date, end_date)
result = billing_api_client.get_data_for_billing_report(start_date, end_date)
rows = [
[
r["organisation_id"], r["organisation_name"], r["service_id"], r["service_name"],
@@ -299,13 +299,13 @@ def usage_for_all_services():
if rows:
return Spreadsheet.from_rows([headers] + rows).as_csv_data, 200, {
'Content-Type': 'text/csv; charset=utf-8',
'Content-Disposition': 'attachment; filename="Usage for all services from {} to {}.csv"'.format(
'Content-Disposition': 'attachment; filename="Billing Report from {} to {}.csv"'.format(
start_date, end_date
)
}
else:
flash('No results for dates')
return render_template('views/platform-admin/usage_for_all_services.html', form=form)
return render_template('views/platform-admin/get-billing-report.html', form=form)
@main.route("/platform-admin/complaints")

View File

@@ -89,7 +89,7 @@ class HeaderNavigation(Navigation):
'live_services',
'live_services_csv',
'notifications_sent_by_service',
'usage_for_all_services',
'get_billing_report',
'organisations',
'platform_admin',
'platform_admin_list_complaints',

View File

@@ -34,8 +34,8 @@ class BillingAPIClient(NotifyAdminAPIClient):
data=data
)
def get_usage_for_all_services(self, start_date, end_date):
return self.get(url='/platform-stats/usage-for-all-services',
def get_data_for_billing_report(self, start_date, end_date):
return self.get(url='/platform-stats/data-for-billing-report',
params={
'start_date': str(start_date),
'end_date': str(end_date),

View File

@@ -2,13 +2,13 @@
{% from "components/form.html" import form_wrapper %}
{% block per_page_title %}
Usage for all services
Billing Report
{% endblock %}
{% block platform_admin_content %}
<h1 class="heading-large">
Usage for all services
Billing Report
</h1>
{% call form_wrapper() %}

View File

@@ -17,6 +17,6 @@
<a class="govuk-link govuk-link--no-visited-state" href="{{ url_for('main.notifications_sent_by_service') }}">Monthly notification statuses for live services</a>
</p>
<p class="govuk-body">
<a class="govuk-link govuk-link--no-visited-state" href="{{ url_for('main.usage_for_all_services') }}">Usage for all services</a>
<a class="govuk-link govuk-link--no-visited-state" href="{{ url_for('main.get_billing_report') }}">Billing Report</a>
</p>
{% endblock %}

View File

@@ -832,13 +832,13 @@ def test_get_notifications_sent_by_service_validates_form(mocker, client_request
assert mock_get_stats_from_api.called is False
def test_usage_for_all_services_when_no_results_for_date(client_request, platform_admin_user, mocker):
def test_get_billing_report_when_no_results_for_date(client_request, platform_admin_user, mocker):
client_request.login(platform_admin_user)
mocker.patch("app.main.views.platform_admin.billing_api_client.get_usage_for_all_services",
mocker.patch("app.main.views.platform_admin.billing_api_client.get_data_for_billing_report",
return_value=[])
page = client_request.post('main.usage_for_all_services',
page = client_request.post('main.get_billing_report',
_expected_status=200,
_data={'start_date': '2019-01-01', 'end_date': '2019-03-31'})
@@ -846,9 +846,9 @@ def test_usage_for_all_services_when_no_results_for_date(client_request, platfor
assert normalize_spaces(error.text) == 'No results for dates'
def test_usage_for_all_services_when_calls_api_and_download_data(platform_admin_client, mocker):
def test_get_billing_report_when_calls_api_and_download_data(platform_admin_client, mocker):
mocker.patch(
"app.main.views.platform_admin.billing_api_client.get_usage_for_all_services",
"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',
'letter_cost': 3.4,
@@ -865,13 +865,13 @@ def test_usage_for_all_services_when_calls_api_and_download_data(platform_admin_
}]
)
response = platform_admin_client.post(url_for('main.usage_for_all_services'),
response = platform_admin_client.post(url_for('main.get_billing_report'),
data={'start_date': '2019-01-01', 'end_date': '2019-03-31'})
assert response.status_code == 200
assert response.content_type == 'text/csv; charset=utf-8'
assert response.headers['Content-Disposition'] == (
'attachment; filename="Usage for all services from {} to {}.csv"'.format('2019-01-01', '2019-03-31')
'attachment; filename="Billing Report from {} to {}.csv"'.format('2019-01-01', '2019-03-31')
)
assert response.get_data(as_text=True) == (