|
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\Invoice; |
|
13
|
|
|
|
|
14
|
|
|
use Riesenia\Pohoda\Common; |
|
15
|
|
|
use Riesenia\Pohoda\Document\AbstractItem; |
|
16
|
|
|
use Riesenia\Pohoda\Type\RecyclingContrib; |
|
17
|
|
|
|
|
18
|
|
|
class Item extends AbstractItem |
|
19
|
|
|
{ |
|
20
|
|
|
/** @var string[] */ |
|
21
|
|
|
protected array $refElements = ['typeServiceMOSS', 'accounting', 'classificationVAT', 'classificationKVDPH', 'centre', 'activity', 'contract']; |
|
22
|
|
|
|
|
23
|
|
|
/** @var string[] */ |
|
24
|
|
|
protected array $elements = ['text', 'quantity', 'unit', 'coefficient', 'payVAT', 'rateVAT', 'percentVAT', 'discountPercentage', 'homeCurrency', 'foreignCurrency', 'typeServiceMOSS', 'note', 'code', 'guarantee', 'guaranteeType', 'stockItem', 'accounting', 'classificationVAT', 'classificationKVDPH', 'centre', 'activity', 'contract', 'expirationDate', 'PDP', 'recyclingContrib']; |
|
25
|
|
|
|
|
26
|
|
|
/** |
|
27
|
|
|
* @inheritdoc |
|
28
|
|
|
*/ |
|
29
|
3 |
|
public function setData(array $data): parent |
|
30
|
|
|
{ |
|
31
|
3 |
|
if (isset($data['recyclingContrib'])) { |
|
32
|
1 |
|
$recyclingContrib = new RecyclingContrib($this->namespacesPaths, $this->sanitizeEncoding, $this->companyRegistrationNumber, $this->resolveOptions, $this->normalizerFactory); |
|
33
|
1 |
|
$data['recyclingContrib'] = $recyclingContrib->setDirectionalVariable($this->useOneDirectionalVariables)->setData($data['recyclingContrib']); |
|
34
|
|
|
} |
|
35
|
|
|
|
|
36
|
3 |
|
return parent::setData($data); |
|
37
|
|
|
} |
|
38
|
|
|
|
|
39
|
|
|
/** |
|
40
|
|
|
* {@inheritdoc} |
|
41
|
|
|
*/ |
|
42
|
1 |
|
protected function configureOptions(Common\OptionsResolver $resolver): void |
|
43
|
|
|
{ |
|
44
|
1 |
|
parent::configureOptions($resolver); |
|
45
|
|
|
|
|
46
|
|
|
// validate / format options |
|
47
|
1 |
|
$resolver->setNormalizer('text', $this->normalizerFactory->getClosure('string90')); |
|
48
|
1 |
|
$resolver->setNormalizer('quantity', $this->normalizerFactory->getClosure('float')); |
|
49
|
1 |
|
$resolver->setNormalizer('unit', $this->normalizerFactory->getClosure('string10')); |
|
50
|
1 |
|
$resolver->setNormalizer('coefficient', $this->normalizerFactory->getClosure('float')); |
|
51
|
1 |
|
$resolver->setNormalizer('payVAT', $this->normalizerFactory->getClosure('bool')); |
|
52
|
1 |
|
$resolver->setAllowedValues('rateVAT', ['none', 'high', 'low', 'third', 'historyHigh', 'historyLow', 'historyThird']); |
|
53
|
1 |
|
$resolver->setNormalizer('percentVAT', $this->normalizerFactory->getClosure('float')); |
|
54
|
1 |
|
$resolver->setNormalizer('discountPercentage', $this->normalizerFactory->getClosure('float')); |
|
55
|
1 |
|
$resolver->setNormalizer('note', $this->normalizerFactory->getClosure('string90')); |
|
56
|
1 |
|
$resolver->setNormalizer('code', $this->normalizerFactory->getClosure('string64')); |
|
57
|
1 |
|
$resolver->setNormalizer('guarantee', $this->normalizerFactory->getClosure('int')); |
|
58
|
1 |
|
$resolver->setAllowedValues('guaranteeType', ['none', 'hour', 'day', 'month', 'year', 'life']); |
|
59
|
1 |
|
$resolver->setNormalizer('expirationDate', $this->normalizerFactory->getClosure('date')); |
|
60
|
1 |
|
$resolver->setNormalizer('PDP', $this->normalizerFactory->getClosure('bool')); |
|
61
|
|
|
} |
|
62
|
|
|
} |
|
63
|
|
|
|