Skip to main content

Relationships between CFDI

In addition to the different types of invoices, there is a concept known as "Related CFDI" used when additional information about a transaction needs to be issued.

Some Examples of Invoice Relationships

To fully understand all the available options when creating an invoice, detailed descriptions of each field, and the most commonly used catalogs, please refer to the Create Invoice API reference.

When giving a discount

When making a sale with a discount, an outgoing CFDI can be issued to make that discount deductible.

const Facturapi = require('facturapi');
const facturapi = new Facturapi('sk_test_API_KEY');

const invoice = await facturapi.invoices.create({
type: "E",
customer: {
legal_name: 'Dunder Mifflin',
email: 'email@example.com',
tax_id: 'ABC101010111',
tax_system: '601',
address: {
zip: '85900'
}
},
items: [{
product: {
description: 'Descuento',
price: 400,
taxes: [
{
type: 'IVA',
rate: 0.16
}
]
}
}],
payment_form: "28", // "Debit card"
related_documents: [
{
relationship: "01", // "Credit note of related documents"
uuid: "UUID_DEL_CFDI_DE_INGRESO"
}
]
});

Returns

When your customer returns a product that was previously invoiced you must issue an Egress invoice, adding the relation to the original Income invoice.

const Facturapi = require('facturapi');
const facturapi = new Facturapi('sk_test_API_KEY');

const invoice = await facturapi.invoices.create({
type: "E",
customer: {
legal_name: 'Dunder Mifflin',
email: 'email@example.com',
tax_id: 'ABC101010111',
tax_system: '601',
address: {
zip: '85900'
}
},
items: [{
product: {
description: 'Devolución total de mercancía',
price: 5000,
taxes: [
{
type: 'IVA',
rate: 0.16
}
]
}
}],
payment_form: "28", // "Debit card"
related_documents: [
{
relationship: "01", // "Credit note of related documents"
uuid: "UUID_DEL_CFDI_DE_INGRESO"
}
]
});

Cancellation of a previous CFDI

When an invoice is canceled and a new one is issued, it is possible to relate them to indicate that the new CFDI is the replacement of a previous document.

const Facturapi = require('facturapi');
const facturapi = new Facturapi('sk_test_API_KEY');

const invoice = await facturapi.invoices.create({
type: "I",
customer: {
legal_name: 'Dunder Mifflin',
email: 'email@example.com',
tax_id: 'ABC101010111',
tax_system: '601',
address: {
zip: '85900'
}
},
items: [{
product: {
description: 'Venta de mercancía',
price: 5000,
taxes: [
{
type: 'IVA',
rate: 0.16
}
]
}
}],
payment_form: "01", // "Efectivo"
related_documents: [
{
relationship: "04", // "Sustitución de los CFDI previos"
uuid: "UUID_DEL_CFDI_PREVIO"
}
]
});