Skip to content

Work / Chitragupt / Wiki / Decisions

2026-10-23-portfolio-position-id-per-statement-year

Decisioncanonicalverified 2026-10-23

DECISION.2026-10-23.PORTFOLIO-POSITION-ID-PER-STATEMENT-YEAR

Portfolio position id is per holding and statement year

Decision

A portfolio position id is ${holdingId}__${ay}, where holdingId is ${formType}__${uid8} and ay falls back to unknown. Re-uploading the same year's statement overwrites that row. A different year keeps its own row.

Why

Keying on holding alone would have discarded earlier years' history. Keying on the document id double-counted NAV on re-upload. Statement year is the natural key: the latest upload of a year is the truth for that year.

Impact

  • apps/functions/src/portfolio/portfolio-position-mapper.ts builds positionId.
  • The holding record stays keyed by form type and is shared across years.
  • Engine sums by holding_id as before. A V2 lot ledger would change the scheme again.
  • Related: pillar-portfolio, 2026-07-09-dedup-content-hash-and-purge.

Status

Active. Replaces 2026-07-12-portfolio-position-dedup.

Sources

  • apps/functions/src/portfolio/portfolio-position-mapper.ts