mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-18 22:33:33 +00:00
UoM and unit rates are now shown for schedule of rates in costing
This commit is contained in:
@@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
# BlenderBIM Add-on - OpenBIM Blender Add-on
|
# BlenderBIM Add-on - OpenBIM Blender Add-on
|
||||||
# Copyright (C) 2020, 2021 Dion Moult <dion@thinkmoult.com>
|
# Copyright (C) 2020, 2021 Dion Moult <dion@thinkmoult.com>
|
||||||
#
|
#
|
||||||
@@ -46,8 +45,13 @@ class BIM_PT_cost_schedules(Panel):
|
|||||||
row = self.layout.row()
|
row = self.layout.row()
|
||||||
row.operator("bim.add_cost_schedule", icon="ADD")
|
row.operator("bim.add_cost_schedule", icon="ADD")
|
||||||
|
|
||||||
for cost_schedule_id, cost_schedule in Data.cost_schedules.items():
|
if self.props.active_cost_schedule_id:
|
||||||
self.draw_cost_schedule_ui(cost_schedule_id, cost_schedule)
|
self.draw_cost_schedule_ui(
|
||||||
|
self.props.active_cost_schedule_id, Data.cost_schedules[self.props.active_cost_schedule_id]
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
for cost_schedule_id, cost_schedule in Data.cost_schedules.items():
|
||||||
|
self.draw_cost_schedule_ui(cost_schedule_id, cost_schedule)
|
||||||
|
|
||||||
def draw_cost_schedule_ui(self, cost_schedule_id, cost_schedule):
|
def draw_cost_schedule_ui(self, cost_schedule_id, cost_schedule):
|
||||||
row = self.layout.row(align=True)
|
row = self.layout.row(align=True)
|
||||||
@@ -464,10 +468,10 @@ class BIM_UL_cost_items(UIList):
|
|||||||
split2.alignment = "RIGHT"
|
split2.alignment = "RIGHT"
|
||||||
split2.prop(item, "name", emboss=False, text="")
|
split2.prop(item, "name", emboss=False, text="")
|
||||||
|
|
||||||
if Data.cost_schedules[self.props.active_cost_schedule_id]["PredefinedType"] != "SCHEDULEOFRATES":
|
if Data.cost_schedules[self.props.active_cost_schedule_id]["PredefinedType"] == "SCHEDULEOFRATES":
|
||||||
split2.label(
|
self.draw_uom_column(split2, cost_item)
|
||||||
text="{0:.2f}".format(cost_item["TotalCostQuantity"]) + f" ({cost_item['UnitSymbol'] or '?'})"
|
else:
|
||||||
)
|
self.draw_quantity_column(split2, cost_item)
|
||||||
|
|
||||||
split2.label(text="{0:.2f}".format(cost_item["TotalAppliedValue"]))
|
split2.label(text="{0:.2f}".format(cost_item["TotalAppliedValue"]))
|
||||||
|
|
||||||
@@ -477,6 +481,17 @@ class BIM_UL_cost_items(UIList):
|
|||||||
split2.label(text="{0:.2f}".format(cost_item["TotalCostValue"]))
|
split2.label(text="{0:.2f}".format(cost_item["TotalCostValue"]))
|
||||||
self.draw_buttons(split2, item, cost_item)
|
self.draw_buttons(split2, item, cost_item)
|
||||||
|
|
||||||
|
def draw_uom_column(self, layout, cost_item):
|
||||||
|
text = "-"
|
||||||
|
if cost_item["CostValues"]:
|
||||||
|
unit_basis = Data.cost_values[cost_item["CostValues"][0]]["UnitBasis"]
|
||||||
|
if unit_basis:
|
||||||
|
text = "{0:.2f}".format(unit_basis["ValueComponent"]) + f" ({unit_basis['UnitSymbol'] or '?'})"
|
||||||
|
layout.label(text=text)
|
||||||
|
|
||||||
|
def draw_quantity_column(self, layout, cost_item):
|
||||||
|
layout.label(text="{0:.2f}".format(cost_item["TotalCostQuantity"]) + f" ({cost_item['UnitSymbol'] or '?'})")
|
||||||
|
|
||||||
def draw_buttons(self, row, item, cost_item):
|
def draw_buttons(self, row, item, cost_item):
|
||||||
pass # TODO: reimplement somewhere with better UX
|
pass # TODO: reimplement somewhere with better UX
|
||||||
# elif self.props.active_cost_item_id:
|
# elif self.props.active_cost_item_id:
|
||||||
|
|||||||
@@ -111,19 +111,20 @@ class Data:
|
|||||||
data["TotalAppliedValue"] = 0.0
|
data["TotalAppliedValue"] = 0.0
|
||||||
data["CategoryValues"] = {}
|
data["CategoryValues"] = {}
|
||||||
for cost_value in cost_item.CostValues or []:
|
for cost_value in cost_item.CostValues or []:
|
||||||
cls.load_cost_item_value(data, cost_item, cost_value)
|
cls.load_cost_item_value(cost_item, data, cost_value)
|
||||||
data["CostValues"].append(cost_value.id())
|
data["CostValues"].append(cost_value.id())
|
||||||
data["TotalAppliedValue"] += cls.cost_values[cost_value.id()]["AppliedValue"]
|
data["TotalAppliedValue"] += cls.cost_values[cost_value.id()]["AppliedValue"]
|
||||||
data["TotalCostValue"] = data["TotalCostQuantity"] * data["TotalAppliedValue"]
|
data["TotalCostValue"] = data["TotalCostQuantity"] * data["TotalAppliedValue"]
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def load_cost_item_value(cls, cost_item_data, cost_item, cost_value):
|
def load_cost_item_value(cls, cost_item, cost_item_data, cost_value):
|
||||||
value_data = cost_value.get_info()
|
value_data = cost_value.get_info()
|
||||||
del value_data["AppliedValue"]
|
del value_data["AppliedValue"]
|
||||||
if value_data["UnitBasis"]:
|
if value_data["UnitBasis"]:
|
||||||
data = cost_value.UnitBasis.get_info()
|
data = cost_value.UnitBasis.get_info()
|
||||||
data["ValueComponent"] = data["ValueComponent"].wrappedValue
|
data["ValueComponent"] = data["ValueComponent"].wrappedValue
|
||||||
data["UnitComponent"] = data["UnitComponent"].id()
|
data["UnitComponent"] = data["UnitComponent"].id()
|
||||||
|
data["UnitSymbol"] = ifcopenshell.util.unit.get_unit_symbol(cost_value.UnitBasis.UnitComponent)
|
||||||
value_data["UnitBasis"] = data
|
value_data["UnitBasis"] = data
|
||||||
if value_data["ApplicableDate"]:
|
if value_data["ApplicableDate"]:
|
||||||
value_data["ApplicableDate"] = ifcopenshell.util.date.ifc2datetime(value_data["ApplicableDate"])
|
value_data["ApplicableDate"] = ifcopenshell.util.date.ifc2datetime(value_data["ApplicableDate"])
|
||||||
@@ -138,7 +139,7 @@ class Data:
|
|||||||
|
|
||||||
cls.cost_values[cost_value.id()] = value_data
|
cls.cost_values[cost_value.id()] = value_data
|
||||||
for component in cost_value.Components or []:
|
for component in cost_value.Components or []:
|
||||||
cls.load_cost_item_value(cost_item_data, cost_item, component)
|
cls.load_cost_item_value(cost_item, cost_item_data, component)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def calculate_applied_value(cls, cost_item, cost_value, category_filter=None):
|
def calculate_applied_value(cls, cost_item, cost_value, category_filter=None):
|
||||||
|
|||||||
Reference in New Issue
Block a user