mirror of
https://github.com/we-promise/sure.git
synced 2026-04-09 15:24:48 +00:00
* third party provider scoping * Simplify logic and allow only admins to mange providers * Broadcast fixes * FIX tests and build * Fixes * Reviews * Scope merchants * DRY fixes
23 lines
932 B
Ruby
23 lines
932 B
Ruby
class Transactions::BulkDeletionsController < ApplicationController
|
|
def create
|
|
# Exclude split children from bulk delete - they must be deleted via unsplit on parent
|
|
# Only allow deletion from accounts where user has owner or full_control permission
|
|
writable_account_ids = writable_accounts.pluck(:id)
|
|
entries_scope = Current.family.entries
|
|
.where(account_id: writable_account_ids)
|
|
.where(parent_entry_id: nil)
|
|
destroyed = entries_scope.destroy_by(id: bulk_delete_params[:entry_ids])
|
|
destroyed.map(&:account).uniq.each(&:sync_later)
|
|
redirect_back_or_to transactions_url, notice: "#{destroyed.count} transaction#{destroyed.count == 1 ? "" : "s"} deleted"
|
|
end
|
|
|
|
private
|
|
def bulk_delete_params
|
|
params.require(:bulk_delete).permit(entry_ids: [])
|
|
end
|
|
|
|
def writable_accounts
|
|
Current.family.accounts.writable_by(Current.user)
|
|
end
|
|
end
|