Hide net contributions before a linked account's history

JA
7d ago
+119-9

Closes #5623
Part of #4078 (part 3, returns engine)
Fork pre-flight: jaysbeekay/sure#943 (same commits, head 7efd8e2fa)
Stacked on #5396

What: for a period that ends before a linked investment account's supported history starts, the account chart no longer draws the net contributions comparison. It used to read 0 under the raw balances, with a "+∞" difference at every point. The comparison, its legend and the incomplete note are hidden together.
Where to start: Account::Chartable#net_contributions_comparable?, read by UI::Account::Chart#show_net_contributions?.
Key tests: chart_test.rb "a linked account's period before its supported history draws no net contributions"; chartable_test.rb "a linked account's period ending before its supported history is not comparable".
Behaviour change: only for such a period. What the line means is unchanged. A period ending on the first supported date is trimmed and still compared.
Stack: top of the portfolio returns stack, on #5396. GitHub shows only this PR's diff.

Evidence
  • Checked against the opening-marker fix (8c1b77d5c): that fix changes only the anchor-day point. With an untrimmed line the builder's start (the anchor) is after through, so it returns no rows and every point is fetch(date, 0). The defect stands.
  • Red: the component test failed before the fix, with the comparison rendered at 0 against 1,000 and "+∞" at both points.
  • Mutations (each caught): dropping the gate in show_net_contributions?; <= instead of < at the boundary; a missing anchor read as not comparable.
  • Full unit suite on 43ffb77ae: 18,012 runs, 0 failures. The 8 errors are ReleaseNotesWorkflowTest (no node).
  • Siblings: net_contributions_incomplete? reads the same anchor and builder rows as the line and already answers false here, because the rows are empty. That is asserted, not changed. InvestmentStatement#net_contributions is a separate statement figure.
  • Migration: none.

Screenshots

A linked (Plaid) investment account from fixtures: balances from day one, first provider activity on day three, chart period day one to day two, so the whole period sits before the supported history. Before, the Total value chart draws a flat dashed net-contributions line at 0 with its legend; after, the chart shows the value line alone.

LightDark
Before (#5396 head)before-lightbefore-dark
After (this PR)after-lightafter-dark

Summary by cubic

Hides the net contributions comparison on account charts for periods that end before a linked investment account's supported history starts. It previously drew 0 under the raw balances, with a "+∞" difference at every point.

  • The comparison, its legend, and the incomplete note are hidden together; a period ending on the first supported date is trimmed and still compared.
  • The supported-history anchor is now cached per account so the chart's checks and its line share a single read; reload drops it.

Summary by CodeRabbit

  • Bug Fixes
    • Net-contributions comparisons appear only when the selected chart period is covered by the linked account’s supported history.
    • Charts remain available for earlier periods, without comparison data or a net-contributions legend when history does not cover the selected dates.
    • Comparison data includes the first date supported by the linked account’s history when the selected period reaches it.
    • Refreshed account data is reflected in subsequent chart comparisons.