node-sped-nfe 1.1.1 → 1.1.2
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/dist/utils/tools.d.ts +1 -0
- package/dist/utils/tools.js +8 -1
- package/package.json +1 -3
- package/saida.txt +0 -0
- package/testes/nfe.xml +285 -0
- package/testes/nfe_sign.xml +1 -0
- package/{exemplos/nfe.js → testes/teste.js} +12 -0
- package/xmlvalid.json +1 -0
- package/docs/README.md +0 -60
- package/docs/Tools.md +0 -105
- package/docs/requisitos.md +0 -26
- package/docs/xml.md +0 -1653
- package/exemplos/consulta.js +0 -19
- package/exemplos/nfce.js +0 -165
- package/exemplos/status.js +0 -22
- package/src/index.ts +0 -4
- package/src/utils/eventos.ts +0 -1487
- package/src/utils/extras.ts +0 -298
- package/src/utils/make.ts +0 -712
- package/src/utils/tools.ts +0 -436
package/src/utils/make.ts
DELETED
|
@@ -1,712 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
import { XMLParser, XMLBuilder, XMLValidator } from "fast-xml-parser";
|
|
3
|
-
import { urlEventos } from "./eventos.js"
|
|
4
|
-
import { cUF2UF } from "./extras.js"
|
|
5
|
-
|
|
6
|
-
//Classe da nota fiscal
|
|
7
|
-
class Make {
|
|
8
|
-
#NFe: {
|
|
9
|
-
[key: string]: any;
|
|
10
|
-
infNFe: { [key: string]: any }
|
|
11
|
-
} = {
|
|
12
|
-
"@xmlns": "http://www.portalfiscal.inf.br/nfe",
|
|
13
|
-
infNFe: {
|
|
14
|
-
"@xmlns": "http://www.portalfiscal.inf.br/nfe",
|
|
15
|
-
}
|
|
16
|
-
};
|
|
17
|
-
#ICMSTot: Record<string, number> = {
|
|
18
|
-
vBC: 0,
|
|
19
|
-
vICMS: 0,
|
|
20
|
-
vICMSDeson: 0,
|
|
21
|
-
vFCP: 0,
|
|
22
|
-
vBCST: 0,
|
|
23
|
-
vST: 0,
|
|
24
|
-
vFCPST: 0,
|
|
25
|
-
vFCPSTRet: 0,
|
|
26
|
-
vProd: 0,
|
|
27
|
-
vFrete: 0,
|
|
28
|
-
vSeg: 0,
|
|
29
|
-
vDesc: 0,
|
|
30
|
-
vII: 0,
|
|
31
|
-
vIPI: 0,
|
|
32
|
-
vIPIDevol: 0,
|
|
33
|
-
vPIS: 0,
|
|
34
|
-
vCOFINS: 0,
|
|
35
|
-
vOutro: 0,
|
|
36
|
-
vNF: 0
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
formatData(dataUsr = new Date()) {
|
|
40
|
-
const ano = dataUsr.getFullYear();
|
|
41
|
-
const mes = String(dataUsr.getMonth() + 1).padStart(2, '0'); // Adiciona 1 porque os meses começam do 0
|
|
42
|
-
const dia = String(dataUsr.getDate()).padStart(2, '0');
|
|
43
|
-
const horas = String(dataUsr.getHours()).padStart(2, '0');
|
|
44
|
-
const minutos = String(dataUsr.getMinutes()).padStart(2, '0');
|
|
45
|
-
const segundos = String(dataUsr.getSeconds()).padStart(2, '0');
|
|
46
|
-
const fusoHorario = -dataUsr.getTimezoneOffset() / 60; // Obtém o fuso horário em horas
|
|
47
|
-
const formatoISO = `${ano}-${mes}-${dia}T${horas}:${minutos}:${segundos}${fusoHorario >= 0 ? '+' : '-'}${String(Math.abs(fusoHorario)).padStart(2, '0')}:00`;
|
|
48
|
-
return formatoISO;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
//Optativa
|
|
52
|
-
tagInfNFe(obj: any) {
|
|
53
|
-
Object.keys(obj).forEach(key => {
|
|
54
|
-
this.#NFe.infNFe[`@${key}`] = obj[key];
|
|
55
|
-
});
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
tagIde(obj: any) {
|
|
59
|
-
this.#NFe.infNFe.ide = new Object();
|
|
60
|
-
Object.keys(obj).forEach(key => {
|
|
61
|
-
this.#NFe.infNFe.ide[key] = obj[key];
|
|
62
|
-
});
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
tagRefNFe(obj: any) {
|
|
66
|
-
if (typeof this.#NFe.infNFe.ide.NFref == "undefined") {
|
|
67
|
-
this.#NFe.infNFe.ide.NFref = new Array();
|
|
68
|
-
}
|
|
69
|
-
this.#NFe.infNFe.ide.NFref.push({ refNFe: obj });
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
tagRefNF(obj: any) {
|
|
73
|
-
if (typeof this.#NFe.infNFe.ide.NFref == "undefined") {
|
|
74
|
-
this.#NFe.infNFe.ide.NFref = new Array();
|
|
75
|
-
}
|
|
76
|
-
this.#NFe.infNFe.ide.NFref.push({ refNF: obj });
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
tagRefNFP(obj: any) {
|
|
80
|
-
if (typeof this.#NFe.infNFe.ide.NFref == "undefined") {
|
|
81
|
-
this.#NFe.infNFe.ide.NFref = new Array();
|
|
82
|
-
}
|
|
83
|
-
this.#NFe.infNFe.ide.NFref.push({ refNFP: obj });
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
tagRefCTe(obj: any) {
|
|
87
|
-
if (typeof this.#NFe.infNFe.ide.NFref == "undefined") {
|
|
88
|
-
this.#NFe.infNFe.ide.NFref = new Array();
|
|
89
|
-
}
|
|
90
|
-
this.#NFe.infNFe.ide.NFref.push({ refCTe: obj });
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
tagRefECF(obj: any) {
|
|
94
|
-
if (typeof this.#NFe.infNFe.ide.NFref == "undefined") {
|
|
95
|
-
this.#NFe.infNFe.ide.NFref = new Array();
|
|
96
|
-
}
|
|
97
|
-
this.#NFe.infNFe.ide.NFref.push({ refECF: obj });
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
tagEmit(obj: any) {
|
|
101
|
-
this.#NFe.infNFe.emit = new Object();
|
|
102
|
-
Object.keys(obj).forEach(key => {
|
|
103
|
-
this.#NFe.infNFe.emit[key] = obj[key];
|
|
104
|
-
if (key == "xFant") {
|
|
105
|
-
this.#NFe.infNFe.emit.enderEmit = {};
|
|
106
|
-
}
|
|
107
|
-
});
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
tagEnderEmit(obj: any) {
|
|
111
|
-
Object.keys(obj).forEach(key => {
|
|
112
|
-
this.#NFe.infNFe.emit.enderEmit[key] = obj[key];
|
|
113
|
-
});
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
tagDest(obj: any) {
|
|
117
|
-
this.#NFe.infNFe.dest = {};
|
|
118
|
-
if (this.#NFe.infNFe.ide.tpAmb == 2 && obj['xNome'] !== undefined) obj['xNome'] = "NF-E EMITIDA EM AMBIENTE DE HOMOLOGACAO - SEM VALOR FISCAL";
|
|
119
|
-
Object.keys(obj).forEach(key => {
|
|
120
|
-
this.#NFe.infNFe.dest[key] = obj[key];
|
|
121
|
-
if (key == "xNome" && this.#NFe.infNFe.ide.mod == 55) {
|
|
122
|
-
this.#NFe.infNFe.dest.enderDest = {};
|
|
123
|
-
}
|
|
124
|
-
});
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
tagEnderDest(obj: any) {
|
|
128
|
-
if (this.#NFe.infNFe.ide.mod == 65) return 1;
|
|
129
|
-
|
|
130
|
-
this.#NFe.infNFe.dest.enderDest = {};
|
|
131
|
-
Object.keys(obj).forEach(key => {
|
|
132
|
-
this.#NFe.infNFe.dest.enderDest[key] = obj[key];
|
|
133
|
-
});
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
tagRetirada(obj: any) {
|
|
137
|
-
this.#NFe.infNFe.retirada = {};
|
|
138
|
-
Object.keys(obj).forEach(key => {
|
|
139
|
-
this.#NFe.infNFe.retirada[key] = obj[key];
|
|
140
|
-
});
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
tagAutXML(obj: any) {
|
|
144
|
-
if (typeof this.#NFe.infNFe.autXML == "undefined") {
|
|
145
|
-
this.#NFe.infNFe.autXML = new Array();
|
|
146
|
-
}
|
|
147
|
-
this.#NFe.infNFe.autXML.push(obj);
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
//tagprod
|
|
151
|
-
tagProd(obj: any) {
|
|
152
|
-
//Abrir tag de imposto
|
|
153
|
-
for (let cont = 0; cont < obj.length; cont++) {
|
|
154
|
-
|
|
155
|
-
if (obj[cont]['@nItem'] === undefined) {
|
|
156
|
-
obj[cont] = { '@nItem': cont + 1, prod: obj[cont], imposto: {} };
|
|
157
|
-
} else {
|
|
158
|
-
obj[cont] = { '@nItem': obj[cont]['@nItem'], prod: obj[cont], imposto: {} };
|
|
159
|
-
delete obj[cont].prod['@nItem'];
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
//Primeiro item + NFCe + Homologação
|
|
163
|
-
if (cont == 0 && this.#NFe.infNFe.ide.mod == 65 && this.#NFe.infNFe.ide.tpAmb == 2) obj[cont].prod.xProd = "NOTA FISCAL EMITIDA EM AMBIENTE DE HOMOLOGACAO - SEM VALOR FISCAL";
|
|
164
|
-
|
|
165
|
-
obj[cont].prod.qCom = (obj[cont].prod.qCom * 1).toFixed(4)
|
|
166
|
-
obj[cont].prod.vUnCom = (obj[cont].prod.vUnCom * 1).toFixed(10)
|
|
167
|
-
obj[cont].prod.vProd = (obj[cont].prod.vProd * 1).toFixed(2)
|
|
168
|
-
|
|
169
|
-
if (obj[cont].prod.vDesc !== undefined) obj[cont].prod.vDesc = (obj[cont].prod.vDesc * 1).toFixed(2)
|
|
170
|
-
|
|
171
|
-
obj[cont].prod.qTrib = (obj[cont].prod.qTrib * 1).toFixed(4)
|
|
172
|
-
obj[cont].prod.vUnTrib = (obj[cont].prod.vUnTrib * 1).toFixed(10)
|
|
173
|
-
//Calcular ICMSTot
|
|
174
|
-
this.#calICMSTot(obj[cont].prod);
|
|
175
|
-
}
|
|
176
|
-
this.#NFe.infNFe.det = obj;
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
tagCreditoPresumidoProd(obj: any) {
|
|
180
|
-
throw "não implementado!";
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
taginfAdProd(index: any, obj: any) {
|
|
184
|
-
Object.keys(obj).forEach(key => {
|
|
185
|
-
this.#NFe.infNFe.det[index][key] = obj[key];
|
|
186
|
-
});
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
tagCEST(obj: any) {
|
|
190
|
-
throw "não implementado!";
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
tagRECOPI(obj: any) {
|
|
194
|
-
throw "não implementado!";
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
tagDI(index: any, obj: any) {
|
|
198
|
-
if (this.#NFe.infNFe.det[index].DI === undefined) this.#NFe.infNFe.det[index].DI = {};
|
|
199
|
-
Object.keys(obj).forEach(key => {
|
|
200
|
-
this.#NFe.infNFe.det[index].DI[key] = obj[key];
|
|
201
|
-
});
|
|
202
|
-
|
|
203
|
-
//Adicionar ao imposto global
|
|
204
|
-
this.#calICMSTot(obj);
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
tagAdi(index: any, obj: any) {
|
|
208
|
-
if (this.#NFe.infNFe.det[index].DI === undefined) this.#NFe.infNFe.det[index].DI = {};
|
|
209
|
-
if (this.#NFe.infNFe.det[index].DI.adi === undefined) this.#NFe.infNFe.det[index].DI.adi = {};
|
|
210
|
-
|
|
211
|
-
Object.keys(obj).forEach(key => {
|
|
212
|
-
this.#NFe.infNFe.det[index].DI.adi[key] = obj[key];
|
|
213
|
-
});
|
|
214
|
-
|
|
215
|
-
//Adicionar ao imposto global
|
|
216
|
-
this.#calICMSTot(obj);
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
tagDetExport(obj: any) {
|
|
220
|
-
throw "não implementado!";
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
tagDetExportInd(obj: any) {
|
|
224
|
-
throw "não implementado!";
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
tagRastro(obj: any) {
|
|
228
|
-
throw "não implementado!";
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
tagVeicProd(obj: any) {
|
|
232
|
-
throw "não implementado!";
|
|
233
|
-
}
|
|
234
|
-
|
|
235
|
-
tagMed(obj: any) {
|
|
236
|
-
throw "não implementado!";
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
tagArma(obj: any) {
|
|
240
|
-
throw "não implementado!";
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
tagComb(obj: any) {
|
|
244
|
-
throw "não implementado!";
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
tagEncerrante() {
|
|
248
|
-
throw "não implementado!";
|
|
249
|
-
}
|
|
250
|
-
|
|
251
|
-
tagOrigComb() {
|
|
252
|
-
throw "não implementado!";
|
|
253
|
-
}
|
|
254
|
-
|
|
255
|
-
tagImposto() {
|
|
256
|
-
throw "não implementado!";
|
|
257
|
-
}
|
|
258
|
-
|
|
259
|
-
tagProdICMS(index: any, obj: any) {
|
|
260
|
-
throw "não implementado!";
|
|
261
|
-
}
|
|
262
|
-
|
|
263
|
-
//
|
|
264
|
-
tagProdICMSST(index: any, obj: any) {
|
|
265
|
-
if (this.#NFe.infNFe.det[index].imposto.ICMS === undefined) this.#NFe.infNFe.det[index].imposto.ICMS = {};
|
|
266
|
-
|
|
267
|
-
this.#NFe.infNFe.det[index].imposto.ICMS.ICMSST = {};
|
|
268
|
-
Object.keys(obj).forEach(key => {
|
|
269
|
-
this.#NFe.infNFe.det[index].imposto.ICMS.ICMSST[key] = obj[key];
|
|
270
|
-
});
|
|
271
|
-
|
|
272
|
-
//Calcular ICMSTot
|
|
273
|
-
this.#calICMSTot(obj);
|
|
274
|
-
}
|
|
275
|
-
|
|
276
|
-
//
|
|
277
|
-
tagProdICMSSN(index: any, obj: any) {
|
|
278
|
-
if (this.#NFe.infNFe.det[index].imposto.ICMS === undefined) this.#NFe.infNFe.det[index].imposto.ICMS = {};
|
|
279
|
-
|
|
280
|
-
let keyXML = "";
|
|
281
|
-
switch (obj.CSOSN) {
|
|
282
|
-
case '101':
|
|
283
|
-
keyXML = 'ICMSSN101';
|
|
284
|
-
break;
|
|
285
|
-
case '102':
|
|
286
|
-
case '103':
|
|
287
|
-
case '300':
|
|
288
|
-
case '400':
|
|
289
|
-
keyXML = 'ICMSSN102';
|
|
290
|
-
break;
|
|
291
|
-
case '201':
|
|
292
|
-
keyXML = 'ICMSSN201';
|
|
293
|
-
break;
|
|
294
|
-
case '202':
|
|
295
|
-
case '203':
|
|
296
|
-
keyXML = 'ICMSSN202';
|
|
297
|
-
break;
|
|
298
|
-
case '500':
|
|
299
|
-
keyXML = 'ICMSSN500';
|
|
300
|
-
break;
|
|
301
|
-
case '900':
|
|
302
|
-
keyXML = 'ICMSSN900';
|
|
303
|
-
break;
|
|
304
|
-
default:
|
|
305
|
-
throw "CSOSN não identificado!";
|
|
306
|
-
break;
|
|
307
|
-
}
|
|
308
|
-
this.#NFe.infNFe.det[index].imposto.ICMS[keyXML] = {};
|
|
309
|
-
Object.keys(obj).forEach(key => {
|
|
310
|
-
this.#NFe.infNFe.det[index].imposto.ICMS[keyXML][key] = obj[key];
|
|
311
|
-
});
|
|
312
|
-
|
|
313
|
-
//Calcular ICMSTot
|
|
314
|
-
this.#calICMSTot(obj);
|
|
315
|
-
}
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
tagProdICMSUFDest(index: any, obj: any) {
|
|
319
|
-
throw "Não implementado!";
|
|
320
|
-
}
|
|
321
|
-
|
|
322
|
-
tagProdIPI(index: any, obj: any) {
|
|
323
|
-
throw "Não implementado!";
|
|
324
|
-
}
|
|
325
|
-
|
|
326
|
-
tagProdII(index: any, obj: any) {
|
|
327
|
-
throw "Não implementado!";
|
|
328
|
-
}
|
|
329
|
-
|
|
330
|
-
tagProdPIS(index: any, obj: any) {
|
|
331
|
-
if (this.#NFe.infNFe.det[index].imposto.PIS === undefined) this.#NFe.infNFe.det[index].imposto.PIS = {};
|
|
332
|
-
|
|
333
|
-
let keyXML = "";
|
|
334
|
-
switch (obj.CST) {
|
|
335
|
-
case '01':
|
|
336
|
-
case '02':
|
|
337
|
-
keyXML = 'PISAliq';
|
|
338
|
-
break;
|
|
339
|
-
case '03':
|
|
340
|
-
keyXML = 'PISQtde';
|
|
341
|
-
break;
|
|
342
|
-
case '04':
|
|
343
|
-
case '05':
|
|
344
|
-
case '06':
|
|
345
|
-
case '07':
|
|
346
|
-
case '08':
|
|
347
|
-
case '09':
|
|
348
|
-
keyXML = 'PISNT';
|
|
349
|
-
break;
|
|
350
|
-
case '49':
|
|
351
|
-
case '50':
|
|
352
|
-
case '51':
|
|
353
|
-
case '52':
|
|
354
|
-
case '53':
|
|
355
|
-
case '54':
|
|
356
|
-
case '55':
|
|
357
|
-
case '56':
|
|
358
|
-
case '60':
|
|
359
|
-
case '61':
|
|
360
|
-
case '62':
|
|
361
|
-
case '63':
|
|
362
|
-
case '64':
|
|
363
|
-
case '65':
|
|
364
|
-
case '66':
|
|
365
|
-
case '67':
|
|
366
|
-
case '70':
|
|
367
|
-
case '71':
|
|
368
|
-
case '72':
|
|
369
|
-
case '73':
|
|
370
|
-
case '74':
|
|
371
|
-
case '75':
|
|
372
|
-
case '98':
|
|
373
|
-
case '99':
|
|
374
|
-
keyXML = 'PISOutr';
|
|
375
|
-
break;
|
|
376
|
-
default:
|
|
377
|
-
throw "CSOSN não identificado!";
|
|
378
|
-
break;
|
|
379
|
-
|
|
380
|
-
}
|
|
381
|
-
this.#NFe.infNFe.det[index].imposto.PIS[keyXML] = {};
|
|
382
|
-
Object.keys(obj).forEach(key => {
|
|
383
|
-
this.#NFe.infNFe.det[index].imposto.PIS[keyXML][key] = obj[key];
|
|
384
|
-
});
|
|
385
|
-
|
|
386
|
-
//Calcular ICMSTot
|
|
387
|
-
this.#calICMSTot(obj);
|
|
388
|
-
}
|
|
389
|
-
|
|
390
|
-
tagProdPISST(index: any, obj: any) {
|
|
391
|
-
if (this.#NFe.infNFe.det[index].imposto.PIS === undefined) this.#NFe.infNFe.det[index].imposto.PIS = {};
|
|
392
|
-
|
|
393
|
-
this.#NFe.infNFe.det[index].imposto.PIS.PISST = {};
|
|
394
|
-
Object.keys(obj).forEach(key => {
|
|
395
|
-
this.#NFe.infNFe.det[index].imposto.PIS.PISST[key] = obj[key];
|
|
396
|
-
});
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
//Calcular ICMSTot
|
|
400
|
-
this.#calICMSTot(obj);
|
|
401
|
-
}
|
|
402
|
-
|
|
403
|
-
tagProdCOFINS(index: any, obj: any) {
|
|
404
|
-
if (this.#NFe.infNFe.det[index].imposto.COFINS === undefined) this.#NFe.infNFe.det[index].imposto.COFINS = {};
|
|
405
|
-
|
|
406
|
-
let keyXML = null;
|
|
407
|
-
switch (obj.CST) {
|
|
408
|
-
case '01':
|
|
409
|
-
case '02':
|
|
410
|
-
keyXML = null;
|
|
411
|
-
break;
|
|
412
|
-
case '03':
|
|
413
|
-
keyXML = "COFINSQtde";
|
|
414
|
-
break;
|
|
415
|
-
case '04':
|
|
416
|
-
case '05':
|
|
417
|
-
case '06':
|
|
418
|
-
case '07':
|
|
419
|
-
case '08':
|
|
420
|
-
case '09':
|
|
421
|
-
keyXML = "COFINSNT";
|
|
422
|
-
break;
|
|
423
|
-
case '49':
|
|
424
|
-
case '50':
|
|
425
|
-
case '51':
|
|
426
|
-
case '52':
|
|
427
|
-
case '53':
|
|
428
|
-
case '54':
|
|
429
|
-
case '55':
|
|
430
|
-
case '56':
|
|
431
|
-
case '60':
|
|
432
|
-
case '61':
|
|
433
|
-
case '62':
|
|
434
|
-
case '63':
|
|
435
|
-
case '64':
|
|
436
|
-
case '65':
|
|
437
|
-
case '66':
|
|
438
|
-
case '67':
|
|
439
|
-
case '70':
|
|
440
|
-
case '71':
|
|
441
|
-
case '72':
|
|
442
|
-
case '73':
|
|
443
|
-
case '74':
|
|
444
|
-
case '75':
|
|
445
|
-
case '98':
|
|
446
|
-
case '99':
|
|
447
|
-
keyXML = "COFINSOutr";
|
|
448
|
-
break;
|
|
449
|
-
}
|
|
450
|
-
|
|
451
|
-
if (keyXML == null) {
|
|
452
|
-
Object.keys(obj).forEach(key => {
|
|
453
|
-
this.#NFe.infNFe.det[index].imposto.COFINS[key] = obj[key];
|
|
454
|
-
});
|
|
455
|
-
} else {
|
|
456
|
-
this.#NFe.infNFe.det[index].imposto.COFINS[keyXML] = {};
|
|
457
|
-
Object.keys(obj).forEach(key => {
|
|
458
|
-
this.#NFe.infNFe.det[index].imposto.COFINS[keyXML][key] = obj[key];
|
|
459
|
-
});
|
|
460
|
-
}
|
|
461
|
-
|
|
462
|
-
//Calcular ICMSTot
|
|
463
|
-
this.#calICMSTot(obj);
|
|
464
|
-
}
|
|
465
|
-
|
|
466
|
-
tagProdCOFINSST(index: any, obj: any) {
|
|
467
|
-
if (this.#NFe.infNFe.det[index].imposto.COFINS === undefined) this.#NFe.infNFe.det[index].imposto.COFINS = {};
|
|
468
|
-
|
|
469
|
-
this.#NFe.infNFe.det[index].imposto.COFINS.COFINSST = {};
|
|
470
|
-
Object.keys(obj).forEach(key => {
|
|
471
|
-
this.#NFe.infNFe.det[index].imposto.PIS.COFINSST[key] = obj[key];
|
|
472
|
-
});
|
|
473
|
-
|
|
474
|
-
//Calcular ICMSTot
|
|
475
|
-
this.#calICMSTot(obj);
|
|
476
|
-
}
|
|
477
|
-
|
|
478
|
-
tagProdISSQN(index: any, obj: any) {
|
|
479
|
-
this.#NFe.infNFe.det[index].imposto.ISSQN = {};
|
|
480
|
-
Object.keys(obj).forEach(key => {
|
|
481
|
-
this.#NFe.infNFe.det[index].imposto.ISSQN[key] = obj[key];
|
|
482
|
-
});
|
|
483
|
-
|
|
484
|
-
//Calcular ICMSTot
|
|
485
|
-
this.#calICMSTot(obj);
|
|
486
|
-
}
|
|
487
|
-
|
|
488
|
-
tagProdImpostoDevol(index: any, obj: any) {
|
|
489
|
-
throw "Não implementado!";
|
|
490
|
-
}
|
|
491
|
-
|
|
492
|
-
tagICMSTot(obj = null) {
|
|
493
|
-
this.#NFe.infNFe.total = {
|
|
494
|
-
ICMSTot: {}
|
|
495
|
-
};
|
|
496
|
-
if (obj != null) {
|
|
497
|
-
Object.keys(obj).forEach(key => {
|
|
498
|
-
this.#NFe.infNFe.total.ICMSTot[key] = obj[key];
|
|
499
|
-
});
|
|
500
|
-
} else {
|
|
501
|
-
Object.keys(this.#ICMSTot).forEach(key => {
|
|
502
|
-
this.#NFe.infNFe.total.ICMSTot[key] = (this.#ICMSTot[key] * 1).toFixed(2);
|
|
503
|
-
});
|
|
504
|
-
this.#NFe.infNFe.total.ICMSTot.vNF = (this.#NFe.infNFe.total.ICMSTot.vProd - this.#NFe.infNFe.total.ICMSTot.vDesc).toFixed(2)
|
|
505
|
-
}
|
|
506
|
-
}
|
|
507
|
-
|
|
508
|
-
tagISSQNTot(obj: any) {
|
|
509
|
-
throw "Não implementado!";
|
|
510
|
-
}
|
|
511
|
-
|
|
512
|
-
tagRetTrib(obj: any) {
|
|
513
|
-
throw "Não implementado!";
|
|
514
|
-
}
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
tagTransp(obj: any) {
|
|
518
|
-
this.#NFe.infNFe.transp = {};
|
|
519
|
-
Object.keys(obj).forEach(key => {
|
|
520
|
-
this.#NFe.infNFe.transp[key] = obj[key];
|
|
521
|
-
});
|
|
522
|
-
}
|
|
523
|
-
|
|
524
|
-
tagTransporta(obj: any) {
|
|
525
|
-
throw "Não implementado!";
|
|
526
|
-
}
|
|
527
|
-
|
|
528
|
-
tagRetTransp(obj: any) {
|
|
529
|
-
throw "Não implementado!";
|
|
530
|
-
}
|
|
531
|
-
|
|
532
|
-
tagVeicTransp(obj: any) {
|
|
533
|
-
throw "Não implementado!";
|
|
534
|
-
}
|
|
535
|
-
|
|
536
|
-
tagReboque(obj: any) {
|
|
537
|
-
throw "Não implementado!";
|
|
538
|
-
}
|
|
539
|
-
|
|
540
|
-
tagVagao(obj: any) {
|
|
541
|
-
throw "Não implementado!";
|
|
542
|
-
}
|
|
543
|
-
|
|
544
|
-
tagBalsa(obj: any) {
|
|
545
|
-
throw "Não implementado!";
|
|
546
|
-
}
|
|
547
|
-
|
|
548
|
-
tagVol(obj: any) {
|
|
549
|
-
throw "Não implementado!";
|
|
550
|
-
}
|
|
551
|
-
|
|
552
|
-
tagLacres(obj: any) {
|
|
553
|
-
throw "Não implementado!";
|
|
554
|
-
}
|
|
555
|
-
|
|
556
|
-
tagFat(obj: any) {
|
|
557
|
-
throw "Não implementado!";
|
|
558
|
-
}
|
|
559
|
-
|
|
560
|
-
tagDup(obj: any) {
|
|
561
|
-
throw "Não implementado!";
|
|
562
|
-
}
|
|
563
|
-
|
|
564
|
-
//tagpag()
|
|
565
|
-
tagTroco(obj: any) {
|
|
566
|
-
if (this.#NFe.infNFe.pag === undefined) this.#NFe.infNFe.pag = {};
|
|
567
|
-
this.#NFe.infNFe.pag.vTroco = obj;
|
|
568
|
-
}
|
|
569
|
-
|
|
570
|
-
tagDetPag(obj: any) {
|
|
571
|
-
if (this.#NFe.infNFe.pag === undefined) this.#NFe.infNFe.pag = {};
|
|
572
|
-
this.#NFe.infNFe.pag.detPag = obj;
|
|
573
|
-
}
|
|
574
|
-
|
|
575
|
-
tagIntermed(obj: any) {
|
|
576
|
-
throw "Não implementado!";
|
|
577
|
-
}
|
|
578
|
-
|
|
579
|
-
tagInfAdic(obj: any) {
|
|
580
|
-
throw "Não implementado!";
|
|
581
|
-
}
|
|
582
|
-
|
|
583
|
-
tagObsCont(obj: any) {
|
|
584
|
-
throw "Não implementado!";
|
|
585
|
-
}
|
|
586
|
-
|
|
587
|
-
tagObsFisco(obj: any) {
|
|
588
|
-
throw "Não implementado!";
|
|
589
|
-
}
|
|
590
|
-
|
|
591
|
-
tagProcRef(obj: any) {
|
|
592
|
-
throw "Não implementado!";
|
|
593
|
-
}
|
|
594
|
-
|
|
595
|
-
tagExporta(obj: any) {
|
|
596
|
-
throw "Não implementado!";
|
|
597
|
-
}
|
|
598
|
-
|
|
599
|
-
tagCompra(obj: any) {
|
|
600
|
-
throw "Não implementado!";
|
|
601
|
-
}
|
|
602
|
-
|
|
603
|
-
tagCana(obj: any) {
|
|
604
|
-
throw "Não implementado!";
|
|
605
|
-
}
|
|
606
|
-
|
|
607
|
-
tagforDia() {
|
|
608
|
-
|
|
609
|
-
}
|
|
610
|
-
|
|
611
|
-
tagdeduc() {
|
|
612
|
-
|
|
613
|
-
}
|
|
614
|
-
|
|
615
|
-
taginfNFeSupl() {
|
|
616
|
-
|
|
617
|
-
}
|
|
618
|
-
|
|
619
|
-
tagInfRespTec(obj: any) {
|
|
620
|
-
if (this.#NFe.infNFe.infRespTec === undefined) this.#NFe.infNFe.infRespTec = {};
|
|
621
|
-
Object.keys(obj).forEach(key => {
|
|
622
|
-
this.#NFe.infNFe.infRespTec[key] = obj[key];
|
|
623
|
-
});
|
|
624
|
-
}
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
//Endereço para retirada
|
|
629
|
-
tagRetiEnder(obj: any) {
|
|
630
|
-
throw "Ainda não configurado!";
|
|
631
|
-
}
|
|
632
|
-
|
|
633
|
-
//Endereço para entrega
|
|
634
|
-
tagEntrega(obj: any) {
|
|
635
|
-
throw "Ainda não configurado!";
|
|
636
|
-
}
|
|
637
|
-
|
|
638
|
-
//Sistema gera a chave da nota fiscal
|
|
639
|
-
#gerarChaveNFe() {
|
|
640
|
-
const chaveSemDV =
|
|
641
|
-
this.#NFe.infNFe.ide.cUF.padStart(2, '0') + // Código da UF (2 dígitos)
|
|
642
|
-
this.#NFe.infNFe.ide.dhEmi.substring(2, 4) + this.#NFe.infNFe.ide.dhEmi.substring(5, 7) + // Ano e Mês da emissão (AAMM, 4 dígitos)
|
|
643
|
-
this.#NFe.infNFe.emit.CNPJ.padStart(14, '0') + // CNPJ do emitente (14 dígitos)
|
|
644
|
-
this.#NFe.infNFe.ide.mod.padStart(2, '0') + // Modelo da NF (2 dígitos)
|
|
645
|
-
this.#NFe.infNFe.ide.serie.padStart(3, '0') + // Série da NF (3 dígitos)
|
|
646
|
-
this.#NFe.infNFe.ide.nNF.padStart(9, '0') + // Número da NF (9 dígitos)
|
|
647
|
-
this.#NFe.infNFe.ide.tpEmis.padStart(1, '0') + // Tipo de Emissão (1 dígito)
|
|
648
|
-
this.#NFe.infNFe.ide.cNF.padStart(8, '0'); // Código Numérico da NF (8 dígitos)
|
|
649
|
-
this.#NFe.infNFe.ide.cDV = this.#calcularDigitoVerificador(chaveSemDV)
|
|
650
|
-
return `${chaveSemDV}${this.#NFe.infNFe.ide.cDV}`;
|
|
651
|
-
|
|
652
|
-
}
|
|
653
|
-
|
|
654
|
-
#calcularDigitoVerificador(key: any) {
|
|
655
|
-
if (key.length !== 43) {
|
|
656
|
-
return '';
|
|
657
|
-
}
|
|
658
|
-
|
|
659
|
-
const multipliers = [2, 3, 4, 5, 6, 7, 8, 9];
|
|
660
|
-
let iCount = 42;
|
|
661
|
-
let weightedSum = 0;
|
|
662
|
-
|
|
663
|
-
while (iCount >= 0) {
|
|
664
|
-
for (let mCount = 0; mCount < 8 && iCount >= 0; mCount++) {
|
|
665
|
-
const sub = parseInt(key[iCount], 10);
|
|
666
|
-
weightedSum += sub * multipliers[mCount];
|
|
667
|
-
iCount--;
|
|
668
|
-
}
|
|
669
|
-
}
|
|
670
|
-
|
|
671
|
-
let vdigit = 11 - (weightedSum % 11);
|
|
672
|
-
if (vdigit > 9) {
|
|
673
|
-
vdigit = 0;
|
|
674
|
-
}
|
|
675
|
-
|
|
676
|
-
return vdigit.toString();
|
|
677
|
-
}
|
|
678
|
-
|
|
679
|
-
xml() {
|
|
680
|
-
if (this.#NFe.infNFe[`@Id`] == null) this.#NFe.infNFe[`@Id`] = `NFe${this.#gerarChaveNFe()}`;
|
|
681
|
-
|
|
682
|
-
//Adicionar QrCode
|
|
683
|
-
if (this.#NFe.infNFe.ide.mod == 65) {
|
|
684
|
-
//Como ja temos cUF, vamos usar o extras.cUF2UF
|
|
685
|
-
let tempUF = urlEventos(cUF2UF[this.#NFe.infNFe.ide.cUF], this.#NFe.infNFe['@versao']);
|
|
686
|
-
this.#NFe.infNFeSupl = {
|
|
687
|
-
qrCode: tempUF.mod65[this.#NFe.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
|
|
688
|
-
urlChave: tempUF.mod65[this.#NFe.infNFe.ide.tpAmb == 1 ? 'producao' : 'homologacao'].urlChave
|
|
689
|
-
}
|
|
690
|
-
}
|
|
691
|
-
|
|
692
|
-
let tempBuild = new XMLBuilder({
|
|
693
|
-
ignoreAttributes: false,
|
|
694
|
-
attributeNamePrefix: "@"
|
|
695
|
-
});
|
|
696
|
-
return tempBuild.build({ NFe: this.#NFe });
|
|
697
|
-
}
|
|
698
|
-
|
|
699
|
-
//Obtem os dados de importo e soma no total, utlizado sempre que for setado algum imposto.
|
|
700
|
-
#calICMSTot(obj: any) {
|
|
701
|
-
Object.keys(obj).map(key => {
|
|
702
|
-
if (this.#ICMSTot[key] !== undefined) {
|
|
703
|
-
this.#ICMSTot[key] += 1 * (obj[key]);
|
|
704
|
-
}
|
|
705
|
-
});
|
|
706
|
-
|
|
707
|
-
}
|
|
708
|
-
}
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
export { Make }
|
|
712
|
-
export default { Make }
|