Compare commits

...

5 Commits

5 changed files with 65 additions and 5 deletions

11
BUGS
View File

@@ -7,3 +7,14 @@
- something to do with missing year of data in quarterly bills - still an issue
* if change a bill (like Amazon), then its future estimates don't update
- recalc does fix, so a simple delete future bills for this bill type and
re-estiate will do it, BUT, its a simple POST now...
I think a re-write of functions in bills may be needed, so that we can
pull out future estimates based on growth (that may need to change due to
this changed amount), etc.
- also occurs if we delete a bill
-- but on the +ve side, changing growth toggle, resets future bills -
so can call UseGrowth( bt_id )
SO only missing bit would be to recalculate growth based on existing
bills for this bill type.... SO, may not need to redo code everywhere,
but should consider it anyway

6
TODO
View File

@@ -1,7 +1,9 @@
bills:
bill for the year (when removed from LE, should be dynamic)
* bill for the year (when removed from LE, should be dynamic)
- REQUIRES REWRITE OF BILLS TO BE HEADLESS and then called from UI/maybe more ajax
- noting BUT also requires above
bills html, and growth types are poor code repitition / lame... could I do something more like:
* bills html, and growth types are poor code repetition / lame... could I do something more like:
{% for gt in growth %}
{% if gt.name == 'Min' %}
<option value='min'

View File

@@ -285,8 +285,10 @@ def calculate_savings_depletion(finance, bill_data, bill_type):
D_CBA_shares -= 1
Sell_shares -= 1
current_savings += actual_sell
add_annotation(finance, current_date, current_savings, actual_sell, "Sell shares" )
# can run out, if so, no need to add :)
if actual_sell>0:
current_savings += actual_sell
add_annotation(finance, current_date, current_savings, actual_sell, "Sell shares" )
current_date += timedelta(days=1)

4
db.py
View File

@@ -100,6 +100,7 @@ def init_db():
ann_growth_avg REAL,
ann_growth_max REAL,
ann_growth_simple REAL,
which_growth STRING,
FOREIGN KEY(freq) REFERENCES bill_freq(id)
)''')
@@ -379,7 +380,7 @@ def insert_bill_type( bt, fq ):
conn = connect_db(False)
cur = conn.cursor()
print( f"fq={fq}" )
cur.execute( f"insert into bill_type ( 'name', 'freq', 'ann_growth_min', 'ann_growth_avg', 'ann_growth_max', 'ann_growth_simple' ) values ( '{bt}', {fq}, 0, 0, 0, 0 )" )
cur.execute( f"insert into bill_type ( name, freq, ann_growth_min, ann_growth_avg, ann_growth_max, ann_growth_simple, which_growth ) values ( '{bt}', {fq}, 0, 0, 0, 0, 'cpi' )" )
conn.commit()
conn.close()
return
@@ -403,6 +404,7 @@ def delete_bill(id):
def delete_bill_type( id ):
conn = connect_db(False)
cur = conn.cursor()
cur.execute( f"delete from bill_data where bill_type = '{id}'" )
cur.execute( f"delete from bill_type where id = '{id}'" )
conn.commit()
conn.close()

View File

@@ -15,6 +15,8 @@
<script src="https://code.highcharts.com/modules/annotations.js"></script>
<script src="https://code.highcharts.com/modules/accessibility.js"></script>
<script src="https://code.highcharts.com/themes/adaptive.js"></script>
<script src="https://code.highcharts.com/modules/exporting.js"></script>
<script src="https://code.highcharts.com/modules/fullscreen.js"></script>
<style>
.col-form-label { width:140px; }
html { font-size: 75% !important; }
@@ -417,7 +419,48 @@
]
});
{% endif %}
}
);
$(document).ready(function() {
// 1. The Resizing Logic
function fitChartsToWindow() {
// Targets any div with your highcharts class that is currently visible
$('.tab-pane.active .highcharts-dark').each(function() {
var $chartDiv = $(this);
var chart = $chartDiv.highcharts();
if (chart) {
// Get position of chart relative to the viewport
var topPos = $chartDiv[0].getBoundingClientRect().top;
// Calculate remaining height (subtracting 5-10px for safety)
var remainingHeight = window.innerHeight - topPos - 10;
// Apply height and reflow
$chartDiv.css('height', remainingHeight + 'px');
chart.reflow();
}
});
}
// 2. Trigger when switching tabs
$('button[data-bs-toggle="tab"]').on('shown.bs.tab', function() {
fitChartsToWindow();
});
// 3. Trigger when window is resized
$(window).on('resize', function() {
fitChartsToWindow();
});
// 4. Initial call (in case the first tab is a graph)
// Wrap in a small timeout to ensure Bootstrap finish rendering
setTimeout(fitChartsToWindow, 100);
});
</script>
<div id="save_modal" class="modal modal-lg" tabindex="-1">
<div class="modal-dialog">