Skip to content

erpbrasil/erpbrasil.edoc.gen

Repository files navigation

Overview

tests
Travis-CI Build Status AppVeyor Build Status Requirements Status
Coverage Status
package

Overview

This is a helper script for generating Python and Odoo ERP libraries for the Brazilian electronic fiscal documents using http://www.davekuhlman.org/generateDS.html. It supports all fiscal documents that have XSD schemas, that is: NF-e, CC-e, NFS-e, MDF-e, CT-e, EFD-Reinf, e-Social, GNRE, BP-e...

But why a helper instead of launching generateDS manually?

  • For all these fiscal documents there is a common pattern: the schemas are inside a zip archive that can be downloaded from an official URL.
  • After normalizing the xsd file names, we launch the generateDS.py generator on them. But we also want to keep our libraries small, so edoc-gen enables to specify that only some xsd files should support both export and import.
  • Finally automating all the steps with the proper settings allowed Raphaël (AKRETION) to quickly re-generate the Python libraries for all the fiscal documents and run the pytests import/export tests on them to ensure any patch in generateDS would would retain real life compatibility (He got some 6 patches merged into generateDS). And mostly it allowed him to the do the same with the Odoo mixin generator plugin: quicky re-generate all Odoo modules and ensure they install and pass the tests. The libraries and Odoo modules are typically distributed as separated packages inside different repos that can get their own bug reports, forks and contributions but it also work to generate everything in the same directory for a quick extensive testing. Automating all these steps allowed Raphaël to prove to the other Odoo OCA Brazilian localization leaders that we could finally abandon hand written XML fiscal libs such as Pysped who were a hassle to maintain for every fiscal schema and its updates.

This tool was first implemented in Bash by Raphaël Valyi (AKRETION) in 2019 https://github.com/akretion/edoc-gen and then transcoded to Python by (KMEE) one year later for an easier portability. It was then cleaned up again by Raphaël to work with the standard generateDS package.

Usage

erpbrasil.edoc.gen.download_schema --help
Usage: download_schema.py [OPTIONS]

  Download a list of schemas of the same service, extract it in order and
  overwrite the files.

  NFE: Has one big file with all the xsd and some small files with     new
  fixes named "Pacote de Liberação"

Options:
  -n, --service_name TEXT  Service Name
  -v, --version TEXT       Version Name
  -u, --url TEXT           List of URLs
  -t DIRECTORY             Directory where the files will be extract
  --help                   Show this message and exit.


erpbrasil.edoc.gen.generate_python --help
Usage: generate_python.py [OPTIONS]

  Create a module in the path dest_dir and generates the python lib for each
  xsd found in the path schema_dir

  :param service_name: for example nfe :param version: v4.00 :param
  schema_dir: /tmp/schemas :param force: flag :param dest_dir:
  /tmp/generated_specs :return:

Options:
  -n, --service_name TEXT   Service Name
  -v, --version TEXT        Version Name
  -s, --schema_dir TEXT     Schema dir
  -f, --force               force
  -d, --dest_dir DIRECTORY  Directory where the files will be extract
  -i, --file_filter TEXT    File Filter
  -m, --main-package TEXT   Main package
  --help                    Show this message and exit.
  • Free software: MIT license

Example for the Brazilian NFe

https://github.com/erpbrasil/nfelib

Example for the NFS-e GINFES

https://github.com/erpbrasil/nfselib/blob/master/scripts/ginfes.sh

Installation

pip install erpbrasil.edoc.gen

You can also install the in-development version with:

pip install https://github.com/erpbrasil/erpbrasil.edoc.gen/archive/master.zip

Credits

Authors / Maintainers:

  • Raphaël Valyi (AKRETION)
  • Luis Felipe Miléo (KMEE)
  • Gabriel Cardoso de Faria (KMEE)

Development

To run the all tests run:

tox

Note, to combine the coverage data from all the tox environments run:

Windows
set PYTEST_ADDOPTS=--cov-append
tox
Other
PYTEST_ADDOPTS=--cov-append tox

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •