Bridge/Symfony/Serializer/Normalizer/SupplierOrderItemNormalizer.php
public function normalize($item, $format = null, array $context = [])
    {
        $data = parent::normalize($item, $format, $context);

        if ($this->contextHasGroup('Summary', $context)) {
            $order = $item->getOrder();

            $received = 0;
            foreach ($order->getDeliveries() as $delivery) {
                foreach ($delivery->getItems() as $di) {
                    if ($di->getOrderItem() === $item) {
                        $received += $di->getQuantity();
                    }
                }
            }

            $formatter = $this->getFormatter();

            $data = array_replace($data, [
                'designation' => $item->getDesignation(),
                'net_price'   => $formatter->currency($item->getNetPrice(), $order->getCurrency()->getCode()),
                'ordered'     => $formatter->number($item->getQuantity()),
                'received'    => $formatter->number($received),
            ]);
        }

        return $data;
    }
public function normalize($item, $format = null, array $context = [])
    {
        $data = parent::normalize($item, $format, $context);

        if ($this->contextHasGroup('Summary', $context)) {
            $order = $item->getOrder();

            $received = 0;
            foreach ($order->getDeliveries() as $delivery) {
                foreach ($delivery->getItems() as $di) {
                    if ($di->getOrderItem() === $item) {
                        $received += $di->getQuantity();
                    }
                }
            }

            $formatter = $this->getFormatter();

            $data = array_replace($data, [
                'designation' => $item->getDesignation(),
                'net_price'   => $formatter->currency($item->getNetPrice(), $order->getCurrency()->getCode()),
                'ordered'     => $formatter->number($item->getQuantity()),
                'received'    => $formatter->number($received),
            ]);
        }

        return $data;
    }
public function normalize ( $ item , $ format = null , array $ context = [ ] ) { $ data = parent :: normalize ( $ item , $ format , $ context ) ; if ( $ this -> contextHasGroup ( 'Summary' , $ context ) ) { $ order = $ item -> getOrder ( ) ; $ received = 0 ; foreach ( $ order -> getDeliveries ( ) as $ delivery ) { foreach ( $ delivery -> getItems ( ) as $ di ) { if ( $ di -> getOrderItem ( ) === $ item ) { $ received += $ di -> getQuantity ( ) ; } } } $ formatter = $ this -> getFormatter ( ) ; $ data = array_replace ( $ data , [ 'designation' => $ item -> getDesignation ( ) , 'net_price' => $ formatter -> currency ( $ item -> getNetPrice ( ) , $ order -> getCurrency ( ) -> getCode ( ) ) , 'ordered' => $ formatter -> number ( $ item -> getQuantity ( ) ) , 'received' => $ formatter -> number ( $ received ) , ] ) ; } return $ data ; }
@inheritdoc

@param SupplierOrderItemInterface $item
@inheritdoc