'Compute the percentage to apply for cash basis method. This value is relevant only for moves that
involve journal items on receivable or payable accounts.'

@api.depends('line_ids.debit', 'line_ids.credit', 'line_ids.matched_debit_ids.amount', 'line_ids.matched_credit_ids.amount', 'line_ids.account_id.user_type_id.type')
def _compute_matched_percentage(self):

    for move in self:
        total_amount = 0.0
        total_reconciled = 0.0
        for line in move.line_ids:
            if (line.account_id.user_type_id.type in ('receivable', 'payable')):
                amount = abs((line.debit - line.credit))
                total_amount += amount
                for partial_line in (line.matched_debit_ids + line.matched_credit_ids):
                    total_reconciled += partial_line.amount
        if float_is_zero(total_amount, precision_rounding=move.currency_id.rounding):
            move.matched_percentage = 1.0
        else:
            move.matched_percentage = (total_reconciled / total_amount)
