diff --git a/budget.py b/budget.py
index 08fbd1a..35db76f 100644
--- a/budget.py
+++ b/budget.py
@@ -16,6 +16,7 @@ def init_db():
debit REAL DEFAULT 0,
amount REAL NOT NULL,
description TEXT,
+ desc_2 TEXT,
created_at TEXT NOT NULL
)
""")
@@ -46,20 +47,20 @@ HTML = """
<title>Budget Tracker</title>
<style>
body {{
- font-family: sans-serif;
- max-width: 600px;
- margin: 40px auto;
+ font-family: sans-serif;
+ max-width: 600px;
+ margin: 40px auto;
}}
- input, button {{
- padding: 8px;
- font-size: 16px;
+ input, select, button {{
+ padding: 8px;
+ font-size: 16px;
}}
.card {{
- border: 1px solid #ccc;
- padding: 16px;
- margin-top: 20px;
+ border: 1px solid #ccc;
+ padding: 16px;
+ margin-top: 20px;
max-width: 50%;
}}
</style>
@@ -70,7 +71,24 @@ input, button {{
<form method="POST" action="/add">
<input name="amount" type="text" placeholder="Amount (+ or -)" required>
- <input name="description" type="text" placeholder="Description (optional)">
+ <select name="description" required>
+ <option value="Amazon Prime">Amazon Prime</option>
+ <option value="Cash" selected>Cash</option>
+ <option value="Council Tax">Council Tax</option>
+ <option value="Credit card">Credit card</option>
+ <option value="Energy bill">Energy bill</option>
+ <option value="Fuel">Fuel</option>
+ <option value="Other">Other</option>
+ <option value="Rent">Rent</option>
+ <option value="Salary">Salary</option>
+ <option value="Savings">Savings</option>
+ <option value="Shopping">Shopping</option>
+ <option value="Sky TV">Sky TV</option>
+ <option value="TV Licence">TV Licence</option>
+ <option value="Virgin Media">Virgin Media</option>
+ <option value="Water">Water</option>
+ </select>
+ <input name="desc_2" type="text" placeholder="Optional second description">
<button type="submit">Add</button>
</form>
@@ -115,6 +133,7 @@ class Handler(BaseHTTPRequestHandler):
amount = float(data["amount"][0])
description = data.get("description", [""])[0]
+ desc_2 = data.get("desc_2", [""])[0]
# Determine if the amount should be credit or debit
if amount > 0:
@@ -126,8 +145,8 @@ class Handler(BaseHTTPRequestHandler):
with sqlite3.connect(DB) as conn:
conn.execute(
- "INSERT INTO entries(credit, debit, amount, description, created_at) VALUES (?, ?, ?, ?, ?)",
- (credit, debit, amount, description, datetime.now().isoformat())
+ "INSERT INTO entries(credit, debit, amount, description, desc_2, created_at) VALUES (?, ?, ?, ?, ?, ?)",
+ (credit, debit, amount, description, desc_2, datetime.now().isoformat())
)
self.send_response(303)