mirror of
https://github.com/GSA/notifications-api.git
synced 2026-02-04 02:11:11 -05:00
The free sms allowances are changing for the financial year starting
April 1 2021. In this PR there is a command to set annual_billing for all active services with the the new defaults. The new method `set_default_free_allowance_for_service` will also be called in a PR to follow that will set a services free allowance to the default if the organisation for the service is changed.
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
from flask import current_app
|
||||
|
||||
from app import db
|
||||
from app.dao.dao_utils import transactional
|
||||
from app.dao.date_util import get_current_financial_year_start_year
|
||||
@@ -49,3 +51,54 @@ def dao_get_all_free_sms_fragment_limit(service_id):
|
||||
return AnnualBilling.query.filter_by(
|
||||
service_id=service_id,
|
||||
).order_by(AnnualBilling.financial_year_start).all()
|
||||
|
||||
|
||||
def set_default_free_allowance_for_service(service, year_start=None):
|
||||
default_free_sms_fragment_limits = {
|
||||
'central': {
|
||||
2020: 250_000,
|
||||
2021: 150_000,
|
||||
},
|
||||
'local': {
|
||||
2020: 25_000,
|
||||
2021: 25_000,
|
||||
},
|
||||
'nhs_central': {
|
||||
2020: 250_000,
|
||||
2021: 150_000,
|
||||
},
|
||||
'nhs_local': {
|
||||
2020: 25_000,
|
||||
2021: 25_000,
|
||||
},
|
||||
'nhs_gp': {
|
||||
2020: 25_000,
|
||||
2021: 10_000,
|
||||
},
|
||||
'emergency_service': {
|
||||
2020: 25_000,
|
||||
2021: 25_000,
|
||||
},
|
||||
'school_or_college': {
|
||||
2020: 25_000,
|
||||
2021: 10_000,
|
||||
},
|
||||
'other': {
|
||||
2020: 25_000,
|
||||
2021: 10_000,
|
||||
},
|
||||
}
|
||||
if not year_start:
|
||||
year_start = get_current_financial_year_start_year()
|
||||
if service.organisation_type:
|
||||
free_allowance = default_free_sms_fragment_limits[service.organisation_type][year_start]
|
||||
else:
|
||||
current_app.logger.info(f"no organisation type for service {service.id}. Using other default of "
|
||||
f"{default_free_sms_fragment_limits['other'][year_start]}")
|
||||
free_allowance = default_free_sms_fragment_limits['other'][year_start]
|
||||
|
||||
dao_create_or_update_annual_billing_for_year(
|
||||
service.id,
|
||||
free_allowance,
|
||||
year_start
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user