Only include ft_billing data for current financial year

Test get_live_services_data endpoint

Expand dao_fetch_live_services_data test with more ft_billing records
This commit is contained in:
Pea Tyczynska
2019-04-29 15:49:12 +01:00
parent 669db0b4ca
commit c15d7878fc
4 changed files with 61 additions and 14 deletions

View File

@@ -7,8 +7,8 @@ import pytz
def get_months_for_financial_year(year):
return [
convert_bst_to_utc(month) for month in (
get_months_for_year(4, 13, year) +
get_months_for_year(1, 4, year + 1)
get_months_for_year(4, 13, year)
+ get_months_for_year(1, 4, year + 1)
)
if convert_bst_to_utc(month) < datetime.now()
]
@@ -22,6 +22,14 @@ def get_financial_year(year):
return get_april_fools(year), get_april_fools(year + 1) - timedelta(microseconds=1)
def get_current_financial_year():
now = datetime.utcnow()
current_month = int(now.strftime('%-m'))
current_year = int(now.strftime('%Y'))
year = current_year if current_month > 3 else current_year - 1
return get_financial_year(year)
def get_april_fools(year):
"""
This function converts the start of the financial year April 1, 00:00 as BST (British Standard Time) to UTC,