moved some hard-coded dates to top of calc.py for ease of use in multiple functions, but also just for code readability, they are more like constants than variables. Code now works out key_dates for use in dealing with future bills / next steps
This commit is contained in:
40
calc.py
40
calc.py
@@ -5,6 +5,15 @@ from defines import END_YEAR
|
||||
# GLOBAL CONSTANTS
|
||||
LEASE = 0
|
||||
|
||||
# Dates that don't change
|
||||
car_balloon_date = datetime(2026, 11, 15)
|
||||
new_fin_year_25 = datetime(2025, 7, 1)
|
||||
new_fin_year_26 = datetime(2026, 7, 1)
|
||||
end_date = datetime(END_YEAR, 4, 15)
|
||||
school_fees_date = datetime(2025, 12, 5)
|
||||
mich_present_date = datetime(2026,10,15)
|
||||
first_pay_date = datetime(2025,1,8)
|
||||
|
||||
def bill_amount_today(finance, day, bill_data, bt_id_name, total ):
|
||||
amt=0
|
||||
day_str = day.strftime("%Y-%m-%d")
|
||||
@@ -100,8 +109,6 @@ def calculate_savings_depletion(finance, bill_data, bill_type):
|
||||
D_has_quit = False
|
||||
D_quit_year = 0
|
||||
claim_tax_on_leave = False
|
||||
new_fin_year_25 = datetime(2025, 7, 1)
|
||||
new_fin_year_26 = datetime(2026, 7, 1)
|
||||
|
||||
# Constants for interest calculations
|
||||
annual_interest_rate = Interest_Rate / 100.0
|
||||
@@ -109,7 +116,6 @@ 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()
|
||||
end_date = datetime(END_YEAR, 4, 15)
|
||||
|
||||
# work out which bill_types relate to future bills
|
||||
for bt in bill_type:
|
||||
@@ -151,11 +157,6 @@ def calculate_savings_depletion(finance, bill_data, bill_type):
|
||||
depletion_date = None
|
||||
savings_per_fortnight = []
|
||||
|
||||
# significant dates that are non-changeable
|
||||
school_fees_date = datetime(2025, 12, 5)
|
||||
car_balloon_date = datetime(2026, 11, 15)
|
||||
mich_present_date = datetime(2026,10,15)
|
||||
|
||||
# significant dates - but who knows when? :)
|
||||
overseas_trip_date = datetime.strptime( finance['Overseas_trip_date'], "%Y-%m-%d")
|
||||
mark_reno_date = datetime.strptime( finance['Mark_reno_date'], "%Y-%m-%d")
|
||||
@@ -360,3 +361,26 @@ def calculate_savings_depletion(finance, bill_data, bill_type):
|
||||
|
||||
return depletion_date, savings_per_fortnight, current_savings
|
||||
|
||||
################################################################################
|
||||
# work out the date D quits and when we own the car, so we can then use it to
|
||||
# handle future bills
|
||||
################################################################################
|
||||
def calc_key_dates( finance ):
|
||||
key_dates={}
|
||||
now = datetime.today()
|
||||
# this will be 0 to 13 days - how far into this fortnights pay cycle are we now
|
||||
days_in_pay_fortnight= ( now - first_pay_date ).days % 14
|
||||
|
||||
# add 1 less fortnight than we continue to work, then add rest of pay cycle (14-days_in_pay_fortnight)
|
||||
key_dates['D_quit_date'] = (now+timedelta(weeks=2*(finance['D_Num_fortnights_pay']-1))+timedelta(days=(14-days_in_pay_fortnight))).strftime('%Y-%m-%d')
|
||||
|
||||
# use lease date
|
||||
if finance['Ioniq6_future'] == LEASE:
|
||||
key_dates['D_hyundai_owned'] = car_balloon_date.strftime('%Y-%m-%d')
|
||||
# use buyout date
|
||||
else:
|
||||
key_dates['D_hyundai_owned'] = finance['Car_buyout_date']
|
||||
|
||||
print( f"kd={key_dates}" )
|
||||
return key_dates
|
||||
|
||||
|
||||
Reference in New Issue
Block a user