From 45de6f509b47c07846d10ac46ab801b4f21c2b55 Mon Sep 17 00:00:00 2001 From: Vitalij Mik Date: Thu, 5 Dec 2024 15:25:00 +0100 Subject: [PATCH] NTR: fix shipping (#908) * NTR: fix shipping * NTR: fix tests --------- Co-authored-by: Vitalij Mik --- .../sw-order/view/sw-order-detail-general/index.js | 2 +- src/Service/MollieApi/Shipment.php | 6 ++++-- tests/PHPUnit/Service/MollieApi/ShipmentTest.php | 3 ++- 3 files changed, 7 insertions(+), 4 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 ]; } } 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');