diff --git a/src/QUI/ERP/Accounting/Invoice/Invoice.php b/src/QUI/ERP/Accounting/Invoice/Invoice.php index 622c2240a6ee5cd4ead74c858a9ba870e077e9ea..440b2e6af2f8f43c67f23e0c6824b1bb53f0a784 100644 --- a/src/QUI/ERP/Accounting/Invoice/Invoice.php +++ b/src/QUI/ERP/Accounting/Invoice/Invoice.php @@ -351,6 +351,15 @@ public function getCustomer(): QUI\ERP\User $userData['id'] = $this->getAttribute('customer_id'); } + // Country fallback + if (empty($userData['country'])) { + if (!empty($invoiceAddress['country'])) { + $userData['country'] = $invoiceAddress['country']; + } else { + $userData['country'] = QUI\ERP\Defaults::getCountry()->getCode(); + } + } + return new QUI\ERP\User($userData); }