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; |
13
|
|
|
|
14
|
|
|
use Riesenia\Pohoda\Invoice\AdvancePaymentItem; |
15
|
|
|
use Riesenia\Pohoda\Type\Link; |
16
|
|
|
|
17
|
|
|
class Invoice extends AbstractDocument |
18
|
|
|
{ |
19
|
8 |
|
public function getImportRoot(): string |
20
|
|
|
{ |
21
|
8 |
|
return 'lst:invoice'; |
22
|
|
|
} |
23
|
|
|
|
24
|
|
|
/** |
25
|
|
|
* Add link. |
26
|
|
|
* |
27
|
|
|
* @param array<string,mixed> $data |
28
|
|
|
* |
29
|
|
|
* @return $this |
30
|
|
|
*/ |
31
|
1 |
|
public function addLink(array $data): self |
32
|
|
|
{ |
33
|
1 |
|
if (!isset($this->data['links']) |
34
|
1 |
|
|| !( |
35
|
1 |
|
is_array($this->data['links']) |
36
|
1 |
|
|| (is_object($this->data['links']) && is_a($this->data['links'], \ArrayAccess::class)) |
37
|
1 |
|
) |
38
|
|
|
) { |
39
|
1 |
|
$this->data['links'] = []; |
40
|
|
|
} |
41
|
|
|
|
42
|
1 |
|
$link = new Link($this->namespacesPaths, $this->sanitizeEncoding, $this->companyRegistrationNumber, $this->resolveOptions, $this->normalizerFactory); |
43
|
1 |
|
$this->data['links'][] = $link->setDirectionalVariable($this->useOneDirectionalVariables)->setData($data); |
44
|
|
|
|
45
|
1 |
|
return $this; |
46
|
|
|
} |
47
|
|
|
|
48
|
|
|
/** |
49
|
|
|
* Add advance payment item. |
50
|
|
|
* |
51
|
|
|
* @param array<string,mixed> $data |
52
|
|
|
* |
53
|
|
|
* @return $this |
54
|
|
|
*/ |
55
|
1 |
|
public function addAdvancePaymentItem(array $data): self |
56
|
|
|
{ |
57
|
1 |
|
if (!isset($this->data['invoiceDetail']) |
58
|
1 |
|
|| !( |
59
|
1 |
|
is_array($this->data['invoiceDetail']) |
60
|
1 |
|
|| (is_object($this->data['invoiceDetail']) && is_a($this->data['invoiceDetail'], \ArrayAccess::class)) |
61
|
1 |
|
) |
62
|
|
|
) { |
63
|
1 |
|
$this->data['invoiceDetail'] = []; |
64
|
|
|
} |
65
|
|
|
|
66
|
1 |
|
$invoiceDetail = new AdvancePaymentItem($this->namespacesPaths, $this->sanitizeEncoding, $this->companyRegistrationNumber, $this->resolveOptions, $this->normalizerFactory); |
67
|
1 |
|
$this->data['invoiceDetail'][] = $invoiceDetail->setDirectionalVariable($this->useOneDirectionalVariables)->setData($data); |
68
|
|
|
|
69
|
1 |
|
return $this; |
70
|
|
|
} |
71
|
|
|
|
72
|
|
|
/** |
73
|
|
|
* {@inheritdoc} |
74
|
|
|
*/ |
75
|
7 |
|
protected function getDocumentElements(): array |
76
|
|
|
{ |
77
|
7 |
|
return \array_merge(parent::getDocumentElements(), ['links']); |
78
|
|
|
} |
79
|
|
|
|
80
|
|
|
/** |
81
|
|
|
* {@inheritdoc} |
82
|
|
|
*/ |
83
|
8 |
|
protected function getDocumentNamespace(): string |
84
|
|
|
{ |
85
|
8 |
|
return 'inv'; |
86
|
|
|
} |
87
|
|
|
|
88
|
|
|
/** |
89
|
|
|
* {@inheritdoc} |
90
|
|
|
*/ |
91
|
8 |
|
protected function getDocumentName(): string |
92
|
|
|
{ |
93
|
8 |
|
return 'invoice'; |
94
|
|
|
} |
95
|
|
|
} |
96
|
|
|
|