Validate Child Table on change of posting date in Payment Entry

Hi All, I want to validate or refresh calculation in child table “Payment Entry Deduction” when I change the posting date in Payment Entry. This is my current script.

frappe.ui.form.on(‘Payment Entry Deduction’,{

amount: function(frm, cdt, cdn) {
    var row = locals[cdt][cdn];
    var company_currency = frappe.get_doc(":Company", frm.doc.company).default_currency;

    if(row.is_unrealized_currency_translation == "1") {
        frappe.model.set_value(cdt, cdn, "exchange_rate", 0);
        frappe.model.set_value(cdt, cdn, "amount_in_account_currency", 0);
        
    } else if(company_currency == frm.doc.paid_from_account_currency) {
        frappe.model.set_value(cdt, cdn, "exchange_rate", 1);
        frappe.model.set_value(cdt, cdn, "amount_in_account_currency", row.amount);
        
    } else {
        frappe.model.set_value(cdt, cdn, "exchange_rate", frm.doc.source_exchange_rate);
        frappe.model.set_value(cdt, cdn, "amount_in_account_currency", flt(flt(row.amount) / flt(frm.doc.source_exchange_rate), -2));
        
    }  

}

});

Hi, try this

frappe.ui.form.on(‘Payment Entry’, {
validate: function(frm) {
calculation_on_deduction_table(frm);
},
});

var calculation_on_deduction_table = function(frm) {
frm.doc.payment_entry_deduction.forEach((row, i) => {
// Do your Calculation and updation with conditions
// Example
// frappe.model.set_value(row.doctype, row.name, “exchange_rate”, 0);
});
};

Hi @jamsheer thanks for this. It worked.