Skip to content

Commit

Permalink
Merge pull request #31 from akretion/nfe_4.00
Browse files Browse the repository at this point in the history
Nfe 4.00 - Odoo 8.0 - OCA
  • Loading branch information
mileo authored Jul 26, 2018
2 parents 37d6462 + 0706ad9 commit 38c3982
Show file tree
Hide file tree
Showing 533 changed files with 36,165 additions and 20,643 deletions.
83 changes: 12 additions & 71 deletions pysped/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,16 @@
# <http://www.gnu.org/licenses/>
#

import sys
import locale

if sys.version_info.major == 2:
locale.setlocale(locale.LC_ALL, b'pt_BR.UTF-8')
locale.setlocale(locale.LC_COLLATE, b'pt_BR.UTF-8')
else:
locale.setlocale(locale.LC_ALL, 'pt_BR.UTF-8')
locale.setlocale(locale.LC_COLLATE, 'pt_BR.UTF-8')

from pysped.cte.leiaute.canccte_104 import CancCTe as CancCTe_104
from pysped.cte.leiaute.canccte_104 import ProcCancCTe as ProcCancCTe_104
from pysped.cte.leiaute.canccte_104 import RetCancCTe as RetCancCTe_104
Expand Down Expand Up @@ -101,74 +111,5 @@
from pysped.nfe.leiaute.nfe_110 import Vol as Vol_110
from pysped.nfe.leiaute.soap_100 import SOAPEnvio as SOAPEnvio_110
from pysped.nfe.leiaute.soap_100 import SOAPRetorno as SOAPRetorno_110
from pysped.nfe.processador_nfe import ProcessadorNFe, DANFE, Certificado


# Pyflakes

Adi_110
Arma_110
CTe_104
CancCTe_104
CancNFe_107
Certificado
ConsCad_101
ConsReciCTe_104
ConsReciNFe_110
ConsSitCTe_104
ConsSitNFe_107
ConsStatServCTe_104
ConsStatServ_107
DANFE
DI_110
Det_110
Dup_104
Dup_110
ESQUEMA_ATUAL
EnviCTe_104
EnviNFe_110
InfNF_104
InfNFe_104
InfOutros_104
InfQ_104
InutCTe_104
InutNFe_107
Lacres_110
Med_110
NFRef_110
NFe_110
ObsCont_104
ObsCont_110
ObsFisco_104
ObsFisco_110
Pass_104
ProcCTe_104
ProcCancCTe_104
ProcCancNFe_107
ProcInutCTe_104
ProcInutNFe_107
ProcNFe_110
ProcRef_110
ProcessadorNFe
ProtCTe_104
ProtNFe_110
Reboque_110
RetCancCTe_104
RetCancNFe_107
RetConsCad_101
RetConsReciCTe_104
RetConsReciNFe_110
RetConsSitCTe_104
RetConsSitNFe_107
RetConsStatServCTe_104
RetConsStatServ_107
RetEnviCTe_104
RetEnviNFe_110
RetInutCTe_104
RetInutNFe_107
SOAPEnvio_104
SOAPEnvio_110
SOAPRetorno_104
SOAPRetorno_110
Vol_110

#from pysped.nfe.processador_nfe import ProcessadorNFe, DANFE, Certificado
from pysped.nfe.processador_nfe import ProcessadorNFe, Certificado
130 changes: 99 additions & 31 deletions pysped/cte/leiaute/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,65 +47,133 @@
#
# Envelopes SOAP
#
from soap_104 import SOAPEnvio as SOAPEnvio_104
from soap_104 import SOAPRetorno as SOAPRetorno_104
from .soap_104 import SOAPEnvio as SOAPEnvio_104
from .soap_104 import SOAPRetorno as SOAPRetorno_104

