Skip to content

[Bug] Provider\RemainingTotalProvider meant to work by ShipmentRefund, but in practice works by shipment Adjustment #286

@diimpp

Description

@diimpp

Provider\RemainingTotalProvider is used to get available amount for refund for both OrderItemUnitRefund and ShipmentRefund.

That's the theory, in practice Validator\RefundAmountValidator expects to be working with Model\ShipmentRefund, which is correct, but order refund page _shipping.html.twig works with shipping Adjustments which is incorrect and source codes of Provider\RemainingTotalProvider were hacked for UI benefit.

    $shippingAdjustment = $this->adjustmentRepository->findOneBy([
            'id' => $id,
            'type' => AdjustmentInterface::SHIPPING_ADJUSTMENT,
        ]);
        Assert::notNull($shippingAdjustment);

So problem is public function getTotalLeftToRefund(int $id, RefundType $type): int expects one kind of $id and gets totally another and underling code was hacked to support adjustments usage.

Maybe this was conscious decision due to shipment and adjustments not being related in prior 1.9, but it should have been handled explicitly in such case.

Solution is to refactor UI to work with shipments directly.

Personally I've encountered this at non-standard use-case, while loading historical data in DB, so there might be no active bugs with standard usage.

Metadata

Metadata

Assignees

No one assigned

    Labels

    DXIssues and PRs aimed at improving Developer eXperience.EnhancementMinor issues and PRs improving the current solutions (optimizations, typo fixes, etc.).

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions