mirror of
https://github.com/GSA/notifications-api.git
synced 2025-12-20 15:31:15 -05:00
Bridging API to update annual_billing table
This commit is contained in:
@@ -135,14 +135,16 @@ def create_or_update_free_sms_fragment_limit(service_id):
|
||||
|
||||
form = validate(req_args, create_or_update_free_sms_fragment_limit_schema)
|
||||
|
||||
financial_year_start = form.get('financial_year_start')
|
||||
free_sms_fragment_limit = form.get('free_sms_fragment_limit')
|
||||
update_free_sms_fragment_limit_data(service_id,
|
||||
free_sms_fragment_limit=form.get('free_sms_fragment_limit'),
|
||||
financial_year_start=form.get('financial_year_start'))
|
||||
return jsonify(form), 201
|
||||
|
||||
|
||||
def update_free_sms_fragment_limit_data(service_id, free_sms_fragment_limit, financial_year_start=None):
|
||||
current_year = get_current_financial_year_start_year()
|
||||
if financial_year_start is None or financial_year_start >= current_year:
|
||||
dao_update_annual_billing_for_current_and_future_years(service_id, free_sms_fragment_limit)
|
||||
else:
|
||||
dao_create_or_update_annual_billing_for_year(service_id,
|
||||
free_sms_fragment_limit, financial_year_start)
|
||||
|
||||
return jsonify(form), 201
|
||||
|
||||
@@ -98,6 +98,7 @@ from app.schemas import (
|
||||
detailed_service_schema
|
||||
)
|
||||
from app.utils import pagination_links
|
||||
from app.billing.rest import update_free_sms_fragment_limit_data
|
||||
|
||||
service_blueprint = Blueprint('service', __name__)
|
||||
|
||||
@@ -202,6 +203,10 @@ def update_service(service_id):
|
||||
if 'letter_contact_block' in req_json:
|
||||
create_or_update_letter_contact(fetched_service.id, req_json['letter_contact_block'])
|
||||
|
||||
# bridging code between frontend is deployed and data has not been migrated yet. Can only update current year
|
||||
if 'free_sms_fragment_limit' in req_json:
|
||||
update_free_sms_fragment_limit_data(fetched_service.id, req_json['free_sms_fragment_limit'])
|
||||
|
||||
if service_going_live:
|
||||
send_notification_to_service_users(
|
||||
service_id=service_id,
|
||||
|
||||
Reference in New Issue
Block a user