Respect account share permissions in bulk edit and categorize
Closes #2099
Before: bulk edit (Transactions::BulkUpdatesController#create) selected entries from the whole family. A member could select transactions from an account that was shared with them read-only, or not shared at all, and change their date, name, notes, category, merchant and tags. The category, merchant and tag IDs were also passed straight to Entry.bulk_update!, so IDs from another family could be attached. The categorize wizard (Transactions::CategorizesController) wrote through Current.accessible_entries, which includes read-only shares.
After:
- Bulk edit follows the same rules as editing a single transaction: owners and
full_controlshares can change every field,read_writeshares can only annotate (notes, category, merchant, tags), and entries on read-only or unshared accounts are skipped. A mixed selection applies each entry's own rights, inside one database transaction. - Category, merchant and tag IDs are resolved through
Current.family(merchants throughavailable_merchants_for, the list the form offers). Foreign IDs are dropped. If every requested tag is foreign, the entries keep their tags instead of being cleared; an explicit empty list still clears them. - The categorize wizard lists, counts and writes only entries the user can annotate. It no longer creates a rule when every selected entry was skipped.
- The "Categorize (N)" menu item on the transactions page counts the same entries as the wizard, so it no longer points at entries the wizard cannot change (cache key bumped).
How
- New
Current.annotatable_entriesnext toCurrent.accessible_entries, built on the existingAccount.annotatable_by. - Bulk edit splits the selection with
Account.writable_byand passes only an allow-list of annotate fields for theread_writepart, matchingTransactionsController#permitted_entry_params.
Related: #2950 also scopes bulk edit to writable_by, as part of the larger reconciliation feature. This PR keeps annotation for read_write shares (as the single-transaction form allows) and also covers the categorize wizard and foreign IDs. The API side (/api/v1/transactions update/destroy) is handled separately in #4000.
Validation
- New controller tests: foreign category/merchant/tag IDs, foreign-only tag list, read_only and unshared accounts skipped, read_write annotates but cannot change date/name, full_control can, mixed selection, categorize create/assign_entry/show/preview_rule with read_only and read_write shares, no rule when nothing was categorized, index count. Each fails without the change (the full_control and read_write positive cases pass before and after).
bin/rails test: 11834 runs, 0 failures, 0 errors.- rubocop, erb_lint, biome lint and brakeman clean.
- No UI changes, so no screenshots.
Summary by CodeRabbit
- Bug Fixes
- Bulk edits now respect shared-account permissions: read-write access allows updating notes, categories, merchants, and tags, while full control allows all supported changes. Read-only and inaccessible entries are skipped.
- Categories, merchants, and tags from outside your family are not applied. If all selected tags are invalid, existing tags remain unchanged; an empty tag selection still clears tags.
- Categorization, rule previews, and uncategorized counts now reflect which shared accounts you can annotate. Rules are created only when categorization succeeds or no entries were selected.