#
# Emissão de CT-e
#
from cte_104 import CTe as CTe_104
from cte_104 import InfNF as InfNF_104
from cte_104 import InfNFe as InfNFe_104
from cte_104 import InfOutros as InfOutros_104
from cte_104 import Pass as Pass_104
from cte_104 import ObsCont as ObsCont_104
from cte_104 import ObsFisco as ObsFisco_104
from cte_104 import InfQ as InfQ_104
#from cte_104 import ContQt as ContQt_104
#from cte_104 import Seg as Seg_104
#from cte_104 import Peri as Peri_104
#from cte_104 import VeicNovos as VeicNovos_104
from cte_104 import Dup as Dup_104
from .cte_104 import CTe as CTe_104
from .cte_104 import InfNF as InfNF_104
from .cte_104 import InfNFe as InfNFe_104
from .cte_104 import InfOutros as InfOutros_104
from .cte_104 import Pass as Pass_104
from .cte_104 import ObsCont as ObsCont_104
from .cte_104 import ObsFisco as ObsFisco_104
from .cte_104 import InfQ as InfQ_104
#from .cte_104 import ContQt as ContQt_104
#from .cte_104 import Seg as Seg_104
#from .cte_104 import Peri as Peri_104
#from .cte_104 import VeicNovos as VeicNovos_104
from .cte_104 import Dup as Dup_104

#
# Envio de lote de CT-e
#
from envicte_104 import EnviCTe as EnviCTe_104
from envicte_104 import RetEnviCTe as RetEnviCTe_104
from .envicte_104 import EnviCTe as EnviCTe_104
from .envicte_104 import RetEnviCTe as RetEnviCTe_104

#
# Consulta do recibo do lote de CT-e
#
from consrecicte_104 import ConsReciCTe as ConsReciCTe_104
from consrecicte_104 import RetConsReciCTe as RetConsReciCTe_104
from consrecicte_104 import ProtCTe as ProtCTe_104
from consrecicte_104 import ProcCTe as ProcCTe_104
from .consrecicte_104 import ConsReciCTe as ConsReciCTe_104
from .consrecicte_104 import RetConsReciCTe as RetConsReciCTe_104
from .consrecicte_104 import ProtCTe as ProtCTe_104
from .consrecicte_104 import ProcCTe as ProcCTe_104

#
# Cancelamento de CT-e
#
from canccte_104 import CancCTe as CancCTe_104
from canccte_104 import RetCancCTe as RetCancCTe_104
from canccte_104 import ProcCancCTe as ProcCancCTe_104
from .canccte_104 import CancCTe as CancCTe_104
from .canccte_104 import RetCancCTe as RetCancCTe_104
from .canccte_104 import ProcCancCTe as ProcCancCTe_104

#
# Inutilização de CT-e
#
from inutcte_104 import InutCTe as InutCTe_104
from inutcte_104 import RetInutCTe as RetInutCTe_104
from inutcte_104 import ProcInutCTe as ProcInutCTe_104
from .inutcte_104 import InutCTe as InutCTe_104
from .inutcte_104 import RetInutCTe as RetInutCTe_104
from .inutcte_104 import ProcInutCTe as ProcInutCTe_104

#
# Consulta a situação de CT-e
#
from conssitcte_104 import ConsSitCTe as ConsSitCTe_104
from conssitcte_104 import RetConsSitCTe as RetConsSitCTe_104
from .conssitcte_104 import ConsSitCTe as ConsSitCTe_104
from .conssitcte_104 import RetConsSitCTe as RetConsSitCTe_104

#
# Consulta a situação do serviço
#
from consstatserv_104 import ConsStatServCTe as ConsStatServCTe_104
from consstatserv_104 import RetConsStatServCTe as RetConsStatServCTe_104
from .consstatserv_104 import ConsStatServCTe as ConsStatServCTe_104
from .consstatserv_104 import RetConsStatServCTe as RetConsStatServCTe_104


ESQUEMA_ATUAL_VERSAO_300 = u'PL_CTe_300'

#Envelopes SOAP
from .soap_300 import SOAPEnvio as SOAPEnvio_300
from .soap_300 import SOAPRetorno as SOAPRetorno_300

