Skip to content

Commit

Permalink
Bug Fix
Browse files Browse the repository at this point in the history
Version Using : 14.47.4
Bug found: False Job card overlap error.
Details: Consider the example below.
A job card with time log 2023-11-22 10:25:00 to 2023-11-22 11:40:00 is throwing error while saving. So as per the existing algorithm for job cards I found below time logs which are overlapping

    2023-11-22 10:20:00 to 2023-11-22 10:30:00
    2023-11-22 10:30:00 to 2023-11-22 10:40:00
    2023-11-22 10:40:00 to 2023-11-22 10:45:00
    2023-11-22 10:45:00 to 2023-11-22 11:00:00 and Production capacity is 3.
    Now if you observe closely only 1 job card is active at any instance of time. so technically all these 4 job cards we can grouped as single set (for overlapping findings not in real) and can have more job cards as we have capacity 3.

So we can see here that at any instance of time from 10:25:00 to 11:00:00 you will find only 2 Job cards running including (the Job card which I am trying save). And as the capacity is 3 this job card must be saved and should not throw any overlapping error.

So the changes we made as below:
we reach to the comparison point as per the previous algorithm and then we have introduced a new layer for finding set of job cards which are not overlapping(sequential). Considering those group job cards as single overlapping set for other job cards so comparison will be correct in this case.
  • Loading branch information
VihangT authored Nov 25, 2023
1 parent 3c6ee05 commit a1636bc
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions erpnext/manufacturing/doctype/job_card/job_card.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ def get_overlap_for(self, args, check_next_available_slot=False):
if existing and production_capacity > len(existing):
return
else:
existing = sorted(existing,key = lambda x : x.get('from_time'))
existing = sorted(existing,key = lambda x : x.get("from_time"))
sequentialjc_list = [[]]
temp = existing.copy()
while len(temp) > 0:
Expand All @@ -230,18 +230,18 @@ def get_overlap_for(self, args, check_next_available_slot=False):
return existing[0] if existing else None

def groupingjc(temp):
seqtemp = [temp[0]['name']]
to_time1 = temp[0]['to_time']
seqtemp = [temp[0]["name"]]
to_time1 = temp[0]["to_time"]
remove_list = [0]
for i in range(1,len(temp)):
if to_time1 <= temp[i]['from_time']:
seqtemp.append(temp[i]['name'])
to_time1 = temp[i]['to_time']
if to_time1 <= temp[i]["from_time"]:
seqtemp.append(temp[i]["name"])
to_time1 = temp[i]["to_time"]
remove_list.append(i)
remove_list.reverse()
for j in remove_list:
temp.pop(j)
return seqtemp,temp #returns 1. grouped Non overlapped Job cards with respect to first Job card 2. remaining Job cards
return [seqtemp,temp] #returns 1. grouped Non overlapped Job cards with respect to first Job card 2. remaining Job cards

def get_workstation_based_on_available_slot(self, existing) -> Optional[str]:
workstations = get_workstations(self.workstation_type)
Expand Down

0 comments on commit a1636bc

Please sign in to comment.