From ed56e8a6260f6100a241dbe6da38263d221efe5a Mon Sep 17 00:00:00 2001 From: Dennis Garding Date: Mon, 10 Aug 2026 15:44:46 +0200 Subject: [PATCH] fix: use 1.0 currency factor for same-currency Magento orders --- src/Profile/Magento/Converter/OrderConverter.php | 3 +++ .../Converter/Magento2OrderConverterTest.php | 14 ++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/src/Profile/Magento/Converter/OrderConverter.php b/src/Profile/Magento/Converter/OrderConverter.php index 4c47904..81115ac 100644 --- a/src/Profile/Magento/Converter/OrderConverter.php +++ b/src/Profile/Magento/Converter/OrderConverter.php @@ -169,6 +169,9 @@ public function convert(array $data, Context $context, MigrationContextInterface $this->convertValue($converted, 'orderNumber', $data['orders'], 'increment_id'); $this->convertValue($converted, 'currencyFactor', $data['orders'], 'store_to_order_rate', self::TYPE_FLOAT); + if (($converted['currencyFactor'] ?? 0.0) <= 0.0) { + $converted['currencyFactor'] = 1.0; + } $this->convertValue($converted, 'orderDateTime', $data['orders'], 'created_at', self::TYPE_DATETIME); $this->convertCurrency($converted, $data); diff --git a/tests/Profile/Magento2/Converter/Magento2OrderConverterTest.php b/tests/Profile/Magento2/Converter/Magento2OrderConverterTest.php index eed4460..0267bee 100644 --- a/tests/Profile/Magento2/Converter/Magento2OrderConverterTest.php +++ b/tests/Profile/Magento2/Converter/Magento2OrderConverterTest.php @@ -277,6 +277,7 @@ public function testConvert(): void static::assertNotNull($converted); static::assertNull($convertResult->getUnmapped()); static::assertArrayHasKey('id', $converted); + static::assertSame(1.0, $converted['currencyFactor']); static::assertNotNull($convertResult->getMappingUuid()); static::assertSame($this->storeUuid, $converted['salesChannelId']); $price = $converted['price']; @@ -289,6 +290,19 @@ public function testConvert(): void static::assertNotNull($converted['totalRounding']); } + public function testConvertWithZeroCurrencyFactor(): void + { + $context = Context::createDefaultContext(); + $orderData = require __DIR__ . '/../../../_fixtures/order_data.php'; + $orderData[0]['orders']['store_to_order_rate'] = '0.0000'; + + $convertResult = $this->orderConverter->convert($orderData[0], $context, $this->migrationContext); + $converted = $convertResult->getConverted(); + + static::assertNotNull($converted); + static::assertSame(1.0, $converted['currencyFactor']); + } + public function testConvertWithInvalidShippingMethod(): void { $context = Context::createDefaultContext();