Name: PyTrustNFe
Owner: Akretion
Description: Módulo NF-e Python
Forked from: danimaribeiro/PyTrustNFe
Created: 2017-11-16 21:35:12.0
Updated: 2018-04-27 16:47:44.0
Pushed: 2017-11-08 20:34:25.0
Homepage: null
Size: 418
Language: Python
GitHub Committers
User | Most Recent Commit | # Commits |
---|
Other Committers
User | Most Recent Commit | # Commits |
---|
Biblioteca Python que tem por objetivo enviar NFe, NFCe e NFSe no Brasil
Dependências:
Teste unitários
Emissão de NFCe
Compatibilidade python 2 e 3
Implementar novos provedores de NFSe
Consulta Cadastro por CNPJ:
pytrustnfe.nfe import consulta_cadastro
pytrustnfe.certificado import Certificado
ificado = open("/path/certificado.pfx", "r").read()
ificado = Certificado(certificado, 'senha_pfx')
= {'cnpj': '12345678901234', 'estado': '42'}
osta = consulta_cadastro(certificado, obj=obj, ambiente=1, estado='42')
Envio de RPS por lote
ificado = open('/path/certificado.pfx', 'r').read()
ificado = Certificado(certificado, '123456')
cessário criar um dicionário com os dados, validação dos dados deve
r feita pela aplicação que está utilizando a lib
= [
{
'assinatura': '123',
'serie': '1',
'numero': '1',
'data_emissao': '2016-08-29',
'codigo_atividade': '07498',
'valor_servico': '2.00',
'valor_deducao': '3.00',
'prestador': {
'inscricao_municipal': '123456'
},
'tomador': {
'tipo_cpfcnpj': '1',
'cpf_cnpj': '12345678923256',
'inscricao_municipal': '123456',
'razao_social': 'Trustcode',
'tipo_logradouro': '1',
'logradouro': 'Vinicius de Moraes, 42',
'numero': '42',
'bairro': 'Corrego',
'cidade': '4205407', # Código da cidade, de acordo com o IBGE
'uf': 'SC',
'cep': '88037240',
},
'codigo_atividade': '07498',
'aliquota_atividade': '5.00',
'descricao': 'Venda de servico'
}
= {
'cpf_cnpj': '12345678901234',
'data_inicio': '2016-08-29',
'data_fim': '2016-08-29',
'total_servicos': '2.00',
'total_deducoes': '3.00',
'lista_rps': rps
rno = envio_lote_rps(certificado, nfse=nfse)
torno é um dicionário { 'received_xml':'', 'sent_xml':'', 'object': object() }
t retorno['received_xml']
t retorno['sent_xml']
torno['object'] é um objeto python criado apartir do xml de resposta
t retorno['object'].Cabecalho.Sucesso
t retorno['object'].ChaveNFeRPS.ChaveNFe.NumeroNFe
t retorno['object'].ChaveNFeRPS.ChaveRPS.NumeroRPS
Cancelamento de NFSe:
pytrustnfe.certificado import Certificado
pytrustnfe.nfse.paulistana import cancelamento_nfe
ificado = open('/path/certificado.pfx', 'r').read()
ificado = Certificado(certificado, '123456')
elamento = {
'cnpj_remetente': '123',
'assinatura': 'assinatura',
'numero_nfse': '456',
'inscricao_municipal': '654',
'codigo_verificacao': '789',
rno = cancelamento_nfe(certificado, cancelamento=cancelamento)
torno é um dicionário { 'received_xml':'', 'sent_xml':'', 'object': object() }
t retorno['received_xml']
t retorno['sent_xml']
torno['object'] é um objeto python criado apartir do xml de resposta
t retorno['object'].Cabecalho.Sucesso
ot retorno['object'].Cabecalho.Sucesso: # Cancelamento com erro
print retorno['object'].Erro.Codigo
print retorno['object'].Erro.Descricao