Skip to content

Commit 26d89f4

Browse files
committed
Revert "Show converted value for validateForRefund error message"
This reverts commit 5b834a5.
1 parent 5b834a5 commit 26d89f4

File tree

2 files changed

+3
-57
lines changed

2 files changed

+3
-57
lines changed

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -196,13 +196,13 @@ protected function validateForRefund(\Magento\Sales\Api\Data\CreditmemoInterface
196196
$creditmemo->getOrder()->getBaseTotalRefunded() + $creditmemo->getBaseGrandTotal()
197197
);
198198
if ($baseOrderRefund > $this->priceCurrency->round($creditmemo->getOrder()->getBaseTotalPaid())) {
199-
$availableRefund = $creditmemo->getOrder()->getTotalPaid()
200-
- $creditmemo->getOrder()->getTotalRefunded();
199+
$baseAvailableRefund = $creditmemo->getOrder()->getBaseTotalPaid()
200+
- $creditmemo->getOrder()->getBaseTotalRefunded();
201201

202202
throw new \Magento\Framework\Exception\LocalizedException(
203203
__(
204204
'The most money available to refund is %1.',
205-
$creditmemo->getOrder()->formatPriceTxt($availableRefund)
205+
$creditmemo->getOrder()->formatPriceTxt($baseAvailableRefund)
206206
)
207207
);
208208
}

app/code/Magento/Sales/Test/Unit/Model/Service/CreditmemoServiceTest.php

Lines changed: 0 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -343,74 +343,20 @@ public function testRefundExpectsMoneyAvailableToReturn()
343343
->willReturn($order);
344344
$creditMemo->method('getBaseGrandTotal')
345345
->willReturn($baseGrandTotal);
346-
$creditMemo->method('getGrandTotal')
347-
->willReturn($baseGrandTotal);
348346
$order->method('getBaseTotalRefunded')
349347
->willReturn($baseTotalRefunded);
350-
$order->method('getTotalRefunded')
351-
->willReturn($baseTotalRefunded);
352348
$this->priceCurrency->method('round')
353349
->withConsecutive([$baseTotalRefunded + $baseGrandTotal], [$baseTotalPaid])
354350
->willReturnOnConsecutiveCalls($baseTotalRefunded + $baseGrandTotal, $baseTotalPaid);
355351
$order->method('getBaseTotalPaid')
356352
->willReturn($baseTotalPaid);
357-
$order->method('getTotalPaid')
358-
->willReturn($baseTotalPaid);
359353
$baseAvailableRefund = $baseTotalPaid - $baseTotalRefunded;
360354
$order->method('formatPriceTxt')
361355
->with($baseAvailableRefund)
362356
->willReturn($baseAvailableRefund);
363357
$this->creditmemoService->refund($creditMemo, true);
364358
}
365359

366-
/**
367-
* @expectedExceptionMessage The most money available to refund is €0.88.
368-
* @expectedException \Magento\Framework\Exception\LocalizedException
369-
*/
370-
public function testMultiCurrencyRefundExpectsMoneyAvailableToReturn()
371-
{
372-
$baseGrandTotal = 10.00;
373-
$baseTotalRefunded = 9.00;
374-
$baseTotalPaid = 10;
375-
376-
$grandTotal = 8.81;
377-
$totalRefunded = 7.929;
378-
$totalPaid = 8.81;
379-
380-
/** @var CreditmemoInterface|MockObject $creditMemo */
381-
$creditMemo = $this->getMockBuilder(CreditmemoInterface::class)
382-
->setMethods(['getId', 'getOrder'])
383-
->getMockForAbstractClass();
384-
$creditMemo->method('getId')
385-
->willReturn(null);
386-
/** @var Order|MockObject $order */
387-
$order = $this->getMockBuilder(Order::class)
388-
->disableOriginalConstructor()
389-
->getMock();
390-
$creditMemo->method('getOrder')
391-
->willReturn($order);
392-
$creditMemo->method('getBaseGrandTotal')
393-
->willReturn($baseGrandTotal);
394-
$creditMemo->method('getGrandTotal')
395-
->willReturn($grandTotal);
396-
$order->method('getBaseTotalRefunded')
397-
->willReturn($baseTotalRefunded);
398-
$order->method('getTotalRefunded')
399-
->willReturn($totalRefunded);
400-
$this->priceCurrency->method('round')
401-
->withConsecutive([$baseTotalRefunded + $baseGrandTotal], [$baseTotalPaid])
402-
->willReturnOnConsecutiveCalls($baseTotalRefunded + $baseGrandTotal, $baseTotalPaid);
403-
$order->method('getBaseTotalPaid')
404-
->willReturn($baseTotalPaid);
405-
$order->method('getTotalPaid')
406-
->willReturn($totalPaid);
407-
$availableRefund = $totalPaid - $totalRefunded;
408-
$order->method('formatPriceTxt')
409-
->with($availableRefund)
410-
->willReturn(sprintf('€%.2f', $availableRefund));
411-
$this->creditmemoService->refund($creditMemo, true);
412-
}
413-
414360
/**
415361
* @expectedExceptionMessage We cannot register an existing credit memo.
416362
* @expectedException \Magento\Framework\Exception\LocalizedException

0 commit comments

Comments
 (0)