workstation and operation time made editable in production order. Cost recalculation logic added

This commit is contained in:
Neil Trini Lasrado 2015-02-16 15:10:29 +05:30
parent 7a64cb2aa5
commit f120aec9c2
2 changed files with 45 additions and 5 deletions

View File

@ -176,7 +176,47 @@ cur_frm.set_query("bom_no", function(doc) {
} else msgprint(__("Please enter Production Item first"));
});
frappe.ui.form.on("Production Order", "additional_operating_cost", function(frm) {
var calculate_total_cost = function(frm) {
var variable_cost = frm.doc.actual_operating_cost ? flt(frm.doc.actual_operating_cost) : flt(frm.doc.planned_operating_cost)
frm.set_value("total_operating_cost", (flt(frm.doc.additional_operating_cost) + variable_cost))
})
}
frappe.ui.form.on("Production Order", "additional_operating_cost", function(frm) {
calculate_total_cost(frm);
});
frappe.ui.form.on("Production Order Operation", "workstation", function(frm, cdt, cdn) {
var d = locals[cdt][cdn];
frappe.call({
"method": "frappe.client.get",
args: {
doctype: "Workstation",
name: d.workstation
},
callback: function (data) {
frappe.model.set_value(d.doctype, d.name, "hour_rate", data.message.hour_rate);
calculate_cost(frm.doc);
calculate_total_cost(frm);
}
})
});
var calculate_cost = function(doc) {
if (doc.operations){
var op = doc.operations;
doc.planned_operating_cost = 0.0;
for(var i=0;i<op.length;i++) {
planned_operating_cost = flt(flt(op[i].hour_rate) * flt(op[i].time_in_mins) / 60, 2);
frappe.model.set_value('Production Order Operation',op[i].name, "planned_operating_cost", planned_operating_cost);
doc.planned_operating_cost += planned_operating_cost;
}
refresh_field('planned_operating_cost');
}
}
frappe.ui.form.on("Production Order Operation", "time_in_mins", function(frm, cdt, cdn) {
calculate_cost(frm.doc);
calculate_total_cost(frm)
});

View File

@ -117,7 +117,7 @@
"permlevel": 0,
"precision": "",
"print_hide": 0,
"read_only": 1,
"read_only": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
@ -173,7 +173,7 @@
"permlevel": 0,
"precision": "",
"print_hide": 0,
"read_only": 1,
"read_only": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
@ -282,7 +282,7 @@
"is_submittable": 0,
"issingle": 0,
"istable": 1,
"modified": "2014-12-23 15:42:34.892964",
"modified": "2015-02-13 16:26:30.441657",
"modified_by": "Administrator",
"module": "Manufacturing",
"name": "Production Order Operation",