Compare commits

...

4 Commits

5 changed files with 31 additions and 18 deletions

6
BUGS
View File

@@ -1,12 +1,6 @@
* when I delete a comp_set && it is the current compare_to, then need to reset compare_to to 'Nothing'
* with future bills - recalculate bills button blows away growth!
- BUT, I think just loading the bills page puts it back -- need to validate and fix if so
* with new vertical lay-out, the autosetting of the bill_type when I click add
bill no longer sets to the tab I am viewing
-- also keeps going back to Gas for some reason?
* can put in dumb dates - DO SOME INPUT VALIDATION, *sigh*
- e.g. 0026-02-19 for a Gas bill

2
db.py
View File

@@ -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

14
main.py
View File

@@ -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
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

View File

@@ -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() { } } )
}

View File

@@ -230,7 +230,12 @@
$(function() { $('[data-bs-toggle="popover"]').popover(); });
window.onload = function() {
$('#Sell_shares').val( {{finance['Sell_shares']}} )
{% 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' )
@@ -440,7 +445,11 @@
url: '/save',
contentType: 'application/json',
data: JSON.stringify({ 'vars': vars, 'savings_data': savingsData }),
success: function() { $('#save_modal').modal('hide'); } } )"
success: function(resp) {
$('#save_modal').modal('hide');
$('#compare_to').append($('<option>', { value: resp.cset_id, text: resp.name }));
}
});"
>Save</button>
</div>
</div>