1 | <?php |
||
2 | |||
3 | /** |
||
4 | * MIT License |
||
5 | * Use of this software requires acceptance of the Evaluation License Agreement. See LICENSE file. |
||
6 | */ |
||
7 | |||
8 | namespace SprykerEco\Zed\Ratepay\Business\Order; |
||
9 | |||
10 | use Generated\Shared\Transfer\ItemTransfer; |
||
0 ignored issues
–
show
|
|||
11 | use Generated\Shared\Transfer\OrderTransfer; |
||
0 ignored issues
–
show
The type
Generated\Shared\Transfer\OrderTransfer was not found. Maybe you did not declare it correctly or list all dependencies?
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. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths
Loading history...
|
|||
12 | use Generated\Shared\Transfer\TotalsTransfer; |
||
0 ignored issues
–
show
The type
Generated\Shared\Transfer\TotalsTransfer was not found. Maybe you did not declare it correctly or list all dependencies?
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. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths
Loading history...
|
|||
13 | use Spryker\Zed\Sales\Persistence\SalesQueryContainerInterface; |
||
14 | use SprykerEco\Zed\Ratepay\Business\Exception\OrderTotalHydrationException; |
||
15 | use SprykerEco\Zed\Ratepay\Dependency\Facade\RatepayToCalculationInterface; |
||
16 | |||
17 | class PartialOrderCalculator implements PartialOrderCalculatorInterface |
||
18 | { |
||
19 | /** |
||
20 | * @var \SprykerEco\Zed\Ratepay\Dependency\Facade\RatepayToCalculationInterface |
||
21 | */ |
||
22 | protected $ratepayToCalculationBridge; |
||
23 | |||
24 | /** |
||
25 | * @var \Spryker\Zed\Sales\Persistence\SalesQueryContainerInterface |
||
26 | */ |
||
27 | protected $salesQueryContainer; |
||
28 | |||
29 | /** |
||
30 | * @param \SprykerEco\Zed\Ratepay\Dependency\Facade\RatepayToCalculationInterface $ratepayToCalculationBridge |
||
31 | * @param \Spryker\Zed\Sales\Persistence\SalesQueryContainerInterface $salesQueryContainer |
||
32 | */ |
||
33 | public function __construct( |
||
34 | RatepayToCalculationInterface $ratepayToCalculationBridge, |
||
35 | SalesQueryContainerInterface $salesQueryContainer |
||
36 | ) { |
||
37 | |||
38 | $this->ratepayToCalculationBridge = $ratepayToCalculationBridge; |
||
39 | $this->salesQueryContainer = $salesQueryContainer; |
||
40 | } |
||
41 | |||
42 | /** |
||
43 | * @param int $idSalesOrderItem |
||
44 | * |
||
45 | * @throws \SprykerEco\Zed\Ratepay\Business\Exception\OrderTotalHydrationException |
||
46 | * |
||
47 | * @return \Generated\Shared\Transfer\ItemTransfer|null |
||
48 | */ |
||
49 | public function getOrderItemTotalsByIdSalesOrderItem($idSalesOrderItem) |
||
50 | { |
||
51 | $salesOrderItemEntity = $this->salesQueryContainer |
||
52 | ->querySalesOrderItem() |
||
53 | ->findOneByIdSalesOrderItem($idSalesOrderItem); |
||
54 | |||
55 | if ($salesOrderItemEntity === null) { |
||
56 | throw new OrderTotalHydrationException( |
||
57 | sprintf('Order item with id "%d" not found!', $idSalesOrderItem) |
||
58 | ); |
||
59 | } |
||
60 | |||
61 | $orderTransfer = $this->createOrderTransfer($salesOrderItemEntity); |
||
62 | |||
63 | $orderTransfer = $this->ratepayToCalculationBridge->getOrderTotalByOrderTransfer($orderTransfer); |
||
64 | |||
65 | $items = $orderTransfer->getItems(); |
||
66 | return $items->count() > 0 ? $items[0] : null; |
||
67 | } |
||
68 | |||
69 | /** |
||
70 | * @param \Orm\Zed\Sales\Persistence\SpySalesOrderItem $salesOrderItemEntity |
||
0 ignored issues
–
show
The type
Orm\Zed\Sales\Persistence\SpySalesOrderItem was not found. Maybe you did not declare it correctly or list all dependencies?
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. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths
Loading history...
|
|||
71 | * |
||
72 | * @throws \SprykerEco\Zed\Ratepay\Business\Exception\OrderTotalHydrationException |
||
73 | * |
||
74 | * @return \Generated\Shared\Transfer\OrderTransfer $orderTransfer |
||
75 | */ |
||
76 | protected function createOrderTransfer($salesOrderItemEntity) |
||
77 | { |
||
78 | $salesOrderEntity = $this->salesQueryContainer |
||
79 | ->querySalesOrder() |
||
80 | ->findOneByIdSalesOrder( |
||
81 | $salesOrderItemEntity->getFkSalesOrder() |
||
82 | ); |
||
83 | |||
84 | if ($salesOrderEntity === null) { |
||
85 | throw new OrderTotalHydrationException( |
||
86 | sprintf('Order with id "%d" not found!', $salesOrderItemEntity->getFkSalesOrder()) |
||
87 | ); |
||
88 | } |
||
89 | |||
90 | $itemTransfer = $this->getHydratedSaleOrderItemTransfer($salesOrderItemEntity); |
||
91 | |||
92 | $orderTransfer = new OrderTransfer(); |
||
93 | $orderTransfer->addItem($itemTransfer); |
||
94 | $orderTransfer->setPriceMode($salesOrderEntity->getPriceMode()); |
||
95 | $orderTransfer->setTotals(new TotalsTransfer()); |
||
96 | |||
97 | return $orderTransfer; |
||
98 | } |
||
99 | |||
100 | /** |
||
101 | * @param \Orm\Zed\Sales\Persistence\SpySalesOrderItem $salesOrderItemEntity |
||
102 | * |
||
103 | * @return \Generated\Shared\Transfer\ItemTransfer |
||
104 | */ |
||
105 | protected function getHydratedSaleOrderItemTransfer($salesOrderItemEntity) |
||
106 | { |
||
107 | $itemTransfer = new ItemTransfer(); |
||
108 | $itemTransfer->fromArray($salesOrderItemEntity->toArray(), true); |
||
109 | $itemTransfer->setUnitGrossPrice($salesOrderItemEntity->getGrossPrice()); |
||
110 | |||
111 | return $itemTransfer; |
||
112 | } |
||
113 | } |
||
114 |
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