user3682707
user3682707

Reputation: 267

How to update CreatedFrom of Journal Entry by SuiteTalk?

I have to apply/attach a Journal Entry to the VendorPayment for voiding, so that I've tried 2 ways:

First is update the (RecordRef)createdFrom of Journal Entry = (recordRef)vendorPayment

Here is my code:

            RecordRef vPaymentRef = new RecordRef();
            vPaymentRef.internalId = "7850";
            vPaymentRef.type = RecordType.vendorPayment;
            vPaymentRef.typeSpecified = true;

            RecordRef currency = new RecordRef();
            currency.internalId = "1";
            currency.type = RecordType.currency;

            RecordRef mySubsidiary = new RecordRef();
            mySubsidiary.internalId = "3";
            mySubsidiary.type = RecordType.subsidiary;


            JournalEntry newJournalEntry = new JournalEntry();

            newJournalEntry.subsidiary = mySubsidiary;

            newJournalEntry.createdFrom = vPaymentRef;

            //newJournalEntry.reversalEntry = "99";

            newJournalEntry.reversalDate = DateTime.Now;
            newJournalEntry.reversalDateSpecified = true;

            //newJournalEntry.reversalDefer = true;
            //newJournalEntry.reversalDeferSpecified = true;

            RecordRef myCurrency = new RecordRef();
            myCurrency.internalId = "1";
            newJournalEntry.currency = myCurrency;

            newJournalEntry.exchangeRate = .911;
            newJournalEntry.exchangeRateSpecified = true;

            RecordRef myDebitAccount = new RecordRef();
            myDebitAccount.internalId = "290"; //account

            RecordRef myCreditAccount = new RecordRef();
            myCreditAccount.internalId = "25"; //a/p account

            newJournalEntry.lineList = new JournalEntryLineList();
            newJournalEntry.lineList.line = new JournalEntryLine[2];

            newJournalEntry.lineList.line[0] = new JournalEntryLine();
            newJournalEntry.lineList.line[0].account = myDebitAccount;
            newJournalEntry.lineList.line[0].debit = 3333;
            newJournalEntry.lineList.line[0].debitSpecified = true;
            newJournalEntry.lineList.line[0].entity = vPayment.entity;

            newJournalEntry.lineList.line[1] = new JournalEntryLine();
            newJournalEntry.lineList.line[1].account = myCreditAccount;
            newJournalEntry.lineList.line[1].credit = 3333;
            newJournalEntry.lineList.line[1].creditSpecified = true;
            newJournalEntry.lineList.line[1].entity = vPayment.entity;

            WriteResponse wr = _service.add(newJournalEntry);

As you see, I have added a VendorPayment to CreatedFrom, the WriteResponse status return true with StatusDetail = null. But when I access the Journal Entry have just created on Netsuite site, the VOID OF is empty (not display). And the type of Journal Entry is "Journal", It have to be "Voiding Journal", and don't have "Reversal Payments Applied" beside the Entry No.

Then, I try the second way : Update the voidJournal of VendorPayment to use the Journal Entry have just created.

Here is my code :

            RecordRef recordRef = new RecordRef();
            recordRef.internalId = "7850";
            recordRef.type = RecordType.vendorPayment;
            recordRef.typeSpecified = true;
            ReadResponse response2 = _service.get(recordRef);
            VendorPayment vPayment = (VendorPayment)response2.record;

            RecordRef recordRefJournal = new RecordRef();
            recordRefJournal.internalId = "8356";
            recordRefJournal.type = RecordType.journalEntry;
            recordRefJournal.typeSpecified = true;

            vPayment.voidJournal = recordRefJournal;
            vPayment.status = "VOIDED";

            WriteResponse wr2 = _service.update(vPayment);

With this way, the WriteResponse status still true, and the StatusDetail still null. When I refresh this vendorPayment on Netsuite site, nothing change, the VOIDED ON and the Status not change.

My Point is Voiding the VendorPayment by SuiteTalk.

I'm really stuck here, please help. Many thanks !!

Upvotes: 0

Views: 1127

Answers (2)

Marty Zigman
Marty Zigman

Reputation: 9

Indeed, the previous comment is right.

What you need to do is two step:

  1. Create the journal entry and reference the Vendor in the entity lines.
  2. Apply it as a payment against the bill.

Consider the code pattern to the article I wrote about writing off Customer Invoices with a Journal Entry.

Marty Zigman, Founder Prolecto Resources, Inc. NetSuite Systems Integration Southern California's Leading Innovation and Implementation Practice

Upvotes: 0

vVinceth
vVinceth

Reputation: 915

Create From field is a field that can only be set by the system. It will only be populate when transforming transactions.

Created From field of the Invoice will only be populated when you click the Bill button of the sales order and another scenario is when you click the Receive button on the PO the Created From field of the Item Receipt.

In suitescirpt

nlapiTransformRecord('salesorder', 1, 'invoice');

What you are trying to do is not possible using the standard Created From field.

Upvotes: 1

Related Questions