RefundPlugin icon indicating copy to clipboard operation
RefundPlugin copied to clipboard

Trigger "partially_refund" order payment transition on each partial refund

Open laurentdabbb opened this issue 3 years ago • 1 comments

Hi,

According to code lines below, "partially_refund" transition is not triggered on order payment state if that state is already on "partially_refund".

https://github.com/Sylius/RefundPlugin/blob/518ba6ed962973e02a4c19964866a21e442516f9/src/StateResolver/OrderPartiallyRefundedStateResolver.php#L50-L56

I think it's a mistake. sylius_order_payment state machine allow transition from "partially_refund" to "partially_refund". So why not playing transition on a new partial refund ?

Rather than checking current order payment state, you should use if( $stateMachine->can( OrderPaymentTransitions::TRANSITION_PARTIALLY_REFUND ) ) before applying.

What do you think about ?

Thanks a lot ;-)

laurentdabbb avatar Feb 18 '22 11:02 laurentdabbb

Hi @laurentdabbb, thank you for reporting the issue. If I see correctly, you may be right and in fact nothing stands in the way of triggering this transition, even if it does not change anything, because as a result we will be in the same state and there are no callbacks defined to it. Would you like to open a PR with such a change?

GSadee avatar Feb 25 '22 06:02 GSadee