mirror of
https://github.com/GSA/notifications-api.git
synced 2025-12-20 07:21:13 -05:00
When a service is associated with a organisation set the free allowance to
the default free allowance for the organisation type. The update/insert for the default free allowance is done in a separate transaction. Updates to services need to happen in a transaction to trigger the insert into the ServicesHistory table. For that reason the call to set_default_free_allowance_for_service is done after the service is updated. I've added a try/except around the set_default_free_allowance_for_service call to ensure we still get the update to the service but get an exception log if the update to annual_billing fails. I believe it's important to preserve the update to the service in the unlikely event that the annual_billing upsert fails.
This commit is contained in:
@@ -53,7 +53,7 @@ def dao_get_all_free_sms_fragment_limit(service_id):
|
||||
).order_by(AnnualBilling.financial_year_start).all()
|
||||
|
||||
|
||||
def set_default_free_allowance_for_service(service, year_start=None):
|
||||
def set_default_free_allowance_for_service(service, year_start=None, commit=True):
|
||||
default_free_sms_fragment_limits = {
|
||||
'central': {
|
||||
2020: 250_000,
|
||||
@@ -90,6 +90,7 @@ def set_default_free_allowance_for_service(service, year_start=None):
|
||||
}
|
||||
if not year_start:
|
||||
year_start = get_current_financial_year_start_year()
|
||||
# handle cases where the year is less than 2020 or greater than 2021
|
||||
if year_start < 2020:
|
||||
year_start = 2020
|
||||
if year_start > 2021:
|
||||
|
||||
Reference in New Issue
Block a user