Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unify service definitions of line items converters #271

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion UPGRADE.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,16 @@ from `provide(OrderItemUnitInterface $orderItemUnit): ?string` to `provide(Adjus

1. The `TaxRateProviderInterface $taxRateProvider` has been added as the second argument in constructor of `Sylius\RefundPlugin\Converter\ShipmentLineItemsConverter`

1. Service definition for `Sylius\RefundPlugin\Converter\ShipmentLineItemsConverter` has been changed from
`Sylius\RefundPlugin\Converter\ShipmentLineItemsConverterInterface` to `Sylius\RefundPlugin\Converter\ShipmentLineItemsConverter`

1. `Sylius\RefundPlugin\Converter\LineItemsConverter` has been changed to `Sylius\RefundPlugin\Converter\OrderItemUnitLineItemsConverter`
and its service definition has been changed from `Sylius\RefundPlugin\Converter\LineItemsConverterInterface` to `Sylius\RefundPlugin\Converter\OrderItemUnitLineItemsConverter`

1. The suffix `Exception` has been removed from classes:
* `Sylius\RefundPlugin\Exception\InvalidRefundAmountException`
* `Sylius\RefundPlugin\Exception\OrderNotAvailableForRefundingException`
* `Sylius\RefundPlugin\Exception\UnitAlreadyRefundedException`
* `Sylius\RefundPlugin\Exception\UnitAlreadyRefundedException`

### UPGRADE FROM 1.0.0-RC.5 TO 1.0.0-RC.6

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
use Sylius\RefundPlugin\Model\OrderItemUnitRefund;
use Sylius\RefundPlugin\Provider\TaxRateProviderInterface;

final class LineItemsConverterSpec extends ObjectBehavior
final class OrderItemUnitLineItemsConverterSpec extends ObjectBehavior
{
function let(RepositoryInterface $orderItemUnitRepository, TaxRateProviderInterface $taxRateProvider): void
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
use Sylius\RefundPlugin\Provider\TaxRateProviderInterface;
use Webmozart\Assert\Assert;

final class LineItemsConverter implements LineItemsConverterInterface
final class OrderItemUnitLineItemsConverter implements LineItemsConverterInterface
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One day, I would love to fix also this interface (as same definition for two different classes, which expects a different type of refunds)

{
/** @var RepositoryInterface */
private $orderItemUnitRepository;
Expand Down
4 changes: 2 additions & 2 deletions src/Converter/ShipmentLineItemsConverter.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,13 @@ public function convert(array $units): array

/** @var ShipmentRefund $shipmentRefund */
foreach ($units as $shipmentRefund) {
$lineItems[] = $this->convertUnitRefundToLineItem($shipmentRefund);
$lineItems[] = $this->convertShipmentRefundToLineItem($shipmentRefund);
}

return $lineItems;
}

private function convertUnitRefundToLineItem(ShipmentRefund $shipmentRefund): LineItemInterface
private function convertShipmentRefundToLineItem(ShipmentRefund $shipmentRefund): LineItemInterface
{
/** @var AdjustmentInterface|null $shippingAdjustment */
$shippingAdjustment = $this
Expand Down
4 changes: 2 additions & 2 deletions src/Resources/config/services/converter.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
<services>
<defaults autowire="false" autoconfigure="false" public="true" />

<service id="Sylius\RefundPlugin\Converter\LineItemsConverterInterface" class="Sylius\RefundPlugin\Converter\LineItemsConverter">
<service id="Sylius\RefundPlugin\Converter\OrderItemUnitLineItemsConverter">
<argument type="service" id="sylius.repository.order_item_unit" />
<argument type="service" id="Sylius\RefundPlugin\Provider\TaxRateProviderInterface" />
</service>

<service id="Sylius\RefundPlugin\Converter\ShipmentLineItemsConverterInterface" class="Sylius\RefundPlugin\Converter\ShipmentLineItemsConverter">
<service id="Sylius\RefundPlugin\Converter\ShipmentLineItemsConverter">
<argument type="service" id="sylius.repository.adjustment" />
<argument type="service" id="Sylius\RefundPlugin\Provider\TaxRateProviderInterface" />
</service>
Expand Down
4 changes: 2 additions & 2 deletions src/Resources/config/services/generator.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
</service>

<service id="Sylius\RefundPlugin\Generator\CreditMemoGenerator">
<argument type="service" id="Sylius\RefundPlugin\Converter\LineItemsConverterInterface" />
<argument type="service" id="Sylius\RefundPlugin\Converter\ShipmentLineItemsConverterInterface" />
<argument type="service" id="Sylius\RefundPlugin\Converter\OrderItemUnitLineItemsConverter" />
<argument type="service" id="Sylius\RefundPlugin\Converter\ShipmentLineItemsConverter" />
<argument type="service" id="Sylius\RefundPlugin\Generator\TaxItemsGeneratorInterface" />
<argument type="service" id="Sylius\RefundPlugin\Generator\SequentialNumberGenerator" />
<argument type="service" id="Sylius\RefundPlugin\Provider\CurrentDateTimeImmutableProviderInterface" />
Expand Down