Fix: Precision in Appraisals (#17673)
* Update appraisal.js This fixes issues associated with 2 decimal places. Example: 4 questions (Each weighted 25%), will give a total result of 5.2 (If 5 achieved on every question). This is because 5*0.25 = 1.25 which is rounded to 1.3 for precision=2. When precision = 3, this is not an issue. * fix: score based on field's precisin
This commit is contained in:
parent
5f2afb8803
commit
a8f6938556
@ -9,11 +9,13 @@ frappe.ui.form.on('Appraisal', {
|
|||||||
return{ query: "erpnext.controllers.queries.employee_query" }
|
return{ query: "erpnext.controllers.queries.employee_query" }
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
onload: function(frm) {
|
onload: function(frm) {
|
||||||
if(!frm.doc.status) {
|
if(!frm.doc.status) {
|
||||||
frm.set_value('status', 'Draft');
|
frm.set_value('status', 'Draft');
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
kra_template: function(frm) {
|
kra_template: function(frm) {
|
||||||
frm.doc.goals = [];
|
frm.doc.goals = [];
|
||||||
erpnext.utils.map_current_doc({
|
erpnext.utils.map_current_doc({
|
||||||
@ -22,6 +24,7 @@ frappe.ui.form.on('Appraisal', {
|
|||||||
frm: frm
|
frm: frm
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
calculate_total: function(frm) {
|
calculate_total: function(frm) {
|
||||||
let goals = frm.doc.goals || [];
|
let goals = frm.doc.goals || [];
|
||||||
let total =0;
|
let total =0;
|
||||||
@ -35,20 +38,17 @@ frappe.ui.form.on('Appraisal', {
|
|||||||
frappe.ui.form.on('Appraisal Goal', {
|
frappe.ui.form.on('Appraisal Goal', {
|
||||||
score: function(frm, cdt, cdn) {
|
score: function(frm, cdt, cdn) {
|
||||||
var d = locals[cdt][cdn];
|
var d = locals[cdt][cdn];
|
||||||
if (d.score){
|
if (d.score) {
|
||||||
if (flt(d.score) > 5) {
|
if (flt(d.score) > 5) {
|
||||||
frappe.msgprint(__("Score must be less than or equal to 5"));
|
frappe.msgprint(__("Score must be less than or equal to 5"));
|
||||||
d.score = 0;
|
d.score = 0;
|
||||||
refresh_field('score', d.name, 'goals');
|
refresh_field('score', d.name, 'goals');
|
||||||
}
|
}
|
||||||
var total = flt(d.per_weightage*d.score)/100;
|
d.score_earned = flt(d.per_weightage*d.score, precision("score_earned", d))/100;
|
||||||
d.score_earned = total.toPrecision(2);
|
} else {
|
||||||
refresh_field('score_earned', d.name, 'goals');
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
d.score_earned = 0;
|
d.score_earned = 0;
|
||||||
refresh_field('score_earned', d.name, 'goals');
|
|
||||||
}
|
}
|
||||||
|
refresh_field('score_earned', d.name, 'goals');
|
||||||
frm.trigger('calculate_total');
|
frm.trigger('calculate_total');
|
||||||
}
|
}
|
||||||
});
|
});
|
Loading…
x
Reference in New Issue
Block a user