Reconcile drivers to the currency's smallest unit

JA
7d ago
+30-12

Part of jaysbeekay/sure#829

What: Portfolio::Drivers#reconciles? now allows one unit of the series' currency where that unit is coarser than a cent. A 0.3 JPY residual now reconciles. This branch draws no row: the "Unexplained JPY 0" row comes from Portfolio::SectionRegistry#driver_reconciles? on fork main, which still reads the cent and moves to tolerance_for in a separate fork-main change.
Where to start: Portfolio::Drivers.tolerance_for in app/models/portfolio/drivers.rb.
Key test: drivers_test.rb "reconciles allows a residual below the currency's smallest unit".
Behaviour change: applies only to currencies with fewer than two decimals. The cent stays as the floor, so currencies with three or more decimals keep the tolerance they had. MGA and MRU move from 0.01 to 0.1 (default_precision: 1).
Base: up/portfolio-drivers-v3 (returns stack slice #5091). No upstream PR yet.

Evidence
  • Red: the new test failed before the fix on the 0.3 JPY line. It also pins the 1 JPY boundary, 1.5 JPY and 0.3 USD as not reconciling, and the KWD cent floor (0.004 reconciles, 0.015 does not).
  • Mutations (each caught): reconciles? defaulting to the cent again; dropping the cent floor; ignoring the currency; < instead of <=.
  • Full unit suite on 931c24871: 17,828 runs, 0 failures. The 8 errors are ReleaseNotesWorkflowTest (no node).
  • Siblings: nothing in app code on this slice reads #reconciles?. Portfolio::Performance stores drivers.to_h, which carries no tolerance, so its cache is unaffected. Portfolio::SectionRegistry#driver_reconciles? on fork main still re-derives the check from the RECONCILE_TOLERANCE literal and moves to tolerance_for in a separate fork-main change.

Upstream PR: we-promise/sure#5637 (same branch, same commits; stacked on we-promise/sure#5624 in the returns stack). Upstream issue: we-promise/sure#5630.