mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-09-06 15:38:25 -04:00
Use the revise api endpoints without current-year parameter
This commit is contained in:
@@ -54,7 +54,7 @@ def _create_service(service_name, organisation_type, email_from, form):
|
||||
)
|
||||
session['service_id'] = service_id
|
||||
|
||||
billing_api_client.create_or_update_free_sms_fragment_limit_for_year(service_id, free_sms_fragment_limit)
|
||||
billing_api_client.create_or_update_free_sms_fragment_limit(service_id, free_sms_fragment_limit)
|
||||
|
||||
return service_id, None
|
||||
except HTTPError as e:
|
||||
|
||||
@@ -112,11 +112,12 @@ def template_history(service_id):
|
||||
def usage(service_id):
|
||||
year, current_financial_year = requested_and_current_financial_year(request)
|
||||
|
||||
free_sms_allowance = billing_api_client.get_free_sms_fragment_limit_for_year(service_id, year)
|
||||
return render_template(
|
||||
'views/usage.html',
|
||||
months=list(get_free_paid_breakdown_for_billable_units(
|
||||
year,
|
||||
billing_api_client.get_free_sms_fragment_limit_for_year(service_id, year),
|
||||
free_sms_allowance,
|
||||
billing_api_client.get_billable_units(service_id, year)
|
||||
)),
|
||||
selected_year=year,
|
||||
@@ -126,7 +127,7 @@ def usage(service_id):
|
||||
end=current_financial_year + 1,
|
||||
),
|
||||
**calculate_usage(billing_api_client.get_service_usage(service_id, year),
|
||||
billing_api_client.get_free_sms_fragment_limit_for_year(service_id, year))
|
||||
free_sms_allowance)
|
||||
)
|
||||
|
||||
|
||||
@@ -291,8 +292,7 @@ def get_dashboard_totals(statistics):
|
||||
|
||||
|
||||
def calculate_usage(usage, free_sms_fragment_limit):
|
||||
# TODO: Don't hardcode these - get em from the API
|
||||
sms_free_allowance = free_sms_fragment_limit # VB-Progress
|
||||
sms_free_allowance = free_sms_fragment_limit
|
||||
|
||||
sms_rate = 0 if len(usage) == 0 else usage[0].get("rate", 0)
|
||||
sms_sent = get_sum_billing_units(breakdown for breakdown in usage if breakdown['notification_type'] == 'sms')
|
||||
|
||||
@@ -42,7 +42,6 @@ from app.main.forms import (
|
||||
)
|
||||
from app import user_api_client, current_service, organisations_client, inbound_number_client, billing_api_client
|
||||
from notifications_utils.formatters import formatted_list
|
||||
from app.utils import get_current_financial_year
|
||||
|
||||
|
||||
dummy_bearer_token = 'bearer_token_set'
|
||||
@@ -737,22 +736,16 @@ def set_organisation_type(service_id):
|
||||
def set_free_sms_allowance(service_id):
|
||||
|
||||
form = FreeSMSAllowance(free_sms_allowance=billing_api_client.get_free_sms_fragment_limit_for_year(service_id))
|
||||
|
||||
if form.validate_on_submit():
|
||||
service_api_client.update_service(
|
||||
service_id,
|
||||
# TODO: Retire this after new end points are added.
|
||||
free_sms_fragment_limit=form.free_sms_allowance.data,
|
||||
)
|
||||
# get a list of all the free sms allowance entries for this service
|
||||
sms_list = billing_api_client.get_free_sms_fragment_limit_for_all_years(service_id)
|
||||
|
||||
for item in range(0, len(sms_list)):
|
||||
if sms_list[item]['financial_year_start'] >= get_current_financial_year():
|
||||
form.set_free_sms_allowance = \
|
||||
billing_api_client.create_or_update_free_sms_fragment_limit_for_year(service_id,
|
||||
form.free_sms_allowance.data,
|
||||
sms_list[item][
|
||||
'financial_year_start'])
|
||||
billing_api_client.create_or_update_free_sms_fragment_limit(service_id, form.free_sms_allowance.data)
|
||||
|
||||
return redirect(url_for('.service_settings', service_id=service_id))
|
||||
|
||||
return render_template(
|
||||
|
||||
Reference in New Issue
Block a user