Updating E-Document Certification Statuses

E-document certification statuses are not automatically updated by the Electronic Invoicing SuiteApp. E-document certification statuses can be updated through the certification sending method implementation. If your company or organization is implementing its own e-document certification sending, you can use the format of the following sample script for capturing sending method return, which can be used to update the e-document certification statuses and log corresponding messages in the E-document Audit Trail.

Note:

Electronic Invoicing SuiteApp provides support to send e-documents for certification individually or in bulk to Avalara. All the eligible e-documents are automatically sent for certification without any manual intervention. For more information about Avalara for e-Invoicing, see Avalara for E-Invoicing.

Status

Description

Ready for Certification

This status is displayed when the e-document sending to Avalara for certification is unsuccessful.

Certification in Progress

This status is displayed when the e-document sending to Avalara for certification is successful.

Note:

This sample script uses the define function, which is required for an entry point script (a script you attach to a script record and deploy). You must use the require function if you want to copy the script into the SuiteScript Debugger and test it. For more information, see SuiteScript Debugger.

The following code is a sample script to implement e-document certification status updates.

          /**
* Copyright (c) 2017, Oracle and/or its affiliates.
*
* @NApiVersion 2.x
* @NScriptType plugintypeimpl
* @NModuleScope public
*/
define([], function() {
   /**
    * send - This function is the entry point of our plugin script
    * @param {Object} plugInContext
    * @param {String} plugInContext.scriptId
    * @param {String} plugInContext.sendMethodId
    * @param {String} plugInContext.eInvoiceContent
    * @param {Object} plugInContext.customer
    * @param {String} plugInContext.customer.id
    * @param {Array} plugInContext.customer.recipients
    * @param {Object} plugInContext.transaction
    * @param {String} plugInContext.transaction.number
    * @param {String} plugInContext.transaction.id
    * @param {String} plugInContext.transaction.poNum
    * @param {Object} plugInContext.sender
    * @param {String} plugInContext.sender.id
    * @param {String} plugInContext.sender.name
    * @param {String} plugInContext.sender.email
    * @param {Array} plugInContext.attachmentFileIds
    *
    * @returns {Object} result
    * @returns {Boolean} result.success
    * @returns {String} result.message
    */
   return {
       send: function(pluginContext) {
           var result = {
               success: true,
               message: '',
               eiStatus: {
                   "transactionId": plugInContext.transaction.id,
                   "transactionType": plugInContext.transaction.tranType,
                   "entity": customer.id,
                   "eDocStatus": "3",
                   "eventType": "3",
                   "details": "The e-Doc successfully certified and is ready for sending.",
                   "owner": plugInContext.sender.id,
                   "isUpdateFields": "true",
                   "extraFieldsForUpdate": {},
                   "bundleId": "",
                   "bundleName": ""
               }
           };
           return result;
       }
   }
}); 

        

If e-document certification is successful, the script will change the e-document status of the transaction to Ready for Sending and add the following details in the E-Document Audit Trail:

The e-document was successfully certified and is ready for sending.

The following table lists the parameters that the object eiStatus in the script takes up.

Parameter

Type

Description

Values

transactionId

String

ID of transaction record

Required

transactionType

String

Transaction type such as INVOICE, VENDOR_BILL, ITEM_FULFILLMENT, and others

Required

entity

String

ID of entity record; for example, Customer, Vendor, and others.

Required

eDocStatus

String

E-document Status

Use numbers for status types. The following numbers can be used:

  • READY_FOR_SENDING : 3

  • CERTIFICATION_IN_PROGRESS : 20

  • CERTIFICATION_DATA_ERROR : 21

  • CERTIFICATION_FAILED : 22

  • CANCELED : 17

Required

eventType

String

E-document Audit Trail Event

Use numbers for event types. The following numbers can be used:

  • READY_FOR_SENDING : 3

  • CERTIFICATION_IN_PROGRESS : 20

  • CERTIFICATION_DATA_ERROR : 21

  • CERTIFICATION_FAILED : 22

  • CANCELED : 16

For more information, see Certification Statuses.

Required

details

String

Details

Required

owner

String

ID of user or Employee

Required

isUpdateFields

String

Flag; if TRUE, the EI Status is updated, fields are provided in extraFieldsForUpdate field and an audit trail is created. Otherwise, an audit trail is created.

Required

extraFieldsForUpdate

JSON

A JSON object containing the key-value pair for the transaction body fields, where key is the field ID and value is the field value. It can be used to update any transaction body field required by a Country SuiteApp.

Required (can be an empty object)

bundleId

String

BundleId of the requester

Required

bundleName

String

BundleName of the requester

Required

The parameter details will be included in the E-Document Audit Trail.

Certification Statuses

The following table has details about each of the certification stages for an e-document.

Status

Description

Ready for Sending (Internal Id: 3)

This status is set when the certification is completed successfully. After the status is set, only Send button will be enabled. You will not be able to re-generate or certify the e-document again.

Certification In Progress (Internal Id: 20)

This means certification process is in progress and no EI buttons will be displayed while the transaction is in this status. You can proceed further, only if the result is either success or failure.

Certification Data Error (Internal Id: 21)

You can set this status during the certification process through the custom plug-in when there are some errors like:

  • Incorrect field values in XML or JSON.

  • Data is not in correct or standard format, and so on.

Electronic Invoicing will allow re-generation of e-document if the status is updated to Certification Data Error.

Note:

Only manual re-generation is possible by clicking Generate button on the transaction.

The bulk generation MR will not pick transactions with this status.

Certification Failed (Internal Id: 22)

You can set this status during the certification process through the custom plug-in when there are some errors due to:

  • Connection failure

  • Incorrect request parameters

  • Incorrect URLs or endpoints, and so on.

Re-generation will not be possible on a transaction and Generate E-Document button will not be available when set to this status.

Certify button will be enabled.

Canceled (internal id: 17)

The status can be set when the e-document is no longer required or the transaction is approved for cancellation by the certification authority. You can set this status during the certification process through a custom plug-in.

No buttons related to the Electronic Invoicing SuiteApp will be visible on the transaction while in this status.

Related Topics

General Notices