In this post, I am going to explain how to calculate the maximum and minimum values of «Concepto» Node for the «ComercioExterior» complement 1.1.
Things you should know before.
- This post was written on March 3, 2020, to verify that the validation rules are still in force in Anexo 20.
- The post deals with the CCE205 rule, only the calculation of minimum and maximum values of the Concept node.
- If you need to consult the CCE216 rule you can consult this post.
- The «ComercioExterior» complement is always expressed in USD.
- I will not use conversions between units of measurement.
- The decimal numbers used for rounding are 2 in USD.
Example case:
I’m going to use the following Cfdi for the tutorial:
Performing the calculation of limits:
I have coded a small console application to calculate the example along with the source code of the utility class. 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 data from the Cfdi through serialization, the number of decimals may not match the original document. For example, 18.9000 in the cfdi can return 18.9 in decimal or double object, for the program, it is the same value, not for the formulas.
What steps do I follow to calculate?
- Iterates in the nodes «Concepto» of the Cfdi.
- For each «Concepto» node. Obtain all «mercancia» nodes that have the same Identification Number as the concept (excluding those with «ValorDolares» at 0 and 1).
- In the case that there are no valid «mercancia» nodes, go to the next «Concepto» node.
- Iterate all the Cfdi «Concepto» nodes and obtain the sum of the «Importe» values of all concepts field with the same Identification Number as the current concept (2 or more «Concepto» nodes may have the same identification number and two or more «mercancia» nodes can have the same identification number).
- Get the «TipoCambio» value of the Cfdi (if the Cfdi was issued in MXN, this value may not exist, you should use 1 instead).
- Get the «TipoCambioUSD» value from the «ComercioExterior» complement.
- Obtain the number of decimals from the sum of Concept Amounts (Step 4).
- Get the number of decimals of the «TipoCambio» value of the Cfdi (if the Cfdi was issued in MXN, this value may not exist, you must use 2 instead).
- Get the number of decimals for the «TipoCambioUSD» value.
- Run the calculation of minimum value and maximum value.
- Round the values and maximums according to the Currency used in the Cfdi.
- Check the amount of «ValorDolares» that is equal to the Sum of the «ValorDolares» fields of the «mercancia» nodes with the same «NumeroIdentificacion» (some PACs calculate the «ValorDolares» field by multiplying the field «CantidadAduana» * «ValorUnitarioAduana» for each node «mercancia»).
- Verify that the «ValorDolares» amount is within the maximum and minimum value.
Points to consider.
The calculation of minimum and maximum values may vary depending on the programming language you use, the type of data or the precision of the calculations, this is more evident when you handle numbers with many decimals.
References:
- NVL in SQL Server - 2023-11-01
- ¿Que es Cake Build? - 2023-02-22
- #How to fix error: MSB4019: The imported project «Microsoft.Data.Tools.Schema.SqlTasks.targets» was not found - 2023-02-20