Invoice/Model/InvoiceSubjectTrait.php
public function getInvoicedAt($latest = false)
    {
        if (0 == $this->invoices->count()) {
            return null;
        }

        $criteria = Criteria::create();
        $criteria
            ->andWhere(Criteria::expr()->eq('type', InvoiceTypes::TYPE_INVOICE))
            ->orderBy(['createdAt' => $latest ? Criteria::DESC : Criteria::ASC]);

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

        /** @var InvoiceInterface $invoice */
        if (false !== $invoice = $invoices->first()) {
            return $invoice->getCreatedAt();
        }

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

        $criteria = Criteria::create();
        $criteria
            ->andWhere(Criteria::expr()->eq('type', InvoiceTypes::TYPE_INVOICE))
            ->orderBy(['createdAt' => $latest ? Criteria::DESC : Criteria::ASC]);

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

        /** @var InvoiceInterface $invoice */
        if (false !== $invoice = $invoices->first()) {
            return $invoice->getCreatedAt();
        }

        return null;
    }
Returns the invoice date.

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

@return \DateTime|null