billing.document) handles the complete lifecycle of tax documents, including creation, validation, rendering, and batch processing.
Overview
This component provides all functionality needed to work with Chilean electronic tax documents (DTE). It processes input data, validates it, builds XML documents, and prepares them for signing and submission.Workers
The Document Component contains the following workers:Builder
Constructs tax documents from normalized data
Parser
Parses input data into internal format
Validator
Validates document data and structure
Normalizer
Normalizes data to standard format
Renderer
Renders documents to XML, PDF, or other formats
Sanitizer
Cleans and sanitizes input data
Loader
Loads existing documents from storage
Dispatcher
Dispatches documents for processing
Batch Processor
Processes multiple documents in batch
Document Bag Manager
Manages DocumentBag containers
Main Methods
bill
Creates a complete tax document ready for signing and submission.Document data in JSON string, array, or object format. Contains all document information like header, items, totals, etc.
CAF (Folio Authorization Code). Can be:
- XML string containing the CAF
- CafInterface object
- null if not required
Digital certificate for signing. Can be:
- Path to certificate file
- Array with certificate data
- CertificateInterface object
- null if signing will be done later
Additional options for document processing
Returns a DocumentBag containing the processed document with all metadata
Worker Access Methods
Returns the builder worker for constructing documents
Returns the parser worker for parsing input data
Returns the validator worker for document validation
Returns the normalizer worker for data normalization
Returns the renderer worker for document rendering
Returns the sanitizer worker for data sanitization
Returns the loader worker for loading documents
Returns the dispatcher worker for document dispatch
Returns the batch processor worker for processing multiple documents
Returns the document bag manager worker
Returns an array of all workers with their keys
Document Processing Flow
When calling thebill() method, the component:
- Loads the CAF if provided as a string
- Creates a DocumentBag container with input data, options, CAF, and certificate
- Parses the input data through the ParserWorker
- Builds the final document through the BuilderWorker
- Returns the DocumentBag with the complete document
Source Reference
Namespace:libredte\lib\Core\Package\Billing\Component\Document\DocumentComponent
Location: /workspace/source/src/Package/Billing/Component/Document/DocumentComponent.php:55