Skip to content
Code-Schnipsel Gruppen Projekte
Commit 73c13161 erstellt von Patrick Müller's avatar Patrick Müller
Dateien durchsuchen

feat: getInvoiceByHash now returns matching temporary invoices

Übergeordneter 3babd48a
No related branches found
No related tags found
Keine zugehörigen Merge Requests gefunden
......@@ -340,13 +340,15 @@ public function getInvoice($id): Invoice
* Return an Invoice by hash
*
* @param string $hash - Hash of the Invoice
* @return Invoice
* @return Invoice|InvoiceTemporary
*
* @throws Exception
* @throws QUI\Exception
*/
public function getInvoiceByHash(string $hash): Invoice
public function getInvoiceByHash(string $hash)
{
$hash = QUI\Utils\Security\Orthos::clear($hash);
$result = QUI::getDataBase()->fetch([
'select' => 'id',
'from' => self::invoiceTable(),
......@@ -356,16 +358,27 @@ public function getInvoiceByHash(string $hash): Invoice
'limit' => 1
]);
$hash = QUI\Utils\Security\Orthos::clear($hash);
if (!empty($result)) {
return $this->getInvoice($result[0]['id']);
}
if (!isset($result[0])) {
throw new Exception(
['quiqqer/invoice', 'exception.invoice.not.found', ['id' => $hash]],
404
);
$result = QUI::getDataBase()->fetch([
'select' => 'id',
'from' => self::temporaryInvoiceTable(),
'where' => [
'hash' => $hash
],
'limit' => 1
]);
if (!empty($result)) {
return $this->getTemporaryInvoice($result[0]['id']);
}
return $this->getInvoice($result[0]['id']);
throw new Exception(
['quiqqer/invoice', 'exception.invoice.not.found', ['id' => $hash]],
404
);
}
/**
......
......@@ -769,7 +769,6 @@ public function copy($PermissionUser = null, $globalProcessId = false): InvoiceT
$globalProcessId = $this->getHash();
}
// Invoice Address
$invoiceAddressId = '';
$invoiceAddress = '';
......
0% oder .
You are about to add 0 people to the discussion. Proceed with caution.
Bearbeitung dieser Nachricht zuerst beenden!
Bitte registrieren oder zum Kommentieren