public function getShippedAt($latest = false)
    {
        if (0 == $this->shipments->count()) {
            return null;
        }

        $criteria = Criteria::create();
        $criteria
            ->andWhere(Criteria::expr()->eq('return', false))
            ->andWhere(Criteria::expr()->in('state', [ShipmentStates::STATE_READY, ShipmentStates::STATE_SHIPPED]))
            ->orderBy(['createdAt' => $latest ? Criteria::DESC : Criteria::ASC]);

        /** @var ArrayCollection $shipments */
        $shipments = $this->shipments;
        $shipments = $shipments->matching($criteria);

        /** @var ShipmentInterface $shipment */
        if (false !== $shipment = $shipments->first()) {
            return $shipment->getCreatedAt();
        }

        return null;
    }
public function getShippedAt($latest = false)
    {
        if (0 == $this->shipments->count()) {
            return null;
        }

        $criteria = Criteria::create();
        $criteria
            ->andWhere(Criteria::expr()->eq('return', false))
            ->andWhere(Criteria::expr()->in('state', [ShipmentStates::STATE_READY, ShipmentStates::STATE_SHIPPED]))
            ->orderBy(['createdAt' => $latest ? Criteria::DESC : Criteria::ASC]);

        /** @var ArrayCollection $shipments */
        $shipments = $this->shipments;
        $shipments = $shipments->matching($criteria);

        /** @var ShipmentInterface $shipment */
        if (false !== $shipment = $shipments->first()) {
            return $shipment->getCreatedAt();
        }

        return null;
    }
Returns the shipment date.

@param bool $latest Whether to return the last shipment date instead of the first

@return \DateTime|null