from datetime import datetime
from dateutil.relativedelta import relativedelta


def find_distinct_month(key, rules):
    distinct_values = []
    for item_dict in rules:
        if key in item_dict:
            value = item_dict[key]
            if value not in distinct_values:
                distinct_values.append(value)
    return distinct_values


def check_principal_write_off(rule_data, bureau_data, bureau_type, OwnershipDict):
    field_mappings = {'experian': {'date_fields': ['Date_Closed', 'Date_of_Last_Payment', 'Date_Reported'],
                                      'value_field': 'Written_Off_Amt_Principal'},
                         'equifax': {'date_fields': ['sch:DateClosed', 'sch:LastPaymentDate', 'sch:DateReported'],
                                     'value_field': 'sch:WriteOffAmount'}}
    rules = rule_data.get("rules")
    failed_rules = []
    ownership_list = [OwnershipDict[i.capitalize()] for i in rule_data.get("Ownership")]
    data_key = field_mappings.get(bureau_type).get("value_field")
    distinct_month = find_distinct_month('months', rules)
    month_write_off = dict.fromkeys(distinct_month, 0)
    if bureau_data:
        for account in bureau_data:
            if (str(account.get("AccountHoldertypeCode")) in ownership_list or OwnershipDict.get(account.get("sch:OwnershipType")) in ownership_list):
                write_off_amt = int(account.get(data_key)) if account.get(data_key) else 0
                for rule_month in distinct_month:
                    if rule_month != '*':
                        for date_field in field_mappings.get(bureau_type).get("date_fields"):
                            relevant_date_str = account.get(date_field)
                            if relevant_date_str:
                                fmt = "%Y%m%d" if bureau_type == 'experian' else "%Y-%m-%d"
                                relevant_date = datetime.strptime(relevant_date_str, fmt)
                                if relevant_date >= datetime.today() - relativedelta(months=int(rule_month)):
                                    month_write_off[rule_month] += write_off_amt
                                break
    for rule in rules:
        if int(rule.get("value")) <= month_write_off[rule.get("months")]:
            failed_rules.append({
                'rule': rule,
                'total_principal_write_off': month_write_off[rule.get("months")],
                'rule_principal_write_off': rule.get("value")
            })
    if failed_rules:
        return 1
    return 0


principal_write_off_rule = {
        "Ownership": [
          "guarantor"
        ],
        "rules": [
          {
            "value": 5000,
            "months": 12
          }
        ]
      }
