Class: Search::ProductCatalogPresenter

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

Overview

Presenter: product catalog presenter.

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



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

def catalog
  return unless r.has_columns?(:catalog_name, :catalog_id)

  h.link_to(r.catalog_name, h.catalog_path(r.catalog_id))
end


16
17
18
19
20
# File 'app/presenters/search/product_catalog_presenter.rb', line 16

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



107
108
109
110
111
# File 'app/presenters/search/product_catalog_presenter.rb', line 107

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



125
126
127
128
129
# File 'app/presenters/search/product_catalog_presenter.rb', line 125

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



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

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



76
77
78
79
80
# File 'app/presenters/search/product_catalog_presenter.rb', line 76

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



82
83
84
85
86
87
88
89
90
91
# File 'app/presenters/search/product_catalog_presenter.rb', line 82

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



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

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



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

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



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

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



62
63
64
# File 'app/presenters/search/product_catalog_presenter.rb', line 62

def parent_price_updated_at
  h.render_date(r.parent_price_updated_at)
end

#priceObject



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

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

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

#price_differenceObject



93
94
95
# File 'app/presenters/search/product_catalog_presenter.rb', line 93

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

#price_difference_factorObject



131
132
133
134
135
136
137
138
139
140
141
142
# File 'app/presenters/search/product_catalog_presenter.rb', line 131

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



58
59
60
# File 'app/presenters/search/product_catalog_presenter.rb', line 58

def price_updated_at
  h.render_date(r.price_updated_at)
end

#price_updated_parent_differential_in_daysObject



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

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

#price_with_vatObject



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

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



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

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



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

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



119
120
121
122
123
# File 'app/presenters/search/product_catalog_presenter.rb', line 119

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



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

def state
  return unless r.has_columns?(:catalog_item_state)

  r.catalog_item_state.to_s
end

#store_item_unit_cogsObject



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

def store_item_unit_cogs
  h.number_to_currency(r.store_item_unit_cogs)
end