Fix the query to count rather than sum the billing units.
Need to fix the query that returns the monhtly billing, there is only one row but there should be two if there are two rates.
This commit is contained in:
Rebecca Law
2017-12-15 17:29:32 +00:00
parent c08f67ea63
commit e0e64d51d5
4 changed files with 25 additions and 18 deletions

View File

@@ -134,9 +134,8 @@ def billing_data_per_month_query(rate, service_id, start_date, end_date, notific
).order_by(
month,
rate_multiplier()
).all()
return results
)
return results.all()
def rate_multiplier():
@@ -152,7 +151,7 @@ def billing_letter_data_per_month_query(service_id, start_date, end_date):
crown = Service.query.get(service_id).crown
results = db.session.query(
month.label('month'),
func.sum(NotificationHistory.billable_units).label('billing_units'),
func.count(NotificationHistory.billable_units).label('billing_units'),
rate_multiplier().label('rate_multiplier'),
NotificationHistory.international,
NotificationHistory.notification_type,
@@ -172,6 +171,5 @@ def billing_letter_data_per_month_query(service_id, start_date, end_date):
).order_by(
month,
rate_multiplier()
).all()
return results
)
return results.all()