accounts = [
    {'Identification_Number': 'NBFXXXXXXXX', 'Subscriber_Name': 'XXXXXXXXXX', 'Account_Number': 'XXX8883',
             'Portfolio_Type': 'I', 'Account_Type': '01', 'Open_Date': '20190328', 'Credit_Limit_Amount': None,
             'Highest_Credit_or_Original_Loan_Amount': '576500', 'Terms_Duration': '035', 'Terms_Frequency': 'M',
             'Scheduled_Monthly_Payment_Amount': None, 'Account_Status': '13', 'Payment_Rating': '0',
             'Payment_History_Profile': '0000?000000000000000000000000000000?', 'Special_Comment': None,
             'Current_Balance': '0', 'Amount_Past_Due': '0', 'Original_Charge_Off_Amount': None,
             'Date_Reported': '20220221', 'Date_of_First_Delinquency': None, 'Date_Closed': '20220221',
             'Date_of_Last_Payment': '20220104', 'SuitFiledWillfulDefaultWrittenOffStatus': None,
             'SuitFiled_WillfulDefault': None, 'Written_off_Settled_Status': None, 'Value_of_Credits_Last_Month': None,
             'Occupation_Code': None, 'Settlement_Amount': None, 'Value_of_Collateral': None,
             'Type_of_Collateral': None, 'Written_Off_Amt_Total': None, 'Written_Off_Amt_Principal': None,
             'Rate_of_Interest': None, 'Repayment_Tenure': '35', 'Promotional_Rate_Flag': None, 'Income': None,
             'Income_Indicator': None, 'Income_Frequency_Indicator': None, 'DefaultStatusDate': None,
             'LitigationStatusDate': None, 'WriteOffStatusDate': None, 'DateOfAddition': '20190331',
             'CurrencyCode': 'INR', 'Subscriber_comments': None, 'Consumer_comments': None,
             'AccountHoldertypeCode': '2', 'CAIS_Account_History': [
        {'Year': '2022', 'Month': '02', 'Days_Past_Due': '0', 'Asset_Classification': '?'},
        {'Year': '2022', 'Month': '01', 'Days_Past_Due': '0', 'Asset_Classification': '?'},
        {'Year': '2021', 'Month': '12', 'Days_Past_Due': '0', 'Asset_Classification': '?'},
        {'Year': '2021', 'Month': '11', 'Days_Past_Due': '0', 'Asset_Classification': '?'},
        {'Year': '2021', 'Month': '10', 'Days_Past_Due': '0', 'Asset_Classification': '?'},
        {'Year': '2021', 'Month': '08', 'Days_Past_Due': '0', 'Asset_Classification': '?'},
        {'Year': '2021', 'Month': '07', 'Days_Past_Due': '0', 'Asset_Classification': '?'},
        {'Year': '2021', 'Month': '06', 'Days_Past_Due': '0', 'Asset_Classification': '?'},
        {'Year': '2021', 'Month': '05', 'Days_Past_Due': '0', 'Asset_Classification': '?'},
        {'Year': '2021', 'Month': '04', 'Days_Past_Due': '0', 'Asset_Classification': '?'},
        {'Year': '2021', 'Month': '03', 'Days_Past_Due': '0', 'Asset_Classification': '?'},
        {'Year': '2021', 'Month': '02', 'Days_Past_Due': '0', 'Asset_Classification': '?'},
        {'Year': '2021', 'Month': '01', 'Days_Past_Due': '0', 'Asset_Classification': '?'},
        {'Year': '2020', 'Month': '12', 'Days_Past_Due': '0', 'Asset_Classification': '?'},
        {'Year': '2020', 'Month': '11', 'Days_Past_Due': '0', 'Asset_Classification': '?'},
        {'Year': '2020', 'Month': '10', 'Days_Past_Due': '0', 'Asset_Classification': '?'},
        {'Year': '2020', 'Month': '09', 'Days_Past_Due': '0', 'Asset_Classification': '?'},
        {'Year': '2020', 'Month': '08', 'Days_Past_Due': '0', 'Asset_Classification': '?'},
        {'Year': '2020', 'Month': '07', 'Days_Past_Due': '0', 'Asset_Classification': '?'},
        {'Year': '2020', 'Month': '06', 'Days_Past_Due': '0', 'Asset_Classification': '?'},
        {'Year': '2020', 'Month': '05', 'Days_Past_Due': '0', 'Asset_Classification': '?'},
        {'Year': '2020', 'Month': '04', 'Days_Past_Due': '0', 'Asset_Classification': '?'},
        {'Year': '2020', 'Month': '03', 'Days_Past_Due': '0', 'Asset_Classification': '?'},
        {'Year': '2020', 'Month': '02', 'Days_Past_Due': '0', 'Asset_Classification': '?'},
        {'Year': '2020', 'Month': '01', 'Days_Past_Due': '0', 'Asset_Classification': 'S'},
        {'Year': '2019', 'Month': '12', 'Days_Past_Due': '0', 'Asset_Classification': 'S'},
        {'Year': '2019', 'Month': '11', 'Days_Past_Due': '0', 'Asset_Classification': 'S'},
        {'Year': '2019', 'Month': '10', 'Days_Past_Due': '0', 'Asset_Classification': 'S'},
        {'Year': '2019', 'Month': '09', 'Days_Past_Due': '0', 'Asset_Classification': 'S'},
        {'Year': '2019', 'Month': '08', 'Days_Past_Due': '0', 'Asset_Classification': 'S'},
        {'Year': '2019', 'Month': '07', 'Days_Past_Due': '0', 'Asset_Classification': 'S'},
        {'Year': '2019', 'Month': '06', 'Days_Past_Due': '0', 'Asset_Classification': 'S'},
        {'Year': '2019', 'Month': '05', 'Days_Past_Due': '0', 'Asset_Classification': 'S'},
        {'Year': '2019', 'Month': '04', 'Days_Past_Due': '0', 'Asset_Classification': 'S'},
        {'Year': '2019', 'Month': '03', 'Days_Past_Due': '0', 'Asset_Classification': 'S'}],
             'CAIS_Holder_Details': {'Surname_Non_Normalized': 'SONU  NIGAM', 'First_Name_Non_Normalized': None,
                                     'Middle_Name_1_Non_Normalized': None, 'Middle_Name_2_Non_Normalized': None,
                                     'Middle_Name_3_Non_Normalized': None, 'Alias': None, 'Gender_Code': '1',
                                     'Income_TAX_PAN': 'BPBPN0003F', 'Passport_Number': None, 'Voter_ID_Number': None,
                                     'Date_of_birth': '19840111'},
             'CAIS_Holder_Address_Details': {'First_Line_Of_Address_non_normalized': 'HATA SHIVPUR',
                                             'Second_Line_Of_Address_non_normalized': 'SHIVPUR',
                                             'Third_Line_Of_Address_non_normalized': 'GORAKHPUR',
                                             'City_non_normalized': 'SHOPUR',
                                             'Fifth_Line_Of_Address_non_normalized': None, 'State_non_normalized': '09',
                                             'ZIP_Postal_Code_non_normalized': '273412',
                                             'CountryCode_non_normalized': 'IB',
                                             'Address_indicator_non_normalized': '04',
                                             'Residence_code_non_normalized': None},
             'CAIS_Holder_Phone_Details': {'Telephone_Number': '8005338853', 'Telephone_Type': '02',
                                           'Telephone_Extension': None, 'Mobile_Telephone_Number': None,
                                           'FaxNumber': None, 'EMailId': None}, 'CAIS_Holder_ID_Details': [
        {'Income_TAX_PAN': 'BPBPN0003F', 'PAN_Issue_Date': None, 'PAN_Expiration_Date': None, 'Passport_Number': None,
         'Passport_Issue_Date': None, 'Passport_Expiration_Date': None, 'Voter_ID_Number': None,
         'Voter_ID_Issue_Date': None, 'Voter_ID_Expiration_Date': None, 'Driver_License_Number': None,
         'Driver_License_Issue_Date': None, 'Driver_License_Expiration_Date': None, 'Ration_Card_Number': None,
         'Ration_Card_Issue_Date': None, 'Ration_Card_Expiration_Date': None, 'Universal_ID_Number': None,
         'Universal_ID_Issue_Date': None, 'Universal_ID_Expiration_Date': None, 'EMailId': None},
        {'Income_TAX_PAN': 'BPBPN0003F', 'PAN_Issue_Date': None, 'PAN_Expiration_Date': None, 'Passport_Number': None,
         'Passport_Issue_Date': None, 'Passport_Expiration_Date': None, 'Voter_ID_Number': None,
         'Voter_ID_Issue_Date': None, 'Voter_ID_Expiration_Date': None, 'Driver_License_Number': None,
         'Driver_License_Issue_Date': None, 'Driver_License_Expiration_Date': None, 'Ration_Card_Number': None,
         'Ration_Card_Issue_Date': None, 'Ration_Card_Expiration_Date': None, 'Universal_ID_Number': None,
         'Universal_ID_Issue_Date': None, 'Universal_ID_Expiration_Date': None, 'EMailId': None},
        {'Income_TAX_PAN': 'BPBPN0003F', 'PAN_Issue_Date': None, 'PAN_Expiration_Date': None, 'Passport_Number': None,
         'Passport_Issue_Date': None, 'Passport_Expiration_Date': None, 'Voter_ID_Number': None,
         'Voter_ID_Issue_Date': None, 'Voter_ID_Expiration_Date': None, 'Driver_License_Number': None,
         'Driver_License_Issue_Date': None, 'Driver_License_Expiration_Date': None, 'Ration_Card_Number': None,
         'Ration_Card_Issue_Date': None, 'Ration_Card_Expiration_Date': None, 'Universal_ID_Number': None,
         'Universal_ID_Issue_Date': None, 'Universal_ID_Expiration_Date': None, 'EMailId': None}]},
            {'Identification_Number': 'PVTXXXXXXXX', 'Subscriber_Name': 'XXXXXXXXXX',
             'Account_Number': 'XXXXXXXXXXXXXXX0231', 'Portfolio_Type': 'R', 'Account_Type': '10',
             'Open_Date': '20200703', 'Credit_Limit_Amount': '230000',
             'Highest_Credit_or_Original_Loan_Amount': '142147', 'Terms_Duration': None, 'Terms_Frequency': None,
             'Scheduled_Monthly_Payment_Amount': None, 'Account_Status': '11', 'Payment_Rating': '0',
             'Payment_History_Profile': '000000000000000000000000000000000000', 'Special_Comment': None,
             'Current_Balance': '18568', 'Amount_Past_Due': None, 'Original_Charge_Off_Amount': None,
             'Date_Reported': '20250531', 'Date_of_First_Delinquency': None, 'Date_Closed': None,
             'Date_of_Last_Payment': '20250507', 'SuitFiledWillfulDefaultWrittenOffStatus': None,
             'SuitFiled_WillfulDefault': None, 'Written_off_Settled_Status': None, 'Value_of_Credits_Last_Month': None,
             'Occupation_Code': 'E', 'Settlement_Amount': None, 'Value_of_Collateral': None, 'Type_of_Collateral': None,
             'Written_Off_Amt_Total': None, 'Written_Off_Amt_Principal': None, 'Rate_of_Interest': None,
             'Repayment_Tenure': '0', 'Promotional_Rate_Flag': None, 'Income': None, 'Income_Indicator': None,
             'Income_Frequency_Indicator': None, 'DefaultStatusDate': None, 'LitigationStatusDate': None,
             'WriteOffStatusDate': None, 'DateOfAddition': '20220531', 'CurrencyCode': 'INR',
             'Subscriber_comments': None, 'Consumer_comments': None, 'AccountHoldertypeCode': '1',
             'CAIS_Account_History': [
                 {'Year': '2025', 'Month': '05', 'Days_Past_Due': '0', 'Asset_Classification': '?'},
                 {'Year': '2025', 'Month': '04', 'Days_Past_Due': '0', 'Asset_Classification': '?'},
                 {'Year': '2025', 'Month': '03', 'Days_Past_Due': '0', 'Asset_Classification': '?'},
                 {'Year': '2025', 'Month': '02', 'Days_Past_Due': '0', 'Asset_Classification': '?'},
                 {'Year': '2025', 'Month': '01', 'Days_Past_Due': '0', 'Asset_Classification': '?'},
                 {'Year': '2024', 'Month': '12', 'Days_Past_Due': '0', 'Asset_Classification': '?'},
                 {'Year': '2024', 'Month': '11', 'Days_Past_Due': '0', 'Asset_Classification': '?'},
                 {'Year': '2024', 'Month': '10', 'Days_Past_Due': '0', 'Asset_Classification': '?'},
                 {'Year': '2024', 'Month': '09', 'Days_Past_Due': '0', 'Asset_Classification': '?'},
                 {'Year': '2024', 'Month': '08', 'Days_Past_Due': '0', 'Asset_Classification': '?'},
                 {'Year': '2024', 'Month': '07', 'Days_Past_Due': '0', 'Asset_Classification': '?'},
                 {'Year': '2024', 'Month': '06', 'Days_Past_Due': '0', 'Asset_Classification': '?'},
                 {'Year': '2024', 'Month': '05', 'Days_Past_Due': '0', 'Asset_Classification': '?'},
                 {'Year': '2024', 'Month': '04', 'Days_Past_Due': '0', 'Asset_Classification': '?'},
                 {'Year': '2024', 'Month': '03', 'Days_Past_Due': '0', 'Asset_Classification': '?'},
                 {'Year': '2024', 'Month': '02', 'Days_Past_Due': '0', 'Asset_Classification': '?'},
                 {'Year': '2024', 'Month': '01', 'Days_Past_Due': '0', 'Asset_Classification': '?'},
                 {'Year': '2023', 'Month': '12', 'Days_Past_Due': '0', 'Asset_Classification': '?'},
                 {'Year': '2023', 'Month': '11', 'Days_Past_Due': '0', 'Asset_Classification': '?'},
                 {'Year': '2023', 'Month': '10', 'Days_Past_Due': '0', 'Asset_Classification': '?'},
                 {'Year': '2023', 'Month': '09', 'Days_Past_Due': '0', 'Asset_Classification': '?'},
                 {'Year': '2023', 'Month': '08', 'Days_Past_Due': '0', 'Asset_Classification': '?'},
                 {'Year': '2023', 'Month': '07', 'Days_Past_Due': '0', 'Asset_Classification': '?'},
                 {'Year': '2023', 'Month': '06', 'Days_Past_Due': '0', 'Asset_Classification': '?'},
                 {'Year': '2023', 'Month': '05', 'Days_Past_Due': '0', 'Asset_Classification': '?'},
                 {'Year': '2023', 'Month': '04', 'Days_Past_Due': '0', 'Asset_Classification': '?'},
                 {'Year': '2023', 'Month': '03', 'Days_Past_Due': '0', 'Asset_Classification': '?'},
                 {'Year': '2023', 'Month': '02', 'Days_Past_Due': '0', 'Asset_Classification': '?'},
                 {'Year': '2023', 'Month': '01', 'Days_Past_Due': '0', 'Asset_Classification': '?'},
                 {'Year': '2022', 'Month': '12', 'Days_Past_Due': '0', 'Asset_Classification': '?'},
                 {'Year': '2022', 'Month': '11', 'Days_Past_Due': '0', 'Asset_Classification': '?'},
                 {'Year': '2022', 'Month': '10', 'Days_Past_Due': '0', 'Asset_Classification': '?'},
                 {'Year': '2022', 'Month': '09', 'Days_Past_Due': '0', 'Asset_Classification': '?'},
                 {'Year': '2022', 'Month': '08', 'Days_Past_Due': '0', 'Asset_Classification': '?'},
                 {'Year': '2022', 'Month': '07', 'Days_Past_Due': '0', 'Asset_Classification': '?'},
                 {'Year': '2022', 'Month': '06', 'Days_Past_Due': '0', 'Asset_Classification': '?'},
                 {'Year': '2022', 'Month': '05', 'Days_Past_Due': '0', 'Asset_Classification': '?'}],
             'CAIS_Holder_Details': {'Surname_Non_Normalized': 'SONU NIGAM', 'First_Name_Non_Normalized': None,
                                     'Middle_Name_1_Non_Normalized': None, 'Middle_Name_2_Non_Normalized': None,
                                     'Middle_Name_3_Non_Normalized': None, 'Alias': None, 'Gender_Code': '1',
                                     'Income_TAX_PAN': 'BPBPN0003F', 'Passport_Number': None, 'Voter_ID_Number': None,
                                     'Date_of_birth': '19840111'},
             'CAIS_Holder_Address_Details': {'First_Line_Of_Address_non_normalized': 'S/O',
                                             'Second_Line_Of_Address_non_normalized': 'GORAKHPUR',
                                             'Third_Line_Of_Address_non_normalized': None, 'City_non_normalized': None,
                                             'Fifth_Line_Of_Address_non_normalized': None, 'State_non_normalized': '09',
                                             'ZIP_Postal_Code_non_normalized': '273412',
                                             'CountryCode_non_normalized': 'IB',
                                             'Address_indicator_non_normalized': '02',
                                             'Residence_code_non_normalized': None},
             'CAIS_Holder_Phone_Details': {'Telephone_Number': None, 'Telephone_Type': '01',
                                           'Telephone_Extension': None, 'Mobile_Telephone_Number': '8005338853',
                                           'FaxNumber': None, 'EMailId': 'NIGAMSONUKUMAR04@GMAIL.COM'},
             'CAIS_Holder_ID_Details': {'Income_TAX_PAN': 'BPBPN0003F', 'PAN_Issue_Date': None,
                                        'PAN_Expiration_Date': None, 'Passport_Number': None,
                                        'Passport_Issue_Date': None, 'Passport_Expiration_Date': None,
                                        'Voter_ID_Number': None, 'Voter_ID_Issue_Date': None,
                                        'Voter_ID_Expiration_Date': None, 'Driver_License_Number': None,
                                        'Driver_License_Issue_Date': None, 'Driver_License_Expiration_Date': None,
                                        'Ration_Card_Number': None, 'Ration_Card_Issue_Date': None,
                                        'Ration_Card_Expiration_Date': None, 'Universal_ID_Number': None,
                                        'Universal_ID_Issue_Date': None, 'Universal_ID_Expiration_Date': None,
                                        'EMailId': 'NIGAMSONUKUMAR04@GMAIL.COM'}},
            {'Identification_Number': 'PVTXXXXXXXX', 'Subscriber_Name': 'XXXXXXXXXX',
             'Account_Number': 'XXXXXXXXXXXXXXX2273', 'Portfolio_Type': 'I', 'Account_Type': '37',
             'Open_Date': '20210311', 'Credit_Limit_Amount': None, 'Highest_Credit_or_Original_Loan_Amount': '105000',
             'Terms_Duration': None, 'Terms_Frequency': None, 'Scheduled_Monthly_Payment_Amount': None,
             'Account_Status': '11', 'Payment_Rating': '0',
             'Payment_History_Profile': '000000000000000000000000000000000000', 'Special_Comment': None,
             'Current_Balance': '30090', 'Amount_Past_Due': None, 'Original_Charge_Off_Amount': None,
             'Date_Reported': '20250531', 'Date_of_First_Delinquency': None, 'Date_Closed': None,
             'Date_of_Last_Payment': '20250507', 'SuitFiledWillfulDefaultWrittenOffStatus': None,
             'SuitFiled_WillfulDefault': None, 'Written_off_Settled_Status': None, 'Value_of_Credits_Last_Month': None,
             'Occupation_Code': None, 'Settlement_Amount': None, 'Value_of_Collateral': None,
             'Type_of_Collateral': None, 'Written_Off_Amt_Total': None, 'Written_Off_Amt_Principal': None,
             'Rate_of_Interest': None, 'Repayment_Tenure': '0', 'Promotional_Rate_Flag': None, 'Income': None,
             'Income_Indicator': None, 'Income_Frequency_Indicator': None, 'DefaultStatusDate': None,
             'LitigationStatusDate': None, 'WriteOffStatusDate': None, 'DateOfAddition': '20220531',
             'CurrencyCode': 'INR', 'Subscriber_comments': None, 'Consumer_comments': None,
             'AccountHoldertypeCode': '1', 'CAIS_Account_History': [
                {'Year': '2025', 'Month': '05', 'Days_Past_Due': '0', 'Asset_Classification': '?'},
                {'Year': '2025', 'Month': '04', 'Days_Past_Due': '0', 'Asset_Classification': '?'},
                {'Year': '2025', 'Month': '03', 'Days_Past_Due': '0', 'Asset_Classification': '?'},
                {'Year': '2025', 'Month': '02', 'Days_Past_Due': '0', 'Asset_Classification': '?'},
                {'Year': '2025', 'Month': '01', 'Days_Past_Due': '0', 'Asset_Classification': '?'},
                {'Year': '2024', 'Month': '12', 'Days_Past_Due': '0', 'Asset_Classification': '?'},
                {'Year': '2024', 'Month': '11', 'Days_Past_Due': '0', 'Asset_Classification': '?'},
                {'Year': '2024', 'Month': '10', 'Days_Past_Due': '0', 'Asset_Classification': '?'},
                {'Year': '2024', 'Month': '09', 'Days_Past_Due': '0', 'Asset_Classification': '?'},
                {'Year': '2024', 'Month': '08', 'Days_Past_Due': '0', 'Asset_Classification': '?'},
                {'Year': '2024', 'Month': '07', 'Days_Past_Due': '0', 'Asset_Classification': '?'},
                {'Year': '2024', 'Month': '06', 'Days_Past_Due': '0', 'Asset_Classification': '?'},
                {'Year': '2024', 'Month': '05', 'Days_Past_Due': '0', 'Asset_Classification': '?'},
                {'Year': '2024', 'Month': '04', 'Days_Past_Due': '0', 'Asset_Classification': '?'},
                {'Year': '2024', 'Month': '03', 'Days_Past_Due': '0', 'Asset_Classification': '?'},
                {'Year': '2024', 'Month': '02', 'Days_Past_Due': '0', 'Asset_Classification': '?'},
                {'Year': '2024', 'Month': '01', 'Days_Past_Due': '0', 'Asset_Classification': '?'},
                {'Year': '2023', 'Month': '12', 'Days_Past_Due': '0', 'Asset_Classification': '?'},
                {'Year': '2023', 'Month': '11', 'Days_Past_Due': '0', 'Asset_Classification': '?'},
                {'Year': '2023', 'Month': '10', 'Days_Past_Due': '0', 'Asset_Classification': '?'},
                {'Year': '2023', 'Month': '09', 'Days_Past_Due': '0', 'Asset_Classification': '?'},
                {'Year': '2023', 'Month': '08', 'Days_Past_Due': '0', 'Asset_Classification': '?'},
                {'Year': '2023', 'Month': '07', 'Days_Past_Due': '0', 'Asset_Classification': '?'},
                {'Year': '2023', 'Month': '06', 'Days_Past_Due': '0', 'Asset_Classification': '?'},
                {'Year': '2023', 'Month': '05', 'Days_Past_Due': '0', 'Asset_Classification': '?'},
                {'Year': '2023', 'Month': '04', 'Days_Past_Due': '0', 'Asset_Classification': '?'},
                {'Year': '2023', 'Month': '03', 'Days_Past_Due': '0', 'Asset_Classification': '?'},
                {'Year': '2023', 'Month': '02', 'Days_Past_Due': '0', 'Asset_Classification': '?'},
                {'Year': '2023', 'Month': '01', 'Days_Past_Due': '0', 'Asset_Classification': '?'},
                {'Year': '2022', 'Month': '12', 'Days_Past_Due': '0', 'Asset_Classification': '?'},
                {'Year': '2022', 'Month': '11', 'Days_Past_Due': '0', 'Asset_Classification': '?'},
                {'Year': '2022', 'Month': '10', 'Days_Past_Due': '0', 'Asset_Classification': '?'},
                {'Year': '2022', 'Month': '09', 'Days_Past_Due': '0', 'Asset_Classification': '?'},
                {'Year': '2022', 'Month': '08', 'Days_Past_Due': '0', 'Asset_Classification': '?'},
                {'Year': '2022', 'Month': '07', 'Days_Past_Due': '0', 'Asset_Classification': '?'},
                {'Year': '2022', 'Month': '06', 'Days_Past_Due': '0', 'Asset_Classification': '?'},
                {'Year': '2022', 'Month': '05', 'Days_Past_Due': '0', 'Asset_Classification': '?'}],
             'CAIS_Holder_Details': {'Surname_Non_Normalized': 'SONU NIGAM', 'First_Name_Non_Normalized': None,
                                     'Middle_Name_1_Non_Normalized': None, 'Middle_Name_2_Non_Normalized': None,
                                     'Middle_Name_3_Non_Normalized': None, 'Alias': None, 'Gender_Code': '1',
                                     'Income_TAX_PAN': 'BPBPN0003F', 'Passport_Number': None, 'Voter_ID_Number': None,
                                     'Date_of_birth': '19840111'},
             'CAIS_Holder_Address_Details': {'First_Line_Of_Address_non_normalized': 'S/O',
                                             'Second_Line_Of_Address_non_normalized': 'GORAKHPUR',
                                             'Third_Line_Of_Address_non_normalized': None, 'City_non_normalized': None,
                                             'Fifth_Line_Of_Address_non_normalized': None, 'State_non_normalized': '09',
                                             'ZIP_Postal_Code_non_normalized': '273412',
                                             'CountryCode_non_normalized': 'IB',
                                             'Address_indicator_non_normalized': '02',
                                             'Residence_code_non_normalized': None},
             'CAIS_Holder_Phone_Details': {'Telephone_Number': None, 'Telephone_Type': '01',
                                           'Telephone_Extension': None, 'Mobile_Telephone_Number': '8005338853',
                                           'FaxNumber': None, 'EMailId': 'NIGAMSONUKUMAR04@GMAIL.COM'},
             'CAIS_Holder_ID_Details': {'Income_TAX_PAN': 'BPBPN0003F', 'PAN_Issue_Date': None,
                                        'PAN_Expiration_Date': None, 'Passport_Number': None,
                                        'Passport_Issue_Date': None, 'Passport_Expiration_Date': None,
                                        'Voter_ID_Number': None, 'Voter_ID_Issue_Date': None,
                                        'Voter_ID_Expiration_Date': None, 'Driver_License_Number': None,
                                        'Driver_License_Issue_Date': None, 'Driver_License_Expiration_Date': None,
                                        'Ration_Card_Number': None, 'Ration_Card_Issue_Date': None,
                                        'Ration_Card_Expiration_Date': None, 'Universal_ID_Number': None,
                                        'Universal_ID_Issue_Date': None, 'Universal_ID_Expiration_Date': None,
                                        'EMailId': 'NIGAMSONUKUMAR04@GMAIL.COM'}},
            {'Identification_Number': 'PVTXXXXXXXX', 'Subscriber_Name': 'XXXXXXXXXX', 'Account_Number': 'XXXX0450',
             'Portfolio_Type': 'I', 'Account_Type': '07', 'Open_Date': '20210319', 'Credit_Limit_Amount': None,
             'Highest_Credit_or_Original_Loan_Amount': '242000', 'Terms_Duration': None, 'Terms_Frequency': None,
             'Scheduled_Monthly_Payment_Amount': None, 'Account_Status': '13', 'Payment_Rating': '0',
             'Payment_History_Profile': '000000000000000000000000????????????', 'Special_Comment': None,
             'Current_Balance': '0', 'Amount_Past_Due': '0', 'Original_Charge_Off_Amount': None,
             'Date_Reported': '20230331', 'Date_of_First_Delinquency': None, 'Date_Closed': '20230310',
             'Date_of_Last_Payment': '20230310', 'SuitFiledWillfulDefaultWrittenOffStatus': None,
             'SuitFiled_WillfulDefault': None, 'Written_off_Settled_Status': None, 'Value_of_Credits_Last_Month': None,
             'Occupation_Code': None, 'Settlement_Amount': None, 'Value_of_Collateral': '0', 'Type_of_Collateral': None,
             'Written_Off_Amt_Total': None, 'Written_Off_Amt_Principal': None, 'Rate_of_Interest': None,
             'Repayment_Tenure': '0', 'Promotional_Rate_Flag': None, 'Income': None, 'Income_Indicator': None,
             'Income_Frequency_Indicator': None, 'DefaultStatusDate': None, 'LitigationStatusDate': None,
             'WriteOffStatusDate': None, 'DateOfAddition': '20210331', 'CurrencyCode': 'INR',
             'Subscriber_comments': None, 'Consumer_comments': None, 'AccountHoldertypeCode': '1',
             'CAIS_Account_History': [
                 {'Year': '2023', 'Month': '03', 'Days_Past_Due': '0', 'Asset_Classification': 'S'},
                 {'Year': '2023', 'Month': '02', 'Days_Past_Due': '0', 'Asset_Classification': 'S'},
                 {'Year': '2023', 'Month': '01', 'Days_Past_Due': '0', 'Asset_Classification': 'S'},
                 {'Year': '2022', 'Month': '12', 'Days_Past_Due': '0', 'Asset_Classification': 'S'},
                 {'Year': '2022', 'Month': '11', 'Days_Past_Due': '0', 'Asset_Classification': 'S'},
                 {'Year': '2022', 'Month': '10', 'Days_Past_Due': '0', 'Asset_Classification': 'S'},
                 {'Year': '2022', 'Month': '09', 'Days_Past_Due': '0', 'Asset_Classification': 'S'},
                 {'Year': '2022', 'Month': '08', 'Days_Past_Due': '0', 'Asset_Classification': 'S'},
                 {'Year': '2022', 'Month': '07', 'Days_Past_Due': '0', 'Asset_Classification': 'S'},
                 {'Year': '2022', 'Month': '06', 'Days_Past_Due': '0', 'Asset_Classification': 'S'},
                 {'Year': '2022', 'Month': '05', 'Days_Past_Due': '0', 'Asset_Classification': 'S'},
                 {'Year': '2022', 'Month': '04', 'Days_Past_Due': '0', 'Asset_Classification': 'S'},
                 {'Year': '2022', 'Month': '03', 'Days_Past_Due': '0', 'Asset_Classification': 'S'},
                 {'Year': '2022', 'Month': '02', 'Days_Past_Due': '0', 'Asset_Classification': 'S'},
                 {'Year': '2022', 'Month': '01', 'Days_Past_Due': '0', 'Asset_Classification': 'S'},
                 {'Year': '2021', 'Month': '12', 'Days_Past_Due': '0', 'Asset_Classification': 'S'},
                 {'Year': '2021', 'Month': '11', 'Days_Past_Due': '0', 'Asset_Classification': 'S'},
                 {'Year': '2021', 'Month': '10', 'Days_Past_Due': '0', 'Asset_Classification': 'S'},
                 {'Year': '2021', 'Month': '09', 'Days_Past_Due': '0', 'Asset_Classification': 'S'},
                 {'Year': '2021', 'Month': '08', 'Days_Past_Due': '0', 'Asset_Classification': 'S'},
                 {'Year': '2021', 'Month': '07', 'Days_Past_Due': '0', 'Asset_Classification': 'S'},
                 {'Year': '2021', 'Month': '06', 'Days_Past_Due': '0', 'Asset_Classification': 'S'},
                 {'Year': '2021', 'Month': '05', 'Days_Past_Due': '0', 'Asset_Classification': 'S'},
                 {'Year': '2021', 'Month': '04', 'Days_Past_Due': '0', 'Asset_Classification': 'S'},
                 {'Year': '2021', 'Month': '03', 'Days_Past_Due': '0', 'Asset_Classification': 'S'}],
             'CAIS_Holder_Details': {'Surname_Non_Normalized': 'SONU', 'First_Name_Non_Normalized': 'NIGAM',
                                     'Middle_Name_1_Non_Normalized': None, 'Middle_Name_2_Non_Normalized': None,
                                     'Middle_Name_3_Non_Normalized': None, 'Alias': None, 'Gender_Code': '1',
                                     'Income_TAX_PAN': 'BPBPN0003F', 'Passport_Number': None, 'Voter_ID_Number': None,
                                     'Date_of_birth': '19840111'}, 'CAIS_Holder_Address_Details': {
                'First_Line_Of_Address_non_normalized': 'S/O:  HARISHCHANDRA, HATA, SHIVPUR',
                'Second_Line_Of_Address_non_normalized': None, 'Third_Line_Of_Address_non_normalized': None,
                'City_non_normalized': None, 'Fifth_Line_Of_Address_non_normalized': None, 'State_non_normalized': '09',
                'ZIP_Postal_Code_non_normalized': '273412', 'CountryCode_non_normalized': 'IB',
                'Address_indicator_non_normalized': '02', 'Residence_code_non_normalized': None},
             'CAIS_Holder_Phone_Details': [
                 {'Telephone_Number': '8005338853', 'Telephone_Type': '03', 'Telephone_Extension': None,
                  'Mobile_Telephone_Number': None, 'FaxNumber': None, 'EMailId': 'NIGAMSONUKUMAR04@GMAIL.COM'},
                 {'Telephone_Number': None, 'Telephone_Type': '01', 'Telephone_Extension': None,
                  'Mobile_Telephone_Number': '8005338853', 'FaxNumber': None, 'EMailId': 'NIGAMSONUKUMAR04@GMAIL.COM'},
                 {'Telephone_Number': '8005338853', 'Telephone_Type': '02', 'Telephone_Extension': None,
                  'Mobile_Telephone_Number': None, 'FaxNumber': None, 'EMailId': 'NIGAMSONUKUMAR04@GMAIL.COM'}],
             'CAIS_Holder_ID_Details': {'Income_TAX_PAN': 'BPBPN0003F', 'PAN_Issue_Date': None,
                                        'PAN_Expiration_Date': None, 'Passport_Number': None,
                                        'Passport_Issue_Date': None, 'Passport_Expiration_Date': None,
                                        'Voter_ID_Number': None, 'Voter_ID_Issue_Date': None,
                                        'Voter_ID_Expiration_Date': None, 'Driver_License_Number': None,
                                        'Driver_License_Issue_Date': None, 'Driver_License_Expiration_Date': None,
                                        'Ration_Card_Number': None, 'Ration_Card_Issue_Date': None,
                                        'Ration_Card_Expiration_Date': None, 'Universal_ID_Number': None,
                                        'Universal_ID_Issue_Date': None, 'Universal_ID_Expiration_Date': None,
                                        'EMailId': 'NIGAMSONUKUMAR04@GMAIL.COM'}},
            {'Identification_Number': 'NBFXXXXXXXX', 'Subscriber_Name': 'XXXXXXXXXX', 'Account_Number': 'XXXX3210',
             'Portfolio_Type': 'I', 'Account_Type': '01', 'Open_Date': '20220219', 'Credit_Limit_Amount': None,
             'Highest_Credit_or_Original_Loan_Amount': '405172', 'Terms_Duration': '035', 'Terms_Frequency': 'M',
             'Scheduled_Monthly_Payment_Amount': None, 'Account_Status': '13', 'Payment_Rating': '0',
             'Payment_History_Profile': '??000000000000000000000000000000000?', 'Special_Comment': None,
             'Current_Balance': '0', 'Amount_Past_Due': '0', 'Original_Charge_Off_Amount': None,
             'Date_Reported': '20250430', 'Date_of_First_Delinquency': None, 'Date_Closed': '20250204',
             'Date_of_Last_Payment': '20250204', 'SuitFiledWillfulDefaultWrittenOffStatus': None,
             'SuitFiled_WillfulDefault': None, 'Written_off_Settled_Status': None, 'Value_of_Credits_Last_Month': None,
             'Occupation_Code': None, 'Settlement_Amount': None, 'Value_of_Collateral': None,
             'Type_of_Collateral': None, 'Written_Off_Amt_Total': None, 'Written_Off_Amt_Principal': None,
             'Rate_of_Interest': None, 'Repayment_Tenure': '35', 'Promotional_Rate_Flag': None, 'Income': None,
             'Income_Indicator': None, 'Income_Frequency_Indicator': None, 'DefaultStatusDate': None,
             'LitigationStatusDate': None, 'WriteOffStatusDate': None, 'DateOfAddition': '20220531',
             'CurrencyCode': 'INR', 'Subscriber_comments': None, 'Consumer_comments': None,
             'AccountHoldertypeCode': '2', 'CAIS_Account_History': [
                {'Year': '2025', 'Month': '04', 'Days_Past_Due': '0', 'Asset_Classification': '?'},
                {'Year': '2025', 'Month': '01', 'Days_Past_Due': '0', 'Asset_Classification': '?'},
                {'Year': '2024', 'Month': '12', 'Days_Past_Due': '0', 'Asset_Classification': '?'},
                {'Year': '2024', 'Month': '11', 'Days_Past_Due': '0', 'Asset_Classification': '?'},
                {'Year': '2024', 'Month': '10', 'Days_Past_Due': '0', 'Asset_Classification': '?'},
                {'Year': '2024', 'Month': '09', 'Days_Past_Due': '0', 'Asset_Classification': '?'},
                {'Year': '2024', 'Month': '08', 'Days_Past_Due': '0', 'Asset_Classification': '?'},
                {'Year': '2024', 'Month': '07', 'Days_Past_Due': '0', 'Asset_Classification': '?'},
                {'Year': '2024', 'Month': '06', 'Days_Past_Due': '0', 'Asset_Classification': '?'},
                {'Year': '2024', 'Month': '05', 'Days_Past_Due': '0', 'Asset_Classification': '?'},
                {'Year': '2024', 'Month': '04', 'Days_Past_Due': '0', 'Asset_Classification': '?'},
                {'Year': '2024', 'Month': '03', 'Days_Past_Due': '0', 'Asset_Classification': '?'},
                {'Year': '2024', 'Month': '02', 'Days_Past_Due': '0', 'Asset_Classification': '?'},
                {'Year': '2024', 'Month': '01', 'Days_Past_Due': '0', 'Asset_Classification': '?'},
                {'Year': '2023', 'Month': '12', 'Days_Past_Due': '0', 'Asset_Classification': '?'},
                {'Year': '2023', 'Month': '11', 'Days_Past_Due': '0', 'Asset_Classification': '?'},
                {'Year': '2023', 'Month': '10', 'Days_Past_Due': '0', 'Asset_Classification': '?'},
                {'Year': '2023', 'Month': '09', 'Days_Past_Due': '0', 'Asset_Classification': '?'},
                {'Year': '2023', 'Month': '08', 'Days_Past_Due': '0', 'Asset_Classification': '?'},
                {'Year': '2023', 'Month': '07', 'Days_Past_Due': '0', 'Asset_Classification': '?'},
                {'Year': '2023', 'Month': '06', 'Days_Past_Due': '0', 'Asset_Classification': '?'},
                {'Year': '2023', 'Month': '05', 'Days_Past_Due': '0', 'Asset_Classification': '?'},
                {'Year': '2023', 'Month': '04', 'Days_Past_Due': '0', 'Asset_Classification': '?'},
                {'Year': '2023', 'Month': '03', 'Days_Past_Due': '0', 'Asset_Classification': '?'},
                {'Year': '2023', 'Month': '02', 'Days_Past_Due': '0', 'Asset_Classification': '?'},
                {'Year': '2023', 'Month': '01', 'Days_Past_Due': '0', 'Asset_Classification': '?'},
                {'Year': '2022', 'Month': '12', 'Days_Past_Due': '0', 'Asset_Classification': '?'},
                {'Year': '2022', 'Month': '11', 'Days_Past_Due': '0', 'Asset_Classification': '?'},
                {'Year': '2022', 'Month': '10', 'Days_Past_Due': '0', 'Asset_Classification': '?'},
                {'Year': '2022', 'Month': '09', 'Days_Past_Due': '0', 'Asset_Classification': '?'},
                {'Year': '2022', 'Month': '08', 'Days_Past_Due': '0', 'Asset_Classification': '?'},
                {'Year': '2022', 'Month': '07', 'Days_Past_Due': '0', 'Asset_Classification': '?'},
                {'Year': '2022', 'Month': '06', 'Days_Past_Due': '0', 'Asset_Classification': '?'},
                {'Year': '2022', 'Month': '05', 'Days_Past_Due': '0', 'Asset_Classification': '?'}],
             'CAIS_Holder_Details': {'Surname_Non_Normalized': 'SONU  NIGAM', 'First_Name_Non_Normalized': None,
                                     'Middle_Name_1_Non_Normalized': None, 'Middle_Name_2_Non_Normalized': None,
                                     'Middle_Name_3_Non_Normalized': None, 'Alias': None, 'Gender_Code': '1',
                                     'Income_TAX_PAN': 'BPBPN0003F', 'Passport_Number': None, 'Voter_ID_Number': None,
                                     'Date_of_birth': '19840111'}, 'CAIS_Holder_Address_Details': {
                'First_Line_Of_Address_non_normalized': 'HATA SHIVPUR GORAKHPUR SHIVPUR SHOPUR',
                'Second_Line_Of_Address_non_normalized': '216 UTTAR PRADESH',
                'Third_Line_Of_Address_non_normalized': None, 'City_non_normalized': None,
                'Fifth_Line_Of_Address_non_normalized': None, 'State_non_normalized': '09',
                'ZIP_Postal_Code_non_normalized': '273412', 'CountryCode_non_normalized': 'IB',
                'Address_indicator_non_normalized': '02', 'Residence_code_non_normalized': None},
             'CAIS_Holder_Phone_Details': [
                 {'Telephone_Number': '8005338853', 'Telephone_Type': '02', 'Telephone_Extension': '91',
                  'Mobile_Telephone_Number': None, 'FaxNumber': None, 'EMailId': 'chauhan.cwa1987@gmail.com'},
                 {'Telephone_Number': None, 'Telephone_Type': '01', 'Telephone_Extension': None,
                  'Mobile_Telephone_Number': '8005338853', 'FaxNumber': None, 'EMailId': 'chauhan.cwa1987@gmail.com'}],
             'CAIS_Holder_ID_Details': [
                 {'Income_TAX_PAN': 'BPBPN0003F', 'PAN_Issue_Date': None, 'PAN_Expiration_Date': None,
                  'Passport_Number': None, 'Passport_Issue_Date': None, 'Passport_Expiration_Date': None,
                  'Voter_ID_Number': None, 'Voter_ID_Issue_Date': None, 'Voter_ID_Expiration_Date': None,
                  'Driver_License_Number': None, 'Driver_License_Issue_Date': None,
                  'Driver_License_Expiration_Date': None, 'Ration_Card_Number': None, 'Ration_Card_Issue_Date': None,
                  'Ration_Card_Expiration_Date': None, 'Universal_ID_Number': None, 'Universal_ID_Issue_Date': None,
                  'Universal_ID_Expiration_Date': None, 'EMailId': 'chauhan.cwa1987@gmail.com'},
                 {'Income_TAX_PAN': 'BPBPN0003F', 'PAN_Issue_Date': None, 'PAN_Expiration_Date': None,
                  'Passport_Number': None, 'Passport_Issue_Date': None, 'Passport_Expiration_Date': None,
                  'Voter_ID_Number': None, 'Voter_ID_Issue_Date': None, 'Voter_ID_Expiration_Date': None,
                  'Driver_License_Number': None, 'Driver_License_Issue_Date': None,
                  'Driver_License_Expiration_Date': None, 'Ration_Card_Number': None, 'Ration_Card_Issue_Date': None,
                  'Ration_Card_Expiration_Date': None, 'Universal_ID_Number': None, 'Universal_ID_Issue_Date': None,
                  'Universal_ID_Expiration_Date': None, 'EMailId': None},
                 {'Income_TAX_PAN': 'BPBPN0003F', 'PAN_Issue_Date': None, 'PAN_Expiration_Date': None,
                  'Passport_Number': None, 'Passport_Issue_Date': None, 'Passport_Expiration_Date': None,
                  'Voter_ID_Number': None, 'Voter_ID_Issue_Date': None, 'Voter_ID_Expiration_Date': None,
                  'Driver_License_Number': None, 'Driver_License_Issue_Date': None,
                  'Driver_License_Expiration_Date': None, 'Ration_Card_Number': None, 'Ration_Card_Issue_Date': None,
                  'Ration_Card_Expiration_Date': None, 'Universal_ID_Number': None, 'Universal_ID_Issue_Date': None,
                  'Universal_ID_Expiration_Date': None, 'EMailId': None}]},
            {'Identification_Number': 'NBFXXXXXXXX', 'Subscriber_Name': 'XXXXXXXXXX',
             'Account_Number': 'XXXXXXXXXXXXXXXX7759', 'Portfolio_Type': 'I', 'Account_Type': '13',
             'Open_Date': '20240501', 'Credit_Limit_Amount': None, 'Highest_Credit_or_Original_Loan_Amount': '46000',
             'Terms_Duration': '012', 'Terms_Frequency': 'M', 'Scheduled_Monthly_Payment_Amount': None,
             'Account_Status': '13', 'Payment_Rating': '0',
             'Payment_History_Profile': '000000000000????????????????????????', 'Special_Comment': None,
             'Current_Balance': '0', 'Amount_Past_Due': '0', 'Original_Charge_Off_Amount': None,
             'Date_Reported': '20250515', 'Date_of_First_Delinquency': None, 'Date_Closed': '20250513',
             'Date_of_Last_Payment': '20250508', 'SuitFiledWillfulDefaultWrittenOffStatus': None,
             'SuitFiled_WillfulDefault': '00', 'Written_off_Settled_Status': None, 'Value_of_Credits_Last_Month': None,
             'Occupation_Code': None, 'Settlement_Amount': None, 'Value_of_Collateral': None,
             'Type_of_Collateral': None, 'Written_Off_Amt_Total': None, 'Written_Off_Amt_Principal': None,
             'Rate_of_Interest': None, 'Repayment_Tenure': '12', 'Promotional_Rate_Flag': None, 'Income': None,
             'Income_Indicator': None, 'Income_Frequency_Indicator': None, 'DefaultStatusDate': None,
             'LitigationStatusDate': None, 'WriteOffStatusDate': None, 'DateOfAddition': '20240531',
             'CurrencyCode': 'INR', 'Subscriber_comments': None, 'Consumer_comments': None,
             'AccountHoldertypeCode': '1', 'CAIS_Account_History': [
                {'Year': '2025', 'Month': '05', 'Days_Past_Due': '0', 'Asset_Classification': '?'},
                {'Year': '2025', 'Month': '04', 'Days_Past_Due': '0', 'Asset_Classification': '?'},
                {'Year': '2025', 'Month': '03', 'Days_Past_Due': '0', 'Asset_Classification': '?'},
                {'Year': '2025', 'Month': '02', 'Days_Past_Due': '0', 'Asset_Classification': '?'},
                {'Year': '2025', 'Month': '01', 'Days_Past_Due': '0', 'Asset_Classification': '?'},
                {'Year': '2024', 'Month': '12', 'Days_Past_Due': '0', 'Asset_Classification': '?'},
                {'Year': '2024', 'Month': '11', 'Days_Past_Due': '0', 'Asset_Classification': '?'},
                {'Year': '2024', 'Month': '10', 'Days_Past_Due': '0', 'Asset_Classification': 'S'},
                {'Year': '2024', 'Month': '09', 'Days_Past_Due': '0', 'Asset_Classification': 'S'},
                {'Year': '2024', 'Month': '08', 'Days_Past_Due': '0', 'Asset_Classification': 'S'},
                {'Year': '2024', 'Month': '07', 'Days_Past_Due': '0', 'Asset_Classification': 'S'},
                {'Year': '2024', 'Month': '06', 'Days_Past_Due': '0', 'Asset_Classification': 'S'},
                {'Year': '2024', 'Month': '05', 'Days_Past_Due': '0', 'Asset_Classification': 'S'}],
             'CAIS_Holder_Details': {'Surname_Non_Normalized': 'SONU NIGAM', 'First_Name_Non_Normalized': None,
                                     'Middle_Name_1_Non_Normalized': None, 'Middle_Name_2_Non_Normalized': None,
                                     'Middle_Name_3_Non_Normalized': None, 'Alias': None, 'Gender_Code': '1',
                                     'Income_TAX_PAN': 'BPBPN0003F', 'Passport_Number': None, 'Voter_ID_Number': None,
                                     'Date_of_birth': '19840111'},
             'CAIS_Holder_Address_Details': {'First_Line_Of_Address_non_normalized': 'HATA GORAKHPUR GORAKHPUR 273412',
                                             'Second_Line_Of_Address_non_normalized': None,
                                             'Third_Line_Of_Address_non_normalized': None, 'City_non_normalized': None,
                                             'Fifth_Line_Of_Address_non_normalized': None, 'State_non_normalized': '09',
                                             'ZIP_Postal_Code_non_normalized': '273412',
                                             'CountryCode_non_normalized': 'IB',
                                             'Address_indicator_non_normalized': '04',
                                             'Residence_code_non_normalized': None},
             'CAIS_Holder_Phone_Details': {'Telephone_Number': None, 'Telephone_Type': '01',
                                           'Telephone_Extension': None, 'Mobile_Telephone_Number': '8005338853',
                                           'FaxNumber': None, 'EMailId': None},
             'CAIS_Holder_ID_Details': {'Income_TAX_PAN': 'BPBPN0003F', 'PAN_Issue_Date': None,
                                        'PAN_Expiration_Date': None, 'Passport_Number': None,
                                        'Passport_Issue_Date': None, 'Passport_Expiration_Date': None,
                                        'Voter_ID_Number': None, 'Voter_ID_Issue_Date': None,
                                        'Voter_ID_Expiration_Date': None, 'Driver_License_Number': None,
                                        'Driver_License_Issue_Date': None, 'Driver_License_Expiration_Date': None,
                                        'Ration_Card_Number': None, 'Ration_Card_Issue_Date': None,
                                        'Ration_Card_Expiration_Date': None, 'Universal_ID_Number': None,
                                        'Universal_ID_Issue_Date': None, 'Universal_ID_Expiration_Date': None,
                                        'EMailId': None}},
            {'Identification_Number': 'PVTXXXXXXXX', 'Subscriber_Name': 'XXXXXXXXXX',
             'Account_Number': 'XXXXXXXXXXXXXXX3196', 'Portfolio_Type': 'R', 'Account_Type': '10',
             'Open_Date': '20250325', 'Credit_Limit_Amount': '230000',
             'Highest_Credit_or_Original_Loan_Amount': '55000', 'Terms_Duration': None, 'Terms_Frequency': None,
             'Scheduled_Monthly_Payment_Amount': None, 'Account_Status': '11', 'Payment_Rating': '0',
             'Payment_History_Profile': '00??????????????????????????????????', 'Special_Comment': None,
             'Current_Balance': '55000', 'Amount_Past_Due': None, 'Original_Charge_Off_Amount': None,
             'Date_Reported': '20250515', 'Date_of_First_Delinquency': None, 'Date_Closed': None,
             'Date_of_Last_Payment': None, 'SuitFiledWillfulDefaultWrittenOffStatus': None,
             'SuitFiled_WillfulDefault': None, 'Written_off_Settled_Status': None, 'Value_of_Credits_Last_Month': None,
             'Occupation_Code': None, 'Settlement_Amount': None, 'Value_of_Collateral': None,
             'Type_of_Collateral': None, 'Written_Off_Amt_Total': None, 'Written_Off_Amt_Principal': None,
             'Rate_of_Interest': None, 'Repayment_Tenure': '0', 'Promotional_Rate_Flag': None, 'Income': None,
             'Income_Indicator': None, 'Income_Frequency_Indicator': None, 'DefaultStatusDate': None,
             'LitigationStatusDate': None, 'WriteOffStatusDate': None, 'DateOfAddition': '20250331',
             'CurrencyCode': 'INR', 'Subscriber_comments': None, 'Consumer_comments': None,
             'AccountHoldertypeCode': '1', 'CAIS_Account_History': [
                {'Year': '2025', 'Month': '05', 'Days_Past_Due': '0', 'Asset_Classification': 'SMA'},
                {'Year': '2025', 'Month': '04', 'Days_Past_Due': '0', 'Asset_Classification': '?'},
                {'Year': '2025', 'Month': '03', 'Days_Past_Due': '0', 'Asset_Classification': '?'}],
             'CAIS_Holder_Details': {'Surname_Non_Normalized': 'SONU NIGAM', 'First_Name_Non_Normalized': None,
                                     'Middle_Name_1_Non_Normalized': None, 'Middle_Name_2_Non_Normalized': None,
                                     'Middle_Name_3_Non_Normalized': None, 'Alias': None, 'Gender_Code': '1',
                                     'Income_TAX_PAN': 'BPBPN0003F', 'Passport_Number': None, 'Voter_ID_Number': None,
                                     'Date_of_birth': '19840111'},
             'CAIS_Holder_Address_Details': {'First_Line_Of_Address_non_normalized': 'HATA GORAKHPUR',
                                             'Second_Line_Of_Address_non_normalized': None,
                                             'Third_Line_Of_Address_non_normalized': None, 'City_non_normalized': None,
                                             'Fifth_Line_Of_Address_non_normalized': None, 'State_non_normalized': '09',
                                             'ZIP_Postal_Code_non_normalized': '273412',
                                             'CountryCode_non_normalized': 'IB',
                                             'Address_indicator_non_normalized': '02',
                                             'Residence_code_non_normalized': None},
             'CAIS_Holder_Phone_Details': {'Telephone_Number': None, 'Telephone_Type': '01',
                                           'Telephone_Extension': None, 'Mobile_Telephone_Number': '8005338853',
                                           'FaxNumber': None, 'EMailId': 'NIGAMSONUKUMAR04@GMAIL.COM'},
             'CAIS_Holder_ID_Details': {'Income_TAX_PAN': 'BPBPN0003F', 'PAN_Issue_Date': None,
                                        'PAN_Expiration_Date': None, 'Passport_Number': None,
                                        'Passport_Issue_Date': None, 'Passport_Expiration_Date': None,
                                        'Voter_ID_Number': None, 'Voter_ID_Issue_Date': None,
                                        'Voter_ID_Expiration_Date': None, 'Driver_License_Number': None,
                                        'Driver_License_Issue_Date': None, 'Driver_License_Expiration_Date': None,
                                        'Ration_Card_Number': None, 'Ration_Card_Issue_Date': None,
                                        'Ration_Card_Expiration_Date': None, 'Universal_ID_Number': None,
                                        'Universal_ID_Issue_Date': None, 'Universal_ID_Expiration_Date': None,
                                        'EMailId': 'NIGAMSONUKUMAR04@GMAIL.COM'}}]
ownership_list_mapping = {
    'Individual': "1",
    'Joint': "2",
    'Joint Account': "2",
    'Authorized User': "3",
    'Authorized user': "3",
    'Guarantor': "7",
    'Deceased': "20",
}

print(check_principal_write_off(principal_write_off_rule, accounts, 'experian', ownership_list_mapping))