# Emissão de CT-e 3.00
from .cte_300 import CTe as CTe_300
from .cte_300 import InfQ as InfQ_300
from .cte_300 import InfNF as InfNF_300
from .cte_300 import InfNFe as InfNFe_300
from .cte_300 import InfOutros as InfOutros_300
from .cte_300 import VeicNovos as VeicNovos_300
from .cte_300 import Comp as Comp_300
from .cte_300 import Pass as Pass_300
from .cte_300 import ObsCont as ObsCont_300
from .cte_300 import ObsFisco as ObsFisco_300
from .cte_300 import AutXML as AutXML_300
from .cte_300 import InfCTeMultimodal as InfCTeMultimodal_300
from .cte_300 import Dup as Dup_300
from .cte_300 import IdDocAnt as IdDocAnt_300
from .cte_300 import IdDocAntPap as IdDocAntPap_300
from .cte_300 import IdDocAntEle as IdDocAntEle_300
from .cte_300 import EmitDocAnt as EmitDocAnt_300
from .cte_300 import InfUnidCarga as InfUnidCarga_300
from .cte_300 import InfUnidTransp as InfUnidTransp_300
from .cte_300 import LacUnidTransp as LacUnidTransp_300
from .cte_300 import LacUnidCarga as LacUnidCarga_300

# Envio e retorno eventos
from .proceventocte_300 import EventoCTe as EventoCTe_300
from .proceventocte_300 import RetEventoCTe as RetEventoCTe_300
from .proceventocte_300 import ProcEventoCTe as ProcEventoCTe_300

# Eventos
from .eventoscte_300 import EvCancCTe as EvCancCTe_300
from .eventoscte_300 import EvEPECCTe as EvEPECCTe_300
from .eventoscte_300 import EvRegMultimodal as EvRegMultimodal_300
from .eventoscte_300 import EvCCeCTe as EvCCeCTe_300
from .eventoscte_300 import InfCorrecao as InfCorrecao_300
from .eventoscte_300 import EvPrestDesacordo as EvPrestDesacordo_300
from .eventoscte_300 import EvGTV as EvGTV_300

# Consulta status servico
from .consstatserv_300 import ConsStatServCTe as ConsStatServCTe_300
from .consstatserv_300 import RetConsStatServCTe as RetConsStatServCTe_300

# Consulta a situação de CT-e
from .conssitcte_300 import ConsSitCTe as ConsSitCTe_300
from .conssitcte_300 import RetConsSitCTe as RetConsSitCTe_300


# Envio de lote de CT-e
from .envicte_300 import EnviCTe as EnviCTe_300
from .envicte_300 import RetEnviCTe as RetEnviCTe_300

# Consulta do recibo do lote de CT-e
from .consrecicte_300 import ConsReciCTe as ConsReciCTe_300
from .consrecicte_300 import RetConsReciCTe as RetConsReciCTe_300
from .consrecicte_300 import ProtCTe as ProtCTe_300
from .consrecicte_300 import ProcCTe as ProcCTe_300

# Inutilização de ct-e
from .inutcte_300 import InutCTe as InutCTe_300
from .inutcte_300 import RetInutCTe as RetInutCTe_300
from .inutcte_300 import ProcInutCTe as ProcInutCTe_300

# Pyflakes

Expand Down
92 changes: 92 additions & 0 deletions pysped/cte/leiaute/canccte_300.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
# -*- coding: utf-8 -*-

from pysped.xml_sped import *
from pysped.cte.leiaute import ESQUEMA_ATUAL_VERSAO_300 as ESQUEMA_ATUAL
import os

DIRNAME = os.path.dirname(__file__)


