fix: allow removing loan offset accounts
Merged
DU
2mo ago+244+244+012345678901234567890123456789-14-14-01234567890123456789
Summary
Fixes #329.
- Include existing eligible offset accounts in the loan edit select and keep them selected.
- Submit an explicit empty value when the current offset set is fully represented, so deselecting all offsets removes the links.
- Preserve the existing
offset_account_idsabsent-key contract. - Keep currency, account type, family, and visibility validation in force for associated accounts.
Testing
- Docker focused tests:
54 runs, 224 assertions, 0 failures. - Mutation checks: all three required regressions were detected.
- Docker RuboCop: passed with no offenses.
- Docker Brakeman: 0 errors, 0 security warnings.
- Full Rails suite was attempted but encountered unrelated Redis connection failures.
- ERB lint reached an internal
better_htmlsource-position exception; no ERB offenses were reported.
Scope
- No JavaScript, dependencies, migrations, or design-system changes.
- OpenSpec planning artifacts remain local and are not included in this PR.
Summary by CodeRabbit
- Bug Fixes
- Loan edits retain eligible offset accounts when the selection is unchanged or additional accounts are selected.
- Existing eligible offset accounts are preselected when editing a loan and no new selection is submitted.
- Explicitly clearing all offset accounts removes them from the loan, including when no other loan details change.
- Existing linked accounts remain selectable when they meet currency, liability type, and visibility requirements.
- After an invalid edit, the form preserves the submitted empty selection rather than restoring cleared accounts.