Class: Workarea::Search::Admin::LegacyOrder

Inherits:
Workarea::Search::Admin show all
Defined in:
app/models/workarea/search/admin/legacy_order.rb

Instance Method Summary collapse

Instance Method Details

#addresses_textObject



55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# File 'app/models/workarea/search/admin/legacy_order.rb', line 55

def addresses_text
  [model.shipping_address, model.billing_address].map do |address|
    [
      address.first_name,
      address.last_name,
      address.company,
      address.street,
      address.street_2,
      address.city,
      address.region,
      address.postal_code,
      address.country,
      address.phone_number
    ]
  end.flatten
end

#as_documentObject



48
49
50
51
52
53
# File 'app/models/workarea/search/admin/legacy_order.rb', line 48

def as_document
  super.merge(
    total_price: model.total_price.to_f,
    placed_at: model.placed_at
  )
end

#facetsObject



44
45
46
# File 'app/models/workarea/search/admin/legacy_order.rb', line 44

def facets
  super.merge(order_status: model.status)
end

#jump_to_positionObject



40
41
42
# File 'app/models/workarea/search/admin/legacy_order.rb', line 40

def jump_to_position
  3
end

#jump_to_textObject



32
33
34
35
36
37
38
# File 'app/models/workarea/search/admin/legacy_order.rb', line 32

def jump_to_text
  if model.placed?
    "#{model.id} - Placed @ #{model.placed_at.to_s(:short)}"
  else
    "#{model.id} - #{model.status.to_s.titleize}"
  end
end

#keywordsObject



28
29
30
# File 'app/models/workarea/search/admin/legacy_order.rb', line 28

def keywords
  super + [model.email, model.alternate_number]
end

#nameObject



5
6
7
8
9
10
11
# File 'app/models/workarea/search/admin/legacy_order.rb', line 5

def name
  if model.billing_address.present?
    model.billing_address.name
  else
    model.name
  end
end

#search_textObject



13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'app/models/workarea/search/admin/legacy_order.rb', line 13

def search_text
  [
    'order',
    model.id,
    model.status,
    model.email,
    model.customer_number,
    model.alternate_number,
    model.items.map { |i| "#{i.product_id} #{i.sku}" },
    model.shipping_method,
    addresses_text,
    tenders_text
  ].flatten.join(' ')
end

#tenders_textObject



72
73
74
75
76
# File 'app/models/workarea/search/admin/legacy_order.rb', line 72

def tenders_text
  model.tenders.map do |tender|
    [tender.issuer, tender.type]
  end.flatten
end