Invoice/EventListener/AbstractInvoiceListener.php
protected function preventForbiddenChange(InvoiceInterface $invoice)
    {
        if ($this->persistenceHelper->isChanged($invoice, 'type')) {
            list($old, $new) = $this->persistenceHelper->getChangeSet($invoice, 'type');
            if ($old != $new) {
                throw new Exception\IllegalOperationException(
                    "Changing the invoice type is not yet supported."
                );
            }
        }
    }
protected function preventForbiddenChange(InvoiceInterface $invoice)
    {
        if ($this->persistenceHelper->isChanged($invoice, 'type')) {
            list($old, $new) = $this->persistenceHelper->getChangeSet($invoice, 'type');
            if ($old != $new) {
                throw new Exception\IllegalOperationException(
                    "Changing the invoice type is not yet supported."
                );
            }
        }
    }
Prevents some of the invoice's fields to change.

@param InvoiceInterface $invoice

@throws Exception\IllegalOperationException