ghinfe 0.6.0 → 0.6.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.
Files changed (110) hide show
  1. package/.env.example +24 -15
  2. package/LICENSE +21 -21
  3. package/README.md +491 -413
  4. package/docs/developer-guide.html +421 -421
  5. package/docs/openapi.yaml +428 -428
  6. package/examples/dce-homologacao.js +141 -0
  7. package/examples/emitir-nfce.js +51 -51
  8. package/examples/emitir-nfe.js +83 -83
  9. package/examples/emitir-nfse.js +46 -46
  10. package/examples/endpoints-sefaz.js +14 -14
  11. package/examples/eventos-nfe.js +49 -49
  12. package/examples/gerar-chave.js +25 -25
  13. package/examples/gerar-dace.js +59 -0
  14. package/examples/gerar-danfe.js +75 -75
  15. package/examples/gerar-dce.js +58 -0
  16. package/examples/layouts-nfse.js +51 -51
  17. package/examples/mock-sefaz.js +52 -52
  18. package/examples/nfse-eventos.js +57 -57
  19. package/examples/reforma-ibscbs.js +27 -27
  20. package/examples/reforma-nfe-xml.js +52 -52
  21. package/examples/status-sefaz.js +12 -12
  22. package/examples/validar-xsd.js +48 -48
  23. package/package.json +59 -68
  24. package/schemas/dce/PL_DCe_100a_NT2024.001/consulta/consSitDCeTiposBasico_v1.00.xsd +123 -0
  25. package/schemas/dce/PL_DCe_100a_NT2024.001/consulta/consSitDCe_v1.00.xsd +10 -0
  26. package/schemas/dce/PL_DCe_100a_NT2024.001/consulta/consStatServDCeTiposBasico_v1.00.xsd +110 -0
  27. package/schemas/dce/PL_DCe_100a_NT2024.001/consulta/consStatServDCe_v1.00.xsd +10 -0
  28. package/schemas/dce/PL_DCe_100a_NT2024.001/consulta/dceTiposBasico_v1.00.xsd +1388 -0
  29. package/schemas/dce/PL_DCe_100a_NT2024.001/consulta/retConsSitDCe_v1.00.xsd +10 -0
  30. package/schemas/dce/PL_DCe_100a_NT2024.001/consulta/retConsStatServDCe_v1.00.xsd +10 -0
  31. package/schemas/dce/PL_DCe_100a_NT2024.001/consulta/tiposGeralDCe_v1.00.xsd +712 -0
  32. package/schemas/dce/PL_DCe_100a_NT2024.001/consulta/xmldsig-core-schema_v1.01.xsd +98 -0
  33. package/schemas/dce/PL_DCe_100a_NT2024.001/dceTiposBasico_v1.00.xsd +1410 -0
  34. package/schemas/dce/PL_DCe_100a_NT2024.001/dce_v1.00.xsd +10 -0
  35. package/schemas/dce/PL_DCe_100a_NT2024.001/evento/evCancDCe_v1.00.xsd +36 -0
  36. package/schemas/dce/PL_DCe_100a_NT2024.001/evento/eventoDCeTiposBasico_v1.00.xsd +283 -0
  37. package/schemas/dce/PL_DCe_100a_NT2024.001/evento/eventoDCe_v1.00.xsd +9 -0
  38. package/schemas/dce/PL_DCe_100a_NT2024.001/evento/procEventoDCe_v1.00.xsd +10 -0
  39. package/schemas/dce/PL_DCe_100a_NT2024.001/evento/retEventoDCe_v1.00.xsd +9 -0
  40. package/schemas/dce/PL_DCe_100a_NT2024.001/evento/tiposGeralDCe_v1.00.xsd +712 -0
  41. package/schemas/dce/PL_DCe_100a_NT2024.001/evento/xmldsig-core-schema_v1.01.xsd +98 -0
  42. package/schemas/dce/PL_DCe_100a_NT2024.001/procDCe_v1.00.xsd +37 -0
  43. package/schemas/dce/PL_DCe_100a_NT2024.001/retDCe_v1.00.xsd +9 -0
  44. package/schemas/dce/PL_DCe_100a_NT2024.001/tiposGeralDCe_v1.00.xsd +712 -0
  45. package/schemas/dce/PL_DCe_100a_NT2024.001/xmldsig-core-schema_v1.01.xsd +98 -0
  46. package/schemas/nfe/PL_009_V4/enviNFe_v3.10.xsd +8 -8
  47. package/schemas/nfe/PL_009_V4/xmldsig-core-schema_v1.01.xsd +97 -97
  48. package/scripts/download-schemas.js +39 -39
  49. package/scripts/test-xsd.js +34 -34
  50. package/src/api/server.js +316 -316
  51. package/src/constants/sefaz.js +69 -69
  52. package/src/danfe/DanfeService.js +205 -205
  53. package/src/danfe/xml-extract.js +69 -69
  54. package/src/dce/builders/DCeEventoXmlBuilder.js +86 -0
  55. package/src/dce/builders/DCeXmlBuilder.js +345 -0
  56. package/src/dce/constants/dce.js +87 -0
  57. package/src/dce/dace/DaceService.js +356 -0
  58. package/src/dce/dace/dace-extract.js +114 -0
  59. package/src/dce/services/DCeService.js +263 -0
  60. package/src/dce/services/DCeSoapService.js +235 -0
  61. package/src/dce/services/DCeXmlService.js +67 -0
  62. package/src/dce/types/DCeDocument.js +106 -0
  63. package/src/dce/utils/qrcode.utils.js +59 -0
  64. package/src/errors/GhinfeError.js +13 -13
  65. package/src/errors/SefazError.js +25 -25
  66. package/src/errors/XsdValidationError.js +15 -15
  67. package/src/index.js +84 -60
  68. package/src/nfce/builders/NFCeXmlBuilder.js +178 -178
  69. package/src/nfce/constants/qrcode.js +26 -26
  70. package/src/nfce/services/NFCeService.js +188 -188
  71. package/src/nfce/services/NFCeXmlService.js +38 -38
  72. package/src/nfce/types/NFCeDocument.js +42 -42
  73. package/src/nfce/utils/qrcode.utils.js +92 -92
  74. package/src/nfe/builders/NFeEventoXmlBuilder.js +110 -110
  75. package/src/nfe/builders/NFeXmlBuilder.js +215 -215
  76. package/src/nfe/mocks/sefaz-responses.js +195 -195
  77. package/src/nfe/services/NFeEventoService.js +95 -95
  78. package/src/nfe/services/NFeService.js +196 -196
  79. package/src/nfe/services/NFeSignService.js +127 -111
  80. package/src/nfe/services/NFeSoapService.js +437 -437
  81. package/src/nfe/services/NFeXmlService.js +41 -41
  82. package/src/nfe/services/NFeXsdService.js +56 -56
  83. package/src/nfe/types/NFeDocument.js +92 -92
  84. package/src/nfe/types/NFeEvento.js +44 -44
  85. package/src/nfse/NFSeMunicipioResolver.js +42 -42
  86. package/src/nfse/builders/NFSeEventoXmlBuilder.js +92 -92
  87. package/src/nfse/builders/NFSeXmlBuilder.js +16 -16
  88. package/src/nfse/constants/municipios.js +82 -82
  89. package/src/nfse/layouts/adapters.js +202 -202
  90. package/src/nfse/mocks/nfse-responses.js +142 -142
  91. package/src/nfse/services/NFSeService.js +191 -191
  92. package/src/nfse/services/NFSeSoapService.js +232 -232
  93. package/src/nfse/services/NFSeXmlService.js +12 -12
  94. package/src/nfse/types/NFSeDocument.js +54 -54
  95. package/src/queue/NFCeQueue.js +63 -63
  96. package/src/queue/NFSeQueue.js +59 -59
  97. package/src/queue/NFeQueue.js +76 -76
  98. package/src/reforma/ibscbs.js +175 -175
  99. package/src/sefaz/SefazEndpointResolver.js +95 -95
  100. package/src/sefaz/ca/icp-brasil-raiz-v10.pem +38 -0
  101. package/src/sefaz/endpoints.registry.js +205 -205
  102. package/src/sefaz/httpsAgent.js +33 -0
  103. package/src/shared/fiscal.helpers.js +53 -53
  104. package/src/utils/certificate.utils.js +69 -47
  105. package/src/utils/chave.utils.js +205 -117
  106. package/src/utils/code128.utils.js +67 -0
  107. package/src/utils/date.utils.js +26 -26
  108. package/src/utils/xml.utils.js +44 -44
  109. package/src/validation/XsdValidator.js +133 -114
  110. package/src/validation/schemas.js +18 -14
