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:
44
db.py
44
db.py
@@ -34,7 +34,8 @@ def init_db():
|
||||
CBA_price REAL,
|
||||
Overseas_trip_date STRING,
|
||||
Mark_reno_date STRING,
|
||||
Sell_shares INTEGER
|
||||
Sell_shares INTEGER,
|
||||
compare_to INTEGER
|
||||
)''')
|
||||
|
||||
cur.execute('''CREATE TABLE IF NOT EXISTS comparison_set (
|
||||
@@ -82,14 +83,15 @@ def init_db():
|
||||
# Interest rate
|
||||
# D_leave_owed_in_days
|
||||
# maybe quarterly update Inflation? (this is harder to appreciate, seems much lower officialy than Savings, but which inflation:
|
||||
# I've decided to consider food only or overall, whichever is worse - but only found a rabobank reference - THIS IS A MATERIAL ISSUE WITH PROJECTING OUT)
|
||||
# I've decided to consider food only or overall, whichever is worse - using this: https://tradingeconomics.com/australia/food-inflation
|
||||
# FOR NOW inf=3 THIS IS A MATERIAL ISSUE WITH PROJECTING OUT)
|
||||
###
|
||||
cur.execute('''INSERT INTO finance (D_Salary, D_Num_fortnights_pay, School_Fees, Car_loan_via_pay, Car_loan, Car_balloon, Living_Expenses, Savings, Interest_Rate,
|
||||
Inflation, Mich_present, Overseas_trip, Mark_reno, D_leave_owed_in_days, D_TLS_shares, M_TLS_shares, D_CBA_shares, TLS_price, CBA_price, Overseas_trip_date, Mark_reno_date, Sell_shares)
|
||||
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)''',
|
||||
(4762.29, 6, 22000, 620, 1001.12, 45824.68, 83000, 416670.67, 5.0, 3.9, 10000, 32000, 10000, 93.64, 1000, 750, 1095, 3.94, 158.57, '2025-06-01', '2025-09-01', 6))
|
||||
# NOTE: 1001.12 car-pay -- is 1017.99 (actual rate) - 16.87 (car park)
|
||||
# NOTE: o/s trip. ~ $4kpp flights x3, then ~$3k / week in barcelona accom, $100pp/pd for food ($2k), + spending money
|
||||
Inflation, Mich_present, Overseas_trip, Mark_reno, D_leave_owed_in_days, D_TLS_shares, M_TLS_shares, D_CBA_shares, TLS_price, CBA_price, Overseas_trip_date, Mark_reno_date, Sell_shares, compare_to)
|
||||
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)''',
|
||||
(4762.29, 6, 22000, 620, 1017.99, 45824.68, 84000, 416670.67, 5.0, 3.0, 10000, 32000, 10000, 93.64, 1000, 750, 1095, 3.92, 167.03, '2025-06-01', '2025-09-01', 6, 0))
|
||||
# NOTE: 1017.99 car-lease (NEED TO VERIFY)
|
||||
# NOTE: o/s trip. ~ $4kpp flights x3, then ~$3k / week in barcelona accom, $100pp/pd for food ($2k), + spending money (could be less)
|
||||
conn.commit()
|
||||
conn.close()
|
||||
|
||||
@@ -112,8 +114,8 @@ def get_budget_data(finance_data):
|
||||
return BUDGET
|
||||
|
||||
def update_finance(data):
|
||||
|
||||
conn = connect_db()
|
||||
print(data)
|
||||
conn = connect_db(False)
|
||||
cur = conn.cursor()
|
||||
cur.execute('''UPDATE finance SET
|
||||
D_Salary = ?,
|
||||
@@ -137,14 +139,15 @@ def update_finance(data):
|
||||
CBA_price = ?,
|
||||
Overseas_trip_date = ?,
|
||||
Mark_reno_date = ?,
|
||||
Sell_shares = ?
|
||||
Sell_shares = ?,
|
||||
compare_to = ?
|
||||
WHERE id = 1''', data)
|
||||
conn.commit()
|
||||
conn.close()
|
||||
|
||||
|
||||
def insert_cset( data ):
|
||||
conn = connect_db()
|
||||
conn = connect_db(False)
|
||||
cur = conn.cursor()
|
||||
cur.execute('''INSERT INTO comparison_set (
|
||||
name, D_Salary, D_Num_fortnights_pay, School_Fees, Car_loan_via_pay,
|
||||
@@ -181,12 +184,12 @@ def get_comp_set_data(cset_id):
|
||||
conn = connect_db(True)
|
||||
cur = conn.cursor()
|
||||
|
||||
# HARDCODED FOR NOW
|
||||
cset_id = 1
|
||||
|
||||
# get saved finance data for this comparison set
|
||||
cur.execute( f"select * from comparison_set where id = {cset_id}" )
|
||||
COMP['vars']= dict(cur.fetchone())
|
||||
res=cur.fetchone()
|
||||
if not res:
|
||||
return None
|
||||
COMP['vars']= dict(res)
|
||||
conn.close()
|
||||
|
||||
# open new connection so we get rows back as basic array
|
||||
@@ -201,3 +204,14 @@ def get_comp_set_data(cset_id):
|
||||
COMP['date'], COMP['amount'] = COMP['savings_data'][-1]
|
||||
return COMP
|
||||
|
||||
|
||||
def get_comp_set_options(finance):
|
||||
finance['COMP_SETS']=[ ( 0, 'Nothing' ) ]
|
||||
# get comp data from DB (as object so dict conversion works below)
|
||||
conn = connect_db(False)
|
||||
cur = conn.cursor()
|
||||
|
||||
# get saved finance data for this comparison set
|
||||
cur.execute( f"select id, name from comparison_set order by id" )
|
||||
finance['COMP_SETS'].extend( cur.fetchall() )
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user