cost web ui:

- add "Linked rate" column,
- assign a cost rate to multiple cost items by selecting linked rate cells & clicking the "assign" button on the chosen cost rate
#5369
This commit is contained in:
myoualid
2024-09-23 20:19:06 +01:00
parent ab8a6b80e4
commit 455012de4c
9 changed files with 267 additions and 200 deletions
@@ -307,6 +307,34 @@ def get_product_quantity_names(elements: list[ifcopenshell.entity_instance]) ->
return [n for n in names if n != "id"]
def get_cost_schedule(cost_item: ifcopenshell.entity_instance) -> ifcopenshell.entity_instance:
"""Returns the cost schedule of a cost item.
"""
for rel in cost_item.HasAssignments or []:
if rel.is_a("IfcRelAssignsToControl") and rel.RelatingControl.is_a("IfcCostSchedule"):
return rel.RelatingControl
for rel in cost_item.Nests or []:
return get_cost_schedule(rel.RelatingObject)
def get_cost_rate(
file: ifcopenshell_wrapper.file, cost_item: ifcopenshell.entity_instance
) -> Optional[ifcopenshell.entity_instance]:
"""Returns the cost rate of a cost item.
"""
# There is no direct relationship between a cost item and a cost rate in IFC, so we need to infer it, based on the assumption that cost_rate.CostValues == cost_item.CostValues.
if get_cost_schedule(cost_item).PredefinedType == "SCHEDULEOFRATES":
return None # Cost item is already a cost rate
if cost_item.CostValues:
potential_rates = file.get_inverse(cost_item.CostValues[0])
for potential_rate in potential_rates:
schedule = get_cost_schedule(potential_rate)
if schedule.PredefinedType == "SCHEDULEOFRATES":
return potential_rate
return None
class CostValueUnserialiser:
def parse(self, formula: str):
l = lark.Lark(