Class: Item::Materials::Checks::RoughinAndInstallKit
- Inherits:
-
BaseService
- Object
- BaseService
- Item::Materials::Checks::RoughinAndInstallKit
- Defined in:
- app/services/item/materials/checks/roughin_and_install_kit.rb
Overview
PS: I would rather not have this, it appears online as well and confuses customers, specially if they did the quote themselves or look at the quote
we provided
Defined Under Namespace
Classes: Result
Instance Method Summary collapse
-
#process(container:, options: {}) ⇒ Result
Status and any material alerts.
- #qualify?(container) ⇒ Boolean
Instance Method Details
#process(container:, options: {}) ⇒ Result
Returns 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 |
# File 'app/services/item/materials/checks/roughin_and_install_kit.rb', line 19 def process(container:, options: {}) return Result.new(status: :skipped) unless qualify?(container) material_alerts = [] invalid_install_kits = container.line_items.select { |l| l.item.exclusive_item_group and IqAccessoryFilter.for_item_or_exclusive_item_group(l.item.exclusive_item_group).for_customer(container.customer).first }.map(&:item) invalid_rough_in_kits = container.line_items.select { |l| l.item.is_roughin_kit? and IqAccessoryFilter.for_item_or_exclusive_item_group(l.item).for_customer(container.customer).first }.map(&:item) if invalid_install_kits.any? = {}.merge() [:room] = container [:group_type] = 'installation_kits' [:group_name] = "Installation Kits" [:recommended_qty] = 0 [:actual_qty] = 1 [:items] = invalid_install_kits [:unmaskable] = true [:name] = "We do not recommend adding Installation Kits to quote/orders for this customer." material_alerts << Item::Materials::Alert.new() end if invalid_rough_in_kits.any? = {}.merge() [:room] = container [:recommended_qty] = 0 [:actual_qty] = 1 [:items] = invalid_rough_in_kits [:unmaskable] = true [:name] = "We do not recommend adding Rough-in Kits to quote/orders for this customer." material_alerts << Item::Materials::Alert.new() end Result.new(status: :ok, alerts: material_alerts) end |
#qualify?(container) ⇒ Boolean
10 11 12 |
# File 'app/services/item/materials/checks/roughin_and_install_kit.rb', line 10 def qualify?(container) container.line_items.any? { |li| (li.item.exclusive_item_group and li.item.exclusive_item_group.key == "installation_kits") or li.item.is_roughin_kit? } end |