frappe.ui.form.on("Validation Items", {
sub_imei: function (frm, cdt, cdn) {
var d = locals[cdt][cdn];
var f = locals[cdt][cdn];
var liness = d.sub_imei.split(/\n/);
var outputvalid = [];
var outputTextvalid = [];
var outputinvalid = [];
var outputTextinvalid = [];
for (var i = 0; i < liness.length; i++) {
var caounts = 0;
$.each(frappe.model.get_list("Serial No", { parent: name }), function (h, g) {
if (g.serial_no == liness[i]) {
caounts = 1;
}
});
if (caounts == 1) {
if (/\S/.test(lines[i])) {
outputTextvalid.push(liness[i] + '\n');
outputvalid.push(liness[i].trim());
}
} else {
if (/\S/.test(lines[i])) {
outputTextinvalid.push(liness[i] + '\n');
outputinvalid.push(liness[i].trim());
}
}
}
frappe.model.set_value(f.doctype, f.name, "val_imei", outputTextvalid);
frappe.model.set_value(f.doctype, f.name, "inv_imei", outputTextinvalid);
doc.val_imei = outputTextvalid;
console.log(liness);
},
val_imei: function (frm, cdt, cdn) {
var d = locals[cdt][cdn];
var f = locals[cdt][cdn];
var total = 0;
var text = d.val_imei.trim();
var lines = text.split(/\r\n|\r|\n/).length;
frappe.model.set_value(f.doctype, f.name, "valid_imei", lines);
},
inv_imei: function (frm, cdt, cdn) {
var d = locals[cdt][cdn];
var f = locals[cdt][cdn];
var total = 0;
var text = d.inv_imei.trim();
var lines = text.split(/\r\n|\r|\n/).length;
frappe.model.set_value(f.doctype, f.name, "invalid_imei", lines);
},
amount_per_unit: function (frm, cdt, cdn) {
var d = locals[cdt][cdn];
var f = locals[cdt][cdn];
var total = 0;
frappe.model.set_value(f.doctype, f.name, "total_amount", d.valid_imei * d.amount_per_unit);
frm.doc.validation_details.forEach(function (d) { total += d.total_amount; });
frm.set_value("rebate_amount", total);
refresh_field("rebate_amount");
},
valid_imei: function (frm, cdt, cdn) {
var d = locals[cdt][cdn];
var f = locals[cdt][cdn];
var total = 0;
frappe.model.set_value(f.doctype, f.name, "total_amount", d.valid_imei * d.amount_per_unit);
frm.doc.validation_details.forEach(function (d) { total += d.total_amount; });
frm.set_value("rebate_amount", total);
refresh_field("rebate_amount");
},
validation_details: function (frm, cdt, cdn) {
var d = locals[cdt][cdn];
var total = 0;
frappe.model.set_value(f.doctype, f.name, "total_amount", d.valid_imei * d.amount_per_unit);
frm.doc.validation_details.forEach(function (d) { total += d.total_amount; });
frm.set_value("rebate_amount", total);
refresh_field("rebate_amount");
}
});
Someone can help me with sub_imei function?