Percentage remaining calculation

i have work plan template,
accomplished target(work completed)percentage and remaining target (work remaining)percentage field in work plan.

so, when i enter work completed percentage, it should reduce the work remaining percentage .

this table is from child.

i used below code, but now working.

var calculate_remaining_target = function(doc, dt,dn){
doc.remaining_target = flt(doc.per_weightage) - flt(doc.accomplished_target);
refresh_many(‘remaining_target’);
}