mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-06-28 19:31:00 -04:00
Format monetary values to two decimal places
This means that the data in the report will match what’s on the page, where the values are rounded to the nearest penny. This uses the same string formatting to round the numbers which the `big_number` component does, so it should round the numbers in the same way.
This commit is contained in:
@@ -187,15 +187,13 @@ def download_organisation_usage_report(org_id):
|
||||
('letter_cost', 'Spent on letters (£)')
|
||||
])
|
||||
|
||||
column_names = OrderedDict(
|
||||
list(unit_column_names.items()) + list(monetary_column_names.items())
|
||||
)
|
||||
|
||||
org_usage_data = [
|
||||
list(column_names.values())
|
||||
list(unit_column_names.values()) + list(monetary_column_names.values())
|
||||
] + [
|
||||
[
|
||||
service[attribute] for attribute in column_names.keys()
|
||||
service[attribute] for attribute in unit_column_names.keys()
|
||||
] + [
|
||||
'{:,.2f}'.format(service[attribute]) for attribute in monetary_column_names.keys()
|
||||
]
|
||||
for service in services_usage
|
||||
]
|
||||
|
||||
@@ -692,9 +692,9 @@ def test_download_organisation_usage_report(
|
||||
'chargeable_billable_sms': 22,
|
||||
'emails_sent': 13000,
|
||||
'free_sms_limit': 100,
|
||||
'letter_cost': 30.50,
|
||||
'letter_cost': 30.5,
|
||||
'sms_billable_units': 122,
|
||||
'sms_cost': 1.93,
|
||||
'sms_cost': 1.934,
|
||||
'sms_remainder': None
|
||||
},
|
||||
{
|
||||
@@ -703,9 +703,9 @@ def test_download_organisation_usage_report(
|
||||
'chargeable_billable_sms': 222,
|
||||
'emails_sent': 23000,
|
||||
'free_sms_limit': 250000,
|
||||
'letter_cost': 60.50,
|
||||
'letter_cost': 60.5,
|
||||
'sms_billable_units': 322,
|
||||
'sms_cost': 3.93,
|
||||
'sms_cost': 3.935,
|
||||
'sms_remainder': None
|
||||
},
|
||||
]}
|
||||
@@ -721,8 +721,8 @@ def test_download_organisation_usage_report(
|
||||
assert csv_report.string == (
|
||||
"Service ID,Service Name,Emails sent,Free text message allowance remaining,"
|
||||
"Spent on text messages (£),Spent on letters (£)"
|
||||
"\r\n596364a0-858e-42c8-9062-a8fe822260eb,Service 1,13000,,1.93,30.5"
|
||||
"\r\n147ad62a-2951-4fa1-9ca0-093cd1a52c52,Service 1,23000,,3.93,60.5\r\n"
|
||||
"\r\n596364a0-858e-42c8-9062-a8fe822260eb,Service 1,13000,,1.93,30.50"
|
||||
"\r\n147ad62a-2951-4fa1-9ca0-093cd1a52c52,Service 1,23000,,3.94,60.50\r\n"
|
||||
)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user