Skip to content

Commit

Permalink
[IMP] l10n_br_account_payment_order: add short name for 'boleto espec…
Browse files Browse the repository at this point in the history
…ies'
  • Loading branch information
antoniospneto committed Mar 22, 2024
1 parent adf2758 commit d7ffa86
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@

from odoo import fields, models

from odoo.addons.l10n_br_account_payment_order.constants import (
get_boleto_especie_short_name,
)

from ..constants.br_cobranca import DICT_BRCOBRANCA_CURRENCY, get_brcobranca_bank

_logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -68,7 +72,10 @@ def send_payment(self):
"documento_numero": move_line.document_number,
"data_vencimento": move_line.date_maturity.strftime("%Y/%m/%d"),
"data_documento": move_line.move_id.invoice_date.strftime("%Y/%m/%d"),
"especie": move_line.payment_mode_id.boleto_species,
"especie": move_line.currency_id.symbol,
"especie_documento": get_boleto_especie_short_name(
move_line.payment_mode_id.boleto_species
),
"moeda": DICT_BRCOBRANCA_CURRENCY["R$"],
"aceite": move_line.payment_mode_id.boleto_accept,
"sacado_endereco": (move_line.partner_id.street_name or "")
Expand Down
43 changes: 29 additions & 14 deletions l10n_br_account_payment_order/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -480,22 +480,37 @@
]

BOLETO_ESPECIE = [
("01", "DUPLICATA MERCANTIL"),
("02", "NOTA PROMISSÓRIA"),
("03", "NOTA DE SEGURO"),
("04", "MENSALIDADE ESCOLAR"),
("05", "RECIBO"),
("06", "CONTRATO"),
("07", "COSSEGUROS"),
("08", "DUPLICATA DE SERVIÇO"),
("09", "LETRA DE CÂMBIO"),
("13", "NOTA DE DÉBITOS"),
("15", "DOCUMENTO DE DÍVIDA"),
("16", "ENCARGOS CONDOMINIAIS"),
("17", "CONTA DE PRESTAÇÃO DE SERVIÇOS"),
("99", "DIVERSOS"),
# CODE, DESCRIPTION, SHORT NAME
("01", "DUPLICATA MERCANTIL", "DM"),
("02", "NOTA PROMISSÓRIA", "NP"),
("03", "NOTA DE SEGURO", "NS"),
("04", "MENSALIDADE ESCOLAR", "ME"),
("05", "RECIBO", "REC"),
("06", "CONTRATO", "CONT"),
("07", "COSSEGUROS", "COSSEG"),
("08", "DUPLICATA DE SERVIÇO", "DS"),
("09", "LETRA DE CÂMBIO", "LC"),
("13", "NOTA DE DÉBITOS", "ND"),
("15", "DOCUMENTO DE DÍVIDA", "DD"),
("16", "ENCARGOS CONDOMINIAIS", "EC"),
("17", "CONTA DE PRESTAÇÃO DE SERVIÇOS", "CPS"),
("99", "DIVERSOS", "DIV"),
]


def get_boleto_especies():
# return the list of "boleto especie" only code and description
return [(code, desc) for code, desc, _ in BOLETO_ESPECIE]


def get_boleto_especie_short_name(selected_code):
# return the short name of "boleto especie"
for code, _, short_name in BOLETO_ESPECIE:
if code == selected_code:
return short_name
return None

Check warning on line 511 in l10n_br_account_payment_order/constants.py

View check run for this annotation

Codecov / codecov/patch

l10n_br_account_payment_order/constants.py#L511

Added line #L511 was not covered by tests


STATE_CNAB = [
("draft", "Novo"),
("done", "Processado"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

from odoo import fields, models

from ..constants import BOLETO_ESPECIE
from ..constants import get_boleto_especies


class L10nBrCNABBoletoFields(models.AbstractModel):
Expand Down Expand Up @@ -99,7 +99,7 @@ class L10nBrCNABBoletoFields(models.AbstractModel):
)

boleto_species = fields.Selection(
selection=BOLETO_ESPECIE,
selection=get_boleto_especies(),
string="Espécie do Título",
default="01",
tracking=True,
Expand Down

0 comments on commit d7ffa86

Please sign in to comment.