How to create Journal Entry in Netsuite Suite Script 1.0?



Hi All,

Today I got chance to work on creation of Journal Entry using Script.
What is Journal Entry Record?
A general journal entry records debits and credits to be posted to ledger accounts. General journal entries adjust the value of any set of accounts without entering transactions such as invoices or bills.
Basically Netsuite does all those things but if ledge is not proper then you can do this manually using amount only .
There can be many source of data for getting amount and account, there are 2 field where we have to enter debit amount and credit amount . Debit and credit amount should be same, only difference is that Account should be different.
So lets say one is "Revenue from Amazon"  and second one is "Revenue from Partner", and you want to Add First one as Credit and second one as Debit account.
Now lets say you have invoice of USD104.33 then you have to add 2 lines ,
one for Credit of 104.33 for account Revenue From Amazon
second for debit of 104.33 for Account Revenue from Partner .

Simple Screen Shot of Journal Entry Record:







If we want to create Journal Entry using script then
Step 1:
Use Create Record api
Step 2:
Set Mandatory and required field values in Record

Step 3:
Add Amount in Credit line for some account
Add Amount in Debit line for Same amount .

Step 4:
Save record

Use Below Code:
           var journalrec = nlapiCreateRecord('journalentry', {recordmode: 'dynamic'});
           //set your mandatory or required body fields here.
            journalrec.selectNewLineItem('line');
            journalrec.setCurrentLineItemValue('line','account',168);
            journalrec.setCurrentLineItemValue('line', 'credit', amount);
//add your line item value here if needed.
            journalrec.commitLineItem('line');
           
            journalrec.selectNewLineItem('line');
            journalrec.setCurrentLineItemValue('line','account',171);
            journalrec.setCurrentLineItemValue('line', 'debit', amount);
//add your line item value here if needed.
            journalrec.commitLineItem('line');
           nlapiSubmitRecord(journalrec, true, true);
Please comment below if you have any suggestions.

Thanks
Abhi

Comments

  1. Earlier i have created a customer payment(creditcard) from invoice using the suitescript.That time i was able to select an account “1415 Receivable for Pending CC Receipts”. But in sales order customer deposit , that “1415 Receivable for Pending CC Receipts” is missing in account list. For moving my deposit from “not deposited” to “deposited” status,i want add the deposit to the “1415 Receivable for Pending CC Receipts” account.How can add this into the list?

    ReplyDelete
  2. Hi Ranjitha,
    go to List -> Accounting -> Accounts.
    It will open Charts Of Account,
    See first if required one is inactive or not, if not there in account create one.
    I am not sure if you need any Approval from finance of your company or not(Approval to create new Account).
    Let me know if any query is there.

    ReplyDelete

Post a Comment

Thanks for you message, please join us on Facebook and Linkedin