Use annual_billing tables at backend for getting and updating free_sms_fragment_limit

This commit is contained in:
venusbb
2017-10-31 11:22:57 +00:00
parent e665f35acc
commit 8ea38ba7b6
10 changed files with 161 additions and 17 deletions
+7 -2
View File
@@ -20,7 +20,8 @@ from app.notify_client.models import InvitedUser
from app import (
invite_api_client,
user_api_client,
service_api_client
service_api_client,
billing_api_client
)
from app.utils import (
@@ -40,17 +41,21 @@ def _add_invited_user_to_service(invited_user):
def _create_service(service_name, organisation_type, email_from, form):
free_sms_fragment_limit = current_app.config['DEFAULT_FREE_SMS_FRAGMENT_LIMITS'].get(organisation_type)
try:
service_id = service_api_client.create_service(
service_name=service_name,
organisation_type=organisation_type,
message_limit=current_app.config['DEFAULT_SERVICE_LIMIT'],
free_sms_fragment_limit=current_app.config['DEFAULT_FREE_SMS_FRAGMENT_LIMITS'].get(organisation_type),
free_sms_fragment_limit=free_sms_fragment_limit,
restricted=True,
user_id=session['user_id'],
email_from=email_from,
)
session['service_id'] = service_id
billing_api_client.create_or_update_free_sms_fragment_limit_for_year(service_id, free_sms_fragment_limit)
return service_id, None
except HTTPError as e:
if e.status_code == 400 and e.message['name']: