node-sped-nfe 1.0.6 → 1.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +188 -0
- package/dist/utils/extras.js +204 -0
- package/dist/utils/make.d.ts +3 -2
- package/dist/utils/make.js +53 -13
- package/dist/utils/tools.d.ts +2 -1
- package/dist/utils/tools.js +39 -4
- package/docs/xml.md +81 -81
- package/exemplos/status.js +4 -1
- package/package.json +5 -3
- package/src/utils/extras.ts +223 -0
- package/src/utils/make.ts +56 -15
- package/src/utils/tools.ts +37 -5
package/LICENSE.md
ADDED
@@ -0,0 +1,188 @@
|
|
1
|
+
GNU LESSER GENERAL PUBLIC LICENSE
|
2
|
+
Version 3, 29 June 2007
|
3
|
+
|
4
|
+
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
5
|
+
Everyone is permitted to copy and distribute verbatim copies
|
6
|
+
of this license document, but changing it is not allowed.
|
7
|
+
|
8
|
+
|
9
|
+
This version of the GNU Lesser General Public License incorporates
|
10
|
+
the terms and conditions of version 3 of the GNU General Public
|
11
|
+
License, supplemented by the additional permissions listed below.
|
12
|
+
|
13
|
+
0. Additional Definitions.
|
14
|
+
|
15
|
+
As used herein, "this License" refers to version 3 of the GNU Lesser
|
16
|
+
General Public License, and the "GNU GPL" refers to version 3 of the GNU
|
17
|
+
General Public License.
|
18
|
+
|
19
|
+
"The Library" refers to a covered work governed by this License,
|
20
|
+
other than an Application or a Combined Work as defined below.
|
21
|
+
|
22
|
+
An "Application" is any work that makes use of an interface provided
|
23
|
+
by the Library, but which is not otherwise based on the Library.
|
24
|
+
Defining a subclass of a class defined by the Library is deemed a mode
|
25
|
+
of using an interface provided by the Library.
|
26
|
+
|
27
|
+
A "Combined Work" is a work produced by combining or linking an
|
28
|
+
Application with the Library. The particular version of the Library
|
29
|
+
with which the Combined Work was made is also called the "Linked
|
30
|
+
Version".
|
31
|
+
|
32
|
+
The "Minimal Corresponding Source" for a Combined Work means the
|
33
|
+
Corresponding Source for the Combined Work, excluding any source code
|
34
|
+
for portions of the Combined Work that, considered in isolation, are
|
35
|
+
based on the Application, and not on the Linked Version.
|
36
|
+
|
37
|
+
The "Corresponding Application Code" for a Combined Work means the
|
38
|
+
object code and/or source code for the Application, including any data
|
39
|
+
and utility programs needed for reproducing the Combined Work from the
|
40
|
+
Application, but excluding the System Libraries of the Combined Work.
|
41
|
+
|
42
|
+
1. Exception to Section 3 of the GNU GPL.
|
43
|
+
|
44
|
+
You may convey a covered work under sections 3 and 4 of this License
|
45
|
+
without being bound by section 3 of the GNU GPL.
|
46
|
+
|
47
|
+
2. Conveying Modified Versions.
|
48
|
+
|
49
|
+
If you modify a copy of the Library, and, in your modifications, a
|
50
|
+
facility refers to a function or data to be supplied by an Application
|
51
|
+
that uses the facility (other than as an argument passed when the
|
52
|
+
facility is invoked), then you may convey a copy of the modified
|
53
|
+
version:
|
54
|
+
|
55
|
+
a) under this License, provided that you make a good faith effort to
|
56
|
+
ensure that, in the event an Application does not supply the
|
57
|
+
function or data, the facility still operates, and performs
|
58
|
+
whatever part of its purpose remains meaningful, or
|
59
|
+
|
60
|
+
b) under the GNU GPL, with none of the additional permissions of
|
61
|
+
this License applicable to that copy.
|
62
|
+
|
63
|
+
3. Object Code Incorporating Material from Library Header Files.
|
64
|
+
|
65
|
+
The object code form of an Application may incorporate material from
|
66
|
+
a header file that is part of the Library. You may convey such object
|
67
|
+
code under terms of your choice, provided that, if the incorporated
|
68
|
+
material is not limited to numerical parameters, data structure
|
69
|
+
layouts and accessors, or small macros, inline functions and templates
|
70
|
+
(ten or fewer lines in length), you do both of the following:
|
71
|
+
|
72
|
+
a) Give prominent notice with each copy of the object code that the
|
73
|
+
Library is used in it and that the Library and its use are
|
74
|
+
covered by this License.
|
75
|
+
|
76
|
+
b) Accompany the object code with a copy of the GNU GPL and this license
|
77
|
+
document.
|
78
|
+
|
79
|
+
4. Combined Works.
|
80
|
+
|
81
|
+
You may convey a Combined Work under terms of your choice that,
|
82
|
+
taken together, effectively do not restrict modification of the
|
83
|
+
portions of the Library contained in the Combined Work and reverse
|
84
|
+
engineering for debugging such modifications, if you also do each of
|
85
|
+
the following:
|
86
|
+
|
87
|
+
a) Give prominent notice with each copy of the Combined Work that
|
88
|
+
the Library is used in it and that the Library and its use are
|
89
|
+
covered by this License.
|
90
|
+
|
91
|
+
b) Accompany the Combined Work with a copy of the GNU GPL and this license
|
92
|
+
document.
|
93
|
+
|
94
|
+
c) For a Combined Work that displays copyright notices during
|
95
|
+
execution, include the copyright notice for the Library among
|
96
|
+
these notices, as well as a reference directing the user to the
|
97
|
+
copies of the GNU GPL and this license document.
|
98
|
+
|
99
|
+
d) Do one of the following:
|
100
|
+
|
101
|
+
0) Convey the Minimal Corresponding Source under the terms of this
|
102
|
+
License, and the Corresponding Application Code in a form
|
103
|
+
suitable for, and under terms that permit, the user to
|
104
|
+
recombine or relink the Application with a modified version of
|
105
|
+
the Linked Version to produce a modified Combined Work, in the
|
106
|
+
manner specified by section 6 of the GNU GPL for conveying
|
107
|
+
Corresponding Source.
|
108
|
+
|
109
|
+
1) Use a suitable shared library mechanism for linking with the
|
110
|
+
Library. A suitable mechanism is one that (a) uses at run time
|
111
|
+
a copy of the Library already present on the user's computer
|
112
|
+
system, and (b) will operate properly with a modified version
|
113
|
+
of the Library that is interface-compatible with the Linked
|
114
|
+
Version.
|
115
|
+
|
116
|
+
e) Provide Installation Information, but only if you would otherwise
|
117
|
+
be required to provide such information under section 6 of the
|
118
|
+
GNU GPL, and only to the extent that such information is
|
119
|
+
necessary to install and execute a modified version of the
|
120
|
+
Combined Work produced by recombining or relinking the
|
121
|
+
Application with a modified version of the Linked Version. (If
|
122
|
+
you use option 4d0, the Installation Information must accompany
|
123
|
+
the Minimal Corresponding Source and Corresponding Application
|
124
|
+
Code. If you use option 4d1, you must provide the Installation
|
125
|
+
Information in the manner specified by section 6 of the GNU GPL
|
126
|
+
for conveying Corresponding Source.)
|
127
|
+
|
128
|
+
5. Combined Libraries.
|
129
|
+
|
130
|
+
You may place library facilities that are a work based on the
|
131
|
+
Library side by side in a single library together with other library
|
132
|
+
facilities that are not Applications and are not covered by this
|
133
|
+
License, and convey such a combined library under terms of your
|
134
|
+
choice, if you do both of the following:
|
135
|
+
|
136
|
+
a) Accompany the combined library with a copy of the same work based
|
137
|
+
on the Library, uncombined with any other library facilities,
|
138
|
+
conveyed under the terms of this License.
|
139
|
+
|
140
|
+
b) Give prominent notice with the combined library that part of it
|
141
|
+
is a work based on the Library, and explaining where to find the
|
142
|
+
accompanying uncombined form of the same work.
|
143
|
+
|
144
|
+
6. Revised Versions of the GNU Lesser General Public License.
|
145
|
+
|
146
|
+
The Free Software Foundation may publish revised and/or new versions
|
147
|
+
of the GNU Lesser General Public License from time to time. Such new
|
148
|
+
versions will be similar in spirit to the present version, but may
|
149
|
+
differ in detail to address new problems or concerns.
|
150
|
+
|
151
|
+
Each version is given a distinguishing version number. If the
|
152
|
+
Library as you received it specifies that a certain numbered version
|
153
|
+
of the GNU Lesser General Public License "or any later version"
|
154
|
+
applies to it, you have the option of following the terms and
|
155
|
+
conditions either of that published version or of any later version
|
156
|
+
published by the Free Software Foundation. If the Library as you
|
157
|
+
received it does not specify a version number of the GNU Lesser
|
158
|
+
General Public License, you may choose any version of the GNU Lesser
|
159
|
+
General Public License ever published by the Free Software Foundation.
|
160
|
+
|
161
|
+
If the Library as you received it specifies that a proxy can decide
|
162
|
+
whether future versions of the GNU Lesser General Public License shall
|
163
|
+
apply, that proxy's public statement of acceptance of any version is
|
164
|
+
permanent authorization for you to choose that version for the
|
165
|
+
Library.
|
166
|
+
|
167
|
+
============================================================
|
168
|
+
MIT LICENCE
|
169
|
+
============================================================
|
170
|
+
Copyright (c) 2016 NFePHP
|
171
|
+
|
172
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
173
|
+
of this software and associated documentation files (the "Software"), to deal
|
174
|
+
in the Software without restriction, including without limitation the rights
|
175
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
176
|
+
copies of the Software, and to permit persons to whom the Software is
|
177
|
+
furnished to do so, subject to the following conditions:
|
178
|
+
|
179
|
+
The above copyright notice and this permission notice shall be included in
|
180
|
+
all copies or substantial portions of the Software.
|
181
|
+
|
182
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
183
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
184
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
185
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
186
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
187
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
188
|
+
THE SOFTWARE.
|
package/dist/utils/extras.js
CHANGED
@@ -55,4 +55,208 @@ const cUF2UF = {
|
|
55
55
|
"GO": "52",
|
56
56
|
"DF": "53"
|
57
57
|
};
|
58
|
+
//Função auxliar de imposto
|
59
|
+
const impEstrutura = (imposto) => {
|
60
|
+
const gStruct = {
|
61
|
+
ICMS: {
|
62
|
+
ICMS_ICMSSN: {
|
63
|
+
"@label": "Tributação",
|
64
|
+
"@type": "select",
|
65
|
+
"@obrig": true,
|
66
|
+
"@values": [
|
67
|
+
{ "102": "Tributação Normal" },
|
68
|
+
{ "103": "Simples Nacional" }
|
69
|
+
],
|
70
|
+
"@next": {
|
71
|
+
CST: {
|
72
|
+
"@label": "Situação Tributaria",
|
73
|
+
"@type": "select",
|
74
|
+
"@obrig": true,
|
75
|
+
"@values": [
|
76
|
+
{ "00": "00 - Tributada integralmente" },
|
77
|
+
{ "10": "10 - Tributada com cobrança do ICMS por ST" },
|
78
|
+
{ "10v2": "10 - Tributada com cobrança do ICMS por ST(com partilha do ICMS entre UF de origem e a UF de destino ou a UFdefinida na legislação)" },
|
79
|
+
{ "20": "20 - Com redução de base de cálculo" },
|
80
|
+
{ "30": "30 - Isenta ou não tributada e com cobrança do ICMS por ST" },
|
81
|
+
{ "40": "40 - Isenta" },
|
82
|
+
{ "41": "41 - Não tributada" },
|
83
|
+
{ "41v2": "41 - Não tributada (ICMSST devido para UF de destino, nas operações interestaduais de produtos que tiveram retenção de ICMS na UF do rementente)" },
|
84
|
+
{ "50": "50 - Suspensão" },
|
85
|
+
{ "51": "51 - Diferimento" },
|
86
|
+
{ "60": "60 - Cobrado anteriormente por ST" },
|
87
|
+
{ "60v2": "60 - Cobrado anteriormente por ST" },
|
88
|
+
{ "70": "70 - Com redução de base de cálculo e cobrança do ICMS por ST" },
|
89
|
+
{ "90": "90 - Outros (Com partilha do ICMS entre a UF de origem e a UF de destino ou a UF definida na legistação)" },
|
90
|
+
{ "90v2": "90 - Outros" },
|
91
|
+
],
|
92
|
+
},
|
93
|
+
orig: {
|
94
|
+
"@label": "Origem",
|
95
|
+
"@type": "select",
|
96
|
+
"@obrig": true,
|
97
|
+
"@values": [
|
98
|
+
{ "0": "Nacional, exceto as indicadas nos códigos 3, 4, 5 e 8" },
|
99
|
+
{ "1": "Estrangeira - Importação direta, exceto a indicada no código 6" },
|
100
|
+
{ "2": "Estrangeira - Adquirida no mercado interno, exceto a indicada no código 7" },
|
101
|
+
{ "3": "Nacional, mercadoria ou bem com Conteúdo de Importação superior a 40% e inferior ou igual a 70%" },
|
102
|
+
{ "4": "Nacional, cuja produção tenha sido feita em conformidade com os processos produtivos básicos de que tratam as legislações citadas nos Ajustes" },
|
103
|
+
{ "5": "Nacional, mercadoria ou bem com Conteúdo de Importação inferior ou igual a 40% " },
|
104
|
+
{ "6": "Estrangeira - Importação direta, sem similar nacional, constante em lista da CAMEX e gás natural" },
|
105
|
+
{ "7": "Estrangeira - Adquirida no mercado interno, sem similar nacional, constante lista CAMEX e gás natural" }
|
106
|
+
],
|
107
|
+
},
|
108
|
+
"@next": {
|
109
|
+
"@CST_00": {
|
110
|
+
modBC: {
|
111
|
+
"@label": "Modalidade de determinação da base de calculo ICMS",
|
112
|
+
"@type": "select",
|
113
|
+
"@obrig": true,
|
114
|
+
"@values": [
|
115
|
+
{ "0": "0-Margem Valor Agregado (%)" },
|
116
|
+
{ "1": "1-Pauta (Valor)" },
|
117
|
+
{ "2": "2-Preço Tabelado Máx" },
|
118
|
+
{ "3": "3-Valor da operação" }
|
119
|
+
],
|
120
|
+
},
|
121
|
+
vBC: {
|
122
|
+
"@label": "Base de calculo ICMS",
|
123
|
+
"@type": "input",
|
124
|
+
"@obrig": true,
|
125
|
+
},
|
126
|
+
pICMS: {
|
127
|
+
"@label": "Líquota do ICMS",
|
128
|
+
"@type": "input",
|
129
|
+
"@obrig": true,
|
130
|
+
},
|
131
|
+
vICMS: {
|
132
|
+
"@label": "Valor ICMS",
|
133
|
+
"@type": "input",
|
134
|
+
"@obrig": true,
|
135
|
+
},
|
136
|
+
pFCP: {
|
137
|
+
"@label": "% Relativo ao FCP ST",
|
138
|
+
"@type": "input",
|
139
|
+
"@obrig": false,
|
140
|
+
},
|
141
|
+
vFCP: {
|
142
|
+
"@label": "Valor ICMS FCP ST",
|
143
|
+
"@type": "input",
|
144
|
+
"@obrig": false,
|
145
|
+
}
|
146
|
+
},
|
147
|
+
"@CST_10": {
|
148
|
+
modBC: {
|
149
|
+
"@label": "Modalidade de determinação da base de calculo ICMS",
|
150
|
+
"@type": "select",
|
151
|
+
"@obrig": true,
|
152
|
+
"@values": [
|
153
|
+
{ "0": "0-Margem Valor Agregado (%)" },
|
154
|
+
{ "1": "1-Pauta (Valor)" },
|
155
|
+
{ "2": "2-Preço Tabelado Máx" },
|
156
|
+
{ "3": "3-Valor da operação" }
|
157
|
+
],
|
158
|
+
},
|
159
|
+
vBC: {
|
160
|
+
"@label": "Base de calculo ICMS",
|
161
|
+
"@type": "input",
|
162
|
+
"@obrig": true,
|
163
|
+
},
|
164
|
+
pICMS: {
|
165
|
+
"@label": "Líquota do ICMS",
|
166
|
+
"@type": "input",
|
167
|
+
"@obrig": true,
|
168
|
+
},
|
169
|
+
vICMS: {
|
170
|
+
"@label": "Valor ICMS",
|
171
|
+
"@type": "input",
|
172
|
+
"@obrig": true,
|
173
|
+
},
|
174
|
+
modBCST: {
|
175
|
+
"@label": "Modalidade de determinação da BC do ICMS ST",
|
176
|
+
"@type": "select",
|
177
|
+
"@obrig": true,
|
178
|
+
"@values": [
|
179
|
+
{ "0": "Preço tabelado ou máximo sugerido" },
|
180
|
+
{ "1": "Lista Negativa (valor)" },
|
181
|
+
{ "2": "Lista Positiva (valor)" },
|
182
|
+
{ "3": "Lista Neutra (valor)" },
|
183
|
+
{ "4": "Margem Valor Agregado (%)" },
|
184
|
+
{ "5": "Pauta (valor)" },
|
185
|
+
{ "6": "Valor da Operação (NT 2019.001)" }
|
186
|
+
],
|
187
|
+
},
|
188
|
+
pMVAST: {
|
189
|
+
"@label": "% Margem de valor adic. ICMS ST",
|
190
|
+
"@type": "input",
|
191
|
+
"@obrig": true,
|
192
|
+
},
|
193
|
+
pRedBCST: {
|
194
|
+
"@label": "% Redução de BC ICMS ST",
|
195
|
+
"@type": "input",
|
196
|
+
"@obrig": true,
|
197
|
+
},
|
198
|
+
vBCST: {
|
199
|
+
"@label": "BC ICMS ST",
|
200
|
+
"@type": "input",
|
201
|
+
"@obrig": true,
|
202
|
+
},
|
203
|
+
pICMSST: {
|
204
|
+
"@label": "Alíquota de ICMS ST",
|
205
|
+
"@type": "input",
|
206
|
+
"@obrig": true,
|
207
|
+
},
|
208
|
+
vICMSST: {
|
209
|
+
"@label": "ICMS ST",
|
210
|
+
"@type": "input",
|
211
|
+
"@obrig": true,
|
212
|
+
},
|
213
|
+
vBCFCPST: {
|
214
|
+
"@label": "BC ICMS FCP ST",
|
215
|
+
"@type": "input",
|
216
|
+
"@obrig": true,
|
217
|
+
},
|
218
|
+
pFCPST: {
|
219
|
+
"@label": "% Relativo ao FCP ST",
|
220
|
+
"@type": "input",
|
221
|
+
"@obrig": true,
|
222
|
+
},
|
223
|
+
vFCPST: {
|
224
|
+
"@label": "Valor ICMS FCP ST",
|
225
|
+
"@type": "input",
|
226
|
+
"@obrig": true,
|
227
|
+
},
|
228
|
+
vBCFCP: {
|
229
|
+
"@label": "BC ICMS FCP",
|
230
|
+
"@type": "input",
|
231
|
+
"@obrig": false,
|
232
|
+
},
|
233
|
+
pFCP: {
|
234
|
+
"@label": "% Relativo ao FCP",
|
235
|
+
"@type": "input",
|
236
|
+
"@obrig": false,
|
237
|
+
},
|
238
|
+
vFCP: {
|
239
|
+
"@label": "Valor ICMS FCP",
|
240
|
+
"@type": "input",
|
241
|
+
"@obrig": false,
|
242
|
+
},
|
243
|
+
}
|
244
|
+
}
|
245
|
+
}
|
246
|
+
},
|
247
|
+
},
|
248
|
+
II: {},
|
249
|
+
ICMSint: {},
|
250
|
+
IPI: {},
|
251
|
+
IPIDev: {},
|
252
|
+
ISSQN: {},
|
253
|
+
COFINS: {},
|
254
|
+
PIS: {}
|
255
|
+
};
|
256
|
+
//Configurar valores
|
257
|
+
let configStruct = async (el, struc) => {
|
258
|
+
return el;
|
259
|
+
};
|
260
|
+
imposto = configStruct(imposto, gStruct);
|
261
|
+
};
|
58
262
|
export { cUF2UF, UF2cUF };
|
package/dist/utils/make.d.ts
CHANGED
@@ -16,10 +16,11 @@ declare class Make {
|
|
16
16
|
tagAutXML(obj: any): void;
|
17
17
|
tagProd(obj: any): void;
|
18
18
|
tagCreditoPresumidoProd(obj: any): void;
|
19
|
-
taginfAdProd(obj: any): void;
|
19
|
+
taginfAdProd(index: any, obj: any): void;
|
20
20
|
tagCEST(obj: any): void;
|
21
21
|
tagRECOPI(obj: any): void;
|
22
|
-
|
22
|
+
tagDI(index: any, obj: any): void;
|
23
|
+
tagAdi(index: any, obj: any): void;
|
23
24
|
tagDetExport(obj: any): void;
|
24
25
|
tagDetExportInd(obj: any): void;
|
25
26
|
tagRastro(obj: any): void;
|
package/dist/utils/make.js
CHANGED
@@ -63,19 +63,34 @@ class Make {
|
|
63
63
|
});
|
64
64
|
}
|
65
65
|
tagRefNFe(obj) {
|
66
|
-
|
66
|
+
if (typeof __classPrivateFieldGet(this, _Make_NFe, "f").infNFe.ide.NFref == "undefined") {
|
67
|
+
__classPrivateFieldGet(this, _Make_NFe, "f").infNFe.ide.NFref = new Array();
|
68
|
+
}
|
69
|
+
__classPrivateFieldGet(this, _Make_NFe, "f").infNFe.ide.NFref.push({ refNFe: obj });
|
67
70
|
}
|
68
71
|
tagRefNF(obj) {
|
69
|
-
|
72
|
+
if (typeof __classPrivateFieldGet(this, _Make_NFe, "f").infNFe.ide.NFref == "undefined") {
|
73
|
+
__classPrivateFieldGet(this, _Make_NFe, "f").infNFe.ide.NFref = new Array();
|
74
|
+
}
|
75
|
+
__classPrivateFieldGet(this, _Make_NFe, "f").infNFe.ide.NFref.push({ refNF: obj });
|
70
76
|
}
|
71
77
|
tagRefNFP(obj) {
|
72
|
-
|
78
|
+
if (typeof __classPrivateFieldGet(this, _Make_NFe, "f").infNFe.ide.NFref == "undefined") {
|
79
|
+
__classPrivateFieldGet(this, _Make_NFe, "f").infNFe.ide.NFref = new Array();
|
80
|
+
}
|
81
|
+
__classPrivateFieldGet(this, _Make_NFe, "f").infNFe.ide.NFref.push({ refNFP: obj });
|
73
82
|
}
|
74
83
|
tagRefCTe(obj) {
|
75
|
-
|
84
|
+
if (typeof __classPrivateFieldGet(this, _Make_NFe, "f").infNFe.ide.NFref == "undefined") {
|
85
|
+
__classPrivateFieldGet(this, _Make_NFe, "f").infNFe.ide.NFref = new Array();
|
86
|
+
}
|
87
|
+
__classPrivateFieldGet(this, _Make_NFe, "f").infNFe.ide.NFref.push({ refCTe: obj });
|
76
88
|
}
|
77
89
|
tagRefECF(obj) {
|
78
|
-
|
90
|
+
if (typeof __classPrivateFieldGet(this, _Make_NFe, "f").infNFe.ide.NFref == "undefined") {
|
91
|
+
__classPrivateFieldGet(this, _Make_NFe, "f").infNFe.ide.NFref = new Array();
|
92
|
+
}
|
93
|
+
__classPrivateFieldGet(this, _Make_NFe, "f").infNFe.ide.NFref.push({ refECF: obj });
|
79
94
|
}
|
80
95
|
tagEmit(obj) {
|
81
96
|
__classPrivateFieldGet(this, _Make_NFe, "f").infNFe.emit = new Object();
|
@@ -111,10 +126,16 @@ class Make {
|
|
111
126
|
});
|
112
127
|
}
|
113
128
|
tagRetirada(obj) {
|
114
|
-
|
129
|
+
__classPrivateFieldGet(this, _Make_NFe, "f").infNFe.retirada = {};
|
130
|
+
Object.keys(obj).forEach(key => {
|
131
|
+
__classPrivateFieldGet(this, _Make_NFe, "f").infNFe.retirada[key] = obj[key];
|
132
|
+
});
|
115
133
|
}
|
116
134
|
tagAutXML(obj) {
|
117
|
-
|
135
|
+
if (typeof __classPrivateFieldGet(this, _Make_NFe, "f").infNFe.autXML == "undefined") {
|
136
|
+
__classPrivateFieldGet(this, _Make_NFe, "f").infNFe.autXML = new Array();
|
137
|
+
}
|
138
|
+
__classPrivateFieldGet(this, _Make_NFe, "f").infNFe.autXML.push(obj);
|
118
139
|
}
|
119
140
|
//tagprod
|
120
141
|
tagProd(obj) {
|
@@ -145,8 +166,10 @@ class Make {
|
|
145
166
|
tagCreditoPresumidoProd(obj) {
|
146
167
|
throw "não implementado!";
|
147
168
|
}
|
148
|
-
taginfAdProd(obj) {
|
149
|
-
|
169
|
+
taginfAdProd(index, obj) {
|
170
|
+
Object.keys(obj).forEach(key => {
|
171
|
+
__classPrivateFieldGet(this, _Make_NFe, "f").infNFe.det[index][key] = obj[key];
|
172
|
+
});
|
150
173
|
}
|
151
174
|
tagCEST(obj) {
|
152
175
|
throw "não implementado!";
|
@@ -154,8 +177,25 @@ class Make {
|
|
154
177
|
tagRECOPI(obj) {
|
155
178
|
throw "não implementado!";
|
156
179
|
}
|
157
|
-
|
158
|
-
|
180
|
+
tagDI(index, obj) {
|
181
|
+
if (__classPrivateFieldGet(this, _Make_NFe, "f").infNFe.det[index].DI === undefined)
|
182
|
+
__classPrivateFieldGet(this, _Make_NFe, "f").infNFe.det[index].DI = {};
|
183
|
+
Object.keys(obj).forEach(key => {
|
184
|
+
__classPrivateFieldGet(this, _Make_NFe, "f").infNFe.det[index].DI[key] = obj[key];
|
185
|
+
});
|
186
|
+
//Adicionar ao imposto global
|
187
|
+
__classPrivateFieldGet(this, _Make_instances, "m", _Make_calICMSTot).call(this, obj);
|
188
|
+
}
|
189
|
+
tagAdi(index, obj) {
|
190
|
+
if (__classPrivateFieldGet(this, _Make_NFe, "f").infNFe.det[index].DI === undefined)
|
191
|
+
__classPrivateFieldGet(this, _Make_NFe, "f").infNFe.det[index].DI = {};
|
192
|
+
if (__classPrivateFieldGet(this, _Make_NFe, "f").infNFe.det[index].DI.adi === undefined)
|
193
|
+
__classPrivateFieldGet(this, _Make_NFe, "f").infNFe.det[index].DI.adi = {};
|
194
|
+
Object.keys(obj).forEach(key => {
|
195
|
+
__classPrivateFieldGet(this, _Make_NFe, "f").infNFe.det[index].DI.adi[key] = obj[key];
|
196
|
+
});
|
197
|
+
//Adicionar ao imposto global
|
198
|
+
__classPrivateFieldGet(this, _Make_instances, "m", _Make_calICMSTot).call(this, obj);
|
159
199
|
}
|
160
200
|
tagDetExport(obj) {
|
161
201
|
throw "não implementado!";
|
@@ -517,10 +557,10 @@ class Make {
|
|
517
557
|
__classPrivateFieldGet(this, _Make_NFe, "f").infNFe[`@Id`] = `NFe${__classPrivateFieldGet(this, _Make_instances, "m", _Make_gerarChaveNFe).call(this)}`;
|
518
558
|
//Adicionar QrCode
|
519
559
|
if (__classPrivateFieldGet(this, _Make_NFe, "f").infNFe.ide.mod == 65) {
|
520
|
-
//Como ja temos cUF,
|
560
|
+
//Como ja temos cUF, vamos usar o extras.cUF2UF
|
521
561
|
let tempUF = urlEventos(cUF2UF[__classPrivateFieldGet(this, _Make_NFe, "f").infNFe.ide.cUF], __classPrivateFieldGet(this, _Make_NFe, "f").infNFe['@versao']);
|
522
562
|
__classPrivateFieldGet(this, _Make_NFe, "f").infNFeSupl = {
|
523
|
-
qrCode: tempUF.mod65[__classPrivateFieldGet(this, _Make_NFe, "f").infNFe.ide.tpAmb == 1 ? 'producao' : 'homologacao'].NFeConsultaQR,
|
563
|
+
qrCode: tempUF.mod65[__classPrivateFieldGet(this, _Make_NFe, "f").infNFe.ide.tpAmb == 1 ? 'producao' : 'homologacao'].NFeConsultaQR, //Este não e o valor final, vamos utilizar apenas para carregar os dados que vão ser utlizados no make
|
524
564
|
urlChave: tempUF.mod65[__classPrivateFieldGet(this, _Make_NFe, "f").infNFe.ide.tpAmb == 1 ? 'producao' : 'homologacao'].urlChave
|
525
565
|
};
|
526
566
|
}
|
package/dist/utils/tools.d.ts
CHANGED
@@ -8,6 +8,7 @@ declare class Tools {
|
|
8
8
|
CSC: string;
|
9
9
|
CSCid: string;
|
10
10
|
versao: string;
|
11
|
+
timeout: number;
|
11
12
|
}, certificado?: {
|
12
13
|
pfx: string;
|
13
14
|
senha: string;
|
@@ -16,7 +17,7 @@ declare class Tools {
|
|
16
17
|
xmlSign(xmlJSON: string, data?: any): Promise<string>;
|
17
18
|
xml2json(xml: string): Promise<object>;
|
18
19
|
json2xml(obj: object): Promise<string>;
|
19
|
-
getCertificado(): Promise<
|
20
|
+
getCertificado(): Promise<object>;
|
20
21
|
consultarNFe(chNFe: string): Promise<string>;
|
21
22
|
sefazStatus(): Promise<string>;
|
22
23
|
}
|
package/dist/utils/tools.js
CHANGED
@@ -23,7 +23,7 @@ import pem from 'pem';
|
|
23
23
|
const __filename = fileURLToPath(import.meta.url);
|
24
24
|
const __dirname = path.dirname(__filename);
|
25
25
|
class Tools {
|
26
|
-
constructor(config = { mod: "", xmllint: 'xmllint', UF: '', tpAmb: 2, CSC: "", CSCid: "", versao: "4.00" }, certificado = { pfx: "", senha: "" }) {
|
26
|
+
constructor(config = { mod: "", xmllint: 'xmllint', UF: '', tpAmb: 2, CSC: "", CSCid: "", versao: "4.00", timeout: 30 }, certificado = { pfx: "", senha: "" }) {
|
27
27
|
_Tools_instances.add(this);
|
28
28
|
_Tools_cert.set(this, void 0);
|
29
29
|
_Tools_xmlTools.set(this, {
|
@@ -36,6 +36,18 @@ class Tools {
|
|
36
36
|
ca: [] // Uma lista de certificados da cadeia (se houver), ou null
|
37
37
|
});
|
38
38
|
_Tools_config.set(this, void 0);
|
39
|
+
if (typeof config != "object")
|
40
|
+
throw "Tools({config},{}): Config deve ser um objecto!";
|
41
|
+
if (typeof config.UF == "undefined")
|
42
|
+
throw "Tools({...,UF:?},{}): UF não definida!";
|
43
|
+
if (typeof config.tpAmb == "undefined")
|
44
|
+
throw "Tools({...,tpAmb:?},{}): tpAmb não definida!";
|
45
|
+
if (typeof config.versao == "undefined")
|
46
|
+
throw "Tools({...,versao:?},{}): versao não definida!";
|
47
|
+
if (typeof config.timeout == "undefined")
|
48
|
+
config.timeout = 30;
|
49
|
+
if (typeof config.xmllint == "undefined")
|
50
|
+
config.xmllint = 'xmllint';
|
39
51
|
//Configurar certificado
|
40
52
|
__classPrivateFieldSet(this, _Tools_config, config, "f");
|
41
53
|
__classPrivateFieldSet(this, _Tools_cert, certificado, "f");
|
@@ -101,6 +113,13 @@ class Tools {
|
|
101
113
|
resvol(data);
|
102
114
|
});
|
103
115
|
});
|
116
|
+
req.setTimeout(__classPrivateFieldGet(this, _Tools_config, "f").timeout * 1000, () => {
|
117
|
+
reject({
|
118
|
+
name: 'TimeoutError',
|
119
|
+
message: 'The operation was aborted due to timeout'
|
120
|
+
});
|
121
|
+
req.destroy(); // cancela a requisição
|
122
|
+
});
|
104
123
|
req.on('error', (erro) => {
|
105
124
|
reject(erro);
|
106
125
|
});
|
@@ -166,7 +185,7 @@ class Tools {
|
|
166
185
|
xml.NFe.infNFeSupl.qrCode = __classPrivateFieldGet(this, _Tools_instances, "m", _Tools_gerarQRCodeNFCe).call(this, xml.NFe, "2", __classPrivateFieldGet(this, _Tools_config, "f").CSCid, __classPrivateFieldGet(this, _Tools_config, "f").CSC);
|
167
186
|
}
|
168
187
|
this.json2xml(xml).then(async (res) => {
|
169
|
-
__classPrivateFieldGet(this, _Tools_instances, "m", _Tools_xmlValido).call(this, res,
|
188
|
+
__classPrivateFieldGet(this, _Tools_instances, "m", _Tools_xmlValido).call(this, res, `nfe_v${__classPrivateFieldGet(this, _Tools_config, "f").versao}`);
|
170
189
|
resvol(res);
|
171
190
|
}).catch(err => {
|
172
191
|
reject(err);
|
@@ -183,11 +202,13 @@ class Tools {
|
|
183
202
|
resvol(__classPrivateFieldGet(this, _Tools_xmlTools, "f").XMLBuilder.build(obj));
|
184
203
|
});
|
185
204
|
}
|
205
|
+
//Obter certificado
|
186
206
|
async getCertificado() {
|
187
207
|
return new Promise(async (resvol, reject) => {
|
188
208
|
__classPrivateFieldGet(this, _Tools_instances, "m", _Tools_certTools).call(this).then(resvol).catch(reject);
|
189
209
|
});
|
190
210
|
}
|
211
|
+
//Consulta NFe
|
191
212
|
consultarNFe(chNFe) {
|
192
213
|
return new Promise(async (resolve, reject) => {
|
193
214
|
if (!chNFe || chNFe.length !== 44) {
|
@@ -223,7 +244,7 @@ class Tools {
|
|
223
244
|
attributeNamePrefix: "@"
|
224
245
|
});
|
225
246
|
// Validação do XML interno (opcional)
|
226
|
-
__classPrivateFieldGet(this, _Tools_instances, "m", _Tools_xmlValido).call(this, builder.build({ consSitNFe }),
|
247
|
+
__classPrivateFieldGet(this, _Tools_instances, "m", _Tools_xmlValido).call(this, builder.build({ consSitNFe }), `consSitNFe_v${__classPrivateFieldGet(this, _Tools_config, "f").versao}`);
|
227
248
|
const xml = builder.build(xmlObj);
|
228
249
|
let tempUF = urlEventos(__classPrivateFieldGet(this, _Tools_config, "f").UF, __classPrivateFieldGet(this, _Tools_config, "f").versao);
|
229
250
|
const url = tempUF[`mod${__classPrivateFieldGet(this, _Tools_config, "f").mod}`][(__classPrivateFieldGet(this, _Tools_config, "f").tpAmb == 1 ? "producao" : "homologacao")].NFeConsultaProtocolo;
|
@@ -240,6 +261,13 @@ class Tools {
|
|
240
261
|
res.on('data', (chunk) => data += chunk);
|
241
262
|
res.on('end', () => resolve(data));
|
242
263
|
});
|
264
|
+
req.setTimeout(__classPrivateFieldGet(this, _Tools_config, "f").timeout * 1000, () => {
|
265
|
+
reject({
|
266
|
+
name: 'TimeoutError',
|
267
|
+
message: 'The operation was aborted due to timeout'
|
268
|
+
});
|
269
|
+
req.destroy(); // cancela a requisição
|
270
|
+
});
|
243
271
|
req.on('error', (err) => reject(err));
|
244
272
|
req.write(xml);
|
245
273
|
req.end();
|
@@ -284,7 +312,7 @@ class Tools {
|
|
284
312
|
attributeNamePrefix: "@"
|
285
313
|
});
|
286
314
|
//Validação
|
287
|
-
__classPrivateFieldGet(this, _Tools_instances, "m", _Tools_xmlValido).call(this, tempBuild.build({ consStatServ }),
|
315
|
+
__classPrivateFieldGet(this, _Tools_instances, "m", _Tools_xmlValido).call(this, tempBuild.build({ consStatServ }), `consStatServ_v${__classPrivateFieldGet(this, _Tools_config, "f").versao}`);
|
288
316
|
let tempUF = urlEventos(__classPrivateFieldGet(this, _Tools_config, "f").UF, __classPrivateFieldGet(this, _Tools_config, "f").versao);
|
289
317
|
let xml = tempBuild.build(xmlObj);
|
290
318
|
const req = https.request(tempUF[`mod${__classPrivateFieldGet(this, _Tools_config, "f").mod}`][(__classPrivateFieldGet(this, _Tools_config, "f").tpAmb == 1 ? "producao" : "homologacao")].NFeStatusServico, {
|
@@ -306,6 +334,13 @@ class Tools {
|
|
306
334
|
resvol(data);
|
307
335
|
});
|
308
336
|
});
|
337
|
+
req.setTimeout(__classPrivateFieldGet(this, _Tools_config, "f").timeout * 1000, () => {
|
338
|
+
reject({
|
339
|
+
name: 'TimeoutError',
|
340
|
+
message: 'The operation was aborted due to timeout'
|
341
|
+
});
|
342
|
+
req.destroy(); // cancela a requisição
|
343
|
+
});
|
309
344
|
req.on('error', (erro) => {
|
310
345
|
reject(erro);
|
311
346
|
});
|