Class: Edi::InvoiceEventProcessor
- Inherits:
-
BaseService
- Object
- BaseService
- Edi::InvoiceEventProcessor
- Defined in:
- app/services/edi/invoice_event_processor.rb
Overview
Service object: invoice event processor.
Instance Attribute Summary
Attributes inherited from BaseService
Instance Method Summary collapse
- #load_orchestrator(customer_id) ⇒ Object
- #process_creation(invoice, options = {}) ⇒ void
-
#regenerate_and_transmit(invoice) ⇒ EdiCommunicationLog?
Regenerate the EDI invoice message and transmit it immediately, mirroring the manual "Regenerate EDI Documents" + "Process" two-step on the invoice screen.
Methods inherited from BaseService
#initialize, #log_debug, #log_error, #log_info, #log_warning, #logger, #process, #tagged_logger
Constructor Details
This class inherits a constructor from BaseService
Instance Method Details
#load_orchestrator(customer_id) ⇒ Object
43 44 45 |
# File 'app/services/edi/invoice_event_processor.rb', line 43 def load_orchestrator(customer_id) Edi::BaseOrchestrator.orchestrator_for_customer_id(customer_id) end |
#process_creation(invoice, options = {}) ⇒ void
This method returns an undefined value.
10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'app/services/edi/invoice_event_processor.rb', line 10 def process_creation(invoice, = {}) return unless invoice.order&.edi_transaction_id return unless (o = load_orchestrator(invoice.customer_id)) if [:skip_if_exists] && invoice.edi_communication_logs.where(category: "invoice").exists? logger.info "Edi -> Skipping creation for invoice #{invoice.id}, EDI invoice message already exists" return end logger.info "Edi -> Processing creation event for invoice id #{invoice.id}" o..confirm_invoice(invoice) if o. o..create_invoice(invoice, { transmit_after: 30.minutes.from_now }) if o. end |
#regenerate_and_transmit(invoice) ⇒ EdiCommunicationLog?
Regenerate the EDI invoice message and transmit it immediately, mirroring
the manual "Regenerate EDI Documents" + "Process" two-step on the invoice
screen. process_creation stamps a 30-minute transmit_after; calling
#process on the fresh invoice-category log bypasses that delay and sends
now (the log is ready, so no force is needed — same as the Process button).
33 34 35 36 37 38 39 40 41 |
# File 'app/services/edi/invoice_event_processor.rb', line 33 def regenerate_and_transmit(invoice) process_creation(invoice) log = invoice.edi_communication_logs .where(category: "invoice", state: "ready") .order(created_at: :desc) .first log&.process log end |