AEAT190/Technical Documentation
Contents |
MODELO 190: TECHNICAL SPECIFICATION
Purpose of the project
The purpose of this project is to create a new module for generating the Spanish official 190 withholding report (Modelo 340) valid file. This module will be part of the Spanish Professional Localization Pack.
Modelo 190 report includes withholdings and payments on account of income from employment and economic activities, prizes and certain capital gains and income allocations.
It must be submitted to the Tax Authorities on a yearly basis within the January month. This report includes all the operations done during the previous year.
The report can be submitted through Internet using a valid format Modelo 190 file.
On line submission implies that the Spanish companies must have a Tax ID as well as a user Certificate X.509.V3 issued by FNMT or any other valid Certificate according to tax authorities requirements.
Modules definition
Modelo 190 will be split in two different modules: one compatible with Openbravo 2.50 old flows, and the other one mainly compatible with Advanced Payables and Receivables and ready to work with data migrated from the old financial flow.
The module compatible with APRM will have 2 different major versions to work with Openbravo 2.50 and Openbravo 3.
- Name: Withholding Report: Modelo 190 (Spain)
- Java Package: org.openbravo.module.aeat190.es
- Version: 1.3.1 compatible with Openbravo 2.50 with Advanced Payables and Receivables, and 3.3.1 compatible with Openbravo 3
- Description: Retenciones e ingresos a cuenta sobre rendimientos del trabajo y de actividades económicas, premios y determinadas ganancias patrimoniales e imputaciones de renta
- Translation Required: Yes
- Module Language: Spanish (Spain)
- License: Openbravo Commercial License
- IsCommercial: Yes
- Has reference data: Yes
- Reference Data Description: Configuración para el Modelo 190
- License text: Copyright (C) 2011 Openbravo S.L.U. Licensed under the Openbravo Commercial License version 1.0. You may obtain a copy of the License at http://www.openbravo.com/legal/obcl.html or in the legal folder of this module distribution.
- Author: Openbravo S.L.U.
- URL: http://forge.openbravo.com/projects/spainaeatmodelo190
- DB Prefix: AEAT190
- Module Dependencies:
- Core 2.50MP36 or Core 3.0MP5
- Provincias de España 1.0.5
- Advanced Payables and Receivables Mngmt 1.0.18 or 3.0MP5
- Tax Report Launcher 1.0.13
- Taxes: configuration for Spain (Impuestos para España) 1.2.39
- Name: Withholding Report: Modelo 190 (Spain) - NOT APRM compatible
- Java Package: org.openbravo.module.aeat190notaprm.es
- Version: 1.0.1
- Description: Retenciones e ingresos a cuenta sobre rendimientos del trabajo y de actividades económicas, premios y determinadas ganancias patrimoniales e imputaciones de renta. Versión compatible únicamente con el antiguo flujo de cobros y pagos
- Translation Required: Yes
- Module Language: Spanish (Spain)
- License: Openbravo Commercial License
- IsCommercial: Yes
- Has reference data: Yes
- Reference Data Description: Configuración para el Modelo 190
- License text: Copyright (C) 2011 Openbravo S.L.U. Licensed under the Openbravo Commercial License version 1.0. You may obtain a copy of the License at http://www.openbravo.com/legal/obcl.html or in the legal folder of this module distribution.
- Author: Openbravo S.L.U.
- URL: http://forge.openbravo.com/projects/spainaeatmodelo190
- DB Prefix: OLD190
- Module Dependencies:
- Core 2.50MP36
- Provincias de España 1.0.5
- Tax Report Launcher 1.0.13
- Taxes: configuration for Spain (Impuestos para España) 1.2.39
Differences between Openbravo 3 and 2.50 versions
The module and backport for APRM versions of the Modelo 190 module are quite similar, having both of them exactly the same functionality. However, from a development perspective they have two important differences that make it impossible to share the same module for both Openbravo Core versions.
- Advanced Payables and Receivables module for Openbravo 2.50 does not support multicurrency operations, so the backport must not use the multicurrency API.
- Since Openbravo 3.0MP5 it's possible to use SQL functions inside Hibernate HQL, which is a feature used during this development. Using this feature forces our 190 module to depend to Openbravo Core from 3.0MP5 version, preventing us to extend the Core's dependency from Openbravo 2.50 to Openbravo 3.
Finally, the module for the old flow will just use the C_DebtPayment records that are linked to a bank statement line or a cash journal line. This module version must be run in Openbravo 2.50 with the old financial flow (instance that does not have the APR module installed).
Important: Take into account that APRM compatible modules are also compatible with the old financial flow data (if any). So the generated report will automatically merge the payment data from both financial flows in a migrated environment with no intervention needed from the user.
Changes in Core or other modules
There is no need to adapt other modules for developing Modelo 190 report
Database code
There is no need to create any database artifact like tables, views, functions or triggers. All the development is done using Java code.
Java code
This module uses the framework available in the Tax Report Launcher. This basically means that we need to have Java class that implements the OBTL_TaxReport_I interface and dataset that defines the input and constant parameters, and the relationship between tax parameters and tax rates in the application.
The AEAT190Report class implements the OBTL_TaxReport_I interface and it's the most important one because it contains all the business logic for generating the 190 file. The generateElectronicFile() method is the entry point to the class, that will first of all initialize the class attributes (initializeAttibutes method) and check all the data for launching the report is OK (checkData method).
After that, the generateRegister1Line() and generateRegister2Line() methods are called to create the valid structure file for the Modelo 190.
The AEAT190Report class delegates all the access to the data stored in the database using DAL (Hibernate) to the AEAT190ReportDao class.
There are several beans that help managing all the information involved in the report:
- BusinessPartnerInfoFor190 is a bean that contains the information per business partner and year that will be included into the Modelo 190
- PaymentInfoFor190 is a bean that contains the payment information per invoice and year. This class will later on allow us to calculate the percentage of withholding to be included into the 190 report according to the paid amount (and year) for the invoices.
- NumericAmount190, which defines the format of the amounts in the 190 declaration
- AEAT190String, which defines the format of the strings in the 190 declaration
Finally, the AEAT190_Utility is an utility class with common public static methods used during the development
Dataset structure
The dataset, with an organization data access level, will contain the relevant information for 190 report of the following tables:
- OBTL_Tax_Parameter, which is the table that links the tax rates with the tax report parameters. The IsBusinessObject checkbox is enabled
- OBTL_Tax_Report, which contains the tax report definition. The IsBusinessObject checkbox is enabled to get Tax Report Groups and Tax Report Parameters
- OBTL_TransactionCode is the table that stores the tributary keys used for the withholding report
The Tax Report definition (inside the Tax Report configuration window), will just contain a record for the yearly basis 190 report associated with the org.openbravo.module.aeat190.es.report.AEAT190Report class.
Three groups will be available:
- File, containing the FileName input parameter
- Supplementary, containing the input parameters for supplementary declarations
- Details, containing tax report parameters with the following search key structure:
- Withholding_<tributary key>_<tributary subkey>: These output parameters will be used for linking tax rates with the related transaction code (Tributary key and subkey). The code is ready to support more tax report parameters is we keep this name convention.