updated to support new fields Car_buyout, Car_buyout_date, Ioniq6_future
This commit is contained in:
38
db.py
38
db.py
@@ -19,6 +19,7 @@ def init_db():
|
|||||||
Car_loan_via_pay INTEGER,
|
Car_loan_via_pay INTEGER,
|
||||||
Car_loan INTEGER,
|
Car_loan INTEGER,
|
||||||
Car_balloon INTEGER,
|
Car_balloon INTEGER,
|
||||||
|
Car_buyout INTEGER,
|
||||||
Living_Expenses INTEGER,
|
Living_Expenses INTEGER,
|
||||||
Savings INTEGER,
|
Savings INTEGER,
|
||||||
Interest_Rate REAL,
|
Interest_Rate REAL,
|
||||||
@@ -34,8 +35,10 @@ def init_db():
|
|||||||
CBA_price REAL,
|
CBA_price REAL,
|
||||||
Overseas_trip_date STRING,
|
Overseas_trip_date STRING,
|
||||||
Mark_reno_date STRING,
|
Mark_reno_date STRING,
|
||||||
|
Car_buyout_date STRING,
|
||||||
Sell_shares INTEGER,
|
Sell_shares INTEGER,
|
||||||
compare_to INTEGER
|
compare_to INTEGER,
|
||||||
|
Ioniq6_future INTEGER
|
||||||
)''')
|
)''')
|
||||||
|
|
||||||
cur.execute('''CREATE TABLE IF NOT EXISTS comparison_set (
|
cur.execute('''CREATE TABLE IF NOT EXISTS comparison_set (
|
||||||
@@ -47,6 +50,7 @@ def init_db():
|
|||||||
Car_loan_via_pay INTEGER,
|
Car_loan_via_pay INTEGER,
|
||||||
Car_loan INTEGER,
|
Car_loan INTEGER,
|
||||||
Car_balloon INTEGER,
|
Car_balloon INTEGER,
|
||||||
|
Car_buyout INTEGER,
|
||||||
Living_Expenses INTEGER,
|
Living_Expenses INTEGER,
|
||||||
Savings INTEGER,
|
Savings INTEGER,
|
||||||
Interest_Rate REAL,
|
Interest_Rate REAL,
|
||||||
@@ -62,9 +66,11 @@ def init_db():
|
|||||||
CBA_price REAL,
|
CBA_price REAL,
|
||||||
Overseas_trip_date STRING,
|
Overseas_trip_date STRING,
|
||||||
Mark_reno_date STRING,
|
Mark_reno_date STRING,
|
||||||
|
Car_buyout_date STRING,
|
||||||
Sell_shares INTEGER,
|
Sell_shares INTEGER,
|
||||||
CBA INTEGER,
|
CBA INTEGER,
|
||||||
TLS INTEGER
|
TLS INTEGER,
|
||||||
|
Ioniq6_future INTEGER
|
||||||
)''')
|
)''')
|
||||||
|
|
||||||
cur.execute('''CREATE TABLE IF NOT EXISTS comparison_savings_data (
|
cur.execute('''CREATE TABLE IF NOT EXISTS comparison_savings_data (
|
||||||
@@ -88,10 +94,10 @@ def init_db():
|
|||||||
# I've decided to consider food only or overall, whichever is worse - using this: https://tradingeconomics.com/australia/food-inflation
|
# 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)
|
# 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,
|
cur.execute('''INSERT INTO finance (D_Salary, D_Num_fortnights_pay, School_Fees, Car_loan_via_pay, Car_loan, Car_balloon, Car_buyout, 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, compare_to)
|
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, Car_buyout_date, Sell_shares, compare_to, Ioniq6_future)
|
||||||
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)''',
|
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))
|
(4762.29, 10, 22000, 620, 2412, 45824.68, 83738.74, 84000, 421271.5, 5.0, 3.0, 10000, 30000, 10000, 94.66, 1000, 750, 1095, 3.9, 158.9, '2025-06-01', '2025-09-01', '2025-02-20', 5, 0, 0))
|
||||||
# NOTE: 1017.99 car-lease (NEED TO VERIFY)
|
# 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)
|
# 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.commit()
|
||||||
@@ -111,12 +117,13 @@ def get_budget_data(finance_data):
|
|||||||
BUDGET=[]
|
BUDGET=[]
|
||||||
BUDGET.append( ('Bills', f"${bills:,.2f}") )
|
BUDGET.append( ('Bills', f"${bills:,.2f}") )
|
||||||
BUDGET.append( ('Buffer', f"${finance_data['CBA']*finance_data['CBA_price']+finance_data['TLS']*finance_data['TLS_price']:,.2f}") )
|
BUDGET.append( ('Buffer', f"${finance_data['CBA']*finance_data['CBA_price']+finance_data['TLS']*finance_data['TLS_price']:,.2f}") )
|
||||||
BUDGET.append( ('Monthly budget', f"${((finance_data['Living_Expenses']-12000) / 12):,.2f}" ) )
|
BUDGET.append( ('Monthly budget', f"${((finance_data['Living_Expenses']) / 12):,.2f}" ) )
|
||||||
BUDGET.append( ('Weekly budget', f"${((finance_data['Living_Expenses']-12000) / 52):,.2f}" ) )
|
BUDGET.append( ('Weekly budget', f"${((finance_data['Living_Expenses']) / 52):,.2f}" ) )
|
||||||
|
BUDGET.append( ('Monthly budget (ex bills)', f"${((finance_data['Living_Expenses']-bills) / 12):,.2f}" ) )
|
||||||
|
BUDGET.append( ('Weekly budget (ex bills)', f"${((finance_data['Living_Expenses']-bills) / 52):,.2f}" ) )
|
||||||
return BUDGET
|
return BUDGET
|
||||||
|
|
||||||
def update_finance(data):
|
def update_finance(data):
|
||||||
print(data)
|
|
||||||
conn = connect_db(False)
|
conn = connect_db(False)
|
||||||
cur = conn.cursor()
|
cur = conn.cursor()
|
||||||
cur.execute('''UPDATE finance SET
|
cur.execute('''UPDATE finance SET
|
||||||
@@ -126,6 +133,7 @@ def update_finance(data):
|
|||||||
Car_loan_via_pay = ?,
|
Car_loan_via_pay = ?,
|
||||||
Car_loan = ?,
|
Car_loan = ?,
|
||||||
Car_balloon = ?,
|
Car_balloon = ?,
|
||||||
|
Car_buyout = ?,
|
||||||
Living_Expenses = ?,
|
Living_Expenses = ?,
|
||||||
Savings = ?,
|
Savings = ?,
|
||||||
Interest_Rate = ?,
|
Interest_Rate = ?,
|
||||||
@@ -141,8 +149,10 @@ def update_finance(data):
|
|||||||
CBA_price = ?,
|
CBA_price = ?,
|
||||||
Overseas_trip_date = ?,
|
Overseas_trip_date = ?,
|
||||||
Mark_reno_date = ?,
|
Mark_reno_date = ?,
|
||||||
|
Car_buyout_date = ?,
|
||||||
Sell_shares = ?,
|
Sell_shares = ?,
|
||||||
compare_to = ?
|
compare_to = ?,
|
||||||
|
Ioniq6_future = ?
|
||||||
WHERE id = 1''', data)
|
WHERE id = 1''', data)
|
||||||
conn.commit()
|
conn.commit()
|
||||||
conn.close()
|
conn.close()
|
||||||
@@ -154,15 +164,15 @@ def insert_cset( data ):
|
|||||||
cur = conn.cursor()
|
cur = conn.cursor()
|
||||||
cur.execute('''INSERT INTO comparison_set (
|
cur.execute('''INSERT INTO comparison_set (
|
||||||
name, D_Salary, D_Num_fortnights_pay, School_Fees, Car_loan_via_pay,
|
name, D_Salary, D_Num_fortnights_pay, School_Fees, Car_loan_via_pay,
|
||||||
Car_loan, Car_balloon, Living_Expenses, Savings, Interest_Rate, Inflation, Mich_present,
|
Car_loan, Car_balloon, Car_buyout, 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,
|
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, CBA, TLS
|
TLS_price, CBA_price, Overseas_trip_date, Mark_reno_date, Car_buyout_date, Sell_shares, CBA, TLS, Ioniq6_future
|
||||||
)
|
)
|
||||||
VALUES (
|
VALUES (
|
||||||
:name, :D_Salary, :D_Num_fortnights_pay, :School_Fees, :Car_loan_via_pay,
|
:name, :D_Salary, :D_Num_fortnights_pay, :School_Fees, :Car_loan_via_pay,
|
||||||
:Car_loan, :Car_balloon, :Living_Expenses, :Savings, :Interest_Rate, :Inflation, :Mich_present,
|
:Car_loan, :Car_balloon, :Car_buyout, :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,
|
: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, :CBA, :TLS
|
:TLS_price, :CBA_price, :Overseas_trip_date, :Mark_reno_date, :Car_buyout_date, :Sell_shares, :CBA, :TLS, :Ioniq6_future
|
||||||
)
|
)
|
||||||
''', data['vars'])
|
''', data['vars'])
|
||||||
cset_id = cur.lastrowid
|
cset_id = cur.lastrowid
|
||||||
|
|||||||
Reference in New Issue
Block a user