Исправь эту функцию так, чтобы корректно учитывались досрочные платежи (cpr) в графике погаешния аннуитетного кредита, сумма погашения должна идти в уменьшение ежемесячного платежа по кредиту def calculate_credit_life_payments_annuity3(cred_sum: [float], cred_rate: [float], cred_term: [float], cpr: [float, dict] = 0, discount_rate: [float, dict] = 0) -> list:

    
    life_time = []
    x = 0
    
    cpr_orig = cpr
    discount_rate_orig = discount_rate

    while round(cred_sum,0)>0 and x<cred_term: 
        
        if x == 0:
            period = 1

            if type(cpr_orig) == dict:
                cpr = interpolate.interp1d(list(cpr_orig.keys()), list(cpr_orig.values()), fill_value = 'extrapolate')(x)
            if type(discount_rate_orig) == dict:
                discount_rate = interpolate.interp1d(list(discount_rate_orig.keys()), list(discount_rate_orig.values()), fill_value = 'extrapolate')(x)
            
            payment_total = cred_sum * (cred_rate/100/12)/(1-(1 + cred_rate/100/12) ** (-cred_term))                
            # payment_total = payment_total * (1 + (0 if cred_term == 1 else cpr))     
            
            payment_in_percent = cred_rate/100/12 * cred_sum                
            payment_in_body = payment_total - payment_in_percent                
                
            life_time += [
                                    {'Совокупный платеж' : payment_total,
                                    'Дисконтированный совокупный платеж' : payment_total / (1 + discount_rate/12 * period),
                                    'Платеж по процентам' : payment_in_percent,
                                    'Платеж по телу кредита' : payment_in_body,
                                    'ОСЗ' : cred_sum - payment_in_body,
                                    'CPR' : cpr,
                                    'discount_rate' : discount_rate}
                         ]
            cred_sum = life_time[-1]['ОСЗ']
            cred_sum = (cred_sum) - ((cred_sum + payment_in_body) * cpr)
            x += 1
            
        else:
            period += 1
            
            if type(cpr_orig) == dict:
                cpr = interpolate.interp1d(list(cpr_orig.keys()), list(cpr_orig.values()), fill_value = 'extrapolate')(x)
            if type(discount_rate_orig) == dict:
                discount_rate = interpolate.interp1d(list(discount_rate_orig.keys()), list(discount_rate_orig.values()), fill_value = 'extrapolate')(x)

                
            payment_total = cred_sum * (cred_rate/100/12)/(1-(1 + cred_rate/100/12) ** (-cred_term))    
                     
            if payment_total > (cred_sum + (cred_rate/100/12 * cred_sum)):
                payment_total = cred_sum + (cred_rate/100/12 * cred_sum)

            payment_in_percent = cred_rate/100/12 * cred_sum                
            payment_in_body = payment_total - payment_in_percent                
                
            life_time += [
                                    {'Совокупный платеж' : payment_total,
                                    'Дисконтированный совокупный платеж' : payment_total / (1 + discount_rate/12 * period),
                                    'Платеж по процентам' : payment_in_percent,
                                    'Платеж по телу кредита' : payment_in_body,
                                    'ОСЗ' : cred_sum - payment_in_body,
                                    'CPR' : cpr,
                                    'discount_rate' : discount_rate}
                         ]
            cred_sum = life_time[-1]['ОСЗ']
            cred_sum = (cred_sum) - ((cred_sum + payment_in_body) * cpr)
            x += 1            
            
            
        
    return life_time