Daily updates from Odoo
Thursday, April 11, 2024
1 change
Resolved issues and error corrections
This update resolves multiple tax calculation and rounding errors in Mexican electronic invoices (CFDI) that were causing validation failures. The fixes ensure that tax amounts are calculated correctly whether rounding is applied per line or globally, exchange rates are handled consistently, and payment records are generated in a deterministic order. These corrections prevent invoices from being rejected by Mexican tax authorities.
Original PR description
**[FIX] round_per_line: Fix payment CFDI rounding issues** - 'base' * 'tasa_o_cuota' must give 'importe' with 0.01 rounding error allowed. Suppose an invoice of 5 * 0.47 with 16% tax. Each line gives…
**[FIX] round_per_line: Fix payment CFDI rounding issues** - 'base' * 'tasa_o_cuota' must give 'importe' with 0.01 rounding error allowed. Suppose an invoice of 5 * 0.47 with 16% tax. Each line gives a tax amount of 0.08 so 0.40 for the whole invoice. However, 5 * 0.47 = 2.35 and 2.35 * 0.16 = 0.38 so the constraint is failing. - 'base' + 'importe' must be exactly equal to the part that is actually paid. Using the same example, we need to report 2.35 + 0.40 = 2.75 **[FIX] round_globally: Manage round globally** Before, the results given in case of round_globally was the same as round_per_line. Suppose an invoice of 5 * 0.47 with 16% tax. We were sending a tax detail of 0.47 * 0.16 ~= 0.08 for each line, so 0.40 for the whole invoice. However, in case of round globally, the total tax is 5 * 0.47 * 0.16 ~= 0.38. The invoice was incorrectly reported as an invoice of 2.75 instead of 2.73. To fix that, the base/tax amount per line are now given using 6 decimals. **[FIX] Deterministic invoices's order in payment CFDI** Before generating a payment CFDI, make sure the invoices are sorted in order to avoid a not deterministic xml. **[FIX] Rounding of TipoCambio** On the xml, the rate to switch from the invoice to payment rate is rounded to 6 decimals. By consistency, we need to use the same number of decimals during the computation to avoid the xml to be rejected. For example: With an MX company setup USD Exchange rate: - Yesterday 17.187 - Today 17.0357 Create an invoice with: - date: yesterday, quantity: 200, unit price: 7.34 USD, tax: 16% Confirm and Send the invoice Register the payment with today date Open the payment and force cfdi SAT Validation will return an error: ''' Code : CRP20204 Message : El valor del campo TotalTrasladosBaseIVA16 no es igual al redondeo de la suma del resultado de multiplicar cada uno de los importes de los atributos BaseP de los impuestos trasladados registrados en el elemento TrasladoP donde los atributos contengan en ImpuestoP el valor IVA, en TipoFactorP el valor Tasa y en TasaOCuotaP el valor 0.160000, por el valor registrado en el atributo TipoCambioP de cada nodo Pago. ''' opw-3775099 **[FIX] Rounding of TotalTrasladosBaseIVA16** - Have an MX company setup - USD Exchange rate: - Yesterday 16.9912 - Today 17.068 - Create two invoices as follows: 1) date yesterday, qty 68.25, unit price 68 USD, tax 16%, total 5383.56 USD 2) date yesterday, qty 24.00, unit price 68 USD, tax 16%, total 1893.12 USD Confirm and Send the two invoices In invoices list view, select both and register payment Select 'Group Payments' Open one of the invoices, and press "Update Payments" In CFDI Tab Force cfdi for the payment Issue: Cfdi validation return an error """ Code : CRP20204 Message : El valor del campo TotalTrasladosBaseIVA16 no es igual al redondeo de la suma del resultado de multiplicar cada uno de los importes de los atributos BaseP de los impuestos trasladados registrados en el elemento TrasladoP donde los atributos contengan en ImpuestoP el valor IVA, en TipoFactorP el valor Tasa y en TasaOCuotaP el valor 0.160000, por el valor registrado en el atributo TipoCambioP de cada nodo Pago. """ opw-3775099 Forward-Port-Of: odoo/enterprise#60025