Skip to content

Commit 9478003

Browse files
author
Oleksii Korshenko
committed
Merge remote-tracking branch 'mainline/develop' into MAGETWO-57569
2 parents ffd683c + 9d0c8f9 commit 9478003

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+4645
-17
lines changed

app/code/Magento/Sales/Api/Data/CommentInterface.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,29 +23,29 @@ interface CommentInterface
2323
const COMMENT = 'comment';
2424

2525
/**
26-
* Gets the comment for the invoice.
26+
* Gets the comment text.
2727
*
2828
* @return string Comment.
2929
*/
3030
public function getComment();
3131

3232
/**
33-
* Sets the comment for the invoice.
33+
* Sets the comment text.
3434
*
3535
* @param string $comment
3636
* @return $this
3737
*/
3838
public function setComment($comment);
3939

4040
/**
41-
* Gets the is-visible-on-storefront flag value for the invoice.
41+
* Gets the is-visible-on-storefront flag value for the comment.
4242
*
4343
* @return int Is-visible-on-storefront flag value.
4444
*/
4545
public function getIsVisibleOnFront();
4646

4747
/**
48-
* Sets the is-visible-on-storefront flag value for the invoice.
48+
* Sets the is-visible-on-storefront flag value for the comment.
4949
*
5050
* @param int $isVisibleOnFront
5151
* @return $this
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?php
2+
/**
3+
* Copyright © 2016 Magento. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\Sales\Api\Data;
7+
8+
use Magento\Framework\Api\ExtensibleDataInterface;
9+
10+
/**
11+
* Interface CreditmemoCommentCreationInterface
12+
*
13+
* @api
14+
*/
15+
interface CreditmemoCommentCreationInterface extends ExtensibleDataInterface, CommentInterface
16+
{
17+
/**
18+
* Retrieve existing extension attributes object or create a new one.
19+
*
20+
* @return \Magento\Sales\Api\Data\CreditmemoCommentCreationExtensionInterface|null
21+
*/
22+
public function getExtensionAttributes();
23+
24+
/**
25+
* Set an extension attributes object.
26+
*
27+
* @param \Magento\Sales\Api\Data\CreditmemoCommentCreationExtensionInterface $extensionAttributes
28+
* @return $this
29+
*/
30+
public function setExtensionAttributes(
31+
\Magento\Sales\Api\Data\CreditmemoCommentCreationExtensionInterface $extensionAttributes
32+
);
33+
}
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
<?php
2+
/**
3+
* Copyright © 2016 Magento. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\Sales\Api\Data;
7+
8+
/**
9+
* Interface CreditmemoCreationArgumentsInterface
10+
*
11+
* @api
12+
*/
13+
interface CreditmemoCreationArgumentsInterface
14+
{
15+
/**
16+
* Gets the credit memo shipping amount.
17+
*
18+
* @return float|null Credit memo shipping amount.
19+
*/
20+
public function getShippingAmount();
21+
22+
/**
23+
* Gets the credit memo positive adjustment.
24+
*
25+
* @return float|null Credit memo positive adjustment.
26+
*/
27+
public function getAdjustmentPositive();
28+
29+
/**
30+
* Gets the credit memo negative adjustment.
31+
*
32+
* @return float|null Credit memo negative adjustment.
33+
*/
34+
public function getAdjustmentNegative();
35+
36+
/**
37+
* Sets the credit memo shipping amount.
38+
*
39+
* @param float $amount
40+
* @return $this
41+
*/
42+
public function setShippingAmount($amount);
43+
44+
/**
45+
* Sets the credit memo positive adjustment.
46+
*
47+
* @param float $amount
48+
* @return $this
49+
*/
50+
public function setAdjustmentPositive($amount);
51+
52+
/**
53+
* Sets the credit memo negative adjustment.
54+
*
55+
* @param float $amount
56+
* @return $this
57+
*/
58+
public function setAdjustmentNegative($amount);
59+
60+
/**
61+
* Gets existing extension attributes.
62+
*
63+
* @return \Magento\Sales\Api\Data\CreditmemoCreationArgumentsExtensionInterface|null
64+
*/
65+
public function getExtensionAttributes();
66+
67+
/**
68+
* Sets extension attributes.
69+
*
70+
* @param \Magento\Sales\Api\Data\CreditmemoCreationArgumentsExtensionInterface $extensionAttributes
71+
*
72+
* @return $this
73+
*/
74+
public function setExtensionAttributes(
75+
\Magento\Sales\Api\Data\CreditmemoCreationArgumentsExtensionInterface $extensionAttributes
76+
);
77+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?php
2+
/**
3+
* Copyright © 2016 Magento. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\Sales\Api\Data;
7+
8+
use Magento\Framework\Api\ExtensibleDataInterface;
9+
10+
/**
11+
* Interface CreditmemoItemCreationInterface
12+
* @api
13+
*/
14+
interface CreditmemoItemCreationInterface extends LineItemInterface, ExtensibleDataInterface
15+
{
16+
/**
17+
* Retrieve existing extension attributes object or create a new one.
18+
*
19+
* @return \Magento\Sales\Api\Data\CreditmemoItemCreationExtensionInterface|null
20+
*/
21+
public function getExtensionAttributes();
22+
23+
/**
24+
* Set an extension attributes object.
25+
*
26+
* @param \Magento\Sales\Api\Data\CreditmemoItemCreationExtensionInterface $extensionAttributes
27+
* @return $this
28+
*/
29+
public function setExtensionAttributes(
30+
\Magento\Sales\Api\Data\CreditmemoItemCreationExtensionInterface $extensionAttributes
31+
);
32+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?php
2+
/**
3+
* Copyright © 2016 Magento. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\Sales\Api\Exception;
7+
8+
/**
9+
* @api
10+
*/
11+
interface CouldNotRefundExceptionInterface
12+
{
13+
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<?php
2+
/**
3+
* Copyright © 2016 Magento. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\Sales\Api;
7+
8+
/**
9+
* Interface RefundInvoiceInterface
10+
*
11+
* @api
12+
*/
13+
interface RefundInvoiceInterface
14+
{
15+
/**
16+
* Create refund for invoice
17+
*
18+
* @param int $invoiceId
19+
* @param \Magento\Sales\Api\Data\CreditmemoItemCreationInterface[] $items
20+
* @param bool|null $isOnline
21+
* @param bool|null $notify
22+
* @param bool|null $appendComment
23+
* @param \Magento\Sales\Api\Data\CreditmemoCommentCreationInterface|null $comment
24+
* @param \Magento\Sales\Api\Data\CreditmemoCreationArgumentsInterface|null $arguments
25+
* @return int
26+
*/
27+
public function execute(
28+
$invoiceId,
29+
array $items = [],
30+
$isOnline = false,
31+
$notify = false,
32+
$appendComment = false,
33+
\Magento\Sales\Api\Data\CreditmemoCommentCreationInterface $comment = null,
34+
\Magento\Sales\Api\Data\CreditmemoCreationArgumentsInterface $arguments = null
35+
);
36+
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<?php
2+
/**
3+
* Copyright © 2016 Magento. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\Sales\Api;
7+
8+
/**
9+
* Interface RefundOrderInterface
10+
*
11+
* @api
12+
*/
13+
interface RefundOrderInterface
14+
{
15+
/**
16+
* Create offline refund for order
17+
*
18+
* @param int $orderId
19+
* @param \Magento\Sales\Api\Data\CreditmemoItemCreationInterface[] $items
20+
* @param bool|null $notify
21+
* @param bool|null $appendComment
22+
* @param \Magento\Sales\Api\Data\CreditmemoCommentCreationInterface|null $comment
23+
* @param \Magento\Sales\Api\Data\CreditmemoCreationArgumentsInterface|null $arguments
24+
* @return int
25+
*/
26+
public function execute(
27+
$orderId,
28+
array $items = [],
29+
$notify = false,
30+
$appendComment = false,
31+
\Magento\Sales\Api\Data\CreditmemoCommentCreationInterface $comment = null,
32+
\Magento\Sales\Api\Data\CreditmemoCreationArgumentsInterface $arguments = null
33+
);
34+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?php
2+
/**
3+
* Copyright © 2016 Magento. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\Sales\Exception;
7+
8+
use Magento\Framework\Exception\LocalizedException;
9+
use Magento\Sales\Api\Exception\CouldNotRefundExceptionInterface;
10+
11+
/**
12+
* Class CouldNotRefundException
13+
*/
14+
class CouldNotRefundException extends LocalizedException implements CouldNotRefundExceptionInterface
15+
{
16+
}

app/code/Magento/Sales/Model/Order/Creditmemo.php

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -532,11 +532,24 @@ public function setAdjustmentNegative($amount)
532532
*/
533533
public function isLast()
534534
{
535-
foreach ($this->getAllItems() as $item) {
535+
$items = $this->getAllItems();
536+
foreach ($items as $item) {
536537
if (!$item->isLast()) {
537538
return false;
538539
}
539540
}
541+
542+
if (empty($items)) {
543+
$order = $this->getOrder();
544+
if ($order) {
545+
foreach ($order->getItems() as $orderItem) {
546+
if ($orderItem->canRefund()) {
547+
return false;
548+
}
549+
}
550+
}
551+
}
552+
540553
return true;
541554
}
542555

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
<?php
2+
/**
3+
* Copyright © 2016 Magento. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\Sales\Model\Order\Creditmemo;
7+
8+
use Magento\Sales\Api\Data\CreditmemoCommentCreationInterface;
9+
10+
/**
11+
* Class CommentCreation
12+
*/
13+
class CommentCreation implements CreditmemoCommentCreationInterface
14+
{
15+
/**
16+
* @var \Magento\Sales\Api\Data\CreditmemoCommentCreationExtensionInterface
17+
*/
18+
private $extensionAttributes;
19+
20+
/**
21+
* @var string
22+
*/
23+
private $comment;
24+
25+
/**
26+
* @var int
27+
*/
28+
private $isVisibleOnFront;
29+
30+
/**
31+
* Retrieve existing extension attributes object or create a new one.
32+
*
33+
* @return \Magento\Sales\Api\Data\CreditmemoCommentCreationExtensionInterface|null
34+
*/
35+
public function getExtensionAttributes()
36+
{
37+
return $this->extensionAttributes;
38+
}
39+
40+
/**
41+
* Set an extension attributes object.
42+
*
43+
* @param \Magento\Sales\Api\Data\CreditmemoCommentCreationExtensionInterface $extensionAttributes
44+
* @return $this
45+
*/
46+
public function setExtensionAttributes(
47+
\Magento\Sales\Api\Data\CreditmemoCommentCreationExtensionInterface $extensionAttributes
48+
) {
49+
$this->extensionAttributes = $extensionAttributes;
50+
return $this;
51+
}
52+
53+
/**
54+
* @inheritdoc
55+
*/
56+
public function getComment()
57+
{
58+
return $this->comment;
59+
}
60+
61+
/**
62+
* @inheritdoc
63+
*/
64+
public function setComment($comment)
65+
{
66+
$this->comment = $comment;
67+
return $this;
68+
}
69+
70+
/**
71+
* @inheritdoc
72+
*/
73+
public function getIsVisibleOnFront()
74+
{
75+
return $this->isVisibleOnFront;
76+
}
77+
78+
/**
79+
* @inheritdoc
80+
*/
81+
public function setIsVisibleOnFront($isVisibleOnFront)
82+
{
83+
$this->isVisibleOnFront = $isVisibleOnFront;
84+
return $this;
85+
}
86+
}

0 commit comments

Comments
 (0)