1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* This file is part of the Spryker Commerce OS. |
5
|
|
|
* For full license information, please view the LICENSE file that was distributed with this source code. |
6
|
|
|
*/ |
7
|
|
|
|
8
|
|
|
namespace SprykerEco\Zed\Payone\Communication\Plugin\Oms\Command; |
9
|
|
|
|
10
|
|
|
use Orm\Zed\Sales\Persistence\SpySalesOrder; |
|
|
|
|
11
|
|
|
use Spryker\Zed\Kernel\Communication\AbstractPlugin; |
12
|
|
|
use Spryker\Zed\Oms\Business\Util\ReadOnlyArrayObject; |
13
|
|
|
use Spryker\Zed\Oms\Dependency\Plugin\Command\CommandByOrderInterface; |
14
|
|
|
|
15
|
|
|
/** |
16
|
|
|
* @method \SprykerEco\Zed\Payone\Business\PayoneFacadeInterface getFacade() |
17
|
|
|
* @method \SprykerEco\Zed\Payone\Communication\PayoneCommunicationFactory getFactory() |
18
|
|
|
* @method \SprykerEco\Zed\Payone\PayoneConfig getConfig() |
19
|
|
|
*/ |
20
|
|
|
class CancelAndRecalculateCommandByOrderPlugin extends AbstractPlugin implements CommandByOrderInterface |
21
|
|
|
{ |
22
|
|
|
/** |
23
|
|
|
* {@inheritDoc} |
24
|
|
|
* - Cancels amount of all other items. |
25
|
|
|
* |
26
|
|
|
* @api |
27
|
|
|
* |
28
|
|
|
* @param \Orm\Zed\Sales\Persistence\SpySalesOrderItem[] $orderItems |
29
|
|
|
* @param \Orm\Zed\Sales\Persistence\SpySalesOrder $orderEntity |
30
|
|
|
* @param \Spryker\Zed\Oms\Business\Util\ReadOnlyArrayObject $data |
31
|
|
|
* |
32
|
|
|
* @return array |
33
|
|
|
*/ |
34
|
|
|
public function run(array $orderItems, SpySalesOrder $orderEntity, ReadOnlyArrayObject $data) |
35
|
|
|
{ |
36
|
|
|
$orderTransfer = $this->getFactory() |
37
|
|
|
->getSalesFacade() |
38
|
|
|
->getOrderByIdSalesOrder($orderEntity->getIdSalesOrder()); |
39
|
|
|
|
40
|
|
|
$orderItemIds = []; |
41
|
|
|
foreach ($orderItems as $orderItem) { |
42
|
|
|
$orderItemIds[] = $orderItem->getIdSalesOrderItem(); |
43
|
|
|
} |
44
|
|
|
|
45
|
|
|
foreach ($orderTransfer->getItems() as $itemTransfer) { |
46
|
|
|
if (in_array($itemTransfer->getIdSalesOrderItem(), $orderItemIds)) { |
47
|
|
|
$itemTransfer->setCanceledAmount($itemTransfer->getSumPriceToPayAggregation()); |
48
|
|
|
} |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
$orderTransfer = $this->getFactory()->getCalculationFacade()->recalculateOrder($orderTransfer); |
52
|
|
|
$this->getFactory()->getSalesFacade()->updateOrder($orderTransfer, $orderEntity->getIdSalesOrder()); |
53
|
|
|
|
54
|
|
|
return []; |
55
|
|
|
} |
56
|
|
|
} |
57
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths