mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-10 01:41:57 +00:00
calculate_cost_item_resource_value not to skip resources without quantities
Noticed the discrepancies for total cost value for resources in Resource UI and in Cost Schedule UI when the same resources assigned to the item. In Resource UI it was considering omitted quantity as 1.0 (https://github.com/IfcOpenShell/IfcOpenShell/blob/c61e3670a8cf248aa5a229bae2dc29eef041fe47/src/ifcopenshell-python/ifcopenshell/util/cost.py#L53-L55) and in Cost Schedule UI it was skipping those resources completely. For cost items it is documented in ifc that if quantity is omitted then costs are considered to be total. Perhaps it's just not documented for the resources? Anyway, not sure if this way is completly correct but making sure resource quantity to be treated similarly in different parts of the codebase. Related to - https://github.com/buildingSMART/IFC4.3.x-development/issues/910 cc @myoualid
This commit is contained in:
@@ -159,11 +159,12 @@ def get_cost(resource: ifcopenshell.entity_instance) -> tuple[float, Union[str,
|
||||
|
||||
|
||||
def get_quantity(resource: ifcopenshell.entity_instance) -> float:
|
||||
if resource.BaseQuantity:
|
||||
return resource.BaseQuantity[3]
|
||||
if resource.Usage and resource.Usage.ScheduleWork:
|
||||
duration = ifcopenshell.util.date.ifc2datetime(resource.Usage.ScheduleWork)
|
||||
return duration.total_seconds() / 3600
|
||||
# TODO: is it safe to assume None quantity should be treated as 1.0? See #910 in ifc4x3dev.
|
||||
quantity = resource.BaseQuantity
|
||||
return 1.0 if quantity is None else quantity[3]
|
||||
|
||||
|
||||
def get_parent_cost(resource: ifcopenshell.entity_instance) -> Union[tuple[float, Union[str, None]], None]:
|
||||
|
||||
Reference in New Issue
Block a user