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 =

Threshold for suggested items underlayment stock.

200
SUGGESTED_ITEMS_TOWEL_WARMERS_STOCK_THRESHOLD =

Threshold for suggested items towel warmers stock.

50
SUGGESTED_ITEMS_ROUGHIN_KITS_STOCK_THRESHOLD =

Threshold for suggested items roughin kits stock.

10
SUGGESTED_ITEMS_INSTALLATION_KITS_STOCK_THRESHOLD =

Threshold for suggested items installation kits stock.

10
SUGGESTED_ITEMS_DEFAULT_THRESHOLD =

Threshold for suggested items default.

5
SUGGEST_UNDERLAYMENT_IF_HOMEOWNER =

Suggest underlayment if homeowner.

nil
SUGGEST_TOWEL_WARMERS_IF_HOMEOWNER =

Suggest towel warmers if homeowner.

nil
SUGGEST_ROUGHIN_KITS_IF_HOMEOWNER =

Suggest roughin kits if homeowner.

nil
SUGGEST_INSTALLATION_KITS_IF_HOMEOWNER =

Suggest installation kits if homeowner.

true
SUGGEST_OTHER_ITEMS_IF_HOMEOWNER =

Suggest other items if homeowner.

nil

Instance Method Summary collapse

Instance Method Details

#suggested_item_applies_to(customer) ⇒ void

Parameters:

  • customer (Object)
  • customer (Object)

Returns:

  • (void)
  • (void)


31
32
33
34
35
36
37
38
# File 'app/models/item/suggested_item_tool.rb', line 31

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_thresholdvoid

This method returns an undefined value.



41
42
43
44
45
46
47
48
49
50
51
# File 'app/models/item/suggested_item_tool.rb', line 41

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