Share one pending predicate, and classify investment cash movements in one place
Merged
JA
2mo ago+1813+1813+0123456789012345678901234567890123456789-86-86-01234567890123456789
Pre-flight for we-promise/sure#3557 — same branch, same commits.
It replaces two earlier pre-flights: #146 (merged, pending-SQL half) and #225 (closed, classifier half). The two upstream PRs were never a stack — their merge base was upstream main, and #3617 carried its own copies of #3557's seven pending-SQL commits. They are now one linear history on current main, so the duplicated commits appear once.
What it carries
- One SQL definition of "pending" that agrees with
Transaction#pending?, replacing per-provider casts across import, reconciliation, analytics and cleanup. Portfolio::FlowClassifier: one rule table, two generated forms (Ruby and SQL) with a parity test, sorting every investment-account entry into inflow, outflow, income, fee or internal.- Three corrections found in review: a NULL
excludedflag on a security transfer's opposite leg; a Contribution/Withdrawal label outranking a real linked transfer; and the SimpleFIN importer excluding stale pending entries before counting them, which madestale_unmatched_pendingunreachable.
31 files, +1,813 / −86, 13 commits.
Verification
Head e01ed2f87, Ruby 3.4.9, PostgreSQL 16. Full suite: 10,235 runs, 43,351 assertions, 0 failures, 33 skips; the single error is this machine's RecurringTransaction::PipelineTest, which fails on any branch here. Rubocop clean on all changed files. Each correction was observed to fail before its fix.