Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 19 additions & 6 deletions erpnext/manufacturing/doctype/job_card/job_card.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,13 +268,16 @@ def validate_time_logs(self, save=False):
)

if d.from_time and d.to_time:
d.time_in_mins = time_diff_in_hours(d.to_time, d.from_time) * 60
d.time_in_mins = flt(
time_diff_in_hours(d.to_time, d.from_time) * 60, d.precision("time_in_mins")
)
self.total_time_in_mins += d.time_in_mins

if d.completed_qty and not self.sub_operations:
self.total_completed_qty += d.completed_qty

self.total_completed_qty = flt(self.total_completed_qty, self.precision("total_completed_qty"))
self.total_time_in_mins = flt(self.total_time_in_mins, self.precision("total_time_in_mins"))

if save and self.docstatus == 1:
self.db_set(
Expand Down Expand Up @@ -651,17 +654,27 @@ def update_sub_operation_status(self):
if row.status != "Complete":
row.status = operation_deatils.status

row.completed_time = operation_deatils.completed_time
completed_time = flt(operation_deatils.completed_time, row.precision("completed_time"))
if operation_deatils.employee:
row.completed_time = row.completed_time / len(set(operation_deatils.employee))
completed_time = flt(
operation_deatils.completed_time / len(set(operation_deatils.employee)),
row.precision("completed_time"),
)

if operation_deatils.completed_qty:
row.completed_qty = operation_deatils.completed_qty / len(
set(operation_deatils.employee)
row.completed_qty = flt(
operation_deatils.completed_qty / len(set(operation_deatils.employee)),
row.precision("completed_qty"),
)

# Only update completed_time if value actually changed.
# completed_time is a Data (string) field, so compare as floats
if flt(row.completed_time) != completed_time:
row.completed_time = completed_time
else:
row.status = "Pending"
row.completed_time = 0.0
if flt(row.completed_time) != 0.0:
row.completed_time = 0.0
row.completed_qty = 0.0

def update_time_logs(self, row):
Expand Down