From 532d0ae7262083d070158cf73b1e2f73ffbbf493 Mon Sep 17 00:00:00 2001
From: Henning Leutz <leutz@pcsg.de>
Date: Tue, 8 Feb 2022 10:16:19 +0100
Subject: [PATCH] fix: add comment to temporary invoice

---
 ajax/invoices/addComment.php | 14 ++------------
 1 file changed, 2 insertions(+), 12 deletions(-)

diff --git a/ajax/invoices/addComment.php b/ajax/invoices/addComment.php
index 61ec5f3..bf218a0 100644
--- a/ajax/invoices/addComment.php
+++ b/ajax/invoices/addComment.php
@@ -13,21 +13,11 @@
 QUI::$Ajax->registerFunction(
     'package_quiqqer_invoice_ajax_invoices_addComment',
     function ($invoiceId, $comment) {
-        $Invoices = QUI\ERP\Accounting\Invoice\Handler::getInstance();
-        $Invoice  = null;
-
         try {
-            $Invoice = $Invoices->getInvoice($invoiceId);
+            $Invoice = QUI\ERP\Accounting\Invoice\Utils\Invoice::getInvoiceByString($invoiceId);
         } catch (\Exception $Exception) {
             QUI\System\Log::addDebug($Exception->getMessage());
-        }
-
-        if ($Invoice === null) {
-            try {
-                $Invoice = $Invoices->getTemporaryInvoice($invoiceId);
-            } catch (\Exception $Exception) {
-                QUI\System\Log::addDebug($Exception->getMessage());
-            }
+            throw $Exception;
         }
 
         $Invoice->addComment($comment);
-- 
GitLab