mirror of
https://github.com/frappe/erpnext.git
synced 2026-08-15 07:28:39 +00:00
fix: add partially transferred status and fix button visibility for partial material transfer on job card
This commit is contained in:
@@ -207,7 +207,9 @@ frappe.ui.form.on("Job Card", {
|
|||||||
if (frm.is_new() || doc.skip_material_transfer || doc.docstatus >= 2) return;
|
if (frm.is_new() || doc.skip_material_transfer || doc.docstatus >= 2) return;
|
||||||
|
|
||||||
const excess_transfer_allowed = doc.__onload.job_card_excess_transfer;
|
const excess_transfer_allowed = doc.__onload.job_card_excess_transfer;
|
||||||
const to_request = doc.for_quantity > doc.transferred_qty;
|
const to_transfer =
|
||||||
|
has_items && doc.items.some((row) => flt(row.transferred_qty) < flt(row.required_qty));
|
||||||
|
const to_request = to_transfer;
|
||||||
|
|
||||||
if (has_items && (to_request || excess_transfer_allowed)) {
|
if (has_items && (to_request || excess_transfer_allowed)) {
|
||||||
frm.add_custom_button(
|
frm.add_custom_button(
|
||||||
@@ -217,9 +219,6 @@ frappe.ui.form.on("Job Card", {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// check if any row has untransferred materials in case of multiple items in JC
|
|
||||||
const to_transfer = doc.items.some((row) => row.transferred_qty < row.required_qty);
|
|
||||||
|
|
||||||
if (has_items && (to_transfer || excess_transfer_allowed)) {
|
if (has_items && (to_transfer || excess_transfer_allowed)) {
|
||||||
frm.add_custom_button(
|
frm.add_custom_button(
|
||||||
__("Material Transfer"),
|
__("Material Transfer"),
|
||||||
@@ -586,11 +585,10 @@ frappe.ui.form.on("Job Card", {
|
|||||||
|
|
||||||
// ── Determine which action buttons to show ────────────────────────
|
// ── Determine which action buttons to show ────────────────────────
|
||||||
const has_remaining_qty = doc.for_quantity + doc.process_loss_qty > doc.total_completed_qty;
|
const has_remaining_qty = doc.for_quantity + doc.process_loss_qty > doc.total_completed_qty;
|
||||||
|
const pending_transfer =
|
||||||
|
has_items && doc.items.some((row) => flt(row.transferred_qty) < flt(row.required_qty));
|
||||||
const materials_ready =
|
const materials_ready =
|
||||||
doc.skip_material_transfer ||
|
doc.skip_material_transfer || !pending_transfer || !doc.finished_good || !has_items;
|
||||||
doc.transferred_qty >= doc.for_quantity + doc.process_loss_qty ||
|
|
||||||
!doc.finished_good ||
|
|
||||||
!has_items?.length;
|
|
||||||
|
|
||||||
let last_row = {};
|
let last_row = {};
|
||||||
const has_sub_ops_or_pending_qty = doc.sub_operations?.length || doc.pending_qty > 0;
|
const has_sub_ops_or_pending_qty = doc.sub_operations?.length || doc.pending_qty > 0;
|
||||||
|
|||||||
@@ -272,7 +272,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
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -695,7 +695,7 @@
|
|||||||
"grid_page_length": 50,
|
"grid_page_length": 50,
|
||||||
"is_submittable": 1,
|
"is_submittable": 1,
|
||||||
"links": [],
|
"links": [],
|
||||||
"modified": "2026-05-21 18:37:05.688342",
|
"modified": "2026-06-19 17:39:42.293242",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Manufacturing",
|
"module": "Manufacturing",
|
||||||
"name": "Job Card",
|
"name": "Job Card",
|
||||||
|
|||||||
@@ -123,6 +123,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",
|
||||||
@@ -1168,6 +1169,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):
|
||||||
from frappe.query_builder.functions import Sum
|
from frappe.query_builder.functions import Sum
|
||||||
|
|
||||||
@@ -1229,7 +1232,22 @@ class JobCard(Document):
|
|||||||
self.status = "Work In Progress"
|
self.status = "Work In Progress"
|
||||||
|
|
||||||
if not self.track_semi_finished_goods and self.docstatus < 2:
|
if not self.track_semi_finished_goods and 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:
|
||||||
@@ -1774,12 +1792,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