put improved foreign key constraints on DB to fix bug where when I delete a cset, that was being used to compare_to, it breaks

This commit is contained in:
2026-02-10 21:35:41 +11:00
parent e3d2d8ea08
commit 20239d72c8
3 changed files with 11 additions and 4 deletions

11
main.py
View File

@@ -41,7 +41,10 @@ def index():
depletion_date=depletion_date.date(); # just show date
# if we are comparing...(compare_to will be 0 / None to start with, and then COMP will be None
COMP=get_comp_set_data(finance_data['compare_to'])
if finance_data['compare_to']:
COMP=get_comp_set_data(finance_data['compare_to'])
else:
COMP={}
DISP=[]
# Row 1
@@ -122,6 +125,9 @@ def update():
old_finance_data = get_finance_data()
raw_compare_to = request.form.get('compare_to')
compare_to_value = None if raw_compare_to == "0" else int(raw_compare_to)
finance_data = (
request.form['D_Salary'],
request.form['D_Num_fortnights_pay'],
@@ -147,9 +153,10 @@ def update():
request.form['Mark_reno_date'],
request.form['Car_buyout_date'],
request.form['Sell_shares'],
request.form['compare_to'],
compare_to_value,
request.form['Ioniq6_future']
)
update_finance(finance_data)
new_finance_data = get_finance_data()
# changed Ioniq6_future, Car_buyout_date or D_Num_fortnights_pay, so lets force recalc key_dates, and therefore estimated bills