public function normalize($unit, $format = null, array $context = [])
    {
        $data = [];

        if ($this->contextHasGroup(['StockView', 'StockAssignment'], $context)) {
            $formatter = $this->getFormatter();

            if (null !== $eda = $unit->getEstimatedDateOfArrival()) {
                $eda = $formatter->date($eda);
            }

            $adjustments = [];
            $assignments = [];

            if ($this->contextHasGroup('StockView', $context)) {
                foreach ($unit->getStockAdjustments() as $adjustment) {
                    $adjustments[] = $this->normalizeObject($adjustment, $format, $context);
                }
                foreach ($unit->getStockAssignments() as $assignment) {
                    $assignments[] = $this->normalizeObject($assignment, $format, $context);
                }
            }

            $data = array_replace($data, [
                'geocodes'    => implode(',', $unit->getGeocodes()),
                'ordered'     => $formatter->number($unit->getOrderedQuantity()),
                'received'    => $formatter->number($unit->getReceivedQuantity()),
                'adjusted'    => $formatter->number($unit->getAdjustedQuantity()),
                'sold'        => $formatter->number($unit->getSoldQuantity()),
                'shipped'     => $formatter->number($unit->getShippedQuantity()),
                'eda'         => $eda,
                'net_price'   => $formatter->currency($unit->getNetPrice(), $unit->getCurrency()),
                'adjustments' => $adjustments,
                'assignments' => $assignments,
            ]);
        }

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

        if ($this->contextHasGroup(['StockView', 'StockAssignment'], $context)) {
            $formatter = $this->getFormatter();

            if (null !== $eda = $unit->getEstimatedDateOfArrival()) {
                $eda = $formatter->date($eda);
            }

            $adjustments = [];
            $assignments = [];

            if ($this->contextHasGroup('StockView', $context)) {
                foreach ($unit->getStockAdjustments() as $adjustment) {
                    $adjustments[] = $this->normalizeObject($adjustment, $format, $context);
                }
                foreach ($unit->getStockAssignments() as $assignment) {
                    $assignments[] = $this->normalizeObject($assignment, $format, $context);
                }
            }

            $data = array_replace($data, [
                'geocodes'    => implode(',', $unit->getGeocodes()),
                'ordered'     => $formatter->number($unit->getOrderedQuantity()),
                'received'    => $formatter->number($unit->getReceivedQuantity()),
                'adjusted'    => $formatter->number($unit->getAdjustedQuantity()),
                'sold'        => $formatter->number($unit->getSoldQuantity()),
                'shipped'     => $formatter->number($unit->getShippedQuantity()),
                'eda'         => $eda,
                'net_price'   => $formatter->currency($unit->getNetPrice(), $unit->getCurrency()),
                'adjustments' => $adjustments,
                'assignments' => $assignments,
            ]);
        }

        return $data;
    }
@inheritdoc

@param StockUnitInterface $unit