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:

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.

Note:

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'll 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: () => ([])
    };
}); 

        

Developing an Extension

When developing an extension, you can choose to customize one or more stages, depending on your business needs. For example, when adding a new box to a report, you typically need to customize a builder to retrieve values from the database. You may have to customize pre- and post-processors to manipulate that data, or to update total boxes. This customizes the export processor that produces the report.

Report extensions are developed through plug-in implementations, as is shown in the following code snippet.

            /**
 * @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('Builders', 'Executing builder')
                // Add select list items.
                const index = query.indexOf('FROM');
                query = query.substring(0, index) + ', SUM(tx.taxamount) allTaxAmounts, MAX(s.custrecord_sample_property_m303) customProperty ' + query.substring(index);
                // Add a table.
                const matches = [...query.matchAll(/WHERE/g)];
                query = query.substring(0, matches[1].index) + 'JOIN subsidiary s ON s.id = tx.subsidiary ' + query.substring(matches[1].index);
                return query;
            }
          },
          {
            script: 'SuiteApps/com.netsuite.spainlocalization/src/builders/DomesticSaleDetailsBuilder',
            implementation: (query) => {
                logger.debug('Builders', 'Executing detail builder')
                return query;
            }
          }
        ]),
      // Preprocessor stage
        customizePreProcessors: () => ([{
            script: 'SuiteApps/com.netsuite.spainlocalization/src/processors/modelos/Modelo303SummaryPreProcessor',
            implementation: (inputData, processorResult) => {
                logger.debug('Preprocessors', 'Executing preprocessor')
                processorResult.alltaxamounts += 10;
                processorResult.customproperty = processorResult.customproperty == 'T' ? true : false;
                return processorResult;
            }
        }]),
      // Postprocessor stage
        customizePostProcessors: () => ([
         {
               script: 'SuiteApps/com.netsuite.spainlocalization/src/processors/modelos/Modelo303SummaryPostProcessor',
               implementation: (definition, dataManager, processorResult) => {
                   logger.debug('Postprocessors', 'Executing postprocessor')
                   processorResult.alltaxamounts += 10;
                   return processorResult;
               }
           },
         {
               script: 'SuiteApps/com.netsuite.spainlocalization/src/processors/modelos/Modelo303DetailsPostProcessor',
               implementation: (definition, dataManager, processorResult) => {
                   logger.emergency('Postprocessors', 'Executing detail postprocessor for box ' + definition.id)
                   if (definition.id == 'box1234') {
                        return [];
                   }
              
                   return processorResult;
               }
             }]),
      // Export processor stage
        customizeExportProcessors: () => ([{
            script: 'SuiteApps/com.netsuite.spainlocalization/src/processors/modelos/Modelo303TxtProcessor.js',
            implementation: (inputData, processorResult) => {
                logger.debug('Export processors', 'Executing export processor')
                processorResult.modelo303 += 'Custom data: ' + inputData.alltaxamounts;
                return processorResult;
            }
        }])
    };
}); 

          

General Notices