Mx Build Cfdi
mx__build_cfdiGenerate a valid, unsealed CFDI 4.0 XML Comprobante for Ingreso or Egreso invoices. Validates RFC fields and outputs the computed total for subsequent sealing.
Instructions
Build a well-formed, unsealed CFDI 4.0 Comprobante XML (Ingreso or Egreso).
comprobante_data is validated against CFDIComprobante — see that
model for the full field list (seller/buyer as MXEmisor/
MXReceptor, lines as CFDIConcepto, tipo_de_comprobante, etc.).
RFC fields are validated via TaxIdentifier.validate_mx_rfc as part of
model construction; a malformed RFC is reported as a validation error,
not a generated document.
The output XML omits Sello/NoCertificado/Certificado — those three
schema-required attributes are populated by mx__seal_cfdi, run
afterward. mx__validate_cfdi run on this output is expected to report
exactly those three attributes missing; that is not a bug in this tool.
For TipoDeComprobante="P" (Complemento de Pagos), use mx__build_pago
instead — this tool only builds Ingreso/Egreso Comprobantes.
Returns a dict with:
xml: the generated, unsealed CFDI 4.0 XML stringtotal: the computedTotalattribute (SubTotal - Descuento + traslados - retenciones)
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| comprobante_data | Yes | Fields matching the CFDIComprobante schema (Ingreso or Egreso only) |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||