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