Hi,
I have a new doctype “PNPA Sales” and is submittable, a child table “Lot Payment Reference”, I have set the child table to be modifiable even if the document is already submitted by checking the “allow on submit” and Perm to 1. I have tried this code:
frappe.ui.form.on(‘Lot Payment Reference’, {
validate: function(frm, cdt, cdn) {
var childTable = locals[cdt][cdn];
// Calculate the difference between parent account_balance and child amount_paid
var accountBalance = frm.doc.account_balance - childTable.amount_paid;
// Calculate the new total_paid_amount by adding the child amount_paid
var totalPaidAmount = frm.doc.total_paid_amount + childTable.amount_paid;
// Update the parent document fields
frappe.model.set_value(frm.doctype, frm.docname, 'account_balance', accountBalance);
frappe.model.set_value(frm.doctype, frm.docname, 'total_paid_amount', totalPaidAmount);
}
});
but still not updating the parent field “total_amount_paid” and “account_balance”, can somebody help me here modify my code or suggest a new client script for this behavior? Thanks in advance.
Ed