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

[16.0][l10n_br_account_payment_order][l10n_br_account_payment_brcobranca] Oca port 14.0 to 16.0 2e18e4 #3537

Open
wants to merge 23 commits into
base: 16.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
47357e5
[FIX] l10n_br_account_payment_order _post
mileo Jul 4, 2024
85e318b
[REF] l10n_br_account_payment_order: New CNAB Conf
mbcosta Sep 10, 2024
f407ae9
[REF] l10n_br_account_payment_order: View CNABConf
mbcosta Sep 10, 2024
cfb96ea
[REF] l10n_br_account_payment_order: Demo CNABConf
mbcosta Sep 10, 2024
80f7da3
[REF] l10n_br_account_payment_brcobranca:CNAB Conf
mbcosta Sep 10, 2024
6e352a3
[FIX+IMP] l10n_br_account_payment_order: Discount
mbcosta Sep 12, 2024
21653aa
[FIX+IMP] l10n_br_account_payment_brcobranca:Disc
mbcosta Sep 12, 2024
ad63885
[REM] l10n_br_account_payment_order: Obsolete Obj
mbcosta Sep 13, 2024
e82db37
[REM] l10n_br_account_payment_brcobranca: Obsolet
mbcosta Sep 13, 2024
11a1611
[CI] l10n_br_account_payment_brcobranca: live API
rvalyi Sep 12, 2024
bfe28fb
[REF] l10n_br_account_payment_brcobranca pre-commit changes
antoniospneto Dec 9, 2024
2984105
[FIX] l10n_br_account_payment_brcobranca: discount value
DiegoParadeda Sep 26, 2024
3a0ec98
[FIX] l10n_br_account_payment_order: cnab config copy
DiegoParadeda Nov 4, 2024
92c30e4
[MIG] l10n_br_account_payment_order: Adapt Scripts
mbcosta Dec 16, 2024
3188d54
[MIG] l10n_br_account_payment_brcobranca: Scripts
mbcosta Dec 16, 2024
1542e8a
[MIG] l10n_br_account_payment_order: Adapt View
mbcosta Dec 16, 2024
aa08065
[FIX] l10n_br_account_payment_order: Name Field
mbcosta Dec 16, 2024
0d5c5fa
[REF] l10n_br_account_payment_order:Check Sequence
mbcosta Dec 16, 2024
e8e51f8
[REF] l10n_br_account_payment_order: Tests
mbcosta Dec 16, 2024
799f58a
[REF] l10n_br_account_payment_brcobranca: Tests
mbcosta Dec 16, 2024
654d98a
[UPD] l10n_br_account_payment_order: README
mbcosta Oct 8, 2024
ca0f72f
[UPD] l10n_br_account_payment_brcobranca: README
mbcosta Oct 8, 2024
589accb
[FIX] l10n_br_account_payment_order: Discount Code
mbcosta Dec 18, 2024
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
6 changes: 6 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,12 @@ jobs:
POSTGRES_DB: odoo
ports:
- 5432:5432
boleto_cnab_api:
image: ghcr.io/akretion/boleto_cnab_api:latest
ports:
- 9292:9292
env:
BRCOBRANCA_API_URL: http://boleto_cnab_api:9292
steps:
- uses: actions/checkout@v3
with:
Expand Down
347 changes: 183 additions & 164 deletions l10n_br_account_payment_brcobranca/README.rst

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions l10n_br_account_payment_brcobranca/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

