How to: Calculate limits on node «mercancías» of «Comercio Exterior» complement of Mexican invoices.

In this post, I will explain how to perform the calculations of the «mercancia» limits of the foreign trade complement.

Things you should know before.

  • This post was written on February 19, 2020, you should verify that the validation rules are still valid in Anexo 20.
  • The post deals with rule CCE216, only the calculation of limits of the «mercancia» node.
  • The foreign trade complement is always expressed in USD.
  • I will not use conversions between units of measurement.
  • The numbers of decimals used for rounding are 2 in USD.

Example case:

I will use the following Cfdi for the tutorial:

Performing limit calculation:

I have coded a small console application to calculate the example and the utility class’s source code. The program takes the fixed inputs, it does not read the example file. You must be careful with the method you choose to read the file, if you take the cfdi data through serialization, the number of decimals may not match the original document. For example, 18.9000 in the cfdi can return in 18.9 in decimal or double object, for the program it is the same value for formulas no.

Points to consider.

The calculation of limits may vary depending on the language you use, the type of data or the accuracy of the calculations, this is more evident when handling numbers with many decimals.


Gustavo Sánchez

Soy especialista en escribir software de calidad. Mediante el uso de marcos de trabajo, técnicas y automatización de procesos he podido reducir los costes operativos de los sistemas de la empresa. Sistemas confiables y adaptables producen clientes felices.

2 comments On How to: Calculate limits on node «mercancías» of «Comercio Exterior» complement of Mexican invoices.

Comments are closed.