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:
2
BUGS
2
BUGS
@@ -1,5 +1,3 @@
|
|||||||
* when I delete a comp_set && it is the current compare_to, then need to reset compare_to to 'Nothing'
|
|
||||||
|
|
||||||
* with future bills - recalculate bills button blows away growth!
|
* with future bills - recalculate bills button blows away growth!
|
||||||
- BUT, I think just loading the bills page puts it back -- need to validate and fix if so
|
- BUT, I think just loading the bills page puts it back -- need to validate and fix if so
|
||||||
|
|
||||||
|
|||||||
2
db.py
2
db.py
@@ -8,6 +8,8 @@ def connect_db(as_object):
|
|||||||
conn = sqlite3.connect('/data/finance.db')
|
conn = sqlite3.connect('/data/finance.db')
|
||||||
else:
|
else:
|
||||||
conn = sqlite3.connect('./finance.db')
|
conn = sqlite3.connect('./finance.db')
|
||||||
|
# allow deleting cset to clear our compare_to properly in finance table
|
||||||
|
conn.execute("PRAGMA foreign_keys = ON;")
|
||||||
if as_object:
|
if as_object:
|
||||||
conn.row_factory = sqlite3.Row # This allows us to access columns by name
|
conn.row_factory = sqlite3.Row # This allows us to access columns by name
|
||||||
return conn
|
return conn
|
||||||
|
|||||||
9
main.py
9
main.py
@@ -41,7 +41,10 @@ def index():
|
|||||||
depletion_date=depletion_date.date(); # just show date
|
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
|
# if we are comparing...(compare_to will be 0 / None to start with, and then COMP will be None
|
||||||
|
if finance_data['compare_to']:
|
||||||
COMP=get_comp_set_data(finance_data['compare_to'])
|
COMP=get_comp_set_data(finance_data['compare_to'])
|
||||||
|
else:
|
||||||
|
COMP={}
|
||||||
|
|
||||||
DISP=[]
|
DISP=[]
|
||||||
# Row 1
|
# Row 1
|
||||||
@@ -122,6 +125,9 @@ def update():
|
|||||||
|
|
||||||
old_finance_data = get_finance_data()
|
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 = (
|
finance_data = (
|
||||||
request.form['D_Salary'],
|
request.form['D_Salary'],
|
||||||
request.form['D_Num_fortnights_pay'],
|
request.form['D_Num_fortnights_pay'],
|
||||||
@@ -147,9 +153,10 @@ def update():
|
|||||||
request.form['Mark_reno_date'],
|
request.form['Mark_reno_date'],
|
||||||
request.form['Car_buyout_date'],
|
request.form['Car_buyout_date'],
|
||||||
request.form['Sell_shares'],
|
request.form['Sell_shares'],
|
||||||
request.form['compare_to'],
|
compare_to_value,
|
||||||
request.form['Ioniq6_future']
|
request.form['Ioniq6_future']
|
||||||
)
|
)
|
||||||
|
|
||||||
update_finance(finance_data)
|
update_finance(finance_data)
|
||||||
new_finance_data = get_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
|
# changed Ioniq6_future, Car_buyout_date or D_Num_fortnights_pay, so lets force recalc key_dates, and therefore estimated bills
|
||||||
|
|||||||
Reference in New Issue
Block a user