Stock/Linker/StockUnitLinker.php
private function updatePrice(StockUnitInterface $stockUnit)
    {
        $price = null;

        if (null !== $item = $stockUnit->getSupplierOrderItem()) {
            if (null === $order = $item->getOrder()) {
                throw new StockLogicException("Supplier order item's order must be set at this point.");
            }

            $currency = $order->getCurrency()->getCode();
            $date = $order->getPaymentDate();
            if ($date > new \DateTime()) {
                $date = null;
            }

            $price = $this->currencyConverter->convert($item->getNetPrice(), $currency, null, $date);
        }

        if (0 !== Money::compare($stockUnit->getNetPrice(), $price, $this->currencyConverter->getDefaultCurrency())) {
            $stockUnit->setNetPrice($price);

            return true;
        }

        return false;
    }
private function updatePrice(StockUnitInterface $stockUnit)
    {
        $price = null;

        if (null !== $item = $stockUnit->getSupplierOrderItem()) {
            if (null === $order = $item->getOrder()) {
                throw new StockLogicException("Supplier order item's order must be set at this point.");
            }

            $currency = $order->getCurrency()->getCode();
            $date = $order->getPaymentDate();
            if ($date > new \DateTime()) {
                $date = null;
            }

            $price = $this->currencyConverter->convert($item->getNetPrice(), $currency, null, $date);
        }

        if (0 !== Money::compare($stockUnit->getNetPrice(), $price, $this->currencyConverter->getDefaultCurrency())) {
            $stockUnit->setNetPrice($price);

            return true;
        }

        return false;
    }
private function updatePrice ( StockUnitInterface $ stockUnit ) { $ price = null ; if ( null !== $ item = $ stockUnit -> getSupplierOrderItem ( ) ) { if ( null === $ order = $ item -> getOrder ( ) ) { throw new StockLogicException ( "Supplier order item's order must be set at this point." ) ; } $ currency = $ order -> getCurrency ( ) -> getCode ( ) ; $ date = $ order -> getPaymentDate ( ) ; if ( $ date > new \ DateTime ( ) ) { $ date = null ; } $ price = $ this -> currencyConverter -> convert ( $ item -> getNetPrice ( ) , $ currency , null , $ date ) ; } if ( 0 !== Money :: compare ( $ stockUnit -> getNetPrice ( ) , $ price , $ this -> currencyConverter -> getDefaultCurrency ( ) ) ) { $ stockUnit -> setNetPrice ( $ price ) ; return true ; } return false ; }
Updates the stock unit price.

@param StockUnitInterface $stockUnit

@return bool Whether or not the net price has been updated.

@throws \Ekyna\Component\Commerce\Exception\LogicException
Updates the stock unit price .