Class: Item::Materials::Checks::CerazorbPlatinumInstallKit

Inherits:
BaseService
  • Object
show all
Defined in:
app/services/item/materials/checks/cerazorb_platinum_install_kit.rb

Overview

OBSOLETE - DO NOT USE ###
We stopped selling these kits long time ago and we don't even sell Cerazorb anymore.

Defined Under Namespace

Classes: Result

Instance Method Summary collapse

Instance Method Details

#process(container:, options: {}) ⇒ Result

Returns status and any material alerts.

Parameters:

  • container (Quote, Order, RoomConfiguration)

    the resource to check

  • options (Hash) (defaults to: {})

    shared check options passed by Item::Materials::Check

Options Hash (options:):

  • :for_www (Boolean)

    whether the check runs for the public site

  • :for_cart (Boolean)

    whether the check runs for the cart

Returns:

  • (Result)

    status and any material alerts



19
20
21
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
47
48
49
50
51
52
53
# File 'app/services/item/materials/checks/cerazorb_platinum_install_kit.rb', line 19

def process(container:, options: {})
  return Result.new(status: :skipped) unless qualify?(container)

  material_alerts = []

  platinum_install_kit = container.line_items.find { |l| l.item.is_platinum_install_kit? }
  cerazorb = container.line_items.goods.find { |l| l.item.is_cerazorb? }
  item = Item.find_by(sku: "FHT-KIT-04-PLT")
  if platinum_install_kit.present? && cerazorb.blank? && container.catalog.catalog_items.by_skus(item.sku).first.present? && item.present?
    ma_options = {}.merge(options)
    ma_options[:room] = container
    ma_options[:group_type] = 'installation_kits'
    ma_options[:group_name] = "Installation Kits"
    ma_options[:recommended_qty] = 0
    ma_options[:actual_qty] = 1
    ma_options[:items] = [item]
    ma_options[:unmaskable] = true
    ma_options[:name] = "We do not recommend adding the #{item.public_name} to your order unless you are planning to install CeraZorb® underlayment." if options[:for_www]
    material_alerts << Item::Materials::Alert.new(ma_options)
  elsif cerazorb.present? && platinum_install_kit.blank? && container.catalog.catalog_items.by_skus(item.sku).first.present? && item.present? && IqAccessoryFilter.for_item_or_exclusive_item_group(item).for_customer(container.customer).first.blank?

    ma_options = {}.merge(options)
    ma_options[:room] = container
    ma_options[:group_type] = 'installation_kits'
    ma_options[:group_name] = "Installation Kits"
    ma_options[:recommended_qty] = 1
    ma_options[:actual_qty] = 0
    ma_options[:unmaskable] = false
    ma_options[:items] = [item]
    ma_options[:name] = "The #{item.public_name} is recommended when you are planning to install CeraZorb® underlayment." if options[:for_www]
    material_alerts << Item::Materials::Alert.new(ma_options)
  end

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

#qualify?(container) ⇒ Boolean

Returns:

  • (Boolean)


10
11
12
# File 'app/services/item/materials/checks/cerazorb_platinum_install_kit.rb', line 10

def qualify?(container)
  container.line_items.any? { |li| li.item.is_platinum_install_kit? || li.item.is_cerazorb? }
end