<commit_before># -*- coding: utf-8 -*-
##############################################################################
#
#    Account Payment Boleto module for Odoo
#    Copyright (C) 2012-2015 KMEE (http://www.kmee.com.br)
#    @author <NAME> <<EMAIL>>
#
#    This program is free software: you can redistribute it and/or modify
#    it under the terms of the GNU Affero General Public License as
#    published by the Free Software Foundation, either version 3 of the
#    License, or (at your option) any later version.
#
#    This program is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU Affero General Public License for more details.
#
#    You should have received a copy of the GNU Affero General Public License
#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################

from datetime import datetime, date
from pyboleto import bank

try:
    from cStringIO import StringIO
except ImportError:
    from StringIO import StringIO
BoletoException = bank.BoletoException


class Boleto:
    boleto = object
    account_number = ''
    account_digit = ''

    branch_number = ''
    branch_digit = ''

    nosso_numero = ''

    @staticmethod
    def getBoleto(move_line, nosso_numero):
        boleto_type = move_line.payment_mode_id.boleto_type
        if boleto_type:
            return dict_boleto[boleto_type][0](move_line, nosso_numero)
        raise BoletoException(u'Configure o tipo de boleto no modo de '
                              u'pagamento')

    @staticmethod
    def getBoletoClass(move_line):
        bank_code = move_line.payment_mode_id.bank_id.bank.bic
        return bank.get_class_for_codigo(bank_code)

    def __init__(self, move_line, nosso_numero):
        self._cedente(move_line.company_id)
        self._sacado(move_line.partner_id)
        self._move_line(move_line)
        self.nosso_numero = nosso_numero

    def getAccountNumber(self):
        if self.account_digit:
            return str(self.account_number + '-' +
                       self.account_digit).encode('utf-8')
        return self.account_number.encode('utf-8')

    def getBranchNumber(self):
        if self.branch_digit:
            return str(self.branch_number + '-' +
                       self.branch_digit).encode('utf-8')
        return self.branch_number.encode('utf-8')

    def _move_line(self, move_line):
        
        boleto_multa_percent = (move_line.debit * move_line.payment_mode_id.cnab_percent_interest  * 0.01) or (move_line.credit * move_line.payment_mode_id.cnab_percent_interest * 0.01) 
        juros_by_day = ((move_line.debit or move_line.credit )+ boleto_multa_percent ) * move_line.payment_mode_id.multa * 0.01
        instrucoes = ''
        if move_line.payment_mode_id.instrucoes:
            instrucoes =  move_line.payment_mode_id.instrucoes
        instrucoes =  instrucoes  + u"\n Após o vencimento cobrar multa de R$ %s e juros de R$ %s ao dia." %(str("%.2f" % boleto_multa_percent) or '', str("%.2f" % juros_by_day or '0.00'))
        self._payment_mode(move_line.payment_mode_id)
        self.boleto.data_vencimento = datetime.date(datetime.strptime(
            move_line.date_maturity, '%Y-%m-%d'))
        self.boleto.data_documento = datetime.date(datetime.strptime(<commit_msg>correct multa computation in boleto<commit_after># -*- coding: utf-8 -*-
##############################################################################
#
#    Account Payment Boleto module for Odoo
#    Copyright (C) 2012-2015 KMEE (http://www.kmee.com.br)
#    @author <NAME> <<EMAIL>>
#
#    This program is free software: you can redistribute it and/or modify
#    it under the terms of the GNU Affero General Public License as
#    published by the Free Software Foundation, either version 3 of the
#    License, or (at your option) any later version.
#
#    This program is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU Affero General Public License for more details.
#
#    You should have received a copy of the GNU Affero General Public License
#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################

from datetime import datetime, date
from pyboleto import bank

try:
    from cStringIO import StringIO
except ImportError:
    from StringIO import StringIO
BoletoException = bank.BoletoException


class Boleto:
    boleto = object
    account_number = ''
    account_digit = ''

    branch_number = ''
    branch_digit = ''

    nosso_numero = ''

    @staticmethod
    def getBoleto(move_line, nosso_numero):
        boleto_type = move_line.payment_mode_id.boleto_type
        if boleto_type:
            return dict_boleto[boleto_type][0](move_line, nosso_numero)
        raise BoletoException(u'Configure o tipo de boleto no modo de '
                              u'pagamento')

    @staticmethod
    def getBoletoClass(move_line):
        bank_code = move_line.payment_mode_id.bank_id.bank.bic
        return bank.get_class_for_codigo(bank_code)

    def __init__(self, move_line, nosso_numero):
        self._cedente(move_line.company_id)
        self._sacado(move_line.partner_id)
        self._move_line(move_line)
        self.nosso_numero = nosso_numero

    def getAccountNumber(self):
        if self.account_digit:
            return str(self.account_number + '-' +
                       self.account_digit).encode('utf-8')
        return self.account_number.encode('utf-8')

    def getBranchNumber(self):
        if self.branch_digit:
            return str(self.branch_number + '-' +
                       self.branch_digit).encode('utf-8')
        return self.branch_number.encode('utf-8')

    def _move_line(self, move_line):
        
        boleto_multa_percent = (move_line.debit * move_line.payment_mode_id.cnab_percent_interest  * 0.01) or (move_line.credit * move_line.payment_mode_id.cnab_percent_interest * 0.01) 
        juros_by_day = (((move_line.debit or move_line.credit )+ boleto_multa_percent ) * move_line.payment_mode_id.multa * 0.01)/30
        instrucoes = ''
        if move_line.payment_mode_id.instrucoes:
            instrucoes =  move_line.payment_mode_id.instrucoes
        instrucoes =  instrucoes  + u"\n Após o vencimento cobrar multa de R$ %s e juros de R$ %s ao dia." %(str("%.2f" % boleto_multa_percent) or '', str("%.2f" % juros_by_day or '0.00'))
        self._payment_mode(move_line.payment_mode_id)
        self.boleto.data_vencimento = datetime.date(datetime.strptime(
            move_line.date_maturity, '%Y-%m-%d'))
        self.boleto.data_documento = datetime.date(datetime.strptime(
{'fraction_non_alphanumeric': 0.13229181596674788, 'fraction_numerical': 0.008599684678228465, 'mean_word_length': 3.0998824911868392, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 4, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '248071', 'n_tokens_mistral': 2239, 'n_tokens_neox': 2160, 'n_words': 523}