4

我正在尝试使用 PHP Netsuite Api 将 SalesOrder 设置为已完成,但我不断收到以下错误:

VALID_LINE_ITEM_REQD - 此交易您必须至少有一个有效的行项目。

我正在使用https://github.com/ryanwinchester/netsuite-php库。

到目前为止,我有以下内容。我也尝试过使用在一些示例中看到的 Initialise 方法,但它们似乎都给出了相同的错误。如果有帮助,我们将使用高级库存管理。

$itemFulfillment = new ItemFulfillment();

// Sales Order
$itemFulfillment->createdFrom = new RecordRef();
$itemFulfillment->createdFrom->internalId = <SALES_ORDER_ID>;

$itemFulfillment->shipStatus = ItemFulfillmentShipStatus::_shipped;

// Customer
$itemFulfillment->entity = new RecordRef();
$itemFulfillment->entity->internalId = <CUSTOMER_ID>;

// List
$fullfillmentList = new ItemFulfillmentItemList();
$fullfillmentList->replaceAll = true;

foreach($salesOrder->itemList->item as $saleItem) {
    $item = new ItemFulfillmentItem();
    $item->location = new RecordRef();
    $item->location->internalId = 4;
    $item->item = new RecordRef();
    $item->item->internalId = $saleItem->item->internalId;
    $item->itemIsFulfilled = true;
    $item->itemReceive = true;
    $item->quantity = $saleItem->quantity;
    $item->orderLine = $saleItem->line;           

    // Department Reference
    $departmentRec = new RecordRef();
    $departmentRec->internalId = 5;
    $item->department = $departmentRec;

    $fullfillmentList->item[] = $item;
}

$itemFulfillment->itemList = $fullfillmentList;


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

$client->add($request);

任何帮助都会很棒。:)

4

2 回答 2

0

将销售订单转换为

跨子公司项目履行记录将返回“VALID_LINE_ITEM_REQD >

如果我们未在 defaultValue 参数中指定inventoryLocation,则您必须至少有一个有效的订单项用于此交易”错误。

function createIF(soId, invLocation) { var itemFulfillment = record.transform({ fromType: record.Type.SALES_ORDER, fromId: soId, toType: record.Type.ITEM_FULFILLMENT, defaultValues: { inventorylocation: invLocation } }); /** * You can insert other script logic here */ var ifID = itemFulfillment.save(); return ifID; }

于 2019-12-18T23:11:33.383 回答
0
  • 确保物品在库存中
  • 确保该项目可供您的子公司使用
  • 确保您正确提交子列表(如果适用)
  • 转储 $saleItem 以查看其中的内容以确保 note 为空
于 2018-12-04T22:24:51.263 回答