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:
- How to create a bank deposit via SuiteScript.
- How to find a customer payment or deposit that you want to apply funds.
- How to apply a payment in one currency to a payment in another currency
// (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.
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
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.
Record is not defined is solved, i am stuck on to display line items before submitting so it can be modified.
Thanks Hitesh,
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”?
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