mirror of
https://github.com/GSA/notifications-api.git
synced 2026-01-31 15:15:38 -05:00
Preserve 'unknown' in ft_billing for sms if the provider is not known.
This commit is contained in:
@@ -1,4 +1,3 @@
|
||||
import random
|
||||
from datetime import datetime, timedelta
|
||||
from app.models import (Notification,
|
||||
Rate,
|
||||
@@ -44,14 +43,14 @@ def create_nightly_billing(day_start=None):
|
||||
Notification.template_id,
|
||||
Notification.service_id,
|
||||
Notification.notification_type,
|
||||
case(
|
||||
[
|
||||
(Notification.notification_type == 'letter', func.coalesce(Notification.sent_by, 'dvla')),
|
||||
(Notification.notification_type == 'sms',
|
||||
func.coalesce(Notification.sent_by, random.choice(['mmg', 'firetext'])))
|
||||
],
|
||||
else_='ses'
|
||||
).label('sent_by'), # This could be null - this is a bug to be fixed.
|
||||
func.coalesce(Notification.sent_by,
|
||||
case(
|
||||
[
|
||||
(Notification.notification_type == 'letter', 'dvla'),
|
||||
(Notification.notification_type == 'sms', 'unknown'),
|
||||
(Notification.notification_type == 'email', 'ses')
|
||||
]),
|
||||
).label('sent_by'),
|
||||
func.coalesce(Notification.rate_multiplier, 1).label('rate_multiplier'),
|
||||
func.coalesce(Notification.international, False).label('international'),
|
||||
func.sum(Notification.billable_units).label('billable_units'),
|
||||
|
||||
Reference in New Issue
Block a user