rename which_financial_year to get_financial_year_for_datetime

also fix bug on the very second of rollover, march 31st 23:00:00, and
add tests
This commit is contained in:
Leo Hemsted
2019-08-28 14:27:08 +01:00
parent 2abcda47a3
commit b7e8f1baa2
3 changed files with 24 additions and 8 deletions

View File

@@ -63,8 +63,9 @@ def get_current_financial_year_start_year():
return financial_year_start
def which_financial_year(start_date):
if start_date <= get_april_fools(int(start_date.strftime('%Y'))):
return int(start_date.strftime('%Y')) - 1
def get_financial_year_for_datetime(start_date):
year = int(start_date.strftime('%Y'))
if start_date < get_april_fools(year):
return year - 1
else:
return int(start_date.strftime('%Y'))
return year