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

Forward changes from origin #1

Open
wants to merge 21 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
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
24 changes: 11 additions & 13 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,22 +1,20 @@
language: python
python:
- '3.4'
- '2.7'
- '3.5'
- '3.6'
install:
- pip install six
- pip install pytest
- pip install coveralls
- pip install six
- pip install pytest
- pip install coveralls
script:
- coverage run --source=sped setup.py test
- python test/fci_test.py
- coverage run --source=sped setup.py test
deploy:
provider: pypi
user: ginx
user: danimaribeiro
password:
secure: "TAjKq1M0eWjMq/ZJ2tuBOYbcLY1v0mwKqRUsrpBJUOgam+4YLQhblPcHLZ3yOV5FzqBxHU/WBByZMloW3Cx5+FYL0MRDmktJTqsM0OjdIqmS5m9+yWIQul8nc/54Aa5lMhXgmDHFrqVV+Noe7nYZ//EetN02DHwx7HN/3lva/Is="
distributions: "sdist bdist_wheel"
secure: PDqIGKOTaUWpM4R8HDqV9cumPUlbLBH/IpFpkGfy79E4UsR6cY4eb0WfoNwBXIlH0lBqVIJizgHcqD3yo0GeHFmOrnjOIZdSZyo3QG7W+nlzIohrwvgQ+pG//nBOgRJn/K5FVV9f2HM+QgKpNXgVU14ZIu+iR8mv/uanuMFoIZu9zmTUJk7mBYGRJteBsr7i+2AaTODQp4G1kXdnWQhj5R+cCVgd2uMFEtErXrqUs+KJ5hxT+OvDQQgEeZao7CVm8fS7Y+OJXBAciXnvtN/dmXlIWXJTtplnnzjGnuwj3c5hnpaX5N3PzJQwXy0ParrwyMoKRFr4ESgZWrlxHnxaPNe0TQjqQs2MFprFVoYgDKfaOzdcwI+bdKaiDztcvOmHPi17L8LdryTT97zSuTMFcKXkhxbr/W/kyL4VClIVrp3AVHyu4K9ih9rjgM+AZjIK28B2GKLCvaZpQy/lFmi21TyNZ92lodWKXJX76i7HhdkExasBiWk3CprC3cuL4wDPJnp9Rb9oO0R0qBV11UC4MsPvtR+6RSJZt/eus3iyNWcq4nbMlFe//yvk265n8nJlxP4qcCthi5+zthbGWoH7+TOMHVE0Svla7EKY0TpPtlixh9Jj0Reqk8sJqbo8RuvrI37nsJG1F5QAmme2TYtn4CryekbCpQLCvq8eZBGCk/4=
on:
tags: true
repo: sped-br/python-sped
branch: 11.0
distributions: bdist_wheel
after_success:
- coveralls
- coveralls
49 changes: 31 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,21 +1,33 @@
# SPED para python

