mirror of
https://github.com/GSA/notifications-api.git
synced 2025-12-20 15:31:15 -05:00
Added command to populate data for annual billing based on last years values.
This commit is contained in:
@@ -34,6 +34,7 @@ from app.utils import get_london_midnight_in_utc
|
||||
def fetch_sms_free_allowance_remainder(start_date):
|
||||
# ASSUMPTION: AnnualBilling has been populated for year.
|
||||
billing_year = which_financial_year(start_date)
|
||||
print(billing_year)
|
||||
start_of_year = convert_utc_to_bst(financial_year_start(billing_year))
|
||||
query = db.session.query(
|
||||
FactBilling.service_id.label("service_id"),
|
||||
@@ -62,7 +63,7 @@ def fetch_sms_billing_for_all_services(start_date, end_date):
|
||||
billing_year = which_financial_year(start_date)
|
||||
free_allowance_remainder = fetch_sms_free_allowance_remainder(start_date).subquery()
|
||||
sms_billable_units = func.sum(FactBilling.billable_units * FactBilling.rate_multiplier)
|
||||
sms_remainder = func.coalesce(free_allowance_remainder.c.sms_remainder, 0)
|
||||
sms_remainder = func.coalesce(free_allowance_remainder.c.sms_remainder, AnnualBilling.free_sms_fragment_limit)
|
||||
chargeable_sms = case([(sms_remainder == 0, sms_billable_units),
|
||||
(sms_billable_units - sms_remainder <= 0, 0),
|
||||
(sms_billable_units - sms_remainder > 0,
|
||||
|
||||
Reference in New Issue
Block a user