1 | <?php |
||
2 | namespace CfdiUtils\Elements\Cfdi33; |
||
3 | |||
4 | use CfdiUtils\Elements\Cfdi33\Traits\ImpuestosTrait; |
||
5 | use CfdiUtils\Elements\Common\AbstractElement; |
||
6 | use CfdiUtils\Nodes\NodeInterface; |
||
7 | |||
8 | class Comprobante extends AbstractElement |
||
9 | { |
||
10 | use ImpuestosTrait; |
||
11 | |||
12 | 417 | public function getElementName(): string |
|
13 | { |
||
14 | 417 | return 'cfdi:Comprobante'; |
|
15 | } |
||
16 | |||
17 | /** |
||
18 | * @todo Remove this deprecation error on version 3.0.0 |
||
19 | * @return CfdiRelacionados |
||
20 | */ |
||
21 | 9 | public function getCfdiRelacionados(): CfdiRelacionados |
|
22 | { |
||
23 | 9 | $arguments = func_get_args(); |
|
24 | 9 | if (count($arguments) > 0) { |
|
25 | 2 | trigger_error( |
|
26 | 2 | 'El método getCfdiRelacionados ya no admite atributos, use addCfdiRelacionados en su lugar', |
|
27 | 2 | E_USER_NOTICE |
|
28 | ); |
||
29 | 2 | return $this->addCfdiRelacionados($arguments[0]); |
|
30 | } |
||
31 | 9 | return $this->helperGetOrAdd(new CfdiRelacionados()); |
|
0 ignored issues
–
show
Bug
Best Practice
introduced
by
Loading history...
|
|||
32 | } |
||
33 | |||
34 | 4 | public function addCfdiRelacionados(array $attributes = []): CfdiRelacionados |
|
35 | { |
||
36 | 4 | $cfdiRelacionados = $this->getCfdiRelacionados(); |
|
37 | 4 | $cfdiRelacionados->addAttributes($attributes); |
|
38 | 4 | return $cfdiRelacionados; |
|
39 | } |
||
40 | |||
41 | 1 | public function addCfdiRelacionado(array $attributes = []): CfdiRelacionado |
|
42 | { |
||
43 | 1 | return $this->getCfdiRelacionados()->addCfdiRelacionado($attributes); |
|
44 | } |
||
45 | |||
46 | 1 | public function multiCfdiRelacionado(array ...$elementAttributes): self |
|
47 | { |
||
48 | 1 | $this->getCfdiRelacionados()->multiCfdiRelacionado($elementAttributes); |
|
49 | 1 | return $this; |
|
50 | } |
||
51 | |||
52 | 16 | public function getEmisor(): Emisor |
|
53 | { |
||
54 | 16 | return $this->helperGetOrAdd(new Emisor()); |
|
0 ignored issues
–
show
|
|||
55 | } |
||
56 | |||
57 | 2 | public function addEmisor(array $attributes = []): Emisor |
|
58 | { |
||
59 | 2 | $emisor = $this->getEmisor(); |
|
60 | 2 | $emisor->addAttributes($attributes); |
|
61 | 2 | return $emisor; |
|
62 | } |
||
63 | |||
64 | 6 | public function getReceptor(): Receptor |
|
65 | { |
||
66 | 6 | return $this->helperGetOrAdd(new Receptor()); |
|
0 ignored issues
–
show
|
|||
67 | } |
||
68 | |||
69 | 4 | public function addReceptor(array $attributes = []): Receptor |
|
70 | { |
||
71 | 4 | $receptor = $this->getReceptor(); |
|
72 | 4 | $receptor->addAttributes($attributes); |
|
73 | 4 | return $receptor; |
|
74 | } |
||
75 | |||
76 | 74 | public function getConceptos(): Conceptos |
|
77 | { |
||
78 | 74 | return $this->helperGetOrAdd(new Conceptos()); |
|
0 ignored issues
–
show
|
|||
79 | } |
||
80 | |||
81 | 72 | public function addConcepto(array $attributes = [], array $children = []): Concepto |
|
82 | { |
||
83 | 72 | return $this->getConceptos()->addConcepto($attributes, $children); |
|
84 | } |
||
85 | |||
86 | 14 | public function getImpuestos(): Impuestos |
|
87 | { |
||
88 | 14 | return $this->helperGetOrAdd(new Impuestos()); |
|
0 ignored issues
–
show
|
|||
89 | } |
||
90 | |||
91 | 1 | public function addImpuestos(array $attributes = []): Impuestos |
|
92 | { |
||
93 | 1 | $impuestos = $this->getImpuestos(); |
|
94 | 1 | $impuestos->addAttributes($attributes); |
|
95 | 1 | return $impuestos; |
|
96 | } |
||
97 | |||
98 | 81 | public function getComplemento(): Complemento |
|
99 | { |
||
100 | 81 | return $this->helperGetOrAdd(new Complemento()); |
|
0 ignored issues
–
show
|
|||
101 | } |
||
102 | |||
103 | 78 | public function addComplemento(NodeInterface $children): self |
|
104 | { |
||
105 | 78 | $this->getComplemento()->add($children); |
|
106 | 78 | return $this; |
|
107 | } |
||
108 | |||
109 | 3 | public function getAddenda(): Addenda |
|
110 | { |
||
111 | 3 | return $this->helperGetOrAdd(new Addenda()); |
|
0 ignored issues
–
show
|
|||
112 | } |
||
113 | |||
114 | 1 | public function addAddenda(NodeInterface $children): self |
|
115 | { |
||
116 | 1 | $this->getAddenda()->add($children); |
|
117 | 1 | return $this; |
|
118 | } |
||
119 | |||
120 | 417 | public function getChildrenOrder(): array |
|
121 | { |
||
122 | return [ |
||
123 | 417 | 'cfdi:CfdiRelacionados', |
|
124 | 'cfdi:Emisor', |
||
125 | 'cfdi:Receptor', |
||
126 | 'cfdi:Conceptos', |
||
127 | 'cfdi:Impuestos', |
||
128 | 'cfdi:Complemento', |
||
129 | 'cfdi:Addenda', |
||
130 | ]; |
||
131 | } |
||
132 | |||
133 | 417 | public function getFixedAttributes(): array |
|
134 | { |
||
135 | return [ |
||
136 | 417 | 'xmlns:cfdi' => 'http://www.sat.gob.mx/cfd/3', |
|
137 | 'xmlns:xsi' => 'http://www.w3.org/2001/XMLSchema-instance', |
||
138 | 'xsi:schemaLocation' => 'http://www.sat.gob.mx/cfd/3 http://www.sat.gob.mx/sitio_internet/cfd/3/cfdv33.xsd', |
||
139 | 'Version' => '3.3', |
||
140 | ]; |
||
141 | } |
||
142 | } |
||
143 |