NetSuite PHP Web服务API不允许我在库存调整的库存明细上设置序列号/批号

问题描述 投票:0回答:1

我有NetSuite PHP Web服务API的以下代码,但它不允许我在库存详细信息上设置库存调整的序列号/批号。

// Create new Inventory Adjustment.
$conv = new InventoryAdjustment();
// Set Inventory Adjustment values. YYYY-MM-DDTHH:MM:SS.mmm-HH:MM.  For example: 2014-03-26T12:32:56.156-04:00
$conv->tranDate = date('Y-m-d\TH:i:s\.\0\0\0\+\0\2:\0\0');   // Set the Transaction Date to current date.
$conv->account = new RecordRef();   // Adjustment Account
$conv->account->internalId = '490';   // Consumables: Packing Materials
// Creat an Inventory Adjustment item line Inventory Details Assignment List's Assignment.
$ass = new InventoryAssignment();
$ass->issueInventoryNumber = new RecordRef();   // Lot Number. See SYN Inventory Numbers Saved Search.
$ass->issueInventoryNumber->internalId = '2';   // 456.
$ass->quantity = 3;   // Quantity.
// Create an Inventory Adjustment item line Inventory Detail's Assignment List.
$detass = new InventoryAssignmentList();
$detass->inventoryAssignment = array($ass);
// Create an Inventory Adjustment item line's Inventory Detail.
$det = new InventoryDetail();
$det->inventoryAssignmentList = $detass;
// Create an Inventory Adjustment item line.
$line = new InventoryAdjustmentInventory();
$line->line = 0;                     // Line number.
$line->item = new RecordRef();       // Item.
$line->item->internalId = '1083';    // Internal id of item
$line->location = new RecordRef();   // Location.
$line->location->internalId = '5';   // My location
$line->adjustQtyBy = 3;              // Adjust Quantity By.
$line->inventoryDetail = $det;       // Inventory Detail.
// Set the Inventory Adjustment Items.
$conv->inventoryList = new InventoryAdjustmentInventoryList();
$conv->inventoryList->inventory = array($line);

// Setup the creation request.
$request = new AddRequest();
$request->record = $conv;
// Execute the creation request and get the response.
$addResponse = $service->add($request);
if ($addResponse->writeResponse->status->isSuccess)
{
   echo 'Add Inventory Adjustment Successful' . $addResponse->writeResponse->baseRef->internalId;
}
else
{
   echo '<br><br>Add Inventory Adjustment NOT Successful<br><br>';
   var_dump($addResponse);
}

我收到以下错误:

Add Inventory Adjustment NOT Successful

object(AddResponse)#6 (1) { ["writeResponse"]=> object(WriteResponse)#22 (2) { ["status"]=> object(Status)#23 (2) { ["statusDetail"]=> array(1) { [0]=> object(StatusDetail)#24 (4) { ["code"]=> string(23) "INSUFFICIENT_PERMISSION" ["message"]=> string(290) "You do not have permissions to set a value for element inventoryassignment.issueinventorynumber due to one of the following reasons: 1) The field is read-only; 2) An associated feature is disabled; 3) The field is available either when a record is created or updated, but not in both cases." ["afterSubmitFailed"]=> NULL ["type"]=> string(5) "ERROR" } } ["isSuccess"]=> bool(false) } ["baseRef"]=> NULL } } 

我们正在使用批量编号库存物料。有谁知道我做错了什么?

php netsuite suitetalk
1个回答
0
投票

原来正确的代码是这样的:

// Create new Inventory Adjustment.
$InventoryAdjustment = new InventoryAdjustment();
$InventoryAdjustment->externalId = 1000;
// Set Inventory Adjustment values. YYYY-MM-DDTHH:MM:SS.mmm-HH:MM.  For example: 2014-03-26T12:32:56.156-04:00
$InventoryAdjustment->tranDate = date('Y-m-d\TH:i:s\.\0\0\0\+\0\2:\0\0');   // Set the Transaction Date to current date.
$InventoryAdjustment->account = new RecordRef();   // Adjustment Account
$InventoryAdjustment->account->internalId = '490';
// Create an Inventory Adjustment item line Inventory Details Assignment List's Assignment.
$inventoryAssignment = new InventoryAssignment();
$inventoryAssignment->receiptInventoryNumber = "SERIAL123";
//$inventoryAssignment->issueInventoryNumber = new RecordRef();
//$inventoryAssignment->issueInventoryNumber->internalId = 2;   // 456.
$inventoryAssignment->quantity = 3;   // Quantity.
// Create an Inventory Adjustment item line Inventory Detail's Assignment List.
$inventoryAssignmentList = new InventoryAssignmentList();
$inventoryAssignmentList->inventoryAssignment = $inventoryAssignment;                       // array($inventoryAssignment);
// Create an Inventory Adjustment item line's Inventory Detail.
$inventoryDetail = new InventoryDetail();
$inventoryDetail->inventoryAssignmentList = $inventoryAssignmentList;
// Create an Inventory Adjustment item line.
$InventoryAdjustmentInventory = new InventoryAdjustmentInventory();
             // $InventoryAdjustmentInventory->line = 0;                     // Line number.
$InventoryAdjustmentInventory->item = new RecordRef();       // Item.
$InventoryAdjustmentInventory->item->internalId = 1083;
$InventoryAdjustmentInventory->location = new RecordRef();   // Location.
$InventoryAdjustmentInventory->location->internalId = 5;
$InventoryAdjustmentInventory->adjustQtyBy = 3;              // Adjust Quantity By.
$InventoryAdjustmentInventory->inventoryDetail = $inventoryDetail;       // Inventory Detail.
// Set the Inventory Adjustment Items.
$InventoryAdjustmentInventoryList = new InventoryAdjustmentInventoryList();
$InventoryAdjustmentInventoryList->inventory = $InventoryAdjustmentInventory;

$InventoryAdjustment->inventoryList = $InventoryAdjustmentInventoryList;

// Setup the Insert/Update request.
$request = new UpsertRequest();
$request->record = $InventoryAdjustment;
// Execute the creation request and get the response.
$addResponse = $service->upsert($request);
© www.soinside.com 2019 - 2024. All rights reserved.