-
-
Notifications
You must be signed in to change notification settings - Fork 72
Description
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.