diff --git a/budget.py b/budget.py
index c59cb30..55b9714 100644
--- a/budget.py
+++ b/budget.py
@@ -46,6 +46,11 @@ def get_month_total():
""", (start.isoformat(), end.isoformat()))
return cur.fetchone()[0]
+ def get_total_budget_amount():
+ with sqlite3.connect(DB) as conn:
+ cur = conn.execute("SELECT COALESCE(SUM(planned_amount), 0) FROM budget")
+ return cur.fetchone()[0]
+
def get_budget_items():
with sqlite3.connect(DB) as conn:
conn.row_factory = sqlite3.Row
@@ -173,7 +178,9 @@ function autoFillAmount() {{
<div class="card">
<h2>This Month</h2>
- <p>{month:.2f}</p>
+ <p>Total: {month:.2f}</p>
+ <p>Budget total: {total_budget_amount:.2f}</p>
+ <p>Projected remaining bal: {projected_remaining:.2f}</p>
</div>
<div class="card">
@@ -205,6 +212,8 @@ class Handler(BaseHTTPRequestHandler):
if self.path == "/":
balance = get_balance()
month = get_month_total()
+ total_budget_amount = get_total_budget_amount()
+ projected_remaining = month - total_budget_amount
budget_items = get_budget_items()
budget_rows = ""
@@ -221,7 +230,7 @@ class Handler(BaseHTTPRequestHandler):
</tr>
"""
- page = HTML.format(balance=balance, month=month, budget_rows=budget_rows)
+ page = HTML.format(balance=balance, month=month, total_budget_amount=total_budget_amount, projected_remaining=projected_remaining, budget_rows=budget_rows)
self.send_response(200)
self.send_header("Content-type", "text/html")