From 5d94e53f48ec3ec8d033fd3369222982ad90ccf3 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Patrick=20M=C3=BCller?= <p.mueller@pcsg.de>
Date: Wed, 16 Mar 2022 14:51:03 +0100
Subject: [PATCH] fix: invoice address must be array on save

---
 src/QUI/ERP/Accounting/Invoice/InvoiceTemporary.php | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/src/QUI/ERP/Accounting/Invoice/InvoiceTemporary.php b/src/QUI/ERP/Accounting/Invoice/InvoiceTemporary.php
index c03cc30..73589d4 100644
--- a/src/QUI/ERP/Accounting/Invoice/InvoiceTemporary.php
+++ b/src/QUI/ERP/Accounting/Invoice/InvoiceTemporary.php
@@ -353,6 +353,8 @@ public function getCustomer()
             'email'     => $User->getAttribute('email')
         ];
 
+        $Customer = false;
+
         try {
             $Customer = QUI\ERP\User::convertUserToErpUser($User);
             $userData = $Customer->getAttributes();
@@ -390,10 +392,6 @@ public function getCustomer()
             }
         }
 
-        if (!empty($this->getAttribute('contact_person'))) {
-            $userData['quiqqer.erp.customer.contact.person'] = $this->getAttribute('contact_person');
-        }
-
         if (empty($userData['country'])) {
             $userData['country'] = QUI\ERP\Defaults::getCountry()->getCode();
         }
@@ -767,8 +765,9 @@ public function update($PermissionUser = null)
                 $invoiceAddressCheck['contactEmail'] = $contactEmail;
 
                 $invoiceAddress = \json_encode($invoiceAddressCheck);
-            } else {
+            } elseif (\is_array($invoiceAddress)) {
                 $invoiceAddress['contactEmail'] = $contactEmail;
+                $invoiceAddress                 = \json_encode($invoiceAddress);
             }
 
             if (!$invoiceAddressCheck) {
-- 
GitLab