Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Falha na exportação de algumas tags #1

Open
mileo opened this issue Mar 21, 2018 · 3 comments
Open

Falha na exportação de algumas tags #1

mileo opened this issue Mar 21, 2018 · 3 comments

Comments

@mileo
Copy link

mileo commented Mar 21, 2018

Estou tentando gerar um XML e estou com problemas nas TAGs verProc e xMunCarrega.

Não sei dizer se é um problema nas lib ou eu que estou usando a lib de forma incorreta.

Agradeço qualquer ajuda.

https://github.com/akretion/mdfelib/blob/generated/mdfelib/v3_00/mdfeTiposBasico.py#L1555
https://github.com/akretion/mdfelib/blob/generated/mdfelib/v3_00/mdfeTiposBasico.py#L1703

fmdf

In [22]: import sys
    ...: from mdfelib.v3_00.mdfeTiposBasico import ide
    ...: from mdfelib.v3_00.mdfeTiposBasico import infMunCarrega
    ...: from mdfelib.v3_00.mdfeTiposBasico import tot
    ...: from mdfelib.v3_00.mdfeTiposBasico import verProc
    ...: 
    ...: carregamento = infMunCarrega(cMunCarrega=2305506,xMunCarrega='TESTE')
    ...: 
    ...: ver_proc = verProc()
    ...: # TODO: Corrigir o ver_proc pois eu não consegui, segui em frente.
    ...: # ver_proc
    ...: identificacao = ide()
    ...: identificacao.cUF = 23
    ...: identificacao.tpAmb = 2
    ...: identificacao.mod = '1'
    ...: identificacao.serie = '1'
    ...: identificacao.nMDF = '1'
    ...: identificacao.cMDF= '00004894'
    ...: identificacao.cDV = 4
    ...: identificacao.modal = 1
    ...: identificacao.dhEmi = '2017-10-02T18:05:55-03:00'
    ...: identificacao.tpEmis = 1
    ...: identificacao.procEmi = '0'
    ...: identificacao.verProc = ver_proc
    ...: identificacao.UFIni = 'CE'
    ...: identificacao.UFFim = 'CE'
    ...: identificacao.infMunCarrega.append(carregamento)
    ...: identificacao.export(sys.stdout, 0)
    ...: 
<ide>
    <cUF>23</cUF>
    <tpAmb>2</tpAmb>
    <mod>1</mod>
    <serie>1</serie>
    <nMDF>1</nMDF>
    <cMDF>00004894</cMDF>
    <cDV>4</cDV>
    <modal>1</modal>
    <dhEmi>2017-10-02T18:05:55-03:00</dhEmi>
    <tpEmis>1</tpEmis>
    <procEmi>0</procEmi>
    <verProc/>
    <UFIni>CE</UFIni>
    <UFFim>CE</UFFim>
    <infMunCarrega>
        <cMunCarrega>2305506</cMunCarrega>
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-22-c9f2f19bdffc> in <module>()
     26 identificacao.UFFim = 'CE'
     27 identificacao.infMunCarrega.append(carregamento)
---> 28 identificacao.export(sys.stdout, 0)

/home/mileo/Projects/test/src/mdfelib/mdfelib/v3_00/mdfeTiposBasico.py in export(self, outfile, level, namespace_, name_, namespacedef_, pretty_print)
   1131         if self.hasContent_():
   1132             outfile.write('>%s' % (eol_, ))
-> 1133             self.exportChildren(outfile, level + 1, namespace_='', name_='ide', pretty_print=pretty_print)
   1134             showIndent(outfile, level, pretty_print)
   1135             outfile.write('</%s%s>%s' % (namespace_, name_, eol_))

/home/mileo/Projects/test/src/mdfelib/mdfelib/v3_00/mdfeTiposBasico.py in exportChildren(self, outfile, level, namespace_, name_, fromsubclass_, pretty_print)
   1191             outfile.write('<%sUFFim>%s</%sUFFim>%s' % (namespace_, self.gds_encode(self.gds_format_string(quote_xml(self.UFFim), input_name='UFFim')), namespace_, eol_))
   1192         for infMunCarrega_ in self.infMunCarrega:
-> 1193             infMunCarrega_.export(outfile, level, namespace_, name_='infMunCarrega', pretty_print=pretty_print)
   1194         for infPercurso_ in self.infPercurso:
   1195             infPercurso_.export(outfile, level, namespace_, name_='infPercurso', pretty_print=pretty_print)

