mirror of
https://github.com/GSA/notifications-api.git
synced 2025-12-20 07:21:13 -05:00
Add new total_letters field to the billing report data
This adds total_letters to the data that is returned by the `/platform-stats/data-for-billing-report` endpoint so that we can add total letters as a column in the CSV file that can be downloaded.
This commit is contained in:
@@ -114,12 +114,13 @@ def fetch_sms_billing_for_all_services(start_date, end_date):
|
||||
return query.all()
|
||||
|
||||
|
||||
def fetch_letter_costs_for_all_services(start_date, end_date):
|
||||
def fetch_letter_costs_and_totals_for_all_services(start_date, end_date):
|
||||
query = db.session.query(
|
||||
Organisation.name.label("organisation_name"),
|
||||
Organisation.id.label("organisation_id"),
|
||||
Service.name.label("service_name"),
|
||||
Service.id.label("service_id"),
|
||||
func.sum(FactBilling.notifications_sent).label("total_letters"),
|
||||
func.sum(FactBilling.notifications_sent * FactBilling.rate).label("letter_cost")
|
||||
).select_from(
|
||||
Service
|
||||
|
||||
Reference in New Issue
Block a user