This commit is contained in:
chris 2021-09-20 17:44:29 +02:00
parent eee96d14b3
commit e800282667
2 changed files with 6 additions and 3 deletions

View file

@ -3,6 +3,7 @@ import os
import calendar
import datetime
import pytz
import requests
import dateutil.parser
@ -14,9 +15,10 @@ host = os.environ.get('FIREFLY_API_HOST')
def _get_budgets():
budgets_json = requests.get(
budgets_req = requests.get(
host + "/api/v1/budgets", headers=header
).json()
)
budgets_json = budgets_req.json()
budgets = budgets_json.get('data')
while "next" in budgets_json.get('links'):
budgets_json = requests.get(
@ -37,7 +39,7 @@ def _get_current_limit(budget_id):
).json()
budgets.extend(budget_json.get('data'))
today = datetime.datetime.combine(datetime.date.today(), datetime.datetime.min.time())
today = datetime.datetime.combine(datetime.date.today(), datetime.datetime.min.time()).replace(tzinfo=pytz.UTC)
return [
budget for budget in budgets
if today >= dateutil.parser.parse(budget.get('attributes').get('start')) and today <= dateutil.parser.parse(budget.get('attributes').get('end'))

View file

@ -1,3 +1,4 @@
Flask==1.1.2
python-dateutil==2.8.1
requests==2.24.0
pytz==2021.1