redo the way we do padding to be much more accurate
This commit is contained in:
2
db.py
2
db.py
@@ -90,7 +90,7 @@ def init_db():
|
||||
if cur.fetchone()[0] == 0:
|
||||
###
|
||||
# For now manually update below on the fortnight of the original pay shcedule to compare saved version vs. our reality. Update:
|
||||
# Savings (Macq+me bank) -- noting ME bank is: $1329.68
|
||||
# Savings (Macq+me bank) -- noting ME bank is: $1434.3
|
||||
# TLS/CBA prices
|
||||
# Interest rate
|
||||
# D_leave_owed_in_days
|
||||
|
||||
19
main.py
19
main.py
@@ -2,7 +2,7 @@
|
||||
from flask import Flask, render_template, request, redirect, url_for, Response, jsonify
|
||||
from calc import calculate_savings_depletion
|
||||
from db import init_db, get_finance_data, update_finance, get_budget_data, insert_cset, get_comp_set_data, get_comp_set_options
|
||||
from collections import defaultdict
|
||||
from collections import defaultdict, Counter
|
||||
from datetime import datetime
|
||||
import csv
|
||||
import io
|
||||
@@ -80,7 +80,22 @@ def index():
|
||||
DISP.append(r)
|
||||
|
||||
now=datetime.today().strftime('%Y-%m-%d')
|
||||
return render_template('index.html', now=now, finance=finance_data, depletion_date=depletion_date, savings=savings_per_fortnight, BUDGET=BUDGET, COMP=COMP, DISP=DISP)
|
||||
|
||||
# Extract years from the date strings
|
||||
years = [datetime.strptime(date, "%Y-%m-%d").year for date, _ in savings_per_fortnight]
|
||||
|
||||
# Count how many times each year appears
|
||||
year_counts = Counter(years)
|
||||
# Sort the items by year
|
||||
sorted_years = sorted(year_counts.items()) # List of (year, count) tuples
|
||||
|
||||
# Access the first and second years
|
||||
first_yr, first_count = sorted_years[0]
|
||||
second_yr, second_count = sorted_years[1]
|
||||
|
||||
# now work out how much padding we need in the first year to align the last dates for all years
|
||||
padding=second_count - first_count
|
||||
return render_template('index.html', now=now, first_yr=first_yr, padding=padding, finance=finance_data, depletion_date=depletion_date, savings=savings_per_fortnight, BUDGET=BUDGET, COMP=COMP, DISP=DISP)
|
||||
|
||||
@app.route('/save', methods=['POST'])
|
||||
def save():
|
||||
|
||||
@@ -93,27 +93,15 @@
|
||||
<div class="row">
|
||||
<div class="col-auto"> <div class="pt-1 pb-1 mb-0 alert text-center" style="background:lemonchiffon">2025</div>
|
||||
|
||||
{% set first_yr=2025 %}
|
||||
{% set started=namespace( val=0 ) %}
|
||||
{% set mon_cnt=namespace( now=4 ) %}
|
||||
{# inside started if below, we add blank lines to the start of the year so the dates line up #}
|
||||
{% for _ in range( 0, padding ) %}
|
||||
<br>
|
||||
{% endfor %}
|
||||
|
||||
{% for date, dollars in savings %}
|
||||
{% set yr=date[:4] %}
|
||||
{% set mon=date[5:7] %}
|
||||
{% set day=date[8:10 ] %}
|
||||
{# inside started if below, we add blank lines to the start of the year so the dates line up #}
|
||||
{% if started.val == 0 %}
|
||||
{% if day|int > 14 %}
|
||||
<br>
|
||||
{% else %}
|
||||
<br>
|
||||
<br>
|
||||
{% endif %}
|
||||
{% for _ in range( 1, 2*mon_cnt.now ) %}
|
||||
<br>
|
||||
{% endfor %}
|
||||
|
||||
{% set started.val = 1 %}
|
||||
{% endif %}
|
||||
|
||||
{% if yr|int > first_yr|int and mon == '01' and day|int <= 14 %}
|
||||
</div><div class="col-auto">
|
||||
|
||||
Reference in New Issue
Block a user