change to col-auto everywhere, with some more forcing of width maximums to make the page more consistent, redid defaults to incorporate updated per fortnight lease cost, and updated inflation figure/notes/references. Updated default Living expenses to 84000 to match latest view of data, fixed up compare_to to now work, shows a graph of data to compare with, allows drop-down to be compare_to nothing or a saved set, only 1 hand saved for now. Annotations on graph for large changes in savings now work and are legible - had to allow overlap and do some overly complex left/right up/down offsetting to make them all sensible

This commit is contained in:
2025-02-13 17:12:02 +11:00
parent 3cf1f1d4de
commit 14de3f1790
5 changed files with 148 additions and 128 deletions

26
calc.py
View File

@@ -1,9 +1,16 @@
# calc.py
from datetime import datetime, timedelta
def add_annotation(finance, dt, amt, text):
def add_annotation(finance, dt, total, delta, text):
# dont add an annotation for small changes (jic)
if abs(delta) < 5000:
return
tm = dt.timestamp() * 1000
finance['annotations'].append( { 'label': text, 'x': tm, 'y': amt } )
if delta > 0:
text += f": ${int(abs(delta))}"
else:
text += f": -${int(abs(delta))}"
finance['annotations'].append( { 'label': text, 'x': tm, 'y': total } )
return
def calculate_savings_depletion(finance):
@@ -98,6 +105,7 @@ def calculate_savings_depletion(finance):
if D_Num_fortnights_pay == 0 and D_leave_after_tax > 0:
print(f"D has resigned {current_date}: get paid out my 9 weeks leave and lose 45% to tax - ${D_leave_after_tax}" )
current_savings += D_leave_after_tax
add_annotation(finance, current_date, current_savings, D_leave_after_tax, "D quit" )
D_leave_after_tax = 0
if fortnight_income:
@@ -125,28 +133,28 @@ def calculate_savings_depletion(finance):
if current_date.date() == school_fees_date.date():
current_savings -= School_Fees
add_annotation(finance, current_date, current_savings, f"Pay School Fees: ${School_Fees}")
add_annotation(finance, current_date, current_savings, -School_Fees, "School Fees")
if current_date.date() == car_balloon_date.date():
current_savings -= Car_balloon
add_annotation(finance, current_date, current_savings, f"car balloon paid: ${Car_balloon}" )
add_annotation(finance, current_date, current_savings, -Car_balloon, "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:
current_savings -= post_lease_car_costs
add_annotation(finance, current_date, current_savings, f"IONIQ 6 ins/rego: ${post_lease_car_costs}" )
add_annotation(finance, current_date, current_savings, -post_lease_car_costs, "IONIQ 6 ins/rego" )
if current_date.date() == overseas_trip_date.date():
current_savings -= Overseas_trip
add_annotation(finance, current_date, current_savings, f"Overseas trip: ${Overseas_trip}")
add_annotation(finance, current_date, current_savings, -Overseas_trip, "O/S trip")
if current_date.date() == mich_present_date.date():
current_savings -= Mich_present
add_annotation(finance, current_date, current_savings, f"Michelle's present: ${Mich_present}")
add_annotation(finance, current_date, current_savings, -Mich_present, "Mich's present" )
if current_date.date() == mark_reno_date.date():
current_savings -= Mark_reno
add_annotation(finance, current_date, current_savings, f"Mark/reno costs: ${Mark_reno}")
add_annotation(finance, current_date, current_savings, -Mark_reno, "Mark/reno" )
if current_savings < 0:
depletion_date = current_date
@@ -177,7 +185,7 @@ def calculate_savings_depletion(finance):
Sell_shares -= 1
current_savings += actual_sell
add_annotation(finance, current_date, current_savings, f"Selling shares: ${int(actual_sell)}" )
add_annotation(finance, current_date, current_savings, actual_sell, "Sell shares" )
current_date += timedelta(days=1)