removed M_* variables that are no longer relevant, cleaned up interface to have columns more ordered, updated default values in DB to be more as accurate as I can make them for now
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -1,2 +1,3 @@
|
||||
__pycache__/
|
||||
.python/
|
||||
finance.db
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
11
calc.py
11
calc.py
@@ -4,9 +4,7 @@ from datetime import datetime, timedelta
|
||||
def calculate_savings_depletion(finance):
|
||||
# Extract all the financial data from the database
|
||||
D_Salary = finance['D_Salary']
|
||||
M_salary = finance['M_salary']
|
||||
D_Num_fortnights_pay = finance['D_Num_fortnights_pay']
|
||||
M_Num_fortnights_pay = finance['M_Num_fortnights_pay']
|
||||
School_Fees = finance['School_Fees']
|
||||
Car_loan_via_pay = finance['Car_loan_via_pay']
|
||||
Car_loan = finance['Car_loan']
|
||||
@@ -15,7 +13,6 @@ def calculate_savings_depletion(finance):
|
||||
Savings = finance['Savings']
|
||||
Interest_Rate = finance['Interest_Rate']
|
||||
Inflation = finance['Inflation']
|
||||
M_payout = finance['M_payout']
|
||||
Mich_present = finance['Mich_present']
|
||||
Overseas_trip = finance['Overseas_trip']
|
||||
Mark_reno = finance['Mark_reno']
|
||||
@@ -59,7 +56,6 @@ def calculate_savings_depletion(finance):
|
||||
# significant dates - but who knows when? :)
|
||||
overseas_trip_date = datetime.strptime( finance['Overseas_trip_date'], "%Y-%m-%d")
|
||||
mark_reno_date = datetime.strptime( finance['Mark_reno_date'], "%Y-%m-%d")
|
||||
M_payout_date = datetime.strptime( finance['M_payout_date'], "%Y-%m-%d")
|
||||
|
||||
# to force deakin pay cycles to match reality, we work from the 8th of Jan as our "day-zero" so we are paid on the 8/1/25, 22/1/25, etc.
|
||||
days_count = ( current_date - datetime(2025,1,1) ).days
|
||||
@@ -84,9 +80,6 @@ def calculate_savings_depletion(finance):
|
||||
if D_Num_fortnights_pay > 0:
|
||||
fortnight_income += D_Salary
|
||||
D_Num_fortnights_pay -= 1
|
||||
if M_Num_fortnights_pay > 0:
|
||||
fortnight_income += M_salary
|
||||
M_Num_fortnights_pay -= 1
|
||||
|
||||
if D_Num_fortnights_pay == 0 and D_leave_after_tax > 0:
|
||||
print(f"D has resigned {current_date}: get paid out my 9 weeks leave and lose 45% to tax - ${D_leave_after_tax}" )
|
||||
@@ -116,10 +109,6 @@ def calculate_savings_depletion(finance):
|
||||
daily_living_expenses = Living_Expenses / 365
|
||||
#print(f"Living Exp inceased {current_date}: ${Living_Expenses}")
|
||||
|
||||
if current_date.date() == M_payout_date.date():
|
||||
current_savings += M_payout
|
||||
print(f"payout={current_date} + {M_payout}")
|
||||
|
||||
if current_date.date() == school_fees_date.date():
|
||||
current_savings -= School_Fees
|
||||
print(f"school fees={current_date} - {School_Fees}")
|
||||
|
||||
19
db.py
19
db.py
@@ -12,9 +12,7 @@ def init_db():
|
||||
cur.execute('''CREATE TABLE IF NOT EXISTS finance (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
D_Salary INTEGER,
|
||||
M_salary INTEGER,
|
||||
D_Num_fortnights_pay INTEGER,
|
||||
M_Num_fortnights_pay INTEGER,
|
||||
School_Fees INTEGER,
|
||||
Car_loan_via_pay INTEGER,
|
||||
Car_loan INTEGER,
|
||||
@@ -23,7 +21,6 @@ def init_db():
|
||||
Savings INTEGER,
|
||||
Interest_Rate REAL,
|
||||
Inflation REAL,
|
||||
M_payout INTEGER,
|
||||
Mich_present INTEGER,
|
||||
Overseas_trip INTEGER,
|
||||
Mark_reno INTEGER,
|
||||
@@ -35,20 +32,16 @@ def init_db():
|
||||
CBA_price REAL,
|
||||
Overseas_trip_date STRING,
|
||||
Mark_reno_date STRING,
|
||||
M_payout_date STRING,
|
||||
Sell_shares INTEGER
|
||||
)''')
|
||||
|
||||
# Check if table is empty, if so insert default values
|
||||
cur.execute('SELECT COUNT(*) FROM finance')
|
||||
if cur.fetchone()[0] == 0:
|
||||
cur.execute('''INSERT INTO finance (D_Salary, M_salary, D_Num_fortnights_pay, M_Num_fortnights_pay,
|
||||
School_Fees, Car_loan_via_pay, Car_loan, Car_balloon, Living_Expenses, Savings, Interest_Rate,
|
||||
Inflation, M_payout, 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,
|
||||
M_payout_date, Sell_shares)
|
||||
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)''',
|
||||
(4762.29, 1962.56, 7, 1, 22000, 620, 1001.12, 45824.68, 65000, 297000, 5.0, 3.9, 96000,10000,28000,10000,90.6,1000,750,1095,4.03,156.21,'2025-06-01','2025-09-01', '2025-01-20', 6))
|
||||
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, 78000, 412000, 5.0, 3.9, 10000, 32000, 10000, 90.6, 1000, 750, 1095, 3.99, 160.61, '2025-06-01', '2025-09-01', 5))
|
||||
# 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
|
||||
conn.commit()
|
||||
@@ -68,9 +61,7 @@ def update_finance(data):
|
||||
cur = conn.cursor()
|
||||
cur.execute('''UPDATE finance SET
|
||||
D_Salary = ?,
|
||||
M_salary = ?,
|
||||
D_Num_fortnights_pay = ?,
|
||||
M_Num_fortnights_pay = ?,
|
||||
School_Fees = ?,
|
||||
Car_loan_via_pay = ?,
|
||||
Car_loan = ?,
|
||||
@@ -79,7 +70,6 @@ def update_finance(data):
|
||||
Savings = ?,
|
||||
Interest_Rate = ?,
|
||||
Inflation = ?,
|
||||
M_payout = ?,
|
||||
Mich_present = ?,
|
||||
Overseas_trip = ?,
|
||||
Mark_reno = ?,
|
||||
@@ -91,7 +81,6 @@ def update_finance(data):
|
||||
CBA_price = ?,
|
||||
Overseas_trip_date = ?,
|
||||
Mark_reno_date = ?,
|
||||
M_payout_date = ?,
|
||||
Sell_shares = ?
|
||||
WHERE id = 1''', data)
|
||||
conn.commit()
|
||||
|
||||
BIN
finance.db
BIN
finance.db
Binary file not shown.
4
main.py
4
main.py
@@ -33,9 +33,7 @@ def update():
|
||||
|
||||
finance_data = (
|
||||
request.form['D_Salary'],
|
||||
request.form['M_salary'],
|
||||
request.form['D_Num_fortnights_pay'],
|
||||
request.form['M_Num_fortnights_pay'],
|
||||
request.form['School_Fees'],
|
||||
request.form['Car_loan_via_pay'],
|
||||
request.form['Car_loan'],
|
||||
@@ -44,7 +42,6 @@ def update():
|
||||
request.form['Savings'],
|
||||
request.form['Interest_Rate'],
|
||||
request.form['Inflation'],
|
||||
request.form['M_payout'],
|
||||
request.form['Mich_present'],
|
||||
request.form['Overseas_trip'],
|
||||
request.form['Mark_reno'],
|
||||
@@ -56,7 +53,6 @@ def update():
|
||||
request.form['CBA_price'],
|
||||
request.form['Overseas_trip_date'],
|
||||
request.form['Mark_reno_date'],
|
||||
request.form['M_payout_date'],
|
||||
request.form['Sell_shares'],
|
||||
)
|
||||
|
||||
|
||||
@@ -19,8 +19,8 @@
|
||||
</div>
|
||||
<div class="col">
|
||||
<div class="input-group">
|
||||
<label for="M_salary" class="col-form-label me-2 text-end float-end">M Salary</label>
|
||||
<input type="number" step="any" class="form-control text-end float-end " id="M_salary" name="M_salary" value="{{ finance['M_salary'] }}">
|
||||
<label for="Savings" class="col-form-label me-2 text-end float-end">Savings</label>
|
||||
<input type="number" step="any" class="form-control text-end float-end " id="Savings" name="Savings" value="{{ finance['Savings'] }}">
|
||||
</div>
|
||||
</div>
|
||||
<div class="col">
|
||||
@@ -29,10 +29,10 @@
|
||||
<input type="number" step="any" class="form-control text-end float-end " id="Living_Expenses" name="Living_Expenses" value="{{ finance['Living_Expenses'] }}">
|
||||
</div>
|
||||
</div>
|
||||
<div class="col">
|
||||
<div class="col-2">
|
||||
<div class="input-group">
|
||||
<label for="Savings" class="col-form-label me-2 text-end float-end">Savings</label>
|
||||
<input type="number" step="any" class="form-control text-end float-end " id="Savings" name="Savings" value="{{ finance['Savings'] }}">
|
||||
<label for="Car_loan_via_pay" class="col-form-label me-2 text-end float-end">Car Loan via Pay</label>
|
||||
<input type="number" step="any" class="bg-light form-control text-end float-end" id="Car_loan_via_pay" name="Car_loan_via_pay" value="{{ finance['Car_loan_via_pay'] }}" readonly>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-4">
|
||||
@@ -52,8 +52,8 @@
|
||||
</div>
|
||||
<div class="col">
|
||||
<div class="input-group">
|
||||
<label for="M_Num_fortnights_pay" class="col-form-label me-2 text-end float-end">M # Fortnights pay</label>
|
||||
<input type="number" class="form-control text-end float-end" id="M_Num_fortnights_pay" name="M_Num_fortnights_pay" value="{{ finance['M_Num_fortnights_pay'] }}">
|
||||
<label for="Interest_Rate" class="col-form-label me-2 text-end float-end">Interest Rate (%)</label>
|
||||
<input type="number" step="any" class="form-control text-end float-end" id="Interest_Rate" name="Interest_Rate" value="{{ finance['Interest_Rate'] }}">
|
||||
</div>
|
||||
</div>
|
||||
<div class="col">
|
||||
@@ -62,10 +62,10 @@
|
||||
<input type="number" step="any" class="form-control text-end float-end" id="Inflation" name="Inflation" value="{{ finance['Inflation'] }}">
|
||||
</div>
|
||||
</div>
|
||||
<div class="col">
|
||||
<div class="col-2">
|
||||
<div class="input-group">
|
||||
<label for="Interest_Rate" class="col-form-label me-2 text-end float-end">Interest Rate (%)</label>
|
||||
<input type="number" step="any" class="form-control text-end float-end" id="Interest_Rate" name="Interest_Rate" value="{{ finance['Interest_Rate'] }}">
|
||||
<label for="Car_loan" class="col-form-label me-2 text-end float-end">Car Loan</label>
|
||||
<input type="number" step="any" class="bg-light form-control text-end float-end" id="Car_loan" name="Car_loan" value="{{ finance['Car_loan'] }}" readonly>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-4">
|
||||
@@ -79,8 +79,8 @@
|
||||
<div class="row align-items-center">
|
||||
<div class="col-2">
|
||||
<div class="input-group">
|
||||
<label for="D_TLS_shares" class="col-form-label me-2 text-end float-end">D TLS amount</label>
|
||||
<input type="number" step="any" class="form-control text-end float-end" id="D_TLS_shares" name="D_TLS_shares" value="{{ finance['D_TLS_shares'] }}" >
|
||||
<label for="D_leave_owed_in_days" class="col-form-label me-2 text-end float-end">D leave owed (in days)</label>
|
||||
<input type="number" step="any" class="form-control text-end float-end" id="D_leave_owed_in_days" name="D_leave_owed_in_days" value="{{ finance['D_leave_owed_in_days'] }}" >
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-2">
|
||||
@@ -89,33 +89,14 @@
|
||||
<input type="number" step="any" class="form-control text-end float-end" id="M_TLS_shares" name="M_TLS_shares" value="{{ finance['M_TLS_shares'] }}" >
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-2">
|
||||
<div class="input-group">
|
||||
<label for="Car_loan_via_pay" class="col-form-label me-2 text-end float-end">Car Loan via Pay</label>
|
||||
<input type="number" step="any" class="bg-light form-control text-end float-end" id="Car_loan_via_pay" name="Car_loan_via_pay" value="{{ finance['Car_loan_via_pay'] }}" readonly>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-2">
|
||||
<div class="offset-2 col-2">
|
||||
<div class="input-group">
|
||||
<label for="Car_balloon" class="col-form-label me-2 text-end float-end">Car Balloon</label>
|
||||
<input type="number" step="any" class="bg-light form-control text-end float-end" id="Car_balloon" name="Car_balloon" value="{{ finance['Car_balloon'] }}" readonly>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-4">
|
||||
<div class="input-group">
|
||||
<label for="M_payout" class="col-form-label me-2 text-end float-end">M VR Payout</label>
|
||||
<input type="number" step="any" class="form-control text-end float-end" id="M_payout" name="M_payout" value="{{ finance['M_payout'] }}" >
|
||||
<input type="date" class="form-control text-end float-end" name="M_payout_date" id="M_payout_date" value="{{finance['M_payout_date']}}" onchange="this.form.submit()">
|
||||
</div>
|
||||
</div>
|
||||
</div class="row">
|
||||
<div class="row align-items-center">
|
||||
<div class="col-2">
|
||||
<div class="input-group">
|
||||
<label for="D_leave_owed_in_days" class="col-form-label me-2 text-end float-end">D leave owed (in days)</label>
|
||||
<input type="number" step="any" class="form-control text-end float-end" id="D_leave_owed_in_days" name="D_leave_owed_in_days" value="{{ finance['D_leave_owed_in_days'] }}" >
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-2">
|
||||
<div class="input-group">
|
||||
<label for="D_CBA_shares" class="col-form-label me-2 text-end float-end">D CBA amount</label>
|
||||
@@ -124,11 +105,11 @@
|
||||
</div>
|
||||
<div class="col-2">
|
||||
<div class="input-group">
|
||||
<label for="Car_loan" class="col-form-label me-2 text-end float-end">Car Loan</label>
|
||||
<input type="number" step="any" class="bg-light form-control text-end float-end" id="Car_loan" name="Car_loan" value="{{ finance['Car_loan'] }}" readonly>
|
||||
<label for="D_TLS_shares" class="col-form-label me-2 text-end float-end">D TLS amount</label>
|
||||
<input type="number" step="any" class="form-control text-end float-end" id="D_TLS_shares" name="D_TLS_shares" value="{{ finance['D_TLS_shares'] }}" >
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-2">
|
||||
<div class="offset-2 col-2">
|
||||
<div class="input-group">
|
||||
<label for="Mich_present" class="col-form-label me-2 text-end float-end float-end">Mich Present</label>
|
||||
<input type="number" step="any" class="form-control text-end float-end bg-light" id="Mich_present" name="Mich_present" value="{{ finance['Mich_present'] }}" readonly>
|
||||
@@ -148,24 +129,12 @@
|
||||
<input type="number" step="any" class="form-control text-end float-end" id="TLS_price" name="TLS_price" value="{{ finance['TLS_price'] }}" >
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-2">
|
||||
<div class="offset-2 col-2">
|
||||
<div class="input-group">
|
||||
<label for="School_Fees" class="col-form-label me-2 text-end float-end">School Fees</label>
|
||||
<input type="number" step="any" class="bg-light form-control text-end float-end" id="School_Fees" name="School_Fees" value="{{ finance['School_Fees'] }}" readonly>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-2">
|
||||
<div class="input-group">
|
||||
<label for="CBA_shares" class="col-form-label me-2 text-end float-end">FINAL # of CBA</label>
|
||||
<input type="number" class="form-control text-end float-end bg-light" id="CBA_shares" value="{{CBA}}" readonly>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-2">
|
||||
<div class="input-group">
|
||||
<label for="TLS_shares" class="offset-1 col-form-label me-2 text-end float-end">FINAL # of TLS</label>
|
||||
<input type="number" class="form-control text-end float-end bg-light" id="TLS_shares" value="{{TLS}}" readonly>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row align-items-center mt-4">
|
||||
@@ -186,6 +155,18 @@
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-2">
|
||||
<div class="input-group">
|
||||
<label for="CBA_shares" class="col-form-label me-2 text-end float-end">FINAL # of CBA</label>
|
||||
<input type="number" class="form-control text-end float-end bg-light" id="CBA_shares" value="{{CBA}}" readonly>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-2">
|
||||
<div class="input-group">
|
||||
<label for="TLS_shares" class="offset-1 col-form-label me-2 text-end float-end">FINAL # of TLS</label>
|
||||
<input type="number" class="form-control text-end float-end bg-light" id="TLS_shares" value="{{TLS}}" readonly>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user