mirror of
https://github.com/GSA/notifications-api.git
synced 2026-08-20 14:29:25 -04:00
Fix bug in organisation report for its services and usages.
If a service has not sent any SMS for the financial year the free allowance was showing up as 0 rather than the number in annual billing. The query has been updated to use an outer join so that the free allow will be returned when there is no ft_billing. There is a potential performance enhancement to only return the data for the services of the organisation in the `fetch_sms_free_allowance_remainder_until_date` subquery. I will investigate in a subsequent PR.
This commit is contained in:
@@ -736,7 +736,7 @@ def test_fetch_usage_year_for_organisation(notify_db_session):
|
||||
notifications_sent=1100)
|
||||
results = fetch_usage_year_for_organisation(fixtures["org_1"].id, 2019)
|
||||
|
||||
assert len(results) == 2
|
||||
assert len(results) == 3
|
||||
first_row = results[str(fixtures["service_1_sms_and_letter"].id)]
|
||||
assert first_row['service_id'] == fixtures["service_1_sms_and_letter"].id
|
||||
assert first_row['service_name'] == fixtures["service_1_sms_and_letter"].name
|
||||
@@ -757,6 +757,16 @@ def test_fetch_usage_year_for_organisation(notify_db_session):
|
||||
assert second_row['letter_cost'] == 0
|
||||
assert second_row['emails_sent'] == 1100
|
||||
|
||||
third_row = results[str(fixtures["service_with_out_ft_billing_this_year"].id)]
|
||||
assert third_row['service_id'] == fixtures["service_with_out_ft_billing_this_year"].id
|
||||
assert third_row['service_name'] == fixtures["service_with_out_ft_billing_this_year"].name
|
||||
assert third_row['free_sms_limit'] == 10
|
||||
assert third_row['sms_remainder'] == 10
|
||||
assert third_row['chargeable_billable_sms'] == 0
|
||||
assert third_row['sms_cost'] == 0
|
||||
assert third_row['letter_cost'] == 0
|
||||
assert third_row['emails_sent'] == 0
|
||||
|
||||
|
||||
def test_fetch_usage_year_for_organisation_populates_ft_billing_for_today(notify_db_session):
|
||||
create_letter_rate(start_date=datetime.utcnow() - timedelta(days=1))
|
||||
|
||||
Reference in New Issue
Block a user