replaced ann_growth with ann_growth_min, ann_growth_avg, ann_growth_max in DB
This commit is contained in:
19
db.py
19
db.py
@@ -88,7 +88,9 @@ def init_db():
|
|||||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||||
freq INTEGER,
|
freq INTEGER,
|
||||||
name STRING,
|
name STRING,
|
||||||
ann_growth REAL,
|
ann_growth_min REAL,
|
||||||
|
ann_growth_avg REAL,
|
||||||
|
ann_growth_max REAL,
|
||||||
FOREIGN KEY(freq) REFERENCES bill_freq(id)
|
FOREIGN KEY(freq) REFERENCES bill_freq(id)
|
||||||
)''')
|
)''')
|
||||||
|
|
||||||
@@ -103,6 +105,7 @@ def init_db():
|
|||||||
bill_type INTEGER,
|
bill_type INTEGER,
|
||||||
amount INTEGER,
|
amount INTEGER,
|
||||||
bill_date DATE,
|
bill_date DATE,
|
||||||
|
estimated INTEGER,
|
||||||
FOREIGN KEY(bill_type) REFERENCES bill_type(id)
|
FOREIGN KEY(bill_type) REFERENCES bill_type(id)
|
||||||
)''')
|
)''')
|
||||||
|
|
||||||
@@ -260,7 +263,9 @@ def get_comp_set_options(finance):
|
|||||||
def get_bill_data():
|
def get_bill_data():
|
||||||
conn = connect_db(True)
|
conn = connect_db(True)
|
||||||
cur = conn.cursor()
|
cur = conn.cursor()
|
||||||
cur.execute('SELECT bd.id, bt.id as bill_type_id, bt.name, bd.amount, bd.bill_date FROM bill_type bt, bill_data bd where bt.id = bd.bill_type order by bt.name, bd.bill_date desc')
|
cur.execute('''SELECT bd.id, bt.id as bill_type_id, bt.name, bd.amount, bd.bill_date, bd.estimated
|
||||||
|
FROM bill_type bt, bill_data bd
|
||||||
|
where bt.id = bd.bill_type order by bt.name, bd.bill_date desc''')
|
||||||
bd = cur.fetchall()
|
bd = cur.fetchall()
|
||||||
conn.close()
|
conn.close()
|
||||||
return bd
|
return bd
|
||||||
@@ -282,10 +287,10 @@ def get_bill_freqs():
|
|||||||
return bf
|
return bf
|
||||||
|
|
||||||
|
|
||||||
def new_bill( name, amount, bill_date ):
|
def new_bill( bill_type, amount, bill_date, estimated ):
|
||||||
conn = connect_db(False)
|
conn = connect_db(False)
|
||||||
cur = conn.cursor()
|
cur = conn.cursor()
|
||||||
cur.execute( f"insert into bill_data ( 'bill_type', 'amount', 'bill_date' ) values ( '{name}', '{amount}', '{bill_date}' )" )
|
cur.execute( f"insert into bill_data ( 'bill_type', 'amount', 'bill_date', 'estimated' ) values ( '{bill_type}', '{amount}', '{bill_date}', {estimated} )" )
|
||||||
conn.commit()
|
conn.commit()
|
||||||
conn.close()
|
conn.close()
|
||||||
return
|
return
|
||||||
@@ -302,7 +307,7 @@ def insert_bill_type( bt, fq ):
|
|||||||
conn = connect_db(False)
|
conn = connect_db(False)
|
||||||
cur = conn.cursor()
|
cur = conn.cursor()
|
||||||
print( f"fq={fq}" )
|
print( f"fq={fq}" )
|
||||||
cur.execute( f"insert into bill_type ( 'name', 'freq', 'ann_growth' ) values ( '{bt}', {fq}, 0 )" )
|
cur.execute( f"insert into bill_type ( 'name', 'freq', 'ann_growth_min', 'ann_growth_avg', 'ann_growth_max' ) values ( '{bt}', {fq}, 0, 0, 0 )" )
|
||||||
conn.commit()
|
conn.commit()
|
||||||
conn.close()
|
conn.close()
|
||||||
return
|
return
|
||||||
@@ -331,10 +336,10 @@ def delete_bill_type( id ):
|
|||||||
conn.close()
|
conn.close()
|
||||||
return
|
return
|
||||||
|
|
||||||
def set_bill_type_growth( id, g ):
|
def set_bill_type_growth( id, min_g, avg_g, max_g ):
|
||||||
conn = connect_db(False)
|
conn = connect_db(False)
|
||||||
cur = conn.cursor()
|
cur = conn.cursor()
|
||||||
cur.execute( f"update bill_type set ann_growth ='{g}' where id = {id}" )
|
cur.execute( f"update bill_type set ann_growth_min='{min_g}', ann_growth_avg ='{avg_g}', ann_growth_max='{max_g}' where id = {id}" )
|
||||||
conn.commit()
|
conn.commit()
|
||||||
conn.close()
|
conn.close()
|
||||||
return
|
return
|
||||||
|
|||||||
Reference in New Issue
Block a user