Sales Invoices are stamped as CFDI Tipo Ingreso documents (Documentation Index
Fetch the complete documentation index at: https://mintlify.com/TI-Sin-Problemas/erpnext_mexico_compliance/llms.txt
Use this file to discover all available pages before exploring further.
TipoDeComprobante.INGRESO). When a Sales Invoice is stamped, the app assembles a cfdi40.Comprobante from the invoice data, signs it with the selected Digital Signing Certificate, and sends it to the TI Sin Problemas web service for PAC stamping. The resulting UUID and stamped XML are stored directly on the Sales Invoice record.
Requirements
All of the following conditions must be satisfied before a Sales Invoice can be stamped:- The Company address must have a Zip Code (
pincodeon the Address DocType). - The Customer must have a valid Mexican Tax ID (RFC) in the
tax_idfield. - The Customer must have a SAT Tax Regime (
mx_tax_regime) set. - The Customer’s billing address must have a Zip Code.
- Every Invoice Item must have a SAT Product or Service Key (
mx_product_service_key). - The UOM of every Invoice Item must have a SAT UOM Key (
mx_uom_key). - The Mode of Payment on the invoice must have a SAT Payment Method code assigned.
- The invoice must have a SAT Payment Option (
mx_payment_option) selected. - At least one Digital Signing Certificate must exist for the Company issuing the invoice.
- You must have available stamp credits in your TI Sin Problemas account.
Stamping a Sales Invoice
Submit the Sales Invoice
Complete and submit the Sales Invoice in ERPNext as you normally would. The document must reach Submitted status before it can be stamped.
Locate the Stamp CFDI button
Once the invoice is submitted, a Stamp CFDI button appears on the form. This button is only visible on submitted, un-stamped invoices.
Select the Digital Signing Certificate
If prompted, select the Digital Signing Certificate (CSD) to use for this invoice. Only certificates associated with the invoice’s Company are shown.
Click Stamp CFDI
The app validates the company address, customer details, and all line items, then signs the CFDI and posts it to
tisp_apps.api.v1.cfdi.stamp. If any validation fails, a descriptive error is shown before any API call is made.If
stamp_on_submit is enabled in CFDI Stamping Settings, steps 2–5 happen automatically at the moment of submission. See the next section for details.Auto-stamp on submit
In CFDI Stamping Settings, the Stamp on Submit (stamp_on_submit) toggle controls automatic stamping. When enabled, the on_submit hook of the Sales Invoice override fires immediately after the document is submitted:
CFDI field mapping
The table below shows how ERPNext fields are translated into CFDI 4.0 XML elements when theget_cfdi_voucher method assembles the cfdi40.Comprobante:
| ERPNext Field | CFDI Element |
|---|---|
| Company (Emisor RFC from CSD) | Emisor/Rfc |
| Company Address Zip Code | LugarExpedicion |
Customer Tax ID (tax_id) | Receptor/Rfc |
| Customer Name — uppercased | Receptor/Nombre |
| Customer Address Zip Code | Receptor/DomicilioFiscalReceptor |
Customer SAT Tax Regime (mx_tax_regime) | Receptor/RegimenFiscalReceptor |
SAT CFDI Use (mx_cfdi_use) | Receptor/UsoCFDI |
SAT Payment Option (mx_payment_option) | MetodoPago |
SAT Payment Method code (mx_payment_mode) | FormaPago |
| Currency | Moneda |
| Conversion Rate (when not MXN) | TipoCambio |
| Posting Date + Posting Time | Fecha |
| Item SAT Product/Service Key | Concepto/ClaveProdServ |
| Item UOM SAT Key | Concepto/ClaveUnidad |
| Item Code | Concepto/NoIdentificacion |
| Item Quantity | Concepto/Cantidad |
| Item Rate + Discount Amount (pre-discount unit price) | Concepto/ValorUnitario |
| Item Discount Amount | Concepto/Descuento |
Related Sales Invoices
Themx_related_sales_invoices child table allows you to link one or more previously stamped CFDIs to the current invoice using an SAT relationship type (e.g., substitute for a cancelled invoice, credit note, etc.). Each row contains:
- Sales Invoice — the related ERPNext Sales Invoice.
- UUID — automatically read from the related invoice’s
mx_uuidfield. - SAT Relationship Type — the SAT catalog code for the relationship (e.g.,
04for substitution).
mx_related_sales_invoices has a UUID. If any related invoice has not yet been stamped, saving the current invoice is blocked with an error.
When the CFDI voucher is assembled, each unique relationship type becomes a cfdi40.CfdiRelacionados element containing the UUIDs for that type:
Addenda
The SAT allows issuers to append custom XML content inside a<cfdi:Addenda> element. The app supports addenda at two levels:
- Customer-level (
mx_addendaon the Customer DocType) — default addenda applied to all invoices for that customer. - Invoice-level (
mx_addendaon the Sales Invoice) — per-invoice addenda that overrides or supplements the customer default.
mx_addenda is treated as a Jinja template rendered with the current document as the doc context variable:
<cfdi:Addenda> element inside the SAT namespace (http://www.sat.gob.mx/cfd/4). The addenda is injected into the stamped XML after the PAC stamps the document — the final mx_stamped_xml stored on the invoice includes the addenda.
Download CFDI files
Once a Sales Invoice is stamped, the Download CFDI Files button packages both the stamped XML and the rendered PDF into a ZIP archive named{invoice_name}_CFDI.zip. The archive contains:
{invoice_name}_CFDI.xml— the full SAT-stamped XML withTimbreFiscalDigital.{invoice_name}_CFDI.pdf— the CFDI PDF representation.