diff --git a/db.py b/db.py index 7802f47..fadb851 100644 --- a/db.py +++ b/db.py @@ -19,6 +19,7 @@ def init_db(): Car_loan_via_pay INTEGER, Car_loan INTEGER, Car_balloon INTEGER, + Car_buyout INTEGER, Living_Expenses INTEGER, Savings INTEGER, Interest_Rate REAL, @@ -34,8 +35,10 @@ def init_db(): CBA_price REAL, Overseas_trip_date STRING, Mark_reno_date STRING, + Car_buyout_date STRING, Sell_shares INTEGER, - compare_to INTEGER + compare_to INTEGER, + Ioniq6_future INTEGER )''') cur.execute('''CREATE TABLE IF NOT EXISTS comparison_set ( @@ -47,6 +50,7 @@ def init_db(): Car_loan_via_pay INTEGER, Car_loan INTEGER, Car_balloon INTEGER, + Car_buyout INTEGER, Living_Expenses INTEGER, Savings INTEGER, Interest_Rate REAL, @@ -62,9 +66,11 @@ def init_db(): CBA_price REAL, Overseas_trip_date STRING, Mark_reno_date STRING, + Car_buyout_date STRING, Sell_shares INTEGER, CBA INTEGER, - TLS INTEGER + TLS INTEGER, + Ioniq6_future INTEGER )''') 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 # 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, 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)) + 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, Car_buyout_date, Sell_shares, compare_to, Ioniq6_future) + VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)''', + (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: o/s trip. ~ $4kpp flights x3, then ~$3k / week in barcelona accom, $100pp/pd for food ($2k), + spending money (could be less) conn.commit() @@ -111,12 +117,13 @@ def get_budget_data(finance_data): BUDGET=[] 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( ('Monthly budget', f"${((finance_data['Living_Expenses']-12000) / 12):,.2f}" ) ) - BUDGET.append( ('Weekly budget', f"${((finance_data['Living_Expenses']-12000) / 52):,.2f}" ) ) + BUDGET.append( ('Monthly budget', f"${((finance_data['Living_Expenses']) / 12):,.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 def update_finance(data): - print(data) conn = connect_db(False) cur = conn.cursor() cur.execute('''UPDATE finance SET @@ -126,6 +133,7 @@ def update_finance(data): Car_loan_via_pay = ?, Car_loan = ?, Car_balloon = ?, + Car_buyout = ?, Living_Expenses = ?, Savings = ?, Interest_Rate = ?, @@ -141,8 +149,10 @@ def update_finance(data): CBA_price = ?, Overseas_trip_date = ?, Mark_reno_date = ?, + Car_buyout_date = ?, Sell_shares = ?, - compare_to = ? + compare_to = ?, + Ioniq6_future = ? WHERE id = 1''', data) conn.commit() conn.close() @@ -154,15 +164,15 @@ def insert_cset( data ): cur = conn.cursor() cur.execute('''INSERT INTO comparison_set ( 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, - 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 ( :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, - :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']) cset_id = cur.lastrowid