<commit_before># -*- coding:utf-8 -*-
##############################################################################
#
#    Copyright (C) 2014 Savoir-faire Linux. All Rights Reserved.
#
#    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 openerp.osv import orm
from openerp.tools.safe_eval import safe_eval as eval
from openerp.tools.translate import _


class hr_payslip(orm.Model):
    _inherit = 'hr.payslip'

    def get_rule_variable(
        self, cr, uid, ids, rule_id, date, localdict=False, context=None
    ):
        """
        Gets a salary rule variable related to a salary rule for
        a period of time

        returns: fixed amount (a float) or a python object (most likely a dict)
        """
        rule = self.pool['hr.salary.rule'].browse(
            cr, uid, rule_id, context=context
        )

        # Find the salary rule variable related to that rule for the
        # requested period
        variable_list = [
            variable for variable in rule.variable_ids
            if variable.date_from <= date <= variable.date_to
        ]
        if not variable_list:<commit_msg>added more description for get_rule_variable<commit_after># -*- coding:utf-8 -*-
##############################################################################
#
#    Copyright (C) 2014 Savoir-faire Linux. All Rights Reserved.
#
#    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 openerp.osv import orm
from openerp.tools.safe_eval import safe_eval as eval
from openerp.tools.translate import _


class hr_payslip(orm.Model):
    _inherit = 'hr.payslip'

    def get_rule_variable(
        self, cr, uid, ids, rule_id, date, localdict=False, context=None
    ):
        """
        Gets a salary rule variable related to a salary rule for
        a period of time

        This method is called from the salary rule:
        payslip.get_rule_variable(rule_id, payslip.date_from)

        By using the optional argument localdict, you can pass the value of
        salary rule already computed. Example:
        payslip.get_rule_variable(rule_id, payslip.date_from, GROSS)

        returns: fixed amount (a float) or a python object (most likely a dict)
        """
        rule = self.pool['hr.salary.rule'].browse(
            cr, uid, rule_id, context=context
        )

        # Find the salary rule variable related to that rule for the
        # requested period
        variable_list = [
            variable for variable in rule.variable_ids
            if variable.date_from <= date <= variable.date_to
        ]
        if not variable_list:
{'fraction_non_alphanumeric': 0.14171855541718556, 'fraction_numerical': 0.0029887920298879204, 'mean_word_length': 2.984126984126984, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '7375250', 'n_tokens_mistral': 1063, 'n_tokens_neox': 1018, 'n_words': 431}