fix: better overlap logic for job card (#38432) (cherry picked from commit 74eab910427ca4af94119b0c099e7743be770006) Co-authored-by: rohitwaghchaure <rohitw1991@gmail.com>
This commit is contained in:
parent
0a29dbe09e
commit
2a9e843610
@ -261,8 +261,7 @@ class JobCard(Document):
|
|||||||
# override capacity for employee
|
# override capacity for employee
|
||||||
production_capacity = 1
|
production_capacity = 1
|
||||||
|
|
||||||
overlap_count = self.get_overlap_count(time_logs)
|
if not self.has_overlap(production_capacity, time_logs):
|
||||||
if time_logs and production_capacity > overlap_count:
|
|
||||||
return {}
|
return {}
|
||||||
|
|
||||||
if self.workstation_type and time_logs:
|
if self.workstation_type and time_logs:
|
||||||
@ -272,16 +271,15 @@ class JobCard(Document):
|
|||||||
|
|
||||||
return time_logs[-1]
|
return time_logs[-1]
|
||||||
|
|
||||||
@staticmethod
|
def has_overlap(self, production_capacity, time_logs):
|
||||||
def get_overlap_count(time_logs):
|
overlap = False
|
||||||
count = 1
|
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
|
# Check overlap exists or not between the overlapping time logs with the current Job Card
|
||||||
for idx, row in enumerate(time_logs):
|
for row in time_logs:
|
||||||
next_idx = idx
|
count = 1
|
||||||
if idx + 1 < len(time_logs):
|
for next_row in time_logs:
|
||||||
next_idx = idx + 1
|
|
||||||
next_row = time_logs[next_idx]
|
|
||||||
if row.name == next_row.name:
|
if row.name == next_row.name:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
@ -301,7 +299,10 @@ class JobCard(Document):
|
|||||||
):
|
):
|
||||||
count += 1
|
count += 1
|
||||||
|
|
||||||
return count
|
if count > production_capacity:
|
||||||
|
return True
|
||||||
|
|
||||||
|
return overlap
|
||||||
|
|
||||||
def get_time_logs(self, args, doctype, check_next_available_slot=False):
|
def get_time_logs(self, args, doctype, check_next_available_slot=False):
|
||||||
jc = frappe.qb.DocType("Job Card")
|
jc = frappe.qb.DocType("Job Card")
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user