billing.exchange) manages the exchange of electronic tax documents between trading parties, including sending to SII and trading partners.
Overview
This component handles the complete document exchange workflow, supporting multiple delivery channels and strategies for both sending and receiving documents.Workers
The Exchange Component contains the following workers:Sender Worker
Sends documents to recipients using various strategies (SII, email, API)
Receiver Worker
Receives and processes incoming documents from trading partners
Main Methods
send
Sends one or more documents to their recipients.Exchange bag containing the documents to send and delivery configuration
Returns an array with the results of the send operation for each document
receive
Receives and processes incoming documents.Exchange bag configured for receiving documents
Returns an array of received and processed documents
handle
Intelligently handles an exchange bag, automatically determining whether to send or receive based on the bag contents.Exchange bag to process
Returns results from either send or receive operation
Worker Access Methods
getSenderWorker
Returns the sender worker for sending documents.Returns the sender worker instance
getReceiverWorker
Returns the receiver worker for receiving documents.Returns the receiver worker instance
getWorkers
Returns all available workers.Returns an associative array with worker names as keys:
sender: SenderWorkerInterfacereceiver: ReceiverWorkerInterface
Sending Strategies
The sender worker supports multiple strategies for document delivery:DTE Sender Strategy
DTE Sender Strategy
Sends regular DTE (Documento Tributario Electrónico) documents to SII.Strategy:
DteSenderStrategyLocation: /workspace/source/src/Package/Billing/Component/Exchange/Worker/Sender/Strategy/Sii/DteSenderStrategy.phpBoleta Sender Strategy
Boleta Sender Strategy
Sends boletas (electronic receipts) to SII using the specific boleta endpoint.Strategy:
BoletaSenderStrategyLocation: /workspace/source/src/Package/Billing/Component/Exchange/Worker/Sender/Strategy/Sii/BoletaSenderStrategy.phpExchange Entities
The component works with the following entities:Sender
Represents the party sending documents with authentication and configuration. Entity:libredte\lib\Core\Package\Billing\Component\Exchange\Entity\Sender
Receiver
Represents the party receiving documents with endpoint configuration. Entity:libredte\lib\Core\Package\Billing\Component\Exchange\Entity\Receiver
PartyIdentifier
Identifies a party in the exchange (RUT, email, etc.). Entity:libredte\lib\Core\Package\Billing\Component\Exchange\Entity\PartyIdentifier
PartyEndpoint
Defines an endpoint for document delivery (URL, email, etc.). Entity:libredte\lib\Core\Package\Billing\Component\Exchange\Entity\PartyEndpoint
Usage Example
Document Flow
When handling an exchange:- The
handle()method checks if the bag has envelopes - If envelopes exist, it routes to the sender worker
- If no envelopes, it routes to the receiver worker
- The appropriate worker processes the documents using the configured strategy
- Results are returned to the caller
Source Reference
Namespace:libredte\lib\Core\Package\Billing\Component\Exchange\ExchangeComponent
Location: /workspace/source/src/Package/Billing/Component/Exchange/ExchangeComponent.php:40