mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-07-11 04:33:52 -04:00
Merge pull request #2182 from alphagov/remove_monthly_billing
Remove view displaying data form monthly_billing table
This commit is contained in:
@@ -141,37 +141,6 @@ def template_usage(service_id):
|
||||
)
|
||||
|
||||
|
||||
@main.route("/services/<service_id>/monthly-billing-usage")
|
||||
@login_required
|
||||
@user_has_permissions('manage_service')
|
||||
def monthly_billing_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)
|
||||
units = billing_api_client.get_billable_units(service_id, year)
|
||||
yearly_usage = billing_api_client.get_service_usage(service_id, year)
|
||||
|
||||
usage_template = 'views/usage.html'
|
||||
if 'letter' in current_service['permissions']:
|
||||
usage_template = 'views/usage-with-letters.html'
|
||||
return render_template(
|
||||
usage_template,
|
||||
months=list(get_free_paid_breakdown_for_billable_units(
|
||||
year,
|
||||
free_sms_allowance,
|
||||
units
|
||||
)),
|
||||
selected_year=year,
|
||||
years=get_tuples_of_financial_years(
|
||||
partial(url_for, '.monthly_billing_usage', service_id=service_id),
|
||||
start=current_financial_year - 1,
|
||||
end=current_financial_year + 1,
|
||||
),
|
||||
**calculate_usage(yearly_usage,
|
||||
free_sms_allowance)
|
||||
)
|
||||
|
||||
|
||||
@main.route("/services/<service_id>/usage")
|
||||
@login_required
|
||||
@user_has_permissions('manage_service')
|
||||
|
||||
@@ -7,26 +7,12 @@ class BillingAPIClient(NotifyAdminAPIClient):
|
||||
def __init__(self):
|
||||
super().__init__("a" * 73, "b")
|
||||
|
||||
def get_billable_units(self, service_id, year):
|
||||
return self.get(
|
||||
'/service/{0}/billing/monthly-usage'.format(service_id),
|
||||
params=dict(year=year)
|
||||
)
|
||||
|
||||
def get_service_usage(self, service_id, year=None):
|
||||
return self.get(
|
||||
'/service/{0}/billing/yearly-usage-summary'.format(service_id),
|
||||
params=dict(year=year)
|
||||
)
|
||||
|
||||
# Temporary methods to compare the usage before and after using ft_billing
|
||||
def get_billable_units_ft(self, service_id, year):
|
||||
return self.get(
|
||||
'/service/{0}/billing/ft-monthly-usage'.format(service_id),
|
||||
params=dict(year=year)
|
||||
)
|
||||
|
||||
# Temporary methods to compare the usage before and after using ft_billing
|
||||
def get_service_usage_ft(self, service_id, year=None):
|
||||
return self.get(
|
||||
'/service/{0}/billing/ft-yearly-usage-summary'.format(service_id),
|
||||
|
||||
@@ -3,30 +3,6 @@ import uuid
|
||||
from app.notify_client.billing_api_client import BillingAPIClient
|
||||
|
||||
|
||||
def test_get_billing_units_calls_correct_endpoint(mocker, api_user_active):
|
||||
service_id = uuid.uuid4()
|
||||
expected_url = '/service/{}/billing/monthly-usage'.format(service_id)
|
||||
|
||||
client = BillingAPIClient()
|
||||
|
||||
mock_get = mocker.patch('app.notify_client.billing_api_client.BillingAPIClient.get')
|
||||
|
||||
client.get_billable_units(service_id, 2017)
|
||||
mock_get.assert_called_once_with(expected_url, params={'year': 2017})
|
||||
|
||||
|
||||
def test_get_get_service_usage_calls_correct_endpoint(mocker, api_user_active):
|
||||
service_id = uuid.uuid4()
|
||||
expected_url = '/service/{}/billing/yearly-usage-summary'.format(service_id)
|
||||
|
||||
client = BillingAPIClient()
|
||||
|
||||
mock_get = mocker.patch('app.notify_client.billing_api_client.BillingAPIClient.get')
|
||||
|
||||
client.get_service_usage(service_id, 2017)
|
||||
mock_get.assert_called_once_with(expected_url, params={'year': 2017})
|
||||
|
||||
|
||||
def test_get_free_sms_fragment_limit_for_year_correct_endpoint(mocker, api_user_active):
|
||||
service_id = uuid.uuid4()
|
||||
expected_url = '/service/{}/billing/free-sms-fragment-limit'.format(service_id)
|
||||
|
||||
Reference in New Issue
Block a user