mirror of
https://github.com/frappe/erpnext.git
synced 2026-08-15 15:38:39 +00:00
fix: add partially transferred status and fix button visibility for partial material transfer on job card
This commit is contained in:
@@ -72,8 +72,9 @@ frappe.ui.form.on("Job Card", {
|
|||||||
frm.toggle_enable("for_quantity", !has_stock_entry);
|
frm.toggle_enable("for_quantity", !has_stock_entry);
|
||||||
|
|
||||||
if (!frm.is_new() && has_items && frm.doc.docstatus < 2) {
|
if (!frm.is_new() && has_items && frm.doc.docstatus < 2) {
|
||||||
let to_request = frm.doc.for_quantity > frm.doc.transferred_qty;
|
const excess_transfer_allowed = frm.doc.__onload.job_card_excess_transfer;
|
||||||
let excess_transfer_allowed = frm.doc.__onload.job_card_excess_transfer;
|
const to_transfer = frm.doc.items.some((row) => flt(row.transferred_qty) < flt(row.required_qty));
|
||||||
|
const to_request = to_transfer;
|
||||||
|
|
||||||
if (to_request || excess_transfer_allowed) {
|
if (to_request || excess_transfer_allowed) {
|
||||||
frm.add_custom_button(
|
frm.add_custom_button(
|
||||||
@@ -85,10 +86,6 @@ frappe.ui.form.on("Job Card", {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// check if any row has untransferred materials
|
|
||||||
// in case of multiple items in JC
|
|
||||||
let to_transfer = frm.doc.items.some((row) => row.transferred_qty < row.required_qty);
|
|
||||||
|
|
||||||
if (to_transfer || excess_transfer_allowed) {
|
if (to_transfer || excess_transfer_allowed) {
|
||||||
frm.add_custom_button(
|
frm.add_custom_button(
|
||||||
__("Material Transfer"),
|
__("Material Transfer"),
|
||||||
@@ -120,7 +117,8 @@ frappe.ui.form.on("Job Card", {
|
|||||||
frm.doc.docstatus == 0 &&
|
frm.doc.docstatus == 0 &&
|
||||||
!frm.is_new() &&
|
!frm.is_new() &&
|
||||||
(frm.doc.for_quantity > frm.doc.total_completed_qty || !frm.doc.for_quantity) &&
|
(frm.doc.for_quantity > frm.doc.total_completed_qty || !frm.doc.for_quantity) &&
|
||||||
(frm.doc.items || !frm.doc.items.length || frm.doc.for_quantity == frm.doc.transferred_qty)
|
(!frm.doc.items.length ||
|
||||||
|
!frm.doc.items.some((row) => flt(row.transferred_qty) < flt(row.required_qty)))
|
||||||
) {
|
) {
|
||||||
// if Job Card is link to Work Order, the job card must not be able to start if Work Order not "Started"
|
// if Job Card is link to Work Order, the job card must not be able to start if Work Order not "Started"
|
||||||
// and if stock mvt for WIP is required
|
// and if stock mvt for WIP is required
|
||||||
|
|||||||
@@ -234,7 +234,7 @@
|
|||||||
"fieldtype": "Select",
|
"fieldtype": "Select",
|
||||||
"label": "Status",
|
"label": "Status",
|
||||||
"no_copy": 1,
|
"no_copy": 1,
|
||||||
"options": "Open\nWork In Progress\nMaterial Transferred\nOn Hold\nSubmitted\nCancelled\nCompleted",
|
"options": "Open\nWork In Progress\nPartially Transferred\nMaterial Transferred\nOn Hold\nSubmitted\nCancelled\nCompleted",
|
||||||
"read_only": 1
|
"read_only": 1
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -513,7 +513,7 @@
|
|||||||
],
|
],
|
||||||
"is_submittable": 1,
|
"is_submittable": 1,
|
||||||
"links": [],
|
"links": [],
|
||||||
"modified": "2026-05-12 12:17:17.750857",
|
"modified": "2026-06-22 11:51:16.526778",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Manufacturing",
|
"module": "Manufacturing",
|
||||||
"name": "Job Card",
|
"name": "Job Card",
|
||||||
|
|||||||
@@ -107,6 +107,7 @@ class JobCard(Document):
|
|||||||
status: DF.Literal[
|
status: DF.Literal[
|
||||||
"Open",
|
"Open",
|
||||||
"Work In Progress",
|
"Work In Progress",
|
||||||
|
"Partially Transferred",
|
||||||
"Material Transferred",
|
"Material Transferred",
|
||||||
"On Hold",
|
"On Hold",
|
||||||
"Submitted",
|
"Submitted",
|
||||||
@@ -927,6 +928,8 @@ class JobCard(Document):
|
|||||||
|
|
||||||
frappe.db.set_value("Job Card Item", row.job_card_item, "transferred_qty", flt(transferred_qty))
|
frappe.db.set_value("Job Card Item", row.job_card_item, "transferred_qty", flt(transferred_qty))
|
||||||
|
|
||||||
|
self.set_status(update_status=True)
|
||||||
|
|
||||||
def set_transferred_qty(self, update_status=False):
|
def set_transferred_qty(self, update_status=False):
|
||||||
"Set total FG Qty in Job Card for which RM was transferred."
|
"Set total FG Qty in Job Card for which RM was transferred."
|
||||||
if not self.items:
|
if not self.items:
|
||||||
@@ -980,7 +983,22 @@ 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.docstatus < 2:
|
||||||
if flt(self.for_quantity) <= flt(self.transferred_qty):
|
if self.items:
|
||||||
|
item_data = frappe.get_all(
|
||||||
|
"Job Card Item",
|
||||||
|
filters={"parent": self.name},
|
||||||
|
fields=["transferred_qty", "required_qty"],
|
||||||
|
)
|
||||||
|
all_transferred = item_data and all(
|
||||||
|
flt(d.transferred_qty) >= flt(d.required_qty) for d in item_data
|
||||||
|
)
|
||||||
|
any_transferred = any(flt(d.transferred_qty) > 0 for d in item_data)
|
||||||
|
|
||||||
|
if all_transferred:
|
||||||
|
self.status = "Material Transferred"
|
||||||
|
elif any_transferred:
|
||||||
|
self.status = "Partially Transferred"
|
||||||
|
elif flt(self.for_quantity) <= flt(self.transferred_qty):
|
||||||
self.status = "Material Transferred"
|
self.status = "Material Transferred"
|
||||||
|
|
||||||
if self.time_logs:
|
if self.time_logs:
|
||||||
@@ -1224,12 +1242,13 @@ def time_diff_in_minutes(string_ed_date, string_st_date):
|
|||||||
|
|
||||||
|
|
||||||
@frappe.whitelist()
|
@frappe.whitelist()
|
||||||
def get_job_details(start, end, filters=None):
|
def get_job_details(start: str, end: str, filters: str | None = None):
|
||||||
events = []
|
events = []
|
||||||
|
|
||||||
event_color = {
|
event_color = {
|
||||||
"Completed": "#cdf5a6",
|
"Completed": "#cdf5a6",
|
||||||
"Material Transferred": "#ffdd9e",
|
"Material Transferred": "#ffdd9e",
|
||||||
|
"Partially Transferred": "#ffe5b4",
|
||||||
"Work In Progress": "#D3D3D3",
|
"Work In Progress": "#D3D3D3",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ frappe.listview_settings["Job Card"] = {
|
|||||||
Completed: "green",
|
Completed: "green",
|
||||||
Cancelled: "red",
|
Cancelled: "red",
|
||||||
"Material Transferred": "blue",
|
"Material Transferred": "blue",
|
||||||
|
"Partially Transferred": "yellow",
|
||||||
Open: "red",
|
Open: "red",
|
||||||
};
|
};
|
||||||
const status = doc.status || "Open";
|
const status = doc.status || "Open";
|
||||||
|
|||||||
Reference in New Issue
Block a user