fix(UX): use doc.status for Job Card status (#31320)
fix(UX): use doc.status for JC status - Use doc.status directly for indicator - single source of truth - Update status to cancelled when doc is cancelled
This commit is contained in:
parent
3d76b1a093
commit
39ec0aca95
@ -626,6 +626,7 @@ class JobCard(Document):
|
|||||||
|
|
||||||
self.status = {0: "Open", 1: "Submitted", 2: "Cancelled"}[self.docstatus or 0]
|
self.status = {0: "Open", 1: "Submitted", 2: "Cancelled"}[self.docstatus or 0]
|
||||||
|
|
||||||
|
if self.docstatus < 2:
|
||||||
if self.for_quantity <= self.transferred_qty:
|
if self.for_quantity <= self.transferred_qty:
|
||||||
self.status = "Material Transferred"
|
self.status = "Material Transferred"
|
||||||
|
|
||||||
|
|||||||
@ -1,16 +1,17 @@
|
|||||||
frappe.listview_settings['Job Card'] = {
|
frappe.listview_settings['Job Card'] = {
|
||||||
has_indicator_for_draft: true,
|
has_indicator_for_draft: true,
|
||||||
|
|
||||||
get_indicator: function(doc) {
|
get_indicator: function(doc) {
|
||||||
if (doc.status === "Work In Progress") {
|
const status_colors = {
|
||||||
return [__("Work In Progress"), "orange", "status,=,Work In Progress"];
|
"Work In Progress": "orange",
|
||||||
} else if (doc.status === "Completed") {
|
"Completed": "green",
|
||||||
return [__("Completed"), "green", "status,=,Completed"];
|
"Cancelled": "red",
|
||||||
} else if (doc.docstatus == 2) {
|
"Material Transferred": "blue",
|
||||||
return [__("Cancelled"), "red", "status,=,Cancelled"];
|
"Open": "red",
|
||||||
} else if (doc.status === "Material Transferred") {
|
};
|
||||||
return [__('Material Transferred'), "blue", "status,=,Material Transferred"];
|
const status = doc.status || "Open";
|
||||||
} else {
|
const color = status_colors[status] || "blue";
|
||||||
return [__("Open"), "red", "status,=,Open"];
|
|
||||||
}
|
return [__(status), color, `status,=,${status}`];
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@ -344,6 +344,30 @@ class TestJobCard(FrappeTestCase):
|
|||||||
cost_after_cancel = self.work_order.total_operating_cost
|
cost_after_cancel = self.work_order.total_operating_cost
|
||||||
self.assertEqual(cost_after_cancel, original_cost)
|
self.assertEqual(cost_after_cancel, original_cost)
|
||||||
|
|
||||||
|
def test_job_card_statuses(self):
|
||||||
|
def assertStatus(status):
|
||||||
|
jc.set_status()
|
||||||
|
self.assertEqual(jc.status, status)
|
||||||
|
|
||||||
|
jc = frappe.new_doc("Job Card")
|
||||||
|
jc.for_quantity = 2
|
||||||
|
jc.transferred_qty = 1
|
||||||
|
jc.total_completed_qty = 0
|
||||||
|
assertStatus("Open")
|
||||||
|
|
||||||
|
jc.transferred_qty = jc.for_quantity
|
||||||
|
assertStatus("Material Transferred")
|
||||||
|
|
||||||
|
jc.append("time_logs", {})
|
||||||
|
assertStatus("Work In Progress")
|
||||||
|
|
||||||
|
jc.docstatus = 1
|
||||||
|
jc.total_completed_qty = jc.for_quantity
|
||||||
|
assertStatus("Completed")
|
||||||
|
|
||||||
|
jc.docstatus = 2
|
||||||
|
assertStatus("Cancelled")
|
||||||
|
|
||||||
|
|
||||||
def create_bom_with_multiple_operations():
|
def create_bom_with_multiple_operations():
|
||||||
"Create a BOM with multiple operations and Material Transfer against Job Card"
|
"Create a BOM with multiple operations and Material Transfer against Job Card"
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user