1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace NFePHP\EFDReinf\Factories; |
4
|
|
|
|
5
|
|
|
/** |
6
|
|
|
* Class EFD-Reinf EvtAssocDespRep Event R-2040 constructor |
7
|
|
|
* |
8
|
|
|
* @category API |
9
|
|
|
* @package NFePHP\EFDReinf |
10
|
|
|
* @copyright NFePHP Copyright (c) 2017 |
11
|
|
|
* @license http://www.gnu.org/licenses/lgpl.txt LGPLv3+ |
12
|
|
|
* @license https://opensource.org/licenses/MIT MIT |
13
|
|
|
* @license http://www.gnu.org/licenses/gpl.txt GPLv3+ |
14
|
|
|
* @author Roberto L. Machado <linux.rlm at gmail dot com> |
15
|
|
|
* @link http://github.com/nfephp-org/sped-efdreinf for the canonical source repository |
16
|
|
|
*/ |
17
|
|
|
|
18
|
|
|
use NFePHP\EFDReinf\Common\Factory; |
19
|
|
|
use NFePHP\EFDReinf\Common\FactoryInterface; |
20
|
|
|
use NFePHP\EFDReinf\Common\FactoryId; |
21
|
|
|
use NFePHP\Common\Certificate; |
22
|
|
|
use stdClass; |
23
|
|
|
|
24
|
|
|
class EvtAssocDespRep extends Factory implements FactoryInterface |
25
|
|
|
{ |
26
|
|
|
/** |
27
|
|
|
* @var string |
28
|
|
|
* NOTA: indica o XSD e o namespace do XML |
29
|
|
|
*/ |
30
|
|
|
protected $evtName = 'evtRecursoRepassadoAssociacao'; |
31
|
|
|
/** |
32
|
|
|
* @var string |
33
|
|
|
*/ |
34
|
|
|
protected $evtTag = 'evtAssocDespRep'; |
35
|
|
|
/** |
36
|
|
|
* @var string |
37
|
|
|
*/ |
38
|
|
|
protected $evtAlias = 'R-2040'; |
39
|
|
|
|
40
|
|
|
/** |
41
|
|
|
* Constructor |
42
|
|
|
* @param string $config |
43
|
|
|
* @param stdClass $std |
44
|
|
|
* @param Certificate $certificate |
45
|
|
|
* @param string date |
46
|
|
|
*/ |
47
|
|
|
public function __construct( |
48
|
|
|
$config, |
49
|
|
|
stdClass $std, |
50
|
|
|
Certificate $certificate = null, |
51
|
|
|
$date = '' |
52
|
|
|
) { |
53
|
|
|
parent::__construct($config, $std, $certificate, $date); |
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
/** |
57
|
|
|
* Node constructor |
58
|
|
|
*/ |
59
|
|
|
protected function toNode() |
60
|
|
|
{ |
61
|
|
|
$ideContri = $this->node->getElementsByTagName('ideContri')->item(0); |
62
|
|
|
//remove ideContri |
63
|
|
|
$this->node->removeChild($ideContri); |
64
|
|
|
//o idEvento pode variar de evento para evento |
65
|
|
|
//então cada factory individualmente terá de construir o seu |
66
|
|
|
$ideEvento = $this->dom->createElement("ideEvento"); |
67
|
|
|
$this->dom->addChild( |
68
|
|
|
$ideEvento, |
69
|
|
|
"indRetif", |
70
|
|
|
$this->std->indretif, |
71
|
|
|
true |
72
|
|
|
); |
73
|
|
|
$this->dom->addChild( |
74
|
|
|
$ideEvento, |
75
|
|
|
"nrRecibo", |
76
|
|
|
!empty($this->std->nrrecibo) ? $this->std->nrrecibo : null, |
77
|
|
|
true |
78
|
|
|
); |
79
|
|
|
$this->dom->addChild( |
80
|
|
|
$ideEvento, |
81
|
|
|
"perApur", |
82
|
|
|
$this->std->perapur, |
83
|
|
|
true |
84
|
|
|
); |
85
|
|
|
$this->dom->addChild( |
86
|
|
|
$ideEvento, |
87
|
|
|
"tpAmb", |
88
|
|
|
$this->tpAmb, |
89
|
|
|
true |
90
|
|
|
); |
91
|
|
|
$this->dom->addChild( |
92
|
|
|
$ideEvento, |
93
|
|
|
"procEmi", |
94
|
|
|
$this->procEmi, |
95
|
|
|
true |
96
|
|
|
); |
97
|
|
|
$this->dom->addChild( |
98
|
|
|
$ideEvento, |
99
|
|
|
"verProc", |
100
|
|
|
$this->verProc, |
101
|
|
|
true |
102
|
|
|
); |
103
|
|
|
$this->node->appendChild($ideEvento); |
104
|
|
|
//cria novo ideContri |
105
|
|
|
$ideContri = $this->dom->createElement("ideContri"); |
106
|
|
|
$this->dom->addChild( |
107
|
|
|
$ideContri, |
108
|
|
|
"tpInsc", |
109
|
|
|
$this->tpInsc, |
110
|
|
|
true |
111
|
|
|
); |
112
|
|
|
$this->dom->addChild( |
113
|
|
|
$ideContri, |
114
|
|
|
"nrInsc", |
115
|
|
|
$this->nrInsc, |
116
|
|
|
true |
117
|
|
|
); |
118
|
|
|
$ideEstab = $this->dom->createElement("ideEstab"); |
119
|
|
|
$this->dom->addChild( |
120
|
|
|
$ideEstab, |
121
|
|
|
"tpInscEstab", |
122
|
|
|
$this->std->tpinscestab, |
123
|
|
|
true |
124
|
|
|
); |
125
|
|
|
$this->dom->addChild( |
126
|
|
|
$ideEstab, |
127
|
|
|
"nrInscEstab", |
128
|
|
|
$this->std->nrinscestab, |
129
|
|
|
true |
130
|
|
|
); |
131
|
|
|
foreach ($this->std->recursosrep as $r) { |
132
|
|
|
$recursosRep = $this->dom->createElement("recursosRep"); |
133
|
|
|
$this->dom->addChild( |
134
|
|
|
$recursosRep, |
135
|
|
|
"cnpjAssocDesp", |
136
|
|
|
$r->cnpjassocdesp, |
137
|
|
|
true |
138
|
|
|
); |
139
|
|
|
$this->dom->addChild( |
140
|
|
|
$recursosRep, |
141
|
|
|
"vlrTotalRep", |
142
|
|
|
$r->vlrtotalrep, |
143
|
|
|
true |
144
|
|
|
); |
145
|
|
|
$this->dom->addChild( |
146
|
|
|
$recursosRep, |
147
|
|
|
"vlrTotalRet", |
148
|
|
|
$r->vlrtotalret, |
149
|
|
|
true |
150
|
|
|
); |
151
|
|
|
$this->dom->addChild( |
152
|
|
|
$recursosRep, |
153
|
|
|
"vlrTotalNRet", |
154
|
|
|
!empty($r->vlrtotalnret) ? $r->vlrtotalnret : null, |
155
|
|
|
false |
156
|
|
|
); |
157
|
|
|
foreach ($r->inforecurso as $i) { |
158
|
|
|
$infoRecurso = $this->dom->createElement("infoRecurso"); |
159
|
|
|
$this->dom->addChild( |
160
|
|
|
$infoRecurso, |
161
|
|
|
"tpRepasse", |
162
|
|
|
$i->tprepasse, |
163
|
|
|
true |
164
|
|
|
); |
165
|
|
|
$this->dom->addChild( |
166
|
|
|
$infoRecurso, |
167
|
|
|
"descRecurso", |
168
|
|
|
$i->descrecurso, |
169
|
|
|
true |
170
|
|
|
); |
171
|
|
|
$this->dom->addChild( |
172
|
|
|
$infoRecurso, |
173
|
|
|
"vlrBruto", |
174
|
|
|
$i->vlrbruto, |
175
|
|
|
true |
176
|
|
|
); |
177
|
|
|
$this->dom->addChild( |
178
|
|
|
$infoRecurso, |
179
|
|
|
"vlrRetApur", |
180
|
|
|
$i->vlrretapur, |
181
|
|
|
true |
182
|
|
|
); |
183
|
|
|
if (!empty($r->infoproc)) { |
184
|
|
|
foreach ($r->infoproc as $k) { |
185
|
|
|
$infoProc = $this->dom->createElement("infoProc"); |
186
|
|
|
$this->dom->addChild( |
187
|
|
|
$infoProc, |
188
|
|
|
"tpProc", |
189
|
|
|
$k->tpproc, |
190
|
|
|
true |
191
|
|
|
); |
192
|
|
|
$this->dom->addChild( |
193
|
|
|
$infoProc, |
194
|
|
|
"nrProc", |
195
|
|
|
$k->nrproc, |
196
|
|
|
true |
197
|
|
|
); |
198
|
|
|
$this->dom->addChild( |
199
|
|
|
$infoProc, |
200
|
|
|
"codSusp", |
201
|
|
|
!empty($k->codsusp) ? $k->codsusp : null, |
202
|
|
|
true |
203
|
|
|
); |
204
|
|
|
$this->dom->addChild( |
205
|
|
|
$infoProc, |
206
|
|
|
"vlrNRet", |
207
|
|
|
$k->vlrnret, |
208
|
|
|
true |
209
|
|
|
); |
210
|
|
|
$infoRecurso->appendChild($infoProc); |
211
|
|
|
} |
212
|
|
|
} |
213
|
|
|
$recursosRep->appendChild($infoRecurso); |
214
|
|
|
} |
215
|
|
|
$ideEstab->appendChild($recursosRep); |
216
|
|
|
} |
217
|
|
|
$ideContri->appendChild($ideEstab); |
218
|
|
|
$this->node->appendChild($ideContri); |
219
|
|
|
$this->reinf->appendChild($this->node); |
220
|
|
|
//$this->xml = $this->dom->saveXML($this->reinf); |
|
|
|
|
221
|
|
|
$this->sign(); |
222
|
|
|
} |
223
|
|
|
} |
224
|
|
|
|
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.
The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.
This check looks for comments that seem to be mostly valid code and reports them.