General Structure of Spain VAT Reports
All Spain Localization reports are built using the Tax Reporting Framework SuiteApp.
The Tax Reporting Framework SuiteApp generates reports through a sequence of stages that correspond to the following stages for the Spain reports:
-
Builder Stage
In this stage, one or more queries are executed. These retrieve the information necessary to populate the report. It is done through components called builders, where the purpose of each builder is to produce a query (for instance, a query sourcing summary data for the report header, a query retrieving information grouped by customer/vendor to populate sections dedicated to each entity, or a query fetching information about individual transactions). Other builders retrieve data for the Detailed Report page. In the UI, it is accessible after clicking on the linked numeric values in individual report boxes. In this case, the builder produces a query that retrieves details about each transaction tax line.
-
Preprocessor Stage
In this stage, a preprocessor component is associated with a builder (each builder must have an associated preprocessor). After the query produced by the builder is executed, the preprocessor performs computations on each row returned by that query. This can be useful, for example, for mapping data returned by the query to enumerate values, perform validation tasks, log, and so on.
-
Postprocessor Stage
After the preprocessor transforms the data produced by the builder, the postprocessor receives the result of this computation. It can then further manipulate that information before generating the report. If a single report has multiple data sources and multiple preprocessors, the postprocessor makes sure all the information is gathered in one place. This includes objects produced by the preprocessors for all the rows returned by the builders. This enables the process to compute totals, apply filters, log metrics, and provide the final output that will be passed on to the last stage. The object returned by the postprocessor is used to generate the report in a text format and to render the HTML preview page. The latter is defined by a Freemarker template that, when evaluated with the output of the postprocessor, determines the structure of the page.
-
Export Processor Stage
The export processor is an optional component that receives the output of the postprocessor and uses it to build the textual report. The object produced in this stage evaluates a Freemarker template that defines how the final document is structured.
In the Tax Reporting Framework SuiteApp, each of the components listed above can be extended. For more information, see Building Tax Reports with Tax Reporting Framework.
The following sections explain how each of the Spain reports implements these stages, and which components are available for extension.
All the relative paths to these components should be prefixed with SuiteApps/com.netsuite.spainlocalization/src/. For example, if you want to extend the component builders/modelos/Modelo303SummaryBuilder, you should reference it as SuiteApps/com.netsuite.spainlocalization/src/builders/modelos/Modelo303SummaryBuilder.
When extending an existing component, log the parameters that you get as input to the Script Execution Log. By inspecting the log, you will be able to understand the object structure and apply your changes. See an example of logging below.
/**
* @NApiVersion 2.1
* @NScriptType plugintypeimpl
*/
define(['N/log'], function (logger) {
return {
// Builder stage
customizeBuilders: () => ([
{
script: 'SuiteApps/com.netsuite.spainlocalization/src/builders/modelos/Modelo303SummaryBuilder',
implementation: (query) => {
logger.debug('Query', query);
return query;
}
}
]),
// Preprocessor stage
customizePreProcessors: () => ([]),
// Postprocessor stage
customizePostProcessors: () => ([]),
// Export processor stage
customizeExportProcessors: () => ([])
};
});