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.
- package/.env.example +24 -15
- package/LICENSE +21 -21
- package/README.md +491 -413
- package/docs/developer-guide.html +421 -421
- package/docs/openapi.yaml +428 -428
- package/examples/dce-homologacao.js +141 -0
- package/examples/emitir-nfce.js +51 -51
- package/examples/emitir-nfe.js +83 -83
- package/examples/emitir-nfse.js +46 -46
- package/examples/endpoints-sefaz.js +14 -14
- package/examples/eventos-nfe.js +49 -49
- package/examples/gerar-chave.js +25 -25
- package/examples/gerar-dace.js +59 -0
- package/examples/gerar-danfe.js +75 -75
- package/examples/gerar-dce.js +58 -0
- package/examples/layouts-nfse.js +51 -51
- package/examples/mock-sefaz.js +52 -52
- package/examples/nfse-eventos.js +57 -57
- package/examples/reforma-ibscbs.js +27 -27
- package/examples/reforma-nfe-xml.js +52 -52
- package/examples/status-sefaz.js +12 -12
- package/examples/validar-xsd.js +48 -48
- package/package.json +59 -68
- package/schemas/dce/PL_DCe_100a_NT2024.001/consulta/consSitDCeTiposBasico_v1.00.xsd +123 -0
- package/schemas/dce/PL_DCe_100a_NT2024.001/consulta/consSitDCe_v1.00.xsd +10 -0
- package/schemas/dce/PL_DCe_100a_NT2024.001/consulta/consStatServDCeTiposBasico_v1.00.xsd +110 -0
- package/schemas/dce/PL_DCe_100a_NT2024.001/consulta/consStatServDCe_v1.00.xsd +10 -0
- package/schemas/dce/PL_DCe_100a_NT2024.001/consulta/dceTiposBasico_v1.00.xsd +1388 -0
- package/schemas/dce/PL_DCe_100a_NT2024.001/consulta/retConsSitDCe_v1.00.xsd +10 -0
- package/schemas/dce/PL_DCe_100a_NT2024.001/consulta/retConsStatServDCe_v1.00.xsd +10 -0
- package/schemas/dce/PL_DCe_100a_NT2024.001/consulta/tiposGeralDCe_v1.00.xsd +712 -0
- package/schemas/dce/PL_DCe_100a_NT2024.001/consulta/xmldsig-core-schema_v1.01.xsd +98 -0
- package/schemas/dce/PL_DCe_100a_NT2024.001/dceTiposBasico_v1.00.xsd +1410 -0
- package/schemas/dce/PL_DCe_100a_NT2024.001/dce_v1.00.xsd +10 -0
- package/schemas/dce/PL_DCe_100a_NT2024.001/evento/evCancDCe_v1.00.xsd +36 -0
- package/schemas/dce/PL_DCe_100a_NT2024.001/evento/eventoDCeTiposBasico_v1.00.xsd +283 -0
- package/schemas/dce/PL_DCe_100a_NT2024.001/evento/eventoDCe_v1.00.xsd +9 -0
- package/schemas/dce/PL_DCe_100a_NT2024.001/evento/procEventoDCe_v1.00.xsd +10 -0
- package/schemas/dce/PL_DCe_100a_NT2024.001/evento/retEventoDCe_v1.00.xsd +9 -0
- package/schemas/dce/PL_DCe_100a_NT2024.001/evento/tiposGeralDCe_v1.00.xsd +712 -0
- package/schemas/dce/PL_DCe_100a_NT2024.001/evento/xmldsig-core-schema_v1.01.xsd +98 -0
- package/schemas/dce/PL_DCe_100a_NT2024.001/procDCe_v1.00.xsd +37 -0
- package/schemas/dce/PL_DCe_100a_NT2024.001/retDCe_v1.00.xsd +9 -0
- package/schemas/dce/PL_DCe_100a_NT2024.001/tiposGeralDCe_v1.00.xsd +712 -0
- package/schemas/dce/PL_DCe_100a_NT2024.001/xmldsig-core-schema_v1.01.xsd +98 -0
- package/schemas/nfe/PL_009_V4/enviNFe_v3.10.xsd +8 -8
- package/schemas/nfe/PL_009_V4/xmldsig-core-schema_v1.01.xsd +97 -97
- package/scripts/download-schemas.js +39 -39
- package/scripts/test-xsd.js +34 -34
- package/src/api/server.js +316 -316
- package/src/constants/sefaz.js +69 -69
- package/src/danfe/DanfeService.js +205 -205
- package/src/danfe/xml-extract.js +69 -69
- package/src/dce/builders/DCeEventoXmlBuilder.js +86 -0
- package/src/dce/builders/DCeXmlBuilder.js +345 -0
- package/src/dce/constants/dce.js +87 -0
- package/src/dce/dace/DaceService.js +356 -0
- package/src/dce/dace/dace-extract.js +114 -0
- package/src/dce/services/DCeService.js +263 -0
- package/src/dce/services/DCeSoapService.js +235 -0
- package/src/dce/services/DCeXmlService.js +67 -0
- package/src/dce/types/DCeDocument.js +106 -0
- package/src/dce/utils/qrcode.utils.js +59 -0
- package/src/errors/GhinfeError.js +13 -13
- package/src/errors/SefazError.js +25 -25
- package/src/errors/XsdValidationError.js +15 -15
- package/src/index.js +84 -60
- package/src/nfce/builders/NFCeXmlBuilder.js +178 -178
- package/src/nfce/constants/qrcode.js +26 -26
- package/src/nfce/services/NFCeService.js +188 -188
- package/src/nfce/services/NFCeXmlService.js +38 -38
- package/src/nfce/types/NFCeDocument.js +42 -42
- package/src/nfce/utils/qrcode.utils.js +92 -92
- package/src/nfe/builders/NFeEventoXmlBuilder.js +110 -110
- package/src/nfe/builders/NFeXmlBuilder.js +215 -215
- package/src/nfe/mocks/sefaz-responses.js +195 -195
- package/src/nfe/services/NFeEventoService.js +95 -95
- package/src/nfe/services/NFeService.js +196 -196
- package/src/nfe/services/NFeSignService.js +127 -111
- package/src/nfe/services/NFeSoapService.js +437 -437
- package/src/nfe/services/NFeXmlService.js +41 -41
- package/src/nfe/services/NFeXsdService.js +56 -56
- package/src/nfe/types/NFeDocument.js +92 -92
- package/src/nfe/types/NFeEvento.js +44 -44
- package/src/nfse/NFSeMunicipioResolver.js +42 -42
- package/src/nfse/builders/NFSeEventoXmlBuilder.js +92 -92
- package/src/nfse/builders/NFSeXmlBuilder.js +16 -16
- package/src/nfse/constants/municipios.js +82 -82
- package/src/nfse/layouts/adapters.js +202 -202
- package/src/nfse/mocks/nfse-responses.js +142 -142
- package/src/nfse/services/NFSeService.js +191 -191
- package/src/nfse/services/NFSeSoapService.js +232 -232
- package/src/nfse/services/NFSeXmlService.js +12 -12
- package/src/nfse/types/NFSeDocument.js +54 -54
- package/src/queue/NFCeQueue.js +63 -63
- package/src/queue/NFSeQueue.js +59 -59
- package/src/queue/NFeQueue.js +76 -76
- package/src/reforma/ibscbs.js +175 -175
- package/src/sefaz/SefazEndpointResolver.js +95 -95
- package/src/sefaz/ca/icp-brasil-raiz-v10.pem +38 -0
- package/src/sefaz/endpoints.registry.js +205 -205
- package/src/sefaz/httpsAgent.js +33 -0
- package/src/shared/fiscal.helpers.js +53 -53
- package/src/utils/certificate.utils.js +69 -47
- package/src/utils/chave.utils.js +205 -117
- package/src/utils/code128.utils.js +67 -0
- package/src/utils/date.utils.js +26 -26
- package/src/utils/xml.utils.js +44 -44
- package/src/validation/XsdValidator.js +133 -114
- package/src/validation/schemas.js +18 -14
|
@@ -1,27 +1,27 @@
|
|
|
1
|
-
import { calcularIBSCBS, buildFragmentoIBSCBS, somarTotaisReforma, REFORMA_LAYOUT } from '../src/index.js';
|
|
2
|
-
|
|
3
|
-
console.log(`=== GHINFE — Reforma Tributária (${REFORMA_LAYOUT}) ===\n`);
|
|
4
|
-
|
|
5
|
-
const itens = [
|
|
6
|
-
{ descricao: 'Produto A', valorTotal: 100 },
|
|
7
|
-
{ descricao: 'Produto B', valorTotal: 250 },
|
|
8
|
-
].map((item) => ({
|
|
9
|
-
...item,
|
|
10
|
-
reforma: calcularIBSCBS(item.valorTotal, {
|
|
11
|
-
pIBSUF: 0.1,
|
|
12
|
-
pIBSMun: 0.05,
|
|
13
|
-
pCBS: 0.9,
|
|
14
|
-
cClassTrib: '000001',
|
|
15
|
-
}),
|
|
16
|
-
}));
|
|
17
|
-
|
|
18
|
-
for (const item of itens) {
|
|
19
|
-
console.log(`${item.descricao}: BC=${item.reforma.vBC}`);
|
|
20
|
-
console.log(` IBS-UF=${item.reforma.vIBSUF} IBS-Mun=${item.reforma.vIBSMun} CBS=${item.reforma.vCBS}`);
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
const totais = somarTotaisReforma(itens);
|
|
24
|
-
console.log('\nTotais:', totais);
|
|
25
|
-
console.log('\nFragmento XML experimental (item 1):\n');
|
|
26
|
-
console.log(buildFragmentoIBSCBS(itens[0].reforma));
|
|
27
|
-
console.log('\nNota: fragmento não é injetado no XML NF-e até schemas PL_010 estáveis.');
|
|
1
|
+
import { calcularIBSCBS, buildFragmentoIBSCBS, somarTotaisReforma, REFORMA_LAYOUT } from '../src/index.js';
|
|
2
|
+
|
|
3
|
+
console.log(`=== GHINFE — Reforma Tributária (${REFORMA_LAYOUT}) ===\n`);
|
|
4
|
+
|
|
5
|
+
const itens = [
|
|
6
|
+
{ descricao: 'Produto A', valorTotal: 100 },
|
|
7
|
+
{ descricao: 'Produto B', valorTotal: 250 },
|
|
8
|
+
].map((item) => ({
|
|
9
|
+
...item,
|
|
10
|
+
reforma: calcularIBSCBS(item.valorTotal, {
|
|
11
|
+
pIBSUF: 0.1,
|
|
12
|
+
pIBSMun: 0.05,
|
|
13
|
+
pCBS: 0.9,
|
|
14
|
+
cClassTrib: '000001',
|
|
15
|
+
}),
|
|
16
|
+
}));
|
|
17
|
+
|
|
18
|
+
for (const item of itens) {
|
|
19
|
+
console.log(`${item.descricao}: BC=${item.reforma.vBC}`);
|
|
20
|
+
console.log(` IBS-UF=${item.reforma.vIBSUF} IBS-Mun=${item.reforma.vIBSMun} CBS=${item.reforma.vCBS}`);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const totais = somarTotaisReforma(itens);
|
|
24
|
+
console.log('\nTotais:', totais);
|
|
25
|
+
console.log('\nFragmento XML experimental (item 1):\n');
|
|
26
|
+
console.log(buildFragmentoIBSCBS(itens[0].reforma));
|
|
27
|
+
console.log('\nNota: fragmento não é injetado no XML NF-e até schemas PL_010 estáveis.');
|
|
@@ -1,52 +1,52 @@
|
|
|
1
|
-
import { NFeService, calcularIBSCBS } from '../src/index.js';
|
|
2
|
-
|
|
3
|
-
const documento = {
|
|
4
|
-
ambiente: 2,
|
|
5
|
-
reformaTributaria: true,
|
|
6
|
-
ide: { uf: 'SP', codigoMunicipio: '3550308', serie: 1, numero: 99 },
|
|
7
|
-
emitente: {
|
|
8
|
-
cnpj: '12345678000199',
|
|
9
|
-
razaoSocial: 'EMPRESA EXEMPLO LTDA',
|
|
10
|
-
ie: '123456789012',
|
|
11
|
-
crt: '3',
|
|
12
|
-
endereco: {
|
|
13
|
-
logradouro: 'Rua A', numero: '1', bairro: 'Centro',
|
|
14
|
-
codigoMunicipio: '3550308', municipio: 'Sao Paulo', uf: 'SP', cep: '01001000',
|
|
15
|
-
},
|
|
16
|
-
},
|
|
17
|
-
destinatario: {
|
|
18
|
-
cpf: '12345678909',
|
|
19
|
-
razaoSocial: 'CONSUMIDOR',
|
|
20
|
-
indIEDest: 9,
|
|
21
|
-
endereco: {
|
|
22
|
-
logradouro: 'Rua B', numero: '2', bairro: 'Centro',
|
|
23
|
-
codigoMunicipio: '3550308', municipio: 'Sao Paulo', uf: 'SP', cep: '01001000',
|
|
24
|
-
},
|
|
25
|
-
},
|
|
26
|
-
itens: [{
|
|
27
|
-
codigo: '001',
|
|
28
|
-
descricao: 'PRODUTO COM IBS/CBS',
|
|
29
|
-
ncm: '84713012',
|
|
30
|
-
cfop: '5102',
|
|
31
|
-
unidade: 'UN',
|
|
32
|
-
quantidade: 1,
|
|
33
|
-
valorUnitario: 100,
|
|
34
|
-
valorTotal: 100,
|
|
35
|
-
cst: '00',
|
|
36
|
-
aliquotaIcms: 18,
|
|
37
|
-
valorIcms: 18,
|
|
38
|
-
reforma: calcularIBSCBS(100, { pIBSUF: 0.1, pIBSMun: 0.05, pCBS: 0.9, cClassTrib: '000001' }),
|
|
39
|
-
}],
|
|
40
|
-
frete: { modalidade: 9 },
|
|
41
|
-
pagamentos: [{ forma: '01', valor: 100 }],
|
|
42
|
-
};
|
|
43
|
-
|
|
44
|
-
const service = new NFeService();
|
|
45
|
-
const doc = service.resolverDocumento(documento);
|
|
46
|
-
const xml = service.gerarXml(doc);
|
|
47
|
-
|
|
48
|
-
console.log('=== GHINFE — NF-e com IBS/CBS injetado ===\n');
|
|
49
|
-
console.log('Chave:', doc.chaveAcesso);
|
|
50
|
-
console.log('Contém IBSCBS:', xml.includes('<IBSCBS>'));
|
|
51
|
-
console.log('Contém IBSCBSTot:', xml.includes('<IBSCBSTot>'));
|
|
52
|
-
console.log('\nTrecho imposto:\n', xml.match(/<IBSCBS>[\s\S]*?<\/IBSCBS>/)?.[0]?.substring(0, 400));
|
|
1
|
+
import { NFeService, calcularIBSCBS } from '../src/index.js';
|
|
2
|
+
|
|
3
|
+
const documento = {
|
|
4
|
+
ambiente: 2,
|
|
5
|
+
reformaTributaria: true,
|
|
6
|
+
ide: { uf: 'SP', codigoMunicipio: '3550308', serie: 1, numero: 99 },
|
|
7
|
+
emitente: {
|
|
8
|
+
cnpj: '12345678000199',
|
|
9
|
+
razaoSocial: 'EMPRESA EXEMPLO LTDA',
|
|
10
|
+
ie: '123456789012',
|
|
11
|
+
crt: '3',
|
|
12
|
+
endereco: {
|
|
13
|
+
logradouro: 'Rua A', numero: '1', bairro: 'Centro',
|
|
14
|
+
codigoMunicipio: '3550308', municipio: 'Sao Paulo', uf: 'SP', cep: '01001000',
|
|
15
|
+
},
|
|
16
|
+
},
|
|
17
|
+
destinatario: {
|
|
18
|
+
cpf: '12345678909',
|
|
19
|
+
razaoSocial: 'CONSUMIDOR',
|
|
20
|
+
indIEDest: 9,
|
|
21
|
+
endereco: {
|
|
22
|
+
logradouro: 'Rua B', numero: '2', bairro: 'Centro',
|
|
23
|
+
codigoMunicipio: '3550308', municipio: 'Sao Paulo', uf: 'SP', cep: '01001000',
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
itens: [{
|
|
27
|
+
codigo: '001',
|
|
28
|
+
descricao: 'PRODUTO COM IBS/CBS',
|
|
29
|
+
ncm: '84713012',
|
|
30
|
+
cfop: '5102',
|
|
31
|
+
unidade: 'UN',
|
|
32
|
+
quantidade: 1,
|
|
33
|
+
valorUnitario: 100,
|
|
34
|
+
valorTotal: 100,
|
|
35
|
+
cst: '00',
|
|
36
|
+
aliquotaIcms: 18,
|
|
37
|
+
valorIcms: 18,
|
|
38
|
+
reforma: calcularIBSCBS(100, { pIBSUF: 0.1, pIBSMun: 0.05, pCBS: 0.9, cClassTrib: '000001' }),
|
|
39
|
+
}],
|
|
40
|
+
frete: { modalidade: 9 },
|
|
41
|
+
pagamentos: [{ forma: '01', valor: 100 }],
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
const service = new NFeService();
|
|
45
|
+
const doc = service.resolverDocumento(documento);
|
|
46
|
+
const xml = service.gerarXml(doc);
|
|
47
|
+
|
|
48
|
+
console.log('=== GHINFE — NF-e com IBS/CBS injetado ===\n');
|
|
49
|
+
console.log('Chave:', doc.chaveAcesso);
|
|
50
|
+
console.log('Contém IBSCBS:', xml.includes('<IBSCBS>'));
|
|
51
|
+
console.log('Contém IBSCBSTot:', xml.includes('<IBSCBSTot>'));
|
|
52
|
+
console.log('\nTrecho imposto:\n', xml.match(/<IBSCBS>[\s\S]*?<\/IBSCBS>/)?.[0]?.substring(0, 400));
|
package/examples/status-sefaz.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { NFeService } from '../src/index.js';
|
|
2
|
-
|
|
3
|
-
console.log('=== GHINFE — Status SEFAZ (mock) ===\n');
|
|
4
|
-
|
|
5
|
-
const service = new NFeService({ mock: true });
|
|
6
|
-
|
|
7
|
-
for (const cenario of ['ok', 'paralisado']) {
|
|
8
|
-
service.soapService.setMockStatusScenario(cenario);
|
|
9
|
-
const status = await service.consultarStatus('SP', 2);
|
|
10
|
-
console.log(`[${cenario}] cStat=${status.cStat} — ${status.xMotivo}`);
|
|
11
|
-
console.log(` emOperacao=${status.emOperacao} tMed=${status.tMed}\n`);
|
|
12
|
-
}
|
|
1
|
+
import { NFeService } from '../src/index.js';
|
|
2
|
+
|
|
3
|
+
console.log('=== GHINFE — Status SEFAZ (mock) ===\n');
|
|
4
|
+
|
|
5
|
+
const service = new NFeService({ mock: true });
|
|
6
|
+
|
|
7
|
+
for (const cenario of ['ok', 'paralisado']) {
|
|
8
|
+
service.soapService.setMockStatusScenario(cenario);
|
|
9
|
+
const status = await service.consultarStatus('SP', 2);
|
|
10
|
+
console.log(`[${cenario}] cStat=${status.cStat} — ${status.xMotivo}`);
|
|
11
|
+
console.log(` emOperacao=${status.emOperacao} tMed=${status.tMed}\n`);
|
|
12
|
+
}
|
package/examples/validar-xsd.js
CHANGED
|
@@ -1,48 +1,48 @@
|
|
|
1
|
-
import { NFeService } from '../src/index.js';
|
|
2
|
-
|
|
3
|
-
const service = new NFeService({ validarXsd: true });
|
|
4
|
-
|
|
5
|
-
const documento = {
|
|
6
|
-
ambiente: 2,
|
|
7
|
-
ide: { uf: 'SP', codigoMunicipio: '3550308', serie: 1, numero: 1 },
|
|
8
|
-
emitente: {
|
|
9
|
-
cnpj: '12345678000199',
|
|
10
|
-
razaoSocial: 'EMPRESA EXEMPLO LTDA',
|
|
11
|
-
ie: '123456789012',
|
|
12
|
-
crt: '3',
|
|
13
|
-
endereco: {
|
|
14
|
-
logradouro: 'Rua Exemplo', numero: '100', bairro: 'Centro',
|
|
15
|
-
codigoMunicipio: '3550308', municipio: 'Sao Paulo', uf: 'SP', cep: '01001000',
|
|
16
|
-
},
|
|
17
|
-
},
|
|
18
|
-
destinatario: {
|
|
19
|
-
cpf: '12345678909',
|
|
20
|
-
razaoSocial: 'NF-E EMITIDA EM AMBIENTE DE HOMOLOGACAO - SEM VALOR FISCAL',
|
|
21
|
-
indIEDest: 9,
|
|
22
|
-
endereco: {
|
|
23
|
-
logradouro: 'Rua Cliente', numero: '200', bairro: 'Jardim',
|
|
24
|
-
codigoMunicipio: '3550308', municipio: 'Sao Paulo', uf: 'SP', cep: '01020000',
|
|
25
|
-
},
|
|
26
|
-
},
|
|
27
|
-
itens: [{
|
|
28
|
-
codigo: '001',
|
|
29
|
-
descricao: 'NOTA FISCAL EMITIDA EM AMBIENTE DE HOMOLOGACAO - SEM VALOR FISCAL',
|
|
30
|
-
ncm: '84713012', cfop: '5102', unidade: 'UN',
|
|
31
|
-
quantidade: 1, valorUnitario: 100, valorTotal: 100,
|
|
32
|
-
cst: '00', aliquotaIcms: 18, valorIcms: 18,
|
|
33
|
-
}],
|
|
34
|
-
frete: { modalidade: 9 },
|
|
35
|
-
pagamentos: [{ forma: '01', valor: 100 }],
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
console.log('=== GHINFE — Validação XSD NF-e ===\n');
|
|
39
|
-
|
|
40
|
-
try {
|
|
41
|
-
const xml = service.gerarXml(documento);
|
|
42
|
-
console.log('XML gerado e validado contra XSD oficial (PL_009_V4)');
|
|
43
|
-
console.log('Chave:', service.resolverDocumento(documento).chaveAcesso);
|
|
44
|
-
console.log('Tamanho XML:', xml.length, 'bytes');
|
|
45
|
-
} catch (error) {
|
|
46
|
-
console.error('Falha:', error.message);
|
|
47
|
-
if (error.erros) error.erros.forEach((e) => console.error(' -', e));
|
|
48
|
-
}
|
|
1
|
+
import { NFeService } from '../src/index.js';
|
|
2
|
+
|
|
3
|
+
const service = new NFeService({ validarXsd: true });
|
|
4
|
+
|
|
5
|
+
const documento = {
|
|
6
|
+
ambiente: 2,
|
|
7
|
+
ide: { uf: 'SP', codigoMunicipio: '3550308', serie: 1, numero: 1 },
|
|
8
|
+
emitente: {
|
|
9
|
+
cnpj: '12345678000199',
|
|
10
|
+
razaoSocial: 'EMPRESA EXEMPLO LTDA',
|
|
11
|
+
ie: '123456789012',
|
|
12
|
+
crt: '3',
|
|
13
|
+
endereco: {
|
|
14
|
+
logradouro: 'Rua Exemplo', numero: '100', bairro: 'Centro',
|
|
15
|
+
codigoMunicipio: '3550308', municipio: 'Sao Paulo', uf: 'SP', cep: '01001000',
|
|
16
|
+
},
|
|
17
|
+
},
|
|
18
|
+
destinatario: {
|
|
19
|
+
cpf: '12345678909',
|
|
20
|
+
razaoSocial: 'NF-E EMITIDA EM AMBIENTE DE HOMOLOGACAO - SEM VALOR FISCAL',
|
|
21
|
+
indIEDest: 9,
|
|
22
|
+
endereco: {
|
|
23
|
+
logradouro: 'Rua Cliente', numero: '200', bairro: 'Jardim',
|
|
24
|
+
codigoMunicipio: '3550308', municipio: 'Sao Paulo', uf: 'SP', cep: '01020000',
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
itens: [{
|
|
28
|
+
codigo: '001',
|
|
29
|
+
descricao: 'NOTA FISCAL EMITIDA EM AMBIENTE DE HOMOLOGACAO - SEM VALOR FISCAL',
|
|
30
|
+
ncm: '84713012', cfop: '5102', unidade: 'UN',
|
|
31
|
+
quantidade: 1, valorUnitario: 100, valorTotal: 100,
|
|
32
|
+
cst: '00', aliquotaIcms: 18, valorIcms: 18,
|
|
33
|
+
}],
|
|
34
|
+
frete: { modalidade: 9 },
|
|
35
|
+
pagamentos: [{ forma: '01', valor: 100 }],
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
console.log('=== GHINFE — Validação XSD NF-e ===\n');
|
|
39
|
+
|
|
40
|
+
try {
|
|
41
|
+
const xml = service.gerarXml(documento);
|
|
42
|
+
console.log('XML gerado e validado contra XSD oficial (PL_009_V4)');
|
|
43
|
+
console.log('Chave:', service.resolverDocumento(documento).chaveAcesso);
|
|
44
|
+
console.log('Tamanho XML:', xml.length, 'bytes');
|
|
45
|
+
} catch (error) {
|
|
46
|
+
console.error('Falha:', error.message);
|
|
47
|
+
if (error.erros) error.erros.forEach((e) => console.error(' -', e));
|
|
48
|
+
}
|
package/package.json
CHANGED
|
@@ -1,68 +1,59 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "ghinfe",
|
|
3
|
-
"version": "0.6.
|
|
4
|
-
"description": "Biblioteca Node.js para emissão de NF-e, NFC-e e
|
|
5
|
-
"main": "src/index.js",
|
|
6
|
-
"type": "module",
|
|
7
|
-
"scripts": {
|
|
8
|
-
"start": "node src/api/server.js",
|
|
9
|
-
"example:nfe": "node examples/emitir-nfe.js",
|
|
10
|
-
"example:mock": "node examples/mock-sefaz.js",
|
|
11
|
-
"example:chave": "node examples/gerar-chave.js",
|
|
12
|
-
"example:eventos": "node examples/eventos-nfe.js",
|
|
13
|
-
"example:xsd": "node examples/validar-xsd.js",
|
|
14
|
-
"example:nfce": "node examples/emitir-nfce.js",
|
|
15
|
-
"example:nfse": "node examples/emitir-nfse.js",
|
|
16
|
-
"example:endpoints": "node examples/endpoints-sefaz.js",
|
|
17
|
-
"example:status": "node examples/status-sefaz.js",
|
|
18
|
-
"example:layouts": "node examples/layouts-nfse.js",
|
|
19
|
-
"example:reforma": "node examples/reforma-ibscbs.js",
|
|
20
|
-
"example:reforma-xml": "node examples/reforma-nfe-xml.js",
|
|
21
|
-
"example:nfse-eventos": "node examples/nfse-eventos.js",
|
|
22
|
-
"example:danfe": "node examples/gerar-danfe.js",
|
|
23
|
-
"
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
"
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
"
|
|
30
|
-
"
|
|
31
|
-
"
|
|
32
|
-
"
|
|
33
|
-
"
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
"
|
|
41
|
-
|
|
42
|
-
"
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
"
|
|
46
|
-
"
|
|
47
|
-
"
|
|
48
|
-
"
|
|
49
|
-
"
|
|
50
|
-
"
|
|
51
|
-
"
|
|
52
|
-
"
|
|
53
|
-
"
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
"
|
|
57
|
-
"
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
"repository": {
|
|
61
|
-
"type": "git",
|
|
62
|
-
"url": "git+https://github.com/vhghilardi/ghinfe.git"
|
|
63
|
-
},
|
|
64
|
-
"bugs": {
|
|
65
|
-
"url": "https://github.com/vhghilardi/ghinfe/issues"
|
|
66
|
-
},
|
|
67
|
-
"homepage": "https://github.com/vhghilardi/ghinfe#readme"
|
|
68
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "ghinfe",
|
|
3
|
+
"version": "0.6.2",
|
|
4
|
+
"description": "Biblioteca Node.js para emissão de NF-e, NFC-e, NFS-e e DC-e — geração de XML, assinatura A1, envio SEFAZ e filas Bull/Redis",
|
|
5
|
+
"main": "src/index.js",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"scripts": {
|
|
8
|
+
"start": "node src/api/server.js",
|
|
9
|
+
"example:nfe": "node examples/emitir-nfe.js",
|
|
10
|
+
"example:mock": "node examples/mock-sefaz.js",
|
|
11
|
+
"example:chave": "node examples/gerar-chave.js",
|
|
12
|
+
"example:eventos": "node examples/eventos-nfe.js",
|
|
13
|
+
"example:xsd": "node examples/validar-xsd.js",
|
|
14
|
+
"example:nfce": "node examples/emitir-nfce.js",
|
|
15
|
+
"example:nfse": "node examples/emitir-nfse.js",
|
|
16
|
+
"example:endpoints": "node examples/endpoints-sefaz.js",
|
|
17
|
+
"example:status": "node examples/status-sefaz.js",
|
|
18
|
+
"example:layouts": "node examples/layouts-nfse.js",
|
|
19
|
+
"example:reforma": "node examples/reforma-ibscbs.js",
|
|
20
|
+
"example:reforma-xml": "node examples/reforma-nfe-xml.js",
|
|
21
|
+
"example:nfse-eventos": "node examples/nfse-eventos.js",
|
|
22
|
+
"example:danfe": "node examples/gerar-danfe.js",
|
|
23
|
+
"example:dce": "node examples/gerar-dce.js",
|
|
24
|
+
"example:dce-homologacao": "node examples/dce-homologacao.js",
|
|
25
|
+
"example:dace": "node examples/gerar-dace.js",
|
|
26
|
+
"schemas:download": "node scripts/download-schemas.js"
|
|
27
|
+
},
|
|
28
|
+
"keywords": [
|
|
29
|
+
"nfe",
|
|
30
|
+
"nfce",
|
|
31
|
+
"nfse",
|
|
32
|
+
"dce",
|
|
33
|
+
"sefaz",
|
|
34
|
+
"nota-fiscal",
|
|
35
|
+
"fiscal",
|
|
36
|
+
"brasil",
|
|
37
|
+
"acbr"
|
|
38
|
+
],
|
|
39
|
+
"author": "",
|
|
40
|
+
"license": "MIT",
|
|
41
|
+
"engines": {
|
|
42
|
+
"node": ">=18.0.0"
|
|
43
|
+
},
|
|
44
|
+
"dependencies": {
|
|
45
|
+
"@xmldom/xmldom": "^0.9.8",
|
|
46
|
+
"axios": "^1.7.9",
|
|
47
|
+
"bull": "^4.16.5",
|
|
48
|
+
"dotenv": "^16.4.7",
|
|
49
|
+
"express": "^4.21.2",
|
|
50
|
+
"ioredis": "^5.4.2",
|
|
51
|
+
"libxmljs2": "^0.37.0",
|
|
52
|
+
"node-forge": "^1.3.1",
|
|
53
|
+
"qrcode": "^1.5.4",
|
|
54
|
+
"swagger-ui-express": "^5.0.1",
|
|
55
|
+
"xml-crypto": "^6.0.0",
|
|
56
|
+
"xmlbuilder2": "^3.1.1",
|
|
57
|
+
"yamljs": "^0.3.0"
|
|
58
|
+
}
|
|
59
|
+
}
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<!-- edited with XMLSpy v2014 rel. 2 (http://www.altova.com) by private (private) -->
|
|
3
|
+
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="http://www.portalfiscal.inf.br/dce" xmlns:ds="http://www.w3.org/2000/09/xmldsig#" targetNamespace="http://www.portalfiscal.inf.br/dce" elementFormDefault="qualified" attributeFormDefault="unqualified">
|
|
4
|
+
<xs:include schemaLocation="tiposGeralDCe_v1.00.xsd"/>
|
|
5
|
+
<xs:import namespace="http://www.w3.org/2000/09/xmldsig#" schemaLocation="xmldsig-core-schema_v1.01.xsd"/>
|
|
6
|
+
<xs:complexType name="TConsSitDCe">
|
|
7
|
+
<xs:annotation>
|
|
8
|
+
<xs:documentation>Tipo Pedido de Consulta da Situação Atual da DCe</xs:documentation>
|
|
9
|
+
</xs:annotation>
|
|
10
|
+
<xs:sequence>
|
|
11
|
+
<xs:element name="tpAmb" type="TAmb">
|
|
12
|
+
<xs:annotation>
|
|
13
|
+
<xs:documentation>Identificação do Ambiente:
|
|
14
|
+
1 - Produção;
|
|
15
|
+
2 - Homologação;</xs:documentation>
|
|
16
|
+
</xs:annotation>
|
|
17
|
+
</xs:element>
|
|
18
|
+
<xs:element name="xServ" type="TServ" fixed="CONSULTAR">
|
|
19
|
+
<xs:annotation>
|
|
20
|
+
<xs:documentation>Serviço Solicitado</xs:documentation>
|
|
21
|
+
</xs:annotation>
|
|
22
|
+
</xs:element>
|
|
23
|
+
<xs:element name="chDCe" type="TChDFe">
|
|
24
|
+
<xs:annotation>
|
|
25
|
+
<xs:documentation>Chaves de acesso do DCe</xs:documentation>
|
|
26
|
+
</xs:annotation>
|
|
27
|
+
</xs:element>
|
|
28
|
+
</xs:sequence>
|
|
29
|
+
<xs:attribute name="versao" type="TVerConsSitDCe" use="required"/>
|
|
30
|
+
</xs:complexType>
|
|
31
|
+
<xs:complexType name="TRetConsSitDCe">
|
|
32
|
+
<xs:annotation>
|
|
33
|
+
<xs:documentation>Tipo Retorno de Pedido de Consulta da Situação Atual de DCe</xs:documentation>
|
|
34
|
+
</xs:annotation>
|
|
35
|
+
<xs:sequence>
|
|
36
|
+
<xs:element name="tpAmb" type="TAmb">
|
|
37
|
+
<xs:annotation>
|
|
38
|
+
<xs:documentation>Identificação do Ambiente:
|
|
39
|
+
1 - Produção
|
|
40
|
+
2 - Homologação</xs:documentation>
|
|
41
|
+
</xs:annotation>
|
|
42
|
+
</xs:element>
|
|
43
|
+
<xs:element name="verAplic" type="TVerAplic">
|
|
44
|
+
<xs:annotation>
|
|
45
|
+
<xs:documentation>Versão do Aplicativo que processou o DCe</xs:documentation>
|
|
46
|
+
</xs:annotation>
|
|
47
|
+
</xs:element>
|
|
48
|
+
<xs:element name="cStat" type="TStat">
|
|
49
|
+
<xs:annotation>
|
|
50
|
+
<xs:documentation>Código do status da mensagem enviada.</xs:documentation>
|
|
51
|
+
</xs:annotation>
|
|
52
|
+
</xs:element>
|
|
53
|
+
<xs:element name="xMotivo" type="TMotivo">
|
|
54
|
+
<xs:annotation>
|
|
55
|
+
<xs:documentation>Descrição literal do status do serviço solicitado.</xs:documentation>
|
|
56
|
+
</xs:annotation>
|
|
57
|
+
</xs:element>
|
|
58
|
+
<xs:element name="cUF" type="TCodUfIBGE">
|
|
59
|
+
<xs:annotation>
|
|
60
|
+
<xs:documentation>código da UF de atendimento</xs:documentation>
|
|
61
|
+
</xs:annotation>
|
|
62
|
+
</xs:element>
|
|
63
|
+
<xs:element name="dhRecbto" type="TDateTimeUTC">
|
|
64
|
+
<xs:annotation>
|
|
65
|
+
<xs:documentation>Preenchido com a data e hora do processamento (informado também no caso de rejeição).
|
|
66
|
+
Formato: “AAAA-MM-DDThh:mm:ssTZD” (UTC – Universal Coordinated Time).</xs:documentation>
|
|
67
|
+
</xs:annotation>
|
|
68
|
+
</xs:element>
|
|
69
|
+
<xs:element name="chDCe" type="TChDFe">
|
|
70
|
+
<xs:annotation>
|
|
71
|
+
<xs:documentation>Chaves de acesso do DCe</xs:documentation>
|
|
72
|
+
</xs:annotation>
|
|
73
|
+
</xs:element>
|
|
74
|
+
<xs:element name="protDCe" minOccurs="0">
|
|
75
|
+
<xs:complexType>
|
|
76
|
+
<xs:sequence>
|
|
77
|
+
<xs:any processContents="skip">
|
|
78
|
+
<xs:annotation>
|
|
79
|
+
<xs:documentation>Retornar protDCe da versão correspondente da DCe autorizada</xs:documentation>
|
|
80
|
+
</xs:annotation>
|
|
81
|
+
</xs:any>
|
|
82
|
+
</xs:sequence>
|
|
83
|
+
<xs:attribute name="versao" use="required">
|
|
84
|
+
<xs:simpleType>
|
|
85
|
+
<xs:restriction base="xs:string">
|
|
86
|
+
<xs:whiteSpace value="preserve"/>
|
|
87
|
+
<xs:enumeration value="1.00"/>
|
|
88
|
+
</xs:restriction>
|
|
89
|
+
</xs:simpleType>
|
|
90
|
+
</xs:attribute>
|
|
91
|
+
</xs:complexType>
|
|
92
|
+
</xs:element>
|
|
93
|
+
<xs:element name="procEventoDCe" minOccurs="0" maxOccurs="unbounded">
|
|
94
|
+
<xs:complexType>
|
|
95
|
+
<xs:sequence>
|
|
96
|
+
<xs:any processContents="skip">
|
|
97
|
+
<xs:annotation>
|
|
98
|
+
<xs:documentation>Retornar procEventoDCe da versão correspondente do evento DCe autorizado</xs:documentation>
|
|
99
|
+
</xs:annotation>
|
|
100
|
+
</xs:any>
|
|
101
|
+
</xs:sequence>
|
|
102
|
+
<xs:attribute name="versao" use="required">
|
|
103
|
+
<xs:simpleType>
|
|
104
|
+
<xs:restriction base="xs:string">
|
|
105
|
+
<xs:whiteSpace value="preserve"/>
|
|
106
|
+
<xs:enumeration value="1.00"/>
|
|
107
|
+
</xs:restriction>
|
|
108
|
+
</xs:simpleType>
|
|
109
|
+
</xs:attribute>
|
|
110
|
+
</xs:complexType>
|
|
111
|
+
</xs:element>
|
|
112
|
+
</xs:sequence>
|
|
113
|
+
<xs:attribute name="versao" type="TVerConsSitDCe" use="required"/>
|
|
114
|
+
</xs:complexType>
|
|
115
|
+
<xs:simpleType name="TVerConsSitDCe">
|
|
116
|
+
<xs:annotation>
|
|
117
|
+
<xs:documentation> Tipo Versão do Consulta situação de DCe - 1.00</xs:documentation>
|
|
118
|
+
</xs:annotation>
|
|
119
|
+
<xs:restriction base="xs:string">
|
|
120
|
+
<xs:pattern value="1\.00"/>
|
|
121
|
+
</xs:restriction>
|
|
122
|
+
</xs:simpleType>
|
|
123
|
+
</xs:schema>
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<!-- edited with XMLSpy v2014 rel. 2 (http://www.altova.com) by private (private) -->
|
|
3
|
+
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="http://www.portalfiscal.inf.br/dce" targetNamespace="http://www.portalfiscal.inf.br/dce" elementFormDefault="qualified" attributeFormDefault="unqualified">
|
|
4
|
+
<xs:include schemaLocation="consSitDCeTiposBasico_v1.00.xsd"/>
|
|
5
|
+
<xs:element name="consSitDCe" type="TConsSitDCe">
|
|
6
|
+
<xs:annotation>
|
|
7
|
+
<xs:documentation>Schema de validação XML do Pedido de Consulta da Situação Atual da DCe</xs:documentation>
|
|
8
|
+
</xs:annotation>
|
|
9
|
+
</xs:element>
|
|
10
|
+
</xs:schema>
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<!-- edited with XMLSpy v2014 rel. 2 (http://www.altova.com) by private (private) -->
|
|
3
|
+
<xs:schema xmlns:ds="http://www.w3.org/2000/09/xmldsig#" xmlns="http://www.portalfiscal.inf.br/dce" xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.portalfiscal.inf.br/dce" elementFormDefault="qualified" attributeFormDefault="unqualified">
|
|
4
|
+
<xs:include schemaLocation="tiposGeralDCe_v1.00.xsd"/>
|
|
5
|
+
<xs:complexType name="TConsStatServ">
|
|
6
|
+
<xs:annotation>
|
|
7
|
+
<xs:documentation>Tipo Pedido de Consulta do Status do Serviço DCe</xs:documentation>
|
|
8
|
+
</xs:annotation>
|
|
9
|
+
<xs:sequence>
|
|
10
|
+
<xs:element name="tpAmb" type="TAmb">
|
|
11
|
+
<xs:annotation>
|
|
12
|
+
<xs:documentation>Identificação do Ambiente:
|
|
13
|
+
1 - Produção
|
|
14
|
+
2 - Homologação</xs:documentation>
|
|
15
|
+
</xs:annotation>
|
|
16
|
+
</xs:element>
|
|
17
|
+
<xs:element name="cUF" type="TCodUfIBGE">
|
|
18
|
+
<xs:annotation>
|
|
19
|
+
<xs:documentation>código da UF de atendimento</xs:documentation>
|
|
20
|
+
</xs:annotation>
|
|
21
|
+
</xs:element>
|
|
22
|
+
<xs:element name="xServ" type="TServ" fixed="STATUS">
|
|
23
|
+
<xs:annotation>
|
|
24
|
+
<xs:documentation>Serviço Solicitado</xs:documentation>
|
|
25
|
+
</xs:annotation>
|
|
26
|
+
</xs:element>
|
|
27
|
+
</xs:sequence>
|
|
28
|
+
<xs:attribute name="versao" type="TVerConsStat" use="required"/>
|
|
29
|
+
</xs:complexType>
|
|
30
|
+
<xs:complexType name="TRetConsStatServ">
|
|
31
|
+
<xs:annotation>
|
|
32
|
+
<xs:documentation>Tipo Resultado da Consulta do Status do Serviço DCe</xs:documentation>
|
|
33
|
+
</xs:annotation>
|
|
34
|
+
<xs:sequence>
|
|
35
|
+
<xs:element name="tpAmb" type="TAmb">
|
|
36
|
+
<xs:annotation>
|
|
37
|
+
<xs:documentation>Identificação do Ambiente:
|
|
38
|
+
1 - Produção
|
|
39
|
+
2 - Homologação</xs:documentation>
|
|
40
|
+
</xs:annotation>
|
|
41
|
+
</xs:element>
|
|
42
|
+
<xs:element name="verAplic">
|
|
43
|
+
<xs:annotation>
|
|
44
|
+
<xs:documentation>Versão do Aplicativo que processou a DCe</xs:documentation>
|
|
45
|
+
</xs:annotation>
|
|
46
|
+
<xs:simpleType>
|
|
47
|
+
<xs:restriction base="TVerAplic">
|
|
48
|
+
<xs:whiteSpace value="collapse"/>
|
|
49
|
+
</xs:restriction>
|
|
50
|
+
</xs:simpleType>
|
|
51
|
+
</xs:element>
|
|
52
|
+
<xs:element name="cStat" type="TStat">
|
|
53
|
+
<xs:annotation>
|
|
54
|
+
<xs:documentation>Código do status da mensagem enviada.</xs:documentation>
|
|
55
|
+
</xs:annotation>
|
|
56
|
+
</xs:element>
|
|
57
|
+
<xs:element name="xMotivo" type="TMotivo">
|
|
58
|
+
<xs:annotation>
|
|
59
|
+
<xs:documentation>Descrição literal do status do serviço solicitado.</xs:documentation>
|
|
60
|
+
</xs:annotation>
|
|
61
|
+
</xs:element>
|
|
62
|
+
<xs:element name="cUF" type="TCodUfIBGE">
|
|
63
|
+
<xs:annotation>
|
|
64
|
+
<xs:documentation>Código da UF responsável pelo serviço</xs:documentation>
|
|
65
|
+
</xs:annotation>
|
|
66
|
+
</xs:element>
|
|
67
|
+
<xs:element name="dhRecbto" type="TDateTimeUTC">
|
|
68
|
+
<xs:annotation>
|
|
69
|
+
<xs:documentation>AAAA-MM-DDTHH:MM:SS TZD</xs:documentation>
|
|
70
|
+
</xs:annotation>
|
|
71
|
+
</xs:element>
|
|
72
|
+
<xs:element name="tMed" minOccurs="0">
|
|
73
|
+
<xs:annotation>
|
|
74
|
+
<xs:documentation>Tempo médio de resposta do serviço (em segundos) dos últimos 5 minutos</xs:documentation>
|
|
75
|
+
</xs:annotation>
|
|
76
|
+
<xs:simpleType>
|
|
77
|
+
<xs:restriction base="xs:integer">
|
|
78
|
+
<xs:pattern value="[0-9]{1,4}"/>
|
|
79
|
+
</xs:restriction>
|
|
80
|
+
</xs:simpleType>
|
|
81
|
+
</xs:element>
|
|
82
|
+
<xs:element name="dhRetorno" type="TDateTimeUTC" minOccurs="0">
|
|
83
|
+
<xs:annotation>
|
|
84
|
+
<xs:documentation>AAAA-MM-DDTHH:MM:SS TZD. Deve ser preenchida com data e hora previstas para o retorno dos serviços prestados.</xs:documentation>
|
|
85
|
+
</xs:annotation>
|
|
86
|
+
</xs:element>
|
|
87
|
+
<xs:element name="xObs" minOccurs="0">
|
|
88
|
+
<xs:annotation>
|
|
89
|
+
<xs:documentation>Campo observação utilizado para incluir informações ao contribuinte</xs:documentation>
|
|
90
|
+
</xs:annotation>
|
|
91
|
+
<xs:simpleType>
|
|
92
|
+
<xs:restriction base="xs:string">
|
|
93
|
+
<xs:minLength value="1"/>
|
|
94
|
+
<xs:maxLength value="255"/>
|
|
95
|
+
<xs:whiteSpace value="collapse"/>
|
|
96
|
+
</xs:restriction>
|
|
97
|
+
</xs:simpleType>
|
|
98
|
+
</xs:element>
|
|
99
|
+
</xs:sequence>
|
|
100
|
+
<xs:attribute name="versao" type="TVerConsStat" use="required"/>
|
|
101
|
+
</xs:complexType>
|
|
102
|
+
<xs:simpleType name="TVerConsStat">
|
|
103
|
+
<xs:annotation>
|
|
104
|
+
<xs:documentation> Tipo Versão do Consulta do Status do Serviço DCe</xs:documentation>
|
|
105
|
+
</xs:annotation>
|
|
106
|
+
<xs:restriction base="xs:string">
|
|
107
|
+
<xs:pattern value="1\.00"/>
|
|
108
|
+
</xs:restriction>
|
|
109
|
+
</xs:simpleType>
|
|
110
|
+
</xs:schema>
|