Outbound Integration of Customer Master Data and Customer Balance From Netsuite

Requirement 

The client would like to sync the customer data and customer balance data from Netsuite to the Application.

Our Solution

We will provide a REST API for the Application user to fetch the data from Netsuite to the Application.

Customer Data Sync

We will be implementing an API to fetch the customer data from Netsuite to an application.

Request : GET

Parameters

  • CompanyCode : Company code(Company code field in the subsidiary record corresponding to subsidiary field in customer record)– Mandatory
  • CustomerCode : Customer Code(id:custentity_code) field in the Customer record – Mandatory
JSON fieldNetsuite FieldMandatoryDescription
customerentityidYesCustomer ID field in customer record
credit_ctrl_areacustrecord_company_codeYesCompany code field in subsidiary recordNote: Script will check the primary subsidiary field in Subsidiary record
credit_limitcustentity_credit_limit_pqn ,custentity_credit_limit_sppiYesCustom fields “Credit limit for PQN” and “credit limit for SPPI” in the financial subtab of the customer record
acct_refentityidYesCustomer ID field in customer record
sale_valueunbilledordersYesOpen Sale order amount based on Company Code (subsidairy) Unbilled orders field in the subsidiaries subtab of the customer record.Value will be corresponding to the company code parameter sent from Application
receivablesbalanceYesOpen invoice amount based on Company Code (subsidiary)Balance field in the subsidiaries subtab of the customer record.Value will be corresponding to the company code parameter sent from Application
rel_spec_liabilitiesdepositbalanceYesDeposit amount based on Company Code (subsidiary)Deposit Balance in the Financial subtab of the customer subtab
exceeded_date
Empty string will be returned
change_obj
Empty string will be returned
created_byEmpty string will be returned
created_onEmpty string will be returned
risk_cateEmpty string will be returned
last_reviewEmpty string will be returned
ind_blocked_creditEmpty string will be returned
credit_rep_grpEmpty string will be returned
next_reviewEmpty string will be returned
credit_info_noEmpty string will be returned
cust_credit_grpEmpty string will be returned
changed_byEmpty string will be returned
ref_dateEmpty string will be returned
cust_grpEmpty string will be returned
paym_dateEmpty string will be returned
paym_amtEmpty string will be returned
paym_currEmpty string will be returned
rec_credit_limitEmpty string will be returned
rec_credit_limit_currEmpty string will be returned
secured_receivablesEmpty string will be returned
credit_exposureunbilledorders+balance-depositbalance
credit_availableCredit limit for PQN- unbilledorders + balance – depositbalance
statusSuccess – Can get the data in Netsuite
messageError – Cannot get the data in Netsuite and put the error message from Netsuite.Will put the error message from Netsuite.

Sample Response

When the request to Netsuite made was successful, the API will return a success array in JSON format

“summary”: {

       “status”: “SUCCESS”,

       “reason”: “RECORD_FOUND”

   },

“Lines”:

[

{

“customer”: “CP01189”

“credit_ctrl_area”: “1810”

“credit_limit”: “1000000.00”

“acct_ref”: “CP01189”

“sale_value”: “150000.00”

“receivables”: “30000.00”

“rel_spec_liabilities”: “0.00”

“exceeded_date”: “”

“change_obj”: “”

“created_by”: “”

“created_on”: “”

“risk_cate”: “”

“last_review”: “”

“ind_blocked_credit”: “”

“credit_rep_grp”: “”

“next_review”: “”

“credit_info_no”: “”

“cust_credit_grp”: “”

“changed_by”: “”

“ref_date”: “”

“cust_grp”: “”

“paym_date”: “”

“paym_amt”: “”

“paym_curr”: “”

“rec_credit_limit”: “”

“rec_credit_limit_curr”: “”

“secured_receivables”:””

“credit_exposure”: “180000.00”

“credit_available”: “820000.00”

“status”: “success”

}

]

Error Response 

When the request to Netsuite made was unsuccessful, the API will return a Error array

“summary”: {

       “status”: “ERROR”,

       “message”: ” Invalid Customer Code”,

      “company_code “: “1810”,

     “cust_no”: “CP01189T”

}

Error Response Messages:

  • Invalid Customer Code
  • Invalid Company Code
  • Customer Code is null
  • Company Code is null
  • Records not found

Customer Balance Sync

We will be implementing an API to fetch the customer balance data from Netsuite to an application.

Request : GET

Parameters

  • CompanyCode : Company code(Company code field in the subsidiary record corresponding to subsidiary field in customer record)– Mandatory
  • CustomerCode : Customer Code(id:custentity_code) field in the Customer record- Mandatory
  • PageIndex: Index of the page(starting from 1)– Mandatory

Note

  • API will be returning an array of all open invoices or credit notes that are applied as response for every request made through the API. Each invoice details object will be separated by a comma.
  • Page size will be limited to 25 results per page 
