Fix bug on organisation-usage page.

The dict is initialised for all live services, but if the organisation has trial mode services they cause a key error.
This commit is contained in:
Rebecca Law
2020-02-27 13:52:02 +00:00
parent ba24fe449b
commit 7b0a3c68cd
3 changed files with 28 additions and 10 deletions

View File

@@ -554,7 +554,8 @@ def fetch_letter_costs_for_organisation(organisation_id, start_date, end_date):
FactBilling.bst_date >= start_date,
FactBilling.bst_date <= end_date,
FactBilling.notification_type == LETTER_TYPE,
Service.organisation_id == organisation_id
Service.organisation_id == organisation_id,
Service.restricted.is_(False)
).group_by(
Service.id,
Service.name,
@@ -579,7 +580,8 @@ def fetch_email_usage_for_organisation(organisation_id, start_date, end_date):
FactBilling.bst_date >= start_date,
FactBilling.bst_date <= end_date,
FactBilling.notification_type == EMAIL_TYPE,
Service.organisation_id == organisation_id
Service.organisation_id == organisation_id,
Service.restricted.is_(False)
).group_by(
Service.id,
Service.name,
@@ -621,7 +623,8 @@ def fetch_sms_billing_for_organisation(organisation_id, start_date, end_date):
FactBilling.bst_date >= start_date,
FactBilling.bst_date <= end_date,
FactBilling.notification_type == SMS_TYPE,
Service.organisation_id == organisation_id
Service.organisation_id == organisation_id,
Service.restricted.is_(False)
).group_by(
Service.id,
Service.name,

View File

@@ -71,7 +71,7 @@ def persist_notification(
billable_units=None,
postage=None,
template_postage=None,
document_download_count=None,
document_download_count=None
):
notification_created_at = created_at or datetime.utcnow()
if not notification_id: