1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace NFePHP\eFinanc\Factories; |
4
|
|
|
|
5
|
|
|
use NFePHP\eFinanc\Common\Factory; |
6
|
|
|
use NFePHP\eFinanc\Common\FactoryInterface; |
7
|
|
|
use NFePHP\eFinanc\Common\FactoryId; |
8
|
|
|
use NFePHP\Common\Certificate; |
9
|
|
|
use stdClass; |
10
|
|
|
|
11
|
|
|
class EvtMovPP extends Factory implements FactoryInterface |
12
|
|
|
{ |
13
|
|
|
|
14
|
|
|
/** |
15
|
|
|
* Constructor |
16
|
|
|
* @param string $config |
17
|
|
|
* @param stdClass $std |
18
|
|
|
* @param Certificate $certificate |
19
|
|
|
* @param string $data |
20
|
|
|
*/ |
21
|
|
|
public function __construct( |
22
|
|
|
$config, |
23
|
|
|
stdClass $std, |
24
|
|
|
Certificate $certificate = null, |
25
|
|
|
$data = '' |
26
|
|
|
) { |
27
|
|
|
$params = new \stdClass(); |
28
|
|
|
$params->evtName = 'evtMovPP'; |
29
|
|
|
$params->evtTag = 'evtMovPP'; |
30
|
|
|
$params->evtAlias = 'F-6000'; |
31
|
|
|
parent::__construct($config, $std, $params, $certificate, $data); |
32
|
|
|
} |
33
|
|
|
|
34
|
|
|
protected function toNode() |
35
|
|
|
{ |
36
|
|
|
$ideDeclarante = $this->node->getElementsByTagName('ideDeclarante')->item(0); |
37
|
|
|
//o idEvento pode variar de evento para evento |
38
|
|
|
//então cada factory individualmente terá de construir o seu |
39
|
|
|
$ideEvento = $this->dom->createElement("ideEvento"); |
40
|
|
|
$this->dom->addChild( |
41
|
|
|
$ideEvento, |
42
|
|
|
"indRetificacao", |
43
|
|
|
$this->std->indretificacao, |
44
|
|
|
true |
45
|
|
|
); |
46
|
|
|
$this->dom->addChild( |
47
|
|
|
$ideEvento, |
48
|
|
|
"nrRecibo", |
49
|
|
|
isset($this->std->nrrecibo) ? $this->std->nrrecibo : null, |
50
|
|
|
false |
51
|
|
|
); |
52
|
|
|
$this->dom->addChild( |
53
|
|
|
$ideEvento, |
54
|
|
|
"tpAmb", |
55
|
|
|
(string) $this->tpAmb, |
56
|
|
|
true |
57
|
|
|
); |
58
|
|
|
$this->dom->addChild( |
59
|
|
|
$ideEvento, |
60
|
|
|
"aplicEmi", |
61
|
|
|
'1', |
62
|
|
|
true |
63
|
|
|
); |
64
|
|
|
$this->dom->addChild( |
65
|
|
|
$ideEvento, |
66
|
|
|
"verAplic", |
67
|
|
|
$this->verAplic, |
68
|
|
|
true |
69
|
|
|
); |
70
|
|
|
$this->node->insertBefore($ideEvento, $ideDeclarante); |
71
|
|
|
|
72
|
|
|
$ideDeclarado = $this->dom->createElement("ideDeclarado"); |
73
|
|
|
$this->dom->addChild( |
74
|
|
|
$ideDeclarado, |
75
|
|
|
"tpNI", |
76
|
|
|
$this->std->tpni, |
77
|
|
|
true |
78
|
|
|
); |
79
|
|
|
$this->dom->addChild( |
80
|
|
|
$ideDeclarado, |
81
|
|
|
"NIDeclarado", |
82
|
|
|
$this->std->nideclarado, |
83
|
|
|
true |
84
|
|
|
); |
85
|
|
|
$this->dom->addChild( |
86
|
|
|
$ideDeclarado, |
87
|
|
|
"NomeDeclarado", |
88
|
|
|
$this->std->nomedeclarado, |
89
|
|
|
true |
90
|
|
|
); |
91
|
|
|
$this->node->appendChild($ideDeclarado); |
92
|
|
|
|
93
|
|
|
$mesCaixa = $this->dom->createElement("mesCaixa"); |
94
|
|
|
$this->dom->addChild( |
95
|
|
|
$mesCaixa, |
96
|
|
|
"anoMesCaixa", |
97
|
|
|
$this->std->anomescaixa, |
98
|
|
|
true |
99
|
|
|
); |
100
|
|
|
foreach ($this->std->infoprevpriv as $infp) { |
101
|
|
|
$infoPrevPriv = $this->dom->createElement("infoPrevPriv"); |
102
|
|
|
$this->dom->addChild( |
103
|
|
|
$infoPrevPriv, |
104
|
|
|
"numProposta", |
105
|
|
|
!empty($infp->numproposta) ? $infp->numproposta : null, |
106
|
|
|
false |
107
|
|
|
); |
108
|
|
|
$this->dom->addChild( |
109
|
|
|
$infoPrevPriv, |
110
|
|
|
"numProcesso", |
111
|
|
|
!empty($infp->numprocesso) ? $infp->numprocesso : null, |
112
|
|
|
false |
113
|
|
|
); |
114
|
|
|
if (!empty($infp->produto)) { |
115
|
|
|
$prod = $this->dom->createElement("Produto"); |
116
|
|
|
$this->dom->addChild( |
117
|
|
|
$prod, |
118
|
|
|
"tpProduto", |
119
|
|
|
$infp->produto->tpproduto, |
120
|
|
|
true |
121
|
|
|
); |
122
|
|
|
$this->dom->addChild( |
123
|
|
|
$prod, |
124
|
|
|
"opcaoTributacao", |
125
|
|
|
$infp->produto->opcaotributacao, |
126
|
|
|
true |
127
|
|
|
); |
128
|
|
|
$infoPrevPriv->appendChild($prod); |
129
|
|
|
} |
130
|
|
|
$this->dom->addChild( |
131
|
|
|
$infoPrevPriv, |
132
|
|
|
"tpPlano", |
133
|
|
|
!empty($infp->tpplano) ? $infp->tpplano : null, |
134
|
|
|
false |
135
|
|
|
); |
136
|
|
|
|
137
|
|
|
$opPrevPriv = $this->dom->createElement("opPrevPriv"); |
138
|
|
|
$saldoInicial = $this->dom->createElement("saldoInicial"); |
139
|
|
|
$this->dom->addChild( |
140
|
|
|
$saldoInicial, |
141
|
|
|
"vlrPrincipal", |
142
|
|
|
number_format($infp->vlrprincipal, 2, ',', ''), |
143
|
|
|
true |
144
|
|
|
); |
145
|
|
|
$this->dom->addChild( |
146
|
|
|
$saldoInicial, |
147
|
|
|
"vlrRendimentos", |
148
|
|
|
isset($infp->vlrrendimentos) ? number_format($infp->vlrrendimentos, 2, ',', '') : null, |
149
|
|
|
false |
150
|
|
|
); |
151
|
|
|
$opPrevPriv->appendChild($saldoInicial); |
152
|
|
|
|
153
|
|
|
if (!empty($infp->aplic)) { |
154
|
|
|
foreach ($infp->aplic as $ap) { |
155
|
|
|
$aplic = $this->dom->createElement("aplic"); |
156
|
|
|
$this->dom->addChild( |
157
|
|
|
$aplic, |
158
|
|
|
"vlrContribuicao", |
159
|
|
|
number_format($ap->vlrcontribuicao, 2, ',', ''), |
160
|
|
|
true |
161
|
|
|
); |
162
|
|
|
$this->dom->addChild( |
163
|
|
|
$aplic, |
164
|
|
|
"vlrCarregamento", |
165
|
|
|
number_format($ap->vlrcarregamento, 2, ',', ''), |
166
|
|
|
true |
167
|
|
|
); |
168
|
|
|
$this->dom->addChild( |
169
|
|
|
$aplic, |
170
|
|
|
"vlrPartPF", |
171
|
|
|
number_format($ap->vlrpartpf, 2, ',', ''), |
172
|
|
|
true |
173
|
|
|
); |
174
|
|
|
$this->dom->addChild( |
175
|
|
|
$aplic, |
176
|
|
|
"vlrPartPJ", |
177
|
|
|
number_format($ap->vlrpartpj, 2, ',', ''), |
178
|
|
|
true |
179
|
|
|
); |
180
|
|
|
$this->dom->addChild( |
181
|
|
|
$aplic, |
182
|
|
|
"cnpj", |
183
|
|
|
isset($ap->cnpj) ? $ap->cnpj : null, |
184
|
|
|
false |
185
|
|
|
); |
186
|
|
|
$opPrevPriv->appendChild($aplic); |
187
|
|
|
} |
188
|
|
|
} |
189
|
|
|
if (!empty($infp->resg)) { |
190
|
|
|
foreach ($infp->resg as $rs) { |
191
|
|
|
$resg = $this->dom->createElement("resg"); |
192
|
|
|
$this->dom->addChild( |
193
|
|
|
$resg, |
194
|
|
|
"vlrAliquotaIRRF", |
195
|
|
|
number_format($rs->vlraliquotairrf, 2, ',', ''), |
196
|
|
|
true |
197
|
|
|
); |
198
|
|
|
$this->dom->addChild( |
199
|
|
|
$resg, |
200
|
|
|
"numAnosCarencia", |
201
|
|
|
number_format($rs->numanoscarencia, 2, ',', ''), |
202
|
|
|
true |
203
|
|
|
); |
204
|
|
|
$this->dom->addChild( |
205
|
|
|
$resg, |
206
|
|
|
"vlrResgatePrincipal", |
207
|
|
|
number_format($rs->vlrresgateprincipal, 2, ',', ''), |
208
|
|
|
true |
209
|
|
|
); |
210
|
|
|
$this->dom->addChild( |
211
|
|
|
$resg, |
212
|
|
|
"vlrResgateRendimentos", |
213
|
|
|
number_format($rs->vlrresgaterendimentos, 2, ',', ''), |
214
|
|
|
true |
215
|
|
|
); |
216
|
|
|
$this->dom->addChild( |
217
|
|
|
$resg, |
218
|
|
|
"vlrIRRF", |
219
|
|
|
number_format($rs->vlrirrf, 2, ',', ''), |
220
|
|
|
true |
221
|
|
|
); |
222
|
|
|
$opPrevPriv->appendChild($resg); |
223
|
|
|
} |
224
|
|
|
} |
225
|
|
|
|
226
|
|
|
if (!empty($infp->benef)) { |
227
|
|
|
foreach ($infp->benef as $bn) { |
228
|
|
|
$benef = $this->dom->createElement("benef"); |
229
|
|
|
$this->dom->addChild( |
230
|
|
|
$benef, |
231
|
|
|
"tpNI", |
232
|
|
|
$bn->tpni, |
233
|
|
|
true |
234
|
|
|
); |
235
|
|
|
$this->dom->addChild( |
236
|
|
|
$benef, |
237
|
|
|
"NIParticipante", |
238
|
|
|
$bn->niparticipante, |
239
|
|
|
true |
240
|
|
|
); |
241
|
|
|
$this->dom->addChild( |
242
|
|
|
$benef, |
243
|
|
|
"CodReceita", |
244
|
|
|
$bn->codreceita, |
245
|
|
|
true |
246
|
|
|
); |
247
|
|
|
$this->dom->addChild( |
248
|
|
|
$benef, |
249
|
|
|
"PrazoVigencia", |
250
|
|
|
$bn->prazovigencia, |
251
|
|
|
true |
252
|
|
|
); |
253
|
|
|
$this->dom->addChild( |
254
|
|
|
$benef, |
255
|
|
|
"vlrMensalInicial", |
256
|
|
|
number_format($bn->vlrmensalinicial, 2, ',', ''), |
257
|
|
|
true |
258
|
|
|
); |
259
|
|
|
$this->dom->addChild( |
260
|
|
|
$benef, |
261
|
|
|
"vlrBruto", |
262
|
|
|
number_format($bn->vlrbruto, 2, ',', ''), |
263
|
|
|
true |
264
|
|
|
); |
265
|
|
|
$this->dom->addChild( |
266
|
|
|
$benef, |
267
|
|
|
"vlrLiquido", |
268
|
|
|
number_format($bn->vlrliquido, 2, ',', ''), |
269
|
|
|
true |
270
|
|
|
); |
271
|
|
|
$this->dom->addChild( |
272
|
|
|
$benef, |
273
|
|
|
"vlrIRRF", |
274
|
|
|
number_format($bn->vlrirrf, 2, ',', ''), |
275
|
|
|
true |
276
|
|
|
); |
277
|
|
|
$this->dom->addChild( |
278
|
|
|
$benef, |
279
|
|
|
"vlrAliquotaIRRF", |
280
|
|
|
number_format($bn->vlraliquotairrf, 2, ',', ''), |
281
|
|
|
true |
282
|
|
|
); |
283
|
|
|
$this->dom->addChild( |
284
|
|
|
$benef, |
285
|
|
|
"competenciaPgto", |
286
|
|
|
$bn->competenciapgto, |
287
|
|
|
true |
288
|
|
|
); |
289
|
|
|
$opPrevPriv->appendChild($benef); |
290
|
|
|
} |
291
|
|
|
} |
292
|
|
|
|
293
|
|
|
$saldoFinal = $this->dom->createElement("saldoFinal"); |
294
|
|
|
$this->dom->addChild( |
295
|
|
|
$saldoFinal, |
296
|
|
|
"vlrPrincipal", |
297
|
|
|
number_format($infp->saldofinal->vlrprincipal, 2, ',', ''), |
298
|
|
|
true |
299
|
|
|
); |
300
|
|
|
$this->dom->addChild( |
301
|
|
|
$saldoFinal, |
302
|
|
|
"vlrRendimentos", |
303
|
|
|
isset($infp->saldofinal->vlrrendimentos) ? |
304
|
|
|
number_format($infp->saldofinal->vlrrendimentos, 2, ',', '') : |
305
|
|
|
null, |
306
|
|
|
false |
307
|
|
|
); |
308
|
|
|
$opPrevPriv->appendChild($saldoFinal); |
309
|
|
|
|
310
|
|
|
$infoPrevPriv->appendChild($opPrevPriv); |
311
|
|
|
|
312
|
|
|
$mesCaixa->appendChild($infoPrevPriv); |
313
|
|
|
} |
314
|
|
|
|
315
|
|
|
$this->node->appendChild($mesCaixa); |
316
|
|
|
//finalização do xml |
317
|
|
|
$this->eFinanceira->appendChild($this->node); |
318
|
|
|
//$this->xml = $this->dom->saveXML($this->eFinanceira); |
319
|
|
|
$this->sign($this->evtTag); |
320
|
|
|
} |
321
|
|
|
} |
322
|
|
|
|