コード例 #1
0
 public function setStockLevel(Unit $unit, array $row, $location = 'web')
 {
     $stockKey = $this->_headingKeys->getKey('stock');
     if (!is_string($location) && !$location instanceof Location\Location) {
         throw new \InvalidArgumentException('Location must be either a string or an instance of Location');
     } elseif (!array_key_exists($stockKey, $row)) {
         throw new \LogicException('No stock column in row!');
     }
     $stockLevel = (int) $row[$stockKey];
     if ($stockLevel > 0) {
         $location = $location instanceof Location\Location ? $location : $this->_locations->get($location);
         $this->_stockManager->setReason($this->_reason);
         $this->_stockManager->set($unit, $location, $stockLevel);
     }
 }
コード例 #2
0
 protected function _loadItem($itemResult, $itemEntity, $return)
 {
     // Cast decimals to float
     $itemEntity->balance = $itemEntity->balance ? (double) $itemEntity->balance : null;
     $itemEntity->calculatedBalance = $itemEntity->calculatedBalance ? (double) $itemEntity->calculatedBalance : null;
     $itemEntity->remainingBalance = $itemEntity->remainingBalance ? (double) $itemEntity->remainingBalance : null;
     $itemEntity->accepted = null !== $itemEntity->accepted ? (bool) $itemEntity->accepted : null;
     $itemEntity->listPrice = (double) $itemEntity->listPrice;
     $itemEntity->actualPrice = (double) $itemEntity->actualPrice;
     $itemEntity->net = (double) $itemEntity->net;
     $itemEntity->discount = (double) $itemEntity->discount;
     $itemEntity->tax = (double) $itemEntity->tax;
     $itemEntity->taxRate = (double) $itemEntity->taxRate;
     $itemEntity->productTaxRate = (double) $itemEntity->productTaxRate;
     $itemEntity->gross = (double) $itemEntity->gross;
     $itemEntity->rrp = (double) $itemEntity->rrp;
     // Only load the order and refunds if one is attached to the return
     if ($itemEntity->orderID) {
         $itemEntity->order = $this->_orderLoader->getByID($itemEntity->orderID);
         // Grab the item from the order for easy access
         if ($itemEntity->orderItemID) {
             $itemEntity->orderItem = $itemEntity->order->items[$itemEntity->orderItemID];
             $itemEntity->unit = $itemEntity->orderItem->getUnit();
         }
         $itemEntity->note = $this->_orderLoader->getEntityLoader('notes')->getByID($itemEntity->noteID, $itemEntity->order);
         // $itemEntity->document = $this->_orderLoader->getEntityLoader('documents')->getByID($itemResult->documentID, $itemEntity->order);
     }
     if ($itemEntity->exchangeItemID) {
         $itemEntity->exchangeItem = $this->_orderLoader->getEntityLoader('items')->getByID($itemEntity->exchangeItemID, $itemEntity->order ?: null);
     }
     if (!$itemEntity->unit) {
         $itemEntity->unit = $this->_unitLoader->getByID($itemEntity->unitID);
     }
     $itemEntity->reason = $this->_reasons->get($itemResult->reason);
     $itemEntity->status = $this->_statuses->get($itemResult->status_code);
     if ($itemResult->returned_stock_location and $this->_stockLocations->exists($itemResult->returned_stock_location)) {
         $itemEntity->returnedStockLocation = $this->_stockLocations->get($itemResult->returned_stock_location);
     }
     $itemEntity->returnedStock = (bool) $itemEntity->returnedStock;
     $itemEntity = $this->_loadDocument($itemEntity, $return);
     return $itemEntity;
 }