Class: PrintAllChecksWorker

Inherits:
Object
  • Object
show all
Includes:
Sidekiq::Job, Workers::StatusBroadcastable
Defined in:
app/workers/print_all_checks_worker.rb

Overview

Sidekiq worker: print all checks.

Instance Attribute Summary

Attributes included from Workers::StatusBroadcastable

#broadcast_status_updates

Instance Method Summary collapse

Methods included from Workers::StatusBroadcastable::Overrides

#at, #store, #total

Instance Method Details

#perform(options) ⇒ Object

Parameters:

  • options (Hash)

    Job arguments

Options Hash (options):

  • current_user_id (Integer)

    ID of the user printing the checks

  • payment_ids (Array<Integer>)

    IDs of the OutgoingPayment records to print

  • regenerate_pdf (Boolean)

    Force regeneration of each check PDF



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'app/workers/print_all_checks_worker.rb', line 14

def perform(options)
  current_user = Party.find(options['current_user_id'])
  total options['payment_ids'].size
  regenerate_pdf = options['regenerate_pdf'].to_b
  num = 0
  pdfs = []
  options['payment_ids'].each do |payment_id|
    at(num, "Processing payment id #{payment_id}")
    payment = OutgoingPayment.find(payment_id)
    pdfs << payment.print_check(current_user, regenerate_pdf: regenerate_pdf)
    num += 1
  end
  pdf = PdfTools.combine(pdfs, output_file_path: Upload.temp_location("combined_check_printout_#{Time.current.to_fs(:no_spaces)}.pdf"))
  upload = Upload.uploadify(pdf, 'check')
  store upload_id: upload.id
end