From f473c09a26f90e3306916ecbec895838ceb88589 Mon Sep 17 00:00:00 2001 From: Connor Rhodes Date: Wed, 20 May 2026 17:52:08 -0500 Subject: [PATCH] Add airport address alias to log-work-expense skill --- log-work-expense/SKILL.md | 19 +++++++++++++- log-work-expense/scripts/log_expense.py | 35 ++++++++++++++++++++++--- 2 files changed, 50 insertions(+), 4 deletions(-) diff --git a/log-work-expense/SKILL.md b/log-work-expense/SKILL.md index f38a955..f84bb64 100644 --- a/log-work-expense/SKILL.md +++ b/log-work-expense/SKILL.md @@ -25,7 +25,7 @@ Log work expenses into `wip.work_expenses` via `scripts/log_expense.py`. 4. **Insert via script** — Run the script once **per entry**: ```bash -uv run --with pymongo ~/notes/skills/log-work-expense/scripts/log_expense.py "" [s2_url_2] +uv run --with pymongo ~/notes/skills/log-work-expense/scripts/log_expense.py "" [s2_url_2] [--route "stop1|stop2"] ``` - **Meal receipts**: Run once per receipt (1 file each). @@ -33,6 +33,23 @@ uv run --with pymongo ~/notes/skills/log-work-expense/scripts/log_expense.py [s2_url_2] + python log_expense.py [s2_url_2] [--route stop1,stop2,...] type: "meal" or "mileage" account: e.g. "LTISD" date: YYYY-MM-DD note: free-text context (quote if it has spaces) s2_url: one or more S2 URLs of uploaded files + --route: comma-separated list of stops (mileage only). Home address is + automatically prepended and appended. Rules enforced: - meal: exactly 1 file per invocation @@ -16,12 +18,32 @@ Rules enforced: """ import sys +from datetime import datetime from pymongo import MongoClient +HOME = "11600 Minda Cir Austin, TX 78758" +ALIASES = { + "airport": "3201 Presidential Blvd, Austin, TX 78719", + "aus": "3201 Presidential Blvd, Austin, TX 78719", +} + def main(): args = sys.argv[1:] + route_stops = None + + if "--route" in args: + idx = args.index("--route") + args.pop(idx) + if idx >= len(args): + print("Error: --route requires a value") + sys.exit(1) + route_val = args.pop(idx) + route_stops = [s.strip() for s in route_val.split("|") if s.strip()] + route_stops = [ALIASES.get(s.lower(), s) for s in route_stops] + route_stops = [HOME] + route_stops + [HOME] + if len(args) < 5: - print("Usage: log_expense.py [s2_url_2]") + print('Usage: log_expense.py [s2_url_2] [--route stop1|stop2]') sys.exit(1) exp_type = args[0] @@ -42,19 +64,26 @@ def main(): print(f"Error: mileage entries must have exactly 2 files (start + end odometer), got {len(files)}") sys.exit(1) + if route_stops is not None and exp_type != "mileage": + print("Error: --route is only valid for mileage entries") + sys.exit(1) + client = MongoClient("mongodb://root:3wwfoUjyk2E2zWELXFlLuHqfw1ALlOp4pb2H5Vq3TImbMIHL2h1u8Jej2mjzCPl@docdb.connorrhodes.com:35563?tls=true&tlsAllowInvalidCertificates=true") db = client["wip"] col = db["work_expenses"] doc = { "files": files, - "date": date, + "date": datetime.strptime(date, "%Y-%m-%d"), "type": exp_type, "account": account, "note": note, "status": "todo" } + if route_stops is not None: + doc["route"] = route_stops + result = col.insert_one(doc) print(f"Inserted {exp_type} for {account} on {date}: {result.inserted_id}")