Skip to content

Commit 9380c95

Browse files
author
Anton Evers
authored
Even existing credit memos should be refundable if their state is open
Credit memos can have the state open: `\Magento\Sales\Model\Order\Creditmemo::STATE_OPEN`. This means that it is possible to have a creditmemo with an ID which still has to be refunded. I'm creating a module that introduces a validation step for refund payments before the actual refund can take place. It uses the open state of credit memos to wait for approval and then refunds the creditmemo. Right now the credit memo is not refundable once it has an ID. I think this is incorrect in case of open credit memos.
1 parent f1e6d1c commit 9380c95

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

app/code/Magento/Sales/Model/Service/CreditmemoService.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ public function refund(
195195
*/
196196
protected function validateForRefund(\Magento\Sales\Api\Data\CreditmemoInterface $creditmemo)
197197
{
198-
if ($creditmemo->getId()) {
198+
if ($creditmemo->getId() && $creditmemo->getState() !== \Magento\Sales\Model\Order\Creditmemo::STATE_OPEN) {
199199
throw new \Magento\Framework\Exception\LocalizedException(
200200
__('We cannot register an existing credit memo.')
201201
);

0 commit comments

Comments
 (0)