Class: Item::Materials::Checks::FloorHeating

Inherits:
BaseService
  • Object
show all
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 =
15.0
CAPACITY_TOLERANCE =
1.05
MAX_WATTS_PER_SQFT =
15.0
STATES_WITH_15_WATTSPERSQFT_LIMIT =
%w[AL AZ FL IL IN KS LA MD MO MS MT NY OK PA VA].freeze
STATES_WITH_2008_SH_WATTAGE_CODE =
%w[IN KS].freeze

Instance Method Summary collapse

Instance Method Details

#get_fh_heating_elements(container) ⇒ Object (protected)



51
52
53
# File 'app/services/item/materials/checks/floor_heating.rb', line 51

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)



55
56
57
58
# File 'app/services/item/materials/checks/floor_heating.rb', line 55

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: {}) ⇒ Object

rubocop:disable Metrics/AbcSize



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'app/services/item/materials/checks/floor_heating.rb', line 22

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, options)
  check_missing_thermostat(material_alerts, container, num_controls, num_heating_elements, options)
  check_current_capacity(material_alerts, container, fh_heating_elements, num_controls, num_pms, options)
  check_excess_capacity(material_alerts, container, fh_heating_elements, num_controls, num_pms, options)
  check_state_wattage_limits(material_alerts, container, fh_heating_elements, options)
  check_slab_heat_wattage(material_alerts, container, sh_heating_elements, options)

  Result.new(status: :ok, alerts: material_alerts)
end

#qualify?(container) ⇒ Boolean

Returns:

  • (Boolean)


16
17
18
19
# File 'app/services/item/materials/checks/floor_heating.rb', line 16

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