@@ -166,7 +166,7 @@ def preenche_manifesto(self):
166166 )
167167
168168 pedagio_1 = ManifestoPedagio (
169- cnpj_fornecedor = '04352277000134 ' ,
169+ cnpj_fornecedor = '17060943000102 ' ,
170170 cpfcnpj_pagador = '75961547191' ,
171171 numero_compra = '789' ,
172172 valor_pedagio = Decimal ('2.64' )
@@ -218,10 +218,10 @@ def preenche_manifesto(self):
218218 )
219219
220220 # Documentos vinculados
221- nfe_1 = ManifestoDocumentosNFe (chave_acesso_nfe = '51180904352277000215550010001445371002594517 ' )
222- nfe_2 = ManifestoDocumentosNFe (chave_acesso_nfe = '51191204352277000215550010001800551003198999 ' )
223- nfe_3 = ManifestoDocumentosNFe (chave_acesso_nfe = '51180904352277000215550010001445371002594517 ' )
224- nfe_4 = ManifestoDocumentosNFe (chave_acesso_nfe = '51191204352277000215550010001800551003198999 ' )
221+ nfe_1 = ManifestoDocumentosNFe (chave_acesso_nfe = '51180917060943000102550010001445371002594517 ' )
222+ nfe_2 = ManifestoDocumentosNFe (chave_acesso_nfe = '51191217060943000102550010001800551003198999 ' )
223+ nfe_3 = ManifestoDocumentosNFe (chave_acesso_nfe = '51180917060943000102550010001445371002594517 ' )
224+ nfe_4 = ManifestoDocumentosNFe (chave_acesso_nfe = '51191217060943000102550010001800551003198999 ' )
225225
226226 manifesto .adicionar_documentos (
227227 cMunDescarga = '3550308' ,
@@ -242,9 +242,9 @@ def preenche_manifesto(self):
242242
243243 manifesto .adicionar_seguradora (
244244 responsavel_seguro = '1' ,
245- cnpj_responsavel = '30221703000100 ' ,
245+ cnpj_responsavel = '75512177000176 ' ,
246246 nome_seguradora = 'TESTE SEGURADORA SA' ,
247- cnpj_seguradora = '30221703000100 ' ,
247+ cnpj_seguradora = '75512177000176 ' ,
248248 numero_apolice = '00000' ,
249249 averbacoes = [averbacao_1 , averbacao_2 ]
250250 )
@@ -270,6 +270,149 @@ def preenche_manifesto(self):
270270 fone = '11912341234'
271271 )
272272
273+ def preenche_manifesto_sem_rntrc (self ):
274+
275+ utc = datetime .timezone .utc
276+ data_emissao = datetime .datetime (2021 , 1 , 14 , 12 , 0 , 0 , tzinfo = utc )
277+ data_viagem = datetime .datetime (2021 , 1 , 14 , 13 , 10 , 20 , tzinfo = utc )
278+
279+ # Emitente
280+ emitente = ManifestoEmitente (
281+ cpfcnpj = '99999999000199' , # cnpj apenas números
282+ inscricao_estadual = '9999999999' , # numero de IE da empresa
283+ razao_social = 'NF-E EMITIDA EM AMBIENTE DE HOMOLOGACAO - SEM VALOR FISCAL' ,
284+ nome_fantasia = 'Nome Fantasia da Empresa' ,
285+ endereco_logradouro = 'RUA UM' ,
286+ endereco_numero = '111' ,
287+ endereco_complemento = None ,
288+ endereco_bairro = 'CENTRO' ,
289+ endereco_municipio = 'CUIABA' ,
290+ endereco_cep = '78118000' ,
291+ endereco_uf = 'MT' ,
292+ endereco_telefone = '65999662821' ,
293+ endereco_email = 'teste@gmail.com'
294+ )
295+
296+ # Totais
297+ totais = ManifestoTotais (
298+ qCTe = 0 ,
299+ qNFe = 2 ,
300+ vCarga = 1000 ,
301+ cUnid = 'KG' ,
302+ qCarga = 5000
303+ )
304+
305+ # Municípios de carregamento
306+ carregamento = ManifestoMunicipioCarrega (
307+ cMunCarrega = '5105101' ,
308+ xMunCarrega = 'JUARA'
309+ )
310+
311+ # modal Rodo
312+ condutor_1 = ManifestoCondutor (
313+ nome_motorista = 'JOAO DA SILVA' ,
314+ cpf_motorista = '12345678912'
315+ )
316+ condutor_2 = ManifestoCondutor (
317+ nome_motorista = 'JOSE DA SILVA' ,
318+ cpf_motorista = '12345678911'
319+ )
320+
321+ veiculo_tracao = []
322+ veiculo_tracao .append (
323+ ManifestoVeiculoTracao (
324+ cInt = '001' ,
325+ placa = 'ABC1234' ,
326+ RENAVAM = '123456789' ,
327+ tara = Decimal ('5000' ),
328+ capKG = Decimal ('4500' ),
329+ capM3 = Decimal ('400' ),
330+ proprietario = None ,
331+ condutor = [condutor_1 , condutor_2 ],
332+ tpRod = '01' ,
333+ tpCar = '02' ,
334+ UF = 'MT'
335+ )
336+ )
337+
338+ contratante = ManifestoContratante (
339+ nome = 'JOAO DA SILVA' ,
340+ cpfcnpj = '12345678912' ,
341+ NroContrato = 'q26393479sakjd231234' ,
342+ vContratoGlobal = Decimal ('2342.64' )
343+ )
344+
345+ modal_rodoviario = ManifestoRodoviario (
346+ rntrc = None ,
347+ ciot = [],
348+ pedagio = [],
349+ contratante = [contratante ],
350+ pagamento = None ,
351+ veiculo_tracao = veiculo_tracao ,
352+ veiculo_reboque = []
353+ )
354+
355+ # Manifesto
356+ manifesto = Manifesto (
357+ uf = 'MT' ,
358+ tipo_emitente = 2 , # 1=Transportadora; 2=Carga própria; 3=CTe Globalizado
359+ tipo_transportador = 0 , # 0=nenhum; 1=etc; 2=tac; 3=ctc
360+ modelo = 58 ,
361+ serie = '920' ,
362+ numero_mdfe = '1' ,
363+ modal = 1 ,
364+ data_emissao = data_emissao ,
365+ forma_emissao = '1' , # 1=Emissão normal (não em contingência);
366+ processo_emissao = '0' , # 0=Emissão de NF-e com aplicativo do contribuinte;
367+ UFIni = 'MT' ,
368+ UFFim = 'MT' ,
369+ infMunCarrega = [carregamento ],
370+ infPercurso = [],
371+ dhIniViagem = data_viagem ,
372+ emitente = emitente ,
373+ modal_rodoviario = modal_rodoviario ,
374+ totais = totais ,
375+ informacoes_complementares_interesse_contribuinte = 'Mensagem complementar'
376+ )
377+
378+ # Documentos vinculados
379+ nfe = ManifestoDocumentosNFe (chave_acesso_nfe = '51180917060943000102550010001445371002594517' )
380+
381+ manifesto .adicionar_documentos (
382+ cMunDescarga = '5102637' ,
383+ xMunDescarga = 'Campo Novo do Parecis' ,
384+ documentos_nfe = [nfe ],
385+ documentos_cte = []
386+ )
387+
388+ # Informações do Seguro
389+ averbacao = ManifestoAverbacao (numero = '00000000000000000000000' )
390+
391+ manifesto .adicionar_seguradora (
392+ responsavel_seguro = '1' ,
393+ cnpj_responsavel = '75512177000176' ,
394+ nome_seguradora = 'TESTE SEGURADORA SA' ,
395+ cnpj_seguradora = '75512177000176' ,
396+ numero_apolice = '00000' ,
397+ averbacoes = [averbacao ]
398+ )
399+
400+ # Produto Predominante
401+ manifesto .adicionar_produto (
402+ tipo_carga = '01' ,
403+ nome_produto = 'Descricao do Produto' ,
404+ cean = '78967142344650' ,
405+ ncm = '01012100'
406+ )
407+
408+ # Responsável técnico
409+ manifesto .adicionar_responsavel_tecnico (
410+ cnpj = '99999999000199' ,
411+ contato = 'Teste PyNFe' ,
412+ email = 'pynfe@pynfe.io' ,
413+ fone = '11912341234'
414+ )
415+
273416 def serializa_mdfe (self ):
274417 serializador = SerializacaoMDFe (_fonte_dados , homologacao = self .homologacao )
275418 return serializador .exportar ()
@@ -323,6 +466,37 @@ def grupo_ide_test(self):
323466 self .assertEqual (UFFim , 'SP' )
324467 self .assertEqual (dhIniViagem , '2021-01-14T13:10:20+00:00' )
325468
469+ def grupo_ide_sem_rntrc_test (self ):
470+ cUF = self .xml_assinado .xpath ('//ns:ide/ns:cUF' , namespaces = self .ns )[0 ].text
471+ tpAmb = self .xml_assinado .xpath ('//ns:ide/ns:tpAmb' , namespaces = self .ns )[0 ].text
472+ tpEmit = self .xml_assinado .xpath ('//ns:ide/ns:tpEmit' , namespaces = self .ns )[0 ].text
473+ mod = self .xml_assinado .xpath ('//ns:ide/ns:mod' , namespaces = self .ns )[0 ].text
474+ serie = self .xml_assinado .xpath ('//ns:ide/ns:serie' , namespaces = self .ns )[0 ].text
475+ nMDF = self .xml_assinado .xpath ('//ns:ide/ns:nMDF' , namespaces = self .ns )[0 ].text
476+ modal = self .xml_assinado .xpath ('//ns:ide/ns:modal' , namespaces = self .ns )[0 ].text
477+ dhEmi = self .xml_assinado .xpath ('//ns:ide/ns:dhEmi' , namespaces = self .ns )[0 ].text
478+ tpEmis = self .xml_assinado .xpath ('//ns:ide/ns:tpEmis' , namespaces = self .ns )[0 ].text
479+ procEmi = self .xml_assinado .xpath ('//ns:ide/ns:procEmi' , namespaces = self .ns )[0 ].text
480+ verProc = self .xml_assinado .xpath ('//ns:ide/ns:verProc' , namespaces = self .ns )[0 ].text
481+ UFIni = self .xml_assinado .xpath ('//ns:ide/ns:UFIni' , namespaces = self .ns )[0 ].text
482+ UFFim = self .xml_assinado .xpath ('//ns:ide/ns:UFFim' , namespaces = self .ns )[0 ].text
483+ dhIniViagem = self .xml_assinado .xpath ('//ns:ide/ns:dhIniViagem' , namespaces = self .ns )[0 ].text
484+
485+ self .assertEqual (cUF , '51' )
486+ self .assertEqual (tpAmb , '2' )
487+ self .assertEqual (tpEmit , '2' )
488+ self .assertEqual (mod , '58' )
489+ self .assertEqual (serie , '920' )
490+ self .assertEqual (nMDF , '1' )
491+ self .assertEqual (modal , '1' )
492+ self .assertEqual (dhEmi , '2021-01-14T12:00:00+00:00' )
493+ self .assertEqual (tpEmis , '1' )
494+ self .assertEqual (procEmi , '0' )
495+ self .assertEqual (verProc , 'PyNFe 0.4' )
496+ self .assertEqual (UFIni , 'MT' )
497+ self .assertEqual (UFFim , 'MT' )
498+ self .assertEqual (dhIniViagem , '2021-01-14T13:10:20+00:00' )
499+
326500 def grupo_municipio_carregamento (self ):
327501 cMunCarrega_1 = self .xml_assinado .xpath ('//ns:ide/ns:infMunCarrega/ns:cMunCarrega' , namespaces = self .ns )[0 ].text
328502 xMunCarrega_1 = self .xml_assinado .xpath ('//ns:ide/ns:infMunCarrega/ns:xMunCarrega' , namespaces = self .ns )[0 ].text
@@ -336,6 +510,13 @@ def grupo_municipio_carregamento(self):
336510 self .assertEqual (cMunCarrega_2 , '5107925' )
337511 self .assertEqual (xMunCarrega_2 , 'SORRISO' )
338512
513+ def grupo_municipio_carregamento_sem_rntrc (self ):
514+ cMunCarrega_1 = self .xml_assinado .xpath ('//ns:ide/ns:infMunCarrega/ns:cMunCarrega' , namespaces = self .ns )[0 ].text
515+ xMunCarrega_1 = self .xml_assinado .xpath ('//ns:ide/ns:infMunCarrega/ns:xMunCarrega' , namespaces = self .ns )[0 ].text
516+
517+ self .assertEqual (cMunCarrega_1 , '5105101' )
518+ self .assertEqual (xMunCarrega_1 , 'JUARA' )
519+
339520 def grupo_percurso (self ):
340521 UFPer_1 = self .xml_assinado .xpath ('//ns:ide/ns:infPercurso/ns:UFPer' , namespaces = self .ns )[0 ].text
341522 UFPer_2 = self .xml_assinado .xpath ('//ns:ide/ns:infPercurso/ns:UFPer' , namespaces = self .ns )[1 ].text
@@ -389,7 +570,7 @@ def grupo_pedagio(self):
389570 nCompra = self .xml_assinado .xpath ('//ns:infModal/ns:rodo/ns:infANTT/ns:valePed/ns:disp/ns:nCompra' , namespaces = self .ns )[0 ].text
390571 vValePed = self .xml_assinado .xpath ('//ns:infModal/ns:rodo/ns:infANTT/ns:valePed/ns:disp/ns:vValePed' , namespaces = self .ns )[0 ].text
391572
392- self .assertEqual (CNPJForn , '04352277000134 ' )
573+ self .assertEqual (CNPJForn , '17060943000102 ' )
393574 self .assertEqual (CPFPg , '75961547191' )
394575 self .assertEqual (nCompra , '789' )
395576 self .assertEqual (vValePed , '2.64' )
@@ -409,6 +590,16 @@ def grupo_contratante(self):
409590 self .assertEqual (xNome_2 , 'JOSE DA SILVA' )
410591 self .assertEqual (CPF_2 , '12345678911' )
411592
593+ def grupo_contratante_sem_rntrc (self ):
594+ xNome_1 = self .xml_assinado .xpath ('//ns:infModal/ns:rodo/ns:infANTT/ns:infContratante/ns:xNome' , namespaces = self .ns )[0 ].text
595+ CPF_1 = self .xml_assinado .xpath ('//ns:infModal/ns:rodo/ns:infANTT/ns:infContratante/ns:CPF' , namespaces = self .ns )[0 ].text
596+ NroContrato_1 = self .xml_assinado .xpath ('//ns:infModal/ns:rodo/ns:infANTT/ns:infContratante/ns:infContrato/ns:NroContrato' , namespaces = self .ns )[0 ].text
597+ vContratoGlobal_1 = self .xml_assinado .xpath ('//ns:infModal/ns:rodo/ns:infANTT/ns:infContratante/ns:infContrato/ns:vContratoGlobal' , namespaces = self .ns )[0 ].text
598+ self .assertEqual (xNome_1 , 'JOAO DA SILVA' )
599+ self .assertEqual (CPF_1 , '12345678912' )
600+ self .assertEqual (NroContrato_1 , 'q26393479sakjd231234' )
601+ self .assertEqual (vContratoGlobal_1 , '2342.64' )
602+
412603 def grupo_veiculos_reboque (self ):
413604 cInt = self .xml_assinado .xpath ('//ns:infModal/ns:rodo/ns:veicReboque/ns:cInt' , namespaces = self .ns )[1 ].text
414605 placa = self .xml_assinado .xpath ('//ns:infModal/ns:rodo/ns:veicReboque/ns:placa' , namespaces = self .ns )[1 ].text
@@ -466,20 +657,20 @@ def grupo_informacoes_documentos_nfe_vinculados(self):
466657 <cMunDescarga>3550308</cMunDescarga>
467658 <xMunDescarga>Sao Paulo</xMunDescarga>
468659 <infNFe>
469- <chNFe>51180904352277000215550010001445371002594517 </chNFe>
660+ <chNFe>51180917060943000102550010001445371002594517 </chNFe>
470661 </infNFe>
471662 <infNFe>
472- <chNFe>51191204352277000215550010001800551003198999 </chNFe>
663+ <chNFe>51191217060943000102550010001800551003198999 </chNFe>
473664 </infNFe>
474665 </infMunDescarga>
475666 <infMunDescarga>
476667 <cMunDescarga>3530607</cMunDescarga>
477668 <xMunDescarga>Mogi das Cruzes</xMunDescarga>
478669 <infNFe>
479- <chNFe>51180904352277000215550010001445371002594517 </chNFe>
670+ <chNFe>51180917060943000102550010001445371002594517 </chNFe>
480671 </infNFe>
481672 <infNFe>
482- <chNFe>51191204352277000215550010001800551003198999 </chNFe>
673+ <chNFe>51191217060943000102550010001800551003198999 </chNFe>
483674 </infNFe>
484675 </infMunDescarga>
485676 </infDoc>
@@ -496,13 +687,22 @@ def grupo_informacoes_documentos_nfe_vinculados(self):
496687
497688 self .assertEqual (cMunDescarga_0 , '3550308' )
498689 self .assertEqual (xMunDescarga_0 , 'Sao Paulo' )
499- self .assertEqual (chNFe_0_0 , '51180904352277000215550010001445371002594517 ' )
500- self .assertEqual (chNFe_0_1 , '51191204352277000215550010001800551003198999 ' )
690+ self .assertEqual (chNFe_0_0 , '51180917060943000102550010001445371002594517 ' )
691+ self .assertEqual (chNFe_0_1 , '51191217060943000102550010001800551003198999 ' )
501692
502693 self .assertEqual (cMunDescarga_1 , '3530607' )
503694 self .assertEqual (xMunDescarga_1 , 'Mogi das Cruzes' )
504- self .assertEqual (chNFe_1_0 , '51180904352277000215550010001445371002594517' )
505- self .assertEqual (chNFe_1_1 , '51191204352277000215550010001800551003198999' )
695+ self .assertEqual (chNFe_1_0 , '51180917060943000102550010001445371002594517' )
696+ self .assertEqual (chNFe_1_1 , '51191217060943000102550010001800551003198999' )
697+
698+ def grupo_informacoes_documentos_nfe_vinculados_sem_rntrc (self ):
699+ cMunDescarga = self .xml_assinado .xpath ('//ns:infMDFe/ns:infDoc/ns:infMunDescarga/ns:cMunDescarga' , namespaces = self .ns )[0 ].text
700+ xMunDescarga = self .xml_assinado .xpath ('//ns:infMDFe/ns:infDoc/ns:infMunDescarga/ns:xMunDescarga' , namespaces = self .ns )[0 ].text
701+ chNFe = self .xml_assinado .xpath ('//ns:infMDFe/ns:infDoc/ns:infMunDescarga/ns:infNFe/ns:chNFe' , namespaces = self .ns )[0 ].text
702+
703+ self .assertEqual (cMunDescarga , '5102637' )
704+ self .assertEqual (xMunDescarga , 'Campo Novo do Parecis' )
705+ self .assertEqual (chNFe , '51180917060943000102550010001445371002594517' )
506706
507707 def grupo_seguro_averbacao (self ):
508708 respSeg = self .xml_assinado .xpath ('//ns:infMDFe/ns:seg/ns:infResp/ns:respSeg' , namespaces = self .ns )[0 ].text
@@ -517,13 +717,30 @@ def grupo_seguro_averbacao(self):
517717 nAver_2 = self .xml_assinado .xpath ('//ns:infMDFe/ns:seg/ns:nAver' , namespaces = self .ns )[1 ].text
518718
519719 self .assertEqual (respSeg , '1' )
520- self .assertEqual (CNPJ_resp , '30221703000100 ' )
720+ self .assertEqual (CNPJ_resp , '75512177000176 ' )
521721 self .assertEqual (xSeg , 'TESTE SEGURADORA SA' )
522- self .assertEqual (CNPJ_seg , '30221703000100 ' )
722+ self .assertEqual (CNPJ_seg , '75512177000176 ' )
523723 self .assertEqual (nApol , '00000' )
524724 self .assertEqual (nAver_1 , '00000000000000000000000' )
525725 self .assertEqual (nAver_2 , '11111111111111111111111' )
526726
727+ def grupo_seguro_averbacao_sem_rntrc (self ):
728+ respSeg = self .xml_assinado .xpath ('//ns:infMDFe/ns:seg/ns:infResp/ns:respSeg' , namespaces = self .ns )[0 ].text
729+ CNPJ_resp = self .xml_assinado .xpath ('//ns:infMDFe/ns:seg/ns:infResp/ns:CNPJ' , namespaces = self .ns )[0 ].text
730+
731+ xSeg = self .xml_assinado .xpath ('//ns:infMDFe/ns:seg/ns:infSeg/ns:xSeg' , namespaces = self .ns )[0 ].text
732+ CNPJ_seg = self .xml_assinado .xpath ('//ns:infMDFe/ns:seg/ns:infSeg/ns:CNPJ' , namespaces = self .ns )[0 ].text
733+
734+ nApol = self .xml_assinado .xpath ('//ns:infMDFe/ns:seg/ns:nApol' , namespaces = self .ns )[0 ].text
735+ nAver_1 = self .xml_assinado .xpath ('//ns:infMDFe/ns:seg/ns:nAver' , namespaces = self .ns )[0 ].text
736+
737+ self .assertEqual (respSeg , '1' )
738+ self .assertEqual (CNPJ_resp , '75512177000176' )
739+ self .assertEqual (xSeg , 'TESTE SEGURADORA SA' )
740+ self .assertEqual (CNPJ_seg , '75512177000176' )
741+ self .assertEqual (nApol , '00000' )
742+ self .assertEqual (nAver_1 , '00000000000000000000000' )
743+
527744 def grupo_produto_predominante (self ):
528745 tpCarga = self .xml_assinado .xpath ('//ns:infMDFe/ns:prodPred/ns:tpCarga' , namespaces = self .ns )[0 ].text
529746 xProd = self .xml_assinado .xpath ('//ns:infMDFe/ns:prodPred/ns:xProd' , namespaces = self .ns )[0 ].text
@@ -610,5 +827,34 @@ def test_manifesto(self):
610827 self .validacao_com_xsd_do_xml_gerado_sem_processar ()
611828
612829
830+ def test_manifesto_sem_rntrc (self ):
831+ # Preenche as classes do pynfe
832+ self .manifesto = self .preenche_manifesto_sem_rntrc ()
833+
834+ # Serializa e assina o XML
835+ self .xml = self .serializa_mdfe ()
836+ self .xml_assinado = self .assina_xml ()
837+
838+ # Teste do conteúdo das tags do XML
839+ self .grupo_ide_sem_rntrc_test ()
840+ self .grupo_municipio_carregamento_sem_rntrc ()
841+ self .grupo_emitente ()
842+
843+ # self.grupo_inf_antt() # não tem o grupo infANTT
844+ self .grupo_contratante_sem_rntrc ()
845+ self .grupo_veiculo_tracao ()
846+
847+ self .grupo_informacoes_documentos_nfe_vinculados_sem_rntrc ()
848+ self .grupo_seguro_averbacao_sem_rntrc ()
849+ self .grupo_produto_predominante ()
850+ self .grupo_totais ()
851+
852+ self .grupo_responsavel_tecnico ()
853+ self .digestvalue_da_assinatura ()
854+
855+ # Testa a validação do XML com os schemas XSD
856+ self .validacao_com_xsd_do_xml_gerado_sem_processar ()
857+
858+
613859if __name__ == '__main__' :
614860 unittest .main ()
0 commit comments