Class: ClientEngine::Client

Inherits:
ApplicationRecord show all
Defined in:
app/models/client_engine/client.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.search(term) ⇒ Object

Metodo de busqueda de clientes por nombre, apellido o documento



20
21
22
23
24
25
26
# File 'app/models/client_engine/client.rb', line 20

def self.search term
	if term
  		where("LOWER(client_engine_clients.first_name || ' ' || client_engine_clients.last_name) LIKE LOWER(?) OR  client_engine_clients.document LIKE ?", "%#{term}%", "%#{term}%")
	else
  		all
	end
end

Instance Method Details

#addressObject



11
12
13
# File 'app/models/client_engine/client.rb', line 11

def address
	read_attribute(:address).titleize unless read_attribute(:address).nil?
end

#full_addressObject



15
16
17
# File 'app/models/client_engine/client.rb', line 15

def full_address
  "#{address}.  - #{locality.titleize} - #{city.titleize} - #{country.titleize}"
end

#nameObject



7
8
9
# File 'app/models/client_engine/client.rb', line 7

def name
	"#{last_name.titleize}, #{first_name.titleize}"
end