Dolibarr module for integration with the VeriFactu system of the Spanish Tax Agency (AEAT).
This project originates from the open source verifactu code originally developed by Alberto SuperAdmin (Alberto Luque Rivas) from easysoft.es and distributed under the GPL v3 license.
This module was developed from the original module licensed under GPL v3 (GNU General Public License version 3). On this basis:
- The code was reorganized and modularized to improve maintainability
- Documentation and comments were translated to English
- A new internal library was created (OpenAEAT\Billing)
This fork maintains all code under GPL v3, respecting the original license and the rights of the original authors, adding the corresponding attribution in all files.
VeriFactu is the AEAT invoice verification system that allows:
- Automatic sending of invoices to AEAT
- Generation of verification QR codes
- Cryptographic chaining of invoices (SHA-256)
- Query of sent invoice status
- Invoice cancellation
- Management of corrective invoices
- Dolibarr 13.0 or higher
- PHP 7.4 or higher
- PHP SOAP extension enabled
- PHP OpenSSL extension enabled
- PHP GD extension enabled (for QR)
- Valid digital certificate (FNMT or equivalent)
- Copy the
verifactufolder to Dolibarr'shtdocs/custom/directory - Go to Setup > Modules in Dolibarr
- Search for "VeriFactu" in the module list
- Activate the module
Go to Setup > Modules > VeriFactu > Configuration
- Environment: Select Test or Production
- Issuer NIF: Company's tax ID number
- Name/Company Name: Company name
Go to Setup > Modules > VeriFactu > Certificates
- Upload the certificate in PFX/P12 format
- Enter the certificate password
- Verify that the certificate is valid
The certificate must be:
- Legal entity certificate (company)
- Issued by a recognized CA (FNMT, etc.)
- Valid and not revoked
Configure the invoicing system data:
- Developer NIF: Software developer's tax ID
- System Name: Name of the invoicing system
- System ID: Unique system identifier
- Version: Software version
- Create an invoice in Dolibarr
- Validate the invoice
- In the "VeriFactu" tab of the invoice:
- Click on "Send to AEAT"
- Verify the response status
- Go to Invoicing > VeriFactu > AEAT Query
- Select the search filters:
- Imputation period (year/month)
- Date range
- Counterparty (customer's NIF)
- Click "Query"
- Access the sent invoice
- In the "VeriFactu" tab:
- Click on "Cancel in AEAT"
- Select the cancellation type
- Confirm the operation
The QR code is automatically generated when sending the invoice and is displayed in:
- The invoice view
- The invoice PDF (if configured)
- The POS receipt (if enabled)
| Code | Description |
|---|---|
| F1 | Full invoice |
| F2 | Simplified invoice |
| F3 | Substitute invoice for simplified ones |
| R1 | Corrective (error based on law) |
| R2 | Corrective (Art. 80.3) |
| R3 | Corrective (Art. 80.4) |
| R4 | Corrective (other) |
| R5 | Corrective in simplified invoice |
- Spanish (es_ES)
- Catalan (ca_ES)
- Basque (eu_ES)
- Galician (gl_ES)
- English (en_US)
The module includes a complete Responsible Declaration system in compliance with current Spanish regulations:
- RD 1007/2023 - VeriFactu Regulation
- RD 254/2025 - Modifications and deadlines
- Order HAC/1177/2024 - Technical specifications
- Art. 29.2.j) Law 58/2003 - General Tax Law
The configuration is located in conf/declaracion_responsable.conf.php and includes:
| Section | Content |
|---|---|
| Producer Data | NIF, company name, address, contact |
| System Data | Name, IdSistemaInformatico, version |
| Components | Required software and hardware |
| Technical Specifications | Signature type (XAdES), hash algorithm (SHA-256) |
| Integrity | Dynamically calculated module hash |
| Compliance | Declaration according to Art. 29.2.j) LGT |
| Subscription | Date, place and signatory |
// Get complete configuration with calculated hash
$declaration = obtenerDeclaracionResponsable(true);
// Validate required fields
$errors = validarDeclaracionResponsable();
// Calculate SHA-256 hash of the module
$hash = calcularHashModuloVerifactu();
// Export in JSON format
$json = exportarDeclaracionJSON();The responsible declaration is available at:
- Menu: VeriFactu > Responsible Declaration
- JSON Export:
/verifactu/views/declaration_json.php
For more details, see docs/responsible_declaration.md.
verifactu/
├── admin/ # Administration pages
│ ├── setup.php # General configuration
│ ├── managecertificates.php # Certificate management
│ └── uploadcertificates.php # Certificate upload
├── class/ # PHP classes
│ ├── actions_verifactu.class.php # Hooks and actions
│ ├── api_verifactu.class.php # REST API
│ └── verifactu.utils.php # Utilities
├── conf/ # Configuration
│ └── declaracion_responsable.conf.php # Responsible declaration
├── core/
│ ├── modules/ # Module descriptor
│ └── triggers/ # Automatic triggers
│ ├── interface_900_modVerifactu_BillRestrictions.class.php
│ └── interface_999_modVerifactu_VerifactuTriggers.class.php
├── docs/ # Documentation
│ └── responsible_declaration.md # Responsible declaration doc
├── lib/
│ ├── newfenix/ # OpenAEAT Billing Library
│ │ ├── src/ # Main classes
│ │ └── vendor/ # Dependencies (QRCode)
│ └── functions/ # Module functions
│ ├── functions.submission.php # Invoice submission
│ ├── functions.query.php # AEAT queries
│ ├── functions.cancellation.php # Cancellation
│ ├── functions.certificates.php # Certificates
│ ├── functions.qr.php # QR generation
│ └── functions.response.php # AEAT responses
├── views/ # Views and pages
│ ├── list.facture.php # Invoice list
│ ├── query.facture.php # AEAT query
│ ├── tabVERIFACTU.facture.php # VeriFactu tab
│ ├── declaration.php # Responsible declaration
│ ├── declaration_json.php # Declaration JSON export
│ ├── faq.php # Help and FAQ
│ ├── pos.facture.php # POS receipt
│ └── documentation.php # Documentation
├── langs/ # Language files
├── css/ # CSS styles
├── js/ # JavaScript
└── README.md # This file
The module exposes a REST API for external integration:
GET /api/index.php/verifactu/integrity
This error indicates a problem with the SOAP message structure. Check:
- Date format (DD-MM-YYYY)
- Issuer and recipient data
- Certificate configuration
If the certificate is not recognized:
- Verify that the certificate has not expired
- Check that the password is correct
- Ensure that the certificate is for a legal entity
If a blank screen appears when viewing invoices:
- Check PHP logs for errors
- Verify that all PHP extensions are installed
- Version: 1.0.3
- Author: Germán Luis Aracil Boned
- Email: [email protected]
- License: GPL-3.0-or-later
- Dedicated to: My colleague and friend Ildefonso González Rodríguez
- Updated mandatory VeriFactu dates: Adjusted automatic production mode transition dates from 2026 to 2027 following the Spanish government's delay announcement:
- Companies: January 1, 2027 (was January 1, 2026)
- Self-employed: July 1, 2027 (was July 1, 2026)
- Simplified project documentation: Streamlined README project history section while maintaining GPL v3 attribution to original author
lib/functions/functions.configuration.php- Environment switching logicadmin/setup.php- Status display dates- All language files (es_ES, en_US, ca_ES, eu_ES, gl_ES)
- Configurable Responsible Declaration: Added configuration file
conf/declaracion_responsable.conf.phpthat complies with Spanish regulations (RD 1007/2023, Order HAC/1177/2024):- Producer data (NIF, address, contact)
- IT system data (IdSistemaInformatico, version)
- Technical specifications (XAdES signature, SHA-256 hash)
- Dynamically calculated module integrity hash
- Compliance declaration with legal references
- JSON Export: New endpoint
/views/declaration_json.phpto export the responsible declaration in JSON format - Documentation: Added
docs/responsible_declaration.mdwith complete configuration guide
- Updated the Responsible Declaration page to use configuration file data
- Automatic validation of required fields with warning messages
- Display of module integrity hash in the declaration
- Error handling in bulk invoice validation: Fixed the issue where invoices with VeriFactu errors cancelled the entire batch validation process. Now, when an invoice fails to send to VeriFactu:
- The invoice remains as draft with PROV reference instead of being validated and then reverted
- Other invoices in the batch continue processing normally
- Improved PostgreSQL connection handling to avoid "connection already closed" errors
- Error messages are displayed correctly to the user