diff --git a/src/blenderbim/blenderbim/bim/module/cost/data.py b/src/blenderbim/blenderbim/bim/module/cost/data.py index c713b9eb39..9786151c6b 100644 --- a/src/blenderbim/blenderbim/bim/module/cost/data.py +++ b/src/blenderbim/blenderbim/bim/module/cost/data.py @@ -117,6 +117,7 @@ class CostSchedulesData: data["TotalAppliedValue"] = 0.0 data["TotalCost"] = 0.0 has_unit_basis = False + is_sum = False if root_element.is_a("IfcCostItem"): values = root_element.CostValues elif root_element.is_a("IfcConstructionResource"): @@ -130,6 +131,11 @@ class CostSchedulesData: data["UnitBasisValueComponent"] = cost_value_data["UnitBasis"]["ValueComponent"] data["UnitBasisUnitSymbol"] = cost_value_data["UnitBasis"]["UnitSymbol"] has_unit_basis = True + else: + data["UnitBasisValueComponent"] = 1 + data["UnitBasisUnitSymbol"] = "U" + if cost_value.Category == "*": + is_sum = True if has_unit_basis: data["TotalCost"] = data["TotalAppliedValue"] / data["UnitBasisValueComponent"] else: @@ -137,7 +143,8 @@ class CostSchedulesData: data["TotalCost"] = data["TotalAppliedValue"] * data["TotalCostQuantity"] else: data["TotalCost"] = data["TotalAppliedValue"] - data["TotalAppliedValue"] = None + if is_sum: + data["TotalAppliedValue"] = None @classmethod def _load_cost_item_quantities(cls, cost_item, data): @@ -154,7 +161,7 @@ class CostSchedulesData: if unit: data["UnitSymbol"] = ifcopenshell.util.unit.get_unit_symbol(unit) else: - data["UnitSymbol"] = None + data["UnitSymbol"] = "U" # same_unit_nested_cost_item = set() # data["DerivedTotalCostQuantity"] = None diff --git a/src/blenderbim/blenderbim/bim/module/cost/ui.py b/src/blenderbim/blenderbim/bim/module/cost/ui.py index 3c5b6e49a5..bdf2e7ef8b 100644 --- a/src/blenderbim/blenderbim/bim/module/cost/ui.py +++ b/src/blenderbim/blenderbim/bim/module/cost/ui.py @@ -620,18 +620,22 @@ class BIM_UL_cost_items_trait: else: row.label(text="", icon="DOT") - def draw_total_cost_column(self, layout, cost_item): - format_numbers = "{0:,.2f}".format(cost_item["TotalCost"]).replace(",", " ") - currency = CostSchedulesData.data["currency"] - text = "{} {}".format(format_numbers, currency["name"]) if currency else format_numbers - layout.label(text=text) - def draw_quantity_column(self, layout, cost_item): if CostSchedulesData.data["is_editing_rates"]: self.draw_uom_column(layout, cost_item) else: self.draw_total_quantity_column(layout, cost_item) + def draw_uom_column(self, layout, cost_item): + layout.label(text=cost_item["UnitBasisUnitSymbol"]) + + def draw_total_quantity_column(self, layout, cost_item): + if cost_item["TotalCostQuantity"]: + label = "{0:.2f}".format(cost_item["TotalCostQuantity"]) + f" {cost_item['UnitSymbol'] or '-'}" + layout.label(text=label) + else: + layout.label(text="-") + def draw_value_column(self, layout, cost_item): if cost_item["TotalAppliedValue"]: text = "{0:,.2f}".format(cost_item["TotalAppliedValue"]).replace(",", " ") @@ -643,8 +647,11 @@ class BIM_UL_cost_items_trait: else: layout.label(text="-") - def draw_uom_column(self, layout, cost_item): - layout.label(text=cost_item["UnitBasisUnitSymbol"] or "-" if cost_item["UnitBasisValueComponent"] else "-") + def draw_total_cost_column(self, layout, cost_item): + format_numbers = "{0:,.2f}".format(cost_item["TotalCost"]).replace(",", " ") + currency = CostSchedulesData.data["currency"] + text = "{} {}".format(format_numbers, currency["name"]) if currency else format_numbers + layout.label(text=text) def draw_order_operator(self, row, ifc_definition_id, cost_item): if cost_item["NestingIndex"] is not None: @@ -657,19 +664,7 @@ class BIM_UL_cost_items_trait: op.cost_item = ifc_definition_id op.new_index = cost_item["NestingIndex"] - 1 - def draw_total_quantity_column(self, layout, cost_item): - if cost_item["TotalCostQuantity"]: - label = "{0:.2f}".format(cost_item["TotalCostQuantity"]) + f" {cost_item['UnitSymbol'] or '-'}" - layout.label(text=label) - else: - layout.label(text="-") - # if cost_item["DerivedTotalCostQuantity"] not in [None, 0]: - # layout.label(text="{0:.2f}".format(cost_item["DerivedTotalCostQuantity"]) + f" {cost_item['DerivedUnitSymbol'] or '-'}") - # else: - # if cost_item["TotalCostQuantity"] == 0: - # layout.label(text="-") - # else: - # layout.label(text="{0:.2f}".format(cost_item["TotalCostQuantity"]) + f" {cost_item['UnitSymbol'] or '-'}") + class BIM_UL_cost_items(BIM_UL_cost_items_trait, UIList):