class InfCancRecebido(XMLNFe):
def __init__(self):
super(InfCancRecebido, self).__init__()
self.Id = TagCaracter(nome='infCanc' , codigo='CR03' , tamanho=[17, 17] , raiz='//retCancCTe', namespace=NAMESPACE_CTE, propriedade='Id', obrigatorio=False)
self.tpAmb = TagInteiro(nome='tpAmb' , codigo='CR05' , tamanho=[1, 1, 1] , raiz='//retCancCTe/infCanc', namespace=NAMESPACE_CTE, valor=2)
self.verAplic = TagCaracter(nome='verAplic', codigo='CR06' , tamanho=[1, 20] , raiz='//retCancCTe/infCanc', namespace=NAMESPACE_CTE)
self.cStat = TagCaracter(nome='cStat' , codigo='CR07' , tamanho=[3, 3, 3] , raiz='//retCancCTe/infCanc', namespace=NAMESPACE_CTE)
self.xMotivo = TagCaracter(nome='xMotivo' , codigo='CR08' , tamanho=[1, 255] , raiz='//retCancCTe/infCanc', namespace=NAMESPACE_CTE)
self.cUF = TagInteiro(nome='cUF' , codigo='CR08a', tamanho=[2, 2, 2] , raiz='//retCancCTe/infCanc', namespace=NAMESPACE_CTE)
self.chCTe = TagCaracter(nome='chCTe' , codigo='CR09' , tamanho=[44, 44, 44], raiz='//retcancCTe/infCanc', namespace=NAMESPACE_CTE, obrigatorio=False)
self.dhRecbto = TagDataHora(nome='dhRecbto', codigo='CR10' , raiz='//retCancCTe/infCanc', namespace=NAMESPACE_CTE, obrigatorio=False)
self.nProt = TagCaracter(nome='nProt' , codigo='CR11' , tamanho=[15, 15, 15], raiz='//retCancCTe/infCanc', namespace=NAMESPACE_CTE, obrigatorio=False)

def get_xml(self):
xml = XMLNFe.get_xml(self)

if self.Id.xml:
xml += self.Id.xml
else:
xml += '<infCanc>'

xml += self.tpAmb.xml
xml += self.verAplic.xml
xml += self.cStat.xml
xml += self.xMotivo.xml
xml += self.cUF.xml
xml += self.chCTe.xml
xml += self.dhRecbto.xml
xml += self.nProt.xml
xml += '</infCanc>'
return xml

def set_xml(self, arquivo):
if self._le_xml(arquivo):
self.Id.xml = arquivo
self.tpAmb.xml = arquivo
self.verAplic.xml = arquivo
self.cStat.xml = arquivo
self.xMotivo.xml = arquivo
self.cUF.xml = arquivo
self.chCTe.xml = arquivo
self.dhRecbto.xml = arquivo
self.nProt.xml = arquivo

xml = property(get_xml, set_xml)


class RetCancCTe(XMLNFe):
def __init__(self):
super(RetCancCTe, self).__init__()
self.versao = TagDecimal(nome='retCancCTe', codigo='CR01', propriedade='versao', namespace=NAMESPACE_CTE, valor='1.04', raiz='/')
self.infCanc = InfCancRecebido()
self.Signature = Signature()
self.caminho_esquema = os.path.join(DIRNAME, 'schema', 'PL_CTe_104c/')
self.arquivo_esquema = 'retCancCTe_v1.04.xsd'

def get_xml(self):
xml = XMLNFe.get_xml(self)
xml += ABERTURA
xml += self.versao.xml
xml += self.infCanc.xml

if len(self.Signature.URI) and (self.Signature.URI.strip() != '#'):
xml += self.Signature.xml

xml += '</retCancCTe>'
return xml

def set_xml(self, arquivo):
if self._le_xml(arquivo):
self.infCanc.xml = arquivo
self.Signature.xml = self._le_noh('//retCancCTe/sig:Signature')

xml = property(get_xml, set_xml)

def protocolo_formatado(self):
if not self.infCanc.nProt.valor:
return ''

formatado = self.infCanc.nProt.valor
formatado += ' - '
formatado += self.infCanc.dhRecbto.formato_danfe()
return formatado
3 changes: 1 addition & 2 deletions pysped/cte/leiaute/consrecicte_104.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
TagDataHora, TagDecimal, TagInteiro, XMLNFe)
from pysped.cte.leiaute import ESQUEMA_ATUAL_VERSAO_104 as ESQUEMA_ATUAL
import os
from cte_104 import CTe
from .cte_104 import CTe


DIRNAME = os.path.dirname(__file__)
Expand Down Expand Up @@ -153,7 +153,6 @@ def set_xml(self, arquivo):
# por isso, a raiz dele não pode ser assumida como sendo sempre o grupo
# protCTe
#
print('aqui:', self._le_noh('//protCTe/infProt', ns=NAMESPACE_CTE))
self.infProt.xml = self._le_noh('//protCTe/infProt', ns=NAMESPACE_CTE)
self.Signature.xml = self._le_noh('//protCTe/sig:Signature')

Expand Down
Loading

0 comments on commit 38c3982

Please sign in to comment.