from math import ceil from helix.constants.panel_type import PanelType from helix.constants.parts import * # This story askes for this special parts to be showed # www.pivotaltracker.com/n/projects/1544689/stories/148016595 PARTS_SHOWN_EVEN_WITH_0_ELEMENTS = [ delta_kit_inverter_mount, delta_kit_inverter_mount_dt ] 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 or part in PARTS_SHOWN_EVEN_WITH_0_ELEMENTS: 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