Compare commits
8 Commits
e7a3cb3d7d
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
| 71606035fd | |||
| b8c1edc084 | |||
| f0fee15548 | |||
| 20239d72c8 | |||
| e3d2d8ea08 | |||
| 8446f59740 | |||
| 3a04b8321c | |||
| 037a9c2d87 |
3
BUGS
3
BUGS
@@ -1,3 +1,6 @@
|
||||
* can put in dumb dates - DO SOME INPUT VALIDATION, *sigh*
|
||||
- e.g. 0026-02-19 for a Gas bill
|
||||
|
||||
* kayo bills are wrong in between normal bills
|
||||
|
||||
* added an electricity bill by accident for 2018, that kills lots :(
|
||||
|
||||
5
bills.py
5
bills.py
@@ -643,8 +643,7 @@ def recalcFutureBills():
|
||||
for fb in future_car_bills:
|
||||
amt=fb['amount']
|
||||
bt=fb['bill_type']
|
||||
# only can use simple growth as its a future bill
|
||||
growth=bill_types[bt]['ann_growth_simple']
|
||||
growth = get_growth_value( bill_types, bt )
|
||||
# factor in growth for next bills
|
||||
for yr in range( int(car_yr), END_YEAR+1 ):
|
||||
new_date=f"{yr}-{car_mmdd}"
|
||||
@@ -661,7 +660,7 @@ def recalcFutureBills():
|
||||
# deal with future bills due to their starting dates being dynamic
|
||||
amt=fb['amount']
|
||||
bt=fb['bill_type']
|
||||
growth=bill_types[bt]['ann_growth_simple']
|
||||
growth = get_growth_value( bill_types, bt )
|
||||
num_ann_bills= bf_id_num[bt_id_freq[bt]]
|
||||
if num_ann_bills == 1:
|
||||
# factor in growth for next bill
|
||||
|
||||
2
db.py
2
db.py
@@ -8,6 +8,8 @@ def connect_db(as_object):
|
||||
conn = sqlite3.connect('/data/finance.db')
|
||||
else:
|
||||
conn = sqlite3.connect('./finance.db')
|
||||
# allow deleting cset to clear our compare_to properly in finance table
|
||||
conn.execute("PRAGMA foreign_keys = ON;")
|
||||
if as_object:
|
||||
conn.row_factory = sqlite3.Row # This allows us to access columns by name
|
||||
return conn
|
||||
|
||||
16
main.py
16
main.py
@@ -41,7 +41,10 @@ def index():
|
||||
depletion_date=depletion_date.date(); # just show date
|
||||
|
||||
# if we are comparing...(compare_to will be 0 / None to start with, and then COMP will be None
|
||||
COMP=get_comp_set_data(finance_data['compare_to'])
|
||||
if finance_data['compare_to']:
|
||||
COMP=get_comp_set_data(finance_data['compare_to'])
|
||||
else:
|
||||
COMP={}
|
||||
|
||||
DISP=[]
|
||||
# Row 1
|
||||
@@ -114,14 +117,18 @@ def index():
|
||||
|
||||
@app.route('/save', methods=['POST'])
|
||||
def save():
|
||||
insert_cset( request.get_json() )
|
||||
return "200"
|
||||
cset_id=insert_cset( request.get_json() )
|
||||
name = request.get_json()['vars']['name']
|
||||
return jsonify( cset_id=cset_id, name=name )
|
||||
|
||||
@app.route('/update', methods=['POST'])
|
||||
def update():
|
||||
|
||||
old_finance_data = get_finance_data()
|
||||
|
||||
raw_compare_to = request.form.get('compare_to')
|
||||
compare_to_value = None if raw_compare_to == "0" else int(raw_compare_to)
|
||||
|
||||
finance_data = (
|
||||
request.form['D_Salary'],
|
||||
request.form['D_Num_fortnights_pay'],
|
||||
@@ -147,9 +154,10 @@ def update():
|
||||
request.form['Mark_reno_date'],
|
||||
request.form['Car_buyout_date'],
|
||||
request.form['Sell_shares'],
|
||||
request.form['compare_to'],
|
||||
compare_to_value,
|
||||
request.form['Ioniq6_future']
|
||||
)
|
||||
|
||||
update_finance(finance_data)
|
||||
new_finance_data = get_finance_data()
|
||||
# changed Ioniq6_future, Car_buyout_date or D_Num_fortnights_pay, so lets force recalc key_dates, and therefore estimated bills
|
||||
|
||||
@@ -456,7 +456,7 @@
|
||||
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-", "") )
|
||||
$("#new-bill-data-type").val( $('.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() { } } )
|
||||
}
|
||||
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
|
||||
<script src="https://code.jquery.com/jquery-3.7.1.min.js" integrity="sha256-/JqT3SQfawRcv/BIHPThkBvs0OEvtFFmqPF/lYI/Cxo=" crossorigin="anonymous"></script>
|
||||
<script src="https://code.highcharts.com/highcharts.js"></script>
|
||||
<script src="https://code.highcharts.com/modules/mouse-wheel-zoom.js"></script>
|
||||
<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>
|
||||
@@ -229,7 +230,12 @@
|
||||
$(function() { $('[data-bs-toggle="popover"]').popover(); });
|
||||
window.onload = function() {
|
||||
$('#Sell_shares').val( {{finance['Sell_shares']}} )
|
||||
$('#compare_to').val( {{finance['compare_to']}} )
|
||||
{% if finance['compare_to'] %}
|
||||
$('#compare_to').val( {{finance['compare_to']}} )
|
||||
{% else %}
|
||||
// set this to Nothing by default
|
||||
$('#compare_to').val( 0 )
|
||||
{% endif %}
|
||||
$('#Ioniq6_future').val( {{finance['Ioniq6_future']}} )
|
||||
|
||||
if( $("#Ioniq6_future option:selected"). text() == 'lease' )
|
||||
@@ -358,7 +364,7 @@
|
||||
|
||||
// Highcharts configuration
|
||||
Highcharts.chart('graph', {
|
||||
chart: { type: 'line' },
|
||||
chart: { type: 'line', zooming: { type: 'x' } },
|
||||
colors: [ 'orange' ],
|
||||
title: { text: 'Savings Over Time' },
|
||||
xAxis: {
|
||||
@@ -385,7 +391,7 @@
|
||||
{% if COMP %}
|
||||
// Highcharts configuration
|
||||
Highcharts.chart('graph-comp', {
|
||||
chart: { type: 'line' },
|
||||
chart: { type: 'line', zooming: { type: 'x' } },
|
||||
colors: [
|
||||
'orange', // Custom color 1
|
||||
'cyan', // Custom color 2
|
||||
@@ -433,13 +439,17 @@
|
||||
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Cancel</button>
|
||||
<button type="button" class="btn btn-info"
|
||||
onClick="
|
||||
vars['name']=$('#save_name').val();
|
||||
$.ajax( {
|
||||
type: 'POST',
|
||||
url: '/save',
|
||||
vars['name'] = $('#save_name').val();
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
url: '/save',
|
||||
contentType: 'application/json',
|
||||
data: JSON.stringify( { 'vars': vars, 'savings_data' :savingsData } ),
|
||||
success: function() { $('#save_modal').modal('hide'); } } )"
|
||||
data: JSON.stringify({ 'vars': vars, 'savings_data': savingsData }),
|
||||
success: function(resp) {
|
||||
$('#save_modal').modal('hide');
|
||||
$('#compare_to').append($('<option>', { value: resp.cset_id, text: resp.name }));
|
||||
}
|
||||
});"
|
||||
>Save</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user