code: private function removeInvoice(Invoice\InvoiceInterface $invoice)
      {
          $invoice->setShipment(null);
          $invoice->setSale(null);
  
          if (null !== $invoice->getId()) {
              foreach ($invoice->getLines() as $line) {
                  $this->persistenceHelper->remove($line, true);
              }
              $this->persistenceHelper->remove($invoice, true);
          } elseif ($this->persistenceHelper->isScheduledForInsert($invoice)) {
              $this->persistenceHelper->getManager()->remove($invoice);
          }
      }
docs: Removes the invoice.
  
  @param Invoice\InvoiceInterface $invoice