I might not properly understand it well enough but I think the payment entry/receipting needs to be simplified in ERPNext. The current Advanced Payment use case doesn’t properly apply for part-payment by clients. The Payment Entry should have an Amount Due field which is accurate when the payment is submitted, Or Outstanding amount should deduct the just Allocated amount. Maybe a topic for another day.
I’ve converted the Payment Entry print format into a Payment Receipt. For part payment, I need to have the actual Outstanding amount after payment allocation:
Actual Outstanding = Outstanding - Allocated.
I’ve been toiling with scripts for over 24hrs and all I get is a blank field in the Payment Entry Doc Type. I can manually set it, but I need it to automatically update so that users dont make errors.
I’ll appreciate the help.
heres my script:
//update custom Outstanding currency type field within Payment Entry DocType
frappe.ui.form.on("Payment Entry", "validate", function(frm) {
$.each(frm.doc.references || [], function(i, d) {
// calculate using PE references table fields
frm.doc.Outstanding= d.outstanding - d.allocated;
});
});
I’m really not sure here, please help
Add a custom field to Payment Entry called Outstanding Amount
Then this client script:
//calculating a new outstanding amount as paid amount is entered.
//The old outstanding amount is pulled from the Payment Entry References (child) table.
frappe.ui.form.on("Payment Entry",{
validate: function(frm) {
var outstanding = 0;
var tot_outstanding = 0;
// add table's outstanding values
$.each(frm.doc.references, function(index, row){
tot_outstanding += row.outstanding_amount;
});
outstanding = tot_outstanding - frm.doc.paid_amount; //subtract paid amount
frm.set_value("outstanding_amount", outstanding);
}
});