Skip to content

Commit

Permalink
Merge db8bf32 into 409c924
Browse files Browse the repository at this point in the history
  • Loading branch information
carcaroff committed Aug 21, 2018
2 parents 409c924 + db8bf32 commit 8b802c4
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
14 changes: 12 additions & 2 deletions br_cnab/febraban/cnab_240/bancos/bradesco.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import re
import string
from decimal import Decimal
from odoo.exceptions import UserError


class Bradesco240(Cnab240):
Expand All @@ -21,9 +22,12 @@ def __init__(self):

def _prepare_header(self):
vals = super(Bradesco240, self)._prepare_header()
vals['servico_servico'] = 1
vals['cedente_convenio'] = self.order.payment_mode_id.bank_account_id.\

cod_convenio = self.order.payment_mode_id.bank_account_id.\
codigo_convenio

vals['servico_servico'] = 1
vals['cedente_convenio'] = '{:<020s}'.format(cod_convenio)
vals['controlecob_numero'] = self.order.id
vals['controlecob_data_gravacao'] = self.data_hoje()
vals['nome_do_banco'] = 'BANCO BRADESCO S.A'
Expand Down Expand Up @@ -98,3 +102,9 @@ def modulo11(self, num, base=9, r=0):
if r == 1:
resto = soma % 11
return resto

def _hook_validation(self):
if not self.order.payment_mode_id.bank_account_id.\
codigo_convenio:
raise UserError(
'Código de convênio não pode estar vazio!')
6 changes: 6 additions & 0 deletions br_cnab/febraban/cnab_240/cnab_240.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,9 @@ def _prepare_segmento(self, line):
def remessa(self, order):
cobrancasimples_valor_titulos = 0
self.order = order

self._hook_validation()

header = self._prepare_header()
self.arquivo = Arquivo(self.bank, **header)
for line in order.line_ids:
Expand All @@ -238,3 +241,6 @@ def data_hoje(self):

def hora_agora(self):
return (int(time.strftime("%H%M%S")))

def _hook_validation(self):
pass

0 comments on commit 8b802c4

Please sign in to comment.