1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace NFePHP\EFDReinf\Factories; |
4
|
|
|
|
5
|
|
|
/** |
6
|
|
|
* Class EFD-Reinf EvtEspDesportivo Event R-3010 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 EvtEspDesportivo extends Factory implements FactoryInterface |
25
|
|
|
{ |
26
|
|
|
/** |
27
|
|
|
* Constructor |
28
|
|
|
* @param string $config |
29
|
|
|
* @param stdClass $std |
30
|
|
|
* @param Certificate $certificate |
31
|
|
|
* @param string date |
32
|
|
|
*/ |
33
|
|
|
public function __construct( |
34
|
|
|
$config, |
35
|
|
|
stdClass $std, |
36
|
|
|
Certificate $certificate = null, |
37
|
|
|
$date = '' |
38
|
|
|
) { |
39
|
|
|
$params = new \stdClass(); |
40
|
|
|
$params->evtName = 'evtEspDesportivo'; |
41
|
|
|
$params->evtTag = 'evtEspDesportivo'; |
42
|
|
|
$params->evtAlias = 'R-3010'; |
43
|
|
|
parent::__construct($config, $std, $params, $certificate, $date); |
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
/** |
47
|
|
|
* Node constructor |
48
|
|
|
*/ |
49
|
|
|
protected function toNode() |
50
|
|
|
{ |
51
|
|
|
$ideContri = $this->node->getElementsByTagName('ideContri')->item(0); |
52
|
|
|
$this->node->removeChild($ideContri); |
53
|
|
|
//o idEvento pode variar de evento para evento |
54
|
|
|
//então cada factory individualmente terá de construir o seu |
55
|
|
|
$ideEvento = $this->dom->createElement("ideEvento"); |
56
|
|
|
$this->dom->addChild( |
57
|
|
|
$ideEvento, |
58
|
|
|
"indRetif", |
59
|
|
|
$this->std->indretif, |
60
|
|
|
true |
61
|
|
|
); |
62
|
|
|
$this->dom->addChild( |
63
|
|
|
$ideEvento, |
64
|
|
|
"nrRecibo", |
65
|
|
|
!empty($this->std->nrrecibo) ? $this->std->nrrecibo : null, |
66
|
|
|
true |
67
|
|
|
); |
68
|
|
|
$this->dom->addChild( |
69
|
|
|
$ideEvento, |
70
|
|
|
"dtApuracao", |
71
|
|
|
$this->std->dtapuracao, |
72
|
|
|
true |
73
|
|
|
); |
74
|
|
|
$this->dom->addChild( |
75
|
|
|
$ideEvento, |
76
|
|
|
"tpAmb", |
77
|
|
|
$this->tpAmb, |
78
|
|
|
true |
79
|
|
|
); |
80
|
|
|
$this->dom->addChild( |
81
|
|
|
$ideEvento, |
82
|
|
|
"procEmi", |
83
|
|
|
$this->procEmi, |
84
|
|
|
true |
85
|
|
|
); |
86
|
|
|
$this->dom->addChild( |
87
|
|
|
$ideEvento, |
88
|
|
|
"verProc", |
89
|
|
|
$this->verProc, |
90
|
|
|
true |
91
|
|
|
); |
92
|
|
|
$this->node->appendChild($ideEvento); |
93
|
|
|
$ideContri = $this->dom->createElement("ideContri"); |
94
|
|
|
$this->dom->addChild( |
95
|
|
|
$ideContri, |
96
|
|
|
"tpInsc", |
97
|
|
|
$this->tpInsc, |
98
|
|
|
true |
99
|
|
|
); |
100
|
|
|
$this->dom->addChild( |
101
|
|
|
$ideContri, |
102
|
|
|
"nrInsc", |
103
|
|
|
$this->nrInsc, |
104
|
|
|
true |
105
|
|
|
); |
106
|
|
|
foreach ($this->std->ideestab as $stab) { |
107
|
|
|
$ideEstab = $this->dom->createElement("ideEstab"); |
108
|
|
|
$this->dom->addChild( |
109
|
|
|
$ideEstab, |
110
|
|
|
"tpInscEstab", |
111
|
|
|
$stab->tpinscestab, |
112
|
|
|
true |
113
|
|
|
); |
114
|
|
|
$this->dom->addChild( |
115
|
|
|
$ideEstab, |
116
|
|
|
"nrInscEstab", |
117
|
|
|
$stab->nrinscestab, |
118
|
|
|
true |
119
|
|
|
); |
120
|
|
|
|
121
|
|
|
foreach ($stab->boletim as $bo) { |
122
|
|
|
$boletim = $this->dom->createElement("boletim"); |
123
|
|
|
$this->dom->addChild( |
124
|
|
|
$boletim, |
125
|
|
|
"nrBoletim", |
126
|
|
|
$bo->nrboletim, |
127
|
|
|
true |
128
|
|
|
); |
129
|
|
|
$this->dom->addChild( |
130
|
|
|
$boletim, |
131
|
|
|
"tpCompeticao", |
132
|
|
|
$bo->tpcompeticao, |
133
|
|
|
true |
134
|
|
|
); |
135
|
|
|
$this->dom->addChild( |
136
|
|
|
$boletim, |
137
|
|
|
"categEvento", |
138
|
|
|
$bo->categevento, |
139
|
|
|
true |
140
|
|
|
); |
141
|
|
|
$this->dom->addChild( |
142
|
|
|
$boletim, |
143
|
|
|
"modDesportiva", |
144
|
|
|
$bo->moddesportiva, |
145
|
|
|
true |
146
|
|
|
); |
147
|
|
|
$this->dom->addChild( |
148
|
|
|
$boletim, |
149
|
|
|
"nomeCompeticao", |
150
|
|
|
$bo->nomecompeticao, |
151
|
|
|
true |
152
|
|
|
); |
153
|
|
|
$this->dom->addChild( |
154
|
|
|
$boletim, |
155
|
|
|
"cnpjMandante", |
156
|
|
|
$bo->cnpjmandante, |
157
|
|
|
true |
158
|
|
|
); |
159
|
|
|
$this->dom->addChild( |
160
|
|
|
$boletim, |
161
|
|
|
"cnpjVisitante", |
162
|
|
|
!empty($bo->cnpjvisitante) ? $bo->cnpjvisitante : null, |
163
|
|
|
true |
164
|
|
|
); |
165
|
|
|
$this->dom->addChild( |
166
|
|
|
$boletim, |
167
|
|
|
"nomeVisitante", |
168
|
|
|
!empty($bo->nomevisitante) ? $bo->nomevisitante : null, |
169
|
|
|
true |
170
|
|
|
); |
171
|
|
|
$this->dom->addChild( |
172
|
|
|
$boletim, |
173
|
|
|
"pracaDesportiva", |
174
|
|
|
$bo->pracadesportiva, |
175
|
|
|
true |
176
|
|
|
); |
177
|
|
|
$this->dom->addChild( |
178
|
|
|
$boletim, |
179
|
|
|
"codMunic", |
180
|
|
|
!empty($bo->codmunic) ? $bo->codmunic : null, |
181
|
|
|
true |
182
|
|
|
); |
183
|
|
|
$this->dom->addChild( |
184
|
|
|
$boletim, |
185
|
|
|
"uf", |
186
|
|
|
$bo->uf, |
187
|
|
|
true |
188
|
|
|
); |
189
|
|
|
$this->dom->addChild( |
190
|
|
|
$boletim, |
191
|
|
|
"qtdePagantes", |
192
|
|
|
$bo->qtdepagantes, |
193
|
|
|
true |
194
|
|
|
); |
195
|
|
|
$this->dom->addChild( |
196
|
|
|
$boletim, |
197
|
|
|
"qtdeNaoPagantes", |
198
|
|
|
$bo->qtdenaopagantes, |
199
|
|
|
true |
200
|
|
|
); |
201
|
|
|
|
202
|
|
|
foreach($bo->receitaingressos as $rec) { |
203
|
|
|
$recIng = $this->dom->createElement("receitaIngressos"); |
204
|
|
|
$this->dom->addChild( |
205
|
|
|
$recIng, |
206
|
|
|
"tpIngresso", |
207
|
|
|
$rec->tpingresso, |
208
|
|
|
true |
209
|
|
|
); |
210
|
|
|
$this->dom->addChild( |
211
|
|
|
$recIng, |
212
|
|
|
"descIngr", |
213
|
|
|
$rec->descingr, |
214
|
|
|
true |
215
|
|
|
); |
216
|
|
|
$this->dom->addChild( |
217
|
|
|
$recIng, |
218
|
|
|
"qtdeIngrVenda", |
219
|
|
|
$rec->qtdeingrvenda, |
220
|
|
|
true |
221
|
|
|
); |
222
|
|
|
$this->dom->addChild( |
223
|
|
|
$recIng, |
224
|
|
|
"qtdeIngrVendidos", |
225
|
|
|
$rec->qtdeingrvendidos, |
226
|
|
|
true |
227
|
|
|
); |
228
|
|
|
$this->dom->addChild( |
229
|
|
|
$recIng, |
230
|
|
|
"qtdeIngrDev", |
231
|
|
|
$rec->qtdeingrdev, |
232
|
|
|
true |
233
|
|
|
); |
234
|
|
|
$this->dom->addChild( |
235
|
|
|
$recIng, |
236
|
|
|
"precoIndiv", |
237
|
|
|
number_format($rec->precoindiv, 2, ',', ''), |
238
|
|
|
true |
239
|
|
|
); |
240
|
|
|
$this->dom->addChild( |
241
|
|
|
$recIng, |
242
|
|
|
"vlrTotal", |
243
|
|
|
number_format($rec->vlrtotal, 2, ',', ''), |
244
|
|
|
true |
245
|
|
|
); |
246
|
|
|
$boletim->appendChild($recIng); |
247
|
|
|
} |
248
|
|
|
|
249
|
|
|
if (!empty($bo->outrasreceitas)) { |
250
|
|
|
foreach ($bo->outrasreceitas as $or) { |
251
|
|
|
$oRec = $this->dom->createElement("outrasReceitas"); |
252
|
|
|
$this->dom->addChild( |
253
|
|
|
$oRec, |
254
|
|
|
"tpReceita", |
255
|
|
|
$or->tpreceita, |
256
|
|
|
true |
257
|
|
|
); |
258
|
|
|
$this->dom->addChild( |
259
|
|
|
$oRec, |
260
|
|
|
"vlrReceita", |
261
|
|
|
number_format($or->vlrreceita, 2, ',', ''), |
262
|
|
|
true |
263
|
|
|
); |
264
|
|
|
$this->dom->addChild( |
265
|
|
|
$oRec, |
266
|
|
|
"descReceita", |
267
|
|
|
$or->descreceita, |
268
|
|
|
true |
269
|
|
|
); |
270
|
|
|
$boletim->appendChild($oRec); |
271
|
|
|
} |
272
|
|
|
} |
273
|
|
|
$ideEstab->appendChild($boletim); |
274
|
|
|
} |
275
|
|
|
$rt = $stab->receitatotal; |
276
|
|
|
$recTot = $this->dom->createElement("receitaTotal"); |
277
|
|
|
$this->dom->addChild( |
278
|
|
|
$recTot, |
279
|
|
|
"vlrReceitaTotal", |
280
|
|
|
number_format($rt->vlrreceitatotal, 2, ',', ''), |
281
|
|
|
true |
282
|
|
|
); |
283
|
|
|
$this->dom->addChild( |
284
|
|
|
$recTot, |
285
|
|
|
"vlrCP", |
286
|
|
|
number_format($rt->vlrcp, 2, ',', ''), |
287
|
|
|
true |
288
|
|
|
); |
289
|
|
|
$this->dom->addChild( |
290
|
|
|
$recTot, |
291
|
|
|
"vlrCPSuspTotal", |
292
|
|
|
!empty($rt->vlrcpsusptotal) ? number_format($rt->vlrcpsusptotal, 2, ',', '') : null, |
293
|
|
|
false |
294
|
|
|
); |
295
|
|
|
$this->dom->addChild( |
296
|
|
|
$recTot, |
297
|
|
|
"vlrReceitaClubes", |
298
|
|
|
number_format($rt->vlrreceitaclubes, 2, ',', ''), |
299
|
|
|
true |
300
|
|
|
); |
301
|
|
|
$this->dom->addChild( |
302
|
|
|
$recTot, |
303
|
|
|
"vlrRetParc", |
304
|
|
|
number_format($rt->vlrretparc, 2, ',', ''), |
305
|
|
|
true |
306
|
|
|
); |
307
|
|
|
if (!empty($rt->infoproc)) { |
308
|
|
|
foreach ($rt->infoproc as $ifp) { |
309
|
|
|
$infoProc = $this->dom->createElement("infoProc"); |
310
|
|
|
$this->dom->addChild( |
311
|
|
|
$infoProc, |
312
|
|
|
"vlrCPSusp", |
313
|
|
|
number_format($ifp->vlrcpsusp, 2, ',', ''), |
314
|
|
|
true |
315
|
|
|
); |
316
|
|
|
$this->dom->addChild( |
317
|
|
|
$infoProc, |
318
|
|
|
"tpProc", |
319
|
|
|
$ifp->tpproc, |
320
|
|
|
true |
321
|
|
|
); |
322
|
|
|
$this->dom->addChild( |
323
|
|
|
$infoProc, |
324
|
|
|
"nrProc", |
325
|
|
|
$ifp->nrproc, |
326
|
|
|
true |
327
|
|
|
); |
328
|
|
|
$this->dom->addChild( |
329
|
|
|
$infoProc, |
330
|
|
|
"codSusp", |
331
|
|
|
!empty($ifp->codsusp) ? $ifp->codsusp : null, |
332
|
|
|
false |
333
|
|
|
); |
334
|
|
|
$recTot->appendChild($infoProc); |
335
|
|
|
} |
336
|
|
|
} |
337
|
|
|
|
338
|
|
|
$ideEstab->appendChild($recTot); |
339
|
|
|
$ideContri->appendChild($ideEstab); |
340
|
|
|
} |
341
|
|
|
$this->node->appendChild($ideContri); |
342
|
|
|
$this->reinf->appendChild($this->node); |
343
|
|
|
//$this->xml = $this->dom->saveXML($this->reinf); |
|
|
|
|
344
|
|
|
$this->sign($this->evtTag); |
345
|
|
|
} |
346
|
|
|
} |
347
|
|
|
|
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.