I cannot get data from child table

Hi all;
I created new doctypes Payroll Loan with a child Payroll Loan Details(employee, pay_period,instalment_amount,paid_amount). I am trying to get through a server script the instalment_amount with no success. This is the script i wrote:

for e in doc.employees: 
    filters = {'start_date' : doc.start_date, 'end_date': doc.end_date}
    pay_period = frappe.get_list('Payroll Period', fields=["*"], filters = filters)[0].name
    
    filters2 = {'employee': e.employee,'pay_period' : pay_period}
    
    data = frappe.db.get_value('Payroll Loan Details',{'employee': e.employee,'pay_period' : pay_period}, ['instalment_amount', 'employee'], as_dict=1)
    
    frappe.msgprint(data.instalment_amount)

I cannot figure out what i am doing wrong. Can someone help me out?
Thanks

@Amouzou_Kossivi_Dodz
we had a similar requirement of getting child table rows from another doctype, below is the code snippet, which may probably help in your case too, by modifying fieldnames and all as per you requirements -

frappe.ui.form.on("Goals setting for Employees",

{

    name1: function (frm)

    {

        cur_frm.clear_table("goals")

        if(frm.doc.designation)

        {

            frappe.call(

            {

                method: "frappe.client.get",

                args:

                {

                    doctype: "Designation",

                    name: frm.doc.designation,

                },

            callback(r)

            {

                if(r.message)

                {

                    var task = r.message;

                    for(var i=0;i<task.goals.length;i++)

                    {

                        var tempObj = task.goals[i];

                       

                        var child = cur_frm.add_child("goals");

                        frappe.model.set_value(child.doctype, child.name, "goal", tempObj.goal)

                    }

                                 

                cur_frm.refresh_field("goals")

                }

              }

              });

        }                    

    },

});

Thanks [murtaza_bk] Finally I got it done. What i have noticed is that you need to convert any number to string before assignement to a field. Therefore:

for e in doc.employees: 
    filters = {'start_date' : doc.start_date, 'end_date': doc.end_date}
    pay_period = frappe.get_list('Payroll Period', fields=["*"], filters = filters)[0].name
    
    filters = {'employee': e.employee,'pay_period' : pay_period}
    
    data = frappe.db.get_value('Payroll Loan Details',{'employee': e.employee,'pay_period' : pay_period}, ['instalment_amount', 'employee'], as_dict=1)
    frappe.msgprint(str(data.instalment_amount))

Thanks all