Ranva Rahul
Ranva Rahul

Reputation: 79

How to Create Vendor Payment record in Netsuite using NetsuiteTalk PHPToolkit

I am using Netsuite SuiteTalk PHPToolKit and trying to create vendor payment record using PHP soap call.

Request:

$vendorPayment                     = new VendorPayment();
$vendorPayment->entity             = new RecordRef();
$vendorPayment->entity->internalId = $bill->entity->internalId;
$vendorPayment->entity->type       = 'vendor';
$vendorPayment->account             = new RecordRef();
$vendorPayment->account->internalId = self::SB_ACCOUNT_INTERNAL_ID;
$vendorPayment->apAcct             = new RecordRef();
$vendorPayment->apAcct->internalId = $bill->account->internalId;
$vendorPayment->customForm             = new RecordRef();
$vendorPayment->customForm->name       = $bill->customForm->name;
$vendorPayment->subsidiary             = new RecordRef();
$vendorPayment->subsidiary->internalId = $bill->subsidiary->internalId;
$vendorPayment->tranDate = time();
$vendorPayment->memo     = 'Testing Memo';

// Create a new instance of the line item.
$lineItem = new \NetSuite\Classes\VendorPaymentApply();
$lineItem->apply = true;
$lineItem->type= 'Bill';
$lineItem->refNum = $bill->tranId;
$lineItem->amount = 30.00;        

// Add the line item to the vendor payment record.
$vendorPayment->applyList = new \NetSuite\Classes\VendorPaymentApplyList();
$vendorPayment->applyList->apply = [$lineItem];

But I am getting this error:

Adding new line to sublist apply is not allowed.

Upvotes: -1

Views: 309

Answers (1)

Ranva Rahul
Ranva Rahul

Reputation: 79

Today, found a way to create vendor payment record in Netsuite using NetsuiteTalk PHPToolkit.

What I am missing in above request is document id in the ApplyList object.

To create vendor payment record in Netsuite we would need to provide Bill internal id in this parameter.

Full Request

    $vendorPayment                     = new VendorPayment();

    $vendorPayment->entity             = new RecordRef();
    $vendorPayment->entity->internalId = $bill->entity->internalId;

    $vendorPayment->account             = new RecordRef();
    $vendorPayment->account->internalId = self::SB_ACCOUNT_INTERNAL_ID;

    $vendorPayment->apAcct             = new RecordRef();
    $vendorPayment->apAcct->internalId = $bill->account->internalId;

    $vendorPayment->customForm             = new RecordRef();
    $vendorPayment->customForm->name       = $bill->customForm->name;

    $vendorPayment->subsidiary             = new RecordRef();
    $vendorPayment->subsidiary->internalId = $bill->subsidiary->internalId;

    $vendorPayment->tranDate = time();
    $vendorPayment->memo     = 'Testing Memo';

    // Create a new instance of the line item.
    $lineItem = new \NetSuite\Classes\VendorPaymentApply();
    $lineItem->apply = 1;
    $lineItem->type= "vendbill";
    $lineItem->refNum = (string) $bill->tranId;
    $lineItem->doc = $bill->internalId;
    $lineItem->amount = $billTransaction['applied_amount'];

    $vendorPayment->applyList = new \NetSuite\Classes\VendorPaymentApplyList();
    $vendorPayment->applyList->apply[] = $lineItem;
    $vendorPayment->applyList->replaceAll = false;

    return $vendorPayment;

Thanks!

Upvotes: 0

Related Questions