From b7768d767c3ac7e1b404cf70495b15c685461ded Mon Sep 17 00:00:00 2001 From: Damien De Paoli Date: Thu, 6 Feb 2025 10:11:45 +1100 Subject: [PATCH] first hard-coded version of a compare capability --- main.py | 7 ++++++- templates/index.html | 25 +++++++++++++++++++++++-- 2 files changed, 29 insertions(+), 3 deletions(-) diff --git a/main.py b/main.py index a5e8149..2223b0f 100644 --- a/main.py +++ b/main.py @@ -20,7 +20,12 @@ def index(): if depletion_date: depletion_date=depletion_date.date(); # just show date - return render_template('index.html', finance=finance_data, depletion_date=depletion_date, savings=savings_per_fortnight, TLS=TLS, CBA=CBA, BUDGET=BUDGET) + # work out comparison func, but hardcode for now: + COMP={} + COMP['date']='2025-02-05' + COMP['amount']=414887 + + return render_template('index.html', finance=finance_data, depletion_date=depletion_date, savings=savings_per_fortnight, TLS=TLS, CBA=CBA, BUDGET=BUDGET, COMP=COMP) @app.route('/update', methods=['POST']) def update(): diff --git a/templates/index.html b/templates/index.html index 728f27c..816f959 100644 --- a/templates/index.html +++ b/templates/index.html @@ -206,18 +206,39 @@ window.onload = function() {

We DONT run out of money before super kicks in!!! -- Details:

{% endif %} + {% if COMP %} +
Note: value in blue below is value we should have been at when comparing to saved values
+ {% endif %} + +
+ {# get comparison date so we can use it below in loop to know when to print it out #} + {% set comp_yr=COMP['date'][:4] %} + {% set comp_mon=COMP['date'][5:7] %} + {% set comp_day=COMP['date'][8:10 ] %} + {% set comp_done=namespace( val=0 ) %} + {% set first_yr=2025 %} {% for date, dollars in savings %} {% set yr=date[:4] %} {% set mon=date[5:7] %} {% set day=date[8:10 ] %} - {% if yr|int > first_yr|int and mon == '01' and day|int <= 14 %} -       + + {% if comp_done.val == 0 and yr == comp_yr and mon == comp_mon and day|int >= comp_day|int %} + + {{ COMP['date'] }}:  + {{ '$%0.2f' % COMP['amount']|float }}
+
+ {% set comp_done.val=1 %} {% endif %} + {% if yr|int > first_yr|int and mon == '01' and day|int <= 14 %} +
      + {% endif %} + {{ date }}:  {{ '$%0.2f' % dollars|float }}
+
{% endfor %}
     SUMMARY/BUDGET
{% for label, value in BUDGET %}