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



13
14
15
16
17
18
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
# File 'app/services/item/materials/checks/cerazorb_platinum_install_kit.rb', line 13

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

  platinum_install_kit = container.line_items.detect{|l| l.item.is_platinum_install_kit?}
  cerazorb = container.line_items.goods.detect{|l| l.item.is_cerazorb?}
  item = Item.find_by(sku: "FHT-KIT-04-PLT")
  if platinum_install_kit.present? and !cerazorb.present? and container.catalog.catalog_items.by_skus(item.sku).first.present? and 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? and !platinum_install_kit.present? and container.catalog.catalog_items.by_skus(item.sku).first.present? and item.present? and !IqAccessoryFilter.for_item_or_exclusive_item_group(item).for_customer(container.customer).first.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] = 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)


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

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