mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-29 09:54:47 +00:00
workstation and operation time made editable in production order. Cost recalculation logic added
This commit is contained in:
@@ -176,7 +176,47 @@ cur_frm.set_query("bom_no", function(doc) {
|
|||||||
} else msgprint(__("Please enter Production Item first"));
|
} 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)
|
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))
|
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)
|
||||||
|
});
|
||||||
@@ -117,7 +117,7 @@
|
|||||||
"permlevel": 0,
|
"permlevel": 0,
|
||||||
"precision": "",
|
"precision": "",
|
||||||
"print_hide": 0,
|
"print_hide": 0,
|
||||||
"read_only": 1,
|
"read_only": 0,
|
||||||
"report_hide": 0,
|
"report_hide": 0,
|
||||||
"reqd": 0,
|
"reqd": 0,
|
||||||
"search_index": 0,
|
"search_index": 0,
|
||||||
@@ -173,7 +173,7 @@
|
|||||||
"permlevel": 0,
|
"permlevel": 0,
|
||||||
"precision": "",
|
"precision": "",
|
||||||
"print_hide": 0,
|
"print_hide": 0,
|
||||||
"read_only": 1,
|
"read_only": 0,
|
||||||
"report_hide": 0,
|
"report_hide": 0,
|
||||||
"reqd": 0,
|
"reqd": 0,
|
||||||
"search_index": 0,
|
"search_index": 0,
|
||||||
@@ -282,7 +282,7 @@
|
|||||||
"is_submittable": 0,
|
"is_submittable": 0,
|
||||||
"issingle": 0,
|
"issingle": 0,
|
||||||
"istable": 1,
|
"istable": 1,
|
||||||
"modified": "2014-12-23 15:42:34.892964",
|
"modified": "2015-02-13 16:26:30.441657",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Manufacturing",
|
"module": "Manufacturing",
|
||||||
"name": "Production Order Operation",
|
"name": "Production Order Operation",
|
||||||
|
|||||||
Reference in New Issue
Block a user