Update the valid_from date for the rate that is intended to start at the begining of the financial year.

It was the start of the financial year in BST, needed to convert it to UTC.
Small change to the logic to find the rates.
This commit is contained in:
Rebecca Law
2017-05-03 17:11:48 +01:00
parent 64ef843777
commit 93e76d2362
3 changed files with 42 additions and 7 deletions

View File

@@ -1,4 +1,4 @@
from datetime import datetime
from datetime import datetime, timedelta
from sqlalchemy import Float, Integer
from sqlalchemy import func, case, cast
@@ -27,7 +27,6 @@ def get_yearly_billing_data(service_id, year):
result = []
for r, n in zip(rates, rates[1:]):
result.append(sms_yearly_billing_data_query(r.rate, service_id, get_valid_from(r.valid_from), n.valid_from))
result.append(
sms_yearly_billing_data_query(rates[-1].rate, service_id, get_valid_from(rates[-1].valid_from), end_date))
result.append(email_yearly_billing_data_query(service_id, start_date, end_date))
@@ -108,7 +107,7 @@ def get_rates_for_year(start_date, end_date, notification_type):
results = []
for current_rate, current_rate_expiry_date in zip(rates, rates[1:]):
if is_between(current_rate.valid_from, start_date, end_date) or \
is_between(current_rate_expiry_date.valid_from, start_date, end_date):
is_between(current_rate_expiry_date.valid_from - timedelta(microseconds=1), start_date, end_date):
results.append(current_rate)
if is_between(rates[-1].valid_from, start_date, end_date):