Class: Item::Materials::Checks::CerazorbPlatinumInstallKit
- Inherits:
-
BaseService
- Object
- BaseService
- Item::Materials::Checks::CerazorbPlatinumInstallKit
- 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? = {}.merge() [:room] = container [:group_type] = 'installation_kits' [:group_name] = "Installation Kits" [:recommended_qty] = 0 [:actual_qty] = 1 [:items] = [item] [:unmaskable] = true [:name] = "We do not recommend adding the #{item.public_name} to your order unless you are planning to install CeraZorb® underlayment." if [:for_www] material_alerts << Item::Materials::Alert.new() 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? = {}.merge() [:room] = container [:group_type] = 'installation_kits' [:group_name] = "Installation Kits" [:recommended_qty] = 1 [:actual_qty] = 0 [:unmaskable] = false [:items] = [item] [:name] = "The #{item.public_name} is recommended when you are planning to install CeraZorb® underlayment." if [:for_www] material_alerts << Item::Materials::Alert.new() end Result.new(status: :ok, alerts: material_alerts) end |
#qualify?(container) ⇒ 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 |