Class: Item::SuggestedItemTool

Inherits:
SimpleDelegator
  • Object
show all
Defined in:
app/models/item/suggested_item_tool.rb

Overview

This class represents a suggested item tool for an item in the application.
It provides methods to determine if a suggested item applies to a customer and
the stock threshold for the suggested item.

Constant Summary collapse

SUGGESTED_ITEMS_UNDERLAYMENT_STOCK_THRESHOLD =
200
SUGGESTED_ITEMS_TOWEL_WARMERS_STOCK_THRESHOLD =
50
SUGGESTED_ITEMS_ROUGHIN_KITS_STOCK_THRESHOLD =
10
SUGGESTED_ITEMS_INSTALLATION_KITS_STOCK_THRESHOLD =
10
SUGGESTED_ITEMS_DEFAULT_THRESHOLD =
5
SUGGEST_UNDERLAYMENT_IF_HOMEOWNER =
nil
SUGGEST_TOWEL_WARMERS_IF_HOMEOWNER =
nil
SUGGEST_ROUGHIN_KITS_IF_HOMEOWNER =
nil
SUGGEST_INSTALLATION_KITS_IF_HOMEOWNER =
true
SUGGEST_OTHER_ITEMS_IF_HOMEOWNER =
nil

Instance Method Summary collapse

Instance Method Details

#suggested_item_applies_to(customer) ⇒ Object



16
17
18
19
20
21
22
23
# File 'app/models/item/suggested_item_tool.rb', line 16

def suggested_item_applies_to(customer)
  return false if underlayment_exclusion?(customer)
  return false if roughin_kits_exclusion?(customer)
  return false if installation_kits_exclusion?(customer)
  return false if other_items_exclusion?(customer)

  true
end

#suggested_item_stock_thresholdObject



25
26
27
28
29
30
31
32
33
34
35
# File 'app/models/item/suggested_item_tool.rb', line 25

def suggested_item_stock_threshold
  if is_underlayment?
    SUGGESTED_ITEMS_UNDERLAYMENT_STOCK_THRESHOLD
  elsif exclusive_item_group && (exclusive_item_group.key == 'roughin_kits')
    SUGGESTED_ITEMS_ROUGHIN_KITS_STOCK_THRESHOLD
  elsif exclusive_item_group && (exclusive_item_group.key == 'installation_kits')
    SUGGESTED_ITEMS_INSTALLATION_KITS_STOCK_THRESHOLD
  else
    SUGGESTED_ITEMS_DEFAULT_THRESHOLD
  end
end