i made custom field called outstanding quantity in Purchase Order Item to calculate the different between qty and revived qty it’s working only when but value manually in outstanding filed but if recived qty update when i made receipt for PO not working
frappe.ui.form.on("Purchase Order Item", {
outstanding_quantity: function(frm, cdt, cdn) {
var row = locals[cdt][cdn];
row.outstanding_quantity = flt(row.qty) - flt(row.received_qty);
frappe.model.set_value(cdt, cdn, 'outstanding_quantity', (flt(row.qty) - flt(row.received_qty)) )
frm.refresh_field("items");
},
qty: function(frm, cdt, cdn) {
var row = locals[cdt][cdn];
row.outstanding_quantity = flt(row.qty) - flt(row.received_qty);
frappe.model.set_value(cdt, cdn, 'outstanding_quantity', (flt(row.qty) - flt(row.received_qty)) )
frm.refresh_field("items");
},
received_qty: function(frm, cdt, cdn) {
var row = locals[cdt][cdn];
row.outstanding_quantity = flt(row.qty) - flt(row.received_qty);
frappe.model.set_value(cdt, cdn, 'outstanding_quantity', (flt(row.qty) - flt(row.received_qty)) )
frm.refresh_field("items");
},
});