Class: CreateReceiptsWorker
- Inherits:
-
Object
- Object
- CreateReceiptsWorker
- Includes:
- Sidekiq::Job, Workers::StatusBroadcastable
- Defined in:
- app/workers/create_receipts_worker.rb
Overview
Sidekiq worker: create receipts.
Instance Attribute Summary
Attributes included from Workers::StatusBroadcastable
Instance Method Summary collapse
Methods included from Workers::StatusBroadcastable::Overrides
Instance Method Details
#perform(options = {}) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'app/workers/create_receipts_worker.rb', line 9 def perform( = {}) = .deep_symbolize_keys excel_file = Upload.find_by(id: [:upload_id]) report = Receipt.create_receipts_from_xlsx(excel_file) do |current_step, total_steps, | total total_steps at(current_step, ) end excel_file.destroy if report[:errors].any? = report[:errors].join('. ') store redirect_to: '/receipts/create_from_excel' store error_message: else = report[:successes].join('. ') store redirect_to: "/receipts/imported?new_receipt_ids%5B%5D=#{report[:new_receipt_ids].join('&new_receipt_ids%5B%5D=')}" store message: end end |