Compare commits
3 Commits
2bdd1348b8
...
8f69023ffd
| Author | SHA1 | Date | |
|---|---|---|---|
| 8f69023ffd | |||
| d2bf472845 | |||
| e84faffd79 |
24
TODO
24
TODO
@@ -1,29 +1,7 @@
|
||||
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:
|
||||
* gas bills are a mess and more than 4 per year... *SIGH* try this:
|
||||
- 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
|
||||
[DONE] - calculate pragmatic min/avg/max/simple
|
||||
- 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
|
||||
- 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 ):
|
||||
conn = connect_db(False)
|
||||
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:
|
||||
# delete old estimates as new bill will potentially change them/growth, etc.
|
||||
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} )" )
|
||||
conn.commit()
|
||||
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_types, insert_bill_type, update_bill_type, delete_bill_type, use_growth
|
||||
from bills import process_bill_data
|
||||
from defines import END_YEAR
|
||||
from collections import defaultdict, Counter
|
||||
from datetime import datetime
|
||||
from datetime import datetime, date
|
||||
import csv
|
||||
import io
|
||||
from disp import FP_VAR
|
||||
@@ -148,7 +149,7 @@ def DisplayBillData():
|
||||
bill_ui = get_bill_ui()
|
||||
process_bill_data(bill_data, bill_types, bill_freqs)
|
||||
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'])
|
||||
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>
|
||||
</div>
|
||||
{% endfor %}
|
||||
{% set total=namespace( sum=0 ) %}
|
||||
{% for bd in bill_data %}
|
||||
{% if '2025' in bd['bill_date'] %}
|
||||
{% set total.sum = total.sum + bd['amount'] %}
|
||||
{% endif %}
|
||||
{% for yr in range( this_year, END_YEAR) %}
|
||||
{% set total=namespace( sum=0 ) %}
|
||||
{% for bd in bill_data %}
|
||||
{% if yr|string in bd['bill_date'] %}
|
||||
{% 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 %}
|
||||
<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>
|
||||
|
||||
<!-- right-hand-side, bill types (e.g. gas, phone, etc.) -->
|
||||
@@ -345,6 +347,8 @@
|
||||
|
||||
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() { } } )
|
||||
}
|
||||
|
||||
@@ -367,6 +371,8 @@
|
||||
{% else %}
|
||||
$('#tab-but-1').tab('show');
|
||||
{% 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>
|
||||
</body>
|
||||
|
||||
Reference in New Issue
Block a user