JSON FieldNetsuite FieldDescription
company_codecustrecord_company_codeCompany code field in subsidiary recordNote: Script will check the primary subsidiary field in Subsidiary record
cust_noentityidCustomer ID field in customer record
fiscal_yearYear from date
acct_notranidDocument Number in the invoice
post_datetrandateDate in the Invoice
assign_notranidDocument Number in the invoice
doc_datetrandateDate in the Invoice
bill_numbertranidDocument Number in the invoice
so_numbercreatedfromCreatedfrom field in the invoice
local_amtsubtotalSubtotal Value in the invoice(show minus if the document is Credit Note)
doc_amtsubtotalSubtotal Value in the invoice(show minus if the document is Credit Note)local_amt will be the subtotal +tax totalNo.11 will be subtotal + tax total in foreign currency itself without any conversion if the currency is not IDRIf the currency is IDR, value will be loc_amt
doc_currcurrencyCurrency field value in the invoice
due_dateduedateDuedate field value in the invoice
due_daysDate diff (DUE_DATE, current date)The number of days remaining to duedate from the current dateNote: If due date is already over, we will be adding a “-” before the days count
payment_trmInternal ID of TermPayment term value in the invoiceEx: 2
ref_doctranidDocument Number in the invoice
doc_typeInvoice = RACredit Note = RCInvoice = RACredit Note = RC
crdr_indicatorInvoice = SCredit Note = HInvoice = SCredit Note = H
thai_amtEmpty string will be returned
exchange_rate_thaiEmpty string will be returned
textTermTerm field text in the invoice recordEx: Net 30
flag_excessEmpty string will be returned
flag_dueEmpty string will be returned
po_numberotherrefnumPO# field in invoice
custom_invEmpty string will be returned
successSuccess – Can get the data in Netsuite
Errorerror – Cannot get the data in Netsuite and put the error message from Netsuite.Will put the error message from Netsuite.

Sample Response message

“summary”: {

       “status”: “SUCCESS”,

       “reason”: “RECORD_FOUND”

   },

   “result”: {

       “pageInfo”: {

           “pageLength”: 1,

           “pageIndex”: 1,

           “isLastPage”: true

       },

       “lines”: [

{

“company_code”: “1810”,

“cust_no”: “CP01189”,

“fiscal_year “: “2021”,

“acct_no”: “INVSPPI-1149”,

“post_date”: “23/10/2021”,

“assign_no”: “INVSPPI-1149”,

“doc_date”: “23/10/2021”,

“bill_number”: “INVSPPI-1149”,

“so_number”: “SOSPPI-13”,

“local_amt”: “3641550”,

“doc_amt”: “3641550”,

“doc_curr”: “IDR”,

“due_days”: “21”,

“payment_trm”: “2”,

“ref_doc”: “INVSPPI-1149”,

“doc_type “: “RA”,

“crdr_indicator “: “S”,

“thai_amt”: “”,

“exchange_rate_thai”: “”,

“text”: “Net 30”,

“flag_excess”: “”,

“po_number”: “PO12”,

“custom_inv”: “”,

“status”: “success”

},

{

“company_code”: “1810”,

“cust_no”: “CP01890”,

“fiscal_year “: “2021”,

“acct_no”: “INVSPPI-1150”,

“post_date”: “23/10/2021”,

“assign_no”: “INVSPPI-1150”,

“doc_date”: “23/10/2021”,

“bill_number”: “INVSPPI-1150”,

“so_number”: “SOSPPI-14”,

“local_amt”: “3641550”,

“doc_amt”: “3641550”,

“doc_curr”: “IDR”,

“due_days”: “21”,

“payment_trm”: “2”,

“ref_doc”: “INVSPPI-1150”,

“doc_type “: “RA”,

“crdr_indicator “: “S”,

“thai_amt”: “”,

“exchange_rate_thai”: “”,

“text”: “Net 30”,

“flag_excess”: “”,

“po_number”: “PO13”,

“custom_inv”: “”,

“status”: “success”

}

]

 }

Error Response 

“summary”: {

       “status”: “ERROR”,

       “message”: ” Invalid Customer Code”,

      “company_code “: “1810”,

     “cust_no”: “CP01189T”

}

Error Response Messages:

  • Invalid Customer Code
  • Invalid Company Code
  • Customer Code is null
  • Company Code is null
  • Records not found
  • Invalid PageIndex (should be greater than one)

API Set Up

API credentials will be shared to the Application user to fetch the data from Netsuite. The Integration record will be created in the Netsuite with Auth 1.0 credentials. The token will be generated for the customized role. 

Steps in customized role setup:

  • “External API User” role will be created in the account for the user to Use the API with limited permissions
  • Employee records will be created for the external API user. 
  • Role will be added to the new user 
  • Token will be generated for the new customised role

Assumptions

  • We will be considering all invoices with open statuses only
  • Authentication will be provided for the customised role only
  • We will only validate the company code and customer code is not null or the parameters is present or not
  • We will be considering the invoices in open status and we will not be considering the date filter.
  • The date format will be dd/mm/yyyy
  • We will be using the invoice record in open status and credit Notes that are unapplied while returning the response. Also, the documents need to be approved

Risk

  • The number of requests made to API is limited to a concurrency of 5.

Time and Effort :32h

Leave a comment

Your email address will not be published. Required fields are marked *