Wired in the free limit from the API

This commit is contained in:
Martyn Inglis
2017-06-07 14:26:00 +01:00
parent e236cc4cbe
commit d2ecd2121e
2 changed files with 5 additions and 4 deletions

View File

@@ -190,7 +190,7 @@ def get_dashboard_partials(service_id):
**calculate_free_tier_usage(service_api_client.get_yearly_sms_unit_count_and_cost(
service_id,
get_current_financial_year(),
))
), service)
),
}
@@ -202,9 +202,8 @@ def get_dashboard_totals(statistics):
return statistics
def calculate_free_tier_usage(usage):
sms_free_allowance = current_app.config['SMS_FREE_TIER_AMOUNT']
def calculate_free_tier_usage(usage, service):
sms_free_allowance = service['data']['free_sms_fragment_limit']
return({
'sms_chargeable': max(0, usage['billable_sms_units'] - sms_free_allowance),
'total_sms_bill': usage['billable_sms_units'],