|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace NFePHP\eSocial\Factories; |
|
4
|
|
|
|
|
5
|
|
|
/** |
|
6
|
|
|
* Class eSocial EvtAqProd Event S-1250 constructor |
|
7
|
|
|
* Read for 2.4.2 layout |
|
8
|
|
|
* |
|
9
|
|
|
* @category library |
|
10
|
|
|
* @package NFePHP\eSocial |
|
11
|
|
|
* @copyright NFePHP Copyright (c) 2017 |
|
12
|
|
|
* @license http://www.gnu.org/licenses/lgpl.txt LGPLv3+ |
|
13
|
|
|
* @license https://opensource.org/licenses/MIT MIT |
|
14
|
|
|
* @license http://www.gnu.org/licenses/gpl.txt GPLv3+ |
|
15
|
|
|
* @author Roberto L. Machado <linux.rlm at gmail dot com> |
|
16
|
|
|
* @link http://github.com/nfephp-org/sped-esocial for the canonical source repository |
|
17
|
|
|
*/ |
|
18
|
|
|
use NFePHP\Common\Certificate; |
|
19
|
|
|
use NFePHP\eSocial\Common\Factory; |
|
20
|
|
|
use NFePHP\eSocial\Common\FactoryId; |
|
21
|
|
|
use NFePHP\eSocial\Common\FactoryInterface; |
|
22
|
|
|
use stdClass; |
|
23
|
|
|
|
|
24
|
|
|
class EvtAqProd extends Factory implements FactoryInterface |
|
25
|
|
|
{ |
|
26
|
|
|
|
|
27
|
|
|
/** |
|
28
|
|
|
* @var int |
|
29
|
|
|
*/ |
|
30
|
|
|
public $sequencial; |
|
31
|
|
|
|
|
32
|
|
|
/** |
|
33
|
|
|
* @var string |
|
34
|
|
|
*/ |
|
35
|
|
|
protected $evtName = 'evtAqProd'; |
|
36
|
|
|
|
|
37
|
|
|
/** |
|
38
|
|
|
* @var string |
|
39
|
|
|
*/ |
|
40
|
|
|
protected $evtAlias = 'S-1250'; |
|
41
|
|
|
|
|
42
|
|
|
/** |
|
43
|
|
|
* Parameters patterns |
|
44
|
|
|
* |
|
45
|
|
|
* @var array |
|
46
|
|
|
*/ |
|
47
|
|
|
protected $parameters = []; |
|
48
|
|
|
|
|
49
|
|
|
/** |
|
50
|
|
|
* Constructor |
|
51
|
|
|
* |
|
52
|
|
|
* @param string $config |
|
53
|
|
|
* @param stdClass $std |
|
54
|
|
|
* @param Certificate $certificate | null |
|
55
|
|
|
* @param string $date |
|
56
|
|
|
*/ |
|
57
|
|
|
public function __construct( |
|
58
|
|
|
$config, |
|
59
|
|
|
stdClass $std, |
|
60
|
|
|
Certificate $certificate = null, |
|
61
|
|
|
$date = '' |
|
62
|
|
|
) { |
|
63
|
|
|
|
|
64
|
|
|
parent::__construct($config, $std, $certificate, $date); |
|
65
|
|
|
} |
|
66
|
|
|
|
|
67
|
|
|
/** |
|
68
|
|
|
* Node constructor |
|
69
|
|
|
*/ |
|
70
|
|
|
protected function toNode() |
|
71
|
|
|
{ |
|
72
|
|
|
$ideEmpregador = $this->node->getElementsByTagName('ideEmpregador')->item(0); |
|
73
|
|
|
//o idEvento pode variar de evento para evento |
|
74
|
|
|
//então cada factory individualmente terá de construir o seu |
|
75
|
|
|
$ideEvento = $this->dom->createElement("ideEvento"); |
|
76
|
|
|
$this->dom->addChild( |
|
77
|
|
|
$ideEvento, |
|
78
|
|
|
"indRetif", |
|
79
|
|
|
$this->std->indretif, |
|
80
|
|
|
true |
|
81
|
|
|
); |
|
82
|
|
|
$this->dom->addChild( |
|
83
|
|
|
$ideEvento, |
|
84
|
|
|
"nrRecibo", |
|
85
|
|
|
!empty($this->std->nrrecibo) ? $this->std->nrrecibo : null, |
|
86
|
|
|
false |
|
87
|
|
|
); |
|
88
|
|
|
$this->dom->addChild( |
|
89
|
|
|
$ideEvento, |
|
90
|
|
|
"indApuracao", |
|
91
|
|
|
$this->std->indapuracao, |
|
92
|
|
|
true |
|
93
|
|
|
); |
|
94
|
|
|
$this->dom->addChild( |
|
95
|
|
|
$ideEvento, |
|
96
|
|
|
"perApur", |
|
97
|
|
|
$this->std->perapur, |
|
98
|
|
|
true |
|
99
|
|
|
); |
|
100
|
|
|
$this->dom->addChild( |
|
101
|
|
|
$ideEvento, |
|
102
|
|
|
"tpAmb", |
|
103
|
|
|
$this->tpAmb, |
|
104
|
|
|
true |
|
105
|
|
|
); |
|
106
|
|
|
$this->dom->addChild( |
|
107
|
|
|
$ideEvento, |
|
108
|
|
|
"procEmi", |
|
109
|
|
|
$this->procEmi, |
|
110
|
|
|
true |
|
111
|
|
|
); |
|
112
|
|
|
$this->dom->addChild( |
|
113
|
|
|
$ideEvento, |
|
114
|
|
|
"verProc", |
|
115
|
|
|
$this->verProc, |
|
116
|
|
|
true |
|
117
|
|
|
); |
|
118
|
|
|
$this->node->insertBefore($ideEvento, $ideEmpregador); |
|
119
|
|
|
|
|
120
|
|
|
$infoAquisProd = $this->dom->createElement("infoAquisProd"); |
|
121
|
|
|
$ideEstabAdquir = $this->dom->createElement("ideEstabAdquir"); |
|
122
|
|
|
$this->dom->addChild( |
|
123
|
|
|
$ideEstabAdquir, |
|
124
|
|
|
"tpInscAdq", |
|
125
|
|
|
$this->std->ideestabadquir->tpinscadq, |
|
126
|
|
|
true |
|
127
|
|
|
); |
|
128
|
|
|
$this->dom->addChild( |
|
129
|
|
|
$ideEstabAdquir, |
|
130
|
|
|
"nrInscAdq", |
|
131
|
|
|
$this->std->ideestabadquir->nrinscadq, |
|
132
|
|
|
true |
|
133
|
|
|
); |
|
134
|
|
|
if (isset($this->std->ideestabadquir->tpaquis)) { |
|
135
|
|
|
if ($this->layoutStr !== 'v02_05_00') { |
|
136
|
|
|
$this->tpAquis($ideEstabAdquir, $this->std->ideestabadquir->tpaquis); |
|
|
|
|
|
|
137
|
|
|
} else { |
|
138
|
|
|
$this->tpAquisV02_05_00( |
|
139
|
|
|
$ideEstabAdquir, |
|
|
|
|
|
|
140
|
|
|
$this->std->ideestabadquir->tpaquis |
|
141
|
|
|
); |
|
142
|
|
|
} |
|
143
|
|
|
} |
|
144
|
|
|
$infoAquisProd->appendChild($ideEstabAdquir); |
|
145
|
|
|
$this->node->appendChild($infoAquisProd); |
|
146
|
|
|
$this->eSocial->appendChild($this->node); |
|
147
|
|
|
//$this->xml = $this->dom->saveXML($this->eSocial); |
|
|
|
|
|
|
148
|
|
|
$this->sign(); |
|
149
|
|
|
} |
|
150
|
|
|
|
|
151
|
|
|
/** |
|
152
|
|
|
* Estrutura do tpAquin v2.4.2 |
|
153
|
|
|
* @param DOMElement $ideEstabAdquir |
|
154
|
|
|
* @param stdClass $tpaquis |
|
155
|
|
|
*/ |
|
156
|
|
|
protected function tpAquis(&$ideEstabAdquir, $tpaquis) |
|
157
|
|
|
{ |
|
158
|
|
|
foreach ($tpaquis as $tp) { |
|
|
|
|
|
|
159
|
|
|
$tpAquis = $this->dom->createElement("tpAquis"); |
|
160
|
|
|
|
|
161
|
|
|
$this->dom->addChild( |
|
162
|
|
|
$tpAquis, |
|
163
|
|
|
"indAquis", |
|
164
|
|
|
$tp->indaquis, |
|
165
|
|
|
true |
|
166
|
|
|
); |
|
167
|
|
|
|
|
168
|
|
|
$this->dom->addChild( |
|
169
|
|
|
$tpAquis, |
|
170
|
|
|
"vlrTotAquis", |
|
171
|
|
|
$tp->vlrtotaquis, |
|
172
|
|
|
true |
|
173
|
|
|
); |
|
174
|
|
|
foreach ($tp->ideprodutor as $ideprod) { |
|
175
|
|
|
$ideProdutor = $this->dom->createElement("ideProdutor"); |
|
176
|
|
|
$this->dom->addChild( |
|
177
|
|
|
$ideProdutor, |
|
178
|
|
|
"tpInscProd", |
|
179
|
|
|
$ideprod->tpinscprod, |
|
180
|
|
|
true |
|
181
|
|
|
); |
|
182
|
|
|
$this->dom->addChild( |
|
183
|
|
|
$ideProdutor, |
|
184
|
|
|
"nrInscProd", |
|
185
|
|
|
$ideprod->nrinscprod, |
|
186
|
|
|
true |
|
187
|
|
|
); |
|
188
|
|
|
$this->dom->addChild( |
|
189
|
|
|
$ideProdutor, |
|
190
|
|
|
"vlrBruto", |
|
191
|
|
|
$ideprod->vlrbruto, |
|
192
|
|
|
true |
|
193
|
|
|
); |
|
194
|
|
|
$this->dom->addChild( |
|
195
|
|
|
$ideProdutor, |
|
196
|
|
|
"vrCPDescPR", |
|
197
|
|
|
$ideprod->vrcpdescpr, |
|
198
|
|
|
true |
|
199
|
|
|
); |
|
200
|
|
|
$this->dom->addChild( |
|
201
|
|
|
$ideProdutor, |
|
202
|
|
|
"vrRatDescPR", |
|
203
|
|
|
$ideprod->vrratdescpr, |
|
204
|
|
|
true |
|
205
|
|
|
); |
|
206
|
|
|
$this->dom->addChild( |
|
207
|
|
|
$ideProdutor, |
|
208
|
|
|
"vrSenarDesc", |
|
209
|
|
|
$ideprod->vrsenardesc, |
|
210
|
|
|
true |
|
211
|
|
|
); |
|
212
|
|
|
if (isset($ideprod->nfs)) { |
|
213
|
|
|
foreach ($ideprod->nfs as $prodnfs) { |
|
214
|
|
|
$nfs = $this->dom->createElement("nfs"); |
|
215
|
|
|
$this->dom->addChild( |
|
216
|
|
|
$nfs, |
|
217
|
|
|
"serie", |
|
218
|
|
|
!empty($prodnfs->serie) ? $prodnfs->serie : null, |
|
219
|
|
|
false |
|
220
|
|
|
); |
|
221
|
|
|
$this->dom->addChild( |
|
222
|
|
|
$nfs, |
|
223
|
|
|
"nrDocto", |
|
224
|
|
|
$prodnfs->nrdocto, |
|
225
|
|
|
true |
|
226
|
|
|
); |
|
227
|
|
|
$this->dom->addChild( |
|
228
|
|
|
$nfs, |
|
229
|
|
|
"dtEmisNF", |
|
230
|
|
|
$prodnfs->dtemisnf, |
|
231
|
|
|
true |
|
232
|
|
|
); |
|
233
|
|
|
$this->dom->addChild( |
|
234
|
|
|
$nfs, |
|
235
|
|
|
"vlrBruto", |
|
236
|
|
|
$prodnfs->vlrbruto, |
|
237
|
|
|
true |
|
238
|
|
|
); |
|
239
|
|
|
$this->dom->addChild( |
|
240
|
|
|
$nfs, |
|
241
|
|
|
"vrCPDescPR", |
|
242
|
|
|
$prodnfs->vrcpdescpr, |
|
243
|
|
|
true |
|
244
|
|
|
); |
|
245
|
|
|
$this->dom->addChild( |
|
246
|
|
|
$nfs, |
|
247
|
|
|
"vrRatDescPR", |
|
248
|
|
|
$prodnfs->vrratdescpr, |
|
249
|
|
|
true |
|
250
|
|
|
); |
|
251
|
|
|
$this->dom->addChild( |
|
252
|
|
|
$nfs, |
|
253
|
|
|
"vrSenarDesc", |
|
254
|
|
|
$prodnfs->vrsenardesc, |
|
255
|
|
|
true |
|
256
|
|
|
); |
|
257
|
|
|
$ideProdutor->appendChild($nfs); |
|
258
|
|
|
} |
|
259
|
|
|
} |
|
260
|
|
|
if (isset($ideprod->infoprocjud)) { |
|
261
|
|
|
foreach ($ideprod->infoprocjud as $prodprocjud) { |
|
262
|
|
|
$infoProcJud = $this->dom->createElement("infoProcJud"); |
|
263
|
|
|
$this->dom->addChild( |
|
264
|
|
|
$infoProcJud, |
|
265
|
|
|
"nrProcJud", |
|
266
|
|
|
$prodprocjud->nrprocjud, |
|
267
|
|
|
true |
|
268
|
|
|
); |
|
269
|
|
|
$this->dom->addChild( |
|
270
|
|
|
$infoProcJud, |
|
271
|
|
|
"codSusp", |
|
272
|
|
|
$prodprocjud->codsusp, |
|
273
|
|
|
true |
|
274
|
|
|
); |
|
275
|
|
|
$this->dom->addChild( |
|
276
|
|
|
$infoProcJud, |
|
277
|
|
|
"vrCPNRet", |
|
278
|
|
|
$prodprocjud->vrcpnret, |
|
279
|
|
|
true |
|
280
|
|
|
); |
|
281
|
|
|
$this->dom->addChild( |
|
282
|
|
|
$infoProcJud, |
|
283
|
|
|
"vrRatNRet", |
|
284
|
|
|
$prodprocjud->vrratnret, |
|
285
|
|
|
true |
|
286
|
|
|
); |
|
287
|
|
|
$this->dom->addChild( |
|
288
|
|
|
$infoProcJud, |
|
289
|
|
|
"vrSenarNRet", |
|
290
|
|
|
$prodprocjud->vrsenarnret, |
|
291
|
|
|
true |
|
292
|
|
|
); |
|
293
|
|
|
$ideProdutor->appendChild($infoProcJud); |
|
294
|
|
|
} |
|
295
|
|
|
} |
|
296
|
|
|
$tpAquis->appendChild($ideProdutor); |
|
297
|
|
|
} |
|
298
|
|
|
$ideEstabAdquir->appendChild($tpAquis); |
|
299
|
|
|
} |
|
300
|
|
|
} |
|
301
|
|
|
|
|
302
|
|
|
/** |
|
303
|
|
|
* Grandes altereções de estrutura na tag tpAquis |
|
304
|
|
|
* @param DOMElement $ideEstabAdquir |
|
305
|
|
|
* @param stdClass $tpaquis |
|
306
|
|
|
*/ |
|
307
|
|
|
protected function tpAquisV02_05_00(&$ideEstabAdquir, $tpaquis) |
|
308
|
|
|
{ |
|
309
|
|
|
foreach ($tpaquis as $tp) { |
|
|
|
|
|
|
310
|
|
|
$tpAquis = $this->dom->createElement("tpAquis"); |
|
311
|
|
|
$tpAquis->setAttribute('indAquis', $tp->indaquis); |
|
312
|
|
|
$tpAquis->setAttribute( |
|
313
|
|
|
'vlrTotAquis', |
|
314
|
|
|
number_format($tp->vlrtotaquis, 2, '.', '') |
|
315
|
|
|
); |
|
316
|
|
|
foreach ($tp->ideprodutor as $ideprod) { |
|
317
|
|
|
$ideProdutor = $this->dom->createElement("ideProdutor"); |
|
318
|
|
|
$ideProdutor->setAttribute('tpInscProd', $ideprod->tpinscprod); |
|
319
|
|
|
$ideProdutor->setAttribute('nrInscProd', $ideprod->nrinscprod); |
|
320
|
|
|
$ideProdutor->setAttribute( |
|
321
|
|
|
'vlrBruto', |
|
322
|
|
|
number_format($ideprod->vlrbruto, 2, '.', '') |
|
323
|
|
|
); |
|
324
|
|
|
$ideProdutor->setAttribute( |
|
325
|
|
|
'vrCPDescPR', |
|
326
|
|
|
number_format($ideprod->vrcpdescpr, 2, '.', '') |
|
327
|
|
|
); |
|
328
|
|
|
$ideProdutor->setAttribute( |
|
329
|
|
|
'vrRatDescPR', |
|
330
|
|
|
number_format($ideprod->vrratdescpr, 2, '.', '') |
|
331
|
|
|
); |
|
332
|
|
|
$ideProdutor->setAttribute( |
|
333
|
|
|
'vrSenarDesc', |
|
334
|
|
|
number_format($ideprod->vrsenardesc, 2, '.', '') |
|
335
|
|
|
); |
|
336
|
|
|
$ideProdutor->setAttribute('indOpcCP', $ideprod->indopccp); |
|
337
|
|
|
|
|
338
|
|
|
foreach ($ideprod->nfs as $prodnfs) { |
|
339
|
|
|
$nfs = $this->dom->createElement("nfs"); |
|
340
|
|
|
!empty($prodnfs->serie) ? $nfs->setAttribute('serie', $prodnfs->serie) : null; |
|
341
|
|
|
$nfs->setAttribute('nrDocto', $prodnfs->nrdocto); |
|
342
|
|
|
$nfs->setAttribute('dtEmisNF', $prodnfs->dtemisnf); |
|
343
|
|
|
$nfs->setAttribute( |
|
344
|
|
|
'vlrBruto', |
|
345
|
|
|
number_format($prodnfs->vlrbruto, 2, '.', '') |
|
346
|
|
|
); |
|
347
|
|
|
$nfs->setAttribute( |
|
348
|
|
|
'vrCPDescPR', |
|
349
|
|
|
number_format($prodnfs->vrcpdescpr, 2, '.', '') |
|
350
|
|
|
); |
|
351
|
|
|
$nfs->setAttribute( |
|
352
|
|
|
'vrRatDescPR', |
|
353
|
|
|
number_format($prodnfs->vrratdescpr, 2, '.', '') |
|
354
|
|
|
); |
|
355
|
|
|
$nfs->setAttribute( |
|
356
|
|
|
'vrSenarDesc', |
|
357
|
|
|
number_format($prodnfs->vrsenardesc, 2, '.', '') |
|
358
|
|
|
); |
|
359
|
|
|
$ideProdutor->appendChild($nfs); |
|
360
|
|
|
} |
|
361
|
|
|
foreach ($ideprod->infoprocjud as $prodprocjud) { |
|
362
|
|
|
$infoProcJud = $this->dom->createElement("infoProcJud"); |
|
363
|
|
|
$infoProcJud->setAttribute('nrProcJud', $prodprocjud->nrprocjud); |
|
364
|
|
|
$infoProcJud->setAttribute('codSusp', $prodprocjud->codsusp); |
|
365
|
|
|
$infoProcJud->setAttribute( |
|
366
|
|
|
'vrCPNRet', |
|
367
|
|
|
number_format($prodprocjud->vrcpnret, 2, '.', '') |
|
368
|
|
|
); |
|
369
|
|
|
$infoProcJud->setAttribute( |
|
370
|
|
|
'vrRatNRet', |
|
371
|
|
|
number_format($prodprocjud->vrratnret, 2, '.', '') |
|
372
|
|
|
); |
|
373
|
|
|
$infoProcJud->setAttribute( |
|
374
|
|
|
'vrSenarNRet', |
|
375
|
|
|
number_format($prodprocjud->vrsenarnret, 2, '.', '') |
|
376
|
|
|
); |
|
377
|
|
|
$ideProdutor->appendChild($infoProcJud); |
|
378
|
|
|
} |
|
379
|
|
|
$tpAquis->appendChild($ideProdutor); |
|
380
|
|
|
if (!empty($tp->infoprocj)) { |
|
381
|
|
|
foreach ($tp->infoprocj as $procjud) { |
|
382
|
|
|
$procJ = $this->dom->createElement("infoProcJ"); |
|
383
|
|
|
$procJ->setAttribute('nrProcJud', $procjud->nrprocjud); |
|
384
|
|
|
$procJ->setAttribute('codSusp', $procjud->codsusp); |
|
385
|
|
|
$procJ->setAttribute( |
|
386
|
|
|
'vrCPNRet', |
|
387
|
|
|
number_format($procjud->vrcpnret, 2, '.', '') |
|
388
|
|
|
); |
|
389
|
|
|
$procJ->setAttribute( |
|
390
|
|
|
'vrRatNRet', |
|
391
|
|
|
number_format($procjud->vrratnret, 2, '.', '') |
|
392
|
|
|
); |
|
393
|
|
|
$procJ->setAttribute( |
|
394
|
|
|
'vrSenarNRet', |
|
395
|
|
|
number_format($procjud->vrsenarnret, 2, '.', '') |
|
396
|
|
|
); |
|
397
|
|
|
$tpAquis->appendChild($procJ); |
|
398
|
|
|
} |
|
399
|
|
|
} |
|
400
|
|
|
} |
|
401
|
|
|
$ideEstabAdquir->appendChild($tpAquis); |
|
402
|
|
|
} |
|
403
|
|
|
} |
|
404
|
|
|
} |
|
405
|
|
|
|
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: