Marty Zigman Marty Zigman
Prolecto Labs Accelerator Templates

Automate NetSuite Bank Deposits with Multiple Currencies via SuiteScript

Accounting NetSuite Technical

Tags: , , , , , ,

This article is relevant if you are seeking to automate bank deposits and you wish to work with multiple currencies in your deposit application.

Background

While in development to enhance NetSuite to accept Bitcoin as a payment method and a currency, a code pattern emerged that, at time of this writing, required the use an API feature not documented by NetSuite.  NetSuite does not appear to formally support the Bank Deposit record type within the SuiteScript API.  However, with some brute force trial and error and forensic work studying NetSuite’s UI, I was able to get it to work.    Remember, if is undocumented, it means NetSuite has no commitment to support it so you must use it accepting full responsibility that your code may break during upgrades. In fact, I discovered that field references changed from 2013.2 to 2014.1.

NetSuite Bank Deposit Code Example

The basic pattern illustrates a few concepts:

  1. How to create a bank deposit via SuiteScript.
  2. How to find a customer payment or deposit that you want to apply funds.
  3. How to apply a payment in one currency to a payment in another currency
The code pattern below hard codes values to make it easier to understand.
// (2014.1 tested) following code snippet will produce a bank deposit in a particular currency
// but allows for the application of payments conducted in another currency

nlapiLogExecution('DEBUG', 'creating a deposit');
var d = nlapiCreateRecord('depo' + 'sit');  // break string into two to avoid Eclipse IDE complaints
d.setFieldValue('account', 181);	// hard code to a non USD bank account.
d.setFieldValue('trandate', nlapiDateToString(new Date()));	// put today's date
d.setFieldValue('memo', 'created in code');
d.setFieldValue('currency', 8); // currency code must be the same as account;  can be left blank 

i = d.getLineItemCount('pay' + 'ment');  // get the number of existing payments to spin through them

//find the customer deposit line we are seeking; go after specific items
for (var g = 1; g <= i; g++){
	if (d.getLineItemValue('pay' + 'ment', 'type', g) == 'CustDep'){
		//deposit application in Bitcoin (foreign currency)
		if (d.getLineItemValue('pay' + 'ment', 'doc' + 'number', g) == '180'){
			d.setLineItemValue('pay' + 'ment', 'payment' + 'amount', g, 15000);
			d.setLineItemValue('pay' + 'ment', 'deposit', g, 'T');
		};

		//deposit application in USD (base currency)
		if (d.getLineItemValue('pay' + 'ment', 'doc' + 'number', g) == '169'){
			d.setLineItemValue('pay' + 'ment', 'payment' + 'amount', g, 1500);
			d.setLineItemValue('pay' + 'ment', 'deposit', g, 'T');
		};
	};
};

//now add fees which we will drive through "Other Deposits" as negative numbers
d.insertLineItem('other', 1);
d.setLineItemValue('other', 'entity', 1, 1519);
d.setLineItemValue('other', 'account', 1, 71);
d.setLineItemValue('other', 'amount', 1, -1000);
d.setLineItemValue('other', 'memo', 1, 'pushing line data in');

//submit record and get the id into the log
nlapiLogExecution('DEBUG', 'd.new id', nlapiSubmitRecord(d));

Get Assistance

Why do I love NetSuite?  Because you can invent on the platform.  If you are looking to enhance your NetSuite system to improve your processing and ultimately generate more revenue and profit, contact us.

Marty Zigman

Holding all three official certifications, Marty is regarded as the top NetSuite expert and leads a team of senior professionals at Prolecto Resources, Inc. He is a former Deloitte & Touche CPA and has held CTO roles. For over 30 years, Marty has produced leadership in ERP, CRM and eCommerce business systems. Contact Marty to set up a conversation.

More Posts - Website - Twitter - Facebook - LinkedIn - YouTube

About Marty Zigman

Marty Zigman

Holding all three official certifications, Marty is regarded as the top NetSuite expert and leads a team of senior professionals at Prolecto Resources, Inc. He is a former Deloitte & Touche CPA and has held CTO roles. For over 30 years, Marty has produced leadership in ERP, CRM and eCommerce business systems. Contact Marty to set up a conversation.

Biography • Website • X (Twitter) • Facebook • LinkedIn • YouTube

5 thoughts on “Automate NetSuite Bank Deposits with Multiple Currencies via SuiteScript

  1. hitesh says:

    Hi Marty,
    Can you please let me know that how can i set
    Line items for deposit automatically and add main item manually.

    Thanks in advance

  2. hitesh says:

    record.selectNewLineItem(‘other’,1);
    record.setCurrentLineItemValue(‘other’,’entity’,1, 41877);
    record.setCurrentLineItemValue(‘other’,’department’,1, 13);
    record.setCurrentLineItemValue(‘other’,’account’,1, 135);
    record.setCurrentLineItemValue(‘other’,’amount’,1,’test’);
    record.setCurrentLineItemValue(‘other’,’memo’,1,’Tgh’);
    record.commitLineItem(‘other’);

    above code display error record not defined.

  3. hitesh says:

    Record is not defined is solved, i am stuck on to display line items before submitting so it can be modified.

    Thanks Hitesh,

  4. Marty Zigman says:

    Are you client side? It looks like you are using the other approach to work with the using the “Current” operator. The code snippet I offered works server side.

    I am not clear what you mean about the Main Item manually. What is the “Main Item”?

  5. hitesh says:

    Thanks for consideration.

    I want to select line item values based on some value passed by the user and functionality to user to update or
    Delete or add new from interface.

    The code you have provided is uploading without any interface to user.

    Items will be added from Check section.user will pass the check id and items from there will be added to item list at deposit section
    .
    After that user should be able to change value for any item .
    Or add new item manually.

    basically i want copy items from check section and add to deposit section

    Thanks for Your help

Leave a Reply

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