Class: PrintAllChecksWorker

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

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



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'app/workers/print_all_checks_worker.rb', line 8

def perform(options)
  options = options.with_indifferent_access
  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