diff --git a/CLAUDE.md b/CLAUDE.md index 8138ffe..3aed90b 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -13,12 +13,17 @@ Personal finance tracker. Bank statements are ingested via an N8N workflow (in t ## Common Commands +**Deployment is push-to-deploy via Komodo** (since 2026-07-19): pushing to `main` on +Gitea triggers the `deploy-finance` Procedure, which runs DeployStack `--build` on the +`finance` stack (files_on_host over `docker/finance/` in the smarthome repo). Just +commit and push — no manual deploy needed. + ```bash -# Build and deploy (from smarthome repo root) +# Manual fallback only (from smarthome repo root), e.g. if Komodo is down docker compose --env-file docker/common.env --env-file docker/finance/.env \ -f docker/finance/docker-compose.yml up -d --build -# IMPORTANT: docker restart does NOT pick up a new image — always use the compose command above +# IMPORTANT: docker restart does NOT pick up a new image — push to main (or use the compose command above) # DB access docker exec postgres-personal psql -U personal -d personal diff --git a/README.md b/README.md index 88fdb60..5bb86f2 100644 --- a/README.md +++ b/README.md @@ -343,6 +343,10 @@ docker exec postgres-personal psql -U personal -d personal \ | `0005_rules` | `rules` | | `0006_budgets` | `budgets` | | `0007_cashflow` | `amount_aud`, `exchange_rate_to_aud` on transactions; `exchange_rate_to_aud` on statements | +| `0008_my_share_percent` | `my_share_percent` on `transaction_overrides` | +| `0009_split_payments` | `split_payments` | +| `0010_csv_import_reconcile` | `reconciled_with_id`, CSV import support | +| `0011_trips` | `trips`, `trip_id` on `transaction_overrides` (catch-up — was applied directly) | > `paperless_doc_id` on statements and the `uq_statements_paperless_doc_id` index were added directly (not tracked in a migration file). > `owner_id` on transactions and `statement_id` made nullable were applied directly (March 2026) to support manual transaction entry without a fake statement. @@ -371,7 +375,13 @@ Currently `merchant_normalized` conflates the *payment provider* with the *merch ## Deployment -Runs as a Docker container alongside the rest of the home lab stack. Build and deploy: +Runs as a Docker container alongside the rest of the home lab stack. + +**Push-to-deploy (default, since 2026-07-19)**: pushing to `main` on Gitea fires a +webhook to Komodo's `deploy-finance` Procedure, which redeploys the `finance` stack +with `--build`. CI (Gitea Actions) runs lint + unit tests on the same push. + +**Manual fallback** if Komodo is unavailable: ```bash # From smarthome repo root @@ -379,4 +389,9 @@ docker compose --env-file docker/common.env --env-file docker/finance/.env \ -f docker/finance/docker-compose.yml up -d --build ``` +The container is only reachable via Traefik (`https://finance.bosecamp.com`, forward-auth +sets `X-Forwarded-User`) plus a `127.0.0.1`-bound host port for on-box debugging — the +app trusts the `X-Forwarded-User` header, so it must never be directly reachable from +the LAN. + The container uses Next.js standalone output. `@prisma/adapter-pg` and `pg` are listed in `serverExternalPackages` in `next.config.ts` to ensure they are included in the standalone bundle. diff --git a/prisma/migrations/0011_trips/migration.sql b/prisma/migrations/0011_trips/migration.sql new file mode 100644 index 0000000..7128e68 --- /dev/null +++ b/prisma/migrations/0011_trips/migration.sql @@ -0,0 +1,21 @@ +-- Trips: group transactions (via transaction_overrides.trip_id) into named +-- trips with analytics. Catch-up migration — this DDL was applied directly to +-- the live DB when the feature shipped; idempotent so re-running is safe. + +CREATE TABLE IF NOT EXISTS trips ( + id SERIAL PRIMARY KEY, + owner_id INTEGER NOT NULL REFERENCES participants(id), + name VARCHAR(255) NOT NULL, + description TEXT, + start_date DATE, + end_date DATE, + color VARCHAR(20) NOT NULL DEFAULT '#6366f1', + archived BOOLEAN NOT NULL DEFAULT false, + created_at TIMESTAMPTZ NOT NULL DEFAULT now() +); + +ALTER TABLE transaction_overrides + ADD COLUMN IF NOT EXISTS trip_id INTEGER REFERENCES trips(id) ON DELETE SET NULL; + +CREATE INDEX IF NOT EXISTS idx_tx_overrides_trip_id + ON transaction_overrides (trip_id) WHERE trip_id IS NOT NULL;