diff --git a/db.py b/db.py index f464c69..9e1a413 100644 --- a/db.py +++ b/db.py @@ -395,3 +395,12 @@ def save_ui(data): conn.commit() conn.close() return + + +def delete_estimated_bills(): + conn = connect_db(False) + cur = conn.cursor() + cur.execute( "delete from bill_data where estimated=1" ) + conn.commit() + conn.close() + return diff --git a/main.py b/main.py index 357b64a..e886fb8 100644 --- a/main.py +++ b/main.py @@ -2,7 +2,7 @@ from flask import Flask, render_template, request, redirect, url_for, Response, jsonify from calc import calculate_savings_depletion, calc_key_dates from db import init_db, get_finance_data, update_finance, get_budget_data, insert_cset, get_comp_set_data, get_comp_set_options, get_bill_freqs -from db import get_bill_data, new_bill, update_bill_data, delete_bill +from db import get_bill_data, new_bill, update_bill_data, delete_bill, delete_estimated_bills from db import get_bill_ui, save_ui from db import get_bill_types, insert_bill_type, update_bill_type, delete_bill_type, use_growth from bills import process_bill_data, calc_future_totals, set_bill_type_growth @@ -142,6 +142,7 @@ def update(): request.form['Ioniq6_future'] ) update_finance(finance_data) + # FIXME: need code here to delete/rebuild future bills if we change "D # Pays to quit " return redirect(url_for('index')) @app.route('/bills') @@ -214,6 +215,10 @@ def SaveUI(): save_ui( data ) return "200" +@app.route('/force_recalc_bills', methods=['POST']) +def force_recalc_bills(): + delete_estimated_bills() + return "200" # Main program if __name__ == '__main__': diff --git a/templates/bills.html b/templates/bills.html index 168e17f..96c12e8 100644 --- a/templates/bills.html +++ b/templates/bills.html @@ -52,6 +52,7 @@ +
@@ -131,7 +132,7 @@ -
+
Bill Type
Date
@@ -466,6 +467,11 @@ }); }); + function ForceRecalcBills() + { + $.ajax( { type: 'POST', url: '/force_recalc_bills', contentType: 'application/json', success: function() { window.location='bills' } } ) + } +