mirror of
https://github.com/GSA/notifications-api.git
synced 2026-08-11 09:27:56 -04:00
- Only rebuild current month for monthly_billing if today is in the current year.
- Change the usage queries to a union so that billing_units is correct for all notification types. Removing the business logic from the schema. - Added tests for different fragment counts, rates and sheet counts.
This commit is contained in:
@@ -266,14 +266,12 @@ def test_fetch_monthly_billing_for_year(notify_db_session):
|
||||
assert str(results[0].month) == "2018-06-01"
|
||||
assert results[0].notifications_sent == 30
|
||||
assert results[0].billable_units == Decimal('60')
|
||||
assert results[0].service_id == service.id
|
||||
assert results[0].rate == Decimal('0.162')
|
||||
assert results[0].notification_type == 'sms'
|
||||
|
||||
assert str(results[1].month) == "2018-07-01"
|
||||
assert results[1].notifications_sent == 31
|
||||
assert results[1].billable_units == Decimal('31')
|
||||
assert results[1].service_id == service.id
|
||||
assert results[1].rate == Decimal('0.158')
|
||||
assert results[1].notification_type == 'sms'
|
||||
|
||||
@@ -330,19 +328,16 @@ def test_fetch_billing_totals_for_year(notify_db_session):
|
||||
|
||||
assert len(results) == 3
|
||||
assert results[0].notification_type == 'email'
|
||||
assert results[0].service_id == service.id
|
||||
assert results[0].notifications_sent == 365
|
||||
assert results[0].billable_units == 365
|
||||
assert results[0].rate == Decimal('0')
|
||||
|
||||
assert results[1].notification_type == 'letter'
|
||||
assert results[1].service_id == service.id
|
||||
assert results[1].notifications_sent == 365
|
||||
assert results[1].billable_units == 365
|
||||
assert results[1].rate == Decimal('0.33')
|
||||
|
||||
assert results[2].notification_type == 'sms'
|
||||
assert results[2].service_id == service.id
|
||||
assert results[2].notifications_sent == 365
|
||||
assert results[2].billable_units == 365
|
||||
assert results[2].rate == Decimal('0.162')
|
||||
|
||||
@@ -511,3 +511,13 @@ def test_get_yearly_billing_data_for_year_includes_current_day_totals(sample_tem
|
||||
)
|
||||
|
||||
assert billing_data[0].monthly_totals[0]['billing_units'] == 3
|
||||
|
||||
|
||||
@freeze_time("2017-06-16 13:00:00")
|
||||
def test_get_billing_data_for_financial_year_updated_monthly_billing_if_today_is_in_current_year(
|
||||
sample_service,
|
||||
mocker
|
||||
):
|
||||
mock = mocker.patch("app.dao.monthly_billing_dao.create_or_update_monthly_billing")
|
||||
get_billing_data_for_financial_year(sample_service.id, 2016)
|
||||
mock.assert_not_called()
|
||||
|
||||
Reference in New Issue
Block a user