fix: work order operation completed qty
This commit is contained in:
parent
5210761e57
commit
6e95d248e3
@ -206,30 +206,31 @@ class JobCard(Document):
|
||||
for_quantity, time_in_mins = 0, 0
|
||||
from_time_list, to_time_list = [], []
|
||||
|
||||
|
||||
field = "operation_id" if self.operation_id else "operation"
|
||||
data = frappe.get_all('Job Card',
|
||||
fields = ["sum(total_time_in_mins) as time_in_mins", "sum(total_completed_qty) as completed_qty"],
|
||||
filters = {"docstatus": 1, "work_order": self.work_order,
|
||||
"workstation": self.workstation, "operation": self.operation})
|
||||
"workstation": self.workstation, field: self.get(field)})
|
||||
|
||||
if data and len(data) > 0:
|
||||
for_quantity = data[0].completed_qty
|
||||
time_in_mins = data[0].time_in_mins
|
||||
|
||||
if for_quantity:
|
||||
if self.get(field):
|
||||
time_data = frappe.db.sql("""
|
||||
SELECT
|
||||
min(from_time) as start_time, max(to_time) as end_time
|
||||
FROM `tabJob Card` jc, `tabJob Card Time Log` jctl
|
||||
WHERE
|
||||
jctl.parent = jc.name and jc.work_order = %s
|
||||
and jc.workstation = %s and jc.operation = %s and jc.docstatus = 1
|
||||
""", (self.work_order, self.workstation, self.operation), as_dict=1)
|
||||
and jc.workstation = %s and jc.{0} = %s and jc.docstatus = 1
|
||||
""".format(field), (self.work_order, self.workstation, self.get(field)), as_dict=1)
|
||||
|
||||
wo = frappe.get_doc('Work Order', self.work_order)
|
||||
|
||||
work_order_field = "name" if field == "operation_id" else field
|
||||
for data in wo.operations:
|
||||
if data.workstation == self.workstation and data.operation == self.operation:
|
||||
if data.get(work_order_field) == self.get(field) and data.workstation == self.workstation:
|
||||
data.completed_qty = for_quantity
|
||||
data.actual_operation_time = time_in_mins
|
||||
data.actual_start_time = time_data[0].start_time if time_data else None
|
||||
|
Loading…
Reference in New Issue
Block a user