forked from odoo-brazil/odoo-brazil-banking
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request odoo-brazil#14 from kmee/fix/refactory_module_paym…
…ent_mode Refatorar modulo para CNAB240
- develop
- (odoo-brazil/odoo-brazil-banking#46)
- develop-campo_nosso_numero_so_numeros
- (odoo-brazil/odoo-brazil-banking#46)
- develop-correcao_dados_demo
- (odoo-brazil/odoo-brazil-banking#46)
- develop-correcao_nome_pastas_l10n_br_account_banking_payment_bradesco_tributos
- (odoo-brazil/odoo-brazil-banking#46)
- develop-correcao_nome_pastas_l10n_br_account_banking_payment_cnab
- (odoo-brazil/odoo-brazil-banking#46)
- develop-correcao_nome_pastas_l10n_br_cnab400_import
- (odoo-brazil/odoo-brazil-banking#46)
- develop-corrigido_wizard_importacao_fatura
- (odoo-brazil/odoo-brazil-banking#46)
- develop-descomentado_arquivos_banking_payment_cnab
- (odoo-brazil/odoo-brazil-banking#46)
- develop-domain-manipulation-guards
- (odoo-brazil/odoo-brazil-banking#46)
- develop-grupo_permissao_acesso_cnab
- (odoo-brazil/odoo-brazil-banking#46)
- develop-incluido_rodape_msgs_cnab_retorno
- (odoo-brazil/odoo-brazil-banking#46)
- develop-incluido_type_payment_na_visao
- (odoo-brazil/odoo-brazil-banking#46)
- develop-incluir_campo_payment_mode_visao_nfe
- (odoo-brazil/odoo-brazil-banking#46)
- develop-incluir_campo_type_payment_visao_payment_mode
- (odoo-brazil/odoo-brazil-banking#46)
- develop-internal_sequence_id_requerido_payment_mode
- (odoo-brazil/odoo-brazil-banking#46)
- develop-leiute_impressao_retorno_cnab
- (odoo-brazil/odoo-brazil-banking#46)
- develop-padronizacao_nome_pastas_l10n_br_cnab_import
- (odoo-brazil/odoo-brazil-banking#46)
- develop-percentual_desconto_ate_data_vencimento
- (odoo-brazil/odoo-brazil-banking#46)
- develop-percentual_mora
- (odoo-brazil/odoo-brazil-banking#46)
- develop-pyboleto_espera_str_nao_unicode
- (odoo-brazil/odoo-brazil-banking#46)
- develop-remover_domain_campo_payment_mode_id
- (odoo-brazil/odoo-brazil-banking#46)
- develop_merged
- (odoo-brazil/odoo-brazil-banking#46)
Showing
46 changed files
with
1,923 additions
and
481 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
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
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
Large diffs are not rendered by default.
Oops, something went wrong.
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
File renamed without changes.
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
60 changes: 60 additions & 0 deletions
60
l10n_br_account_banking_payment_cnab/febraban/cnab_240/bancos/bb.py
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,60 @@ | ||
# coding: utf-8 | ||
|
||
from __future__ import division, print_function, unicode_literals | ||
|
||
import re | ||
import string | ||
|
||
from ..cnab_240 import Cnab240 | ||
|
||
|
||
class BB240(Cnab240): | ||
|
||
def __init__(self): | ||
super(Cnab240, self).__init__() | ||
from cnab240.bancos import bancodobrasil | ||
self.bank = bancodobrasil | ||
|
||
def _prepare_header(self): | ||
""" | ||
Preparar header do arquivo. | ||
Adicionar informações no header do arquivo do Banco do Brasil | ||
""" | ||
vals = super(BB240, self)._prepare_header() | ||
# vals['servico_servico'] = 1 | ||
return vals | ||
|
||
def _prepare_cobranca(self, line): | ||
""" | ||
Preparar o evento (segmentoA e segmentoB) apartir da payment.line | ||
:param line - payment.line | ||
:return: dict - Informações | ||
""" | ||
vals = super(BB240, self)._prepare_cobranca(line) | ||
# vals['prazo_baixa'] = unicode(str( | ||
# vals['prazo_baixa']), "utf-8") | ||
# vals['desconto1_percentual'] = Decimal('0.00') | ||
# vals['valor_iof'] = Decimal('0.00') | ||
# # vals['cobrancasimples_valor_titulos'] = Decimal('02.00') | ||
# vals['identificacao_titulo_banco'] = int( | ||
# vals['identificacao_titulo_banco']) | ||
# vals['cedente_conta_dv'] = unicode(str( | ||
# vals['cedente_conta_dv']), "utf-8") | ||
# vals['cedente_agencia_dv'] = unicode(str( | ||
# vals['cedente_agencia_dv']), "utf-8") | ||
# vals['cedente_dv_ag_cc'] = unicode(str( | ||
# vals['cedente_dv_ag_cc']), "utf-8") | ||
return vals | ||
|
||
# Override cnab_240.nosso_numero. Diferentes números de dígitos entre | ||
# CEF e Itau | ||
def nosso_numero(self, format): | ||
digito = format[-1:] | ||
carteira = format[:3] | ||
nosso_numero = re.sub( | ||
'[%s]' % re.escape(string.punctuation), '', format[3:-1] or '') | ||
return carteira, nosso_numero, digito | ||
|
||
def str_to_unicode(inp_str): | ||
inp_str = unicode(inp_str, "utf-8") | ||
return inp_str |
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
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
466 changes: 398 additions & 68 deletions
466
l10n_br_account_banking_payment_cnab/febraban/cnab_240/cnab_240.py
Large diffs are not rendered by default.
Oops, something went wrong.
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
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
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
100 changes: 100 additions & 0 deletions
100
l10n_br_account_banking_payment_cnab/model/bank_payment_line.py
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,100 @@ | ||
# -*- coding: utf-8 -*- | ||
from openerp import models, fields, api | ||
from ..constantes import COMPLEMENTO_TIPO_SERVICO, CODIGO_FINALIDADE_TED, \ | ||
AVISO_FAVORECIDO | ||
|
||
STATE = [ | ||
('draft', 'Draft'), | ||
('wait', 'Waiting Paiment'), | ||
('exception', 'Exception'), | ||
('paid', 'Paid'), | ||
] | ||
|
||
|
||
class BankPaymentLine(models.Model): | ||
_inherit = 'bank.payment.line' | ||
|
||
@api.model | ||
def default_get(self, fields_list): | ||
res = super(BankPaymentLine, self).default_get(fields_list) | ||
mode = self.env['payment.order'].browse( | ||
self.env.context.get('order_id')).mode | ||
if mode.codigo_finalidade_doc: | ||
res.update({ | ||
'codigo_finalidade_doc': mode.codigo_finalidade_doc}) | ||
if mode.codigo_finalidade_ted: | ||
res.update({ | ||
'codigo_finalidade_ted': mode.codigo_finalidade_ted | ||
}) | ||
if mode.codigo_finalidade_complementar: | ||
res.update({ | ||
'codigo_finalidade_complementar': | ||
mode.codigo_finalidade_complementar | ||
}) | ||
if mode.aviso_ao_favorecido: | ||
res.update({ | ||
'aviso_ao_favorecido': mode.aviso_ao_favorecido | ||
}) | ||
return res | ||
|
||
codigo_finalidade_doc = fields.Selection( | ||
selection=COMPLEMENTO_TIPO_SERVICO, | ||
string=u'Complemento do Tipo de Serviço', | ||
help=u'Campo P005 do CNAB' | ||
) | ||
codigo_finalidade_ted = fields.Selection( | ||
selection=CODIGO_FINALIDADE_TED, | ||
string=u'Código Finalidade da TED', | ||
help=u'Campo P011 do CNAB' | ||
) | ||
codigo_finalidade_complementar = fields.Char( | ||
size=2, | ||
string=u'Código de finalidade complementar', | ||
help=u'Campo P013 do CNAB' | ||
) | ||
aviso_ao_favorecido = fields.Selection( | ||
selection=AVISO_FAVORECIDO, | ||
string=u'Aviso ao Favorecido', | ||
help=u'Campo P006 do CNAB', | ||
default='0', | ||
) | ||
abatimento = fields.Float( | ||
digits=(13, 2), | ||
string=u'Valor do Abatimento', | ||
help=u'Campo G045 do CNAB', | ||
default=0.00 | ||
) | ||
desconto = fields.Float( | ||
digits=(13, 2), | ||
string=u'Valor do Desconto', | ||
help=u'Campo G046 do CNAB', | ||
default=0.00 | ||
) | ||
mora = fields.Float( | ||
digits=(13, 2), | ||
string=u'Valor da Mora', | ||
help=u'Campo G047 do CNAB', | ||
default=0.00 | ||
) | ||
multa = fields.Float( | ||
digits=(13, 2), | ||
string=u'Valor da Multa', | ||
help=u'Campo G048 do CNAB', | ||
default=0.00 | ||
) | ||
state2 = fields.Selection( | ||
string="State", | ||
selection=STATE, | ||
default="draft", | ||
) | ||
evento_id = fields.One2many( | ||
string="Eventos CNAB", | ||
comodel_name="l10n.br.cnab.evento", | ||
inverse_name="bank_payment_line_id", | ||
readonly=True | ||
) | ||
codigo_finalidade_complementar = fields.Char( | ||
size=2, | ||
string=u'Código de finalidade complementar', | ||
help=u'Campo P013 do CNAB', | ||
) |
304 changes: 304 additions & 0 deletions
304
l10n_br_account_banking_payment_cnab/model/l10n_br_cnab.py
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,304 @@ | ||
# -*- coding: utf-8 -*- | ||
# Copyright 2017 KMEE - Luiz Felipe do Divino Costa <luiz.divino@kmee.com.br> | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
|
||
import base64 | ||
import codecs | ||
import logging | ||
from datetime import datetime | ||
from ..constantes import CODIGO_OCORRENCIAS | ||
|
||
from openerp import api, models, fields, exceptions | ||
|
||
_logger = logging.getLogger(__name__) | ||
try: | ||
from cnab240.bancos import bancodobrasil | ||
from cnab240.tipos import Arquivo | ||
except ImportError as err: | ||
_logger.debug = (err) | ||
|
||
STATE = [ | ||
('draft', 'Novo'), | ||
('done', 'Processado'), | ||
] | ||
|
||
TIPO_OPERACAO = { | ||
'C': u'Lançamento a Crédito', | ||
'D': u'Lançamento a Débito', | ||
'E': u'Extrato para Conciliação', | ||
'G': u'Extrato para Gestão de Caixa', | ||
'I': u'Informações de Títulos Capturados do Próprio Banco', | ||
'R': u'Arquivo Remessa', | ||
'T': u'Arquivo Retorno', | ||
} | ||
|
||
TIPO_SERVICO = { | ||
'01': 'Cobrança', | ||
'03': 'Boleto de Pagamento Eletrônico', | ||
'04': 'Conciliação Bancária', | ||
'05': 'Débitos', | ||
'06': 'Custódia de Cheques', | ||
'07': 'Gestão de Caixa', | ||
'08': 'Consulta/Informação Margem', | ||
'09': 'Averbação da Consignação/Retenção', | ||
'10': 'Pagamento Dividendos', | ||
'11': 'Manutenção da Consignação', | ||
'12': 'Consignação de Parcelas', | ||
'13': 'Glosa da Consignação (INSS)', | ||
'14': 'Consulta de Tributos a pagar', | ||
'20': 'Pagamento Fornecedor', | ||
'22': 'Pagamento de Contas, Tributos e Impostos', | ||
'23': 'Interoperabilidade entre Contas de Instituições de Pagamentos', | ||
'25': 'Compror', | ||
'26': 'Compror Rotativo', | ||
'29': 'Alegação do Pagador', | ||
'30': 'Pagamento Salários', | ||
'32': 'Pagamento de honorários', | ||
'33': 'Pagamento de bolsa auxílio', | ||
'34': 'Pagamento de prebenda (remuneração a padres e sacerdotes)', | ||
'40': 'Vendor', | ||
'41': 'Vendor a Termo', | ||
'50': 'Pagamento Sinistros Segurados', | ||
'60': 'Pagamento Despesas Viajante em Trânsito', | ||
'70': 'Pagamento Autorizado', | ||
'75': 'Pagamento Credenciados', | ||
'77': 'Pagamento de Remuneração', | ||
'80': 'Pagamento Representantes / Vendedores Autorizados', | ||
'90': 'Pagamento Benefícios', | ||
'98': 'Pagamentos Diversos', | ||
} | ||
|
||
TIPO_INSCRICAO_EMPRESA = { | ||
0: 'Isento / Não informado', | ||
1: 'CPF', | ||
2: 'CGC / CNPJ', | ||
3: 'PIS / PASEP', | ||
9: 'Outros', | ||
} | ||
|
||
|
||
class L10nBrHrCnab(models.Model): | ||
_name = "l10n.br.cnab" | ||
_rec_name = "display_name" | ||
|
||
@api.multi | ||
def processar_arquivo_retorno(self): | ||
arquivo_retono = base64.b64decode(self.arquivo_retorno) | ||
f = open('/tmp/cnab_retorno.ret', 'wb') | ||
f.write(arquivo_retono) | ||
f.close() | ||
arquivo_retono = codecs.open('/tmp/cnab_retorno.ret', encoding='ascii') | ||
arquivo_parser = Arquivo(bancodobrasil, arquivo=arquivo_retono) | ||
if not arquivo_parser.header.arquivo_codigo == u'2': | ||
raise exceptions.Warning( | ||
u"Este não é um arquivo de retorno!" | ||
) | ||
data_arquivo = str(arquivo_parser.header.arquivo_data_de_geracao) | ||
self.data_arquivo = fields.Date.from_string( | ||
data_arquivo[4:] + "-" + data_arquivo[2:4] + "-" + | ||
data_arquivo[0:2] | ||
) | ||
self.bank_account_id = self.env['res.partner.bank'].search( | ||
[('acc_number', '=', arquivo_parser.header.cedente_conta)]).id | ||
self.num_lotes = arquivo_parser.trailer.totais_quantidade_lotes | ||
self.num_eventos = arquivo_parser.trailer.totais_quantidade_registros | ||
for lote in arquivo_parser.lotes: | ||
account_bank_id_lote = self.env['res.partner.bank'].search( | ||
[('acc_number', '=', lote.header.cedente_conta)] | ||
).id | ||
vals = { | ||
'account_bank_id': account_bank_id_lote, | ||
'empresa_inscricao_numero': | ||
str(lote.header.empresa_inscricao_numero), | ||
'empresa_inscricao_tipo': | ||
TIPO_INSCRICAO_EMPRESA[lote.header.empresa_inscricao_tipo], | ||
'servico_operacao': | ||
TIPO_OPERACAO[lote.header.servico_operacao], | ||
'tipo_servico': TIPO_SERVICO[str(lote.header.servico_servico)], | ||
'mensagem': lote.header.mensagem1, | ||
'qtd_registros': lote.trailer.quantidade_registros, | ||
'total_valores': float(lote.trailer.somatoria_valores), | ||
'cnab_id': self.id, | ||
} | ||
lote_id = self.env['l10n.br.cnab.lote'].create(vals) | ||
for evento in lote.eventos: | ||
data_evento = str( | ||
evento.credito_data_real) | ||
data_evento = fields.Date.from_string( | ||
data_evento[4:] + "-" + data_evento[2:4] + "-" + | ||
data_evento[0:2] | ||
) | ||
account_bank_id_lote = self.env['res.partner.bank'].search( | ||
[ | ||
('bra_number', '=', evento.favorecido_agencia), | ||
('bra_number_dig', '=', evento.favorecido_agencia_dv), | ||
('acc_number', '=', evento.favorecido_conta), | ||
('acc_number_dig', '=', evento.favorecido_conta_dv) | ||
]) | ||
account_bank_id_lote = account_bank_id_lote.ids[0] \ | ||
if account_bank_id_lote else False | ||
favorecido_partner = self.env['res.partner.bank'].search( | ||
[('owner_name', 'ilike', evento.favorecido_nome)] | ||
) | ||
favorecido_partner = favorecido_partner[0].partner_id.id \ | ||
if favorecido_partner else False | ||
bank_payment_line_id = self.env['bank.payment.line'].search( | ||
[ | ||
('name', '=', evento.credito_seu_numero) | ||
] | ||
) | ||
ocorrencias_dic = dict(CODIGO_OCORRENCIAS) | ||
ocorrencias = [ | ||
evento.ocorrencias[0:2], | ||
evento.ocorrencias[2:4], | ||
evento.ocorrencias[4:6], | ||
evento.ocorrencias[6:8], | ||
evento.ocorrencias[8:10] | ||
] | ||
vals_evento = { | ||
'data_real_pagamento': data_evento, | ||
'segmento': evento.servico_segmento, | ||
'favorecido_nome': favorecido_partner, | ||
'favorecido_conta_bancaria': account_bank_id_lote, | ||
'nosso_numero': str(evento.credito_nosso_numero), | ||
'seu_numero': evento.credito_seu_numero, | ||
'tipo_moeda': evento.credito_moeda_tipo, | ||
'valor_pagamento': evento.credito_valor_pagamento, | ||
'ocorrencias': evento.ocorrencias, | ||
'str_motiv_a': ocorrencias_dic[ocorrencias[0]] if | ||
ocorrencias[0] else '', | ||
'str_motiv_b': ocorrencias_dic[ocorrencias[1]] if | ||
ocorrencias[1] else '', | ||
'str_motiv_c': ocorrencias_dic[ocorrencias[2]] if | ||
ocorrencias[2] else '', | ||
'str_motiv_d': ocorrencias_dic[ocorrencias[3]] if | ||
ocorrencias[3] else '', | ||
'str_motiv_e': ocorrencias_dic[ocorrencias[4]] if | ||
ocorrencias[4] else '', | ||
'lote_id': lote_id.id, | ||
'bank_payment_line_id': bank_payment_line_id.id, | ||
} | ||
self.env['l10n.br.cnab.evento'].create(vals_evento) | ||
if evento.ocorrencias and bank_payment_line_id: | ||
if '00' in ocorrencias: | ||
bank_payment_line_id.write({'state2': 'paid'}) | ||
else: | ||
bank_payment_line_id.write({'state2': 'exception'}) | ||
|
||
return self.write({'state': 'done'}) | ||
|
||
@api.multi | ||
def _get_name(self, data): | ||
cnab_ids = self.search([('data', '=', data)]) | ||
return data + " - " + ( | ||
str(len(cnab_ids) + 1) if cnab_ids else '1' | ||
) | ||
|
||
@api.model | ||
def create(self, vals): | ||
name = self._get_name(vals['data']) | ||
vals.update({'name': name}) | ||
return super(L10nBrHrCnab, self).create(vals) | ||
|
||
arquivo_retorno = fields.Binary(string='Arquivo Retorno') | ||
data = fields.Date( | ||
string="Data CNAB", | ||
required=True, | ||
default=datetime.now() | ||
) | ||
name = fields.Char( | ||
string="Name", | ||
) | ||
lote_id = fields.One2many( | ||
string="Lotes", | ||
comodel_name="l10n.br.cnab.lote", | ||
inverse_name="cnab_id" | ||
) | ||
state = fields.Selection( | ||
string=u"Estágio", | ||
selection=STATE, | ||
default="draft", | ||
) | ||
data_arquivo = fields.Datetime( | ||
string="Data Criação no Banco", | ||
) | ||
bank_account_id = fields.Many2one( | ||
string="Conta cedente", | ||
comodel_name="res.partner.bank", | ||
) | ||
num_lotes = fields.Integer( | ||
string=u"Número de Lotes", | ||
) | ||
num_eventos = fields.Integer( | ||
string=u"Número de Eventos", | ||
) | ||
|
||
|
||
class L10nBrHrCnabLote(models.Model): | ||
_name = "l10n.br.cnab.lote" | ||
|
||
account_bank_id = fields.Many2one( | ||
string=u"Conta Bancária", | ||
comodel_name="res.partner.bank", | ||
) | ||
empresa_inscricao_numero = fields.Char(string=u"Número de Inscrição") | ||
empresa_inscricao_tipo = fields.Char(string=u"Tipo de Inscrição") | ||
servico_operacao = fields.Char(string=u"Tipo de Operação") | ||
tipo_servico = fields.Char(strin=u"Tipo do Serviço") | ||
mensagem = fields.Char(string="Mensagem") | ||
qtd_registros = fields.Integer(string="Quantidade de Registros") | ||
total_valores = fields.Float(string="Valor Total") | ||
evento_id = fields.One2many( | ||
string="Eventos", | ||
comodel_name="l10n.br.cnab.evento", | ||
inverse_name="lote_id", | ||
) | ||
cnab_id = fields.Many2one( | ||
string="CNAB", | ||
comodel_name="l10n.br.cnab" | ||
) | ||
state = fields.Selection( | ||
string="State", | ||
related="cnab_id.state", | ||
selection=STATE, | ||
default="draft", | ||
) | ||
|
||
|
||
class L10nBrHrCnabEvento(models.Model): | ||
_name = "l10n.br.cnab.evento" | ||
|
||
data_real_pagamento = fields.Datetime(string="Data Real do Pagamento") | ||
segmento = fields.Char(string="Segmento") | ||
favorecido_nome = fields.Many2one( | ||
string="Favorecido", | ||
comodel_name="res.partner" | ||
) | ||
favorecido_conta_bancaria = fields.Many2one( | ||
string=u"Conta Bancária", | ||
comodel_name="res.partner.bank", | ||
) | ||
nosso_numero = fields.Char(string=u"Nosso Número") | ||
seu_numero = fields.Char(string=u"Seu Número") | ||
tipo_moeda = fields.Char(string=u"Tipo de Moeda") | ||
valor_pagamento = fields.Float(string="Valor do Pagamento") | ||
ocorrencias = fields.Char(string=u"Ocorrências") | ||
str_motiv_a = fields.Char(u'Motivo da ocorrência 01') | ||
str_motiv_b = fields.Char(u'Motivo de ocorrência 02') | ||
str_motiv_c = fields.Char(u'Motivo de ocorrência 03') | ||
str_motiv_d = fields.Char(u'Motivo de ocorrência 04') | ||
str_motiv_e = fields.Char(u'Motivo de ocorrência 05') | ||
bank_payment_line_id = fields.Many2one( | ||
string="Bank Payment Line", | ||
comodel_name="bank.payment.line", | ||
) | ||
lote_id = fields.Many2one( | ||
string="Lote", | ||
comodel_name="l10n.br.cnab.lote", | ||
) | ||
state = fields.Selection( | ||
string="State", | ||
related="lote_id.state", | ||
selection=STATE, | ||
default="draft", | ||
) |
94 changes: 94 additions & 0 deletions
94
l10n_br_account_banking_payment_cnab/model/payment_line.py
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,94 @@ | ||
# -*- coding: utf-8 -*- | ||
from openerp import models, fields, api | ||
from ..constantes import COMPLEMENTO_TIPO_SERVICO, CODIGO_FINALIDADE_TED, \ | ||
AVISO_FAVORECIDO | ||
|
||
STATE = [ | ||
('draft', 'Draft'), | ||
('wait', 'Waiting Paiment'), | ||
('exception', 'Exception'), | ||
('paid', 'Paid'), | ||
] | ||
|
||
|
||
class PaymentLine(models.Model): | ||
_inherit = 'payment.line' | ||
|
||
@api.model | ||
def default_get(self, fields_list): | ||
res = super(PaymentLine, self).default_get(fields_list) | ||
mode = self.env['payment.order'].browse( | ||
self.env.context.get('order_id')).mode | ||
if mode.codigo_finalidade_doc: | ||
res.update({ | ||
'codigo_finalidade_doc': mode.codigo_finalidade_doc}) | ||
if mode.codigo_finalidade_ted: | ||
res.update({ | ||
'codigo_finalidade_ted': mode.codigo_finalidade_ted | ||
}) | ||
if mode.codigo_finalidade_complementar: | ||
res.update({ | ||
'codigo_finalidade_complementar': | ||
mode.codigo_finalidade_complementar | ||
}) | ||
if mode.aviso_ao_favorecido: | ||
res.update({ | ||
'aviso_ao_favorecido': mode.aviso_ao_favorecido | ||
}) | ||
return res | ||
|
||
seu_numero = fields.Char( | ||
string=u'Seu Número', | ||
size=20, | ||
help=u'Campo G064' | ||
) | ||
codigo_finalidade_doc = fields.Selection( | ||
selection=COMPLEMENTO_TIPO_SERVICO, | ||
string=u'Complemento do Tipo de Serviço', | ||
help=u'Campo P005 do CNAB', | ||
) | ||
codigo_finalidade_ted = fields.Selection( | ||
selection=CODIGO_FINALIDADE_TED, | ||
string=u'Código Finalidade da TED', | ||
help=u'Campo P011 do CNAB', | ||
) | ||
codigo_finalidade_complementar = fields.Char( | ||
size=2, | ||
string=u'Código de finalidade complementar', | ||
help=u'Campo P013 do CNAB', | ||
) | ||
aviso_ao_favorecido = fields.Selection( | ||
selection=AVISO_FAVORECIDO, | ||
string=u'Aviso ao Favorecido', | ||
help=u'Campo P006 do CNAB', | ||
default='0', | ||
) | ||
abatimento = fields.Float( | ||
digits=(13, 2), | ||
string=u'Valor do Abatimento', | ||
help=u'Campo G045 do CNAB', | ||
default=0.00 | ||
) | ||
desconto = fields.Float( | ||
digits=(13, 2), | ||
string=u'Valor do Desconto', | ||
help=u'Campo G046 do CNAB', | ||
default=0.00 | ||
) | ||
mora = fields.Float( | ||
digits=(13, 2), | ||
string=u'Valor da Mora', | ||
help=u'Campo G047 do CNAB', | ||
default=0.00 | ||
) | ||
multa = fields.Float( | ||
digits=(13, 2), | ||
string=u'Valor da Multa', | ||
help=u'Campo G048 do CNAB', | ||
default=0.00 | ||
) | ||
state2 = fields.Selection( | ||
related="bank_line_id.state2", | ||
selection=STATE, | ||
default="draft", | ||
) |
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
106 changes: 53 additions & 53 deletions
106
l10n_br_account_banking_payment_cnab/model/payment_order.py
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
11 changes: 11 additions & 0 deletions
11
l10n_br_account_banking_payment_cnab/security/cnab_cobranca_security.xml
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,11 @@ | ||
<?xml version="1.0" encoding="UTF-8" ?> | ||
<openerp> | ||
<data> | ||
|
||
<record id="group_cnab_cobranca" model="res.groups"> | ||
<field name="name">CNAB Cobranca</field> | ||
<field name="category_id" ref="base.module_category_accounting_and_finance"/> | ||
</record> | ||
|
||
</data> | ||
</openerp> |
6 changes: 6 additions & 0 deletions
6
l10n_br_account_banking_payment_cnab/security/ir.model.access.csv
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,6 @@ | ||
"id","name","model_id:id","group_id:id","perm_read","perm_write","perm_create","perm_unlink" | ||
access_l10n_br_cnab,access_l10n_br_cnab,model_l10n_br_cnab,,1,0,0,0 | ||
access_l10n_br_cnab_lote,access_l10n_br_cnab_lote,model_l10n_br_cnab_lote,,1,0 | ||
access_l10n_br_cnab_evento,access_l10n_br_cnab_evento,model_l10n_br_cnab_evento,,1,0,0,0 | ||
access_l10n_br_cnab_sequence,access_l10n_br_cnab_sequence,model_l10n_br_cnab_sequence,,1,0,0,0 | ||
access_l10n_br_cnab_file_sufix_sequence,access_l10n_br_cnab_file_sufix_sequence,model_l10n_br_cnab_file_sufix_sequence,,1,0,0,0 |
207 changes: 0 additions & 207 deletions
207
l10n_br_account_banking_payment_cnab/tests/invoice_create.yml
This file was deleted.
Oops, something went wrong.
36 changes: 36 additions & 0 deletions
36
l10n_br_account_banking_payment_cnab/view/bank_payment_line.xml
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,36 @@ | ||
<openerp> | ||
<data> | ||
|
||
<record id="bank_payment_line_form" model="ir.ui.view"> | ||
<field name="name">bank.payment.line.form</field> | ||
<field name="model">bank.payment.line</field> | ||
<field name="inherit_id" ref="account_banking_payment_export.bank_payment_line_form"/> | ||
<field name="arch" type="xml"> | ||
<group name="main" position="before"> | ||
<header> | ||
<field name="state2" widget="statusbar" nolabel="1" statusbar_visible="draft,wait,paid" clickable="True"/> | ||
</header> | ||
</group> | ||
<group name="main" position="after"> | ||
<group> | ||
<field name="codigo_finalidade_doc"/> | ||
<field name="codigo_finalidade_ted"/> | ||
<field name="codigo_finalidade_complementar"/> | ||
<field name="abatimento"/> | ||
<field name="desconto"/> | ||
<field name="mora"/> | ||
<field name="multa"/> | ||
<field name="aviso_ao_favorecido"/> | ||
</group> | ||
<xpath expr="//group[@string='Related Payment Lines'" position="after"> | ||
<group string="Histórico de Eventos CNAB Relacionados" name="evento-lines"> | ||
<field name="evento_id" nolabel="1"/> | ||
</group> | ||
</xpath> | ||
</group> | ||
</field> | ||
</record> | ||
|
||
<menuitem id="menu_banking_payment_line" name="Linhas Bancárias de Pagamento" action="account_banking_payment_export.bank_payment_line_action" parent="account_payment.menu_main_payment" sequence="7"/> | ||
</data> | ||
</openerp> |
173 changes: 173 additions & 0 deletions
173
l10n_br_account_banking_payment_cnab/view/l10n_br_cnab_retorno_view.xml
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,173 @@ | ||
<?xml version="1.0" encoding="UTF-8" ?> | ||
<openerp> | ||
<data> | ||
|
||
<menuitem id="menu_main_cnab" name="CNAB" parent="account.menu_finance" sequence="6"/> | ||
|
||
<record id="view_cnab_retorno_tree" model="ir.ui.view"> | ||
<field name="name">cnab.retorno.tree</field> | ||
<field name="model">l10n.br.cnab</field> | ||
<field name="arch" type="xml"> | ||
<tree string="CNAB Retorno Lines"> | ||
<field name="name" /> | ||
<field name="data" /> | ||
<field name="arquivo_retorno" /> | ||
<field name="data_arquivo" /> | ||
<field name="bank_account_id" /> | ||
<field name="num_lotes" /> | ||
<field name="num_eventos" /> | ||
</tree> | ||
</field> | ||
</record> | ||
|
||
<record id="view_cnab_lote_tree" model="ir.ui.view"> | ||
<field name="name">cnab.lote.tree</field> | ||
<field name="model">l10n.br.cnab.lote</field> | ||
<field name="arch" type="xml"> | ||
<tree string="CNAB Lotes Lines"> | ||
<field name="account_bank_id" /> | ||
<field name="empresa_inscricao_numero" /> | ||
<field name="empresa_inscricao_tipo" /> | ||
<field name="servico_operacao" /> | ||
<field name="tipo_servico" /> | ||
<field name="mensagem" /> | ||
<field name="qtd_registros" /> | ||
<field name="total_valores" /> | ||
<field name="evento_id" context="{'form_view_ref':'l10n_br_account_banking_payment_cnab.cnab_retorno_evento_form_view'}" /> | ||
</tree> | ||
</field> | ||
</record> | ||
|
||
<record id="view_cnab_evento_tree" model="ir.ui.view"> | ||
<field name="name">cnab.evento.tree</field> | ||
<field name="model">l10n.br.cnab.evento</field> | ||
<field name="arch" type="xml"> | ||
<tree string="CNAB Evento Lines"> | ||
<field name="data_real_pagamento" /> | ||
<field name="segmento" /> | ||
<field name="favorecido_nome" /> | ||
<field name="nosso_numero" /> | ||
<field name="seu_numero" /> | ||
<field name="tipo_moeda" /> | ||
<field name="valor_pagamento" /> | ||
<field name="ocorrencias" /> | ||
<field name="str_motiv_a" /> | ||
<field name="str_motiv_b" /> | ||
<field name="str_motiv_c" /> | ||
<field name="str_motiv_d" /> | ||
<field name="str_motiv_e" /> | ||
</tree> | ||
</field> | ||
</record> | ||
|
||
<record id="cnab_retorno_evento_form_view" model="ir.ui.view"> | ||
<field name="name">cnab.retorno.evento.form.view</field> | ||
<field name="model">l10n.br.cnab.evento</field> | ||
<field name="arch" type="xml"> | ||
<form> | ||
<header> | ||
<field name="state" widget="statusbar" nolabel="1" statusbar_visible="draft,done" /> | ||
</header> | ||
<group> | ||
<group> | ||
<field name="data_real_pagamento" attrs="{'readonly': [('state', '=', 'done')]}" /> | ||
<field name="segmento" attrs="{'readonly': [('state', '=', 'done')]}" /> | ||
<field name="favorecido_nome" attrs="{'readonly': [('state', '=', 'done')]}" /> | ||
<field name="nosso_numero" attrs="{'readonly': [('state', '=', 'done')]}" /> | ||
<field name="seu_numero" attrs="{'readonly': [('state', '=', 'done')]}" /> | ||
<field name="tipo_moeda" attrs="{'readonly': [('state', '=', 'done')]}" /> | ||
<field name="valor_pagamento" attrs="{'readonly': [('state', '=', 'done')]}" /> | ||
<field name="bank_payment_line_id" attrs="{'readonly': [('state', '=', 'done')]}" /> | ||
</group> | ||
<group> | ||
<field name="ocorrencias" attrs="{'readonly': [('state', '=', 'done')]}" /> | ||
<field name="str_motiv_a" attrs="{'readonly': [('state', '=', 'done')]}" /> | ||
<field name="str_motiv_b" attrs="{'readonly': [('state', '=', 'done')]}" /> | ||
<field name="str_motiv_c" attrs="{'readonly': [('state', '=', 'done')]}" /> | ||
<field name="str_motiv_d" attrs="{'readonly': [('state', '=', 'done')]}" /> | ||
<field name="str_motiv_e" attrs="{'readonly': [('state', '=', 'done')]}" /> | ||
</group> | ||
</group> | ||
</form> | ||
</field> | ||
</record> | ||
|
||
<record id="cnab_retorno_lote_form_view" model="ir.ui.view"> | ||
<field name="name">cnab.retorno.lote.form.view</field> | ||
<field name="model">l10n.br.cnab.lote</field> | ||
<field name="arch" type="xml"> | ||
<form> | ||
<header> | ||
<field name="state" widget="statusbar" nolabel="1" statusbar_visible="draft,done" /> | ||
</header> | ||
<group> | ||
<group> | ||
<field name="account_bank_id" attrs="{'readonly': [('state', '=', 'done')]}" /> | ||
<field name="empresa_inscricao_numero" attrs="{'readonly': [('state', '=', 'done')]}" /> | ||
<field name="empresa_inscricao_tipo" attrs="{'readonly': [('state', '=', 'done')]}" /> | ||
<field name="servico_operacao" attrs="{'readonly': [('state', '=', 'done')]}" /> | ||
</group> | ||
<group> | ||
<field name="tipo_servico" attrs="{'readonly': [('state', '=', 'done')]}" /> | ||
<field name="mensagem" attrs="{'readonly': [('state', '=', 'done')]}" /> | ||
<field name="qtd_registros" attrs="{'readonly': [('state', '=', 'done')]}" /> | ||
<field name="total_valores" attrs="{'readonly': [('state', '=', 'done')]}" /> | ||
</group> | ||
</group> | ||
<group string="Eventos"> | ||
<field name="evento_id" ontext="{'form_view_ref':'l10n_br_account_banking_payment_cnab.cnab_retorno_evento_form_view'}" nolabel="1" attrs="{'readonly': [('state', '=', 'done')]}"/> | ||
</group> | ||
</form> | ||
</field> | ||
</record> | ||
|
||
<record id="cnab_retorno_form_view" model="ir.ui.view"> | ||
<field name="name">cnab.retorno.form.view</field> | ||
<field name="model">l10n.br.cnab</field> | ||
<field name="arch" type="xml"> | ||
<form> | ||
<header> | ||
<button name="processar_arquivo_retorno" states="draft" string="Processar Retorno" type="object" class="oe_highlight" attrs="{'invisible': [('state', '=', 'done')]}" /> | ||
<field name="state" widget="statusbar" nolabel="1" statusbar_visible="draft,done" /> | ||
</header> | ||
<sheet> | ||
<h1> | ||
<field name="name" readonly="1"/> | ||
</h1> | ||
<group> | ||
<group> | ||
<field name="data" attrs="{'readonly': [('state', '=', 'done')]}" /> | ||
<field name="arquivo_retorno" attrs="{'readonly': [('state', '=', 'done')]}" /> | ||
</group> | ||
|
||
</group> | ||
<group attrs="{'invisible': [('state','!=', 'done')], 'readonly': [('state', '=', 'done')]}"> | ||
<group> | ||
<field name="data_arquivo" attrs="{'readonly': [('state', '=', 'done')]}"/> | ||
<field name="bank_account_id" attrs="{'readonly': [('state', '=', 'done')]}" /> | ||
</group> | ||
<group> | ||
<field name="num_lotes" attrs="{'readonly': [('state', '=', 'done')]}" /> | ||
<field name="num_eventos" attrs="{'readonly': [('state', '=', 'done')]}" /> | ||
</group> | ||
</group> | ||
<group string="Lote de Eventos" name="evento-lines" attrs="{'invisible': [('state','!=', 'done')]}"> | ||
<field name="lote_id" context="{'form_view_ref':'l10n_br_account_banking_payment_cnab.cnab_retorno_lote_form_view'}" nolabel="1" attrs="{'readonly': [('state', '=', 'done')]}" /> | ||
</group> | ||
</sheet> | ||
</form> | ||
</field> | ||
</record> | ||
|
||
<record id="action_cnab_retorno" model="ir.actions.act_window"> | ||
<field name="name">CNAB Retorno</field> | ||
<field name="type">ir.actions.act_window</field> | ||
<field name="res_model">l10n.br.cnab</field> | ||
<field name="view_type">form</field> | ||
<field name="view_mode">tree,form</field> | ||
</record> | ||
|
||
<menuitem id="menu_cnab_retorno" parent="menu_main_cnab" name="CNAB Retorno" sequence="1" action="action_cnab_retorno"/> | ||
|
||
</data> | ||
</openerp> |
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
37 changes: 37 additions & 0 deletions
37
l10n_br_account_banking_payment_cnab/view/payment_line.xml
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,37 @@ | ||
<openerp> | ||
<data> | ||
<record id="view_payment_order_form" model="ir.ui.view"> | ||
<field name="name">payment.order.form</field> | ||
<field name="inherit_id" ref="account_banking_payment_export.view_payment_order_form" /> | ||
<field name="model">payment.order</field> | ||
<field name="arch" type="xml"> | ||
<field name="line_ids" position="attributes"> | ||
<attribute name="context">{'order_id': active_id or False, | ||
'default_mode': mode}</attribute> | ||
</field> | ||
<xpath expr="//field[@name='line_ids']/form/notebook" position="before"> | ||
<group name="cnab"> | ||
<field name="seu_numero"/> | ||
<field name="codigo_finalidade_doc"/> | ||
<field name="codigo_finalidade_ted"/> | ||
<field name="codigo_finalidade_complementar"/> | ||
<field name="aviso_ao_favorecido"/> | ||
</group> | ||
</xpath> | ||
</field> | ||
</record> | ||
|
||
<record id="view_payment_line_form" model="ir.ui.view"> | ||
<field name="name">payment.line.form</field> | ||
<field name="model">payment.line</field> | ||
<field name="inherit_id" ref="account_payment.view_payment_line_form" /> | ||
<field name="arch" type="xml"> | ||
<xpath expr="//notebook" position="before"> | ||
<header> | ||
<field name="state2" widget="statusbar" nolabel="1" statusbar_visible="draft,wait,paid" /> | ||
</header> | ||
</xpath> | ||
</field> | ||
</record> | ||
</data> | ||
</openerp> |
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
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
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
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
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
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