Skip to content
This repository has been archived by the owner on Apr 23, 2024. It is now read-only.

Features #60

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions autorizadores.json
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,10 @@
"inutilizacao": {
"url_producao": "https://nfe.sefa.pr.gov.br/nfe/NFeInutilizacao4",
"url_homologacao": "https://homologacao.nfce.sefa.pr.gov.br/nfce/Nfeinutilizacao4.asmx"
},
"recepcaoEvento": {
"url_producao": "https://nfce.sefa.pr.gov.br/nfce/NFeRecepcaoEvento4",
"url_homologacao": "https://homologacao.nfce.sefa.pr.gov.br/nfce/NFeRecepcaoEvento4"
}
}
},
Expand Down
4 changes: 4 additions & 0 deletions autorizadoresNFe.json
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,10 @@
"consultarStatusServico": {
"url_producao": "https://nfe.sefa.pr.gov.br/nfe/NFeStatusServico4?wsdl",
"url_homologacao": "https://homologacao.nfe.sefa.pr.gov.br/nfe/NFeStatusServico4?wsdl"
},
"recepcaoEvento": {
"url_producao": "https://nfe.sefa.pr.gov.br/nfe/NFeRecepcaoEvento4",
"url_homologacao": "https://homologacao.nfe.sefa.pr.gov.br/nfe/NFeRecepcaoEvento4"
}
}
},
Expand Down
11 changes: 10 additions & 1 deletion lib/factory/interface/nfe/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ export interface RetornoProcessamento {
xml_recebido: string;
status: number;
success: boolean;
data: Object;
data: {
retEnviNFe?: Object;
};
error: string;
}
export interface NFeBase {
Expand Down Expand Up @@ -66,12 +68,17 @@ export interface DocumentoFiscal {
justificativaContingencia: string;
isContingenciaOffline: boolean;
indIntermed?: string;
NFref?: {
refNFe?: string;
}[];
}
export interface Produto {
prod: DetalhesProduto;
imposto: Imposto;
infoAdicional: string;
numeroItem: string;
pis: Object | undefined;
cofins: Object | undefined;
}
export interface DetalhesProduto {
codigo: string;
Expand Down Expand Up @@ -293,6 +300,8 @@ export interface RetTrib {
}
export interface Transporte {
modalidateFrete: string;
transporta: Object;
vol: Object;
}
export interface Cobranca {
fatura: Fatura;
Expand Down
31 changes: 15 additions & 16 deletions lib/factory/processor/enviaProcessor.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,9 @@ class EnviaProcessor {
}
configuraUrlsSefaz() {
const { geral: { modelo, ambiente }, empresa } = this.configuracoes;
if (!soapAutorizacao || !soapRetAutorizacao) {
let Sefaz = modelo == '65' ? sefazNfce_1.SefazNFCe : sefazNfe_1.SefazNFe;
soapAutorizacao = Sefaz.getSoapInfo(empresa.endereco.uf, ambiente, nfe_1.ServicosSefaz.autorizacao);
soapRetAutorizacao = Sefaz.getSoapInfo(empresa.endereco.uf, ambiente, nfe_1.ServicosSefaz.retAutorizacao);
}
let Sefaz = modelo == '65' ? sefazNfce_1.SefazNFCe : sefazNfe_1.SefazNFe;
soapAutorizacao = Sefaz.getSoapInfo(empresa.endereco.uf, ambiente, nfe_1.ServicosSefaz.autorizacao);
soapRetAutorizacao = Sefaz.getSoapInfo(empresa.endereco.uf, ambiente, nfe_1.ServicosSefaz.retAutorizacao);
}
appendQRCodeXML(documento, xmlAssinado) {
let qrCode = null;
Expand Down Expand Up @@ -319,6 +317,7 @@ class EnviaProcessor {
dhSaiEnt: documento.dhSaiEnt,
dhCont: documento.dhContingencia,
xJust: documento.justificativaContingencia,
NFref: documento.NFref,
};
if (documento.indIntermed) {
ide.indIntermed = Utils.getEnumByValue(schema.TNFeInfNFeIdeIndIntermed, documento.indIntermed); // NT 2020.006
Expand Down Expand Up @@ -394,7 +393,7 @@ class EnviaProcessor {
prod: this.getDetProd(produtos[i].prod, ambiente, i == 0),
imposto: this.getDetImposto(produtos[i].imposto, modelo, produtos[i].prod.CFOP),
infAdProd: produtos[i].infoAdicional,
impostoDevol: (produtos[i].prod.percentualDevolucao && (produtos[i].prod.percentualDevolucao > 0)) ? this.getImpostoDevolucao({ pDevol: produtos[i].prod.percentualDevolucao, vIPIDevol: produtos[i].prod.valorIPIDevolucao }) : undefined
impostoDevol: (produtos[i].prod.percentualDevolucao && (produtos[i].prod.percentualDevolucao > 0)) ? this.getImpostoDevolucao({ pDevol: produtos[i].prod.percentualDevolucao, vIPIDevol: produtos[i].prod.valorIPIDevolucao }) : undefined,
});
}
return det_list;
Expand Down Expand Up @@ -1167,18 +1166,18 @@ class EnviaProcessor {
}
getTransp(transp) {
return {
modFrete: transp.modalidateFrete
modFrete: transp.modalidateFrete,
transporta: transp.transporta,
/**
* transporta: TNFeInfNFeTranspTransporta;
retTransp: TNFeInfNFeTranspRetTransp;
//balsa
//reboque
//vagao
//veicTransp
* retTransp: TNFeInfNFeTranspRetTransp;
balsa
reboque
vagao
veicTransp
items: object[];
itemsElementName: ItemsChoiceType5[];
vol: TNFeInfNFeTranspVol[];
*/
*/
vol: transp.vol,
};
}
getCobr(cobranca) {
Expand Down Expand Up @@ -1221,13 +1220,13 @@ class EnviaProcessor {
detPag = {};
detPag.indPag = Utils.getEnumByValue(schema.TNFeInfNFePagDetPagIndPag, pag.indicadorFormaPagamento);
detPag.tPag = Utils.getEnumByValue(schema.TNFeInfNFePagDetPagTPag, pag.formaPagamento);
detPag.vPag = pag.valor;
if (pag.descricaoFormaPagamento) {
detPag.xPag = pag.descricaoFormaPagamento; // YA02A NT 2020.006
}
if (pag.dadosCartao) {
detPag.card = this.getDetalhamentoCartao(pag.dadosCartao);
}
detPag.vPag = pag.valor;
listPagamentos.push(detPag);
}
return listPagamentos;
Expand Down
31 changes: 20 additions & 11 deletions lib/factory/processor/nfeProcessor2.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ class NFeProcessor {
return result;
}
async executar(documento) {
var _a, _b, _c, _d;
const { arquivos, geral } = this.configuracoes;
let result = {};
try {
Expand All @@ -58,11 +59,16 @@ class NFeProcessor {
let cStat = '';
if (result.envioNF && result.envioNF.data) {
const data = Object(result.envioNF.data);
if (data.retEnviNFe && geral.modelo == '55') {
retEnviNFe = data.retEnviNFe;
const recibo = retEnviNFe.infRec.nRec;
result.consultaProc = await this.retornoProcessor.executar(recibo);
retConsReciNFe = Object(result.consultaProc.data).retConsReciNFe;
retEnviNFe = data.retEnviNFe;
if (data.retEnviNFe) {
if (geral.modelo == '55' && retEnviNFe.infRec) {
const recibo = retEnviNFe.infRec.nRec;
result.consultaProc = await this.retornoProcessor.executar(recibo);
}
if ((_b = (_a = result.envioNF) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.retEnviNFe)
retConsReciNFe = Object(result.envioNF.data.retEnviNFe);
else
retConsReciNFe = Object(result.consultaProc.data).retConsReciNFe;
cStat = retConsReciNFe.cStat;
}
if (retEnviNFe && retConsReciNFe)
Expand Down Expand Up @@ -90,14 +96,17 @@ class NFeProcessor {
fs.writeFileSync(filename, xmlNfeProc);
}
else {
const filenameEnvio = `${arquivos.pastaEnvio}${retEnviNFe.infRec.nRec}-enviNFe.xml`;
const filenameRetorno = `${arquivos.pastaRetorno}${retEnviNFe.infRec.nRec}-retEnviNFe.xml`;
const date = new Date().toISOString().replace(/:/g, '-');
const filenameEnvio = `${arquivos.pastaEnvio}${date}${((_c = retEnviNFe.infRec) === null || _c === void 0 ? void 0 : _c.nRec) || ''}-enviNFe.xml`;
const filenameRetorno = `${arquivos.pastaRetorno}${date}${((_d = retEnviNFe.infRec) === null || _d === void 0 ? void 0 : _d.nRec) || ''}-retEnviNFe.xml`;
fs.writeFileSync(filenameEnvio, result.envioNF.xml_enviado);
fs.writeFileSync(filenameRetorno, result.envioNF.xml_recebido);
const filenameConsultaEnvio = `${arquivos.pastaEnvio}${retConsReciNFe.nRec}-consReciNFe.xml`;
const filenameConsultaRetorno = `${arquivos.pastaRetorno}${retConsReciNFe.nRec}-retConsReciNFe.xml`;
fs.writeFileSync(filenameConsultaEnvio, result.consultaProc.xml_enviado);
fs.writeFileSync(filenameConsultaRetorno, result.consultaProc.xml_recebido);
if (result.consultaProc) {
const filenameConsultaEnvio = `${arquivos.pastaEnvio}${retConsReciNFe.nRec}-consReciNFe.xml`;
const filenameConsultaRetorno = `${arquivos.pastaRetorno}${retConsReciNFe.nRec}-retConsReciNFe.xml`;
fs.writeFileSync(filenameConsultaEnvio, result.consultaProc.xml_enviado);
fs.writeFileSync(filenameConsultaRetorno, result.consultaProc.xml_recebido);
}
}
}
}
Expand Down
6 changes: 4 additions & 2 deletions lib/factory/schema/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ export interface TNFeInfNFeIde {
verProc: string;
dhCont: string;
xJust: string;
nFref: TNFeInfNFeIdeNFref[];
NFref?: TNFeInfNFeIdeNFref[];
indIntermed?: TNFeInfNFeIdeIndIntermed;
}
export declare enum TNFeInfNFeIdeIndIntermed {
Expand Down Expand Up @@ -203,7 +203,7 @@ export interface TNFeInfNFeIdeNFref {
refNF?: TNFeInfNFeIdeNFrefRefNF;
refNFP?: TNFeInfNFeIdeNFrefRefNFP;
refNFe?: string;
itemElementName: ItemChoiceType1;
itemElementName?: ItemChoiceType1;
}
export interface TNFeInfNFeIdeNFrefRefECF {
mod: TNFeInfNFeIdeNFrefRefECFMod;
Expand Down Expand Up @@ -440,6 +440,8 @@ export interface TNFeInfNFeDet {
imposto: TNFeInfNFeDetImposto;
impostoDevol: any;
infAdProd: string;
PIS: Object;
COFINS: Object;
}
export interface TNFeInfNFeDetProd {
cProd: string;
Expand Down
2 changes: 1 addition & 1 deletion lib/factory/webservices/webserviceHelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ class WebServiceHelper {
if (proxy) {
result.proxy = proxyToUrl(proxy);
}
console.log(result);
// console.log(result)
return result;
}
static buildCertAgentOpt(cert) {
Expand Down
7 changes: 6 additions & 1 deletion src/factory/interface/nfe/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export interface RetornoProcessamento {
xml_recebido: string,
status: number,
success: boolean,
data: Object,
data: {retEnviNFe?: Object},
error: string
}

Expand Down Expand Up @@ -74,13 +74,16 @@ export interface DocumentoFiscal {
justificativaContingencia: string;
isContingenciaOffline: boolean;
indIntermed?: string;
NFref?: {refNFe?: string}[];
}

export interface Produto {
prod: DetalhesProduto;
imposto: Imposto;
infoAdicional: string;
numeroItem: string;
pis: Object | undefined,
cofins: Object | undefined,
}

export interface DetalhesProduto {
Expand Down Expand Up @@ -329,6 +332,8 @@ export interface RetTrib {

export interface Transporte {
modalidateFrete: string;
transporta: Object,
vol: Object,
//..
}

Expand Down
36 changes: 17 additions & 19 deletions src/factory/processor/enviaProcessor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,12 +100,10 @@ export class EnviaProcessor {

private configuraUrlsSefaz() {
const { geral: { modelo, ambiente }, empresa } = this.configuracoes;
if (!soapAutorizacao || !soapRetAutorizacao) {
let Sefaz = modelo == '65' ? SefazNFCe : SefazNFe;
let Sefaz = modelo == '65' ? SefazNFCe : SefazNFe;

soapAutorizacao = Sefaz.getSoapInfo(empresa.endereco.uf, ambiente, ServicosSefaz.autorizacao);
soapRetAutorizacao = Sefaz.getSoapInfo(empresa.endereco.uf, ambiente, ServicosSefaz.retAutorizacao);
}
soapAutorizacao = Sefaz.getSoapInfo(empresa.endereco.uf, ambiente, ServicosSefaz.autorizacao);
soapRetAutorizacao = Sefaz.getSoapInfo(empresa.endereco.uf, ambiente, ServicosSefaz.retAutorizacao);
}

private appendQRCodeXML(documento: NFCeDocumento, xmlAssinado: string) {
Expand Down Expand Up @@ -387,7 +385,7 @@ export class EnviaProcessor {
dhSaiEnt: documento.dhSaiEnt,
dhCont: documento.dhContingencia,
xJust: documento.justificativaContingencia,
//nFref: schema.TNFeInfNFeIdeNFref[],
NFref: documento.NFref,
};

if (documento.indIntermed) {
Expand Down Expand Up @@ -476,7 +474,7 @@ export class EnviaProcessor {
prod: this.getDetProd(produtos[i].prod, ambiente, i == 0),
imposto: this.getDetImposto(produtos[i].imposto, modelo, produtos[i].prod.CFOP),
infAdProd: produtos[i].infoAdicional,
impostoDevol: (produtos[i].prod.percentualDevolucao && (produtos[i].prod.percentualDevolucao > 0)) ? this.getImpostoDevolucao({ pDevol: produtos[i].prod.percentualDevolucao, vIPIDevol: produtos[i].prod.valorIPIDevolucao }) : undefined
impostoDevol: (produtos[i].prod.percentualDevolucao && (produtos[i].prod.percentualDevolucao > 0)) ? this.getImpostoDevolucao({ pDevol: produtos[i].prod.percentualDevolucao, vIPIDevol: produtos[i].prod.valorIPIDevolucao }) : undefined,
});
}

Expand Down Expand Up @@ -1273,18 +1271,18 @@ export class EnviaProcessor {

private getTransp(transp: Transporte) {
return <schema.TNFeInfNFeTransp>{
modFrete: transp.modalidateFrete
modFrete: transp.modalidateFrete,
transporta: transp.transporta,
/**
* transporta: TNFeInfNFeTranspTransporta;
retTransp: TNFeInfNFeTranspRetTransp;
//balsa
//reboque
//vagao
//veicTransp
* retTransp: TNFeInfNFeTranspRetTransp;
balsa
reboque
vagao
veicTransp
items: object[];
itemsElementName: ItemsChoiceType5[];
vol: TNFeInfNFeTranspVol[];
*/
*/
vol: transp.vol,
}
}

Expand Down Expand Up @@ -1339,15 +1337,15 @@ export class EnviaProcessor {

detPag.indPag = Utils.getEnumByValue(schema.TNFeInfNFePagDetPagIndPag, pag.indicadorFormaPagamento);
detPag.tPag = Utils.getEnumByValue(schema.TNFeInfNFePagDetPagTPag, pag.formaPagamento);
detPag.vPag = pag.valor;


if (pag.descricaoFormaPagamento) {
detPag.xPag = pag.descricaoFormaPagamento; // YA02A NT 2020.006
}

if (pag.dadosCartao) {
detPag.card = this.getDetalhamentoCartao(pag.dadosCartao);
}
detPag.vPag = pag.valor;
listPagamentos.push(detPag);
}

Expand Down
31 changes: 19 additions & 12 deletions src/factory/processor/nfeProcessor2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,16 @@ export class NFeProcessor {

if (result.envioNF && result.envioNF.data) {
const data = Object(result.envioNF.data);
if (data.retEnviNFe && geral.modelo == '55') {
retEnviNFe = data.retEnviNFe;
const recibo = retEnviNFe.infRec.nRec;
result.consultaProc = <RetornoProcessamento>await this.retornoProcessor.executar(recibo);
retConsReciNFe = Object(result.consultaProc.data).retConsReciNFe;
retEnviNFe = data.retEnviNFe;
if (data.retEnviNFe) {
if (geral.modelo == '55' && retEnviNFe.infRec) {
const recibo = retEnviNFe.infRec.nRec;
result.consultaProc = <RetornoProcessamento>await this.retornoProcessor.executar(recibo);
}
if (result.envioNF?.data?.retEnviNFe)
retConsReciNFe = Object(result.envioNF.data.retEnviNFe);
else
retConsReciNFe = Object(result.consultaProc.data).retConsReciNFe;
cStat = retConsReciNFe.cStat;
}

Expand Down Expand Up @@ -103,15 +108,17 @@ export class NFeProcessor {

fs.writeFileSync(filename, xmlNfeProc);
} else {
const filenameEnvio = `${arquivos.pastaEnvio}${retEnviNFe.infRec.nRec}-enviNFe.xml`;
const filenameRetorno = `${arquivos.pastaRetorno}${retEnviNFe.infRec.nRec}-retEnviNFe.xml`;
const date = new Date().toISOString().replace(/:/g, '-');
const filenameEnvio = `${arquivos.pastaEnvio}${date}${retEnviNFe.infRec?.nRec || ''}-enviNFe.xml`;
const filenameRetorno = `${arquivos.pastaRetorno}${date}${retEnviNFe.infRec?.nRec || ''}-retEnviNFe.xml`;
fs.writeFileSync(filenameEnvio, result.envioNF.xml_enviado);
fs.writeFileSync(filenameRetorno, result.envioNF.xml_recebido);

const filenameConsultaEnvio = `${arquivos.pastaEnvio}${retConsReciNFe.nRec}-consReciNFe.xml`;
const filenameConsultaRetorno = `${arquivos.pastaRetorno}${retConsReciNFe.nRec}-retConsReciNFe.xml`;
fs.writeFileSync(filenameConsultaEnvio, result.consultaProc.xml_enviado);
fs.writeFileSync(filenameConsultaRetorno, result.consultaProc.xml_recebido);
if (result.consultaProc) {
const filenameConsultaEnvio = `${arquivos.pastaEnvio}${retConsReciNFe.nRec}-consReciNFe.xml`;
const filenameConsultaRetorno = `${arquivos.pastaRetorno}${retConsReciNFe.nRec}-retConsReciNFe.xml`;
fs.writeFileSync(filenameConsultaEnvio, result.consultaProc.xml_enviado);
fs.writeFileSync(filenameConsultaRetorno, result.consultaProc.xml_recebido);
}
}
}
} else if (result.retornoContingenciaOffline && result.success) {
Expand Down
Loading