diff --git a/erpnext/manufacturing/doctype/job_card/job_card.py b/erpnext/manufacturing/doctype/job_card/job_card.py index 90f915d9c24..1b4840d14b5 100644 --- a/erpnext/manufacturing/doctype/job_card/job_card.py +++ b/erpnext/manufacturing/doctype/job_card/job_card.py @@ -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: diff --git a/erpnext/manufacturing/doctype/job_card/test_job_card.py b/erpnext/manufacturing/doctype/job_card/test_job_card.py index 7f456b9881e..12205a80a2b 100644 --- a/erpnext/manufacturing/doctype/job_card/test_job_card.py +++ b/erpnext/manufacturing/doctype/job_card/test_job_card.py @@ -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 diff --git a/erpnext/manufacturing/doctype/work_order/work_order.js b/erpnext/manufacturing/doctype/work_order/work_order.js index 6da3d803358..df5027172ff 100644 --- a/erpnext/manufacturing/doctype/work_order/work_order.js +++ b/erpnext/manufacturing/doctype/work_order/work_order.js @@ -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); }, diff --git a/erpnext/manufacturing/doctype/work_order/work_order.py b/erpnext/manufacturing/doctype/work_order/work_order.py index 332a86979c2..e6e7d7612c5 100644 --- a/erpnext/manufacturing/doctype/work_order/work_order.py +++ b/erpnext/manufacturing/doctype/work_order/work_order.py @@ -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: