public function view()
    {
        if (!userHasPermission('admin:invoice:invoice:edit')) {
            unauthorised();
        }

        $oUri                  = Factory::service('Uri');
        $oModel                = $this->oInvoiceModel;
        $iInvoiceId            = (int) $oUri->segment(5);
        $this->data['invoice'] = $this->oInvoiceModel->getById(
            $iInvoiceId,
            ['expand' => $oModel::EXPAND_ALL]
        );

        if (!$this->data['invoice'] || $this->data['invoice']->state->id == 'DRAFT') {
            show404();
        }

        $this->data['page']->title = 'View Invoice &rsaquo; ' . $this->data['invoice']->ref;

        $oAsset = Factory::service('Asset');
        $oAsset->load('admin.invoice.view.min.js', 'nails/module-invoice');

        Helper::loadView('view');
    }