mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-10 17:58:20 +00:00
Fix bug in date calculations when editing task times without sufficient data
This commit is contained in:
@@ -40,11 +40,11 @@ class Usecase:
|
||||
del self.settings["attributes"]["ScheduleFinish"]
|
||||
|
||||
duration_type = self.settings["attributes"].get("DurationType", self.settings["task_time"].DurationType)
|
||||
if "ScheduleFinish" in self.settings["attributes"]:
|
||||
if self.settings["attributes"].get("ScheduleFinish", None):
|
||||
self.settings["attributes"]["ScheduleFinish"] = ifcopenshell.util.sequence.get_soonest_working_day(
|
||||
self.settings["attributes"]["ScheduleFinish"], duration_type, self.calendar
|
||||
)
|
||||
if "ScheduleStart" in self.settings["attributes"]:
|
||||
if self.settings["attributes"].get("ScheduleStart", None):
|
||||
self.settings["attributes"]["ScheduleStart"] = ifcopenshell.util.sequence.get_soonest_working_day(
|
||||
self.settings["attributes"]["ScheduleStart"], duration_type, self.calendar
|
||||
)
|
||||
@@ -63,7 +63,7 @@ class Usecase:
|
||||
and self.settings["task_time"].ScheduleStart
|
||||
):
|
||||
self.calculate_finish()
|
||||
elif "ScheduleStart" in self.settings["attributes"].keys() and self.settings["task_time"].ScheduleDuration:
|
||||
elif self.settings["attributes"].get("ScheduleStart", None) and self.settings["task_time"].ScheduleDuration:
|
||||
self.calculate_finish()
|
||||
elif self.settings["attributes"].get("ScheduleFinish", None) and self.settings["task_time"].ScheduleStart:
|
||||
self.calculate_duration()
|
||||
|
||||
@@ -88,6 +88,26 @@ class TestEditTaskTime(test.bootstrap.IFC4):
|
||||
assert task_time.ScheduleFinish is None
|
||||
assert task_time.ScheduleDuration is None
|
||||
|
||||
def test_editing_just_a_start_date_with_no_duration_or_finish_but_with_a_calendar(self):
|
||||
ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcProject")
|
||||
calendar = ifcopenshell.api.run("sequence.add_work_calendar", self.file)
|
||||
task = self.file.createIfcTask()
|
||||
ifcopenshell.api.run("control.assign_control", self.file, relating_control=calendar, related_object=task)
|
||||
task_time = ifcopenshell.api.run("sequence.add_task_time", self.file, task=task)
|
||||
ifcopenshell.api.run(
|
||||
"sequence.edit_task_time",
|
||||
self.file,
|
||||
task_time=task_time,
|
||||
attributes={
|
||||
"ScheduleDuration": None,
|
||||
"ScheduleStart": datetime.datetime(2000, 1, 1),
|
||||
"ScheduleFinish": None,
|
||||
},
|
||||
)
|
||||
assert task_time.ScheduleStart == "2000-01-01T00:00:00"
|
||||
assert task_time.ScheduleFinish is None
|
||||
assert task_time.ScheduleDuration is None
|
||||
|
||||
def test_schedule_finish_dates_are_auto_calculated_if_possible(self):
|
||||
task_time = ifcopenshell.api.run("sequence.add_task_time", self.file, task=self.file.createIfcTask())
|
||||
ifcopenshell.api.run(
|
||||
|
||||
Reference in New Issue
Block a user