Skip to content

MAGETWO-11669: API salesRefundInvoiceV1 does no save invoice ID on credit memo #11687

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

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions app/code/Magento/Sales/Model/RefundInvoice.php
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ public function execute(
$invoice->getBaseTotalRefunded() + $creditmemo->getBaseGrandTotal()
);
}
$creditmemo->setInvoiceId($invoice->getId());
$this->invoiceRepository->save($invoice);
$order = $this->orderRepository->save($order);
$creditmemo = $this->creditmemoRepository->save($creditmemo);
Expand Down
6 changes: 5 additions & 1 deletion app/code/Magento/Sales/Test/Unit/Model/RefundInvoiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ class RefundInvoiceTest extends \PHPUnit\Framework\TestCase
private $orderMock;

/**
* @var OrderInterface|\PHPUnit_Framework_MockObject_MockObject
* @var InvoiceInterface|\PHPUnit_Framework_MockObject_MockObject
*/
private $invoiceMock;

Expand Down Expand Up @@ -186,6 +186,7 @@ protected function setUp()
->getMockForAbstractClass();

$this->invoiceMock = $this->getMockBuilder(InvoiceInterface::class)
->setMethods(['getId'])
->disableOriginalConstructor()
->getMockForAbstractClass();

Expand Down Expand Up @@ -239,6 +240,9 @@ public function testOrderCreditmemo($invoiceId, $isOnline, $items, $notify, $app
$this->invoiceRepositoryMock->expects($this->once())
->method('get')
->willReturn($this->invoiceMock);
$this->invoiceMock->expects($this->once())
->method('getId')
->willReturn($invoiceId);
$this->orderRepositoryMock->expects($this->once())
->method('get')
->willReturn($this->orderMock);
Expand Down