Compare commits
3 Commits
2bdd1348b8
...
8f69023ffd
| Author | SHA1 | Date | |
|---|---|---|---|
| 8f69023ffd | |||
| d2bf472845 | |||
| e84faffd79 |
24
TODO
24
TODO
@@ -1,29 +1,7 @@
|
|||||||
UI:
|
UI:
|
||||||
* when we choose a tab of bill_data -> set new bill select based on tab
|
|
||||||
& vice-versa, add a bill of type, reload page to show the tab of those bills
|
|
||||||
|
|
||||||
For bills:
|
For bills:
|
||||||
* gas bills are a mess and more than 4 per year... *SIGH* try this:
|
[DONE] - calculate pragmatic min/avg/max/simple
|
||||||
- if len(bills) > num_ann_bills (effectively too many bills for what we expect)
|
|
||||||
- normalise by looping over *EVERY* year of bills
|
|
||||||
- for each bill in yr:
|
|
||||||
- pb=find_prev_bill( bill )...
|
|
||||||
- calc days between pb and bill to get daily cost
|
|
||||||
- work out qtr() and take # days from bill in Qtr X and add it to Q[X]
|
|
||||||
- if # days i X+1 add those to Q[X+1]
|
|
||||||
- then need to be careful when working out totals/growth to use Q[...] not bill['year']
|
|
||||||
* growth for internet/monthly is a bit skewed.... Really think min/avg/max might need to be smarter
|
|
||||||
- at least max, its 114-134 BUT, not in 1 year, really that changed from 2022 to 2025, so 3 years... (or max = 18% over 3 years, or 6%)
|
|
||||||
-- so ann_growth_avg or max needs to factor in years of same prices
|
|
||||||
[DONE] -- Pragmatical growth before I bonkers:
|
|
||||||
[DONE] - monthly, prob. just flat by default (simple 1 or 12 bills for the year each year and I can get a growth rate from that)
|
|
||||||
[DONE] - and apply monthly growth - annually 12 + months from last bill each year
|
|
||||||
[DONE] - quarterly - should be able to take last qtr-1 ... qtr-4 and then grow them all by growth
|
|
||||||
[DONE]- annual easy
|
|
||||||
* once auto-filled bills exist:
|
|
||||||
[DONE]- calc growth
|
|
||||||
[DONE] - project out to I am 60 (A/Q/M) - A/Q done, M to go
|
|
||||||
[DONE] - probably need to allow a toggle to: allow show manual, show auto-filled past, show auto-filled future, show all
|
|
||||||
- remove bills from Living_Expenses (carefully - but by hand)
|
- remove bills from Living_Expenses (carefully - but by hand)
|
||||||
- fold future bills into calc so they are taken out in a more time and growth appropriate way
|
- fold future bills into calc so they are taken out in a more time and growth appropriate way
|
||||||
- inflation can then be put to a more realistic quarterly figure
|
- inflation can then be put to a more realistic quarterly figure
|
||||||
|
|||||||
5
db.py
5
db.py
@@ -309,9 +309,12 @@ def get_bill_freqs():
|
|||||||
def new_bill( bill_type, amount, bill_date, estimated ):
|
def new_bill( bill_type, amount, bill_date, estimated ):
|
||||||
conn = connect_db(False)
|
conn = connect_db(False)
|
||||||
cur = conn.cursor()
|
cur = conn.cursor()
|
||||||
# force delete estimates as new bill will potentially change them/growth, etc.
|
# if we are a real bill added by UI
|
||||||
if not estimated:
|
if not estimated:
|
||||||
|
# delete old estimates as new bill will potentially change them/growth, etc.
|
||||||
cur.execute( f"delete from bill_data where estimated=1" )
|
cur.execute( f"delete from bill_data where estimated=1" )
|
||||||
|
# force the next /bills load to show the tab for the bill we are adding
|
||||||
|
cur.execute( f"update bill_ui set last_tab='{bill_type}'" )
|
||||||
cur.execute( f"insert into bill_data ( 'bill_type', 'amount', 'bill_date', 'estimated' ) values ( '{bill_type}', '{float(amount):.2f}', '{bill_date}', {estimated} )" )
|
cur.execute( f"insert into bill_data ( 'bill_type', 'amount', 'bill_date', 'estimated' ) values ( '{bill_type}', '{float(amount):.2f}', '{bill_date}', {estimated} )" )
|
||||||
conn.commit()
|
conn.commit()
|
||||||
conn.close()
|
conn.close()
|
||||||
|
|||||||
5
main.py
5
main.py
@@ -6,8 +6,9 @@ from db import get_bill_data, new_bill, update_bill_data, delete_bill
|
|||||||
from db import get_bill_ui, save_ui
|
from db import get_bill_ui, save_ui
|
||||||
from db import get_bill_types, insert_bill_type, update_bill_type, delete_bill_type, use_growth
|
from db import get_bill_types, insert_bill_type, update_bill_type, delete_bill_type, use_growth
|
||||||
from bills import process_bill_data
|
from bills import process_bill_data
|
||||||
|
from defines import END_YEAR
|
||||||
from collections import defaultdict, Counter
|
from collections import defaultdict, Counter
|
||||||
from datetime import datetime
|
from datetime import datetime, date
|
||||||
import csv
|
import csv
|
||||||
import io
|
import io
|
||||||
from disp import FP_VAR
|
from disp import FP_VAR
|
||||||
@@ -148,7 +149,7 @@ def DisplayBillData():
|
|||||||
bill_ui = get_bill_ui()
|
bill_ui = get_bill_ui()
|
||||||
process_bill_data(bill_data, bill_types, bill_freqs)
|
process_bill_data(bill_data, bill_types, bill_freqs)
|
||||||
bill_data = get_bill_data()
|
bill_data = get_bill_data()
|
||||||
return render_template('bills.html', bill_data=bill_data, bill_types=bill_types, bill_freqs=bill_freqs, bill_ui=bill_ui )
|
return render_template('bills.html', bill_data=bill_data, bill_types=bill_types, bill_freqs=bill_freqs, bill_ui=bill_ui, this_year=datetime.today().year, END_YEAR=END_YEAR )
|
||||||
|
|
||||||
@app.route('/newbilltype', methods=['POST'])
|
@app.route('/newbilltype', methods=['POST'])
|
||||||
def InsertBillType():
|
def InsertBillType():
|
||||||
|
|||||||
@@ -86,20 +86,22 @@
|
|||||||
<button id="bill-type-canc-{{bt.id}}" class="px-0 col-1 btn btn-danger bg-danger-subtle text-danger d-none" onClick="CancelUpdateBillType({{bt.id}}, '{{bt.name}}')"><span class="bi bi-x"> Cancel</button>
|
<button id="bill-type-canc-{{bt.id}}" class="px-0 col-1 btn btn-danger bg-danger-subtle text-danger d-none" onClick="CancelUpdateBillType({{bt.id}}, '{{bt.name}}')"><span class="bi bi-x"> Cancel</button>
|
||||||
</div>
|
</div>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
{% set total=namespace( sum=0 ) %}
|
{% for yr in range( this_year, END_YEAR) %}
|
||||||
{% for bd in bill_data %}
|
{% set total=namespace( sum=0 ) %}
|
||||||
{% if '2025' in bd['bill_date'] %}
|
{% for bd in bill_data %}
|
||||||
{% set total.sum = total.sum + bd['amount'] %}
|
{% if yr|string in bd['bill_date'] %}
|
||||||
{% endif %}
|
{% set total.sum = total.sum + bd['amount'] %}
|
||||||
|
{% endif %}
|
||||||
|
{% endfor %}
|
||||||
|
<div class="row">
|
||||||
|
<div class="pt-4 col text-end display-6">
|
||||||
|
Total bills in {{yr}}
|
||||||
|
</div>
|
||||||
|
<div class="pt-4 col display-6 text-primary">
|
||||||
|
${{'%.2f'|format(total.sum)}}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
<div class="row">
|
|
||||||
<div class="pt-4 col text-end display-6">
|
|
||||||
Total bills in 2025:
|
|
||||||
</div>
|
|
||||||
<div class="pt-4 col display-6 text-primary">
|
|
||||||
${{total.sum}}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- right-hand-side, bill types (e.g. gas, phone, etc.) -->
|
<!-- right-hand-side, bill types (e.g. gas, phone, etc.) -->
|
||||||
@@ -345,6 +347,8 @@
|
|||||||
|
|
||||||
function SaveTab( last_tab )
|
function SaveTab( last_tab )
|
||||||
{
|
{
|
||||||
|
// set the drop-down for new bill to be this tab now...
|
||||||
|
$("#new-bill-data-type").val( $('.nav-tabs .nav-link.active').prop('id').replace("tab-but-", "") )
|
||||||
$.ajax( { type: 'POST', url: '/saveui', contentType: 'application/json', data: JSON.stringify( { 'last_tab': last_tab } ), success: function() { } } )
|
$.ajax( { type: 'POST', url: '/saveui', contentType: 'application/json', data: JSON.stringify( { 'last_tab': last_tab } ), success: function() { } } )
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -367,6 +371,8 @@
|
|||||||
{% else %}
|
{% else %}
|
||||||
$('#tab-but-1').tab('show');
|
$('#tab-but-1').tab('show');
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
// make the new bill drop-down default to the same as the current tab
|
||||||
|
$("#new-bill-data-type").val( {{bill_ui.last_tab}} )
|
||||||
} )
|
} )
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
|
|||||||
Reference in New Issue
Block a user