From 79ded2b5f5edc90cc0422cd7a9a165f4189b65b4 Mon Sep 17 00:00:00 2001 From: Vitalij Mik Date: Thu, 5 Dec 2024 14:56:27 +0100 Subject: [PATCH 1/2] NTR: fix shipping --- .../sw-order/view/sw-order-detail-general/index.js | 2 +- src/Service/MollieApi/Shipment.php | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/Resources/app/administration/src/module/mollie-payments/extension/sw-order/view/sw-order-detail-general/index.js b/src/Resources/app/administration/src/module/mollie-payments/extension/sw-order/view/sw-order-detail-general/index.js index 69354d314..c14943c9e 100644 --- a/src/Resources/app/administration/src/module/mollie-payments/extension/sw-order/view/sw-order-detail-general/index.js +++ b/src/Resources/app/administration/src/module/mollie-payments/extension/sw-order/view/sw-order-detail-general/index.js @@ -263,7 +263,7 @@ Component.override('sw-order-detail-general', { MolliePaymentsRefundBundleRepositoryService.setOrderId(this.order.id); MolliePaymentsRefundBundleRepositoryService.fetch().then((response) => { - this.isShippingPossible = response.data.shipping; + this.isShippingPossible = response.data.shipping.shippableQuantity > 0; }); this.refundedManagerService.isRefundManagerAvailable(this.order.salesChannelId, this.order.id).then((possible)=>{ diff --git a/src/Service/MollieApi/Shipment.php b/src/Service/MollieApi/Shipment.php index 4fc2b116d..a2daf793f 100644 --- a/src/Service/MollieApi/Shipment.php +++ b/src/Service/MollieApi/Shipment.php @@ -181,12 +181,13 @@ public function getTotals(string $mollieOrderId, string $salesChannelId): array return [ 'amount' => 0.0, 'quantity' => 0, + 'shippable' => 0 ]; } $totalAmount = 0.0; $totalQuantity = 0; - + $shippableQuantity = 0; foreach ($mollieOrder->lines() as $mollieOrderLine) { /** @var OrderLine $mollieOrderLine */ if ($mollieOrderLine->type === OrderLineType::TYPE_SHIPPING_FEE) { @@ -197,13 +198,14 @@ public function getTotals(string $mollieOrderId, string $salesChannelId): array if ($mollieOrderLine->amountShipped) { $totalAmount += floatval($mollieOrderLine->amountShipped->value); } - + $shippableQuantity += $mollieOrderLine->shippableQuantity; $totalQuantity += $mollieOrderLine->quantityShipped; } return [ 'amount' => $totalAmount, 'quantity' => $totalQuantity, + 'shippableQuantity' => $shippableQuantity ]; } } From ed6c86635a02c5a2900a0aa264cfbc501d0ecaf2 Mon Sep 17 00:00:00 2001 From: Vitalij Mik Date: Thu, 5 Dec 2024 15:03:39 +0100 Subject: [PATCH 2/2] NTR: fix tests --- tests/PHPUnit/Service/MollieApi/ShipmentTest.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/PHPUnit/Service/MollieApi/ShipmentTest.php b/tests/PHPUnit/Service/MollieApi/ShipmentTest.php index 1251dec14..4718ecb8f 100644 --- a/tests/PHPUnit/Service/MollieApi/ShipmentTest.php +++ b/tests/PHPUnit/Service/MollieApi/ShipmentTest.php @@ -195,7 +195,8 @@ public function testGetTotals() $expectedTotals = [ 'amount' => 175.0, - 'quantity' => 5 + 'quantity' => 5, + 'shippableQuantity' => 4 ]; $actualTotals = $this->shipmentApiService->getTotals('mollieOrderId', 'salesChannelId');