Aim: Fetch Purchase Order from FoodStuff eXchange and create it as a Sales Order in NetSuite and send the Order Message, ASN and INV XML to the site.
Process/Steps :
- From NetSuite, we will fetch a Purchase Order from FoodStuff eXchange as XML.
- If there is no Purchase Order, then stops further execution
- If there is Purchase Order, then proceed further
- Store the XML on the Custom Record ‘AHNZ-67 JJ FoodStuff Integration’.
- Parse the XML into JSON
- If successful, proceed to Step 3
- If failure, attach the XML as a file in the custom record and goto Step 1
- We will use the STORE_OWNER_CODE from FoodStuff eXchange XML and match it with ‘FOODSTUFFS STORE ID’ of customers to determine the customer in NetSuite.
- If the customer is found in NetSuite, proceed to Step 4.
- If no such customer is present, we will create the customer in NetSuite with the information available from foodstuff eXchange XML. The value of the parent customer will be based on the EAN_Prefix value in the eXchange XML.
- When we create the customer in NetSuite, then
- STORE_OWNER_CODE from XML will be a unique identifier for the customer and will be set in FOODSTUFFS STORE ID in NetSuite
- The Customer : Company : Street Address in XML will be Ship Address in Customer
- The Order Header : Bill to : Company : Postal Address in XML will be Bill Address in Customer
- Proceed to Create Customer
- If successful, proceed to Step 4
- If failure, store the failure reason on custom record and got to Step 1
- After the customer is identified/created, we will store the customer reference on the custom record and will proceed to create Sales Order for the customer
- ORDER_NUM from XML will be a unique identifier for Sales Order and will be set in the field PO #
- Location will be BLENHEIM
- Currency will be NZD
- SUPPLIER_PRODUCT from FoodStuff eXchange XML will match with GTIN Code (UPC CODE) on NetSuite Item Record, used as Item Unique Identifier
- If all the Items from FoodStuff eXchange cannot be mapped successfully to NetSuite, flag this in Custom Record as Partial Sales Order.
- The ORDER_HEADER : BUYER should be prepend as Attention on Shipping Address
- Proceed to create Sales Order
- If successful, proceed to Step 5
- If failure, store the failure reason on custom record and got to Step 5
- After the successful creation of the Sales order , then the order message XML (sales order creation acknowledgment) has been sent to the FoodStuff eXchange
- A custom field has been created in the custom record to save the order message xml.
- The order message xml has been created and send to the site
- The script will take all the Item Fulfilments for the created sales orders based on the search of the custom record and the script will send the ASN Message XML to the Foodstuff eXchange site. The script will not take the Item fulfillments of the sales order whose Partial Sales Order field is checked.
- The custom field “Item Fulfillment” has been created in the custom record and the related item fulfillment of the sales order will be set in the field.
- The script will take each item fulfillment and create a ASN XML request and send it to the Foodstuff eXchange site.
- A custom field is created for saving the ASN XML request message.
- If an error is encountered, we will save the error message in a field.
- The response also has been saved to a custom field.
- The script will take all the Invoice for the created sales orders based on the search of the custom record and the script will send the INV Message XML to the Foodstuff eXchange site. The script will not take the Invoices of the sales order whose Partial Sales Order field is checked.
- The custom field “Invoice” has been created in the custom record and the related invoice of the sales order will be set in the field.
- The script will take each invoice and create an INV XMLrequest and send it to the Foodstuff eXchange site.
- A custom field is created for saving the INV XML request message.
- If an error is encountered, we will save the error message in a field.
- The response also has been saved to a custom field.
- Go to Step 1