mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-08-15 15:28:50 -04:00
Revert "Merge pull request #1288 from alphagov/add-new-rate-logic"
This reverts commitadbff63d1f, reversing changes made to80f0b4b2a2.
This commit is contained in:
@@ -59,8 +59,6 @@ class Config(object):
|
||||
ACTIVITY_STATS_LIMIT_DAYS = 7
|
||||
TEST_MESSAGE_FILENAME = 'Report'
|
||||
|
||||
SMS_FREE_TIER_AMOUNT = 250000
|
||||
|
||||
STATSD_ENABLED = False
|
||||
STATSD_HOST = "statsd.hostedgraphite.com"
|
||||
STATSD_PORT = 8125
|
||||
|
||||
@@ -2,7 +2,6 @@ from datetime import datetime
|
||||
from functools import partial
|
||||
from flask import (
|
||||
render_template,
|
||||
current_app,
|
||||
url_for,
|
||||
session,
|
||||
jsonify,
|
||||
@@ -187,7 +186,7 @@ def get_dashboard_partials(service_id):
|
||||
'has_jobs': bool(immediate_jobs),
|
||||
'usage': render_template(
|
||||
'views/dashboard/_usage.html',
|
||||
**calculate_free_tier_usage(service_api_client.get_yearly_sms_unit_count_and_cost(
|
||||
**calculate_usage(service_api_client.get_service_usage(
|
||||
service_id,
|
||||
get_current_financial_year(),
|
||||
))
|
||||
@@ -202,19 +201,9 @@ def get_dashboard_totals(statistics):
|
||||
return statistics
|
||||
|
||||
|
||||
def calculate_free_tier_usage(usage):
|
||||
sms_free_allowance = current_app.config['SMS_FREE_TIER_AMOUNT']
|
||||
|
||||
return({
|
||||
'sms_chargeable': max(0, usage['billable_sms_units'] - sms_free_allowance),
|
||||
'total_sms_bill': usage['billable_sms_units'],
|
||||
'total_sms_cost': usage['total_cost'],
|
||||
'sms_allowance_remaining': sms_free_allowance - int(usage['billable_sms_units'])
|
||||
})
|
||||
|
||||
|
||||
def calculate_usage(usage):
|
||||
sms_free_allowance = current_app.config['SMS_FREE_TIER_AMOUNT']
|
||||
# TODO: Don't hardcode these - get em from the API
|
||||
sms_free_allowance = 250000
|
||||
|
||||
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')
|
||||
|
||||
@@ -221,12 +221,6 @@ class ServiceAPIClient(NotifyAdminAPIClient):
|
||||
params=dict(year=year)
|
||||
)
|
||||
|
||||
def get_yearly_sms_unit_count_and_cost(self, service_id, year=None):
|
||||
return self.get(
|
||||
'/service/{0}/yearly-sms-billable-units'.format(service_id),
|
||||
params=dict(year=year)
|
||||
)
|
||||
|
||||
def get_monthly_notification_stats(self, service_id, year):
|
||||
return self.get(url='/service/{}/notifications/monthly?year={}'.format(service_id, year))
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
<div class="keyline-block">
|
||||
{% if sms_chargeable %}
|
||||
{{ big_number(
|
||||
total_sms_cost,
|
||||
(sms_chargeable * sms_rate),
|
||||
'spent on text messages',
|
||||
currency="£",
|
||||
smaller=True
|
||||
|
||||
Reference in New Issue
Block a user