Class: MassSearch::OutgoingPaymentApproveCheckWorker

Inherits:
Object
  • Object
show all
Includes:
Workers::MassSearchWorker
Defined in:
app/workers/mass_search/outgoing_payment_approve_check_worker.rb

Overview

Approves each selected OutgoingPayment check.
Requires current user to have :approve_check permission on OutgoingPayment.

Instance Method Summary collapse

Methods included from Workers::MassSearchWorker

included

Instance Method Details

#build_enumerator(args, cursor:) ⇒ Object

Build enumerator.

Parameters:

  • args (Array)

    the args to build

  • cursor (Object)

    the cursor to build

Returns:

  • (Object)

    the result



13
14
15
16
17
18
19
20
21
# File 'app/workers/mass_search/outgoing_payment_approve_check_worker.rb', line 13

def build_enumerator(args, cursor:)
  super
  unless @user&.&.can?(:approve_check, OutgoingPayment)
    @unauthorised = true
    return active_record_records_enumerator(@search.search_results.none, cursor: cursor)
  end

  active_record_records_enumerator(@search.search_results, cursor: cursor)
end

#on_completeObject

On complete.

Returns:

  • (Object)

    the result



26
27
28
29
30
31
32
33
34
# File 'app/workers/mass_search/outgoing_payment_approve_check_worker.rb', line 26

def on_complete
  if @unauthorised
    store error_message: "You don't have permission to approve checks.",
          redirect_to:   UrlHelper.instance.accounts_payable_dashboard_path
    return
  end

  super
end