Display currency on cost item values and total cost

This commit is contained in:
Sigma Dimensions
2023-06-02 14:49:59 +01:00
parent f4344b9e75
commit 1d13edd747
2 changed files with 24 additions and 16 deletions
@@ -46,9 +46,16 @@ class CostSchedulesData:
"cost_quantities": cls.cost_quantities(), "cost_quantities": cls.cost_quantities(),
"cost_values": cls.cost_values(), "cost_values": cls.cost_values(),
"quantity_types": cls.quantity_types(), "quantity_types": cls.quantity_types(),
"currency": cls.currency(),
} }
cls.is_loaded = True cls.is_loaded = True
@classmethod
def currency(cls):
unit = tool.Unit.get_project_currency_unit()
if unit:
return {"id": unit.id(), "name": unit.Currency}
@classmethod @classmethod
def total_cost_schedules(cls): def total_cost_schedules(cls):
return len(tool.Ifc.get().by_type("IfcCostSchedule")) return len(tool.Ifc.get().by_type("IfcCostSchedule"))
+17 -16
View File
@@ -219,7 +219,6 @@ class BIM_PT_cost_schedules(Panel):
blenderbim.bim.helper.draw_attributes(self.props.cost_value_attributes, self.layout.box()) blenderbim.bim.helper.draw_attributes(self.props.cost_value_attributes, self.layout.box())
def draw_readonly_cost_value_ui(self, layout, cost_value): def draw_readonly_cost_value_ui(self, layout, cost_value):
print(cost_value)
if self.props.active_cost_value_id == cost_value["id"] and self.props.cost_value_editing_type == "FORMULA": if self.props.active_cost_value_id == cost_value["id"] and self.props.cost_value_editing_type == "FORMULA":
layout.prop(self.props, "cost_value_formula", text="") layout.prop(self.props, "cost_value_formula", text="")
else: else:
@@ -605,7 +604,10 @@ class BIM_UL_cost_items_trait:
row.label(text="", icon="DOT") row.label(text="", icon="DOT")
def draw_total_cost_column(self, layout, cost_item): def draw_total_cost_column(self, layout, cost_item):
layout.label(text="{0:,.2f}".format(cost_item["TotalCost"]).replace(",", " ")) 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): def draw_quantity_column(self, layout, cost_item):
if CostSchedulesData.data["is_editing_rates"]: if CostSchedulesData.data["is_editing_rates"]:
@@ -614,14 +616,15 @@ class BIM_UL_cost_items_trait:
self.draw_total_quantity_column(layout, cost_item) self.draw_total_quantity_column(layout, cost_item)
def draw_value_column(self, layout, cost_item): def draw_value_column(self, layout, cost_item):
text = ( if cost_item["TotalAppliedValue"]:
"{0:,.2f}".format(cost_item["TotalAppliedValue"]).replace(",", " ") text = "{0:,.2f}".format(cost_item["TotalAppliedValue"]).replace(",", " ")
if cost_item["TotalAppliedValue"] if cost_item["UnitBasisValueComponent"] not in [None, 1]:
else "-" text = "{} / {}".format(text, round(cost_item["UnitBasisValueComponent"], 2))
) text = "{} {}".format(text, cost_item["Currency"]) if cost_item["Currency"] else text
if cost_item["UnitBasisValueComponent"] not in [None, 1]: currency = CostSchedulesData.data["currency"]
text += " / {}".format(round(cost_item["UnitBasisValueComponent"], 2)) layout.label(text="{} {}".format(text, currency["name"]) if currency else text)
layout.label(text=text) else:
layout.label(text="-")
def draw_uom_column(self, layout, cost_item): def draw_uom_column(self, layout, cost_item):
layout.label(text=cost_item["UnitBasisUnitSymbol"] or "-" if cost_item["UnitBasisValueComponent"] else "-") layout.label(text=cost_item["UnitBasisUnitSymbol"] or "-" if cost_item["UnitBasisValueComponent"] else "-")
@@ -638,12 +641,10 @@ class BIM_UL_cost_items_trait:
op.new_index = cost_item["NestingIndex"] - 1 op.new_index = cost_item["NestingIndex"] - 1
def draw_total_quantity_column(self, layout, cost_item): def draw_total_quantity_column(self, layout, cost_item):
label = ( if cost_item["TotalCostQuantity"]:
"{0:.2f}".format(cost_item["TotalCostQuantity"]) + f" {cost_item['UnitSymbol'] or '-'}" label = "{0:.2f}".format(cost_item["TotalCostQuantity"]) + f" {cost_item['UnitSymbol'] or '-'}"
if cost_item["TotalCostQuantity"] layout.label(text=label)
else "-" else:
)
layout.label(text=label)
# if cost_item["DerivedTotalCostQuantity"] not in [None, 0]: # if cost_item["DerivedTotalCostQuantity"] not in [None, 0]:
# layout.label(text="{0:.2f}".format(cost_item["DerivedTotalCostQuantity"]) + f" {cost_item['DerivedUnitSymbol'] or '-'}") # layout.label(text="{0:.2f}".format(cost_item["DerivedTotalCostQuantity"]) + f" {cost_item['DerivedUnitSymbol'] or '-'}")
# else: # else: