diff --git a/pysped/nfe/danfe/__init__.py b/pysped/nfe/danfe/__init__.py index b75d8939..28bc62ea 100644 --- a/pysped/nfe/danfe/__init__.py +++ b/pysped/nfe/danfe/__init__.py @@ -39,7 +39,14 @@ # # -from pysped.nfe.danfe.danfe import DANFE -#from pysped.nfe.danfe.daede import DAEDE +import sys + + +if sys.version_info.major == 2: + from pysped.nfe.danfe.danfe_geraldo import DANFE +else: + from pysped.nfe.danfe.danfe import DANFE + +from pysped.nfe.danfe.daede import DAEDE from pysped.nfe.danfe.danfce import DANFCE from pysped.nfe.danfe.danfse import DANFSE diff --git a/pysped/nfe/leiaute/nfe_110.py b/pysped/nfe/leiaute/nfe_110.py index fb238975..814c28e8 100644 --- a/pysped/nfe/leiaute/nfe_110.py +++ b/pysped/nfe/leiaute/nfe_110.py @@ -4007,7 +4007,7 @@ def _calcula_dv(self, valor): def gera_nova_chave(self): chave = str(self.infNFe.ide.cUF.valor).zfill(2) - if str(self.infNFe.versao.valor) == '3.10': + if str(self.infNFe.versao.valor) in ('3.10', '4.00'): chave += str(self.infNFe.ide.dhEmi.valor.strftime('%y%m')).zfill(4) else: diff --git a/pysped/nfe/leiaute/nfe_310.py b/pysped/nfe/leiaute/nfe_310.py index 7b94aa6f..524babc8 100644 --- a/pysped/nfe/leiaute/nfe_310.py +++ b/pysped/nfe/leiaute/nfe_310.py @@ -586,8 +586,8 @@ def get_xml(self): xml += self.vICMSST.xml else: xml += self.modBC.xml - xml += self.vBC.xml xml += self.pRedBC.xml + xml += self.vBC.xml xml += self.pICMS.xml xml += self.vICMS.xml xml += self.modBCST.xml @@ -646,8 +646,8 @@ def get_xml(self): elif self.CST.valor == '70': xml += self.modBC.xml - xml += self.vBC.xml xml += self.pRedBC.xml + xml += self.vBC.xml xml += self.pICMS.xml xml += self.vICMS.xml xml += self.modBCST.xml @@ -665,8 +665,8 @@ def get_xml(self): elif self.CST.valor == '90': xml += self.modBC.xml - xml += self.vBC.xml xml += self.pRedBC.xml + xml += self.vBC.xml xml += self.pICMS.xml xml += self.vICMS.xml xml += self.modBCST.xml @@ -729,8 +729,8 @@ def get_xml(self): elif self.CSOSN.valor == '900': xml += self.modBC.xml - xml += self.vBC.xml xml += self.pRedBC.xml + xml += self.vBC.xml xml += self.pICMS.xml xml += self.vICMS.xml xml += self.modBCST.xml diff --git a/pysped/nfe/leiaute/nfe_400.py b/pysped/nfe/leiaute/nfe_400.py index c6d61ecf..58166cca 100644 --- a/pysped/nfe/leiaute/nfe_400.py +++ b/pysped/nfe/leiaute/nfe_400.py @@ -249,9 +249,10 @@ def get_xml(self): xml += self.pICMSST.xml xml += self.vICMSST.xml - xml += self.vBCFCPST.xml - xml += self.pFCPST.xml - xml += self.vFCPST.xml + if self.vFCP.valor: + xml += self.vBCFCPST.xml + xml += self.pFCPST.xml + xml += self.vFCPST.xml else: xml += self.modBC.xml @@ -337,8 +338,8 @@ def get_xml(self): elif self.CST.valor == '70': xml += self.modBC.xml - xml += self.vBC.xml xml += self.pRedBC.xml + xml += self.vBC.xml xml += self.pICMS.xml xml += self.vICMS.xml xml += self.modBCST.xml @@ -352,17 +353,18 @@ def get_xml(self): xml += self.pICMSST.xml xml += self.vICMSST.xml - xml += self.vBCFCPST.xml - xml += self.pFCPST.xml - xml += self.vFCPST.xml + if self.vFCP.valor: + xml += self.vBCFCPST.xml + xml += self.pFCPST.xml + xml += self.vFCPST.xml xml += self.vICMSDeson.xml xml += self.motDesICMS.xml elif self.CST.valor == '90': xml += self.modBC.xml - xml += self.vBC.xml xml += self.pRedBC.xml + xml += self.vBC.xml xml += self.pICMS.xml xml += self.vICMS.xml @@ -934,7 +936,7 @@ class Pag(XMLNFe): def __init__(self): super(Pag, self).__init__() self.detPag = [] - self.vTroco = TagDecimal(nome='vTroco' , codigo='', tamanho=[1, 13, 1], decimais=[0, 2, 2], raiz='//pag') + self.vTroco = TagDecimal(nome='vTroco' , codigo='YA09', tamanho=[1, 13, 1], decimais=[0, 2, 2], raiz='//pag') def get_xml(self): # @@ -946,7 +948,8 @@ def get_xml(self): for d in self.detPag: xml += d.xml - xml += self.vTroco.xml + if self.vTroco.valor: + xml += self.vTroco.xml xml += '' return xml @@ -1042,17 +1045,17 @@ def get_xml(self): xml += self.vBC.xml xml += self.vICMS.xml xml += self.vICMSDeson.xml + if self.vFCPUFDest.valor: + xml += self.vFCPUFDest.xml + if self.vICMSUFDest.valor: + xml += self.vICMSUFDest.xml + if self.vICMSUFRemet.valor: + xml += self.vICMSUFRemet.xml xml += self.vFCP.xml xml += self.vBCST.xml xml += self.vST.xml xml += self.vFCPST.xml xml += self.vFCPSTRet.xml - if self.vICMSUFDest.valor: - xml += self.vICMSUFDest.xml - if self.vICMSUFRemet.valor: - xml += self.vICMSUFRemet.xml - if self.vFCPUFDest.valor: - xml += self.vFCPUFDest.xml xml += self.vProd.xml xml += self.vFrete.xml xml += self.vSeg.xml @@ -1074,9 +1077,9 @@ def set_xml(self, arquivo): self.vICMS.xml = arquivo self.vICMSDeson.xml = arquivo self.vFCPUFDest.xml = arquivo + self.vFCP.xml = arquivo self.vICMSUFDest.xml = arquivo self.vICMSUFRemet.xml = arquivo - self.vFCP.xml = arquivo self.vBCST.xml = arquivo self.vST.xml = arquivo self.vFCPST.xml = arquivo @@ -1348,7 +1351,7 @@ def set_xml(self, arquivo): self.transp.xml = arquivo self.cobr.xml = arquivo - self.pag = self.le_grupo('//NFe/infNFe/pag', Pag) + self.pag.xml = arquivo self.infAdic.xml = arquivo self.exporta.xml = arquivo diff --git a/pysped/nfe/processador_nfe.py b/pysped/nfe/processador_nfe.py index d390d77e..fca555bb 100644 --- a/pysped/nfe/processador_nfe.py +++ b/pysped/nfe/processador_nfe.py @@ -497,7 +497,7 @@ def enviar_lote(self, numero_lote=None, lista_nfes=[]): arq.write(n.xml) arq.close - arq = open(self.caminho + str(envio.idLote.valor).strip().rjust(15, '0') + '-env-lot.xml', 'w') + arq = open(self.caminho + str(envio.idLote.valor).strip().rjust(15, '0') + '-env-lot.xml', 'w', encoding='utf-8') arq.write(envio.xml) arq.close() diff --git a/setup.py b/setup.py index 0e0a9e7c..e1085ad0 100644 --- a/setup.py +++ b/setup.py @@ -4,7 +4,7 @@ setup( name = "PySPED", - version = "1.1.0", + version = "1.2.0", author = "Aristides Caldeira", author_email = 'aristides.caldeira@tauga.com.br', test_suite='tests',