Skip to content

Commit e7f31b9

Browse files
committed
MAGETWO-55657: Implement new service OrderInvoice
- add interfaces for exceptions and change their location
1 parent 5236b37 commit e7f31b9

File tree

7 files changed

+55
-28
lines changed

7 files changed

+55
-28
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
* @api
1414
*/
1515
interface InvoiceCommentInterface extends \Magento\Framework\Api\ExtensibleDataInterface,
16-
\Magento\Sales\Api\Data\InvoiceCommentCreationInterface
16+
\Magento\Sales\Api\Data\InvoiceCommentCreationInterface
1717
{
1818
/**#@+
1919
* Constants for keys of data array. Identical to the name of the getter in snake case.

app/code/Magento/Sales/Api/DocumentValidationException.php

Lines changed: 0 additions & 17 deletions
This file was deleted.
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
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 CouldNotInvoiceExceptionInterface
12+
{
13+
14+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
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 DocumentValidationExceptionInterface
12+
{
13+
14+
}

app/code/Magento/Sales/Api/CouldNotInvoiceException.php renamed to app/code/Magento/Sales/Exception/CouldNotInvoiceException.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@
33
* Copyright © 2016 Magento. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
6-
namespace Magento\Sales\Api;
6+
namespace Magento\Sales\Exception;
77

88
use Magento\Framework\Exception\LocalizedException;
9+
use Magento\Sales\Api\Exception\CouldNotInvoiceExceptionInterface;
910

1011
/**
1112
* Class CouldNotInvoiceException
12-
* @api
1313
*/
14-
class CouldNotInvoiceException extends LocalizedException
14+
class CouldNotInvoiceException extends LocalizedException implements CouldNotInvoiceExceptionInterface
1515
{
1616

1717
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
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\DocumentValidationExceptionInterface;
10+
11+
/**
12+
* Class DocumentValidationException
13+
*/
14+
class DocumentValidationException extends LocalizedException implements DocumentValidationExceptionInterface
15+
{
16+
17+
}

app/code/Magento/Sales/Model/OrderInvoice.php

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,7 @@
1717
use Magento\Sales\Model\Order\PaymentAdapterInterface;
1818
use Magento\Sales\Model\Order\OrderStateResolverInterface;
1919
use Magento\Sales\Model\Order\Config as OrderConfig;
20-
use Magento\Sales\Api\Data\InvoiceInterface;
2120
use Magento\Sales\Model\Order\InvoiceRepository;
22-
use Magento\Sales\Api\DocumentValidationException;
23-
use Magento\Sales\Api\CouldNotInvoiceException;
2421
use Psr\Log\LoggerInterface;
2522

2623
/**
@@ -126,8 +123,8 @@ public function __construct(
126123
* @param \Magento\Sales\Api\Data\InvoiceCommentCreationInterface|null $comment
127124
* @param \Magento\Sales\Api\Data\InvoiceCreationArgumentsInterface|null $arguments
128125
* @return int
129-
* @throws DocumentValidationException
130-
* @throws CouldNotInvoiceException
126+
* @throws \Magento\Sales\Api\Exception\DocumentValidationExceptionInterface
127+
* @throws \Magento\Sales\Api\Exception\CouldNotInvoiceExceptionInterface
131128
* @throws \Magento\Framework\Exception\InputException
132129
* @throws \Magento\Framework\Exception\NoSuchEntityException
133130
* @throws \DomainException
@@ -152,7 +149,7 @@ public function execute(
152149
);
153150
$errorMessages = $this->invoiceValidator->validate($invoice, $order);
154151
if (!empty($errorMessages)) {
155-
throw new DocumentValidationException(
152+
throw new \Magento\Sales\Exception\DocumentValidationException(
156153
__("Invoice Document Validation Error(s):\n" . implode("\n", $errorMessages))
157154
);
158155
}
@@ -170,7 +167,9 @@ public function execute(
170167
} catch (\Exception $e) {
171168
$this->logger->critical($e);
172169
$connection->rollBack();
173-
throw new CouldNotInvoiceException(__('Could not save an invoice, see error log for details'));
170+
throw new \Magento\Sales\Exception\CouldNotInvoiceException(
171+
__('Could not save an invoice, see error log for details')
172+
);
174173
}
175174
if ($notify) {
176175
if (!$appendComment) {

0 commit comments

Comments
 (0)