Finalized the this month script, which will be sent weekly via text to me and necessary parties. The last month and new_month_check transactions are also cleaned up and working. The next tasks are to sunset the import of moneyed as reading the actual-py docs, I found that I can do transactions.get_amount() which will return a decimal formatted number instead of needing to change the strings, etc. Will also need to clean up the files so they are more organized for public release.
This commit is contained in:
@ -29,7 +29,7 @@ def simple_track(actual):
|
||||
if cat.name == "Income":
|
||||
formatted_amount = str(b.amount)[:-2] + "." + str(b.amount)[-2:]
|
||||
expected_income = Money(formatted_amount, USD)
|
||||
main_dict[cat.name] = {"Expected Income": expected_income, "Actual Income": Money(0, USD), "Total Spent": Money(0, USD), "Amount Left Against Budget": Money(0, USD)}
|
||||
main_dict[cat.name] = {"Expected Income": expected_income, "Actual Income": Money(0, USD), "Total Spent": Money(0, USD), "Left Against Budget": Money(0, USD), "Left Against Actual": Money(0, USD)}
|
||||
category_transcations(sesh=actual.session, main_list=main_dict, origin="simple")
|
||||
|
||||
def main(actual):
|
||||
@ -72,10 +72,14 @@ def category_transcations(sesh, main_list, origin):
|
||||
amount_left = curr_sum + main_list['Income']['Expected Income']
|
||||
main_list['Income']['Expected Income'] = main_list['Income']['Expected Income']
|
||||
main_list['Income']['Actual Income'] = income_sum
|
||||
main_list['Income']['Amount Left Against Budget'] = amount_left
|
||||
main_list['Income']['Left Against Budget'] = amount_left
|
||||
main_list['Income']['Total Spent'] = curr_sum
|
||||
xx = curr_sum.amount
|
||||
if xx.is_zero():
|
||||
main_list['Income']['Left Against Actual'] = income_sum+curr_sum
|
||||
else:
|
||||
main_list['Income']['Left Against Actual'] = income_sum+curr_sum
|
||||
|
||||
# print(f"curr_sum: {curr_sum} PLUS total_sum: {total_sum}")
|
||||
else:
|
||||
for keys, vals in main_list.items():
|
||||
this_month_trans = get_transactions(sesh, category=keys, start_date=MONTHDAYDATE)
|
||||
@ -84,20 +88,11 @@ def category_transcations(sesh, main_list, origin):
|
||||
tamount = str(ta.amount)[:-2] + "." + str(ta.amount)[-2:]
|
||||
total_sum = Money(tamount, USD)
|
||||
curr_sum += total_sum
|
||||
# print(f"curr_sum: {curr_sum} PLUS total_sum: {total_sum}")
|
||||
amount_list = curr_sum + vals["budgeted_amount"]
|
||||
vals["budgeted_amount"] = vals['budgeted_amount']
|
||||
vals["amount_spent"] = curr_sum
|
||||
vals["amount_left"] = amount_list
|
||||
|
||||
# sorted_items = sorted(main_list.items(), key=lambda item: item[1]['amount_left'])
|
||||
# sorted_nested_dict = dict(sorted_items)
|
||||
# pp.pprint(sorted_nested_dict)
|
||||
# pp.pprint(sorted_key_val)
|
||||
# sorted_data = sorted(main_list, key=lambda x: main_list[x]['amount_left'])
|
||||
# pp.pprint(sorted_data)
|
||||
# sort_budgets_for_notification(sorted_data)
|
||||
|
||||
if origin == "simple":
|
||||
x = format_dicts(main_list)
|
||||
simple_notifications(x)
|
||||
@ -150,13 +145,6 @@ def format_dicts(budgets_sorted):
|
||||
return o
|
||||
|
||||
|
||||
# categies = str([x['category'] for x in negative_budget ])[1:-1].replace('"','').replace("'",'')
|
||||
# categies2 = str([x['category'] for x in some_budget_left ])[1:-1].replace('"','').replace("'",'')
|
||||
# categies3 = str([x['category'] for x in no_budget_left ])[1:-1].replace('"','').replace("'",'')
|
||||
# print(f"""Here's your spending status so far for this month. First, here are the categories where you've overspent:\n- {str(categies)}.\n\nHere is where you still have some budget left:\n- {str(categies2)}.\n\nAnd finally, here is where you're exactly where you need to be. $0 left.\n- {str(categies3)}""")
|
||||
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
with Actual(
|
||||
base_url=os.getenv('BASEURL'),
|
||||
|
||||
Reference in New Issue
Block a user