Skip to content

Commit

Permalink
NTR: fix shipping (#908)
Browse files Browse the repository at this point in the history
* NTR: fix shipping

* NTR: fix tests

---------

Co-authored-by: Vitalij Mik <[email protected]>
  • Loading branch information
BlackScorp and Vitalij Mik authored Dec 5, 2024
1 parent 595cd5c commit 45de6f5
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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)=>{
Expand Down
6 changes: 4 additions & 2 deletions src/Service/MollieApi/Shipment.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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
];
}
}
3 changes: 2 additions & 1 deletion tests/PHPUnit/Service/MollieApi/ShipmentTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,8 @@ public function testGetTotals()

$expectedTotals = [
'amount' => 175.0,
'quantity' => 5
'quantity' => 5,
'shippableQuantity' => 4
];

$actualTotals = $this->shipmentApiService->getTotals('mollieOrderId', 'salesChannelId');
Expand Down

0 comments on commit 45de6f5

Please sign in to comment.