Class: Item::Materials::Checks::FloorHeating
- Inherits:
-
BaseService
- Object
- BaseService
- Item::Materials::Checks::FloorHeating
- Defined in:
- app/services/item/materials/checks/floor_heating.rb
Overview
Validates floor heating configurations including controls, power modules,
current capacity, and state-specific wattage requirements.
Defined Under Namespace
Classes: Result
Constant Summary collapse
- AMPS_PER_CONTROL =
Amps per control.
15.0- CAPACITY_TOLERANCE =
Capacity tolerance.
1.05- MAX_WATTS_PER_SQFT =
Maximum watts per sqft.
15.0- STATES_WITH_15_WATTSPERSQFT_LIMIT =
Limit for states with 15 wattspersqft.
%w[AL AZ FL IL IN KS LA MD MO MS MT NY OK PA VA].freeze
- STATES_WITH_2008_SH_WATTAGE_CODE =
States with 2008 sh wattage code.
%w[IN KS].freeze
Instance Method Summary collapse
- #get_fh_heating_elements(container) ⇒ Object protected
- #get_sh_heating_elements(container) ⇒ Object protected
-
#process(container:, options: {}) ⇒ Result
Status and any material alerts.
- #qualify?(container) ⇒ Boolean
Instance Method Details
#get_fh_heating_elements(container) ⇒ Object (protected)
60 61 62 |
# File 'app/services/item/materials/checks/floor_heating.rb', line 60 def get_fh_heating_elements(container) container.line_items.heating_elements.by_product_line_path(LtreePaths::PL_FLOOR_HEATING).to_a end |
#get_sh_heating_elements(container) ⇒ Object (protected)
64 65 66 67 |
# File 'app/services/item/materials/checks/floor_heating.rb', line 64 def get_sh_heating_elements(container) container.line_items.heating_elements.by_product_line_path(LtreePaths::PL_FLOOR_HEATING_SLAB_HEAT_MAT).to_a + container.line_items.heating_elements.by_product_line_path(LtreePaths::PL_FLOOR_HEATING_SLAB_HEAT_CABLE).to_a end |
#process(container:, options: {}) ⇒ Result
Returns status and any material alerts.
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'app/services/item/materials/checks/floor_heating.rb', line 32 def process(container:, options: {}) # first test if we have any floor heating element products fh_heating_elements = get_fh_heating_elements(container) sh_heating_elements = get_sh_heating_elements(container) return Result.new(status: :skipped) unless qualify?(container) && fh_heating_elements.present? material_alerts = [] # get actual controls in the line items controls = container.line_items.thermostats.to_a # get actual power modules pms = container.line_items.power_modules.to_a # next test if we have more fh controls than we have fh heating elements num_controls = controls.sum(&:quantity) num_pms = pms.sum(&:quantity) num_heating_elements = fh_heating_elements.sum(&:quantity) check_controls_vs_heating_elements(material_alerts, container, controls, num_controls, num_heating_elements, ) check_missing_thermostat(material_alerts, container, num_controls, num_heating_elements, ) check_current_capacity(material_alerts, container, fh_heating_elements, num_controls, num_pms, ) check_excess_capacity(material_alerts, container, fh_heating_elements, num_controls, num_pms, ) check_state_wattage_limits(material_alerts, container, fh_heating_elements, ) check_slab_heat_wattage(material_alerts, container, sh_heating_elements, ) Result.new(status: :ok, alerts: material_alerts) end |
#qualify?(container) ⇒ Boolean
22 23 24 25 |
# File 'app/services/item/materials/checks/floor_heating.rb', line 22 def qualify?(container) # we only apply this test when a container is a room or is a quote or order with no rooms, ie a single system container.is_a?(RoomConfiguration) || (container.respond_to?(:room_configurations) && container.room_configurations.count <= 1) end |