fix bug with cost schedules confusing 0 quantity with no quantities

a bit related to #4704

1) fixed util.cost.get_total_quantity
2) fixed similar issue in cost.data that calculates the final value that user will see in UI
3) changed UI, "-" is shown when there are no quantities and "0" is when quantities are there but they just equal to zero.

Before - https://i.imgur.com/EO53DhM.png
After - https://i.imgur.com/H6rK4sP.png

fyi @myoualid
This commit is contained in:
Andrej730
2024-05-21 16:27:56 +05:00
parent ce6ce1b975
commit 9aacafd575
3 changed files with 8 additions and 3 deletions
@@ -40,7 +40,12 @@ def get_primitive_applied_value(applied_value: Union[ifcopenshell.entity_instanc
def get_total_quantity(root_element: ifcopenshell.entity_instance) -> Union[float, None]:
# 3 IfcPhysicalQuantity Value
if root_element.is_a("IfcCostItem"):
return sum([q[3] for q in root_element.CostQuantities or []]) or None
# Different output for no quantities and zero quantites
# as they have different meaning in IFC.
quantities = root_element.CostQuantities
if not quantities:
return None
return sum([q[3] for q in quantities])
elif root_element.is_a("IfcConstructionResource"):
quantity = root_element.BaseQuantity
return quantity[3] if quantity else 1.0