From b1687615e562b13f41eff94ec03e3eedf586e577 Mon Sep 17 00:00:00 2001
From: Henning Leutz <leutz@pcsg.de>
Date: Tue, 10 Sep 2024 05:23:51 +0200
Subject: [PATCH] fix(Order): copy all customer data to invoice

---
 src/QUI/ERP/Order/Order.php | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/src/QUI/ERP/Order/Order.php b/src/QUI/ERP/Order/Order.php
index a0511c3c..a2b3fba8 100644
--- a/src/QUI/ERP/Order/Order.php
+++ b/src/QUI/ERP/Order/Order.php
@@ -189,6 +189,10 @@ public function createInvoice(
             $this->getGlobalProcessId()
         );
 
+        if ($this->getCustomer()) {
+            $TemporaryInvoice->setCustomer($this->getCustomer());
+        }
+
         $this->History->addComment(
             QUI::getLocale()->get(
                 'quiqqer/order',
@@ -243,7 +247,8 @@ public function createInvoice(
             'order_id' => $this->getUUID(),
             'order_date' => $this->getCreateDate(),
             'project_name' => $this->getAttribute('project_name'),
-            'customer_id' => $this->customerId,
+            'customer_id' => $this->getCustomer()?->getUUID(),
+            'customer_data' => $this->getCustomer()?->getAttributes(),
             'payment_method' => $payment,
             'time_for_payment' => QUI\ERP\Customer\Utils::getInstance()->getPaymentTimeForUser($this->customerId),
             'invoice_address_id' => $invoiceAddressId,
@@ -287,6 +292,8 @@ public function createInvoice(
                 'payment_data' => QUI\Security\Encryption::encrypt(json_encode($this->paymentData)),
                 'currency_data' => json_encode($this->getCurrency()->toArray()),
                 'currency' => $this->getCurrency()->getCode(),
+                'customer_id' => $this->getCustomer()?->getUUID(),
+                'customer_data' => json_encode($this->getCustomer()?->getAttributes()),
             ],
             ['hash' => $TemporaryInvoice->getUUID()]
         );
-- 
GitLab