1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
class Store < ActiveRecord::Base
attr_accessible :name, :phone, :address, :city, :province, :country, :units_on_hand, :geoloc, :heat, :highrise_id, :postal_code, :attn
has_many :store_product_quantity_checks
has_many :orders, :foreign_key=>:shipping_store_id
has_many :managers
has_many :product_store_daily_stocking_levels
def highrise_company
unless self.highrise_id.nil?
begin
return Highrise::Company.find(self.highrise_id)
rescue
return nil
end
else
return nil
end
end
def name_and_location
"#{self.name} - #{self.city} #{self.province}"
end
def load_from_highrise_company
hc = self.highrise_company
hca = hc.contact_data.addresses[0]
self.name = hc.name
self.address = hca.street
self.city = hca.city
self.province = hca.state
self.country = hca.country
self.postal_code = hca.zip
self.save
end
end
|