Compare commits

...

2 Commits

Author SHA1 Message Date
chris d13ef5dfd8 report new average data 2020-11-05 13:21:53 +01:00
chris 715b0a2fbf add more averages 2020-11-05 13:20:00 +01:00
2 changed files with 6 additions and 2 deletions

View File

@ -78,13 +78,15 @@ def _collect_budget_data():
budgets.append({
"id": budget.get('id'),
"name": budget.get('attributes').get('name'),
"limit": _get_current_limit(budget.get('id')).get('attributes').get('amount'),
"limit": float(_get_current_limit(budget.get('id')).get('attributes').get('amount')),
"spent": _get_current_spent_amount(budget.get('id')),
})
currbudget = budgets[-1]
currbudget['remaining'] = (float(currbudget.get('limit')) - float(currbudget.get('spent')))
remaining_per_day = currbudget.get('remaining') / firefly.get_remaining_days()
currbudget['remaining_per_day'] = 0 if remaining_per_day < 0 else remaining_per_day
currbudget['spent_per_day'] = currbudget['spent'] / datetime.datetime.today().day
currbudget['average_per_day'] = currbudget['limit'] / (datetime.datetime.today().day + firefly.get_remaining_days() - 1)
return budgets

View File

@ -33,8 +33,10 @@ class BudgetBot(object):
reply = "Invalid budget name"
else:
reply = "Budget *{}*\n".format(budget[0]['name'])
reply += " Limit: {}\n".format(budget[0].get('limit'))
reply += " Available current month: {:.2f}".format(budget.get('limit'))
reply += " Average per day: {:.2f}".format(budget.get('average_per_day'))
reply += " Spent: {:.2f}\n".format(budget[0].get('spent'))
reply += " Spent per day: {:.2f}".format(budget.get('spent_per_day'))
reply += " Remaining: {:.2f}\n".format(budget[0].get('remaining'))
reply += " Remaining per day: {:.2f}".format(budget[0].get('remaining_per_day'))
else: