fix: allow re-linking payment to new bill after original is ended
Merged
JO
1mo ago+98+98+01234567890123456789-8-8-0123456789
Fixes #3592
Problem
When a user deletes a bill, the app sets its recurring_transaction
status to ended rather than hard-deleting it. Its occurrences and
allocations persist in the database.
entry_capacity and unmeasurable_entry? in the Allocator were
summing allocations across all series, including ended ones. This
made the entry appear fully spent, blocking re-use on a new bill and
raising Allocated amount must be greater than 0.
Fix
Scope both entry_capacity and unmeasurable_entry? to exclude
allocations whose parent recurring_transaction has status: "ended".
Test
Added a test that reproduces the exact scenario:
- Link a payment to a bill's occurrence
- End the series (simulating bill deletion)
- Create a replacement bill
- Link the same payment to the new bill → must succeed
Summary by CodeRabbit
- Bug Fixes
- Payments allocated to ended recurring transactions can now be reused for replacement bills. Allocations from ended transactions no longer consume capacity or prevent valid reallocations.
- Payments allocated to active recurring transactions remain unavailable for reuse by other active bills.