Class: Search::ProductCatalogPresenter

Inherits:
BasePresenter
  • Object
show all
Includes:
Presenters::Timeable
Defined in:
app/presenters/search/product_catalog_presenter.rb

Direct Known Subclasses

ProductCatalogTextPresenter

Instance Attribute Summary

Attributes inherited from BasePresenter

#current_account, #options, #url_helper

Instance Method Summary collapse

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

#catalogObject



24
25
26
27
# File 'app/presenters/search/product_catalog_presenter.rb', line 24

def catalog
  return unless r.has_columns?(:catalog_name, :catalog_id)
  h.link_to(r.catalog_name, h.catalog_path(r.catalog_id))
end


14
15
16
17
# File 'app/presenters/search/product_catalog_presenter.rb', line 14

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_priceObject



100
101
102
103
# File 'app/presenters/search/product_catalog_presenter.rb', line 100

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_vatObject



115
116
117
118
# File 'app/presenters/search/product_catalog_presenter.rb', line 115

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_skuObject



6
7
8
9
10
11
12
# File 'app/presenters/search/product_catalog_presenter.rb', line 6

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_priceObject



70
71
72
73
74
# File 'app/presenters/search/product_catalog_presenter.rb', line 70

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_violationObject



76
77
78
79
80
81
82
83
84
85
# File 'app/presenters/search/product_catalog_presenter.rb', line 76

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_priceObject



46
47
48
49
50
# File 'app/presenters/search/product_catalog_presenter.rb', line 46

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_itemObject



29
30
31
32
# File 'app/presenters/search/product_catalog_presenter.rb', line 29

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_priceObject



34
35
36
37
38
# File 'app/presenters/search/product_catalog_presenter.rb', line 34

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_atObject



56
57
58
# File 'app/presenters/search/product_catalog_presenter.rb', line 56

def parent_price_updated_at
  h.render_date(r.parent_price_updated_at)
end

#priceObject



40
41
42
43
44
# File 'app/presenters/search/product_catalog_presenter.rb', line 40

def price
  return unless r.has_columns?(:price, :currency_symbol)

  h.number_to_currency(r.price, unit: r.currency_symbol)
end

#price_differenceObject



87
88
89
# File 'app/presenters/search/product_catalog_presenter.rb', line 87

def price_difference
  h.number_to_currency(r.price_difference, unit: r.currency_symbol)
end

#price_difference_factorObject



120
121
122
123
124
125
126
127
128
129
130
# File 'app/presenters/search/product_catalog_presenter.rb', line 120

def price_difference_factor
  return unless r.has_columns?(:price_diverging, :price_difference_factor)
  if r.price_diverging
   h.(: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_atObject



52
53
54
# File 'app/presenters/search/product_catalog_presenter.rb', line 52

def price_updated_at
  h.render_date(r.price_updated_at)
end

#price_updated_parent_differential_in_daysObject



60
61
62
# File 'app/presenters/search/product_catalog_presenter.rb', line 60

def price_updated_parent_differential_in_days
  h.pluralize(r.price_updated_parent_differential_in_days.to_i, 'day')
end

#price_with_vatObject



105
106
107
108
# File 'app/presenters/search/product_catalog_presenter.rb', line 105

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_priceObject



64
65
66
67
68
# File 'app/presenters/search/product_catalog_presenter.rb', line 64

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_priceObject



95
96
97
98
# File 'app/presenters/search/product_catalog_presenter.rb', line 95

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_vatObject



110
111
112
113
# File 'app/presenters/search/product_catalog_presenter.rb', line 110

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

#stateObject



19
20
21
22
# File 'app/presenters/search/product_catalog_presenter.rb', line 19

def state
  return unless r.has_columns?(:catalog_item_state)
  "#{r.catalog_item_state}"
end

#store_item_unit_cogsObject



91
92
93
# File 'app/presenters/search/product_catalog_presenter.rb', line 91

def store_item_unit_cogs
  h.number_to_currency(r.store_item_unit_cogs)
end