Ejemplo n.º 1
0
 /**
  * a product is fixed from RMA
  *
  * @param unknown            $qty
  * @param string             $comments
  * @param BaseEntityAbstract $entity
  */
 public function fixedFromRMA($qty, $comments, BaseEntityAbstract $entity = null)
 {
     $rma = $entity instanceof RMA ? $entity : ($entity instanceof RMAItem ? $entity->getRMA() : null);
     $order = $rma instanceof RMA ? $rma->getOrder() : null;
     $unitCostFromRMA = intval($this->getStockInRMA()) === 0 ? 0 : $this->getTotalRMAValue() / $this->getStockInRMA();
     return $this->setStockInRMA(($originalStockOnRMA = $this->getStockInRMA()) - $qty)->setTotalRMAValue(($originalTotalRMAValue = $this->getTotalRMAValue()) - $qty * $unitCostFromRMA)->setStockOnHand(($originStockOnHand = $this->getStockOnHand()) + $qty)->setTotalOnHandValue(($originalTotalOnHandValue = $this->getTotalOnHandValue()) + $qty * $unitCostFromRMA)->snapshotQty($entity instanceof BaseEntityAbstract ? $entity : $this, ProductQtyLog::TYPE_RMA, 'Stock Fixed from: ' . ($creditNote instanceof CreditNote ? 'RMA[' . $rma->getRaNo() . ']' : '') . ($order instanceof Order ? ' generated from Order[' . $order->getOrderNo() . ']' : '') . (trim($comments) === '' ? '.' : ': ' . $comments))->save()->addLog('StockInRMA(' . $originalStockOnRMA . ' => ' . $this->getStockInRMA() . '), TotalRMAValue(' . $originalTotalRMAValue . ' => ' . $this->getTotalRMAValue() . '), StockOnHand(' . $originStockOnHand . ' => ' . $this->getStockOnHand() . '), TotalOnHandValue(' . $originalTotalOnHandValue . ' => ' . $this->getTotalOnHandValue() . ')' . (trim($comments) === '' ? '.' : ': ' . $comments), Log::TYPE_SYSTEM, 'STOCK_QTY_CHG', __CLASS__ . '::' . __FUNCTION__);
 }