Saturday, May 18, 2019

PHP Toolkit New Version (2012.2 and Later) >Add Journal Entry

Below is a sample code that will create Journal Entry 

<?php
require_once '../PHPToolkit/NetSuiteService.php';

$service = new NetSuiteService();

// create Journal Entry record
$JournalEntry = new JournalEntry();
$JournalEntry->postingPeriod = new RecordRef();
$JournalEntry->postingPeriod->internalId = 83;
$JournalEntry->currency = new RecordRef();
$JournalEntry->currency->internalId = 1; //USA


$JournalEntryLine[] = new JournalEntryLine();
$JournalEntryLine[0]->account = new RecordRef();
$JournalEntryLine[0]->account->internalId = 137; //Account ID
$JournalEntryLine[0]->debit = 100;
$JournalEntryLine[1]->account= new RecordRef();
$JournalEntryLine[1]->account->internalId = 27; //Account ID
$JournalEntryLine[1]->credit = 100;

$JournalEntryLineList = new JournalEntryLineList();
$JournalEntryLineList->line = $JournalEntryLine;

$JournalEntry->lineList = $JournalEntryLineList;

$request = new AddRequest();
$request->record = $JournalEntry;

$addResponse = $service->add($request);
if (!$addResponse->writeResponse->status->isSuccess) {
    echo "ADD JOURNAL ENTRY ERROR";
} else {
    echo "ADD JOURNAL ENTRY SUCCESS, id " . $addResponse->writeResponse->baseRef->internalId;
}

?>

No comments:

Post a Comment