format totals per year and based on dates/END_YEAR
This commit is contained in:
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.) -->
|
||||||
|
|||||||
Reference in New Issue
Block a user