frappe.ui.form.on(‘POS Invoice’, {
refresh(frm) {
// your code here
}
})
frappe.ui.form.on(‘POS Invoice Item’, {
previous_reading: function(frm, cdt, cdn) {
calculateQuantity(frm, cdt, cdn);
},
current_reading: function(frm, cdt, cdn) {
calculateQuantit(frm, cdt, cdn);
}
});
function calculateQuantit(frm, cdt, cdn) {
var doc = locals[cdt][cdn];
var previous_reading = doc.previous_reading;
var current_reading = doc.current_reading;
if (previous_reading && current_reading) {
var difference = current_reading - previous_reading;
frappe.model.set_value(cdt, cdn, 'qty', difference);
}
}
هل هذا صحيح لم يتنفذ عندي