Skip to content

Biblioteca Nfe para emissão de Nota Fiscal de Serviço para WebService da prefeitura de São Paulo, Nota do milhão.

Notifications You must be signed in to change notification settings

vsgobbi/nfe-library

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Description

Lib created in order to sign XML content for SOAP Envelops when a signature is required. This library is intended to be used within WebServices that require certificate signature values inside the XML body. Pure Python coded. Its features consist in extracting .CERT or .PEM files and PrivateKeys to add values on Signatures elements as SignatureValue and X509Certificate with rsa-sha1 encryption type, compliant with http://www.w3.org/2000/09/xmldsig. Sign a XML file or buffered string using A1 or A3 certificate, PKCS1_v1_5 supported by RFC3447. It serializes the data to request SOAP RPC services. Creates POST requests on WebServices as NFe and NFSe.

Table of Contents

GPL

License: GPL v3 Build Status Coverage Status


Installation

Clone

CLONE PROJECT

  • Firstly, clone this repo to your local machine
git clone https://github.com/vsgobbi/nfe-library.git

INSTALL PACKAGE

python setup.py install

INSTALL REQUIRED LIBS

  • Install main libs
pip install -r requirements.txt

Features

Using the following libs:

  • lxml, pyCrypto, requests, ssl, rsa

Setup

CREATE VENV

  • Create virtualenv using Python2.7
virtualenv -p python2.7 venv
  • Activate the virtualenv
source venv/bin/activate
  • Verify if version is correct
python --version #expected return: Python2.7
pip --version

Usage

Using this lib:

We can create a new RPS, Consult Nfes and Cancel Nfes
# coding: utf-8
from gateways.saopaulo import SaopauloGateway

certificateContent=open("../static/certificate.crt", "rb").read()
privateKeyContent = open("./static/rsaKey.pem").read()

###Create Nfe:

nota = {
    "senderTaxId": "01234567890123",
    "subscription": "01234567",
    "rpsSeries": "TESTE",
    "rpsNumber": "9117092019",
    "rpsType": "RPS",
    "issueDate": "2019-07-09",
    "statusRps": "N",
    "rpsTax": "T",
    "issRetain": "false",
    "serviceAmount": "1",
    "deductionAmount": "0",
    "pisAmount": "0",
    "irAmount": "0",
    "csllAmount": "0",
    "cofinsAmount": "0",
    "inssAmount": "0",
    "serviceCode": "05895",
    "aliquot": "2",
    "receiverTaxId": "32109876543210",
    "receiverName": "SOME COMPANY NAME",
    "receiverStreetLine1": "Null",
    "receiverStreetNumber": "123",
    "receiverStreetLine2": "Null",
    "receiverDistrict": "Null",
    "receiverCity": "3550308",
    "receiverState": "SP",
    "receiverZipCode": "00000000",
    "receiverEmail": "none@none",
    "description": "Teste de emissao de NFS-e de boletos prestados",
}

print(SaopauloGateway.sendRps(
    privateKeyContent=privateKeyContent,
    certificateContent=certificateContent,
    **nota
    ))

###How to delete a Nfe:

nota = {
    "senderTaxId": "01234567890123",
    "subscription": "01234567",
    "nfeNumber": "001"
}

print(SaopauloGateway.cancelRps(
    privateKeyContent=privateKeyContent,
    certificateContent=certificateContent,
    **nota
    ))

###Consult sent Nfes

parameters = {
    "senderTaxId": "01234567890123",
    "subscription": "01234567",
    "dtInicio": "2019-09-15",
    "dtFim": "2019-09-18",
}

print(SaopauloGateway.consultNfes(
    privateKeyContent=privateKeyContent,
    certificateContent=certificateContent,
    **parameters
))

Contributing

Get started

  • Step 1

    • 🍴 Fork this repo!
  • Step 2

    • 🔨🔨 Clone this repo to your local machine using
    git clone `https://github.com/vsgobbi/nfe-library`

Support

Reach out to me at one of the following places!


License

License: GPL v3

About

Biblioteca Nfe para emissão de Nota Fiscal de Serviço para WebService da prefeitura de São Paulo, Nota do milhão.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages