Recalculte Balance Installment Amount after each Payment Entry Against Payment Term

Hi every one! Needed a help on this custom Script! It calculates the remaining amount against each payment term on a new sales order generation.

However when I make a Payment Entry and Tag it against a Payment Term, now on Viewing the Sales Order, the payment shows correctly against that Payment Term but Remaining Installment Amount won’t update.

Please guide, if I should write a script to recalculate Balance Installment Amount on each new Payment Entry against that sales order!

frappe.ui.form.on(‘Payment Schedule’, ‘payment_amount’,
function(frm, doctype, name) {
var row = locals[doctype][name];
frappe.model.set_value(doctype, name, “remaining_installment_amount”, flt(row.payment_amount) - flt(row.paid_amount));
});

frappe.ui.form.on(‘Payment Schedule’, ‘paid_amount’,
function(frm, doctype, name) {
var row = locals[doctype][name];
frappe.model.set_value(doctype, name, “remaining_installment_amount”, flt(row.payment_amount) - flt(row.paid_amount));
});

On%20Sales%20Order%20Submit

On%20Payment%20Entry

@Sarmad_Saqlain Hi there! I have been searching, and there is no way to get a report with unpaid Sales Orders.

And I got to your script. So there is nothing by default in the system to get this data?