mirror of
https://github.com/GSA/notifications-api.git
synced 2026-02-03 09:51:11 -05:00
Remove references to monthly_billing table from api
This commit is contained in:
@@ -1,4 +1,3 @@
|
||||
import json
|
||||
from datetime import datetime
|
||||
|
||||
from flask import Blueprint, jsonify, request
|
||||
@@ -15,12 +14,8 @@ from app.dao.annual_billing_dao import (
|
||||
dao_update_annual_billing_for_future_years
|
||||
)
|
||||
from app.dao.date_util import get_current_financial_year_start_year
|
||||
from app.dao.date_util import get_months_for_financial_year
|
||||
from app.dao.fact_billing_dao import fetch_monthly_billing_for_year, fetch_billing_totals_for_year
|
||||
from app.dao.monthly_billing_dao import (
|
||||
get_billing_data_for_financial_year,
|
||||
get_monthly_billing_by_notification_type
|
||||
)
|
||||
|
||||
from app.errors import InvalidRequest
|
||||
from app.errors import register_errors
|
||||
from app.models import SMS_TYPE, EMAIL_TYPE, LETTER_TYPE
|
||||
@@ -60,41 +55,6 @@ def get_yearly_billing_usage_summary_from_ft_billing(service_id):
|
||||
return jsonify(data)
|
||||
|
||||
|
||||
@billing_blueprint.route('/monthly-usage')
|
||||
def get_yearly_usage_by_month(service_id):
|
||||
try:
|
||||
year = int(request.args.get('year'))
|
||||
results = []
|
||||
for month in get_months_for_financial_year(year):
|
||||
letter_billing_for_month = get_monthly_billing_by_notification_type(service_id, month, LETTER_TYPE)
|
||||
if letter_billing_for_month:
|
||||
results.extend(_transform_billing_for_month_letters(letter_billing_for_month))
|
||||
billing_for_month = get_monthly_billing_by_notification_type(service_id, month, SMS_TYPE)
|
||||
if billing_for_month:
|
||||
results.append(_transform_billing_for_month_sms(billing_for_month))
|
||||
return jsonify(results)
|
||||
|
||||
except TypeError:
|
||||
return jsonify(result='error', message='No valid year provided'), 400
|
||||
|
||||
|
||||
@billing_blueprint.route('/yearly-usage-summary')
|
||||
def get_yearly_billing_usage_summary(service_id):
|
||||
try:
|
||||
year = int(request.args.get('year'))
|
||||
billing_data = get_billing_data_for_financial_year(service_id, year)
|
||||
notification_types = [EMAIL_TYPE, LETTER_TYPE, SMS_TYPE]
|
||||
response = [
|
||||
_get_total_billable_units_and_rate_for_notification_type(billing_data, notification_type)
|
||||
for notification_type in notification_types
|
||||
]
|
||||
|
||||
return json.dumps(response)
|
||||
|
||||
except TypeError:
|
||||
return jsonify(result='error', message='No valid year provided'), 400
|
||||
|
||||
|
||||
def _get_total_billable_units_and_rate_for_notification_type(billing_data, noti_type):
|
||||
total_sent = 0
|
||||
rate = 0
|
||||
|
||||
Reference in New Issue
Block a user