Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: better overlap logic for job card (backport #38432) #38522

Merged
Merged
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
23 changes: 12 additions & 11 deletions erpnext/manufacturing/doctype/job_card/job_card.py
Original file line number Diff line number Diff line change
Expand Up @@ -261,8 +261,7 @@ def get_overlap_for(self, args, check_next_available_slot=False):
# override capacity for employee
production_capacity = 1

overlap_count = self.get_overlap_count(time_logs)
if time_logs and production_capacity > overlap_count:
if not self.has_overlap(production_capacity, time_logs):
return {}

if self.workstation_type and time_logs:
Expand All @@ -272,16 +271,15 @@ def get_overlap_for(self, args, check_next_available_slot=False):

return time_logs[-1]

@staticmethod
def get_overlap_count(time_logs):
count = 1
def has_overlap(self, production_capacity, time_logs):
overlap = False
if production_capacity == 1 and len(time_logs) > 0:
return True

# Check overlap exists or not between the overlapping time logs with the current Job Card
for idx, row in enumerate(time_logs):
next_idx = idx
if idx + 1 < len(time_logs):
next_idx = idx + 1
next_row = time_logs[next_idx]
for row in time_logs:
count = 1
for next_row in time_logs:
if row.name == next_row.name:
continue

Expand All @@ -301,7 +299,10 @@ def get_overlap_count(time_logs):
):
count += 1

return count
if count > production_capacity:
return True

return overlap

def get_time_logs(self, args, doctype, check_next_available_slot=False):
jc = frappe.qb.DocType("Job Card")
Expand Down
Loading