<commit_before># Copyright 2018 <NAME>/NV
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from odoo import fields, models
from odoo.tools import float_compare


class AccountMove(models.Model):

    _inherit = 'account.move'

    def _can_pay_invoice_with_discount(self, check_due_date=True):
        self.ensure_one()
        today = fields.Date.today()
        rounding = self.currency_id.rounding
        if not self.has_discount:
            return False

        if check_due_date:
            date_check_valid = self.discount_due_date >= today
        else:
            date_check_valid = True

        return (
            date_check_valid and
            float_compare(
                self.amount_residual,
                self.amount_total - self.refunds_discount_amount,
                precision_rounding=rounding,
            ) == 0
        )
<commit_msg>[MIG] account_cash_discount_write_off to v13<commit_after># Copyright 2018 <NAME>/NV
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from odoo import fields, models
from odoo.tools import float_compare


class AccountMove(models.Model):

    _inherit = 'account.move'

    def _can_pay_invoice_with_discount(self, check_due_date=True):
        self.ensure_one()
        today = fields.Date.today()
        rounding = self.currency_id.rounding
        if not self.has_discount:
            return False

        if check_due_date:
            date_check_valid = self.discount_due_date >= today
        else:
            date_check_valid = True

        refunds_amount_total = self._get_refunds_amount_total()['total']
        return (
            date_check_valid and
            float_compare(
                self.amount_residual,
                self.amount_total - refunds_amount_total,
                precision_rounding=rounding,
            ) == 0
        )

{'fraction_non_alphanumeric': 0.07877813504823152, 'fraction_numerical': 0.00857449088960343, 'mean_word_length': 2.1697792869269947, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, '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': '1456256', 'n_tokens_mistral': 585, 'n_tokens_neox': 549, 'n_words': 109}