Saturday, May 18, 2019

PHP Toolkit New Version (2012.2 and Later) > Create Inventory Adjustment record via Web Services with Advanced Bin/Numbered Inventory Management feature enabled.

Below is a sample code that will create Inventory Adjustment record and enter serial number on the inventory detail page

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

    $service = new NetSuiteService();

    $InventoryAdjustment = new InventoryAdjustment();
    $InventoryAdjustment->externalId = 1000;

    $InventoryAdjustment->postingPeriod = new RecordRef();
    $InventoryAdjustment->postingPeriod->internalId = 81;
    $InventoryAdjustment->account = new RecordRef();
    $InventoryAdjustment->account->internalId = 137;

    $inventoryAssignment = new InventoryAssignment();
    $inventoryAssignment->receiptInventoryNumber = "SERIAL123";

    $inventoryAssignmentList = new InventoryAssignmentList();
    $inventoryAssignmentList->inventoryAssignment = $inventoryAssignment;

    $inventoryDetail = new InventoryDetail();
    $inventoryDetail->inventoryAssignmentList = $inventoryAssignmentList;

    $InventoryAdjustmentInventory  = new InventoryAdjustmentInventory();
    $InventoryAdjustmentInventory->item = new RecordRef();
    $InventoryAdjustmentInventory->item->internalId = 2326;
    $InventoryAdjustmentInventory->location = new RecordRef();
    $InventoryAdjustmentInventory->location->internalId = 6;
    $InventoryAdjustmentInventory->adjustQtyBy = 1;
    $InventoryAdjustmentInventory->inventoryDetail = $inventoryDetail;

    $InventoryAdjustmentInventoryList = new InventoryAdjustmentInventoryList();
    $InventoryAdjustmentInventoryList->inventory = $InventoryAdjustmentInventory;

    $InventoryAdjustment->inventoryList = $InventoryAdjustmentInventoryList;

    $request = new UpsertRequest();
    $request->record = $InventoryAdjustment;


    $upsertResponse = $service->upsert($request);
   
    if (!$upsertResponse->writeResponse->status->isSuccess) {
        echo "ADD INVENTORY ADJUSTMENT ERROR";

    } else {
        echo "ADD INVENTORY ADJUSTMENT SUCCESS, id " . $upsertResponse->writeResponse->baseRef->internalId;
    }
?>

 

No comments:

Post a Comment