public function setWrittenOff($iInvoiceId): bool
    {
        $oNow    = Factory::factory('DateTime');
        $bResult = $this->update(
            $iInvoiceId,
            [
                'state'       => self::STATE_WRITTEN_OFF,
                'written_off' => $oNow->format('Y-m-d H:i:s'),
            ]
        );

        if ($bResult) {
            $this->triggerEvent(
                Events::INVOICE_WRITTEN_OFF,
                [$this->getInvoiceForEvent($iInvoiceId)]
            );
        }

        return $bResult;
    }