|
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\Payone\Business\Payment\DataMapper; |
|
9
|
|
|
|
|
10
|
|
|
use Generated\Shared\Transfer\ItemTransfer; |
|
|
|
|
|
|
11
|
|
|
use Spryker\DecimalObject\Decimal; |
|
12
|
|
|
use SprykerEco\Shared\Payone\PayoneApiConstants; |
|
13
|
|
|
use SprykerEco\Zed\Payone\Business\Api\Request\Container\AbstractRequestContainer; |
|
14
|
|
|
|
|
15
|
|
|
class ProductMapper implements ProductMapperInterface |
|
16
|
|
|
{ |
|
17
|
|
|
/** |
|
18
|
|
|
* @param \Generated\Shared\Transfer\OrderTransfer|\Generated\Shared\Transfer\QuoteTransfer $itemsContainer |
|
|
|
|
|
|
19
|
|
|
* @param \SprykerEco\Zed\Payone\Business\Api\Request\Container\AbstractRequestContainer $requestContainer |
|
20
|
|
|
* |
|
21
|
|
|
* @return \SprykerEco\Zed\Payone\Business\Api\Request\Container\AbstractRequestContainer |
|
22
|
|
|
*/ |
|
23
|
|
|
public function mapProductItems($itemsContainer, AbstractRequestContainer $requestContainer): AbstractRequestContainer |
|
24
|
|
|
{ |
|
25
|
|
|
$arrayIt = []; |
|
26
|
|
|
$arrayId = []; |
|
27
|
|
|
$arrayPr = []; |
|
28
|
|
|
$arrayNo = []; |
|
29
|
|
|
$arrayDe = []; |
|
30
|
|
|
$arrayVa = []; |
|
31
|
|
|
|
|
32
|
|
|
$key = 1; |
|
33
|
|
|
|
|
34
|
|
|
foreach ($itemsContainer->getItems() as $itemTransfer) { |
|
35
|
|
|
$arrayIt[$key] = PayoneApiConstants::INVOICING_ITEM_TYPE_GOODS; |
|
36
|
|
|
$arrayId[$key] = $itemTransfer->getSku(); |
|
37
|
|
|
$arrayPr[$key] = $itemTransfer->getUnitGrossPrice(); |
|
38
|
|
|
$arrayNo[$key] = $itemTransfer->getQuantity(); |
|
39
|
|
|
$arrayDe[$key] = $itemTransfer->getName(); |
|
40
|
|
|
$arrayVa[$key] = $this->getTaxRateFromItemTransfer($itemTransfer); |
|
41
|
|
|
$key++; |
|
42
|
|
|
} |
|
43
|
|
|
|
|
44
|
|
|
$requestContainer->setIt($arrayIt); |
|
45
|
|
|
$requestContainer->setId($arrayId); |
|
46
|
|
|
$requestContainer->setPr($arrayPr); |
|
47
|
|
|
$requestContainer->setNo($arrayNo); |
|
48
|
|
|
$requestContainer->setDe($arrayDe); |
|
49
|
|
|
$requestContainer->setVa($arrayVa); |
|
50
|
|
|
|
|
51
|
|
|
return $requestContainer; |
|
52
|
|
|
} |
|
53
|
|
|
|
|
54
|
|
|
/** |
|
55
|
|
|
* @param \Generated\Shared\Transfer\ItemTransfer $itemTransfer |
|
56
|
|
|
* |
|
57
|
|
|
* @return int |
|
58
|
|
|
*/ |
|
59
|
|
|
protected function getTaxRateFromItemTransfer(ItemTransfer $itemTransfer): int |
|
60
|
|
|
{ |
|
61
|
|
|
$taxRateValue = $itemTransfer->getTaxRate(); |
|
62
|
|
|
if ($taxRateValue instanceof Decimal) { |
|
63
|
|
|
return $taxRateValue->toInt(); |
|
64
|
|
|
} |
|
65
|
|
|
|
|
66
|
|
|
return (int)$taxRateValue; |
|
67
|
|
|
} |
|
68
|
|
|
} |
|
69
|
|
|
|
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