mirror of
https://github.com/GSA/notifications-api.git
synced 2026-03-20 02:00:22 -04: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'),
|
||||
|
||||
@@ -261,7 +261,7 @@ def test_create_nightly_billing_null_sent_by_sms(
|
||||
assert record.rate == Decimal(1.33)
|
||||
assert record.billable_units == 1
|
||||
assert record.rate_multiplier == 1
|
||||
assert record.provider in ['mmg', 'firetext']
|
||||
assert record.provider == 'unknown'
|
||||
|
||||
|
||||
@freeze_time('2018-01-15T03:30:00')
|
||||
|
||||
Reference in New Issue
Block a user