67 Commits

Author SHA1 Message Date
Gonçalo Rodrigues
541a1c3556 feat: animated homepage + split personal/business navigation (#25)
- New animated homepage at / with 3D card tilt, particle canvas,
  floating ring decorations, and gradient title shimmer
- Personal finance pages move to /dashboard (base.html shows only
  personal nav + a subtle Business link)
- Business/org inner pages use base_org.html with a purple theme,
  org breadcrumb, Year/Team dropdowns, and a ← Hub back link
- org home/teams/members/invite/events/requests/ledger/analysis/report
  all switched to renderOrg() + base_org.html
- Route strings updated to org-home, org-teams, org-events, etc.
  so active nav highlighting works correctly in the business shell

Co-authored-by: Gonçalo Rodrigues <guga@Goncalos-MacBook-Pro.local>
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-14 17:02:37 +01:00
Gonçalo Rodrigues
1fce3b36aa feat: add checkable goals list to org events (#24)
Goals are stored as EventGoal items embedded in the event document.
During active fiscal years, members can check/uncheck goals inline.
Goals can be added and deleted while the event is not yet approved.

Co-authored-by: Gonçalo Rodrigues <guga@Goncalos-MacBook-Pro.local>
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-14 16:15:55 +01:00
Gonçalo Rodrigues
26a7236494 style: global dark form inputs + team emoji avatars (#23)
Form inputs:
- Add a catch-all CSS rule targeting all text-type inputs, selects, and
  textareas not already covered by .form-group or .form-input — sets
  background:--bg2, color:--text, focus ring. Fixes white-box appearance
  in transactions, goals, settings, portfolio, import, people, and tax
  templates without touching any HTML.

Team avatars:
- OrgTeam.Avatar string (emoji) — persisted in MongoDB, defaults to 👥
- OrgTeamCreate handler reads "avatar" form field
- org_teams.html: emoji picker (30 options) in new-team modal; preview
  updates live; selected emoji highlighted with accent border
- avatarEmojis() and teamAvatar() template functions registered in FuncMap
- Team badges in org_members, org_events, org_event_detail, org_report
  all show the emoji inline with the team name

Co-authored-by: Gonçalo Rodrigues <guga@Goncalos-MacBook-Pro.local>
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-14 16:08:29 +01:00
Gonçalo Rodrigues
ceeee2a46a style: add .form-input/.form-label CSS classes for dark-theme form fields (#22)
Org templates use class="form-input" and class="form-label" which had no
CSS definition — browsers fell back to white-box defaults, clashing with
the dark teal theme.

- .form-input: dark bg (--bg2), teal border, accent focus ring + glow,
  placeholder dimming, file input button styling
- .form-label: uppercase micro-label style (11px, --text3) matching the
  existing card section headers throughout the app
- textarea.form-input: resize:vertical, min-height, line-height
- select option / .form-input option: dark background on dropdown items
- Keep .form-group label unchanged so existing non-org templates are unaffected

Co-authored-by: Gonçalo Rodrigues <guga@Goncalos-MacBook-Pro.local>
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-14 16:03:45 +01:00
Gonçalo Rodrigues
07e3525dae fix(finance): org polish — broken links, upload handler, populated selects (#21)
- org_home.html: fix Requests/Ledger links (were pointing to non-existent
  /years/{id}/requests routes; corrected to /orgs/{slug}/requests and
  /orgs/{slug}/ledger). Add Analysis link. Add Close year button for admins.
- OrgRequestNew: pass events + teams to GET template so dropdowns are
  populated (were silently discarded with _ = events).
- OrgRequestDetailData: add NewEvents/NewTeams fields for new-request form.
- OrgRequestUpload: implement file upload handler — saves to
  /data/org-files/{org_id}/{req_id}/{id} and records metadata in MongoDB.
  Register POST /orgs/{slug}/requests/{req_id}/upload route.
- org_request_detail.html: show upload form in attachments section;
  populate event/team selects on new request form.

Co-authored-by: Gonçalo Rodrigues <guga@Goncalos-MacBook-Pro.local>
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-14 16:00:23 +01:00
Gonçalo Rodrigues
0f58a51c6d feat(finance): org Phases 2-5 — events, requests, ledger, analysis, report (#20)
Phase 2 — Event planning:
- Create/edit/delete/submit events per fiscal year
- Budget lines (income + expense) with planned amounts
- Admin review flow: approve / reject / comment
- Post-mortem feedback comments on closed years

Phase 3 — Transaction requests:
- 5 types: reimbursement, purchase_order, cash_advance, income, budget_transfer
- Full status machine with append-only StatusLog audit trail
- PO delivery sub-form (actual vendor, amount, invoice note)
- Cash advance settlement sub-form (spent + returned)
- Ledger view per fiscal year with income/expense summary
- Bank CSV import: parse → preview → confirm → ledger entries

Phase 4 — Plan vs actual analysis:
- Variance table by event (planned vs actual income/expense)
- Variance table by team

Phase 5 — Year-end report:
- Executive summary with net variance
- Per-event section: budget lines + team feedback comments
- Feedback form available on closed fiscal years

Supporting changes:
- New store methods: getLedgerEntries, createLedgerEntry, updateLedgerEntry,
  getAttachments, createAttachment
- New template funcs: dateInput, statusColor, varColor
- parseEuroAmount + parseBankCSV helpers in handler_org.go

Co-authored-by: Gonçalo Rodrigues <guga@Goncalos-MacBook-Pro.local>
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-14 12:58:47 +01:00
Gonçalo Rodrigues
1a935aa8ff Merge pull request #19 from GoncaloRodri/feature/org-phase1
feat(finance): org management scaffold — Phase 1
2026-06-14 12:45:04 +01:00
Gonçalo Rodrigues
6ed848a001 feat(finance): org management scaffold — Phase 1
Adds multi-tenant organisation support inside the existing finance namespace.
Users can create organisations, invite others via a copy-paste token link,
and manage teams/members with RBAC (admin, finance, member, viewer).
Fiscal year lifecycle is gated: activation requires all planned events to
be approved first. All org data lives in `org_`-prefixed MongoDB collections.

New files:
- models_org.go      — domain types (Org, OrgTeam, OrgMember, OrgInvite,
                       FiscalYear, OrgEvent, BudgetLine, EventComment,
                       TxRequest with full StatusLog audit trail, etc.)
- store_org.go       — MongoDB store methods for all org collections
- handler_org.go     — HTTP handlers + RegisterOrgRoutes(); join invite
                       route lives at /join/{token} to avoid ServeMux
                       conflict with /orgs/{slug}/... wildcard routes
- templates/org_*.html — list, create, home, teams, members, invite, join

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-14 12:43:48 +01:00
Gonçalo Rodrigues
1b9284801c Merge pull request #17 from GoncaloRodri/feature/fixes-mobile-nav
fix: portfolio values, Yahoo UA header, mobile hamburger nav
2026-06-13 19:37:39 +01:00
Gonçalo Rodrigues
a66941160a fix: portfolio value formula, Yahoo UA header, mobile nav hamburger
- Remove erroneous /100 in currentValue calculation (portfolio values
  were 100x too small, causing net worth card to show ~€0)
- Add User-Agent header to Yahoo Finance requests (avoids 429s)
- Wrap ES module chart body in if(total>0){} block (return at top
  level of a module is a SyntaxError — chart was silently broken)
- Add mobile hamburger menu: full-screen drawer at ≤720px with
  animated open/close, all nav links, scroll lock while open

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-13 19:33:12 +01:00
Gonçalo Rodrigues
981b832d7f test: add missing traderepublic_securities.csv testdata fixture
Provides the 5-row Trade Republic securities CSV that
TestParseSecuritiesCSV_FromFile expects; CI was failing
with "no such file or directory".

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-13 19:32:17 +01:00
Gonçalo Rodrigues
b1c9609f42 Merge pull request #18 from GoncaloRodri/feature/nav-cleanup
Feature/nav cleanup
2026-06-13 19:31:12 +01:00
Gonçalo Rodrigues
09984272cd style: dark teal/cyan theme across the whole app
Replace indigo accent palette with deep black backgrounds and
cyan-teal accents (#00c9b8 dark, #00897b light). Borders, glows,
text muted tones and background gradients all updated to match.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-13 19:12:58 +01:00
Gonçalo Rodrigues
5c6752b4a3 style: blue-green palette for portfolio allocation chart
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-13 19:09:02 +01:00
Gonçalo Rodrigues
6712c36081 feat: user-editable ISIN→ticker mappings for unrecognised holdings
When a holding has no price (ISIN not in the built-in map and Yahoo
rejects the raw ISIN), the portfolio page now shows an amber banner
listing each missing ISIN with an inline text input and a "Look up"
link to Yahoo Finance symbol search.

Submitting the form POSTs to /portfolio/ticker which upserts the mapping
into a finance_ticker_mappings collection keyed by (user_id, ISIN).
On the next page load custom mappings are resolved first, before the
hardcoded isinToTicker table, so user overrides always win.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-13 19:05:36 +01:00
Gonçalo Rodrigues
5dc920cb1a fix: add QDVE.DE ticker mapping for iShares S&P 500 IT Sector ETF (IE00B3WJKG14)
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-13 19:00:56 +01:00
Gonçalo Rodrigues
a2d3b60500 fix: allocation chart — illegal top-level return in ES module
`return` at the top level of a <script type="module"> is a SyntaxError
in strict mode, so the entire Three.js chart script was killed before
executing regardless of whether prices were available.

Replaced `if (total <= 0) return` with `if (total > 0) { ... }` wrapping
the full chart body. Also filter out holdings with value=0 before building
the arc geometry so a single un-priced ISIN can't produce a zero-arc slice.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-13 18:55:38 +01:00
Gonçalo Rodrigues
d77020dcc5 fix: add User-Agent header to Yahoo Finance price requests
Without it the API returns "Too Many Requests" (not JSON), prices map
stays empty, currentValue = 0, and every holding shows -100% P&L with
an empty allocation chart.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-13 18:49:49 +01:00
Gonçalo Rodrigues
5d30b5eaee fix: portfolio current value divided by 100 erroneously
currentPrice is already in cents, so currentValue = price * shares.
The extra /100 made every holding appear worth 100x less than its cost,
producing ~-100% P&L on every position and an empty allocation chart
(values too small for Chart.js to render).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-13 18:41:13 +01:00
Gonçalo Rodrigues
8c33a070e5 Merge pull request #16 from GoncaloRodri/feature/nav-cleanup
refactor: consolidate nav from 15 items to 7
2026-06-13 18:34:39 +01:00
Gonçalo Rodrigues
437fb5a2df refactor: consolidate nav from 15 items to 7
- Merge Sharing + Household → /people (tab switcher: sharing | household)
- Merge Accounts + Categories → /settings (tab switcher: accounts | categories)
- Add Analysis dropdown in nav: Reports, Projections, Tax, Net Worth, What If
- Add Settings dropdown in nav: Accounts & Categories, Import CSV, Import Guide
- Legacy GET /sharing, /household, /accounts, /categories redirect 301 to new URLs
- Remove Import and Import Guide as standalone nav links
- New People handler consolidates all people-related mutations (_action field)
- New Settings handler renders both account and category lists in one page

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-13 18:33:15 +01:00
Gonçalo Rodrigues
3dd7362964 Merge pull request #15 from GoncaloRodri/feature/backlog-tax-household-autoimport
refactor: retire Auto Import schedules, add Import Guide + duplicate …
2026-06-13 18:24:51 +01:00
Gonçalo Rodrigues
7f7e696b4d refactor: retire Auto Import schedules, add Import Guide + duplicate notice
- Auto Import page replaced with a static Import Guide: step-by-step
  instructions for CGD/Trade Republic/generic CSV export, duplicate
  detection explanation, and a curl example for headless automation
- Removed POST /auto-import and DELETE /auto-import/{id} routes and
  their handler logic; schedule CRUD was misleading since no bank
  exposes an unauthenticated CSV endpoint
- Nav label changed from "Auto Import" to "Import Guide"
- Transactions page now renders an amber banner when redirected with
  ?notice=all_duplicates (every row in the uploaded file was skipped)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-13 18:20:48 +01:00
Gonçalo Rodrigues
97289d89eb Merge pull request #14 from GoncaloRodri/feature/backlog-tax-household-autoimport
feat: Tax Summary, Household Mode, and Auto Import
2026-06-13 18:17:44 +01:00
Gonçalo Rodrigues
2170457528 feat: duplicate detection on CSV import
Compute a sha256 fingerprint (date|description|amount|account_id, first
16 hex chars) for every CSV row and store it as bank_ref. At preview
time, existing fingerprints are fetched and matching rows are shown
greyed out with a "duplicate" label. At confirm time, those rows are
silently skipped — only truly new transactions are inserted.

If every row is a duplicate the user is redirected with ?notice=all_duplicates
instead of inserting an empty batch.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-13 18:15:23 +01:00
Gonçalo Rodrigues
1c2bac1d5f feat: implement Tax Summary, Household Mode, and Auto Import
- Tax Summary (/tax): annual gross income from Income transactions,
  FIFO capital gains/losses from trades, expenses by category, CSV export
- Household Mode (/household): link a partner account, combined
  income/expense/disposable view for current month, shared goals list
- Auto Import (/auto-import): schedule recurring CSV imports with
  account, format and optional source URL; delete schedules; webhook docs
- New store methods for households and import_schedules collections
- storeIface extended; mockStore updated; all tests still pass

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-13 17:28:22 +01:00
Gonçalo Rodrigues
722559519e Merge pull request #13 from GoncaloRodri/feature/unit-tests
test: unit tests — 70.3% coverage
2026-06-13 17:20:35 +01:00
Gonçalo Rodrigues
9dfc95cd32 test: add unit tests — 70.3% coverage
Extracted storeIface from Handler so store can be mocked in tests.
Added handler_test.go with 98 test cases covering:
- All HTTP handlers (Dashboard, Transactions, Accounts, Categories, Goals,
  Portfolio, Reports, Projections, NetWorth, Simulator, Sharing, Import*)
- Auth middleware (authMW, ownerOrViewerMW)
- Pure helpers (monthsBetween, parseFloat, sortStrings, appendIfMissing)
- Error paths (bad JSON, missing fields, store errors, bad CSV)
- Alert logic (budget exceeded, goal miss, spend pace)
- Template funcmap exercised via rich render scenarios

Also added tickerStore.resolve tests to portfolio_test.go.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-13 17:18:49 +01:00
Gonçalo Rodrigues
dfe7d14475 Merge pull request #12 from GoncaloRodri/feature/phase6-alerts
feat: phase 6 — dashboard alerts and nudges
2026-06-13 17:05:39 +01:00
Gonçalo Rodrigues
995c6d89d6 feat: phase 6 — dashboard alerts and nudges
Adds server-computed alert banners to the dashboard:
- Budget exceeded (red): when a category spend is over 100% of budget
- Budget pace warning (amber): 80%+ of budget used but <80% of month elapsed
- Goal deadline risk (amber): avg savings rate too low to hit a goal on time
- Spend pace warning (amber): disposable spending is 20%+ ahead of month progress

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-13 17:03:12 +01:00
Gonçalo Rodrigues
2b1ee6422a Merge pull request #11 from GoncaloRodri/feature/phase5-simulator
feat: phases 4 & 5 — net worth + what-if simulator
2026-06-13 17:00:41 +01:00
Gonçalo Rodrigues
39282ff550 feat: phase 5 — what-if simulator + savings rate history
Adds /simulator page with live sliders for income change, one-off
expenses, and fixed cost shifts. Goal timelines update in real time
showing months gained/lost. Includes a savings rate bar chart from
historical monthly data.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-13 16:57:14 +01:00
Gonçalo Rodrigues
2150745d1c Merge pull request #10 from GoncaloRodri/feature/phase4-net-worth
Feature/phase4 net worth
2026-06-13 16:54:52 +01:00
Gonçalo Rodrigues
42f5b0df4d feat: phase 4 — net worth page + dashboard card
Adds /networth page with hero total, cash/portfolio breakdown cards,
and a month-by-month historical chart. Also shows net worth as a
value card on the dashboard with a link to the full breakdown.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-13 16:52:57 +01:00
Gonçalo Rodrigues
2e3fcb0e69 Merge pull request #9 from GoncaloRodri/feature/phase3-goals-commit
feat: phase 3 — goals commit + conflict detection
2026-06-13 16:49:39 +01:00
Gonçalo Rodrigues
bfd5f62a7a feat: show committed goals in fixed costs panel
Committed goals now appear in the Fixed Costs panel on the dashboard
with a "committed goal" label, and the total line uses TotalCommittedCents
(fixed costs + goal contributions) instead of total monthly expenses.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-13 16:46:55 +01:00
Gonçalo Rodrigues
2324f62721 feat: add fixed costs panel to dashboard
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-13 16:41:48 +01:00
Gonçalo Rodrigues
3b041267ad feat: phase 3 — goals commit + plan
- Commit/uncommit button on each goal card
- Committed goals are deducted from disposable income on the dashboard
  (Available to spend now reflects reserved goal contributions)
- Conflict detection: warning banner when committed goals exceed
  disposable income, showing the shortfall
- Goals summary bar: disposable before goals, reserved per month,
  free to spend after committed goals

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-13 16:37:45 +01:00
Gonçalo Rodrigues
1712ac3851 Merge pull request #8 from GoncaloRodri/feature/phase2-goals
feat: phase 2 — goals explore mode
2026-06-13 16:35:36 +01:00
Gonçalo Rodrigues
35156e001d fix: change GoalPlan int fields to int64 to match sub template func
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-13 16:33:15 +01:00
Gonçalo Rodrigues
99be71be8a fix: replace month input with month/year dropdowns in goal modal
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-13 16:28:58 +01:00
Gonçalo Rodrigues
be0c2bd89e feat: phase 2 — goals explore mode
Adds a Goals page where users can plan financial goals before committing
to them. Each goal shows:

- Required monthly contribution to hit the deadline
- Months remaining vs months at current savings rate
- Disposable income impact (what's left after the contribution)
- Feasibility banner (green if on track, red with month delta if not)
- Progress bar once savings are tracked

Goal types: one-off purchase, deposit/down-payment, emergency fund,
recurring investment — each with a description hint in the creation modal.

Data: Goal model + store CRUD in finance_goals collection.
Nav: Goals tab added between Portfolio and Sharing.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-13 16:20:46 +01:00
Gonçalo Rodrigues
809fc01d48 Merge pull request #7 from GoncaloRodri/feature/phase1-dashboard
feat: phase 1 dashboard — disposable income & smart panels
2026-06-13 16:17:38 +01:00
Gonçalo Rodrigues
5412dda2ac fix: dashboard investment display and budget health
- Exclude FixedCategories (Housing, Utilities, Subscriptions, Investments)
  from budget health panel — they are committed costs, not variable spend
- Portfolio card and stocks panel now degrade gracefully to cost basis
  when Yahoo Finance prices are unavailable, instead of showing €0
- Stocks panel shows "cost basis" label per holding when live prices
  are not available

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-13 16:14:44 +01:00
Gonçalo Rodrigues
b27268febe fix: revert image names to match service.mk directory-derived names
service.mk builds homelab/<dirname>:latest so manifests must match:
- homelab/api:latest (finance/services/api)
- homelab/users:latest (auth/services/users)
- homelab/gateway:latest (auth/services/gateway)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-13 16:04:26 +01:00
Gonçalo Rodrigues
e562ff27bf fix: use latest tag for local builds to match deployment manifests
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-13 16:01:19 +01:00
Gonçalo Rodrigues
1d3aa764cb feat: phase 1 dashboard redesign — disposable income + smart panels
Replaces the old KPI/chart dashboard with a focused layout that
answers the three key questions immediately:

- Hero block: "Available to spend" = income − fixed costs − spent so far,
  with a progress bar showing % of disposable used vs month elapsed
- Bank math panel: detects recurring fixed expenses (Housing, Utilities,
  Subscriptions, Investments) from last 3 months and shows the minimum
  bank balance needed right now including a 2-week safety buffer
- Savings rate card with month-over-month delta
- Portfolio snapshot card with total value and P&L
- Stocks at a glance panel: per-holding value and P&L inline
- Budget health: thin bars per category, red when over limit
- Recent activity: last 5 transactions with category color dots

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-13 15:51:46 +01:00
Gonçalo Rodrigues
be76117ce7 Merge pull request #6 from GoncaloRodri/docs/architecture-and-dashboard-plan
Docs/architecture and dashboard plan
2026-06-13 15:45:32 +01:00
Gonçalo Rodrigues
8b26a89a84 ci: consolidate to a single ci.yml that runs all tests
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-13 15:40:26 +01:00
Gonçalo Rodrigues
8b1c816fa0 ci: simplify to test-only workflows + Makefile deploy targets
GitHub Actions now only runs tests (free, cloud runners, no setup).
Deployment is manual via `make deploy-finance` / `make deploy-all`
which builds locally, imports into k3d, and applies with kubectl.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-13 15:37:29 +01:00