diff --git a/app/main/views/organisations.py b/app/main/views/organisations.py index f29f47e04..21bba27af 100644 --- a/app/main/views/organisations.py +++ b/app/main/views/organisations.py @@ -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 ] diff --git a/tests/app/main/views/organisations/test_organisations.py b/tests/app/main/views/organisations/test_organisations.py index 4cb5e1c9e..bbef28c9b 100644 --- a/tests/app/main/views/organisations/test_organisations.py +++ b/tests/app/main/views/organisations/test_organisations.py @@ -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" )