move future bills into bills.py, away from calc.py for file content consistency

This commit is contained in:
2025-09-15 22:17:17 +10:00
parent 8274da0ce0
commit 1c112e6f6b
2 changed files with 97 additions and 67 deletions

62
calc.py
View File

@@ -117,35 +117,15 @@ def calculate_savings_depletion(finance, bill_data, bill_type):
# main loop range -- start from now, and simulate till D is 60 (April 2031)
current_date = datetime.today()
# work out which bill_types relate to future bills
for bt in bill_type:
if 'Hyundai' in bt['name']:
if 'Car Ins' in bt['name']:
ioniq6_ins_bt = bt
if 'Car Rego' in bt['name']:
ioniq6_rego_bt = bt
if 'Health Ins' in bt['name']:
health_ins_bt = bt
if 'Phone' in bt['name'] and 'Damien' in bt['name']:
phone_d_bt = bt
# TODO: need to refactor Living_Expenses to exclude bills
total=0
yr=str(current_date.year)
for b in bill_data:
if b['bill_type'] == ioniq6_rego_bt['id']:
ioniq6_rego = b['amount']
if b['bill_type'] == ioniq6_ins_bt['id']:
ioniq6_ins = b['amount']
if b['bill_type'] == health_ins_bt['id']:
health_ins = b['amount']
if b['bill_type'] == phone_d_bt['id']:
phone_d = b['amount']
if yr in b['bill_date']:
total += b['amount']
print( f"this yr={current_date.year} - total={total} -- hi={health_ins}, phone_d={phone_d}" )
print( f"this yr={current_date.year} - total={total}" )
Living_Expenses -= total
print( f"LE is now={Living_Expenses}" )
@@ -187,19 +167,6 @@ def calculate_savings_depletion(finance, bill_data, bill_type):
# if we have a bill for today, pay for it
current_savings -= bill_amount_today( finance, current_date, bill_data, bt_id_name, current_savings )
# KLUDGE for future bills for now:
# if I have quit, pay monthly future bills - assume 1st day of month for health ins
if D_has_quit and current_date.day == 1:
health_ins = health_ins * 1+((health_ins_bt['ann_growth_simple'])/100)*12
current_savings -= health_ins
# once a year from when I quit, pay the phone bill (year I quit comes below)
if D_has_quit and current_date.month == D_quit_date.month and current_date.day == D_quit_date.day:
amt=phone_d
for y in range( D_quit_date.year, current_date.year):
amt = amt * (1+phone_d_bt['ann_growth_simple']/100)
current_savings -= amt
# Calculate daily interest but apply at the end of the month
monthly_interest += current_savings * daily_interest_rate
@@ -230,8 +197,6 @@ def calculate_savings_depletion(finance, bill_data, bill_type):
current_savings += D_leave_after_tax
add_annotation(finance, current_date, current_savings, D_leave_after_tax, "D quit" )
D_leave_after_tax = 0
# pay for 1st year of phone for Damien
current_savings -= phone_d
# its end of 'next' fin year, if tax_diff > 0, then ddp quit after new tax year and gets back the overpaid tax
if current_date > new_fin_year_26 and claim_tax_on_leave:
@@ -281,30 +246,6 @@ def calculate_savings_depletion(finance, bill_data, bill_type):
add_annotation(finance, current_date, current_savings, -Car_buyout, "car buyout")
print(f"{current_date}: car buyout - ${Car_buyout}" )
# Anniversary of Car purchase/balloon so potentially insurance/rego
# when I quit, the if we haven't paid the car outright, then need to add rego, but not insurance
# if we pay-out the car, then add insurace and rego
if current_date.month == car_balloon_date.month and current_date.day == car_balloon_date.day:
# staying with the lease (0), if I have quit, then pay monthly rego only up to lease date, but full cost after car balloon date
if Ioniq6_future == LEASE:
if current_date.year >= car_balloon_date.year:
ins_amt=ioniq6_ins
for y in range( car_balloon_date.year, current_date.year):
ins_amt = ins_amt * (1+ioniq6_ins_bt['ann_growth_simple']/100)
rego_amt=ioniq6_rego
for y in range( car_balloon_date.year, current_date.year):
rego_amt = rego_amt * (1+ioniq6_rego_bt['ann_growth_simple']/100)
current_savings -= (ins_amt+rego_amt)
add_annotation(finance, current_date, current_savings, -(ins_amt+rego_amt), "IONIQ 6 ins/rego" )
# if we buy car outright, then as long as this anniversary is after buyout date, pay ins and rego
elif current_date.year >= car_buyout_date.year:
current_savings -= (ioniq6_ins + ioniq6_rego)
add_annotation(finance, current_date, current_savings, -(ioniq6_ins+ioniq6_rego), "IONIQ 6 ins/rego" )
# if current_date.date() == overseas_trip_date.date():
# current_savings -= 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, -Mich_present, "Mich's present" )
@@ -358,7 +299,6 @@ def calculate_savings_depletion(finance, bill_data, bill_type):
finance['CBA']=D_CBA_shares
finance['TLS']=D_TLS_shares+M_TLS_shares
return depletion_date, savings_per_fortnight, current_savings
################################################################################