Set up electronic messages for SPED-Reinf events
Electronic message functionality is new in Microsoft Dynamics 365 Finance. It lets you maintain and track various processes for electronic messages when there is an exchange of information between Finance and tax authority web services.
Before you issue SPED-Reinf events to the government website, use the predefined configuration that Microsoft has prepared to meet SPED-Reinf requirements. This configuration is delivered as a data entity. After it's imported into Finance, users will be able to generate, validate, and deliver all events that are described in the SPED-Reinf scope.
Import the configuration from the data entity
To set up electronic message functionality for communication of SPED-Reinf events, use the predefined configuration that is available in Microsoft Dynamics Lifecycle Services.
Sign in to Lifecycle Services.
Select the Shared asset library tile.
Select Data package as the asset type, and then select the package for the SPED-REINF event communication data entities. (The file name is SPEDREINF_EMSettings Layout 2.1.2.zip.)
Save the file in the location where data entities should be stored.
Sign in to Finance, and go to Workspaces > Data management.
Select the Import tile.
Enter a description and a name to identify the job, such as SpedReinf.
In the Source data format field, select Package.
Select Upload, and then select the file that you saved from Lifecycle Services (SPEDReinf_EMSettings Layout 2.1.2.zip).
Select Save, and wait until all data entities are shown on the page.
Select Import.
You will receive a notification about the import process. You can also manually refresh the page to view the progress of the import process. When the process is completed, you can view the Execution summary page.
Structure of electronic messages
Every event that is created, delivered, and received is represented by a message and a message item.
The message item is represented by the XML event message. It includes the following information that is stored in the message or updated in Finance:
- The full National Registry of Legal Entities (CNPJ) number of the fiscal establishment
- The root CNPJ
- The booking period
- The start date of the period that the message is valid for
- The receipt protocol number
- A value that indicates whether the message is registered in Dynamics 365
You can find this configuration on the Additional fields page (Tax > Setup > Electronic messages > Additional fields).
Note
Don't remove this configuration. This configuration is included in the package.
The message item types are classified by the type of event on the Message item types page (Tax > Setup > Electronic messages > Message item types).
Note
Don't remove this configuration. This configuration is included in the package.
- To set up the number sequence for message items, go to Tax > Setup > Parameters > General ledger parameters, and then, on the Number sequences tab, select a number sequence for the Message and Message item references.
Note
The number sequence must be defined as non-continuous.
Certificates
Trusted certificates must be configured and used in Finance, because the SPED-Reinf should always be signed by an e-CNPJ certificate that is authorized by the Brazilian Public Key Infrastructure (ICP-Brasil), regardless of any other signatures. This e-CNPJ certificate should match the first eight digits of the root fiscal establishment's CNPJ number, because the report is issued by the root fiscal establishment and the related fiscal establishments.
In Finance, you must register the Key Vault certificate in Azure.
For information about how to set up a Key Vault client, see Setting up Azure Key Vault Client.
Go to System administration > Setup > Key Vault parameters.
Enter the following information:
- Key Vault URL
- Key Vault client
- Key Vault secret key
- Key Vault secret ID
After registration, associate the certificate in the setup parameters for the Report generation action, as described in the next section.
Set up parameters
Every time that a message is created, prepared, validated, delivered, or received, the related action must be identified through an X++ class on the Executable class settings page (Tax > Setup > Electronic messages > Executable class settings).
Preparation items (Preparacao dos eventos) – This action is used to create and prepare the XML message. The action requests more parameters, such as Booking date, CNPJ, and CNPJ root, because the events are generated based on this information.
Process response (Processo de reposta) – This action is used to update the delivered message when the government approves it by using a protocol number. Additionally, the message is updated as registered on the government website.
Report generation (Geracao de relatório) – This action is used to send and receive the message item.
Note
Don't remove this configuration. This configuration is included in the package.
Specific actions
Before a message is delivered, set up XML schema validation to help prevent rejections from the government website.
Go to Organization administration > Document management > Document management parameters, and enable .xsd files by adding XSD as a new file type.
Go to Tax > Setup > Electronic messages > Message processing actions, and select New > File to attach the schemas (.xsd files) to the following actions:
- Verify (Validar)
- Re-Verify (Re-Validar)
- Cancel-Verify (Exclusão-Validar)
Select the Attachments button (paper clip symbol) to attach the schemas of the events (XSD) that are made available by the SPED-Reinf.
Select New > File > Add all schemas.
Go to Tax > Setup > Electronic messages > Message processing actions, and select Populate (Incluir).
In the Populate records action field, select Registrar transacões.
Go to Tax > Setup > Electronic messages > Web service settings, and set up a web services connection and certificates to issue and inquire about events.