32 lines
1.1 KiB
Python
32 lines
1.1 KiB
Python
|
import calendar
|
||
|
import datetime
|
||
|
|
||
|
import firefly.budgets
|
||
|
|
||
|
|
||
|
def _get_remaining_days():
|
||
|
today = datetime.date.today()
|
||
|
endofmonth = today.replace(day=calendar.monthrange(today.year, today.month)[1])
|
||
|
return (endofmonth - today).days
|
||
|
|
||
|
def main():
|
||
|
budgets = []
|
||
|
for budget in firefly.budgets._get_budgets():
|
||
|
budgets.append({
|
||
|
"id": budget.get('id'),
|
||
|
"name": budget.get('attributes').get('name'),
|
||
|
"limit": firefly.budgets._get_current_limit(budget.get('id')).get('attributes').get('amount'),
|
||
|
"spent": str(firefly.budgets._get_current_spent_amount(budget.get('id'))),
|
||
|
})
|
||
|
for budget in budgets:
|
||
|
remaining_per_day = (float(budget.get('limit')) - float(budget.get('spent'))) / _get_remaining_days()
|
||
|
remaining_per_day = 0 if remaining_per_day < 0 else remaining_per_day
|
||
|
print("Budget: " + budget.get('name'))
|
||
|
print(" Limit: " + budget.get('limit'))
|
||
|
print(" Spent: " + budget.get('spent'))
|
||
|
print(" Remaining per day: " + str(remaining_per_day))
|
||
|
|
||
|
|
||
|
if __name__ == "__main__":
|
||
|
main()
|