Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/Profile/Magento/Converter/OrderConverter.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
14 changes: 14 additions & 0 deletions tests/Profile/Magento2/Converter/Magento2OrderConverterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'];
Expand All @@ -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();
Expand Down