forked from brasil-js/node-danfe-nfephp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathteste.js
48 lines (41 loc) · 1.19 KB
/
teste.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
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
// Utilização:
// node teste danfe /caminho/para/arquivo-nfe.xml
// node teste dacce /caminho/para/arquivo-cce.xml
var nfephp = require('./index'),
fs = require('fs'),
tipo = process.argv[2],
caminhoParaXml = process.argv[3],
xml = fs.readFileSync(caminhoParaXml).toString();
tipo === 'danfe' && nfephp.gerarDanfe(xml, {
creditos: 'Brasil.js e NFePHP'
}, function(err, danfe) {
if(err) {
throw err;
}
var caminhoParaPdf = caminhoParaXml.replace('.xml', '.pdf');
fs.writeFileSync(caminhoParaPdf, danfe, {
encoding: 'binary'
});
});
tipo === 'cce' && nfephp.gerarDacce(xml, {
creditos: 'Brasil.js e NFePHP',
razaoSocial: 'Gammasoft',
logradouro: 'Rua dos Testes',
numero: '333',
complemento: 'Torre B',
bairro: 'Bairro da Integração Contínua',
cep: '72000000',
municipio: 'Brasília',
uf: 'DF',
telefone: '6111223344',
email: '[email protected]',
registroNacional: '08942348821'
}, function(err, danfe) {
if(err) {
throw err;
}
var caminhoParaPdf = caminhoParaXml.replace('.xml', '.pdf');
fs.writeFileSync(caminhoParaPdf, danfe, {
encoding: 'binary'
});
});