public function save()
    {
        $oInvoiceModel = Factory::model('Invoice', 'nails/module-invoice');
        if (empty($this->iId)) {
            $oInvoice = $oInvoiceModel->create($this->toArray(), true);
            if (empty($oInvoice)) {
                throw new InvoiceException($oInvoiceModel->lastError());
            }
            $this->iId  = $oInvoice->id;
            $this->sRef = $oInvoice->ref;
        } else {
            $oInvoice = $oInvoiceModel->getById($this->iId);
        }
        return $oInvoice;
    }