1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* This file is part of riesenia/pohoda package. |
5
|
|
|
* |
6
|
|
|
* Licensed under the MIT License |
7
|
|
|
* (c) RIESENIA.com |
8
|
|
|
*/ |
9
|
|
|
|
10
|
|
|
declare(strict_types=1); |
11
|
|
|
|
12
|
|
|
namespace Riesenia\Pohoda\StockTransfer; |
13
|
|
|
|
14
|
|
|
use Riesenia\Pohoda\AbstractAgenda; |
15
|
|
|
use Riesenia\Pohoda\Common; |
16
|
|
|
use Riesenia\Pohoda\Type\StockItem; |
17
|
|
|
|
18
|
|
|
class Item extends AbstractAgenda |
19
|
|
|
{ |
20
|
|
|
/** @var string[] */ |
21
|
|
|
protected array $elements = ['quantity', 'stockItem', 'note']; |
22
|
|
|
|
23
|
|
|
/** |
24
|
|
|
* {@inheritdoc} |
25
|
|
|
*/ |
26
|
1 |
|
public function setData(array $data): parent |
27
|
|
|
{ |
28
|
|
|
// process stock item |
29
|
1 |
|
if (isset($data['stockItem'])) { |
30
|
1 |
|
$stockItem = new StockItem($this->namespacesPaths, $this->sanitizeEncoding, $this->companyRegistrationNumber, $this->resolveOptions, $this->normalizerFactory); |
31
|
1 |
|
$data['stockItem'] = $stockItem->setDirectionalVariable($this->useOneDirectionalVariables)->setData($data['stockItem']); |
32
|
|
|
} |
33
|
|
|
|
34
|
1 |
|
return parent::setData($data); |
|
|
|
|
35
|
|
|
} |
36
|
|
|
|
37
|
|
|
/** |
38
|
|
|
* {@inheritdoc} |
39
|
|
|
*/ |
40
|
1 |
|
public function getXML(): \SimpleXMLElement |
41
|
|
|
{ |
42
|
1 |
|
$xml = $this->createXML()->addChild('pre:prevodkaItem', '', $this->namespace('pre')); |
43
|
|
|
|
44
|
1 |
|
$this->addElements($xml, $this->elements, 'pre'); |
45
|
|
|
|
46
|
1 |
|
return $xml; |
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
/** |
50
|
|
|
* {@inheritdoc} |
51
|
|
|
*/ |
52
|
1 |
|
protected function configureOptions(Common\OptionsResolver $resolver): void |
53
|
|
|
{ |
54
|
|
|
// available options |
55
|
1 |
|
$resolver->setDefined($this->elements); |
56
|
|
|
|
57
|
|
|
// validate / format options |
58
|
1 |
|
$resolver->setNormalizer('quantity', $this->normalizerFactory->getClosure('float')); |
59
|
1 |
|
$resolver->setNormalizer('note', $this->normalizerFactory->getClosure('string90')); |
60
|
|
|
} |
61
|
|
|
} |
62
|
|
|
|