fix: consider process_loss_qty in work order
(cherry picked from commit 95fda47b6c)
This commit is contained in:
@@ -982,7 +982,9 @@ class JobCard(Document):
|
||||
if self.time_logs:
|
||||
self.status = "Work In Progress"
|
||||
|
||||
if self.docstatus == 1 and (self.for_quantity <= self.total_completed_qty or not self.items):
|
||||
if self.docstatus == 1 and (
|
||||
self.for_quantity <= (self.total_completed_qty + self.process_loss_qty) or not self.items
|
||||
):
|
||||
self.status = "Completed"
|
||||
|
||||
if update_status:
|
||||
|
||||
@@ -516,6 +516,7 @@ class TestJobCard(FrappeTestCase):
|
||||
self.assertEqual(jc.status, status)
|
||||
|
||||
jc = frappe.new_doc("Job Card")
|
||||
jc.process_loss_qty = 0
|
||||
jc.for_quantity = 2
|
||||
jc.transferred_qty = 1
|
||||
jc.total_completed_qty = 0
|
||||
|
||||
@@ -397,7 +397,10 @@ frappe.ui.form.on("Work Order", {
|
||||
message = title;
|
||||
// pending qty
|
||||
if (!frm.doc.skip_transfer) {
|
||||
var pending_complete = frm.doc.material_transferred_for_manufacturing - frm.doc.produced_qty;
|
||||
var pending_complete =
|
||||
frm.doc.material_transferred_for_manufacturing -
|
||||
frm.doc.produced_qty -
|
||||
frm.doc.process_loss_qty;
|
||||
if (pending_complete) {
|
||||
var width = (pending_complete / frm.doc.qty) * 100 - added_min;
|
||||
title = __("{0} items in progress", [pending_complete]);
|
||||
@@ -409,6 +412,16 @@ frappe.ui.form.on("Work Order", {
|
||||
message = message + ". " + title;
|
||||
}
|
||||
}
|
||||
if (frm.doc.process_loss_qty) {
|
||||
var process_loss_width = (frm.doc.process_loss_qty / frm.doc.qty) * 100;
|
||||
title = __("{0} items lost during process.", [frm.doc.process_loss_qty]);
|
||||
bars.push({
|
||||
title: title,
|
||||
width: process_loss_width + "%",
|
||||
progress_class: "progress-bar-danger",
|
||||
});
|
||||
message = message + ". " + title;
|
||||
}
|
||||
frm.dashboard.add_progress(__("Status"), bars, message);
|
||||
},
|
||||
|
||||
|
||||
@@ -1519,7 +1519,9 @@ def close_work_order(work_order, status):
|
||||
work_order = frappe.get_doc("Work Order", work_order)
|
||||
if work_order.get("operations"):
|
||||
job_cards = frappe.get_list(
|
||||
"Job Card", filters={"work_order": work_order.name, "status": "Work In Progress"}, pluck="name"
|
||||
"Job Card",
|
||||
filters={"work_order": work_order.name, "status": "Work In Progress", "docstatus": 1},
|
||||
pluck="name",
|
||||
)
|
||||
|
||||
if job_cards:
|
||||
|
||||
Reference in New Issue
Block a user