{
"name": "Boletos e CNAB de cobrança",
"summary": "receivable Boletos and CNAB using the brcobranca lib",
"version": "16.0.2.0.0",
"summary": "receivable Boletos and CNAB using the BRCobranca lib",
"version": "16.0.3.0.0",
"license": "AGPL-3",
"author": "Akretion, Odoo Community Association (OCA)",
"maintainers": ["rvalyi", "mbcosta"],
Expand Down
56 changes: 28 additions & 28 deletions l10n_br_account_payment_brcobranca/demo/account_payment_mode.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,112 +3,112 @@

<!-- Bradesco CNAB 400 -->
<record
id="l10n_br_account_payment_order.payment_mode_cobranca_bradesco400"
model="account.payment.mode"
id="l10n_br_account_payment_order.cnab_config_bradesco_400"
model="l10n_br_cnab.config"
>
<field name="cnab_processor">brcobranca</field>
</record>

<!-- Modo de Pagamento cobrança Bradesco 240 -->
<record
id="l10n_br_account_payment_order.payment_mode_cobranca_bradesco240"
model="account.payment.mode"
id="l10n_br_account_payment_order.cnab_config_bradesco_240"
model="l10n_br_cnab.config"
>
<field name="cnab_processor">brcobranca</field>
</record>

<!-- Payment Mode Cobrança Unicred 400 -->
<record
id="l10n_br_account_payment_order.payment_mode_cobranca_unicred400"
model="account.payment.mode"
id="l10n_br_account_payment_order.cnab_config_unicred_400"
model="l10n_br_cnab.config"
>
<field name="cnab_processor">brcobranca</field>
</record>

<!-- Payment Mode Cobrança Unicred 240 -->
<record
id="l10n_br_account_payment_order.payment_mode_cobranca_unicred240"
model="account.payment.mode"
id="l10n_br_account_payment_order.cnab_config_unicred_240"
model="l10n_br_cnab.config"
>
<field name="cnab_processor">brcobranca</field>
</record>

<!-- Payment Mode Cobrança AILOS 240 -->
<record
id="l10n_br_account_payment_order.payment_mode_cobranca_ailos240"
model="account.payment.mode"
id="l10n_br_account_payment_order.cnab_config_ailos_240"
model="l10n_br_cnab.config"
>
<field name="cnab_processor">brcobranca</field>
</record>

<!-- Modo de Pagamento cobrança Itau 240 -->
<record
id="l10n_br_account_payment_order.payment_mode_cobranca_itau240"
model="account.payment.mode"
id="l10n_br_account_payment_order.cnab_config_itau_240"
model="l10n_br_cnab.config"
>
<field name="cnab_processor">brcobranca</field>
</record>

<!-- Modo de Pagamento cobrança Itau 400 -->
<record
id="l10n_br_account_payment_order.payment_mode_cobranca_itau400"
model="account.payment.mode"
id="l10n_br_account_payment_order.cnab_config_itau_400"
model="l10n_br_cnab.config"
>
<field name="cnab_processor">brcobranca</field>
</record>

<!-- Modo de Pagamento cobrança Caixa Economica Federal 240 -->
<record
id="l10n_br_account_payment_order.payment_mode_cobranca_cef240"
model="account.payment.mode"
id="l10n_br_account_payment_order.cnab_config_cef_240"
model="l10n_br_cnab.config"
>
<field name="cnab_processor">brcobranca</field>
</record>

<!-- Modo de Pagamento cobrança Caixa Economica Federal 400 -->
<record
id="l10n_br_account_payment_order.payment_mode_cobranca_cef400"
model="account.payment.mode"
id="l10n_br_account_payment_order.cnab_config_cef_400"
model="l10n_br_cnab.config"
>
<field name="cnab_processor">brcobranca</field>
</record>

<!-- Modo de Pagamento Cobrança SICRED 240 -->
<record
id="l10n_br_account_payment_order.payment_mode_cobranca_sicredi240"
model="account.payment.mode"
id="l10n_br_account_payment_order.cnab_config_sicredi_240"
model="l10n_br_cnab.config"
>
<field name="cnab_processor">brcobranca</field>
</record>

<!-- Payment Mode Cobrança Banco do Brasil 400 -->
<record
id="l10n_br_account_payment_order.payment_mode_cobranca_bb400"
model="account.payment.mode"
id="l10n_br_account_payment_order.cnab_config_bb_400"
model="l10n_br_cnab.config"
>
<field name="cnab_processor">brcobranca</field>
</record>

<!-- Payment Mode Cobrança Banco do Brasil 240 -->
<record
id="l10n_br_account_payment_order.payment_mode_cobranca_bb240"
model="account.payment.mode"
id="l10n_br_account_payment_order.cnab_config_bb_240"
model="l10n_br_cnab.config"
>
<field name="cnab_processor">brcobranca</field>
</record>

<!-- Bradesco 400 -->
<record
id="l10n_br_account_payment_order.payment_mode_cobranca_santander_400"
model="account.payment.mode"
id="l10n_br_account_payment_order.cnab_config_santander_400"
model="l10n_br_cnab.config"
>
<field name="cnab_processor">brcobranca</field>
</record>

<!-- Bradesco 240 -->
<record
id="l10n_br_account_payment_order.payment_mode_cobranca_santander_240"
model="account.payment.mode"
id="l10n_br_account_payment_order.cnab_config_santander_240"
model="l10n_br_cnab.config"
>
<field name="cnab_processor">brcobranca</field>
</record>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Copyright (C) 2024-Today - Akretion (<http://www.akretion.com>).
# @author Magno Costa <[email protected]>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from openupgradelib import openupgrade


def update_cnab_config(env):
"""Atualiza a Configuração do CNAB"""
env.cr.execute(
"""
SELECT id FROM account_payment_mode WHERE payment_method_id IN
(SELECT id FROM account_payment_method WHERE code IN ('240', '400', '500')
AND payment_type = 'inbound');
"""
)
for row in env.cr.fetchall():
payment_mode = env["account.payment.mode"].browse(row[0])
cnab_config = env["l10n_br_cnab.config"].search(
[
("bank_id", "=", payment_mode.fixed_journal_id.bank_id.id),
("payment_method_id", "=", payment_mode.payment_method_id.id),
]
)
cnab_config.cnab_processor = payment_mode.cnab_processor


@openupgrade.migrate()
def migrate(env, version):
if not version:
return
update_cnab_config(env)
2 changes: 1 addition & 1 deletion l10n_br_account_payment_brcobranca/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
from . import account_payment_order
from . import account_payment_line
from . import account_journal
from . import account_payment_mode
from . import l10n_br_cnab_config
2 changes: 1 addition & 1 deletion l10n_br_account_payment_brcobranca/models/account_move.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class AccountMove(models.Model):
_inherit = "account.move"

def generate_boleto_pdf(self):
if self.payment_mode_id.cnab_processor != "brcobranca":
if self.payment_mode_id.cnab_config_id.cnab_processor != "brcobranca":
return super().generate_boleto_pdf()

file_pdf = self.file_boleto_pdf_id
Expand Down
34 changes: 16 additions & 18 deletions l10n_br_account_payment_brcobranca/models/account_move_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ def send_payment(self):
bank_name_brcobranca = get_brcobranca_bank(
bank_account_id, move_line.payment_mode_id.payment_method_code
)
cnab_config = move_line.payment_mode_id.cnab_config_id

boleto_cnab_api_data = {
"bank": bank_name_brcobranca[0],
Expand All @@ -64,8 +65,8 @@ def send_payment(self):
"sacado_documento": move_line.partner_id.cnpj_cpf,
"agencia": bank_account_id.bra_number,
"conta_corrente": bank_account_id.acc_number,
"convenio": move_line.payment_mode_id.cnab_company_bank_code,
"carteira": str(move_line.payment_mode_id.boleto_wallet),
"convenio": cnab_config.cnab_company_bank_code,
"carteira": str(cnab_config.boleto_wallet),
"nosso_numero": int(
"".join(i for i in move_line.own_number if i.isdigit())
),
Expand All @@ -74,10 +75,10 @@ def send_payment(self):
"data_documento": move_line.move_id.invoice_date.strftime("%Y/%m/%d"),
"especie": move_line.currency_id.symbol,
"especie_documento": get_boleto_especie_short_name(
move_line.payment_mode_id.boleto_species
cnab_config.boleto_species
),
"moeda": DICT_BRCOBRANCA_CURRENCY["R$"],
"aceite": move_line.payment_mode_id.boleto_accept,
"aceite": cnab_config.boleto_accept,
"sacado_endereco": (move_line.partner_id.street_name or "")
+ " "
+ (move_line.partner_id.street_number or "")
Expand All @@ -92,19 +93,16 @@ def send_payment(self):
"data_processamento": move_line.move_id.invoice_date.strftime(
"%Y/%m/%d"
),
"instrucao1": move_line.payment_mode_id.instructions or "",
"instrucao1": cnab_config.instructions or "",
}

# Instrução de Juros
if move_line.payment_mode_id.boleto_interest_perc > 0.0:
if cnab_config.boleto_interest_perc > 0.0:
valor_juros = move_line.currency_id.round(
move_line.debit
* ((move_line.payment_mode_id.boleto_interest_perc / 100) / 30),
move_line.debit * ((cnab_config.boleto_interest_perc / 100) / 30),
)
percentual_formatado = (
f"{move_line.payment_mode_id.boleto_interest_perc:.2f}".replace(
".", ","
)
f"{cnab_config.boleto_interest_perc:.2f}".replace(".", ",")
)
juros_formatado = f"{valor_juros:.2f}".replace(".", ",")
instrucao_juros = (
Expand All @@ -118,12 +116,12 @@ def send_payment(self):
)

# Instrução Multa
if move_line.payment_mode_id.boleto_fee_perc > 0.0:
if cnab_config.boleto_fee_perc > 0.0:
valor_multa = move_line.currency_id.round(
move_line.debit * (move_line.payment_mode_id.boleto_fee_perc / 100),
move_line.debit * (cnab_config.boleto_fee_perc / 100),
)
percentual_formatado = (
f"{move_line.payment_mode_id.boleto_fee_perc:.2f}".replace(".", ",")
percentual_formatado = f"{cnab_config.boleto_fee_perc:.2f}".replace(
".", ","
)
multa_formatado = f"{valor_multa:.2f}".replace(".", ",")
instrucao_multa = (
Expand Down Expand Up @@ -173,8 +171,8 @@ def send_payment(self):
if bank_account_id.bank_id.code_bc in ("748", "756"):
boleto_cnab_api_data.update(
{
"byte_idt": move_line.payment_mode_id.boleto_byte_idt,
"posto": move_line.payment_mode_id.boleto_post,
"byte_idt": cnab_config.boleto_byte_idt,
"posto": cnab_config.boleto_post,
}
)
# Campo usado no Unicred
Expand All @@ -193,7 +191,7 @@ def send_payment(self):
# no boleto é usado o convenio
boleto_cnab_api_data.update(
{
"convenio": move_line.payment_mode_id.convention_code,
"convenio": cnab_config.convention_code,
}
)

Expand Down
Loading
Loading