/**
  * @param \Magento\Sales\Api\Data\OrderInterface $order
  */
 public function splitQty(\Magento\Sales\Api\Data\OrderInterface $order)
 {
     $storeId = $order->getStoreId();
     /* get stock ID for the store view */
     $stockId = $this->_manStock->getStockIdByStoreId($storeId);
     /** @var \Magento\Sales\Api\Data\OrderItemInterface[] $items */
     $items = $order->getItems();
     $itemsData = [];
     /** @var \Magento\Sales\Api\Data\OrderItemInterface $item */
     foreach ($items as $item) {
         $prodId = $item->getProductId();
         $itemId = $item->getItemId();
         /* qty of the product can be changed in invoice, but we use ordered only  */
         $qty = $item->getQtyOrdered();
         /* register sale item (fragment total qty by lots) */
         $itemData = $this->_manObj->create(\Praxigento\Warehouse\Service\QtyDistributor\Data\Item::class);
         $itemData->setItemId($itemId);
         $itemData->setProductId($prodId);
         $itemData->setQuantity($qty);
         $itemData->setStockId($stockId);
         $itemsData[] = $itemData;
     }
     $reqSale = $this->_manObj->create(\Praxigento\Warehouse\Service\QtyDistributor\Request\RegisterSale::class);
     $reqSale->setSaleItems($itemsData);
     $this->_callQtyDistributor->registerSale($reqSale);
 }
 public function test_registerForSaleItem()
 {
     /** === Test Data === */
     $ITEM_ID = 1;
     $PROD_ID = 1;
     $STOCK_ID = 1;
     $QTY = 8;
     /** === Call and asserts  === */
     $req = new Request\RegisterForSaleItem();
     $req->setItemId($ITEM_ID);
     $req->setProductId($PROD_ID);
     $req->setStockId($STOCK_ID);
     $req->setQuantity($QTY);
     $res = $this->obj->registerForSaleItem($req);
     $this->assertNotNull($res);
 }