mirror of
https://github.com/GSA/notifications-api.git
synced 2026-02-01 07:35:34 -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 datetime import datetime, timedelta
|
||||||
from app.models import (Notification,
|
from app.models import (Notification,
|
||||||
Rate,
|
Rate,
|
||||||
@@ -44,14 +43,14 @@ def create_nightly_billing(day_start=None):
|
|||||||
Notification.template_id,
|
Notification.template_id,
|
||||||
Notification.service_id,
|
Notification.service_id,
|
||||||
Notification.notification_type,
|
Notification.notification_type,
|
||||||
case(
|
func.coalesce(Notification.sent_by,
|
||||||
[
|
case(
|
||||||
(Notification.notification_type == 'letter', func.coalesce(Notification.sent_by, 'dvla')),
|
[
|
||||||
(Notification.notification_type == 'sms',
|
(Notification.notification_type == 'letter', 'dvla'),
|
||||||
func.coalesce(Notification.sent_by, random.choice(['mmg', 'firetext'])))
|
(Notification.notification_type == 'sms', 'unknown'),
|
||||||
],
|
(Notification.notification_type == 'email', 'ses')
|
||||||
else_='ses'
|
]),
|
||||||
).label('sent_by'), # This could be null - this is a bug to be fixed.
|
).label('sent_by'),
|
||||||
func.coalesce(Notification.rate_multiplier, 1).label('rate_multiplier'),
|
func.coalesce(Notification.rate_multiplier, 1).label('rate_multiplier'),
|
||||||
func.coalesce(Notification.international, False).label('international'),
|
func.coalesce(Notification.international, False).label('international'),
|
||||||
func.sum(Notification.billable_units).label('billable_units'),
|
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.rate == Decimal(1.33)
|
||||||
assert record.billable_units == 1
|
assert record.billable_units == 1
|
||||||
assert record.rate_multiplier == 1
|
assert record.rate_multiplier == 1
|
||||||
assert record.provider in ['mmg', 'firetext']
|
assert record.provider == 'unknown'
|
||||||
|
|
||||||
|
|
||||||
@freeze_time('2018-01-15T03:30:00')
|
@freeze_time('2018-01-15T03:30:00')
|
||||||
|
|||||||
Reference in New Issue
Block a user