public function findOrCreateGoodLine(
        Invoice\InvoiceInterface $invoice,
        Common\SaleItemInterface $item,
        $available,
        $expected = null
    ) {
        $line = null;

        if (0 >= $available) {
            return $line;
        }

        // Existing line lookup
        foreach ($invoice->getLinesByType(Document\DocumentLineTypes::TYPE_GOOD) as $invoiceLine) {
            if ($invoiceLine->getSaleItem() === $item) {
                $line = $invoiceLine;
            }
        }

        // Not found, create it
        if (null === $line) {
            $line = $this->createLine($invoice);
            $line
                ->setInvoice($invoice)
                ->setType(Document\DocumentLineTypes::TYPE_GOOD)
                ->setSaleItem($item)
                ->setDesignation($item->getDesignation())
                ->setDescription($item->getDescription())
                ->setReference($item->getReference());
        }

        // Set available and expected quantity
        $line->setAvailable($available);
        $line->setExpected($expected);

        if (Invoice\InvoiceTypes::isInvoice($invoice) && null === $invoice->getId()) {
            // Set default quantity for new non return shipment items
            $line->setQuantity(min($expected, $available));
        }

        return $line;
    }