Hide net contributions before a linked account's history
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 afterthrough, so it returns no rows and every point isfetch(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 areReleaseNotesWorkflowTest(nonode). - 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_contributionsis 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.
| Light | Dark | |
|---|---|---|
| Before (#5396 head) | ![]() | ![]() |
| After (this PR) | ![]() | ![]() |
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;
reloaddrops 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.



