# Vue Routing / FX / ETF Cleanup / TrueWealth Hotfix Pattern

Use this reference for FinanceManager hotfixes where Vue routes/menu links, Equity/ETF FX status, snapshot cleanup, and TrueWealth portfolio modelling overlap.

## Trigger

Apply when the user reports any combination of:

- Vue Budget menu links rendering 404/stale/fallback pages.
- Equity/ETF detail pages showing `FX fehlt` even when the transaction/cache appears resolved, or CHF positions show FX missing.
- Manual ETF/Equity snapshots cannot be removed even though they are single manually entered initial/adjustment rows.
- TrueWealth appears as normal Equity/ETF positions but should be managed as a total-value portfolio.

## Routing checks

1. Inspect `frontend/src/router/index.ts`, `frontend/src/navigation/userNav.ts`, and relevant smoke tests together.
2. Add direct aliases for user-visible menu paths when the existing route is nested under an analysis/admin path. Example: keep `/planning/budget/analysis/data-explorer` but also support `/planning/budget/data-explorer` if the menu/user expects it.
3. Verify with both unit/smoke tests and HTTP/browser sanity from the current running checkout; stale Vite/uvicorn processes can mask route changes.

## FX rules for Equity/ETF pages

1. Do not derive FX status only from current valuation currency; inspect transaction `currency_original`, stored `fx_status`, and `fx_rate_to_chf`.
2. CHF transactions are `not_needed` with rate `1` and should resolve false-positive missing-FX alerts with audit.
3. Foreign-currency transactions are `ok` only when a valid rate is stored; never store/display `ok` without a rate.
4. Current market-price valuation may need latest/current FX even when historical transaction FX is missing; keep those states distinct.
5. If an explicit provider recheck fails, do not invent or manually fabricate rates. Report the unresolved FX cache/provider boundary and leave valuation degraded.

## Snapshot removal / ETF cleanup

1. Before runtime cleanup, create and verify a DB backup outside the repo.
2. Dry-run aggregate-only: count active ETF/Equity positions, safe removals, and blocked-with-history positions; do not print row values.
3. A safe removal is limited to exactly one active transaction for the position and a known manual/snapshot source/type, e.g. `initial_position_snapshot`/`initial_snapshot` or legacy `manual_adjustment` from `manual_dashboard`.
4. Positions with more than one transaction or real buy/sell/dividend history remain blocked.
5. Productive cleanup should void/storno the row and write audit events; do not hard-delete ledger history.

## TrueWealth managed portfolio model

1. Treat TrueWealth as a managed/manual total-value account when the account type/metadata marks it as such (`managed_portfolio`, `robo_portfolio`, `manual_total_value`), not merely because a legacy brokerage platform label contains “True Wealth”.
2. Block managed total-value accounts from the normal `Position hinzufügen` Equity/ETF wizard.
3. Add/use account-value snapshot APIs behind Preview → Confirm → Audit for manual total value updates.
4. Portfolio buckets should separate Crypto, PostFinance Aktien/ETFs, TrueWealth, and Cash; do not double-count Equity and TrueWealth.

## Verification gate

- Backend focused tests for FX, removal guard, and TrueWealth account metadata.
- Frontend smoke tests for all affected menu paths and wizard filtering.
- Full pytest, full Vitest, frontend build.
- Secret scans should use realistic token regexes and inspect candidates; broad terms like `api_key` in tests are not automatically leaks.
- Remove generated artifacts/caches before Git-safety, commit, push, and verify remote hash.
