node-sped-nfe 1.0.0

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.
Files changed (37) hide show
  1. package/README.md +75 -0
  2. package/docs/README.md +49 -0
  3. package/docs/xml.md +1653 -0
  4. package/index.js +5 -0
  5. package/package.json +19 -0
  6. package/testes/assinar.js +16 -0
  7. package/testes/nfe.js +166 -0
  8. package/testes/nfe.json +194 -0
  9. package/testes/nfe.xml +292 -0
  10. package/testes/nfe_guara.xml +1 -0
  11. package/testes/nfe_guara_sign.xml +1 -0
  12. package/testes/nfe_guara_sign_lote.xml +1 -0
  13. package/testes/nfe_teste.json +45 -0
  14. package/utils/eventos.js +32 -0
  15. package/utils/make.js +798 -0
  16. package/utils/schemas/consReciNFe_v4.00.xsd +9 -0
  17. package/utils/schemas/consSitNFe_v4.00.xsd +9 -0
  18. package/utils/schemas/consStatServ_v4.00.xsd +9 -0
  19. package/utils/schemas/enviNFe_v4.00.xsd +9 -0
  20. package/utils/schemas/inutNFe_v4.00.xsd +9 -0
  21. package/utils/schemas/leiauteConsSitNFe_v4.00.xsd +502 -0
  22. package/utils/schemas/leiauteConsStatServ_v4.00.xsd +98 -0
  23. package/utils/schemas/leiauteInutNFe_v4.00.xsd +193 -0
  24. package/utils/schemas/leiauteNFe_v4.00.xsd +7412 -0
  25. package/utils/schemas/nfe_v4.00.xsd +9 -0
  26. package/utils/schemas/procInutNFe_v4.00.xsd +9 -0
  27. package/utils/schemas/procNFe_v4.00.xsd +9 -0
  28. package/utils/schemas/retConsReciNFe_v4.00.xsd +9 -0
  29. package/utils/schemas/retConsSitNFe_v4.00.xsd +9 -0
  30. package/utils/schemas/retConsStatServ_v4.00.xsd +9 -0
  31. package/utils/schemas/retEnviNFe_v4.00.xsd +9 -0
  32. package/utils/schemas/retInutNFe_v4.00.xsd +9 -0
  33. package/utils/schemas/tiposBasico_v4.00.xsd +598 -0
  34. package/utils/schemas/xmldsig-core-schema_v1.01.xsd +98 -0
  35. package/utils/sefaz.js +84 -0
  36. package/utils/tools.js +277 -0
  37. package/utils/xmllint.js +244195 -0
