mirror of
https://github.com/GSA/notifications-api.git
synced 2026-02-01 15:46:07 -05:00
Update letter data for usage-for-all-services report
Usage for all services is a platform admin report that groups letters by postage. We want it to show `europe` and `rest-of-world` letters under a single category of `international`, so this updates the query to do that and to order appropriately.
This commit is contained in:
@@ -623,7 +623,7 @@ def test_fetch_letter_costs_for_all_services(notify_db_session):
|
||||
assert len(results) == 3
|
||||
assert results[0] == (org.name, org.id, service.name, service.id, Decimal('3.40'))
|
||||
assert results[1] == (org_2.name, org_2.id, service_2.name, service_2.id, Decimal('14.00'))
|
||||
assert results[2] == (None, None, service_3.name, service_3.id, Decimal('8.25'))
|
||||
assert results[2] == (None, None, service_3.name, service_3.id, Decimal('24.45'))
|
||||
|
||||
|
||||
def test_fetch_letter_line_items_for_all_service(notify_db_session):
|
||||
@@ -632,12 +632,14 @@ def test_fetch_letter_line_items_for_all_service(notify_db_session):
|
||||
|
||||
results = fetch_letter_line_items_for_all_services(datetime(2019, 6, 1), datetime(2019, 9, 30))
|
||||
|
||||
assert len(results) == 5
|
||||
assert len(results) == 7
|
||||
assert results[0] == (org_1.name, org_1.id, service_1.name, service_1.id, Decimal('0.45'), 'second', 6)
|
||||
assert results[1] == (org_1.name, org_1.id, service_1.name, service_1.id, Decimal("0.35"), 'first', 2)
|
||||
assert results[2] == (org_2.name, org_2.id, service_2.name, service_2.id, Decimal("0.65"), 'second', 20)
|
||||
assert results[3] == (org_2.name, org_2.id, service_2.name, service_2.id, Decimal("0.50"), 'first', 2)
|
||||
assert results[4] == (None, None, service_3.name, service_3.id, Decimal("0.55"), 'second', 15)
|
||||
assert results[4] == (None, None, service_3.name, service_3.id, Decimal("0.35"), 'second', 2)
|
||||
assert results[5] == (None, None, service_3.name, service_3.id, Decimal("0.50"), 'first', 1)
|
||||
assert results[6] == (None, None, service_3.name, service_3.id, Decimal("1.55"), 'international', 15)
|
||||
|
||||
|
||||
@freeze_time('2019-06-01 13:30')
|
||||
|
||||
@@ -941,7 +941,13 @@ def set_up_usage_data(start_date):
|
||||
notifications_sent=12, billable_unit=5, rate=.65, postage='second')
|
||||
|
||||
create_ft_billing(bst_date=two_days_later, template=letter_template_4,
|
||||
notifications_sent=15, billable_unit=4, rate=.55, postage='second')
|
||||
notifications_sent=7, billable_unit=4, rate=1.55, postage='rest-of-world')
|
||||
create_ft_billing(bst_date=two_days_later, template=letter_template_4,
|
||||
notifications_sent=8, billable_unit=4, rate=1.55, postage='europe')
|
||||
create_ft_billing(bst_date=two_days_later, template=letter_template_4,
|
||||
notifications_sent=2, billable_unit=1, rate=.35, postage='second')
|
||||
create_ft_billing(bst_date=two_days_later, template=letter_template_4,
|
||||
notifications_sent=1, billable_unit=1, rate=.50, postage='first')
|
||||
|
||||
create_ft_billing(bst_date=start_date, template=email_template, notifications_sent=10)
|
||||
|
||||
|
||||
@@ -153,5 +153,7 @@ def test_get_usage_for_all_services(notify_db_session, admin_request):
|
||||
assert response[3]["service_id"] == str(service_3.id)
|
||||
assert response[3]["sms_cost"] == 0
|
||||
assert response[3]["sms_fragments"] == 0
|
||||
assert response[3]["letter_cost"] == 8.25
|
||||
assert response[3]["letter_breakdown"] == "15 second class letters at 55p\n"
|
||||
assert response[3]["letter_cost"] == 24.45
|
||||
assert response[3]["letter_breakdown"] == (
|
||||
"2 second class letters at 35p\n1 first class letters at 50p\n15 international letters at £1.55\n"
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user