Set the invoice object

@param integer $iInvoiceId The invoice to use for the request

@return $this
@throws RequestException
4695
public function setInvoice($iInvoiceId)
    {
        //  Validate
        $oModel   = $this->oInvoiceModel;
        $oInvoice = $oModel->getById(
            $iInvoiceId,
            ['expand' => $oModel::EXPAND_ALL]
        );

        if (empty($oInvoice)) {
            throw new RequestException('Invalid invoice ID.');
        }

        $this->oInvoice = $oInvoice;
        return $this;
    }
465054
public function setOrderInvoice(\HarvestCloud\CoreBundle\Entity\Invoice\OrderInvoice $invoice = null)
    {
        $this->orderInvoice = $invoice;

        return $this;
    }
615668
protected function setInvoiceSource($invoiceSource)
    {
        parent::setInvoiceSource($invoiceSource);

        // Load some models and properties we are going to use.
        $this->getRegistry()->load->model('catalog/product');

        switch ($this->invoiceSource->getType()) {
            case Source::Order:
                $this->order = $this->invoiceSource->getSource();
                break;
            case Source::CreditNote:
                break;
        }
    }
1213181
public function setId(int $id) : CNabuDataObject
    {
        if ($id === null) {
            throw new ENabuCoreException(
                    ENabuCoreException::ERROR_NULL_VALUE_NOT_ALLOWED_IN,
                    array("\$id")
            );
        }
        $this->setValue('nb_catalog_tag_id', $id);
        
        return $this;
    }
121872
public function deletePayment(SalesInvoicePayment $salesInvoicePayment)
    {
        if (! isset($salesInvoicePayment->id)) {
            throw new ApiException('Required [id] is missing');
        }

        $this->connection()->delete($this->endpoint . '/' . $this->id . '/payments/' . $salesInvoicePayment->id);

        return $this;
    }
108489
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;
    }
719822
public function setTemplateId(string $templateId = null)
    {
        if (!$this->setHeaderFieldModel('TemplateID', $templateId)) {
            $this->getHeaders()->addTextHeader('TemplateID', $templateId);
        }

        return $this;
    }
760862
public function invoice($orderId, $invoiceKey)
    {
        /** @var OrderHandler $handler */
        $handler = $this->requestHandler();
        return $handler->invoice($orderId, $invoiceKey);
    }
459490
public function setDocumentId($documentId)
    {
        if (preg_match($this->getDocumentIdRegex(), $documentId)) {
            $this->document_id = $documentId;

            return $this;
        }

        throw new InvalidArgument(
            'document_id must be a string with 10 alphanumeric letters.' .
                     '5 letters, followed by 4 numbers, followed by 1 letter or number. Example: ABCDE1234F'
        );
    }
82803
func (s *BillingRecord) SetInvoiceId(v string) *BillingRecord {
	s.InvoiceId = &v
	return s
}
1334920
public function setInvoiceTax(\Core\Entity\InvoiceTax $invoice_tax = null) {
        $this->invoice_tax = $invoice_tax;

        return $this;
    }
560067
public function findByInvoiceId($invoiceId)
    {
        $result = $this->connection()->get($this->getEndpoint() . '/find_by_invoice_id/' . urlencode($invoiceId));

        return $this->makeFromResponse($result);
    }
676825
public function save(ServiceInterface $service, Invoice $invoice = null)
    {
        if (!$this->validate()) {
            throw new NotValidException('Unable to validate invoice history');
        }

        if ($invoice === null) {
            throw new Exception('$invoice must be instance of Invoice');
        }

        $newInvoice = $service->saveHistory($this, $invoice);
        $invoice->setData($newInvoice->toArray(), false);
        return $this->reload(
            end($invoice->history)
        );
    }
1037954
public function setInternalId($id)
    {
        if ($this->_id !== null && $this->_id !== $id) {
            throw new ClientException('Should not update the id of an existing document');
        }


        if (!preg_match('/^[a-zA-Z0-9_-]{1,64}\/[a-zA-Z0-9_:.@\-()+,=;$!*\'%]{1,254}$/', $id)) {
            throw new ClientException('Invalid format for document id');
        }

        $this->_id = (string) $id;
    }
128191
public function setStatus(\Core\Entity\InvoiceStatus $invoice_status = null) {
        $this->invoice_status = $invoice_status;

        return $this;
    }
1031109
public function setMessagingId(int $nb_messaging_id) : CNabuDataObject
    {
        if ($nb_messaging_id === null) {
            throw new ENabuCoreException(
                    ENabuCoreException::ERROR_NULL_VALUE_NOT_ALLOWED_IN,
                    array("\$nb_messaging_id")
            );
        }
        $this->setValue('nb_messaging_id', $nb_messaging_id);
        
        return $this;
    }
327214
public function setInvoiceTime($invoiceTime)
    {
        if (is_a($invoiceTime, 'DateTime')) {
            $this->invoiceTime = $invoiceTime;
        } else if (is_numeric($invoiceTime)) {
            $invoiceDateTime = new \DateTime('', new \DateTimeZone("UTC"));
            $invoiceDateTime->setTimestamp($invoiceTime);
            $this->invoiceTime = $invoiceDateTime;
        }
        return $this;
    }