Costa Rica Electronic Invoicing 4.4 - Factura Electronica Costa Rica Hacienda, FE 4.4, Tiquete, Nota de Credito
by Modvanta https://modvantaapps.tech$ 28.92

Send Costa Rica comprobantes electronicos version 4.4 from your Odoo invoices: Factura, Tiquete, Nota de credito, Nota de debito and Factura de exportacion, signed with your ATV key and sent to the Hacienda recepcion API.
The module builds the 50 digit clave and the 20 digit consecutivo per establishment, terminal and document type, puts the CABYS code on every line, signs with XAdES-EPES and the Hacienda policy, logs in at the IdP and reads Hacienda's answer.
Please read: not yet tested against the live Hacienda API
Built from the public Ministerio de Hacienda document Anexos y Estructuras version 4.4 (structure, notes, signature example, IdP and API) and the public recepcion API page.
The 4.4 XSD files could not be downloaded from Hacienda's site, so the XML follows the element order and conditions of the Anexos and is checked by the module's own rules, not by the XSD. Hacienda answers were simulated. Test in the Hacienda sandbox with your own ATV user and key before you issue real comprobantes.
Who it is for
Companies in Costa Rica that issue their own comprobantes from Odoo 19 with the key and API user generated in ATV, without paying a monthly provider, and the Odoo partners who set it up for them.
Key features
Consecutivo and Hacienda status on the list
Each invoice shows its numero consecutivo and its Hacienda status: to send, sent, accepted, rejected or a connection problem. You can search by clave.

Clave, consecutivo and Hacienda's answer on the invoice
The Hacienda tab keeps the comprobante type, the 50 digit clave, the consecutivo, the emission date, the signed XML named clave.xml, Hacienda's answer named clave_respuesta.xml and every call.

Printed Factura
The printout carries the document type, consecutivo and clave (Nota 1), the CABYS of each line, the IVA rate label, the sale condition and payment method, the totals and a QR with the clave.

Tiquete for consumers
Customers without identification get a Tiquete Electronico with its own consecutivo.

Factura de exportacion in USD
Customers abroad get a Factura Electronica de Exportacion with the foreign id, the currency code and the exchange rate.

Notas de credito and debito with the original clave
Credit and debit notes refer to the original clave with the document type and the reference code you choose (anula, corrige monto, devolucion de mercancia).

CABYS code on the product
Each product carries its 13 digit CABYS code and, for exports, the partida arancelaria. A product without CABYS stops the comprobante before a number is used.

Establishment and terminal per journal
Each sales journal has its establishment and terminal; numbering runs without gaps per document type.

Settings
Simulation, sandbox or production, the issuer identification type, economic activity, software provider id, location codes, the ATV key and the API user and password, with a button to test the login.

How it works
- Install the module on a company with the Costa Rica chart of accounts (l10n_cr).
- In Accounting settings fill the issuer data and the location codes, then load your ATV key and API user for the sandbox.
- Add the CABYS code to your products and tick Costa Rica comprobantes on the sales journal.
- Post an invoice and press Send to Hacienda, or let the scheduled job do it.
- The module signs the XML, gets a token from the IdP, sends the comprobante and reads the answer until Hacienda accepts or rejects it.
- Print or email the invoice: the customer receives the PDF, the signed XML and Hacienda's answer.
Settings
- Mode: Simulation (local, no fiscal value), Hacienda sandbox or production.
- Issuer: identification type, economic activity code (6 digits), software provider id, provincia, canton, distrito and barrio.
- ATV key (.p12) stored by the Odoo certificate module; API user and password readable only by administrators.
- Sandbox IdP address and client id, limited to comprobanteselectronicos.go.cr addresses. Production uses the address published in Anexo 3.
- Per sales journal: establishment and terminal. Per tax: the CodigoTarifaIVA when the rate alone is not enough. Per unit: the Hacienda unit code.
What was tested
- 39 automated tests: every comprobante type of this module, goods and services, IVA 13 and 4 percent and exempt lines, discounts, USD exports, notes, numbering, rejections and reissue, retries, the IdP login, the printout and access rights.
- Each signed XML is verified in the tests: the document digest, the SignedProperties digest and the RSA-SHA256 value, with the policy hash published by Hacienda.
What is not included
- Factura electronica de compra and Recibo electronico de pago.
- Exoneraciones, otros cargos and impuestos other than IVA.
- Accepting or rejecting supplier comprobantes (MensajeReceptor).
- Validation against the 4.4 XSD files, which were not available for download.
FAQ
Do I need a provider?
No. Odoo signs with your ATV key and calls the Hacienda API directly with your API user.
Can I try it first?
Yes. Simulation runs the whole flow locally; those comprobantes have no fiscal value. Then use the Hacienda sandbox.
What happens if Hacienda does not answer?
The comprobante keeps its clave and signed XML; the next try sends the same document.
What if Hacienda rejects it?
You see Hacienda's message. Fix the cause and press Issue again with a new consecutivo.
Which IVA rates?
13, 4, 2, 1 and 0.5 percent follow from the rate; 0 percent is exenta unless you set another code on the tax.
En espanol
Emita comprobantes electronicos version 4.4 desde Odoo: Factura, Tiquete, Nota de credito, Nota de debito y Factura de exportacion, firmados con XAdES-EPES y su llave de ATV, y enviados al API de recepcion de Hacienda.
Incluye clave de 50 digitos, consecutivo por sucursal y terminal, CABYS por linea, token del IdP y respuesta de Hacienda adjunta. Pruebe en el ambiente de pruebas de Hacienda antes de emitir comprobantes reales.
Compatibility
Odoo 19 Community and Enterprise. Depends on Costa Rica accounting (l10n_cr), debit notes and the certificate module, all part of Odoo.
Support
Write to modvantaapps@gmail.com.
| Availability |
Odoo Online
Odoo.sh
On Premise
|
| Odoo Apps Dependencies |
•
Invoicing (account)
• Discuss (mail) |
| Lines of code | 1241 |
| Technical Name |
mdv_cr_einvoice |
| License | OPL-1 |
| Website | https://modvantaapps.tech |
Odoo Proprietary License v1.0 This software and associated files (the "Software") may only be used (executed, modified, executed after modifications) if you have purchased a valid license from the authors, typically via Odoo Apps, or if you have received a written agreement from the authors of the Software (see the COPYRIGHT file). You may develop Odoo modules that use the Software as a library (typically by depending on it, importing it and using its resources), but without copying any source code or material from the Software. You may distribute those modules under the license of your choice, provided that this license is compatible with the terms of the Odoo Proprietary License (For example: LGPL, MIT, or proprietary licenses similar to this one). It is forbidden to publish, distribute, sublicense, or sell copies of the Software or modified copies of the Software. The above copyright notice and this permission notice must be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Please log in to comment on this module