mirror of
https://github.com/GSA/notifications-api.git
synced 2026-08-25 16:53:42 -04:00
Prepare to switch to "chargeable_units" in API
This is so we can migrate from "billing_units" to this new field in the Admin app, without breaking anything in between.
This commit is contained in:
@@ -30,7 +30,9 @@ def serialize_ft_billing_yearly_totals(rows):
|
||||
return [
|
||||
{
|
||||
"notification_type": row.notification_type,
|
||||
# TEMPORARY: while we migrate to "chargeable_units" in the Admin app
|
||||
"billing_units": row.billable_units,
|
||||
"chargeable_units": row.chargeable_units,
|
||||
"rate": float(row.rate),
|
||||
"letter_total": float(row.billable_units * row.rate) if row.notification_type == 'letter' else 0,
|
||||
}
|
||||
|
||||
@@ -201,7 +201,9 @@ def fetch_billing_totals_for_year(service_id, year):
|
||||
union(*[
|
||||
db.session.query(
|
||||
func.sum(query.c.notifications_sent).label("notifications_sent"),
|
||||
# TEMPORARY: while we switch to "chargeable units"
|
||||
func.sum(query.c.chargeable_units).label("billable_units"),
|
||||
func.sum(query.c.chargeable_units).label("chargeable_units"),
|
||||
query.c.rate.label("rate"),
|
||||
query.c.notification_type.label("notification_type"),
|
||||
).group_by(
|
||||
|
||||
@@ -240,15 +240,21 @@ def test_get_yearly_billing_usage_summary_from_ft_billing(admin_request, notify_
|
||||
)
|
||||
|
||||
assert len(json_response) == 3
|
||||
|
||||
assert json_response[0]['notification_type'] == 'email'
|
||||
assert json_response[0]['billing_units'] == 275
|
||||
assert json_response[0]['chargeable_units'] == 275
|
||||
assert json_response[0]['rate'] == 0
|
||||
assert json_response[0]['letter_total'] == 0
|
||||
|
||||
assert json_response[1]['notification_type'] == 'letter'
|
||||
assert json_response[1]['billing_units'] == 275
|
||||
assert json_response[1]['chargeable_units'] == 275
|
||||
assert json_response[1]['rate'] == 0.33
|
||||
assert json_response[1]['letter_total'] == 90.75
|
||||
|
||||
assert json_response[2]['notification_type'] == 'sms'
|
||||
assert json_response[2]['billing_units'] == 825
|
||||
assert json_response[2]['chargeable_units'] == 825
|
||||
assert json_response[2]['rate'] == 0.0162
|
||||
assert json_response[2]['letter_total'] == 0
|
||||
|
||||
@@ -508,21 +508,25 @@ def test_fetch_billing_totals_for_year(notify_db_session):
|
||||
assert results[0].notification_type == 'email'
|
||||
assert results[0].notifications_sent == 365
|
||||
assert results[0].billable_units == 365
|
||||
assert results[0].chargeable_units == 365
|
||||
assert results[0].rate == Decimal('0')
|
||||
|
||||
assert results[1].notification_type == 'letter'
|
||||
assert results[1].notifications_sent == 365
|
||||
assert results[1].billable_units == 365
|
||||
assert results[1].chargeable_units == 365
|
||||
assert results[1].rate == Decimal('0.3')
|
||||
|
||||
assert results[2].notification_type == 'letter'
|
||||
assert results[2].notifications_sent == 365
|
||||
assert results[2].billable_units == 365
|
||||
assert results[2].chargeable_units == 365
|
||||
assert results[2].rate == Decimal('0.33')
|
||||
|
||||
assert results[3].notification_type == 'sms'
|
||||
assert results[3].notifications_sent == 365
|
||||
assert results[3].billable_units == 365
|
||||
assert results[3].chargeable_units == 365
|
||||
assert results[3].rate == Decimal('0.162')
|
||||
|
||||
|
||||
@@ -534,21 +538,25 @@ def test_fetch_billing_totals_for_year_variable_rates(notify_db_session):
|
||||
assert results[0].notification_type == 'letter'
|
||||
assert results[0].notifications_sent == 1
|
||||
assert results[0].billable_units == 1
|
||||
assert results[0].chargeable_units == 1
|
||||
assert results[0].rate == Decimal('0.33')
|
||||
|
||||
assert results[1].notification_type == 'letter'
|
||||
assert results[1].notifications_sent == 1
|
||||
assert results[1].billable_units == 1
|
||||
assert results[1].chargeable_units == 1
|
||||
assert results[1].rate == Decimal('0.36')
|
||||
|
||||
assert results[2].notification_type == 'sms'
|
||||
assert results[2].notifications_sent == 1
|
||||
assert results[2].billable_units == 4
|
||||
assert results[2].chargeable_units == 4
|
||||
assert results[2].rate == Decimal('0.015')
|
||||
|
||||
assert results[3].notification_type == 'sms'
|
||||
assert results[3].notifications_sent == 2
|
||||
assert results[3].billable_units == 5
|
||||
assert results[3].chargeable_units == 5
|
||||
assert results[3].rate == Decimal('0.162')
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user