add annotations properly now

This commit is contained in:
2025-02-12 18:06:49 +11:00
parent 65ed02812a
commit ce38b3d1f0
2 changed files with 31 additions and 29 deletions

26
calc.py
View File

@@ -1,11 +1,11 @@
# calc.py
from datetime import datetime, timedelta
# this somehow needs to connect the annotation, so maybe store it via date in an annotations array?
# not sure I need amount, etc.
def add_annotation(label,amount):
def add_annotation(finance, dt, amt, text):
tm = dt.timestamp() * 1000
finance['annotations'].append( { 'label': text, 'x': tm, 'y': amt } )
return
def calculate_savings_depletion(finance):
# Extract all the financial data from the database
D_Salary = finance['D_Salary']
@@ -74,6 +74,10 @@ def calculate_savings_depletion(finance):
fortnight_income = 0
monthly_interest = 0
# Create an empty dict to store annotations to display in the GUI
# (key is date, text is for larger spend items by hand)
finance['annotations']=[]
while current_date <= end_date:
#paid on 8th or 22nd of Jan (so 8th day of fortnight)
is_fortnight = (days_count % 14 == 7)
@@ -121,28 +125,28 @@ def calculate_savings_depletion(finance):
if current_date.date() == school_fees_date.date():
current_savings -= School_Fees
print(f"school fees={current_date} - {School_Fees}")
add_annotation(finance, current_date, current_savings, f"Pay School Fees: ${School_Fees}")
if current_date.date() == car_balloon_date.date():
current_savings -= Car_balloon
print(f"car balloon paid={current_date} - {Car_balloon}")
add_annotation(finance, current_date, current_savings, f"car balloon paid: ${Car_balloon}" )
# Anniversary of Car balloon so pay insurance/rego
if current_date.year >= car_balloon_date.year and current_date.month == car_balloon_date.month and current_date.day == car_balloon_date.day:
print(f"time to pay IONIQ 6 insurance/rego of: {post_lease_car_costs}" )
current_savings -= post_lease_car_costs
add_annotation(finance, current_date, current_savings, f"IONIQ 6 ins/rego: ${post_lease_car_costs}" )
if current_date.date() == overseas_trip_date.date():
current_savings -= Overseas_trip
print(f"overseas_trip={current_date} - {Overseas_trip}")
add_annotation(finance, current_date, current_savings, f"Overseas trip: ${Overseas_trip}")
if current_date.date() == mich_present_date.date():
current_savings -= Mich_present
print(f"Mich_present={current_date} - {Mich_present}")
add_annotation(finance, current_date, current_savings, f"Michelle's present: ${Mich_present}")
if current_date.date() == mark_reno_date.date():
current_savings -= Mark_reno
print(f"Mark/reno costs={current_date} - {Mark_reno}")
add_annotation(finance, current_date, current_savings, f"Mark/reno costs: ${Mark_reno}")
if current_savings < 0:
depletion_date = current_date
@@ -172,8 +176,8 @@ def calculate_savings_depletion(finance):
D_CBA_shares -= 1
Sell_shares -= 1
print( f"SELLING SHARES {current_date}: D_TLS={D_TLS_shares}, D_CBA={D_CBA_shares}" )
current_savings += actual_sell
add_annotation(finance, current_date, current_savings, f"Selling shares: ${int(actual_sell)}" )
current_date += timedelta(days=1)