On this page
The Challenge
Creating an invoice when a sales order is fulfilled requires that you create the invoice in your ERP system and then manually upload/enter it into the EDI gateway. This is mostly a manual process which utilizes a lot of time. In addition to that, it is a challenge to handle errors and any changes in the expected schema.
SnapLogic's B2B solution helps you setup a Pipeline that handles the invoice creation aspect. This use case demonstrates how you can leverage SnapLogic to create invoices for multiple fulfilled sales orders in NetSuite and then send these invoices to the EDI gateway's SFTP site.
The Solution
The following Pipeline, when executed, creates an invoice for every fulfilled order in Netsuite and sends the invoice to the EDI gateway.
This Pipeline utilizes an expression library called helpers. You will need to download this expression library to execute this Pipeline correctly. Download the Pipeline and the expression library from the Downloads section below.
This Pipeline performs the following tasks:
- Reading and mapping the NetSuite sales order.
- Creating item fulfillment.
- Creating and processing the invoice.
Task1: Reading and Mapping the NetSuite Sales Order
In the use case Creating B2B Transaction -- Sales Order Use Case we wrote the sales order created by NetSuite into a file in the SnapLogic Database (SLDB). We now read this file to retrieve all the sales order data by using the File Reader Snap labelled Read Result. This data is then parsed and sent to the Mapper Snap labelled Get SO Mapper. This Snap is configured to retrieve the Internal ID for each sales order.
The base reference type, salesOrder, and the Internal IDs are sent to the NetSuite Get Snap labelled Get Sales Order.
This enables us to retrieve the order's current state.
Task 2: Creating Item Fulfillment
Item fulfillment in any business case is a manual process. A sales order is deemed fulfilled only after the merchandise/product/service has been shipped for delivery. In our use case, we simulate that process by marking the sales orders as fulfilled or "_shipped". This part is carried out by the Snaps labelled Root Mapper, Item Mapper, and Create Item Fulfillment. All these Snaps work together to provide the Internal ID.
The output from the Root Mapper Snap is passed to the NetSuite Create Snap labelled Create Invoice where the invoices are created.
Task 3: Creating and Processing the Invoice
The NetSuite Create Snap, Create Invoice, is configured to create invoice based on the Internal ID it receives.
From the above output we retrieve only the base reference, type, and Internal ID using the Mapper Snap, Get Invoice Mapper.
We do this since the base reference and Internal ID are all we need to retrieve the invoice's details from NetSuite using the NetSuite Get Snap labelled Get Invoice. This Snap retrieves the invoice's details. From these details we retrieve the Control ID using the Mapper Snap labelled Invoice Mapper.
At this juncture, we have all the information we need from NetSuite to communicate to the EDI gateway that the sales order sent from it has been fulfilled. To do so, we perform two operations:
- Send the invoice to the EDI gateway
- Create a local record of the invoice
Sending invoice to the EDI gateway
The invoice data is formatted as a JSON and written into the EDI gateway's Out sub-directory using a File Writer Snap. This establishes a communication between the ERP system and the EDI gateway.
Creating a local record of the invoice
The invoice data is formatted as a JSON and written into the SLDB. You can write a SnapLogic expression to use the invoice ID and Control ID in the filename to keep it unique and identifiable.
Try it Out
- Download the Solution Pipeline and Expression Library.
- Login to SnapLogic and click the button in SnapLogic Designer.
- Select the Pipeline from your local Drive.
- Edit the Pipeline's details such as Label.
Import the expression library in the Expression Libraries section.
- Click Save.
- Configure the accounts in the Snaps as appropriate.
- Validate and execute the Pipeline.
Downloads