37 lines
1.0 KiB
Python
37 lines
1.0 KiB
Python
from math import ceil
|
|
|
|
from helix.constants.panel_type import PanelType
|
|
|
|
|
|
def add_parts_to_list(parts_list, parts_to_add, multiplier=1):
|
|
for part, quantity in parts_to_add.items():
|
|
previous_value = parts_list.get(part) or 0
|
|
if quantity != 0:
|
|
parts_list[part] = previous_value + quantity * multiplier
|
|
|
|
|
|
def apply_fudge_factors(parts_list, fudge_factors):
|
|
for part, quantity in parts_list.items():
|
|
fudge_factor = fudge_factors.get(part) or 1.0
|
|
parts_list[part] = quantity * fudge_factor
|
|
|
|
|
|
def apply_package_size_rounding(parts_list, package_sizes):
|
|
for part, quantity in parts_list.items():
|
|
package_size = package_sizes.get(part) or 1
|
|
parts_list[part] = package_size * ceil(quantity / package_size)
|
|
|
|
|
|
def get_panel_type_counts(panels):
|
|
panel_type_counts = {
|
|
PanelType.Corner: 0,
|
|
PanelType.NorthSouth: 0,
|
|
PanelType.EastWest: 0,
|
|
PanelType.Middle: 0,
|
|
}
|
|
|
|
for panel in panels:
|
|
panel_type_counts[panel.panel_type] += 1
|
|
|
|
return panel_type_counts
|