diff --git a/spec/Provider/TaxRateAmountProviderSpec.php b/spec/Provider/TaxRateAmountProviderSpec.php index 0d6116672..954d84ca6 100644 --- a/spec/Provider/TaxRateAmountProviderSpec.php +++ b/spec/Provider/TaxRateAmountProviderSpec.php @@ -8,7 +8,6 @@ use Sylius\RefundPlugin\Entity\AdjustmentInterface; use Sylius\RefundPlugin\Provider\TaxRateAmountProviderInterface; - final class TaxRateAmountProviderSpec extends ObjectBehavior { function it_implements_tax_rate_provider_interface(): void @@ -23,7 +22,6 @@ function it_provides_a_tax_rate_amount_from_tax_adjustment(AdjustmentInterface $ $this->provide($adjustment)->shouldReturn(0.20); } - function it_throws_exception_if_order_item_unit_has_more_than_1_tax_adjustment(AdjustmentInterface $adjustment): void { $adjustment->getDetails()->willReturn(['detail' => 'detail']); diff --git a/spec/Provider/TaxRateProviderSpec.php b/spec/Provider/TaxRateProviderSpec.php index b676ff118..7963d3ee0 100644 --- a/spec/Provider/TaxRateProviderSpec.php +++ b/spec/Provider/TaxRateProviderSpec.php @@ -44,7 +44,6 @@ function it_returns_null_if_there_is_no_tax_adjustment(OrderItemUnitInterface $o function it_returns_null_if_there_is_no_adjustment_with_details_with_tax_rate_amount( OrderItemUnitInterface $orderItemUnit, AdjustmentInterface $taxAdjustment - ): void { $orderItemUnit ->getAdjustments(AdjustmentInterface::TAX_ADJUSTMENT) @@ -60,7 +59,6 @@ function it_throws_exception_if_order_item_unit_has_more_than_1_tax_adjustment( OrderItemUnitInterface $orderItemUnit, AdjustmentInterface $firstTaxAdjustment, AdjustmentInterface $secondTaxAdjustment - ): void { $orderItemUnit ->getAdjustments(AdjustmentInterface::TAX_ADJUSTMENT) diff --git a/src/Converter/ShipmentLineItemsConverter.php b/src/Converter/ShipmentLineItemsConverter.php index de4cb7a2f..347f96935 100644 --- a/src/Converter/ShipmentLineItemsConverter.php +++ b/src/Converter/ShipmentLineItemsConverter.php @@ -59,12 +59,15 @@ private function convertUnitRefundToLineItem(ShipmentRefund $shipmentRefund): Li $grossValue = $shipmentRefund->total(); - $taxAdjustment = $shipment->getAdjustments(AdjustmentInterface::TAX_ADJUSTMENT)->first(); + $taxAdjustments = $shipment->getAdjustments(AdjustmentInterface::TAX_ADJUSTMENT); + + $taxAdjustmentAmount = 0; + if (count($taxAdjustments) > 0) { + $taxAdjustmentAmount = $this->taxRateAmountProvider->provide($taxAdjustments[0]); + } - $taxAdjustmentAmount = $this->taxRateAmountProvider->provide($taxAdjustment); $taxRate = $taxAdjustmentAmount * 100 . '%'; $taxAmount = (int) ($grossValue * $taxAdjustmentAmount); - $netValue = $grossValue - $taxAmount; return new LineItem( diff --git a/tests/Behat/Context/Ui/CreditMemoContext.php b/tests/Behat/Context/Ui/CreditMemoContext.php index 11d4dac63..7a5d38a39 100644 --- a/tests/Behat/Context/Ui/CreditMemoContext.php +++ b/tests/Behat/Context/Ui/CreditMemoContext.php @@ -226,7 +226,6 @@ public function itsTotalShouldBeInCurrency(string $total, string $currencyCode): public function itsNetTotalShouldBe(string $total): void { Assert::same($this->creditMemoDetailsPage->getNetTotal(), $total); - } /** @@ -235,7 +234,6 @@ public function itsNetTotalShouldBe(string $total): void public function itsTaxTotalShouldBe(string $total): void { Assert::same($this->creditMemoDetailsPage->getTaxTotal(), $total); - } /**