Class: AccountingDocumentTransmissionWorker

Inherits:
Object
  • Object
show all
Includes:
Sidekiq::Job
Defined in:
app/workers/accounting_document_transmission_worker.rb

Overview

Sidekiq worker: accounting document transmission.

Instance Method Summary collapse

Instance Method Details

#perform(document_class, document_id) ⇒ void

This method returns an undefined value.

Transmits an accounting document by building its communication.

Parameters:

  • document_class (String)

    class name of the document to transmit

  • document_id (Integer)

    primary key of the document record



12
13
14
15
16
17
18
19
20
# File 'app/workers/accounting_document_transmission_worker.rb', line 12

def perform(document_class, document_id)
  logger.info "Accounting document transmission worker starting and looking for #{document_class} ID: #{document_id}"
  doc = document_class.classify.constantize.where(id: document_id).first
  raise "Unable to find #{document_class} ID: #{document_id}" if doc.nil?
  return true if doc.transmitted?

  CommunicationBuilder.new(resource: doc).create
  logger.info "#{document_class} ID: #{document_id} transmission worker completed"
end