@@ -1,41 +1,41 @@
1
- import { NFeXmlBuilder } from '../builders/NFeXmlBuilder.js';
2
- import { NFeXsdService } from './NFeXsdService.js';
3
- import { reformaHabilitada } from '../../reforma/ibscbs.js';
4
-
5
- /**
6
- * Serviço responsável pela geração e validação XSD do XML da NF-e.
7
- */
8
- export class NFeXmlService {
9
- /**
10
- * @param {{ validarXsd?: boolean }} [options]
11
- */
12
- constructor(options = {}) {
13
- this.builder = new NFeXmlBuilder();
14
- this.xsdService = new NFeXsdService();
15
- this.validarXsd = options.validarXsd ?? false;
16
- }
17
-
18
- /**
19
- * @param {import('../types/NFeDocument.js').NFeDocument} documento
20
- * @param {{ validarXsd?: boolean }} [options]
21
- */
22
- gerarXml(documento, options = {}) {
23
- const xml = this.builder.build(documento);
24
- const deveValidar = options.validarXsd ?? this.validarXsd;
25
-
26
- // PL_009 não conhece IBSCBS — não validar XSD quando reforma está ativa
27
- if (deveValidar && !reformaHabilitada(documento)) {
28
- this.xsdService.validarNFe(xml, { preAssinatura: true });
29
- }
30
-
31
- return xml;
32
- }
33
-
34
- /**
35
- * @param {string} xml
36
- * @param {{ preAssinatura?: boolean }} [options]
37
- */
38
- validarXml(xml, options = {}) {
39
- return this.xsdService.validarNFe(xml, options);
40
- }
41
- }
1
+ import { NFeXmlBuilder } from '../builders/NFeXmlBuilder.js';
2
+ import { NFeXsdService } from './NFeXsdService.js';
3
+ import { reformaHabilitada } from '../../reforma/ibscbs.js';
4
+
5
+ /**
6
+ * Serviço responsável pela geração e validação XSD do XML da NF-e.
7
+ */
8
+ export class NFeXmlService {
9
+ /**
10
+ * @param {{ validarXsd?: boolean }} [options]
11
+ */
12
+ constructor(options = {}) {
13
+ this.builder = new NFeXmlBuilder();
14
+ this.xsdService = new NFeXsdService();
15
+ this.validarXsd = options.validarXsd ?? false;
16
+ }
17
+
18
+ /**
19
+ * @param {import('../types/NFeDocument.js').NFeDocument} documento
20
+ * @param {{ validarXsd?: boolean }} [options]
21
+ */
22
+ gerarXml(documento, options = {}) {
23
+ const xml = this.builder.build(documento);
24
+ const deveValidar = options.validarXsd ?? this.validarXsd;
25
+
26
+ // PL_009 não conhece IBSCBS — não validar XSD quando reforma está ativa
27
+ if (deveValidar && !reformaHabilitada(documento)) {
28
+ this.xsdService.validarNFe(xml, { preAssinatura: true });
29
+ }
30
+
31
+ return xml;
32
+ }
33
+
34
+ /**
35
+ * @param {string} xml
36
+ * @param {{ preAssinatura?: boolean }} [options]
37
+ */
38
+ validarXml(xml, options = {}) {
39
+ return this.xsdService.validarNFe(xml, options);
40
+ }
41
+ }
@@ -1,56 +1,56 @@
1
- import { XsdValidator } from '../../validation/XsdValidator.js';
2
- import { XSD_SCHEMAS } from '../../validation/schemas.js';
3
-
4
- /**
5
- * Validação XSD específica para NF-e / NFC-e (layout 4.00).
6
- */
7
- export class NFeXsdService {
8
- /**
9
- * Valida XML da NF-e (modelo 55) contra schema oficial.
10
- * @param {string} xml
11
- * @param {{ preAssinatura?: boolean }} [options]
12
- * preAssinatura=true injeta stub estrutural (Signature) para validar infNFe antes de assinar
13
- */
14
- validarNFe(xml, options = {}) {
15
- return XsdValidator.validar(xml, XSD_SCHEMAS.NFE, {
16
- injetarAssinaturaStub: options.preAssinatura ?? !xml.includes('</Signature>'),
17
- modelo: '55',
18
- });
19
- }
20
-
21
- /**
22
- * Valida XML da NFC-e (modelo 65) contra schema oficial.
23
- * @param {string} xml
24
- * @param {{ preAssinatura?: boolean }} [options]
25
- */
26
- validarNFCe(xml, options = {}) {
27
- return XsdValidator.validar(xml, XSD_SCHEMAS.NFE, {
28
- injetarAssinaturaStub: options.preAssinatura ?? !xml.includes('</Signature>'),
29
- modelo: '65',
30
- });
31
- }
32
-
33
- /**
34
- * @param {string} xml
35
- * @param {'55'|'65'} [modelo]
36
- */
37
- tentarValidar(xml, modelo = '55') {
38
- return modelo === '65' ? this.tentarValidarNFCe(xml) : this.tentarValidarNFe(xml);
39
- }
40
-
41
- /** @param {string} xml */
42
- tentarValidarNFe(xml) {
43
- return XsdValidator.tentarValidar(xml, XSD_SCHEMAS.NFE, {
44
- injetarAssinaturaStub: !xml.includes('</Signature>'),
45
- modelo: '55',
46
- });
47
- }
48
-
49
- /** @param {string} xml */
50
- tentarValidarNFCe(xml) {
51
- return XsdValidator.tentarValidar(xml, XSD_SCHEMAS.NFE, {
52
- injetarAssinaturaStub: !xml.includes('</Signature>'),
53
- modelo: '65',
54
- });
55
- }
56
- }
1
+ import { XsdValidator } from '../../validation/XsdValidator.js';
2
+ import { XSD_SCHEMAS } from '../../validation/schemas.js';
3
+
4
+ /**
5
+ * Validação XSD específica para NF-e / NFC-e (layout 4.00).
6
+ */
7
+ export class NFeXsdService {
8
+ /**
9
+ * Valida XML da NF-e (modelo 55) contra schema oficial.
10
+ * @param {string} xml
11
+ * @param {{ preAssinatura?: boolean }} [options]
12
+ * preAssinatura=true injeta stub estrutural (Signature) para validar infNFe antes de assinar
13
+ */
14
+ validarNFe(xml, options = {}) {
15
+ return XsdValidator.validar(xml, XSD_SCHEMAS.NFE, {
16
+ injetarAssinaturaStub: options.preAssinatura ?? !xml.includes('</Signature>'),
17
+ modelo: '55',
18
+ });
19
+ }
20
+
21
+ /**
22
+ * Valida XML da NFC-e (modelo 65) contra schema oficial.
23
+ * @param {string} xml
24
+ * @param {{ preAssinatura?: boolean }} [options]
25
+ */
26
+ validarNFCe(xml, options = {}) {
27
+ return XsdValidator.validar(xml, XSD_SCHEMAS.NFE, {
28
+ injetarAssinaturaStub: options.preAssinatura ?? !xml.includes('</Signature>'),
29
+ modelo: '65',
30
+ });
31
+ }
32
+
33
+ /**
34
+ * @param {string} xml
35
+ * @param {'55'|'65'} [modelo]
36
+ */
37
+ tentarValidar(xml, modelo = '55') {
38
+ return modelo === '65' ? this.tentarValidarNFCe(xml) : this.tentarValidarNFe(xml);
39
+ }
40
+
41
+ /** @param {string} xml */
42
+ tentarValidarNFe(xml) {
43
+ return XsdValidator.tentarValidar(xml, XSD_SCHEMAS.NFE, {
44
+ injetarAssinaturaStub: !xml.includes('</Signature>'),
45
+ modelo: '55',
46
+ });
47
+ }
48
+
49
+ /** @param {string} xml */
50
+ tentarValidarNFCe(xml) {
51
+ return XsdValidator.tentarValidar(xml, XSD_SCHEMAS.NFE, {
52
+ injetarAssinaturaStub: !xml.includes('</Signature>'),
53
+ modelo: '65',
54
+ });
55
+ }
56
+ }
@@ -1,92 +1,92 @@
1
- /**
2
- * @typedef {Object} NFeEndereco
3
- * @property {string} logradouro
4
- * @property {string} numero
5
- * @property {string} [complemento]
6
- * @property {string} bairro
7
- * @property {string} codigoMunicipio IBGE 7 dígitos
8
- * @property {string} municipio
9
- * @property {string} uf
10
- * @property {string} cep
11
- * @property {string} [telefone]
12
- */
13
-
14
- /**
15
- * @typedef {Object} NFeEmitente
16
- * @property {string} cnpj
17
- * @property {string} razaoSocial
18
- * @property {string} [nomeFantasia]
19
- * @property {string} ie
20
- * @property {string} crt 1=Simples, 2=Simples excesso, 3=Normal
21
- * @property {NFeEndereco} endereco
22
- */
23
-
24
- /**
25
- * @typedef {Object} NFeDestinatario
26
- * @property {string} [cnpj]
27
- * @property {string} [cpf]
28
- * @property {string} razaoSocial
29
- * @property {string} [ie]
30
- * @property {number} [indIEDest] 1=Contribuinte, 2=Isento, 9=Não contribuinte
31
- * @property {NFeEndereco} endereco
32
- */
33
-
34
- /**
35
- * @typedef {Object} NFeItem
36
- * @property {string} codigo
37
- * @property {string} descricao
38
- * @property {string} ncm
39
- * @property {string} cfop
40
- * @property {string} unidade
41
- * @property {number} quantidade
42
- * @property {number} valorUnitario
43
- * @property {number} valorTotal
44
- * @property {string} [ean]
45
- * @property {string} [cst] CST ICMS (ex: "00")
46
- * @property {number} [aliquotaIcms]
47
- * @property {number} [valorIcms]
48
- * @property {import('../../reforma/ibscbs.js').TributacaoRTC} [reforma] IBS/CBS (PL_010)
49
- */
50
-
51
- /**
52
- * @typedef {Object} NFeFrete
53
- * @property {number} modalidade 0=Emitente, 1=Destinatário, 9=Sem frete
54
- * @property {number} [valor]
55
- * @property {string} [transportadora]
56
- * @property {string} [cnpjTransportadora]
57
- */
58
-
59
- /**
60
- * @typedef {Object} NFePagamento
61
- * @property {string} forma 01=Dinheiro, 03=Cartão crédito, etc.
62
- * @property {number} valor
63
- */
64
-
65
- /**
66
- * @typedef {Object} NFeIde
67
- * @property {string} uf Sigla UF (ex: "SP")
68
- * @property {string} codigoMunicipio IBGE
69
- * @property {number} [serie]
70
- * @property {number} numero
71
- * @property {number} [tipoEmissao] 1=Normal
72
- * @property {number} [finalidade] 1=Normal
73
- * @property {number} [consumidorFinal] 0=Não, 1=Sim
74
- * @property {number} [presenca] 1=Presencial
75
- * @property {number} [naturezaOperacao]
76
- */
77
-
78
- /**
79
- * @typedef {Object} NFeDocumento
80
- * @property {string} [chaveAcesso] 44 dígitos — gerada automaticamente se omitida
81
- * @property {number} [ambiente] 1=Produção, 2=Homologação
82
- * @property {boolean} [reformaTributaria] força totais IBS/CBS mesmo sem item.reforma
83
- * @property {NFeIde} ide
84
- * @property {NFeEmitente} emitente
85
- * @property {NFeDestinatario} destinatario
86
- * @property {NFeItem[]} itens
87
- * @property {NFeFrete} [frete]
88
- * @property {NFePagamento[]} [pagamentos]
89
- * @property {string} [informacoesComplementares]
90
- */
91
-
92
- export {};
1
+ /**
2
+ * @typedef {Object} NFeEndereco
3
+ * @property {string} logradouro
4
+ * @property {string} numero
5
+ * @property {string} [complemento]
6
+ * @property {string} bairro
7
+ * @property {string} codigoMunicipio IBGE 7 dígitos
8
+ * @property {string} municipio
9
+ * @property {string} uf
10
+ * @property {string} cep
11
+ * @property {string} [telefone]
12
+ */
13
+
14
+ /**
15
+ * @typedef {Object} NFeEmitente
16
+ * @property {string} cnpj
17
+ * @property {string} razaoSocial
18
+ * @property {string} [nomeFantasia]
19
+ * @property {string} ie
20
+ * @property {string} crt 1=Simples, 2=Simples excesso, 3=Normal
21
+ * @property {NFeEndereco} endereco
22
+ */
23
+
24
+ /**
25
+ * @typedef {Object} NFeDestinatario
26
+ * @property {string} [cnpj]
27
+ * @property {string} [cpf]
28
+ * @property {string} razaoSocial
29
+ * @property {string} [ie]
30
+ * @property {number} [indIEDest] 1=Contribuinte, 2=Isento, 9=Não contribuinte
31
+ * @property {NFeEndereco} endereco
32
+ */
33
+
34
+ /**
35
+ * @typedef {Object} NFeItem
36
+ * @property {string} codigo
37
+ * @property {string} descricao
38
+ * @property {string} ncm
39
+ * @property {string} cfop
40
+ * @property {string} unidade
41
+ * @property {number} quantidade
42
+ * @property {number} valorUnitario
43
+ * @property {number} valorTotal
44
+ * @property {string} [ean]
45
+ * @property {string} [cst] CST ICMS (ex: "00")
46
+ * @property {number} [aliquotaIcms]
47
+ * @property {number} [valorIcms]
48
+ * @property {import('../../reforma/ibscbs.js').TributacaoRTC} [reforma] IBS/CBS (PL_010)
49
+ */
50
+
51
+ /**
52
+ * @typedef {Object} NFeFrete
53
+ * @property {number} modalidade 0=Emitente, 1=Destinatário, 9=Sem frete
54
+ * @property {number} [valor]
55
+ * @property {string} [transportadora]
56
+ * @property {string} [cnpjTransportadora]
57
+ */
58
+
59
+ /**
60
+ * @typedef {Object} NFePagamento
61
+ * @property {string} forma 01=Dinheiro, 03=Cartão crédito, etc.
62
+ * @property {number} valor
63
+ */
64
+
65
+ /**
66
+ * @typedef {Object} NFeIde
67
+ * @property {string} uf Sigla UF (ex: "SP")
68
+ * @property {string} codigoMunicipio IBGE
69
+ * @property {number} [serie]
70
+ * @property {number} numero
71
+ * @property {number} [tipoEmissao] 1=Normal
72
+ * @property {number} [finalidade] 1=Normal
73
+ * @property {number} [consumidorFinal] 0=Não, 1=Sim
74
+ * @property {number} [presenca] 1=Presencial
75
+ * @property {number} [naturezaOperacao]
76
+ */
77
+
78
+ /**
79
+ * @typedef {Object} NFeDocumento
80
+ * @property {string} [chaveAcesso] 44 dígitos — gerada automaticamente se omitida
81
+ * @property {number} [ambiente] 1=Produção, 2=Homologação
82
+ * @property {boolean} [reformaTributaria] força totais IBS/CBS mesmo sem item.reforma
83
+ * @property {NFeIde} ide
84
+ * @property {NFeEmitente} emitente
85
+ * @property {NFeDestinatario} destinatario
86
+ * @property {NFeItem[]} itens
87
+ * @property {NFeFrete} [frete]
88
+ * @property {NFePagamento[]} [pagamentos]
89
+ * @property {string} [informacoesComplementares]
90
+ */
91
+
92
+ export {};
@@ -1,44 +1,44 @@
1
- /** Tipos de evento NF-e conforme tabela SEFAZ. */
2
- export const NFE_EVENTOS = {
3
- CARTA_CORRECAO: '110110',
4
- CANCELAMENTO: '110111',
5
- CIENCIA_OPERACAO: '210210',
6
- CONFIRMACAO_OPERACAO: '210200',
7
- DESCONHECIMENTO_OPERACAO: '210220',
8
- OPERACAO_NAO_REALIZADA: '210240',
9
- };
10
-
11
- /** Texto fixo exigido na CC-e. */
12
- export const CCE_COND_USO =
13
- 'A Carta de Correcao e disciplinada pelo paragrafo 1o-A do art. 7o do Convenio S/N, ' +
14
- 'de 15 de dezembro de 1970 e pode ser utilizada para regularizacao de erro ocorrido ' +
15
- 'na emissao de documento fiscal, desde que o erro nao esteja relacionado com: ' +
16
- 'I - as variaveis que determinam o valor do imposto tais como: base de calculo, ' +
17
- 'aliquota, diferenca de preco, quantidade, valor da operacao ou da prestacao; ' +
18
- 'II - a correcao de dados cadastrais que implique mudanca do remetente ou do destinatario; ' +
19
- 'III - a data de emissao ou de saida.';
20
-
21
- /**
22
- * @typedef {Object} NFeEventoBase
23
- * @property {string} chaveAcesso Chave da NF-e (44 dígitos)
24
- * @property {string} cnpj CNPJ do autor do evento
25
- * @property {string} uf Sigla UF
26
- * @property {number} [ambiente] 1=Produção, 2=Homologação
27
- * @property {number} [sequencia] nSeqEvento (default 1)
28
- * @property {string} [idLote] ID do lote de eventos
29
- */
30
-
31
- /**
32
- * @typedef {NFeEventoBase & {
33
- * protocolo: string,
34
- * justificativa: string,
35
- * }} NFeCancelamento
36
- */
37
-
38
- /**
39
- * @typedef {NFeEventoBase & {
40
- * correcao: string,
41
- * }} NFeCartaCorrecao
42
- */
43
-
44
- export {};
1
+ /** Tipos de evento NF-e conforme tabela SEFAZ. */
2
+ export const NFE_EVENTOS = {
3
+ CARTA_CORRECAO: '110110',
4
+ CANCELAMENTO: '110111',
5
+ CIENCIA_OPERACAO: '210210',
6
+ CONFIRMACAO_OPERACAO: '210200',
7
+ DESCONHECIMENTO_OPERACAO: '210220',
8
+ OPERACAO_NAO_REALIZADA: '210240',
9
+ };
10
+
11
+ /** Texto fixo exigido na CC-e. */
12
+ export const CCE_COND_USO =
13
+ 'A Carta de Correcao e disciplinada pelo paragrafo 1o-A do art. 7o do Convenio S/N, ' +
14
+ 'de 15 de dezembro de 1970 e pode ser utilizada para regularizacao de erro ocorrido ' +
15
+ 'na emissao de documento fiscal, desde que o erro nao esteja relacionado com: ' +
16
+ 'I - as variaveis que determinam o valor do imposto tais como: base de calculo, ' +
17
+ 'aliquota, diferenca de preco, quantidade, valor da operacao ou da prestacao; ' +
18
+ 'II - a correcao de dados cadastrais que implique mudanca do remetente ou do destinatario; ' +
19
+ 'III - a data de emissao ou de saida.';
20
+
21
+ /**
22
+ * @typedef {Object} NFeEventoBase
23
+ * @property {string} chaveAcesso Chave da NF-e (44 dígitos)
24
+ * @property {string} cnpj CNPJ do autor do evento
25
+ * @property {string} uf Sigla UF
26
+ * @property {number} [ambiente] 1=Produção, 2=Homologação
27
+ * @property {number} [sequencia] nSeqEvento (default 1)
28
+ * @property {string} [idLote] ID do lote de eventos
29
+ */
30
+
31
+ /**
32
+ * @typedef {NFeEventoBase & {
33
+ * protocolo: string,
34
+ * justificativa: string,
35
+ * }} NFeCancelamento
36
+ */
37
+
38
+ /**
39
+ * @typedef {NFeEventoBase & {
40
+ * correcao: string,
41
+ * }} NFeCartaCorrecao
42
+ */
43
+
44
+ export {};
@@ -1,42 +1,42 @@
1
- import { NFSE_MUNICIPIOS } from './constants/municipios.js';
2
- import { GhinfeError } from '../errors/GhinfeError.js';
3
-
4
- /**
5
- * Resolve endpoint NFS-e por código IBGE do município.
6
- */
7
- export class NFSeMunicipioResolver {
8
- /** @type {Record<string, object>} */
9
- static #custom = {};
10
-
11
- /**
12
- * Registra endpoint customizado para um município.
13
- * @param {string} codigoMunicipio IBGE 7 dígitos
14
- * @param {{ nome?: string, homologacao: string, producao: string, layout?: string }} config
15
- */
16
- static registrar(codigoMunicipio, config) {
17
- this.#custom[codigoMunicipio] = config;
18
- }
19
-
20
- /**
21
- * @param {string} codigoMunicipio
22
- * @param {number} [ambiente] 1=Produção, 2=Homologação
23
- */
24
- static resolver(codigoMunicipio, ambiente = 2) {
25
- const config = this.#custom[codigoMunicipio] ?? NFSE_MUNICIPIOS[codigoMunicipio];
26
-
27
- if (!config) {
28
- throw new GhinfeError(
29
- `Endpoint NFS-e não configurado para município ${codigoMunicipio}. Use NFSeMunicipioResolver.registrar()`,
30
- 'NFSE_MUNICIPIO_NOT_FOUND'
31
- );
32
- }
33
-
34
- const url = ambiente === 1 ? config.producao : config.homologacao;
35
- return { url, layout: config.layout ?? 'abrasf', nome: config.nome };
36
- }
37
-
38
- /** @returns {string[]} */
39
- static listarMunicipios() {
40
- return [...new Set([...Object.keys(NFSE_MUNICIPIOS), ...Object.keys(this.#custom)])];
41
- }
42
- }
1
+ import { NFSE_MUNICIPIOS } from './constants/municipios.js';
2
+ import { GhinfeError } from '../errors/GhinfeError.js';
3
+
4
+ /**
5
+ * Resolve endpoint NFS-e por código IBGE do município.
6
+ */
7
+ export class NFSeMunicipioResolver {
8
+ /** @type {Record<string, object>} */
9
+ static #custom = {};
10
+
11
+ /**
12
+ * Registra endpoint customizado para um município.
13
+ * @param {string} codigoMunicipio IBGE 7 dígitos
14
+ * @param {{ nome?: string, homologacao: string, producao: string, layout?: string }} config
15
+ */
16
+ static registrar(codigoMunicipio, config) {
17
+ this.#custom[codigoMunicipio] = config;
18
+ }
19
+
20
+ /**
21
+ * @param {string} codigoMunicipio
22
+ * @param {number} [ambiente] 1=Produção, 2=Homologação
23
+ */
24
+ static resolver(codigoMunicipio, ambiente = 2) {
25
+ const config = this.#custom[codigoMunicipio] ?? NFSE_MUNICIPIOS[codigoMunicipio];
26
+
27
+ if (!config) {
28
+ throw new GhinfeError(
29
+ `Endpoint NFS-e não configurado para município ${codigoMunicipio}. Use NFSeMunicipioResolver.registrar()`,
30
+ 'NFSE_MUNICIPIO_NOT_FOUND'
31
+ );
32
+ }
33
+
34
+ const url = ambiente === 1 ? config.producao : config.homologacao;
35
+ return { url, layout: config.layout ?? 'abrasf', nome: config.nome };
36
+ }
37
+
38
+ /** @returns {string[]} */
39
+ static listarMunicipios() {
40
+ return [...new Set([...Object.keys(NFSE_MUNICIPIOS), ...Object.keys(this.#custom)])];
41
+ }
42
+ }