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 EvtFechamentoeFinanceira 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 = 'evtFechamentoeFinanceira'; |
28
|
|
|
$params->evtTag = 'evtFechamentoeFinanceira'; |
29
|
|
|
$params->evtAlias = 'F-4000'; |
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
|
|
|
$infoFechamento = $this->dom->createElement("infoFechamento"); |
72
|
|
|
$this->dom->addChild( |
73
|
|
|
$infoFechamento, |
74
|
|
|
"dtInicio", |
75
|
|
|
$this->std->dtinicio, |
76
|
|
|
true |
77
|
|
|
); |
78
|
|
|
$this->dom->addChild( |
79
|
|
|
$infoFechamento, |
80
|
|
|
"dtFim", |
81
|
|
|
$this->std->dtfim, |
82
|
|
|
true |
83
|
|
|
); |
84
|
|
|
$this->dom->addChild( |
85
|
|
|
$infoFechamento, |
86
|
|
|
"sitEspecial", |
87
|
|
|
$this->std->sitespecial, |
88
|
|
|
true |
89
|
|
|
); |
90
|
|
|
$this->node->insertBefore($infoFechamento); |
91
|
|
|
|
92
|
|
View Code Duplication |
if (!empty($this->std->fechamentopp)) { |
|
|
|
|
93
|
|
|
$fpp = $this->std->fechamentopp; |
94
|
|
|
$FechamentoPP = $this->dom->createElement("FechamentoPP"); |
95
|
|
|
foreach ($fpp->fechamentomes as $fm) { |
96
|
|
|
$FechamentoMes = $this->dom->createElement("FechamentoMes"); |
97
|
|
|
$this->dom->addChild( |
98
|
|
|
$FechamentoMes, |
99
|
|
|
"anoMesCaixa", |
100
|
|
|
$fm->anomescaixa, |
101
|
|
|
true |
102
|
|
|
); |
103
|
|
|
$this->dom->addChild( |
104
|
|
|
$FechamentoMes, |
105
|
|
|
"quantArqTrans", |
106
|
|
|
$fm->quantarqtrans, |
107
|
|
|
true |
108
|
|
|
); |
109
|
|
|
$FechamentoPP->appendChild($FechamentoMes); |
110
|
|
|
} |
111
|
|
|
$this->node->appendChild($FechamentoPP); |
112
|
|
|
} |
113
|
|
|
|
114
|
|
|
if (!empty($this->std->fechamentomovopfin)) { |
115
|
|
|
$opfin = $this->std->fechamentomovopfin; |
116
|
|
|
$FechamentoMovOpFin = $this->dom->createElement("FechamentoMovOpFin"); |
117
|
|
|
foreach ($opfin->fechamentomes as $fm) { |
118
|
|
|
$FechamentoMes = $this->dom->createElement("FechamentoMes"); |
119
|
|
|
$this->dom->addChild( |
120
|
|
|
$FechamentoMes, |
121
|
|
|
"anoMesCaixa", |
122
|
|
|
$fm->anomescaixa, |
123
|
|
|
true |
124
|
|
|
); |
125
|
|
|
$this->dom->addChild( |
126
|
|
|
$FechamentoMes, |
127
|
|
|
"quantArqTrans", |
128
|
|
|
$fm->quantarqtrans, |
129
|
|
|
true |
130
|
|
|
); |
131
|
|
|
$FechamentoMovOpFin->appendChild($FechamentoMes); |
132
|
|
|
} |
133
|
|
|
if (!empty($opfin->entdecexterior)) { |
134
|
|
|
$EntDecExterior = $this->dom->createElement("EntDecExterior"); |
135
|
|
|
$this->dom->addChild( |
136
|
|
|
$EntDecExterior, |
137
|
|
|
"ContasAReportar", |
138
|
|
|
$opfin->entdecexterior->contasareportar, |
139
|
|
|
true |
140
|
|
|
); |
141
|
|
|
$FechamentoMovOpFin->appendChild($EntDecExterior); |
142
|
|
|
} |
143
|
|
|
|
144
|
|
|
if (!empty($opfin->entpatdecexterior)) { |
145
|
|
|
foreach ($opfin->entpatdecexterior as $ex) { |
146
|
|
|
$EntPatDecExterior = $this->dom->createElement("EntPatDecExterior"); |
147
|
|
|
$this->dom->addChild( |
148
|
|
|
$EntPatDecExterior, |
149
|
|
|
"GIIN", |
150
|
|
|
$ex->giin, |
151
|
|
|
true |
152
|
|
|
); |
153
|
|
|
$this->dom->addChild( |
154
|
|
|
$EntPatDecExterior, |
155
|
|
|
"CNPJ", |
156
|
|
|
$ex->cnpj, |
157
|
|
|
true |
158
|
|
|
); |
159
|
|
|
$this->dom->addChild( |
160
|
|
|
$EntPatDecExterior, |
161
|
|
|
"ContasAReportar", |
162
|
|
|
$ex->contasareportar, |
163
|
|
|
true |
164
|
|
|
); |
165
|
|
|
$FechamentoMovOpFin->appendChild($EntPatDecExterior); |
166
|
|
|
} |
167
|
|
|
} |
168
|
|
|
$this->node->appendChild($FechamentoMovOpFin); |
169
|
|
|
} |
170
|
|
|
|
171
|
|
View Code Duplication |
if (!empty($this->std->fechamentomovopfinanual)) { |
|
|
|
|
172
|
|
|
$f = $this->std->fechamentomovopfinanual->fechamentoano; |
173
|
|
|
$fechaAno = $this->dom->createElement("FechamentoMovOpFinAnual"); |
174
|
|
|
$fAno = $this->dom->createElement("FechamentoAno"); |
175
|
|
|
$this->dom->addChild( |
176
|
|
|
$fAno, |
177
|
|
|
"anoCaixa", |
178
|
|
|
$f->anocaixa, |
179
|
|
|
true |
180
|
|
|
); |
181
|
|
|
$this->dom->addChild( |
182
|
|
|
$fAno, |
183
|
|
|
"quantArqTrans", |
184
|
|
|
$f->quantarqtrans, |
185
|
|
|
true |
186
|
|
|
); |
187
|
|
|
$fechaAno->appendChild($fAno); |
188
|
|
|
$this->node->appendChild($fechaAno); |
189
|
|
|
} |
190
|
|
|
|
191
|
|
|
//finalização do xml |
192
|
|
|
$this->eFinanceira->appendChild($this->node); |
193
|
|
|
//$this->xml = $this->dom->saveXML($this->eFinanceira); |
194
|
|
|
$this->sign($this->evtTag); |
195
|
|
|
} |
196
|
|
|
} |
197
|
|
|
|
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.