Module: SalesHelper

Defined in:
app/helpers/sales_helper.rb

Instance Method Summary collapse

Instance Method Details

#door_list_grouped_attribute(door_list_items, attr) ⇒ Object



14
15
16
# File 'app/helpers/sales_helper.rb', line 14

def door_list_grouped_attribute(door_list_items, attr)
  door_list_items.map {|d| d.send(attr)}.uniq.select {|n| n.present? }.to_sentence
end

#door_list_name_and_company(person) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
# File 'app/helpers/sales_helper.rb', line 18

def door_list_name_and_company(person)
  result            = []
  result           << (:strong, person.first_name) if person.first_name.present?
  result           << " #{person.last_name}"                  if person.last_name.present?
  if person.company_name.present?
    result         << ", " if result.any?
    result         << person.company_name
  end

  safe_join(result)
end

#door_list_sort(person) ⇒ Object



2
3
4
5
6
7
8
9
10
11
12
# File 'app/helpers/sales_helper.rb', line 2

def door_list_sort(person)
  result = if person.last_name.present?
    person.last_name
  elsif person.first_name.present?
    person.first_name
  else
    person.email
  end

  result.downcase
end