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

Trigger "partially_refund" order payment transition on each partial refund #347

Open
laurentdabbb opened this issue Feb 18, 2022 · 1 comment
Labels
Enhancement Minor issues and PRs improving the current solutions (optimizations, typo fixes, etc.).

Comments

@laurentdabbb
Copy link

Hi,

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

if ($order->getPaymentState() === OrderPaymentStates::STATE_PARTIALLY_REFUNDED) {
return;
}
$stateMachine = $this->stateMachineFactory->get($order, OrderPaymentTransitions::GRAPH);
$stateMachine->apply(OrderPaymentTransitions::TRANSITION_PARTIALLY_REFUND);

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 ;-)

@GSadee GSadee added the Enhancement Minor issues and PRs improving the current solutions (optimizations, typo fixes, etc.). label Feb 25, 2022
@GSadee
Copy link
Member

GSadee commented Feb 25, 2022

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement Minor issues and PRs improving the current solutions (optimizations, typo fixes, etc.).
Projects
None yet
Development

No branches or pull requests

2 participants