diff --git a/TODO b/TODO index 7ded265..d7c1e04 100644 --- a/TODO +++ b/TODO @@ -3,8 +3,6 @@ CALC: differently, but hard to calc - slides around with tax brackets in future UI: - * have a comparison management capability - somehow, at least be able to delete csets (can I put an x inside the menu? OR, have a manage button and pop-up?) - * maybe a help/note/set of links somehow, to common things: e.g. macquarie int rate page, inflation source, etc. - also then could effectively take those "notes" out of db.py and incorporate, so that when I update stuff it gets done right - in fact, I *COULD* have a basic date check/workflow, e.g. its been more than X days since Y was updated, click here diff --git a/db.py b/db.py index 9e1a413..c65cb6d 100644 --- a/db.py +++ b/db.py @@ -404,3 +404,11 @@ def delete_estimated_bills(): conn.commit() conn.close() return + +def delete_cset(id): + conn = connect_db(False) + cur = conn.cursor() + cur.execute( f"delete from comparison_set where id = '{id}'" ) + conn.commit() + conn.close() + return diff --git a/main.py b/main.py index e886fb8..3fc08c0 100644 --- a/main.py +++ b/main.py @@ -3,7 +3,7 @@ from flask import Flask, render_template, request, redirect, url_for, Response, 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, delete_estimated_bills -from db import get_bill_ui, save_ui +from db import get_bill_ui, save_ui, delete_cset 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 from defines import END_YEAR @@ -220,6 +220,32 @@ def force_recalc_bills(): delete_estimated_bills() return "200" +@app.route('/cset') +def cset(): + finance_data = get_finance_data() + get_comp_set_options(finance_data) + comp_data={} + for el in finance_data['COMP_SETS']: + comp_data[el[0]] = get_comp_set_data( el[0] ) + # delete items not that helpful (same for all, not that interesting) + if el[0]: + del comp_data[el[0]]['vars']['Car_loan_via_pay'] + del comp_data[el[0]]['vars']['Mark_reno'] + del comp_data[el[0]]['vars']['Mark_reno_date'] + del comp_data[el[0]]['vars']['Overseas_trip_date'] + del comp_data[el[0]]['vars']['Car_balloon'] + del comp_data[el[0]]['vars']['Mich_present'] + del comp_data[el[0]]['vars']['D_TLS_shares'] + del comp_data[el[0]]['vars']['M_TLS_shares'] + + return render_template('cset.html', finance=finance_data, comp_data=comp_data ) + +@app.route('/delcset', methods=['POST']) +def DeleteCSet(): + data = request.get_json() + delete_cset( data['id'] ) + return "200" + # Main program if __name__ == '__main__': app.run(debug=True) diff --git a/templates/bills.html b/templates/bills.html index 96c12e8..a822882 100644 --- a/templates/bills.html +++ b/templates/bills.html @@ -475,4 +475,3 @@ - diff --git a/templates/index.html b/templates/index.html index 6c5cae6..a1030f7 100644 --- a/templates/index.html +++ b/templates/index.html @@ -19,7 +19,7 @@
-

Finance Tracker (go to Bills)

+

Finance Tracker (go to Bills or Comparison Sets)

{% for r in DISP %} @@ -389,4 +389,3 @@
-