Add Complements to CFDI: Nómina, Carta Porte, Pagos, and More
Attach SAT-recognized complements to CFDI 4.0 documents including Nómina 1.2, Carta Porte 3.0/3.1, Comercio Exterior 2.0, and custom unsupported complements.
Use this file to discover all available pages before exploring further.
Complements (complementos) are optional but frequently required XML extensions that the SAT defines for specific invoice types — payroll receipts, freight documents, foreign-trade exports, payments, and more. In CfdiUtils, a complement is an element or raw node that you attach to the cfdi:Complemento wrapper inside a Comprobante using the addComplemento() method.The library ships with typed element helpers for several of the most common complements under CfdiUtils\Elements. For complements that do not yet have a dedicated element class, you can fall back to the generic CfdiUtils\Nodes\Node API and attach the raw node directly. Both paths produce the same XML output.
Namespace:CfdiUtils\Elements\Nomina12 XML prefix:nomina12 XML namespace URI:http://www.sat.gob.mx/nomina12 XSD:http://www.sat.gob.mx/sitio_internet/cfd/nomina/nomina12.xsdThe Nómina 1.2 revision B complement is valid from January 1, 2020. It is used on TipoDeComprobante = 'N' (payroll) invoices.Node hierarchy (abbreviated):
Methods prefixed with get retrieve-or-create the single child node (for [0,1] nodes). Methods prefixed with add for multi-occurrence nodes ([0,N]) always append a new child. Methods prefixed with multi accept variadic attribute arrays and add multiple children at once.
Namespace:CfdiUtils\Elements\CartaPorte30 XML prefix:cartaporte30 XML namespace URI:http://www.sat.gob.mx/CartaPorte30 XSD:http://www.sat.gob.mx/sitio_internet/cfd/CartaPorte/CartaPorte30.xsd Effective: January 1, 2024Carta Porte 3.0 is used on transport invoices that move goods within Mexico.Key element methods on CartaPorte:
Namespace:CfdiUtils\Elements\CartaPorte31 XML prefix:cartaporte31 XML namespace URI:http://www.sat.gob.mx/CartaPorte31 XSD:http://www.sat.gob.mx/sitio_internet/cfd/CartaPorte/CartaPorte31.xsd Effective: July 17, 2024Carta Porte 3.1 is the current version of the transport complement. Its element structure is nearly identical to 3.0, with the addition of RegimenesAduaneros on the root CartaPorte node.Extra element methods on CartaPorte (3.1 only):
Method
Returns
getRegimenesAduaneros()
RegimenesAduaneros
Usage is otherwise the same as 3.0 — just substitute the namespace:
<?phpuse CfdiUtils\CfdiCreator40;use CfdiUtils\Elements\CartaPorte31\CartaPorte;$creator = new CfdiCreator40(/* ... */);$comprobante = $creator->comprobante();$cartaPorte = new CartaPorte(['Version' => '3.1', 'TranspInternac' => 'No']);// ... populate $cartaPorte the same way as 3.0 ...$comprobante->addComplemento($cartaPorte);
Namespace:CfdiUtils\Elements\Cce20 XML prefix:cce20 XML namespace URI:http://www.sat.gob.mx/ComercioExterior20 XSD:http://www.sat.gob.mx/sitio_internet/cfd/ComercioExterior20/ComercioExterior20.xsd Effective: January 15, 2024Comercio Exterior 2.0 is required when exporting goods from Mexico. Compared to version 1.1, the Emisor/Domicilio and Mercancias nodes are now mandatory, and TipoOperacion and Subdivision attributes were removed.Key element methods on ComercioExterior:
Not every SAT complement has a dedicated element class in CfdiUtils\Elements. Because CfdiUtils stores all document data as CfdiUtils\Nodes\Node objects internally, you can construct any complement manually using the same low-level API and attach it to the comprobante.The following example attaches a Leyendas Fiscales complement, which does not have a typed element helper:
<?phpuse CfdiUtils\CfdiCreator40;use CfdiUtils\Nodes\Node;$creator = new CfdiCreator40(/* ... */);$comprobante = $creator->comprobante();// Build the complement node manually using CfdiUtils\Nodes\Node$leyendasFisc = new Node( 'leyendasFisc:LeyendasFiscales', [ // Required XML namespace declarations for this complement 'xmlns:leyendasFisc' => 'http://www.sat.gob.mx/leyendasFiscales', 'xsi:schemaLocation' => 'http://www.sat.gob.mx/leyendasFiscales' . ' http://www.sat.gob.mx/sitio_internet/cfd/leyendasFiscales/leyendasFisc.xsd', 'version' => '1.0', ]);// Add child nodes the same way$leyendasFisc->addChild(new Node('leyendasFisc:Leyenda', [ 'disposicionFiscal' => 'RESDERAUTH', 'norma' => 'Artículo 2. Fracción IV.', 'textoLeyenda' => 'El software desarrollado se entrega con licencia MIT',]));// Attach to the comprobante — same API as typed complements$comprobante->addComplemento($leyendasFisc);$creator->saveXml('cfdi_with_leyendas.xml');
The resulting XML places the xmlns:leyendasFisc declaration on the complement node itself. After calling $creator->moveSatDefinitionsToComprobante() the declaration is promoted to the root cfdi:Comprobante node, as required by the SAT:
A full list of SAT-defined complements and their XSD schemas is published at the SAT’s electronic invoice portal: http://www.sat.gob.mx/informacion_fiscal/factura_electronica/Paginas/complementos_factura_cfdi.aspx
The Pagos (Payment) complement is used on TipoDeComprobante = 'P' payment receipts. CfdiUtils includes a dedicated writer helper — CfdiUtils\SumasConceptos\SumasConceptosWriterPagos20 — that automatically calculates and writes the Totales node of the Pagos 2.0 complement.
Pagos 2.0 Utility
See the Pagos 2.0 documentation for the full API including SumasPagos20 and how to attach and compute the payment totals automatically.