public function writeOff()
    {
        if (!empty($this->iId)) {
            $oInvoiceModel = Factory::model('Invoice', 'nails/module-invoice');
            if (!$oInvoiceModel->setWrittenOff($this->iId)) {
                throw new InvoiceException('Failed to write off invoice.');
            }
        }

        return $this;
    }