Electronic Invoicing Builder Kit
What is Builder Kit
You can use the Electronic Invoicing Builder Kit feature to meet the e-invoicing compliance requirements in countries supported by Avalara, and where NetSuite does not provide a localization support at present.
This enables you to use Avalara for E-Invoicing.
See E-Invoicing Mandate Definitions, for the list of e-invoicing mandates supported by Avalara.
Before using e-invoicing builder kit, ensure to check if your country is present in the list of countries with e-invoicing support provided by NetSuite.
Understanding Builder Kit
The Electronic Invoicing Builder kit enables you to implement the e-invoicing solution for your requirements. If the mandate is supported by Avalara, you can implement a working solution for it in your NetSuite account.
When you use Builder Kit to implement your e-invoicing solution, you set up following components:
-
For Outbound:
-
E-Document Template (with custom data source)
-
Document status processing of a sent e-document (with custom processing logic).
-
The Mandate definition-this enables you to fulfill a required mandate and own its implementation details.
-
-
For Inbound:
E-Document Template (Custom Data source plugin implementation)-to process inbound e-documents that you receive through Avalara from networks like PEPPOL)
Outbound and Inbound can be set up independent to each other when you use Builder Kit to implement the e-invoicing solution.
After you implement the Builder Kit feature and the required local setup is completed, the standard E-Invoicing SuiteApp is ready. You must perform the following steps to use e-invoicing:
-
Generate e-documents for country mandate of your choice.
-
Send the document to networks like PEPPOL or tax authorities (supported by Avalara).
-
Sync the status of the same e-document back at NetSuite, after the e-document is sent on networks like PEPPOL or to tax authorities.
-
Receive and send transaction responses.
Components of the Electronic Invoicing Builder Kit
You should create and configure the following components of the Builder kit based on local requirements:
-
Mandate
-
E-Document Templates
-
Custom Plugin Implementations
-
Custom Data Source for E-document (Outbound)
-
Avalara Message Process Plugin Type
-
Inbound Custom Data Source Plugin Type
-
-
Starter Templates:
The Builder kit feature provides starter templates that you can customize further and then use in the Builder kit to tailor the e-invoicing solution to your desired country and e-invoicing mandates.
The starter template include:
-
Sample SuiteScript code for the custom plugin types. These can be used as a starting point and can be configured further.
-
E-Document Templates (FreeMarker Templates to generate UBL2.1 e-documents) which can be configured to enable:
-
Generation of a compliant e-document.
-
Sending the e-document to the concerned Tax Authorities or networks like PEPPOL (powered by Avalara).
-
Processing responses for tax authorities/Networks.
-
-
An additional step involved in the configuration of the Builder kit is creating the required Custom Fields and/ or Custom Records, for input and output values of the e-invoicing, depending on your mandate requirements. This is done using the standard NetSuite customization. For more information see, Customization Overview.
Using the Electronic Invoicing Builder Kit
To start using Builder Kit, please contact your account administrator to enable access for your NetSuite account.
Using Builder Kit in NetSuite Sandbox (optional)
If you have the NetSuite Sandbox account, you can configure Builder kit in sandbox first and do the required testing, to ensure your implementation works as expected. After configuring the components, they can be used in the production setup.
NetSuite sandbox allows you to test send your e-documents to Avalara sandbox which works with the test mode of the tax authorities / networks like PEPPOL, serving as the test environment for your e-Invoicing flow.
Prerequisites
Install the required SuiteApps:
-
Electronic Invoicing
-
NetSuite Electronic Business
-
License Client
The NSEB SuiteApp requires you to perform initial setup steps in production, before NSEB can be used in sandbox for testing. For more information see, NSEB Sandbox Quick Start
Configuring the components of Builder Kit
Configure the following components:
Create Plugin Implementation
You must have the Administrator role to create the plugin implementations.
You can create plugin implementations of below types using the samples provided as part of EI SuiteApp:
-
Avalara Message Process Plugin Type-for document status processing.
-
Custom Data Source for E-document-for outbound generation.
You can refer to the already sourced Transaction data available from Electronic Invoicing (refer to CDS data available from EI). If you need to override the available values, you can do it when implementing. If it is not required to override, you do not need to take any action and the values will be used during e-document generation, depending on the template mappings. Refer to the CDS data available from reference Outbound UBL CDS and add the missing or tweak the existing if needed, based on countries' requirement.
For more details on how to create plugin implementation, see Creating a Custom Plug-in Alternate Implementation.
Create Mandate Record
You must have the Administrator role to create the mandate record. A mandate record can be created using builder kit interface:
-
Go to Setup > E-Invoicing > Builder Kit
-
Create a Mandate record and set:
-
Name: Should be the mandate value supported by Avalara.
-
Plugin implementation script id of 'Avalara Message Process Plugin Type' type created in the previous step, for example-. customscript_msgprocess_belgium.
-
NSEB Setup
Setup the NetSuite Electronic Business SuiteApp in your sandbox account. For more details, refer to NetSuite Electronic Business Sandbox for the overview and NSEB Sandbox Quick Start for the steps.
To use NSEB in sandbox for testing, you must install NSEB first in production account, and perform the initial setup steps in production. For more information see, NSEB Sandbox Quick Start.
As part of the NSEB setup in sandbox, be sure to activate the mandate you created in the previous step. For more details see, Mandate Activation of Avalara Sandbox company.
Creating E-Document Templates using Builder Kit
You must have the Administrator role to create the e-document templates using Builder kit. You can use Builder Kit to create an E-Document Template with ready “starter” details which can be customized according to your needs.
You will need e-document templates to generate e-documents. Builder Kit helps you create e-document templates with standard/starter mappings and the custom data sourcing implementation, that you can further customize according to your needs.
Steps to create the E-document templates:
-
Go to Setup > E-Invoicing > Builder Kit
-
Enter the required details:
-
Name of the Builder E-Document Template.
-
E-Document Package you want the Template to reside in.
-
Subsidiaries you want the E-Document Template to be available for.
-
Outbound Details
-
Outbound Starter – select the sample starting template with mappings.
-
Outbound CDS – select the sample plugin implementation that sources the transaction data. You can select the CDS plugin implementation created in the first step.
-
-
Inbound Details
-
Inbound Starter – select the template that comes with default mapping. Current option is Inbound Generic PEPPOL, which helps you convert a PEPPOL E-Document.
-
Inbound CDS – select the inbound custom data sourcing implementation.
-
Inbound XSD – select the XSD option. This is a must.
-
-
-
Click Save.
You will be redirected to the created E-Document Template, with the “Template for Outbound E- documents” and “Custom Data Source Plugin Implementation” already populated, based on your selection of Outbound Starter and Outbound CDS.
Similarly, if you provided a choice for Inbound Starter, Inbound CDS, and Inbound XSD, the newly created E-Document Template record contains “Field Mapping for Inbound E-documents” already populated, based on your selection.
You can always modify these field values in the created E-Document Template by navigating to the record by going to Setup > Electronic Invoicing > E-Document Templates.
Create the Required Custom Fields
The country mandate or network to which the e-documents are sent (for example-PEPPOL) might require associated values to be stored with an invoice, before the e-document is generated and sent, and after the e-document is sent.
You may need to "create custom fields" depending on your country mandate. These custom fields could be used by you for two different purposes:
-
Values that should be stored before e-document generation, and to be used during e-document generation:
A custom transaction body field can be used to store values that can be sourced and used in the generated e-document using Outbound CDS.
For example: a value associated with the invoice, required to be present in the generated e-document.
-
Values that should be stored as result of sending out an e-document:
Custom transaction body fields can be used store the results of sending the e-document to tax authority or networks like PEPPOL.
For example: Unique ID of document generated by tax authority, digital signatures etc.
Additional Setup for Inbound
Inbound e-documents can be supported by implementing the following Builder kit created components:
-
E-Documents Templates (Inbound)-Be sure to configure the Inbound Details when creating the E-Document Template using Builder Kit. For more information, see Creating E-Document Templates using Builder Kit.
-
You must create the Plugin Implementation to resolve/select/set the Vendor based on custom logic. Create a custom plugin implementation of type “Inbound Custom Data Source Plugin Type”.
Using Builder Kit in NetSuite Production
For Sandbox Users
When you have the components (plugin implementations and templates) ready after your modifications (if any) and verified to be working in your NetSuite sandbox (optional), you will be ready to use the components in your Builder Kit setup in your Production accounts.
If you have implemented and tested Builder kit components in Sandbox, store a copy of the plugin implementations, modified templates (if any), and related customizations, so that you can create/reuse it in Production.
For Non-Sandbox Users
You can implement the components similar to sandbox steps, and test with zero value or one cent invoices.
The following are the steps to use Builder Kit in Production:
-
Create Plugin Implementation:
-
Create Mandate Record:
-
NSEB Setup:
You must complete the NetSuite Electronic Business SuiteApp setup in your production account. For more details, refer to NetSuite Electronic Business Overview for the overview and Avalara Managers Guide for the steps.
Important:If you have already setup NSEB in sandbox for testing, you must already have NSEB installed in your production account, and the initial setup steps already performed in production. You should resume setup in production from Avalara Company Creation or Avalara Mandate Activation steps.
As part of the NSEB setup in production, ensure to activate the mandate you created in the previous step. Refer to Avalara Mandate Activation for more information.
-
Creating E-Document Templates using Builder Kit:
-
Create the Require Custom Fields:
Customizing Electronic Invoicing Builder Kit Templates
After you have used the Electronic Invoicing Builder kit to create E-Document Templates, you can customize them using SuiteScript and FreeMarker, to generate the format of document required (fro example-PEPPOL BIS 3.0 and similar UBL based documents).
You can also customize how the result of sending an e-document (the document reference number, allotment number, QR code etc. corresponding to the sent e-document) is tagged with the corresponding invoice and other transactions in NetSuite, using Avalara Message Process Plugin Implementation.
Sourcing custom data for e-documents
You can include custom data in generated e-documents, by implementing Custom Data Source plugin implementation in SuiteScript and use them in the E-Document Templates. Builder Kit provides sample PEPPOL custom data source plugin implementation that can be used as a reference.
Understanding the Outbound CDS Plugin Implementation
The Custom Data Source Plugin Implementation (CDS) is a custom plugin type that you can implement by creating plugin implementations. The plugin implementation you create should fully define the interface’s function inject. It should contain the logic executed by an interface’s function inject that will:
-
Return the data sourced using SuiteScript that is expected to be present in the generated e-document.
-
The Mandate that the document is being generated for.
More details about the interface:
Functions |
---|
inject(params) |
Params |
---|
{String} params.transactionId {Object} params.transactionRecord |
Returns |
---|
{Object} result {render.DataSource} result.alias {string} result.format {Object | Document | string} result.data {string} result.data.mandate {Object | Document | string} result.data.transaction -Custom data can be returned here. {Object} result.result (optional) {Boolean} result.result.success (optional)-It can be used to cause failure in generation. Useful when want to abort the generation process. Optional and defaulted to true if omitted. {string} result.result.eiAuditTrailMsg (optional)-This appears on the E-Document Audit Trail of transaction. |
Sourcing a value from custom record
For example, when implementing the Custom Data Sourcing plugin implementation, a search, query, or (least preferred) record load can be performed to source a custom data.
It can then be included at certain key in the object returned by the plugin implementation:
at object returned at customDataSources[0].data.transaction.
For example: customObj.myvalue = “value”;
return {
customDataSources: [
{
format: render.DataSource.OBJECT,
alias: "avalara_cds",
data: {
mandate: mandate,
transaction: customObj,
},
},
],
result: {
success: true,
eiAuditTrailMsg: "", //EI puts a default message if the CDS is returned successfully
},
};
Using Script execution logs for logging and debugging
After customizing the plugin implementation stater to suit your needs, you can test your changes by generating e-documents with the templates. To help with debugging, N/log Module and log.debug(options) can be used. The logs can be inspected under following script:
-
Customization > Scripting > Scripts
-
Set the filter to TYPE: Suitelet
-
View script ID customscript_ei_generation_service_su
Be sure to set the Script Deployment to Log Level DEBUG, when using log.debug(options).
Appendix: Sample outbound CDS plugin implementation for PEPPOL e-documents.
You can locate the sample outbound CDS plugin implementation for PEPPOL e-documents in your File Cabinet:
Documents > File > File Cabinet > SuiteBundles > Bundle 436209 > Sample Templates > Builder > Plugin Implementations > plugins > pl_starter_outbound_cds_ubl_2_1.js
Modifying Template Mapping
Adding tags, and mapping additional values returned from Outbound CDS plugin implementation.
After the E-Document Templates are created using builder kit, you may modify the outbound template by editing the Template for Outbound E-documents field in the E-Document Template.
You can add additional XML tags that reference data returned by Custom data source Plugin Implementation type set in Custom Data Source Plugin Implementation field of the same E-Document Template record.
Writing Avalara Message Process Plugin Type
To sync the status and related updates about an e-document after it is generated and sent, you will need to implement a custom plugin of type “Avalara Message Process Plugin Type”.
-
Appendix: Sample Avalara Message Process plugin type implementation.
You can see a sample plugin implementation by navigating to:
Documents > File > File Cabinet > SuiteBundles > Bundle 436209 > Sample Templates > Builder > Plugin Implementations > plugins > pl_peppol_starter_avalara_doc_status.js
-
Customizing the sample to add a value to custom transaction body field. The sample plugin implementation should implement function processRequestStatus
- {Object} params - {Object} params.transaction - {Object} params.docStatusPayload { companyId, obnControlNumber id, events: "array<Event>", status, events[].message, events[].responseKey (optional)}
-
Using Script execution logs for logging and debugging.
After customizing the plugin implementation stater to suit your needs, you can test your changes by generating e-documents with the templates. To help with debugging, N/log Module and log.debug(options) can be used.
The logs can be inspected under following script:
-
Customization > Scripting > Scripts
-
Set the filter to TYPE: RESTlet
-
View script ID customscript_ei_update_transaction_rl
Ensure to set the Script Deployment to Log Level DEBUG, when using log.debug(options)