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.
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.