This repository has been archived by the owner on Jan 24, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refatora service de código de barras (#28)
* adiciona nix e poetry * termina configuração do nix e poetry * adiciona numeração do código de barras em baixo da imagem * corrige nix e poetry * adiciona documento cnab240 * altera testes * adiciona mais documentos * adiciona serviço de cobrança * documenta melhor * altera testes * cria teste * finaliza BarcodeCobrancaService * flake8 * implementa testes * refatora BarcodeService * cria models para os códigos de barra * fmt * ajusta alguns detalhes * Refatora para DACService * refatora DAC e MOD 10 e 11... * altera barcode_cobranca para utilizar DAC e MOD * cria barcode_tributo * altera testes * cria testes de tributo * corrige docstring e conversão de tributos * conversão utilizando slices * fmt * validação da linha digitável do tributo! * incremental model BarcodeTributo * adiciona identificação de tributo * altera docstring * Update bb_wrapper/services/barcode_tributo.py Co-authored-by: PedroRegisPOAR <pedroalencarregis@hotmail.com> * Update flake.nix Co-authored-by: PedroRegisPOAR <pedroalencarregis@hotmail.com> * remove arquivos obsoletos Co-authored-by: PedroRegisPOAR <pedroalencarregis@hotmail.com>
- Loading branch information
1 parent
a78b8d0
commit 1839169
Showing
35 changed files
with
1,978 additions
and
619 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
from typing import Optional | ||
|
||
from pydantic import BaseModel, constr, validator, root_validator | ||
|
||
from ..services.barcode_cobranca import BarcodeCobrancaService | ||
from ..services.barcode_tributo import BarcodeTributoService | ||
|
||
|
||
class BarcodeCobranca(BaseModel): | ||
code_line: Optional[constr(min_length=47, max_length=47, regex=r"^\d+$")] | ||
barcode: Optional[constr(min_length=44, max_length=44, regex=r"^\d+$")] | ||
barcode_image: Optional[str] | ||
|
||
# noinspection PyMethodParameters | ||
@validator("code_line") | ||
def _code_line_must_be_valid(cls, code_line): | ||
BarcodeCobrancaService().validate_code_line(code_line) | ||
return code_line | ||
|
||
# noinspection PyMethodParameters | ||
@validator("barcode") | ||
def _barcode_must_be_valid(cls, barcode): | ||
BarcodeCobrancaService().validate_barcode(barcode) | ||
return barcode | ||
|
||
# noinspection PyMethodParameters | ||
@root_validator | ||
def _set_data(cls, values): | ||
from ..services.barcode import BarcodeService | ||
|
||
code_line, barcode = values.get("code_line"), values.get("barcode") | ||
|
||
if code_line: | ||
values["barcode"] = BarcodeCobrancaService().code_line_to_barcode(code_line) | ||
elif barcode: | ||
values["code_line"] = BarcodeCobrancaService().barcode_to_code_line(barcode) | ||
else: | ||
raise ValueError("Informe a linha digitável ou código de barras!") | ||
|
||
values["barcode_image"] = BarcodeService().generate_barcode_b64image( | ||
values["barcode"] | ||
) | ||
return values | ||
|
||
|
||
class BarcodeTributo(BaseModel): | ||
code_line: Optional[constr(min_length=48, max_length=48, regex=r"^\d+$")] | ||
barcode: Optional[constr(min_length=44, max_length=44, regex=r"^\d+$")] | ||
barcode_image: Optional[str] | ||
|
||
# noinspection PyMethodParameters | ||
@validator("code_line") | ||
def _code_line_must_be_valid(cls, code_line): | ||
BarcodeTributoService().validate_code_line(code_line) | ||
return code_line | ||
|
||
# noinspection PyMethodParameters | ||
@validator("barcode") | ||
def _barcode_must_be_valid(cls, barcode): | ||
BarcodeTributoService().validate_barcode(barcode) | ||
return barcode | ||
|
||
# noinspection PyMethodParameters | ||
@root_validator | ||
def _set_data(cls, values): | ||
from ..services.barcode import BarcodeService | ||
|
||
code_line, barcode = values.get("code_line"), values.get("barcode") | ||
|
||
if code_line: | ||
values["barcode"] = BarcodeTributoService().code_line_to_barcode(code_line) | ||
elif barcode: | ||
values["code_line"] = BarcodeTributoService().barcode_to_code_line(barcode) | ||
else: | ||
raise ValueError("Informe a linha digitável ou código de barras!") | ||
|
||
values["barcode_image"] = BarcodeService().generate_barcode_b64image( | ||
values["barcode"] | ||
) | ||
return values |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,11 @@ | ||
from .b64 import Base64Service # noqa: F401 | ||
from .unicode import UnicodeService | ||
from .qrcode import QRCodeService | ||
from .barcode import BarCodeService | ||
from .barcode import BarcodeService | ||
from .mod import ModService # noqa: F401 | ||
from .febrabran import FebrabranService # noqa: F401 | ||
from .pixcode import PixCodeService # noqa: F401 | ||
|
||
|
||
parse_unicode_to_alphanumeric = UnicodeService().parse_unicode_to_alphanumeric | ||
generate_qrcode_b64image = QRCodeService().generate_qrcode_b64image | ||
generate_barcode_b64image = BarCodeService().generate_barcode_b64image | ||
generate_barcode_b64image = BarcodeService().generate_barcode_b64image |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.