Class: Search::ProductCatalogPresenter
- Inherits:
-
BasePresenter
- Object
- SimpleDelegator
- BasePresenter
- Search::ProductCatalogPresenter
- Includes:
- Presenters::Timeable
- Defined in:
- app/presenters/search/product_catalog_presenter.rb
Overview
Row presenter for ProductCatalogSearch — renders the cells in the CRM
product catalog search/results table. Wraps a ViewProductCatalog projection
rather than a fully-loaded CatalogItem so the search grid stays light.
Direct Known Subclasses
Instance Attribute Summary
Attributes inherited from BasePresenter
#current_account, #options, #url_helper
Instance Method Summary collapse
-
#catalog ⇒ ActiveSupport::SafeBuffer?
Linked catalog name → catalog show page.
-
#coupon_link ⇒ ActiveSupport::SafeBuffer?
Linked coupon code → coupon show page.
-
#effective_price ⇒ String?
Effective price formatted as currency.
-
#effective_price_with_vat ⇒ String?
Effective price including VAT formatted as currency.
-
#item_sku ⇒ ActiveSupport::SafeBuffer, String
Linked item SKU → catalog item show page when an ID is available.
-
#map_price ⇒ String?
Minimum advertised price formatted as currency.
-
#map_violation ⇒ ActiveSupport::SafeBuffer?
MAP violation indicator badge (
Yes/No). -
#old_price ⇒ String?
Previous item price formatted as currency.
-
#parent_catalog_item ⇒ ActiveSupport::SafeBuffer?
Linked parent catalog item name → parent catalog item show page.
-
#parent_catalog_price ⇒ String?
Parent catalog price formatted as currency.
-
#parent_price_updated_at ⇒ String
Date the parent catalog price was last updated.
-
#price ⇒ String?
Item price formatted as currency.
-
#price_difference ⇒ String
Difference between item and parent catalog prices formatted as currency.
-
#price_difference_factor ⇒ ActiveSupport::SafeBuffer, ...
Percentage factor of the price divergence from the parent catalog.
-
#price_updated_at ⇒ String
Date the item price was last updated.
-
#price_updated_parent_differential_in_days ⇒ String
Difference in days between item and parent catalog price updates.
-
#price_with_vat ⇒ String?
Price including VAT formatted as currency.
-
#retail_price ⇒ String?
Retail price formatted as currency.
-
#sale_price ⇒ String?
Sale price formatted as currency.
-
#sale_price_with_vat ⇒ String?
Sale price including VAT formatted as currency.
-
#state ⇒ String?
Catalog item state as a string.
-
#store_item_unit_cogs ⇒ String
Store item unit cost of goods sold formatted as currency.
Methods inherited from BasePresenter
#can?, #capture, #concat, #content_tag, #fa_icon, #h, #initialize, #link_to, #number_to_currency, #present, presents, #r, #safe_present, #simple_format, #u
Constructor Details
This class inherits a constructor from BasePresenter
Instance Method Details
#catalog ⇒ ActiveSupport::SafeBuffer?
Linked catalog name → catalog show page.
43 44 45 46 47 |
# File 'app/presenters/search/product_catalog_presenter.rb', line 43 def catalog return unless r.has_columns?(:catalog_name, :catalog_id) h.link_to(r.catalog_name, h.catalog_path(r.catalog_id)) end |
#coupon_link ⇒ ActiveSupport::SafeBuffer?
Linked coupon code → coupon show page.
25 26 27 28 29 |
# File 'app/presenters/search/product_catalog_presenter.rb', line 25 def coupon_link return unless r.has_columns?(:coupon_id, :coupon_code) h.link_to(r.coupon_code, h.coupon_path(r.coupon_id)) end |
#effective_price ⇒ String?
Effective price formatted as currency.
164 165 166 167 168 |
# File 'app/presenters/search/product_catalog_presenter.rb', line 164 def effective_price return unless r.has_columns?(:effective_price, :currency_symbol) h.number_to_currency(r.effective_price, unit: r.currency_symbol) end |
#effective_price_with_vat ⇒ String?
Effective price including VAT formatted as currency.
191 192 193 194 195 |
# File 'app/presenters/search/product_catalog_presenter.rb', line 191 def effective_price_with_vat return unless r.has_columns?(:effective_price_with_vat, :currency_symbol) h.number_to_currency(r.effective_price_with_vat, unit: r.currency_symbol) end |
#item_sku ⇒ ActiveSupport::SafeBuffer, String
Linked item SKU → catalog item show page when an ID is available.
14 15 16 17 18 19 20 |
# File 'app/presenters/search/product_catalog_presenter.rb', line 14 def item_sku if r.respond_to?(:id) h.link_to(r.item_sku, h.catalog_item_path(r.id)) else r.item_sku end end |
#map_price ⇒ String?
Minimum advertised price formatted as currency.
118 119 120 121 122 |
# File 'app/presenters/search/product_catalog_presenter.rb', line 118 def map_price return unless r.has_columns?(:map_price, :currency_symbol) h.number_to_currency(r.map_price, unit: r.currency_symbol) end |
#map_violation ⇒ ActiveSupport::SafeBuffer?
MAP violation indicator badge (Yes/No).
127 128 129 130 131 132 133 134 135 136 |
# File 'app/presenters/search/product_catalog_presenter.rb', line 127 def map_violation return unless r.has_columns?(:map_violation, :retail_price, :map_price, :currency_symbol) return if r.map_violation.nil? if r.map_violation h.tag.span('Yes', class: 'badge bg-danger', title: "Retail: #{h.number_to_currency(r.retail_price, unit: r.currency_symbol)} < MAP: #{h.number_to_currency(r.map_price, unit: r.currency_symbol)}") else h.tag.span('No', class: 'badge bg-success') end end |
#old_price ⇒ String?
Previous item price formatted as currency.
79 80 81 82 83 |
# File 'app/presenters/search/product_catalog_presenter.rb', line 79 def old_price return unless r.has_columns?(:old_price, :currency_symbol) h.number_to_currency(r.old_price, unit: r.currency_symbol) end |
#parent_catalog_item ⇒ ActiveSupport::SafeBuffer?
Linked parent catalog item name → parent catalog item show page.
52 53 54 55 56 |
# File 'app/presenters/search/product_catalog_presenter.rb', line 52 def parent_catalog_item return unless r.has_columns?(:parent_catalog_item_id, :parent_catalog_name) h.link_to(r.parent_catalog_name, h.catalog_item_path(r.parent_catalog_item_id)) end |
#parent_catalog_price ⇒ String?
Parent catalog price formatted as currency.
61 62 63 64 65 |
# File 'app/presenters/search/product_catalog_presenter.rb', line 61 def parent_catalog_price return unless r.has_columns?(:parent_catalog_price, :currency_symbol) h.number_to_currency(r.parent_catalog_price, unit: r.currency_symbol) end |
#parent_price_updated_at ⇒ String
Date the parent catalog price was last updated.
95 96 97 |
# File 'app/presenters/search/product_catalog_presenter.rb', line 95 def parent_price_updated_at h.render_date(r.parent_price_updated_at) end |
#price ⇒ String?
Item price formatted as currency.
70 71 72 73 74 |
# File 'app/presenters/search/product_catalog_presenter.rb', line 70 def price return unless r.has_columns?(:price, :currency_symbol) h.number_to_currency(r.price, unit: r.currency_symbol) end |
#price_difference ⇒ String
Difference between item and parent catalog prices formatted as currency.
141 142 143 |
# File 'app/presenters/search/product_catalog_presenter.rb', line 141 def price_difference h.number_to_currency(r.price_difference, unit: r.currency_symbol) end |
#price_difference_factor ⇒ ActiveSupport::SafeBuffer, ...
Percentage factor of the price divergence from the parent catalog.
200 201 202 203 204 205 206 207 208 209 210 211 |
# File 'app/presenters/search/product_catalog_presenter.rb', line 200 def price_difference_factor return unless r.has_columns?(:price_diverging, :price_difference_factor) if r.price_diverging h.content_tag(:p, (r.price_difference_factor * 100).round(2), style: 'color: red;font-weight:bolder', title: "The parent catalog discount differs from the discount in this item. Parent catalog discount is #{(r.parent_catalog_discount * 100).round(2)} %") else (r.price_difference_factor * 100).round(2) end end |
#price_updated_at ⇒ String
Date the item price was last updated.
88 89 90 |
# File 'app/presenters/search/product_catalog_presenter.rb', line 88 def price_updated_at h.render_date(r.price_updated_at) end |
#price_updated_parent_differential_in_days ⇒ String
Difference in days between item and parent catalog price updates.
102 103 104 |
# File 'app/presenters/search/product_catalog_presenter.rb', line 102 def price_updated_parent_differential_in_days h.pluralize(r.price_updated_parent_differential_in_days.to_i, 'day') end |
#price_with_vat ⇒ String?
Price including VAT formatted as currency.
173 174 175 176 177 |
# File 'app/presenters/search/product_catalog_presenter.rb', line 173 def price_with_vat return unless r.has_columns?(:price_with_vat, :currency_symbol) h.number_to_currency(r.price_with_vat, unit: r.currency_symbol) end |
#retail_price ⇒ String?
Retail price formatted as currency.
109 110 111 112 113 |
# File 'app/presenters/search/product_catalog_presenter.rb', line 109 def retail_price return unless r.has_columns?(:retail_price, :currency_symbol) h.number_to_currency(r.retail_price, unit: r.currency_symbol) end |
#sale_price ⇒ String?
Sale price formatted as currency.
155 156 157 158 159 |
# File 'app/presenters/search/product_catalog_presenter.rb', line 155 def sale_price return unless r.has_columns?(:sale_price, :currency_symbol) h.number_to_currency(r.sale_price, unit: r.currency_symbol) end |
#sale_price_with_vat ⇒ String?
Sale price including VAT formatted as currency.
182 183 184 185 186 |
# File 'app/presenters/search/product_catalog_presenter.rb', line 182 def sale_price_with_vat return unless r.has_columns?(:sale_price_with_vat, :currency_symbol) h.number_to_currency(r.sale_price_with_vat, unit: r.currency_symbol) end |
#state ⇒ String?
Catalog item state as a string.
34 35 36 37 38 |
# File 'app/presenters/search/product_catalog_presenter.rb', line 34 def state return unless r.has_columns?(:catalog_item_state) r.catalog_item_state.to_s end |
#store_item_unit_cogs ⇒ String
Store item unit cost of goods sold formatted as currency.
148 149 150 |
# File 'app/presenters/search/product_catalog_presenter.rb', line 148 def store_item_unit_cogs h.number_to_currency(r.store_item_unit_cogs) end |