/home/mileo/Projects/test/src/mdfelib/mdfelib/v3_00/mdfeTiposBasico.py in export(self, outfile, level, namespace_, name_, namespacedef_, pretty_print)
   1661         if self.hasContent_():
   1662             outfile.write('>%s' % (eol_, ))
-> 1663             self.exportChildren(outfile, level + 1, namespace_='', name_='infMunCarrega', pretty_print=pretty_print)
   1664             showIndent(outfile, level, pretty_print)
   1665             outfile.write('</%s%s>%s' % (namespace_, name_, eol_))

/home/mileo/Projects/test/src/mdfelib/mdfelib/v3_00/mdfeTiposBasico.py in exportChildren(self, outfile, level, namespace_, name_, fromsubclass_, pretty_print)
   1677             outfile.write('<%scMunCarrega>%s</%scMunCarrega>%s' % (namespace_, self.gds_encode(self.gds_format_string(quote_xml(self.cMunCarrega), input_name='cMunCarrega')), namespace_, eol_))
   1678         if self.xMunCarrega is not None:
-> 1679             self.xMunCarrega.export(outfile, level, namespace_, name_='xMunCarrega', pretty_print=pretty_print)
   1680     def build(self, node):
   1681         already_processed = set()

AttributeError: 'str' object has no attribute 'export'

@mileo
Copy link
Author

mileo commented Mar 21, 2018

from mdfelib.v3_00.mdfeTiposBasico import emit
emit(CNPJ='5393935100129', IE=None, xNome='Luis', xFant=None, enderEmit=None)
emitente.export(sys.stdout, 0)
<emit>
    <CNPJ>5393935100129</CNPJ>
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-43-2dfd5a04f0fc> in <module>()
----> 1 emitente.export(sys.stdout, 0)

/home/mileo/Projects/zenir/src/mdfelib/mdfelib/v3_00/mdfeTiposBasico.py in export(self, outfile, level, namespace_, name_, namespacedef_, pretty_print)
   1957         if self.hasContent_():
   1958             outfile.write('>%s' % (eol_, ))
-> 1959             self.exportChildren(outfile, level + 1, namespace_='', name_='emit', pretty_print=pretty_print)
   1960             showIndent(outfile, level, pretty_print)
   1961             outfile.write('</%s%s>%s' % (namespace_, name_, eol_))

/home/mileo/Projects/zenir/src/mdfelib/mdfelib/v3_00/mdfeTiposBasico.py in exportChildren(self, outfile, level, namespace_, name_, fromsubclass_, pretty_print)
   1975             self.IE.export(outfile, level, namespace_, name_='IE', pretty_print=pretty_print)
   1976         if self.xNome is not None:
-> 1977             self.xNome.export(outfile, level, namespace_, name_='xNome', pretty_print=pretty_print)
   1978         if self.xFant is not None:
   1979             self.xFant.export(outfile, level, namespace_, name_='xFant', pretty_print=pretty_print)

AttributeError: 'str' object has no attribute 'export'

In [44]: emitente.export(sys.stdout, 0)               

Verifiquei que o padrão se repete para os tipos TString

@rvalyi
Copy link
Member

rvalyi commented Mar 21, 2018

vc pode baixar o generateDS na versao que eu usei para gerir o codigo aqui
https://drive.google.com/file/d/1-7tOtY4Uzt1fRERZ8_IkhEK3Iym3bh3O/view?usp=sharing

Depois preciso recortar aquele diff em uns 5 commits e fazer uns rebases daqueles commits para poder fazer commits organizados no repo e propor o merge no projeto original. Uma contrib que eu gostaria seria para ter uma opçao de ter as mensagens de erro em pt_BR. Idealmente seria localizavel, mas poderiamos usar apenas um patch no caso das libs do SPED.

@mileo
Copy link
Author

mileo commented Mar 21, 2018

Comparando com o XSD da NF-E

Esta faltando no fim do aquivo de tipos básicos a definição do tipo TString

<xs:simpleType name="TString">
		<xs:annotation>
			<xs:documentation> Tipo string genérico</xs:documentation>
		</xs:annotation>
		<xs:restriction base="xs:string">
			<xs:whiteSpace value="preserve"/>
			<xs:pattern value="[!-ÿ]{1}[ -ÿ]{0,}[!-ÿ]{1}|[!-ÿ]{1}"/>
		</xs:restriction>
	</xs:simpleType>

Copiei este trecho do arquivo da NF-e e vou tentar gerar novamente.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants