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

[FIX] CSOSN and CST diplay #30

Merged
merged 2 commits into from
Jul 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 0 additions & 46 deletions .appveyor.yml

This file was deleted.

85 changes: 53 additions & 32 deletions .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
@@ -1,40 +1,61 @@
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python

name: Python package

on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]

name: build
on: [push, pull_request]
jobs:
build:

runs-on: ubuntu-latest
test:
name: ${{ matrix.name }}
runs-on: ${{ matrix.os }}
timeout-minutes: 30
strategy:
fail-fast: false
matrix:
python-version: ["3.5", "3.8", "3.10"]
include:
- name: 'check'
python: '3.9'
toxpython: 'python3.9'
tox_env: 'check'
os: 'ubuntu-latest'
- name: 'py37 (ubuntu)'
python: '3.7'
toxpython: 'python3.7'
python_arch: 'x64'
tox_env: 'py37'
os: 'ubuntu-latest'
- name: 'py38 (ubuntu)'
python: '3.8'
toxpython: 'python3.8'
python_arch: 'x64'
tox_env: 'py38'
os: 'ubuntu-latest'
- name: 'py39 (ubuntu)'
python: '3.9'
toxpython: 'python3.9'
python_arch: 'x64'
tox_env: 'py39'
os: 'ubuntu-latest'
- name: 'py310 (ubuntu)'
python: '3.10'
toxpython: 'python3.10'
python_arch: 'x64'
tox_env: 'py310'
os: 'ubuntu-latest'

steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v3
- uses: actions/checkout@v3
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install flake8 pytest
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
- name: Lint with flake8
run: |
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: Test with pytest
fetch-depth: 0
- uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python }}
architecture: ${{ matrix.python_arch }}
- name: install dependencies
run: |
pytest
python -mpip install --progress-bar=off -r ci/requirements.txt
virtualenv --version
pip --version
tox --version
pip list --format=freeze
- name: test
env:
TOXPYTHON: '${{ matrix.toxpython }}'
run: >
tox -e ${{ matrix.tox_env }} -v
52 changes: 0 additions & 52 deletions .travis.yml

This file was deleted.

1 change: 1 addition & 0 deletions ci/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
virtualenv>=16.6.0
pip>=19.1.1
setuptools>=18.0.1
tox
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ def read(*names, **kwargs):
'lxml',
'py3o.template',
'sh',
'pytz',
'python-dateutil',
# eg: 'aspectlib==1.1.1', 'six>=1.7',
],
Expand Down
Binary file modified src/erpbrasil/edoc/pdf/danfe.odt
Binary file not shown.
18 changes: 8 additions & 10 deletions src/erpbrasil/edoc/pdf/danfe_formata.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
# -*- coding: utf-8 -*-
import base64
import locale
import pytz

from datetime import datetime
from dateutil.parser import parse

from genshi import Markup
from reportlab.graphics.barcode import createBarcodeDrawing

import pytz
from dateutil.parser import parse
from erpbrasil.base.fiscal import cnpj_cpf
from erpbrasil.base.misc import format_zipcode
from genshi import Markup
from reportlab.graphics.barcode import createBarcodeDrawing


def formata_decimal(numero, digitos):
Expand Down Expand Up @@ -145,7 +143,7 @@ def formata_dhRecbto(dhRecbto):
# FIXME em algum ponto o valor do campo esta sendo formatado para string
# deveria ter um tratamento caso o valor seja None deveria retornar a string
# vazia '' ao invés de retornar 'None'
if dhRecbto is 'None':
if dhRecbto == 'None':
return ''
else:
dhRecbto = str(dhRecbto)
Expand Down Expand Up @@ -437,17 +435,17 @@ def regime_tributario(NFe):


def cst_formatado(det):
formatado = str(det.imposto.ICMS.tipoICMS.orig).zfill(1)
formatado = str(det.imposto.ICMS.tipoICMS.orig).zfill(1) + '/'

if hasattr(det.imposto, 'ISSQN'):
if str(det.imposto.ISSQN.regime_tributario.text) == 1:
formatado += '400'
else:
formatado += '41'

elif det.imposto.ICMS.regime_tributario == 1:
elif hasattr(det.imposto.ICMS.tipoICMS, 'CSOSN'):
formatado += str(det.imposto.ICMS.tipoICMS.CSOSN).zfill(3)
else:
elif hasattr(det.imposto.ICMS.tipoICMS, 'CST'):
formatado += str(det.imposto.ICMS.tipoICMS.CST).zfill(2)

return formatado
Expand Down
2 changes: 1 addition & 1 deletion src/erpbrasil/edoc/pdf/nfe.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ def __getattribute__(*args):
result = objectify.ObjectifiedElement.__getattribute__(*args)

# Caso existe um metodo de formatação para o atributo no danfe_formatado
if type(result) == NFeElement:
if type(result) is NFeElement:
search = re.search('{.*}(.*)', result.tag)
if not search:
return result
Expand Down
14 changes: 8 additions & 6 deletions tests/test_xml.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@
OUTPUT = 'output'
TIPO = 'danfe'

for (dirpath, dirnames, filenames) in walk(PATH):
for file in filenames:
arquivo = path.join(PATH, file)
output = path.join(OUTPUT, file)

print('XML: ' + file)
print(base.ImprimirXml.imprimir(caminho_xml=arquivo, output_dir=output))
def test_pdf_gen():
for (dirpath, dirnames, filenames) in walk(PATH):
for file in filenames:
arquivo = path.join(PATH, file)
output = path.join(OUTPUT, file)

print('XML: ' + file)
print(base.ImprimirXml.imprimir(caminho_xml=arquivo, output_dir=output))
38 changes: 16 additions & 22 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,32 +1,21 @@
[testenv:bootstrap]
deps =
jinja2
matrix
tox
skip_install = true
commands =
python ci/bootstrap.py
passenv =
*
; a generative tox configuration, see: https://tox.readthedocs.io/en/latest/config.html#generative-envlist

[tox]
envlist =
clean,
check,
docs,
{py36,py37,py38,pypy,pypy3},
{py37,py38,py39,py310},
report
ignore_basepython_conflict = true

[testenv]
basepython =
pypy: {env:TOXPYTHON:pypy}
pypy3: {env:TOXPYTHON:pypy3}
py36: {env:TOXPYTHON:python3.6}
{py38,docs,spell}: {env:TOXPYTHON:python3.8}
{py39,docs,spell}: {env:TOXPYTHON:python3.9}
py37: {env:TOXPYTHON:python3.7}
py38: {env:TOXPYTHON:python3.8}
py39: {env:TOXPYTHON:python3.9}
py310: {env:TOXPYTHON:python3.10}
{bootstrap,clean,check,report,codecov}: {env:TOXPYTHON:python3}
setenv =
PYTHONPATH={toxinidir}/tests
Expand All @@ -36,25 +25,29 @@ passenv =
usedevelop = false
deps =
pytest
pytest-travis-fold
pytest-cov

commands =
{posargs:pytest --cov --cov-report=term-missing -vv tests}

[testenv:bootstrap]
deps =
jinja2
matrix
tox
skip_install = true
commands =
python ci/bootstrap.py

[testenv:check]
deps =
docutils
check-manifest
flake8
readme-renderer
pygments
isort
skip_install = true
commands =
python setup.py check --strict --metadata --restructuredtext
python setup.py check --strict --metadata --restructuredtext -vv
check-manifest {toxinidir}
flake8 src tests setup.py
isort --verbose --check-only --diff --recursive src tests setup.py

[testenv:spell]
setenv =
Expand All @@ -80,6 +73,7 @@ deps =
codecov
skip_install = true
commands =
coverage xml --ignore-errors
codecov []

[testenv:report]
Expand Down
Loading