Make description for additional components a property

This commit is contained in:
Tyler Ward 2020-10-01 23:41:24 +01:00
parent 20622e0346
commit a450c82e72
2 changed files with 7 additions and 6 deletions

View File

@ -57,6 +57,7 @@ class AdditionalComponent:
unit: Optional[str] = None
qty_multiplier: Union[ConnectorMultiplier, CableMultiplier, None] = None
@property
def description(self) -> str:
name_subtype = f', {self.subtype}' if self.subtype else ''
return f'{self.type.capitalize()}{name_subtype}'

View File

@ -108,10 +108,10 @@ class Harness:
for extra in connector.additional_components:
qty = extra.qty * connector.get_qty_multiplier(extra.qty_multiplier)
if(self.mini_bom_mode):
id = self.get_bom_index(extra.description(), extra.unit, extra.manufacturer, extra.mpn, extra.pn)
id = self.get_bom_index(extra.description, extra.unit, extra.manufacturer, extra.mpn, extra.pn)
rows.append(component_table_entry(f'{id} ({extra.type.capitalize()})', qty, extra.unit))
else:
rows.append(component_table_entry(extra.description(), qty, extra.unit, extra.pn, extra.manufacturer, extra.mpn))
rows.append(component_table_entry(extra.description, qty, extra.unit, extra.pn, extra.manufacturer, extra.mpn))
rows.append([html_line_breaks(connector.notes)])
html.extend(nested_html_table(rows))
@ -191,10 +191,10 @@ class Harness:
for extra in cable.additional_components:
qty = extra.qty * cable.get_qty_multiplier(extra.qty_multiplier)
if(self.mini_bom_mode):
id = self.get_bom_index(extra.description(), extra.unit, extra.manufacturer, extra.mpn, extra.pn)
id = self.get_bom_index(extra.description, extra.unit, extra.manufacturer, extra.mpn, extra.pn)
rows.append(component_table_entry(f'{id} ({extra.type.capitalize()})', qty, extra.unit))
else:
rows.append(component_table_entry(extra.description(), qty, extra.unit, extra.pn, extra.manufacturer, extra.mpn))
rows.append(component_table_entry(extra.description, qty, extra.unit, extra.pn, extra.manufacturer, extra.mpn))
rows.append([html_line_breaks(cable.notes)])
html.extend(nested_html_table(rows))
@ -373,7 +373,7 @@ class Harness:
qty = part.qty * connector.get_qty_multiplier(part.qty_multiplier)
bom_items.append(
{
'item': part.description(),
'item': part.description,
'qty': qty,
'unit': part.unit,
'manufacturer': part.manufacturer,
@ -411,7 +411,7 @@ class Harness:
qty = part.qty * cable.get_qty_multiplier(part.qty_multiplier)
bom_items.append(
{
'item': part.description(),
'item': part.description,
'qty': qty,
'unit': part.unit,
'manufacturer': part.manufacturer,