mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-09 09:21:46 +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
|
||||
# Copyright (C) 2020, 2021 Dion Moult <dion@thinkmoult.com>
|
||||
#
|
||||
@@ -46,8 +45,13 @@ class BIM_PT_cost_schedules(Panel):
|
||||
row = self.layout.row()
|
||||
row.operator("bim.add_cost_schedule", icon="ADD")
|
||||
|
||||
for cost_schedule_id, cost_schedule in Data.cost_schedules.items():
|
||||
self.draw_cost_schedule_ui(cost_schedule_id, cost_schedule)
|
||||
if self.props.active_cost_schedule_id:
|
||||
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):
|
||||
row = self.layout.row(align=True)
|
||||
@@ -464,10 +468,10 @@ class BIM_UL_cost_items(UIList):
|
||||
split2.alignment = "RIGHT"
|
||||
split2.prop(item, "name", emboss=False, text="")
|
||||
|
||||
if Data.cost_schedules[self.props.active_cost_schedule_id]["PredefinedType"] != "SCHEDULEOFRATES":
|
||||
split2.label(
|
||||
text="{0:.2f}".format(cost_item["TotalCostQuantity"]) + f" ({cost_item['UnitSymbol'] or '?'})"
|
||||
)
|
||||
if Data.cost_schedules[self.props.active_cost_schedule_id]["PredefinedType"] == "SCHEDULEOFRATES":
|
||||
self.draw_uom_column(split2, cost_item)
|
||||
else:
|
||||
self.draw_quantity_column(split2, cost_item)
|
||||
|
||||
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"]))
|
||||
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):
|
||||
pass # TODO: reimplement somewhere with better UX
|
||||
# elif self.props.active_cost_item_id:
|
||||
|
||||
@@ -111,19 +111,20 @@ class Data:
|
||||
data["TotalAppliedValue"] = 0.0
|
||||
data["CategoryValues"] = {}
|
||||
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["TotalAppliedValue"] += cls.cost_values[cost_value.id()]["AppliedValue"]
|
||||
data["TotalCostValue"] = data["TotalCostQuantity"] * data["TotalAppliedValue"]
|
||||
|
||||
@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()
|
||||
del value_data["AppliedValue"]
|
||||
if value_data["UnitBasis"]:
|
||||
data = cost_value.UnitBasis.get_info()
|
||||
data["ValueComponent"] = data["ValueComponent"].wrappedValue
|
||||
data["UnitComponent"] = data["UnitComponent"].id()
|
||||
data["UnitSymbol"] = ifcopenshell.util.unit.get_unit_symbol(cost_value.UnitBasis.UnitComponent)
|
||||
value_data["UnitBasis"] = data
|
||||
if 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
|
||||
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
|
||||
def calculate_applied_value(cls, cost_item, cost_value, category_filter=None):
|
||||
|
||||
Reference in New Issue
Block a user