Class: C80Estate::Area

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
app/models/c80_estate/area.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.all_areasObject



32
33
34
# File 'app/models/c80_estate/area.rb', line 32

def self.all_areas
  self.all
end

.all_areas_sqObject



68
69
70
71
72
73
74
75
76
77
# File 'app/models/c80_estate/area.rb', line 68

def self.all_areas_sq
  sum = 0
  self.all.each do |area|
    area_prop_square = area.item_props.where(:prop_name_id => 9)
    if area_prop_square.present?
      sum += area_prop_square.first.value.to_i
    end
  end
  sum
end

.busy_areasObject



52
53
54
# File 'app/models/c80_estate/area.rb', line 52

def self.busy_areas
  self.joins(:astatuses).where(:c80_estate_astatuses => {tag: 'busy'})
end

.busy_areas_sqObject

посчитает кол-во занятых метров



57
58
59
60
61
62
63
64
65
66
# File 'app/models/c80_estate/area.rb', line 57

def self.busy_areas_sq
  sum = 0
  self.busy_areas.each do |area|
    area_prop_square = area.item_props.where(:prop_name_id => 9)
    if area_prop_square.present?
      sum += area_prop_square.first.value.to_i
    end
  end
  sum
end

.free_areasObject



36
37
38
# File 'app/models/c80_estate/area.rb', line 36

def self.free_areas
  self.joins(:astatuses).where(:c80_estate_astatuses => {tag: 'free'})
end

.free_areas_sqObject

посчитает кол-во свободных метров



41
42
43
44
45
46
47
48
49
50
# File 'app/models/c80_estate/area.rb', line 41

def self.free_areas_sq
  sum = 0
  self.free_areas.each do |area|
    area_prop_square = area.item_props.where(:prop_name_id => 9)
    if area_prop_square.present?
      sum += area_prop_square.first.value.to_i
    end
  end
  sum
end

Instance Method Details

#assigned_person_titleObject



111
112
113
114
115
116
117
# File 'app/models/c80_estate/area.rb', line 111

def assigned_person_title
  res = "-"
  if assigned_person.present?
    res = assigned_person.email
  end
  res
end

#astatus_idObject



103
104
105
106
107
108
109
# File 'app/models/c80_estate/area.rb', line 103

def astatus_id
  res = -1
  if astatuses.count > 0
    res = astatuses.first.id
  end
  res
end

#astatus_titleObject



95
96
97
98
99
100
101
# File 'app/models/c80_estate/area.rb', line 95

def astatus_title
  res = "-"
  if astatuses.count > 0
    res = astatuses.first.title
  end
  res
end

#atype_titleObject



79
80
81
82
83
84
85
# File 'app/models/c80_estate/area.rb', line 79

def atype_title
  res = "-"
  if atype.present?
    res = atype.title
  end
  res
end

#owner_idObject



119
120
121
122
123
124
125
# File 'app/models/c80_estate/area.rb', line 119

def owner_id
  res = -1
  if owner.present?
    res = owner.id
  end
  res
end

#property_titleObject



87
88
89
90
91
92
93
# File 'app/models/c80_estate/area.rb', line 87

def property_title
  res = "-"
  if property.present?
    res = property.title
  end
  res
end