From c111458168d65504861fea2bad6b9f38d0f1e740 Mon Sep 17 00:00:00 2001 From: venusbb Date: Tue, 14 Nov 2017 16:11:59 +0000 Subject: [PATCH] Bridging API to update annual_billing table --- app/billing/rest.py | 10 ++++++---- app/service/rest.py | 5 +++++ 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/app/billing/rest.py b/app/billing/rest.py index 614842d3f..1bdeaf6a9 100644 --- a/app/billing/rest.py +++ b/app/billing/rest.py @@ -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 diff --git a/app/service/rest.py b/app/service/rest.py index c6e8c4201..a17920d36 100644 --- a/app/service/rest.py +++ b/app/service/rest.py @@ -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,