incorporate bills for dates/amounts into calculations, still need to do future bills on triggers

This commit is contained in:
2025-09-03 22:35:24 +10:00
parent 4b63b8bd44
commit ebac4aaf66
4 changed files with 63 additions and 23 deletions

13
db.py
View File

@@ -271,12 +271,17 @@ def get_comp_set_options(finance):
conn.close()
return
def get_bill_data():
def get_bill_data(order_by):
conn = connect_db(True)
cur = conn.cursor()
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''')
if order_by == "order_by_date_only":
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 bd.bill_date desc''')
else:
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()
conn.close()
return bd