package/utils/make.js ADDED
@@ -0,0 +1,798 @@
1
+
2
+ import { XMLParser, XMLBuilder, XMLValidator } from "fast-xml-parser";
3
+
4
+ //Classe da nota fiscal
5
+ class Make {
6
+ #NFe = {
7
+ "@xmlns": "http://www.portalfiscal.inf.br/nfe",
8
+ infNFe: {
9
+ "@xmlns": "http://www.portalfiscal.inf.br/nfe",
10
+ }
11
+ };
12
+ #ICMSTot = {
13
+ vBC: 0,
14
+ vICMS: 0,
15
+ vICMSDeson: 0,
16
+ vFCP: 0,
17
+ vBCST: 0,
18
+ vST: 0,
19
+ vFCPST: 0,
20
+ vFCPSTRet: 0,
21
+ vProd: 0,
22
+ vFrete: 0,
23
+ vSeg: 0,
24
+ vDesc: 0,
25
+ vII: 0,
26
+ vIPI: 0,
27
+ vIPIDevol: 0,
28
+ vPIS: 0,
29
+ vCOFINS: 0,
30
+ vOutro: 0,
31
+ vNF: 0
32
+ };
33
+
34
+ formatData(dataUsr = new Date()) {
35
+ const ano = dataUsr.getFullYear();
36
+ const mes = String(dataUsr.getMonth() + 1).padStart(2, '0'); // Adiciona 1 porque os meses começam do 0
37
+ const dia = String(dataUsr.getDate()).padStart(2, '0');
38
+ const horas = String(dataUsr.getHours()).padStart(2, '0');
39
+ const minutos = String(dataUsr.getMinutes()).padStart(2, '0');
40
+ const segundos = String(dataUsr.getSeconds()).padStart(2, '0');
41
+ const fusoHorario = -dataUsr.getTimezoneOffset() / 60; // Obtém o fuso horário em horas
42
+ const formatoISO = `${ano}-${mes}-${dia}T${horas}:${minutos}:${segundos}${fusoHorario >= 0 ? '+' : '-'}${String(Math.abs(fusoHorario)).padStart(2, '0')}:00`;
43
+ return formatoISO;
44
+ }
45
+
46
+ //Optativa
47
+ tagInfNFe(obj) {
48
+ Object.keys(obj).forEach(key => {
49
+ this.#NFe.infNFe[`@${key}`] = obj[key];
50
+ });
51
+ }
52
+
53
+ tagIde(obj) {
54
+ this.#NFe.infNFe.ide = new Object();
55
+ Object.keys(obj).forEach(key => {
56
+ this.#NFe.infNFe.ide[key] = obj[key];
57
+ });
58
+ }
59
+
60
+ tagRefNFe(obj) {
61
+ throw "Não implementado!";
62
+ }
63
+
64
+ tagRefNF(obj) {
65
+ throw "Não implementado!";
66
+ }
67
+
68
+ tagRefNFP(obj) {
69
+ throw "Não implementado!";
70
+ }
71
+
72
+ tagRefCTe(obj) {
73
+ throw "Não implementado!";
74
+ }
75
+
76
+ tagRefECF(obj) {
77
+ throw "Não implementado!";
78
+ }
79
+
80
+ tagEmit(obj) {
81
+ this.#NFe.infNFe.emit = new Object();
82
+ Object.keys(obj).forEach(key => {
83
+ this.#NFe.infNFe.emit[key] = obj[key];
84
+ if (key == "xFant") {
85
+ this.#NFe.infNFe.emit.enderEmit = {};
86
+ }
87
+ });
88
+ }
89
+
90
+ tagEnderEmit(obj) {
91
+ Object.keys(obj).forEach(key => {
92
+ this.#NFe.infNFe.emit.enderEmit[key] = obj[key];
93
+ });
94
+ }
95
+
96
+ tagDest(obj) {
97
+ this.#NFe.infNFe.dest = {};
98
+ if (this.#NFe.infNFe.ide.tpAmb == 2 && obj['xNome'] !== undefined) obj['xNome'] = "NF-E EMITIDA EM AMBIENTE DE HOMOLOGACAO - SEM VALOR FISCAL";
99
+ Object.keys(obj).forEach(key => {
100
+ this.#NFe.infNFe.dest[key] = obj[key];
101
+ if (key == "xNome" && this.#NFe.infNFe.ide.mod == 55) {
102
+ this.#NFe.infNFe.dest.enderDest = {};
103
+ }
104
+ });
105
+ }
106
+
107
+ tagEnderDest(obj) {
108
+ if (this.#NFe.infNFe.ide.mod == 65) return 1;
109
+
110
+ this.#NFe.infNFe.dest.enderDest = {};
111
+ Object.keys(obj).forEach(key => {
112
+ this.#NFe.infNFe.dest.enderDest[key] = obj[key];
113
+ });
114
+ }
115
+
116
+ tagRetirada(obj) {
117
+ throw "não implementado!";
118
+ }
119
+
120
+ tagEntrega(obj) {
121
+ throw "não implementado!";
122
+ }
123
+
124
+ tagAutXML(obj) {
125
+ throw "não implementado!";
126
+ }
127
+
128
+ //tagprod
129
+ tagProd(obj) {
130
+ //Abrir tag de imposto
131
+ for (let cont = 0; cont < obj.length; cont++) {
132
+ if (obj[cont]['@nItem'] === undefined) {
133
+ obj[cont] = { '@nItem': cont + 1, prod: obj[cont], imposto: {} };
134
+ } else {
135
+ obj[cont] = { '@nItem': obj[cont]['@nItem'], prod: obj[cont], imposto: {} };
136
+ delete obj[cont].prod['@nItem'];
137
+ }
138
+
139
+ obj[cont].prod.qCom = (obj[cont].prod.qCom * 1).toFixed(4)
140
+ obj[cont].prod.vUnCom = (obj[cont].prod.vUnCom * 1).toFixed(10)
141
+ obj[cont].prod.vProd = (obj[cont].prod.vProd * 1).toFixed(2)
142
+
143
+ if (obj[cont].prod.vDesc !== undefined) obj[cont].prod.vDesc = (obj[cont].prod.vDesc * 1).toFixed(2)
144
+
145
+ obj[cont].prod.qTrib = (obj[cont].prod.qTrib * 1).toFixed(4)
146
+ obj[cont].prod.vUnTrib = (obj[cont].prod.vUnTrib * 1).toFixed(10)
147
+ //Calcular ICMSTot
148
+ this.#calICMSTot(obj[cont].prod);
149
+ }
150
+ this.#NFe.infNFe.det = obj;
151
+ }
152
+
153
+ tagCreditoPresumidoProd(obj) {
154
+ throw "não implementado!";
155
+ }
156
+
157
+ taginfAdProd(obj) {
158
+ throw "não implementado!";
159
+ }
160
+
161
+ tagCEST(obj) {
162
+ throw "não implementado!";
163
+ }
164
+
165
+ tagRECOPI(obj) {
166
+ throw "não implementado!";
167
+ }
168
+
169
+ tagAdi(obj) {
170
+ throw "não implementado!";
171
+ }
172
+
173
+ tagDetExport(obj) {
174
+ throw "não implementado!";
175
+ }
176
+
177
+ tagDetExportInd(obj) {
178
+ throw "não implementado!";
179
+ }
180
+
181
+ tagRastro(obj) {
182
+ throw "não implementado!";
183
+ }
184
+
185
+ tagVeicProd(obj) {
186
+ throw "não implementado!";
187
+ }
188
+
189
+ tagMed(obj) {
190
+ throw "não implementado!";
191
+ }
192
+
193
+ tagArma(obj) {
194
+ throw "não implementado!";
195
+ }
196
+
197
+ tagComb(obj) {
198
+ throw "não implementado!";
199
+ }
200
+
201
+ tagEncerrante() {
202
+ throw "não implementado!";
203
+ }
204
+
205
+ tagOrigComb() {
206
+ throw "não implementado!";
207
+ }
208
+
209
+ tagImposto() {
210
+ throw "não implementado!";
211
+ }
212
+
213
+ tagProdICMS(index, obj) {
214
+ throw "não implementado!";
215
+ }
216
+
217
+
218
+
219
+ //
220
+ tagProdICMSST(index, obj) {
221
+ this.#NFe.infNFe.det[index].ICMSPart = {};
222
+ Object.keys(obj).forEach(key => {
223
+ this.#NFe.infNFe.det[index].ICMSPart[key] = obj[key];
224
+ });
225
+
226
+ //Calcular ICMSTot
227
+ this.#calICMSTot(obj);
228
+ }
229
+
230
+ //
231
+ tagProdICMSST(index, obj) {
232
+ if (this.#NFe.infNFe.det[index].imposto.ICMS === undefined) this.#NFe.infNFe.det[index].imposto.ICMS = {};
233
+
234
+ this.#NFe.infNFe.det[index].imposto.ICMS.ICMSST = {};
235
+ Object.keys(obj).forEach(key => {
236
+ this.#NFe.infNFe.det[index].imposto.ICMS.ICMSST[key] = obj[key];
237
+ });
238
+
239
+ //Calcular ICMSTot
240
+ this.#calICMSTot(obj);
241
+ }
242
+
243
+ //
244
+ tagProdICMSSN(index, obj) {
245
+ if (this.#NFe.infNFe.det[index].imposto.ICMS === undefined) this.#NFe.infNFe.det[index].imposto.ICMS = {};
246
+
247
+ let keyXML = "";
248
+ switch (obj.CSOSN) {
249
+ case '101':
250
+ keyXML = 'ICMSSN101';
251
+ break;
252
+ case '102':
253
+ case '103':
254
+ case '300':
255
+ case '400':
256
+ keyXML = 'ICMSSN102';
257
+ break;
258
+ case '201':
259
+ keyXML = 'ICMSSN201';
260
+ break;
261
+ case '202':
262
+ case '203':
263
+ keyXML = 'ICMSSN202';
264
+ break;
265
+ case '500':
266
+ keyXML = 'ICMSSN500';
267
+ break;
268
+ case '900':
269
+ keyXML = 'ICMSSN900';
270
+ break;
271
+ default:
272
+ throw "CSOSN não identificado!";
273
+ break;
274
+ }
275
+ this.#NFe.infNFe.det[index].imposto.ICMS[keyXML] = {};
276
+ Object.keys(obj).forEach(key => {
277
+ this.#NFe.infNFe.det[index].imposto.ICMS[keyXML][key] = obj[key];
278
+ });
279
+
280
+ //Calcular ICMSTot
281
+ this.#calICMSTot(obj);
282
+ }
283
+
284
+
285
+ tagProdICMSUFDest(index, obj) {
286
+ throw "Não implementado!";
287
+ }
288
+
289
+ tagProdIPI(index, obj) {
290
+ throw "Não implementado!";
291
+ }
292
+
293
+ tagProdII(index, obj) {
294
+ throw "Não implementado!";
295
+ }
296
+
297
+ tagProdPIS(index, obj) {
298
+ if (this.#NFe.infNFe.det[index].imposto.PIS === undefined) this.#NFe.infNFe.det[index].imposto.PIS = {};
299
+
300
+ let keyXML = "";
301
+ switch (obj.CST) {
302
+ case '01':
303
+ case '02':
304
+ keyXML = 'PISAliq';
305
+ break;
306
+ case '03':
307
+ keyXML = 'PISQtde';
308
+ break;
309
+ case '04':
310
+ case '05':
311
+ case '06':
312
+ case '07':
313
+ case '08':
314
+ case '09':
315
+ keyXML = 'PISNT';
316
+ break;
317
+ case '49':
318
+ case '50':
319
+ case '51':
320
+ case '52':
321
+ case '53':
322
+ case '54':
323
+ case '55':
324
+ case '56':
325
+ case '60':
326
+ case '61':
327
+ case '62':
328
+ case '63':
329
+ case '64':
330
+ case '65':
331
+ case '66':
332
+ case '67':
333
+ case '70':
334
+ case '71':
335
+ case '72':
336
+ case '73':
337
+ case '74':
338
+ case '75':
339
+ case '98':
340
+ case '99':
341
+ keyXML = 'PISOutr';
342
+ break;
343
+ default:
344
+ throw "CSOSN não identificado!";
345
+ break;
346
+
347
+ }
348
+ this.#NFe.infNFe.det[index].imposto.PIS[keyXML] = {};
349
+ Object.keys(obj).forEach(key => {
350
+ this.#NFe.infNFe.det[index].imposto.PIS[keyXML][key] = obj[key];
351
+ });
352
+
353
+ //Calcular ICMSTot
354
+ this.#calICMSTot(obj);
355
+ }
356
+
357
+ tagProdPISST(index, obj) {
358
+ if (this.#NFe.infNFe.det[index].imposto.PIS === undefined) this.#NFe.infNFe.det[index].imposto.PIS = {};
359
+
360
+ this.#NFe.infNFe.det[index].imposto.PIS.PISST = {};
361
+ Object.keys(obj).forEach(key => {
362
+ this.#NFe.infNFe.det[index].imposto.PIS.PISST[key] = obj[key];
363
+ });
364
+
365
+
366
+ //Calcular ICMSTot
367
+ this.#calICMSTot(obj);
368
+ }
369
+
370
+ tagProdCOFINS(index, obj) {
371
+ if (this.#NFe.infNFe.det[index].imposto.COFINS === undefined) this.#NFe.infNFe.det[index].imposto.COFINS = {};
372
+
373
+ let keyXML = null;
374
+ switch (obj.CST) {
375
+ case '01':
376
+ case '02':
377
+ keyXML = null;
378
+ break;
379
+ case '03':
380
+ keyXML = "COFINSQtde";
381
+ break;
382
+ case '04':
383
+ case '05':
384
+ case '06':
385
+ case '07':
386
+ case '08':
387
+ case '09':
388
+ keyXML = "COFINSNT";
389
+ break;
390
+ case '49':
391
+ case '50':
392
+ case '51':
393
+ case '52':
394
+ case '53':
395
+ case '54':
396
+ case '55':
397
+ case '56':
398
+ case '60':
399
+ case '61':
400
+ case '62':
401
+ case '63':
402
+ case '64':
403
+ case '65':
404
+ case '66':
405
+ case '67':
406
+ case '70':
407
+ case '71':
408
+ case '72':
409
+ case '73':
410
+ case '74':
411
+ case '75':
412
+ case '98':
413
+ case '99':
414
+ keyXML = "COFINSOutr";
415
+ break;
416
+ }
417
+
418
+ if (keyXML == null) {
419
+ Object.keys(obj).forEach(key => {
420
+ this.#NFe.infNFe.det[index].imposto.COFINS[key] = obj[key];
421
+ });
422
+ } else {
423
+ this.#NFe.infNFe.det[index].imposto.COFINS[keyXML] = {};
424
+ Object.keys(obj).forEach(key => {
425
+ this.#NFe.infNFe.det[index].imposto.COFINS[keyXML][key] = obj[key];
426
+ });
427
+ }
428
+
429
+ //Calcular ICMSTot
430
+ this.#calICMSTot(obj);
431
+ }
432
+
433
+ tagProdCOFINSST(index, obj) {
434
+ if (this.#NFe.infNFe.det[index].imposto.COFINS === undefined) this.#NFe.infNFe.det[index].imposto.COFINS = {};
435
+
436
+ this.#NFe.infNFe.det[index].imposto.COFINS.COFINSST = {};
437
+ Object.keys(obj).forEach(key => {
438
+ this.#NFe.infNFe.det[index].imposto.PIS.COFINSST[key] = obj[key];
439
+ });
440
+
441
+ //Calcular ICMSTot
442
+ this.#calICMSTot(obj);
443
+ }
444
+
445
+ tagProdISSQN(index, obj) {
446
+ this.#NFe.infNFe.det[index].imposto.ISSQN = {};
447
+ Object.keys(obj).forEach(key => {
448
+ this.#NFe.infNFe.det[index].imposto.ISSQN[key] = obj[key];
449
+ });
450
+
451
+ //Calcular ICMSTot
452
+ this.#calICMSTot(obj);
453
+ }
454
+
455
+ tagProdImpostoDevol(index, obj) {
456
+ throw "Não implementado!";
457
+ }
458
+
459
+ tagICMSTot(obj = null) {
460
+ this.#NFe.infNFe.total = {
461
+ ICMSTot: {}
462
+ };
463
+ if (obj != null) {
464
+ Object.keys(obj).forEach(key => {
465
+ this.#NFe.infNFe.total.ICMSTot[key] = obj[key];
466
+ });
467
+ } else {
468
+ Object.keys(this.#ICMSTot).forEach(key => {
469
+ this.#NFe.infNFe.total.ICMSTot[key] = (this.#ICMSTot[key] * 1).toFixed(2);
470
+ });
471
+ this.#NFe.infNFe.total.ICMSTot.vNF = (this.#NFe.infNFe.total.ICMSTot.vProd - this.#NFe.infNFe.total.ICMSTot.vDesc).toFixed(2)
472
+ }
473
+ }
474
+
475
+ tagISSQNTot(obj) {
476
+ throw "Não implementado!";
477
+ }
478
+
479
+ tagRetTrib(obj) {
480
+ throw "Não implementado!";
481
+ }
482
+
483
+
484
+ tagTransp(obj) {
485
+ this.#NFe.infNFe.transp = {};
486
+ Object.keys(obj).forEach(key => {
487
+ this.#NFe.infNFe.transp[key] = obj[key];
488
+ });
489
+ }
490
+
491
+ tagTransporta(obj) {
492
+ throw "Não implementado!";
493
+ }
494
+
495
+ tagRetTransp(obj) {
496
+ throw "Não implementado!";
497
+ }
498
+
499
+ tagVeicTransp(obj) {
500
+ throw "Não implementado!";
501
+ }
502
+
503
+ tagReboque(obj) {
504
+ throw "Não implementado!";
505
+ }
506
+
507
+ tagVagao(obj) {
508
+ throw "Não implementado!";
509
+ }
510
+
511
+ tagBalsa(obj) {
512
+ throw "Não implementado!";
513
+ }
514
+
515
+ tagVol(obj) {
516
+ throw "Não implementado!";
517
+ }
518
+
519
+ tagLacres(obj) {
520
+ throw "Não implementado!";
521
+ }
522
+
523
+ tagFat(obj) {
524
+ throw "Não implementado!";
525
+ }
526
+
527
+ tagDup(obj) {
528
+ throw "Não implementado!";
529
+ }
530
+
531
+ //tagpag()
532
+ tagTroco(obj) {
533
+ if (this.#NFe.infNFe.pag === undefined) this.#NFe.infNFe.pag = {};
534
+ this.#NFe.infNFe.pag.vTroco = obj;
535
+ }
536
+
537
+ tagDetPag(obj) {
538
+ if (this.#NFe.infNFe.pag === undefined) this.#NFe.infNFe.pag = {};
539
+ this.#NFe.infNFe.pag.detPag = obj;
540
+ }
541
+
542
+ tagIntermed(obj) {
543
+ throw "Não implementado!";
544
+ }
545
+
546
+ tagInfAdic(obj) {
547
+ throw "Não implementado!";
548
+ }
549
+
550
+ tagObsCont(obj) {
551
+ throw "Não implementado!";
552
+ }
553
+
554
+ tagObsFisco(obj) {
555
+ throw "Não implementado!";
556
+ }
557
+
558
+ tagProcRef(obj) {
559
+ throw "Não implementado!";
560
+ }
561
+
562
+ tagExporta(obj) {
563
+ throw "Não implementado!";
564
+ }
565
+
566
+ tagCompra(obj) {
567
+ throw "Não implementado!";
568
+ }
569
+
570
+ tagCana(obj) {
571
+ throw "Não implementado!";
572
+ }
573
+
574
+ tagforDia() {
575
+
576
+ }
577
+
578
+ tagdeduc() {
579
+
580
+ }
581
+
582
+ taginfNFeSupl() {
583
+
584
+ }
585
+
586
+ tagInfRespTec(obj) {
587
+ if (this.#NFe.infNFe.infRespTec === undefined) this.#NFe.infNFe.infRespTec = {};
588
+ Object.keys(obj).forEach(key => {
589
+ this.#NFe.infNFe.infRespTec[key] = obj[key];
590
+ });
591
+ }
592
+
593
+
594
+
595
+ //Endereço para retirada
596
+ tagRetiEnder(obj) {
597
+ throw "Ainda não configurado!";
598
+ }
599
+
600
+ //Endereço para entrega
601
+ tagEntrega(obj) {
602
+ throw "Ainda não configurado!";
603
+ }
604
+
605
+
606
+ #gerarChaveNFe() {
607
+
608
+ const chaveSemDV =
609
+ this.#NFe.infNFe.ide.cUF.padStart(2, '0') + // Código da UF (2 dígitos)
610
+ 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)
611
+ this.#NFe.infNFe.emit.CNPJ.padStart(14, '0') + // CNPJ do emitente (14 dígitos)
612
+ this.#NFe.infNFe.ide.mod.padStart(2, '0') + // Modelo da NF (2 dígitos)
613
+ this.#NFe.infNFe.ide.serie.padStart(3, '0') + // Série da NF (3 dígitos)
614
+ this.#NFe.infNFe.ide.nNF.padStart(9, '0') + // Número da NF (9 dígitos)
615
+ this.#NFe.infNFe.ide.tpEmis.padStart(1, '0') + // Tipo de Emissão (1 dígito)
616
+ this.#NFe.infNFe.ide.cNF.padStart(8, '0'); // Código Numérico da NF (8 dígitos)
617
+ this.#NFe.infNFe.ide.cDV = this.#calcularDigitoVerificador(chaveSemDV)
618
+ return `${chaveSemDV}${this.#NFe.infNFe.ide.cDV}`;
619
+
620
+ }
621
+
622
+ #calcularDigitoVerificador(key) {
623
+ if (key.length !== 43) {
624
+ return '';
625
+ }
626
+
627
+ const multipliers = [2, 3, 4, 5, 6, 7, 8, 9];
628
+ let iCount = 42;
629
+ let weightedSum = 0;
630
+
631
+ while (iCount >= 0) {
632
+ for (let mCount = 0; mCount < 8 && iCount >= 0; mCount++) {
633
+ const sub = parseInt(key[iCount], 10);
634
+ weightedSum += sub * multipliers[mCount];
635
+ iCount--;
636
+ }
637
+ }
638
+
639
+ let vdigit = 11 - (weightedSum % 11);
640
+ if (vdigit > 9) {
641
+ vdigit = 0;
642
+ }
643
+
644
+ return vdigit.toString();
645
+ }
646
+
647
+ xml() {
648
+ if (this.#NFe.infNFe[`@Id`] == null) this.#NFe.infNFe[`@Id`] = `NFe${this.#gerarChaveNFe()}`;
649
+
650
+ //Adicionar QrCode
651
+ if (this.#NFe.infNFe.ide.mod == 55) {
652
+ /*this.#NFe.infNFeSupl = {
653
+ qrCode: "",
654
+ urlChave: ""
655
+ }*/
656
+ }
657
+
658
+ let tempBuild = new XMLBuilder({
659
+ ignoreAttributes: false,
660
+ attributeNamePrefix: "@",
661
+ parseTagValue: false, // Evita conversão automática de valores
662
+ parseNodeValue: false, // Mantém valores como strings
663
+ });
664
+ return tempBuild.build({ NFe: this.#NFe });
665
+ }
666
+
667
+ #getInfoQRCodeByUF(uf, amb) {
668
+ if (this.#NFe.infNFe.ide.tpAmb) {
669
+ switch (this.#NFe.infNFe.ide.cUF) {
670
+ case 'AC':
671
+ return { urlChave: 'www.sefaznet.ac.gov.br/nfce/consulta', urlQRCode: 'http://www.sefaznet.ac.gov.br/nfce/qrcode' };
672
+ case 'AL':
673
+ return { urlChave: 'www.sefaz.al.gov.br/nfce/consulta', urlQRCode: 'http://nfce.sefaz.al.gov.br/QRCode/consultarNFCe.jsp' };
674
+ case 'AP':
675
+ return { urlChave: 'www.sefaz.ap.gov.br/nfce/consulta', urlQRCode: 'https://www.sefaz.ap.gov.br/nfce/nfcep.php' };
676
+ case 'AM':
677
+ return { urlChave: 'www.sefaz.am.gov.br/nfce/consulta', urlQRCode: 'http://sistemas.sefaz.am.gov.br/nfceweb/consultarNFCe.jsp' };
678
+ case 'BA':
679
+ return { urlChave: 'www.sefaz.ba.gov.br/nfce/consulta', urlQRCode: 'http://nfe.sefaz.ba.gov.br/servicos/nfce/modulos/geral/NFCEC_consulta_chave_acesso.aspx' };
680
+ case 'CE':
681
+ return { urlChave: 'www.sefaz.ce.gov.br/nfce/consulta', urlQRCode: 'http://nfce.sefaz.ce.gov.br/pages/ShowNFCe.html' };
682
+ case 'DF':
683
+ return { urlChave: 'www.fazenda.df.gov.br/nfce/consulta', urlQRCode: 'http://dec.fazenda.df.gov.br/ConsultarNFCe.aspx' };
684
+ case 'ES':
685
+ return { urlChave: 'www.sefaz.es.gov.br/nfce/consulta', urlQRCode: 'http://app.sefaz.es.gov.br/ConsultaNFCe/qrcode.aspx' };
686
+ case 'GO':
687
+ return { urlChave: 'www.sefaz.go.gov.br/nfce/consulta', urlQRCode: 'http://nfe.sefaz.go.gov.br/nfeweb/sites/nfce/danfeNFCe' };
688
+ case 'MA':
689
+ return { urlChave: 'www.sefaz.ma.gov.br/nfce/consulta', urlQRCode: 'http://www.nfce.sefaz.ma.gov.br/portal/consultarNFCe.jsp' };
690
+ case 'MG':
691
+ return { urlChave: 'http://nfce.fazenda.mg.gov.br/portalnfce', urlQRCode: 'https://nfce.fazenda.mg.gov.br/portalnfce/sistema/qrcode.xhtml' };
692
+ case 'MS':
693
+ return { urlChave: 'http://www.dfe.ms.gov.br/nfce/consulta', urlQRCode: 'http://www.dfe.ms.gov.br/nfce/qrcode' };
694
+ case '51': //MT
695
+ return { urlChave: 'http://www.sefaz.mt.gov.br/nfce/consultanfce', urlQRCode: 'http://www.sefaz.mt.gov.br/nfce/consultanfce' };
696
+ case 'PA':
697
+ return { urlChave: 'www.sefa.pa.gov.br/nfce/consulta', urlQRCode: 'https://appnfc.sefa.pa.gov.br/portal/view/consultas/nfce/nfceForm.seam' };
698
+ case 'PB':
699
+ return { urlChave: 'www.receita.pb.gov.br/nfce/consulta', urlQRCode: 'http://www.receita.pb.gov.br/nfce' };
700
+ case 'PE':
701
+ return { urlChave: 'nfce.sefaz.pe.gov.br/nfce/consulta', urlQRCode: 'http://nfce.sefaz.pe.gov.br/nfce-web/consultarNFCe' };
702
+ case 'PI':
703
+ return { urlChave: 'www.sefaz.pi.gov.br/nfce/consulta', urlQRCode: 'http://www.sefaz.pi.gov.br/nfce/qrcode' };
704
+ case 'PR':
705
+ return { urlChave: 'http://www.fazenda.pr.gov.br/nfce/consulta', urlQRCode: 'http://www.fazenda.pr.gov.br/nfce/qrcode/' };
706
+ case 'RJ':
707
+ return { urlChave: 'www.fazenda.rj.gov.br/nfce/consulta', urlQRCode: 'http://www4.fazenda.rj.gov.br/consultaNFCe/QRCode' };
708
+ case 'RN':
709
+ return { urlChave: 'www.set.rn.gov.br/nfce/consulta', urlQRCode: 'http://nfce.set.rn.gov.br/consultarNFCe.aspx' };
710
+ case 'RO':
711
+ return { urlChave: 'www.sefin.ro.gov.br/nfce/consulta', urlQRCode: 'http://www.nfce.sefin.ro.gov.br/consultanfce/consulta.jsp' };
712
+ case 'RS':
713
+ return { urlChave: 'www.sefaz.rs.gov.br/nfce/consulta', urlQRCode: 'https://www.sefaz.rs.gov.br/NFCE/NFCE-COM.aspx' };
714
+ case 'RR':
715
+ return { urlChave: 'www.sefaz.rr.gov.br/nfce/consulta', urlQRCode: 'https://www.sefaz.rr.gov.br/nfce/servlet/qrcode' };
716
+ case 'SE':
717
+ return { urlChave: 'http://www.nfce.se.gov.br/nfce/consulta', urlQRCode: 'http://www.nfce.se.gov.br/portal/consultarNFCe.jsp' };
718
+ case 'SP':
719
+ return { urlChave: 'https://www.nfce.fazenda.sp.gov.br/consulta', urlQRCode: 'https://www.nfce.fazenda.sp.gov.br/qrcode' };
720
+ case 'TO':
721
+ return { urlChave: 'www.sefaz.to.gov.br/nfce/consulta', urlQRCode: 'http://www.sefaz.to.gov.br/nfce/qrcode' };
722
+ default:
723
+ throw new Error('URL do QRCode não encontrada pelo UF (' + uf + ') informado.');
724
+ }
725
+ }
726
+ else {
727
+ switch (this.#NFe.infNFe.ide.cUF) {
728
+ case 'AC':
729
+ return { urlChave: 'www.sefaznet.ac.gov.br/nfce/consulta', urlQRCode: 'http://hml.sefaznet.ac.gov.br/nfce/qrcode' };
730
+ case 'AL':
731
+ return { urlChave: 'www.sefaz.al.gov.br/nfce/consulta', urlQRCode: 'http://nfce.sefaz.al.gov.br/QRCode/consultarNFCe.jsp' };
732
+ case 'AP':
733
+ return { urlChave: 'www.sefaz.ap.gov.br/nfce/consulta', urlQRCode: 'https://www.sefaz.ap.gov.br/nfcehml/nfce.php' };
734
+ case 'AM':
735
+ return { urlChave: 'https://sistemas.sefaz.am.gov.br/nfceweb-hom/formConsulta.do', urlQRCode: 'https://sistemas.sefaz.am.gov.br/nfceweb-hom/consultarNFCe.jsp' };
736
+ case 'BA':
737
+ return { urlChave: 'http://hinternet.sefaz.ba.gov.br/nfce/consulta', urlQRCode: 'http://hnfe.sefaz.ba.gov.br/servicos/nfce/modulos/geral/NFCEC_consulta_chave_acesso.aspx' };
738
+ case 'CE':
739
+ return { urlChave: 'www.sefaz.ce.gov.br/nfce/consulta', urlQRCode: 'http://nfceh.sefaz.ce.gov.br/pages/ShowNFCe.html' };
740
+ case 'DF':
741
+ return { urlChave: 'www.fazenda.df.gov.br/nfce/consulta', urlQRCode: 'http://dec.fazenda.df.gov.br/ConsultarNFCe.aspx' };
742
+ case 'ES':
743
+ return { urlChave: 'www.sefaz.es.gov.br/nfce/consulta', urlQRCode: 'http://homologacao.sefaz.es.gov.br/ConsultaNFCe/qrcode.aspx' };
744
+ case 'GO':
745
+ return { urlChave: 'http://www.nfce.go.gov.br/post/ver/214413/consulta-nfc-e-homologacao', urlQRCode: 'http://homolog.sefaz.go.gov.br/nfeweb/sites/nfce/danfeNFCe' };
746
+ case 'MA':
747
+ return { urlChave: 'www.sefaz.ma.gov.br/nfce/consulta', urlQRCode: 'http://www.hom.nfce.sefaz.ma.gov.br/portal/consultarNFCe.jsp' };
748
+ case 'MG':
749
+ return { urlChave: 'http://hnfce.fazenda.mg.gov.br/portalnfce', urlQRCode: 'https://nfce.fazenda.mg.gov.br/portalnfce/sistema/qrcode.xhtml' };
750
+ case 'MS':
751
+ return { urlChave: 'http://www.dfe.ms.gov.br/nfce/consulta', urlQRCode: 'http://www.dfe.ms.gov.br/nfce/qrcode' };
752
+ case '51': //MT
753
+ return { urlChave: 'http://homologacao.sefaz.mt.gov.br/nfce/consultanfce', urlQRCode: 'http://homologacao.sefaz.mt.gov.br/nfce/consultanfce' };
754
+ case 'PA':
755
+ return { urlChave: 'www.sefa.pa.gov.br/nfce/consulta', urlQRCode: 'https://appnfc.sefa.pa.gov.br/portal-homologacao/view/consultas/nfce/nfceForm.seam' };
756
+ case 'PB':
757
+ return { urlChave: 'www.receita.pb.gov.br/nfcehom', urlQRCode: 'http://www.receita.pb.gov.br/nfcehom' };
758
+ case 'PE':
759
+ return { urlChave: 'nfce.sefaz.pe.gov.br/nfce/consulta', urlQRCode: 'http://nfcehomolog.sefaz.pe.gov.br/nfce-web/consultarNFCe' };
760
+ case 'PI':
761
+ return { urlChave: 'www.sefaz.pi.gov.br/nfce/consulta', urlQRCode: 'http://www.sefaz.pi.gov.br/nfce/qrcode' };
762
+ case 'PR':
763
+ return { urlChave: 'http://www.fazenda.pr.gov.br/nfce/consulta', urlQRCode: 'http://www.fazenda.pr.gov.br/nfce/qrcode/' };
764
+ case 'RJ':
765
+ return { urlChave: 'www.fazenda.rj.gov.br/nfce/consulta', urlQRCode: 'http://www4.fazenda.rj.gov.br/consultaNFCe/QRCode' };
766
+ case 'RN':
767
+ return { urlChave: 'www.set.rn.gov.br/nfce/consulta', urlQRCode: 'http://hom.nfce.set.rn.gov.br/consultarNFCe.aspx' };
768
+ case 'RO':
769
+ return { urlChave: 'www.sefin.ro.gov.br/nfce/consulta', urlQRCode: 'http://www.nfce.sefin.ro.gov.br/consultanfce/consulta.jsp' };
770
+ case 'RS':
771
+ return { urlChave: 'www.sefaz.rs.gov.br/nfce/consulta', urlQRCode: 'https://www.sefaz.rs.gov.br/NFCE/NFCE-COM.aspx' };
772
+ case 'RR':
773
+ return { urlChave: 'www.sefaz.rr.gov.br/nfce/consulta', urlQRCode: 'http://200.174.88.103:8080/nfce/servlet/qrcode' };
774
+ case 'SE':
775
+ return { urlChave: 'http://www.hom.nfe.se.gov.br/nfce/consulta', urlQRCode: 'http://www.hom.nfe.se.gov.br/portal/consultarNFCe.jsp' };
776
+ case 'SP':
777
+ return { urlChave: 'https://www.homologacao.nfce.fazenda.sp.gov.br/consulta', urlQRCode: 'https://www.homologacao.nfce.fazenda.sp.gov.br/qrcode' };
778
+ case 'TO':
779
+ return { urlChave: 'http://homologacao.sefaz.to.gov.br/nfce/consulta.jsf', urlQRCode: 'http://homologacao.sefaz.to.gov.br/nfce/qrcode' };
780
+ default:
781
+ throw new Error('URL do QRCode não encontrada pelo UF (' + uf + ') informado.');
782
+ }
783
+ }
784
+ }
785
+
786
+ #calICMSTot(obj) {
787
+ Object.keys(obj).map(key => {
788
+ if (this.#ICMSTot[key] !== undefined) {
789
+ this.#ICMSTot[key] += 1 * (obj[key]);
790
+ }
791
+ });
792
+
793
+ }
794
+ }
795
+
796
+
797
+ export { Make }
798
+ export default { Make }