Monthly billing has been updated to populate for letters.

This commit is contained in:
Rebecca Law
2017-12-12 15:54:59 +00:00
parent d9db4691a1
commit 4ea79d9eb1
6 changed files with 73 additions and 20 deletions

View File

@@ -9,8 +9,8 @@ from app.models import (
SMS_TYPE,
EMAIL_TYPE,
MonthlyBilling,
NotificationHistory
)
NotificationHistory,
LETTER_TYPE)
from app.statsd_decorators import statsd
from app.utils import convert_utc_to_bst
@@ -31,6 +31,7 @@ def create_or_update_monthly_billing(service_id, billing_month):
start_date, end_date = get_month_start_and_end_date_in_utc(billing_month)
_update_monthly_billing(service_id, start_date, end_date, SMS_TYPE)
_update_monthly_billing(service_id, start_date, end_date, EMAIL_TYPE)
_update_monthly_billing(service_id, start_date, end_date, LETTER_TYPE)
def _monthly_billing_data_to_json(billing_data):

View File

@@ -50,6 +50,11 @@ def get_billing_data_for_month(service_id, start_date, end_date, notification_ty
)
)
if notification_type == LETTER_TYPE:
results.extend(billing_letter_data_per_month_query(
service_id=service_id, start_date=start_date, end_date=end_date)
)
return results
@@ -165,10 +170,11 @@ def billing_letter_data_per_month_query(service_id, start_date, end_date):
NotificationHistory.notification_type,
month,
NotificationHistory.rate_multiplier,
NotificationHistory.international
NotificationHistory.international,
LetterRate.rate
).order_by(
month,
rate_multiplier()
).all()
return results
return results