Merge pull request #1190 from alphagov/imdad-feat-get-monthly-usage-from-billing-table

Get monthly usage breakdown from the correct table
This commit is contained in:
Imdad Ahad
2017-08-18 14:21:12 +01:00
committed by GitHub
4 changed files with 127 additions and 51 deletions

View File

@@ -5,6 +5,20 @@ import pytz
from app.utils import convert_bst_to_utc
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)
)
if month < datetime.now()
]
def get_months_for_year(start, end, year):
return [datetime(year, month, 1) for month in range(start, end)]
def get_financial_year(year):
return get_april_fools(year), get_april_fools(year + 1) - timedelta(microseconds=1)