Skip to content

Commit

Permalink
PISHPS-306: line item refund fix and status fix (#848)
Browse files Browse the repository at this point in the history
  • Loading branch information
m-muxfeld-diw authored Sep 30, 2024
1 parent 69e98c9 commit c4fd0a4
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
6 changes: 5 additions & 1 deletion src/Service/Refund/RefundCreditNoteService.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,11 @@ public function addCreditNoteToOrder(string $orderId, string $refundId, array $l

$data = ['id' => $orderId, 'lineItems' => []];

foreach ($lineItems as ['id' => $lineItemId]) {
foreach ($lineItems as ['id' => $lineItemId, 'amount' => $amount]) {
if ($amount === 0) {
// refund manager front end sends all line items, even if they are not going to be refunded
continue;
}
$lineItem = $this->orderLineItemRepository->search(new Criteria([$lineItemId]), $context)->first();
if (!$lineItem instanceof OrderLineItemEntity) {
continue;
Expand Down
2 changes: 1 addition & 1 deletion src/Service/Transition/DeliveryTransitionService.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ public function partialShipDelivery(OrderDeliveryEntity $delivery, Context $cont
{
$statusTechnical = $this->getStatusTechnicalName($delivery);

if ($statusTechnical === OrderDeliveryStates::STATE_PARTIALLY_SHIPPED) {
if ($statusTechnical === OrderDeliveryStates::STATE_PARTIALLY_SHIPPED || $statusTechnical === OrderDeliveryStates::STATE_PARTIALLY_RETURNED) {
return;
}

Expand Down
4 changes: 2 additions & 2 deletions tests/PHPUnit/Service/Refund/RefundCreditNoteServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ public function throwsExceptionWhenNoLineItemsAreProvided(): void
public function testCanAddRefundLineItems(): void
{
$data = [
['id' => $lineItemId = Uuid::randomBytes()]
['id' => $lineItemId = Uuid::randomBytes(), 'amount' => 1]
];

$price = $this->createConfiguredMock(CalculatedPrice::class, [
Expand Down Expand Up @@ -185,7 +185,7 @@ public function testThrowsExceptionWhenNoCreditLineItemsWouldBeUpserted(): void
$this->expectException(CreditNoteException::class);

$data = [
['id' => Uuid::randomBytes()]
['id' => Uuid::randomBytes(), 'amount' => 1]
];

$searchResult = $this->createConfiguredMock(EntitySearchResult::class, ['first' => null]);
Expand Down

0 comments on commit c4fd0a4

Please sign in to comment.