Skip to content

Adiciona registros faltantes. #15

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

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
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
14 changes: 7 additions & 7 deletions sped/campos.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,9 @@ def set(self, registro, valor):
registro.valores[self._indice] = ''
return
if valor and not self.__class__.validar(valor):
raise FormatoInvalidoError(registro, self.nome)
raise FormatoInvalidoError(registro, self.nome, valor)
if not isinstance(valor, str):
raise FormatoInvalidoError(registro, self.nome)
raise FormatoInvalidoError(registro, self.nome, valor)
registro.valores[self._indice] = valor or ''

@staticmethod
Expand Down Expand Up @@ -97,7 +97,7 @@ def get(self, registro):

def set(self, registro, valor):
if valor != self._valor:
raise CampoFixoError(registro, self.nome)
raise CampoFixoError(registro, self.nome, valor)


class CampoAlfanumerico(Campo):
Expand Down Expand Up @@ -134,7 +134,7 @@ def set(self, registro, valor):
elif valor is None:
super().set(registro, None)
else:
raise FormatoInvalidoError(registro, self.nome)
raise FormatoInvalidoError(registro, self.nome, valor)


class CampoNumerico(Campo):
Expand Down Expand Up @@ -174,7 +174,7 @@ def set(self, registro, valor):
elif not valor:
super().set(registro, '0')
else:
raise FormatoInvalidoError(registro, self.nome)
raise FormatoInvalidoError(registro, self.nome, valor)


class CampoData(Campo):
Expand All @@ -193,7 +193,7 @@ def set(self, registro, valor):
elif not valor:
super().set(registro, None)
else:
raise FormatoInvalidoError(registro, self.nome)
raise FormatoInvalidoError(registro, self.nome, valor)


class CampoRegex(Campo):
Expand All @@ -207,7 +207,7 @@ def set(self, registro, valor):
if not valor or self._regex.match(valor):
super().set(registro, valor)
else:
raise FormatoInvalidoError(registro, str(self))
raise FormatoInvalidoError(registro, str(self), valor)

# def __repr__(self):
# return '' f'{self.__class__.__name__}({self.indice}, {self.nome}, {self._obrigatorio}, {self._regex})'
Expand Down
10 changes: 10 additions & 0 deletions sped/efd/icms_ipi/registros.py
Original file line number Diff line number Diff line change
Expand Up @@ -775,6 +775,16 @@ class RegistroC190(Registro):
Campo(11, 'VL_IPI'),
Campo(12, 'COD_OBS'),
]
class RegistroC191(Registro):
"""
INFORMAÇÕES DO FUNDO DE COMBATE À POBREZA – FCP – NA NFe (CÓDIGO 55) E NA NFC-E (CÓDIGO 65)
"""
campos = [
CampoFixo(1, 'REG', 'C191'),
CampoNumerico(2, 'VL_FCP_OP'),
CampoNumerico(3, 'VL_FCP_ST'),
CampoNumerico(4, 'VL_FCP_RET'),
]


class RegistroC195(Registro):
Expand Down
5 changes: 3 additions & 2 deletions sped/erros.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,13 @@ def __str__(self):


class CampoError(RegistroError):
def __init__(self, registro, campo):
def __init__(self, registro, campo, valor = None):
super(CampoError, self).__init__(registro)
self._campo = campo
self._valor = valor

def __str__(self):
return u'{0} -> {1}'.format(self._registro.__class__.__name__, self._campo)
return u'{0} -> {1}. Valor: {2}'.format(self._registro.__class__.__name__, self._campo, str(self._valor))


class CampoFixoError(CampoError):
Expand Down