[![Build Status](https://travis-ci.org/sped-br/python-sped.svg "Build Status")](https://travis-ci.org/sped-br/python-sped)
[![Coverage Status](https://coveralls.io/repos/sped-br/python-sped/badge.svg)](https://coveralls.io/r/sped-br/python-sped)
[![Code Health](https://landscape.io/github/sped-br/python-sped/master/landscape.svg?style=flat)](https://landscape.io/github/sped-br/python-sped/master)

Biblioteca para geração dos arquivos do Sistema Público de Escrituração Digital (SPED) para Python.

> This software is coded and documented in portuguese only as it is intended to be used to generate the necessary files for the brazilian government regarding to digital bookkeeping.

```
!!! Aviso importante !!!

O SPED necessita de atualizações constantes para continuar se adequando a legislação vigente e eu como desenvolvedor inicial desta biblioteca não consigo mais mante-la e portanto estou arquivando este repositório.

Nos anos que mantive este projeto público, o uso foi mínimo ou inexistente.

Comumente recebo emails, por ser o mantenedor dela, sempre de alguém procurando uma solução simples e barata para a geração dos arquivos do SPED, porém estes são muito mais complexos que os necessários a NF-e, a título de comparação.

Caso você possua recursos e disponibilidade para manter este projeto ou você faça uso dele e deseja assumir a administração da organização no GitHub e PyPI, você é bem vindo para tal desde que demostre real interesse nisso com contribuições (Pull Requests) a este repositório.

Ao termino de 1 ano deste comunicado, este repositório e os pacotes PyPI serão removidos de forma definitiva.

A licença de uso (MIT) permite que qualquer um use o código fonte aqui disponibilizado como bem queira, sem a necessidade de minha autorização para tal.
```

## Requisitos

* python
* six
- python
- six

## Como instalar

$ pip install sped
$ pip install python-sped

## Objetivos do Projeto

Expand All @@ -32,22 +44,23 @@ Outras linguagens de programação poderão ter versões especificas conforme mi
## Contribuições para o Projeto

Contribuições são bem vindas ao projeto, exemplos de como você pode contribuir:
* usando o projeto e [apontando bugs](https://github.com/sped-br/python-sped/issues)
* [sugestões de melhoria](https://github.com/sped-br/python-sped/issues)
* enviando [pull requests](https://github.com/sped-br/python-sped/pulls)
* auxiliando na [documentação](https://github.com/sped-br/python-sped/wiki)

- usando o projeto e [apontando bugs](https://github.com/sped-br/python-sped/issues)
- [sugestões de melhoria](https://github.com/sped-br/python-sped/issues)
- enviando [pull requests](https://github.com/sped-br/python-sped/pulls)
- auxiliando na [documentação](https://github.com/sped-br/python-sped/wiki)

## Status do Projeto

O projeto está em fase inicial de desenvolvimento e **não deve** ser usado em produção.

| Módulo | Status |
|----------------|:-------------:|
| ECD | Funcional |
| ECF | Funcional |
| EFD-PIS/COFINS | Funcional |
| EFD-ICMS/IPI | Funcional |
| FCI | Funcional |
| Módulo | Status |
| -------------- | :-------: |
| ECD | Funcional |
| ECF | Funcional |
| EFD-PIS/COFINS | Funcional |
| EFD-ICMS/IPI | Funcional |
| FCI | Funcional |

### ECD

Expand Down
6 changes: 3 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def run_tests(self):


setup(
name='sped',
name='python-sped',
packages=find_packages(exclude=['contrib', 'docs', 'test*']),
include_package_data=True,
package_data={
Expand All @@ -39,8 +39,8 @@ def run_tests(self):
'Python.',
author='Sergio Garcia',
author_email='[email protected]',
url='https://github.com/sped-br/python-sped',
download_url='https://github.com/sped-br/python-sped/releases',
url='https://github.com/Trust-Code/python-sped',
download_url='https://github.com/Trust-Code/python-sped/releases',
license='MIT',
classifiers=[
'Development Status :: 3 - Alpha',
Expand Down
2 changes: 1 addition & 1 deletion sped/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@
from .escrituracao import Escrituracao


__version__ = '1.0.0'
__version__ = '1.0.2'
14 changes: 3 additions & 11 deletions sped/blocos.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,30 +4,22 @@


class Bloco(object):
def __init__(self, nome):
def __init__(self, nome=''):
self._nome = nome
self._registros = []
self.registro_abertura = Registro()
self.registro_encerramento = Registro()

def __repr__(self):
return f'<{self.__class__.__module__}.{self.__class__.__name__}({self._nome})>'
return '<%s.%s(%s)>' % (self.__class__.__module__,
self.__class__.__name__, self._nome)

@property
def abertura(self):
# Define o indicador de movimento ou dados
self.registro_abertura[2] = '0' if self._registros else '1'
print(self.registro_abertura)
print(self.registro_abertura[2])
return self.registro_abertura

@property
def encerramento(self):
# Define a quantidade de registros
if self.registro_abertura.REG[0] == '0' or self.registro_abertura.REG[0] == '9':
self.registro_encerramento[2] = len(self._registros) + 3
else:
self.registro_encerramento[2] = len(self._registros) + 2
return self.registro_encerramento

@property
Expand Down
8 changes: 5 additions & 3 deletions sped/campos.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ def __init__(self, indice, nome, obrigatorio=False):
self._obrigatorio = obrigatorio

def __repr__(self):
return f'<{self.__class__.__module__}.{self.__class__.__name__}({self._indice}, {self._nome})>'
return '<%s.%s(%s, %s)>' % (self.__class__.__module__,
self.__class__.__name__,
self._indice, self._nome)

@property
def indice(self):
Expand Down Expand Up @@ -207,8 +209,8 @@ def set(self, registro, valor):
else:
raise FormatoInvalidoError(registro, str(self))

def __repr__(self):
return f'{self.__class__.__name__}({self.indice}, {self.nome}, {self._obrigatorio}, {self._regex})'
# def __repr__(self):
# return '' f'{self.__class__.__name__}({self.indice}, {self.nome}, {self._obrigatorio}, {self._regex})'


class CampoCNPJ(Campo):
Expand Down
35 changes: 29 additions & 6 deletions sped/ecd/arquivos.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
from .registros import Registro0000
from .registros import Registro9900
from .registros import Registro9999
from .registros import RegistroI030
from .registros import RegistroJ900


class ArquivoDigital(arquivos.ArquivoDigital):
Expand All @@ -20,13 +22,13 @@ class ArquivoDigital(arquivos.ArquivoDigital):

def __init__(self):
super(ArquivoDigital, self).__init__()
self._blocos['0'] = Bloco0()
self._blocos['I'] = BlocoI()
self._blocos['J'] = BlocoJ()
self._blocos['9'] = Bloco9()
self._blocos['0'] = Bloco0('0')
self._blocos['I'] = BlocoI('I')
self._blocos['J'] = BlocoJ('J')
self._blocos['9'] = Bloco9('9')

def prepare(self):
bloco_9 = self._blocos['9'] = Bloco9()
bloco_9 = self._blocos['9'] = Bloco9('9')

for bloco in self._blocos.values():
regs = {}
Expand All @@ -35,7 +37,15 @@ def prepare(self):
regs[reg.REG] = 0
regs[reg.REG] += 1
if bloco == self._blocos['0']:
bloco.registro_encerramento.QTD_LIN_0 = sum(
[x for x in regs.values()]) + 1
regs['0000'] = 1
if bloco == self._blocos['I']:
bloco.registro_encerramento.QTD_LIN_I = sum(
[x for x in regs.values()])
if bloco == self._blocos['J']:
bloco.registro_encerramento.QTD_LIN_J = sum(
[x for x in regs.values()])
if bloco == bloco_9:
regs['9999'] = 1
regs['9900'] += len(regs.keys())
Expand All @@ -45,8 +55,21 @@ def prepare(self):
registro.QTD_REG_BLC = regs[reg]
bloco_9.add(registro)

if bloco == self._blocos['9']:
bloco.registro_encerramento.QTD_LIN_9 = sum(
[x for x in regs.values()])

reg_count = 2
for bloco in self._blocos.values():
reg_count += len(bloco.registros)

self._registro_encerramento[2] = reg_count
encerramentoI = [x for x in self._blocos['I'].registros
if isinstance(x, RegistroI030)]
encerramentoI[0].QTD_LIN = reg_count

encerramentoJ = [x for x in self._blocos['J'].registros
if isinstance(x, RegistroJ900)]
encerramentoJ[0].QTD_LIN = reg_count

# self._blocos['J'].registros[1].QTD_LIN = reg_count
self._registro_encerramento.QTD_LIN = reg_count
16 changes: 8 additions & 8 deletions sped/ecd/blocos.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ class Bloco0(Bloco):
"""
Abertura, Identificação e Referências
"""
registro_abertura = Registro0001
registro_encerramento = Registro0990
registro_abertura = Registro0001()
registro_encerramento = Registro0990()

@property
def fechamento(self):
Expand All @@ -29,24 +29,24 @@ class BlocoI(Bloco):
"""
Lançamentos Contábeis
"""
registro_abertura = RegistroI001
registro_encerramento = RegistroI990
registro_abertura = RegistroI001()
registro_encerramento = RegistroI990()


class BlocoJ(Bloco):
"""
Demonstrações Contábeis
"""
registro_abertura = RegistroJ001
registro_encerramento = RegistroJ990
registro_abertura = RegistroJ001()
registro_encerramento = RegistroJ990()


class Bloco9(Bloco):
"""
Controle e Encerramento do Arquivo Digital
"""
registro_abertura = Registro9001
registro_encerramento = Registro9990
registro_abertura = Registro9001()
registro_encerramento = Registro9990()

@property
def fechamento(self):
Expand Down
17 changes: 10 additions & 7 deletions sped/ecd/registros.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ class Registro0000(Registro):
Campo(13, 'IND_NIRE'),
Campo(14, 'IND_FIN_ESC'),
Campo(15, 'COD_HASH_SUB'),
Campo(16, 'NIRE_SUBST'),
Campo(17, 'IND_GRANDE_PORTE'),
Campo(18, 'TIP_ECD'),
Campo(19, 'COD_SCP'),
Campo(20, 'IDENT_MF')
Campo(16, 'IND_GRANDE_PORTE'),
Campo(17, 'TIP_ECD'),
Campo(18, 'COD_SCP'),
Campo(19, 'IDENT_MF'),
Campo(20, 'IND_ESC_CONS')
]


Expand Down Expand Up @@ -456,6 +456,7 @@ class RegistroJ100(Registro):
Campo(7, 'IND_DC_BAL'),
CampoNumerico(8, 'VL_CTA_INI', precisao=2),
Campo(9, 'IND_DC_BAL_INI'),
Campo(10, 'NOTA_EXP_REF'),
]


Expand All @@ -472,6 +473,7 @@ class RegistroJ150(Registro):
Campo(6, 'IND_VL'),
CampoNumerico(7, 'VL_CTA_ULT_DRE', precisao=2),
Campo(8, 'IND_VL_ULT_DRE'),
Campo(9, 'NOTA_EXP_REF'),
]


Expand Down Expand Up @@ -509,15 +511,16 @@ class RegistroJ930(Registro):
campos = [
CampoFixo(1, 'REG', 'J930'),
CampoAlfanumerico(2, 'IDENT_NOM'),
CampoAlfanumerico(3, 'IDENT_CPF', tamanho=11),
CampoAlfanumerico(3, 'IDENT_CPF_CNPJ', tamanho=14),
CampoAlfanumerico(4, 'IDENT_QUALIF'),
CampoAlfanumerico(5, 'COD_ASSIN', tamanho=3),
CampoAlfanumerico(6, 'IND_CRC'),
CampoAlfanumerico(7, 'EMAIL'),
CampoAlfanumerico(8, 'FONE'),
CampoAlfanumerico(9, 'UF_CRC'),
CampoAlfanumerico(10, 'NUM_SEQ_CRC'),
CampoData(11, 'DT_CRC')
CampoData(11, 'DT_CRC'),
CampoAlfanumerico(12, 'IND_RESP_LEGAL')
]


Expand Down
Loading