diff --git a/composer.json b/composer.json index 582afb9c85085a031cd2f1def83782d74d6739aa..287dd3922d0c2c8c84ea661f93ec2788fbcab027 100644 --- a/composer.json +++ b/composer.json @@ -23,6 +23,7 @@ "php81_bc/strftime": "^0.7", "ramsey/uuid": "^3|^4", "quiqqer/core": "^2", + "quiqqer/currency": "^2.2", "quiqqer/qui": "^1.6.7", "quiqqer/erp": "^3.7.1", "quiqqer/countries": "^2", diff --git a/src/QUI/ERP/Order/Basket/Basket.php b/src/QUI/ERP/Order/Basket/Basket.php index 94a4eda1d0fee5a6ee6e0feb99f7ef125a8e5e74..c868498bff97a2f01180c7660497c173d3091500 100644 --- a/src/QUI/ERP/Order/Basket/Basket.php +++ b/src/QUI/ERP/Order/Basket/Basket.php @@ -76,6 +76,7 @@ public function __construct(bool | int $basketId, null | QUI\Interfaces\Users\Us } $this->List->setUser($User); + $this->List->setCurrency(QUI\ERP\Currency\Handler::getRuntimeCurrency()); $this->FrontendMessages = new QUI\ERP\Comments(); if (is_bool($basketId)) { @@ -101,8 +102,6 @@ public function __construct(bool | int $basketId, null | QUI\Interfaces\Users\Us if (!empty($data['products'])) { $this->import(json_decode($data['products'], true)); } - - $this->List->setCurrency(QUI\ERP\Defaults::getUserCurrency()); } /** @@ -461,11 +460,17 @@ public function toOrder(QUI\ERP\Order\AbstractOrder $Order): void // update the data $products = $Products->getProducts(); + $Currency = $Products->getCurrency(); + + if (!$Currency) { + $Currency = QUI\ERP\Currency\Handler::getRuntimeCurrency(); + } $InvoiceAddress = $Order->getInvoiceAddress(); $DeliveryAddress = $Order->getDeliveryAddress(); $Order->clear(); + $Order->setCurrency($Currency); foreach ($products as $Product) { if (!method_exists($Product, 'toArticle')) { @@ -479,6 +484,7 @@ public function toOrder(QUI\ERP\Order\AbstractOrder $Order): void } } + $Order->setInvoiceAddress($InvoiceAddress); $Order->setDeliveryAddress($DeliveryAddress); $Order->update(); diff --git a/src/QUI/ERP/Order/Controls/OrderProcess/Basket.php b/src/QUI/ERP/Order/Controls/OrderProcess/Basket.php index 7c97c2cb67a223268aedce184b76660750070c91..29328ad245a685f3fbe03eba17076ddafbdca0a0 100644 --- a/src/QUI/ERP/Order/Controls/OrderProcess/Basket.php +++ b/src/QUI/ERP/Order/Controls/OrderProcess/Basket.php @@ -113,7 +113,7 @@ public function validate(): void $Current = $OrderProcess->getCurrentStep(); // if current step is basket, we need no cleanup ... only later - if ($Current instanceof QUI\ERP\Order\Controls\Basket\Basket) { + if ($Current instanceof QUI\ERP\Order\Controls\OrderProcess\Basket) { return; } } diff --git a/src/QUI/ERP/Order/OrderProcess.php b/src/QUI/ERP/Order/OrderProcess.php index d3e413cb1106edcbb0cccf24ed01876345b6341e..39e25168fb1a48732a1cdc6e2517fd19176ac8b2 100644 --- a/src/QUI/ERP/Order/OrderProcess.php +++ b/src/QUI/ERP/Order/OrderProcess.php @@ -153,15 +153,15 @@ public function __construct(array $attributes = []) $this->setAttribute('orderHash', $Order->getUUID()); // set order currency - $UserCurrency = QUI\ERP\Defaults::getUserCurrency(); + $UserCurrency = QUI\ERP\Currency\Handler::getRuntimeCurrency(); - if ($UserCurrency && $UserCurrency->getCode() !== $Order->getCurrency()->getCode()) { + if ($UserCurrency->getCode() !== $Order->getCurrency()->getCode()) { $Order->setCurrency($UserCurrency); $Order->update(); } // order is successful, so no other step must be shown - if ($Order && $Order->isSuccessful()) { + if ($Order->isSuccessful()) { $LastStep = end($steps); $this->setAttribute('step', $LastStep->getName()); @@ -1426,6 +1426,7 @@ protected function getProcessingStep(): mixed } catch (QUI\Exception) { } + // @todo process step sich merken, sonst 1000 neue objekte return new Controls\OrderProcess\Processing([ 'Order' => $this->getOrder(), 'priority' => 40 diff --git a/src/QUI/ERP/Order/Utils/Utils.php b/src/QUI/ERP/Order/Utils/Utils.php index ee5cfce6a85fe4afd29cc1e2fa312d6c23b9e46b..e946123497da7ea9015e3c4b9787ff25055e4551 100644 --- a/src/QUI/ERP/Order/Utils/Utils.php +++ b/src/QUI/ERP/Order/Utils/Utils.php @@ -298,6 +298,9 @@ public static function importProductsToBasketList( $productClass = $productData['class']; } + if (!isset($productData['price_currency'])) { + $productData['price_currency'] = $List->getCurrency()?->getCode(); + } // bridge for text articles if (