Skip to content
Code-Schnipsel Gruppen Projekte
Commit 69174d59 erstellt von Henning Leutz's avatar Henning Leutz :martial_arts_uniform:
Dateien durchsuchen

feat: implement dynamic currency handling

The updates include:

- Added `quiqqer/currency` package to `composer.json`.
- Refactored code in `Basket.php`, `OrderProcess.php` and `Utils.php` to use the new
`getRuntimeCurrency` function for currency handling.
- Removed hardcoded currency setting in `Basket.php`.
- Updated code in `OrderProcess/Basket.php` to correctly reference new Basket class.
- Added logic to set currency from product data in `Utils.php`.

These changes allow for dynamic handling of currencies across the application, reducing the need
for hardcoded values and enhancing flexibility and maintainability.
Übergeordneter d0f58832
No related branches found
No related tags found
2 Merge Requests!152Update 'next-3.x' with latest changes from 'main',!151feat: implement dynamic currency handling
Pipeline #16595 bestanden mit Phase
in 4 Minuten und 5 Sekunden
......@@ -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",
......
......@@ -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();
......
......@@ -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;
}
}
......
......@@ -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
......
......@@ -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 (
......
0% oder .
You are about to add 0 people to the discussion. Proceed with caution.
Bearbeitung dieser Nachricht zuerst beenden!
Bitte registrieren oder zum Kommentieren