app/models/c80_estate/property.rb in c80_estate-0.1.0.37 vs app/models/c80_estate/property.rb in c80_estate-0.1.0.38

- old
+ new

@@ -60,11 +60,13 @@ sum = 0.0 c = self.all.count if c > 0 self.all.each do |prop| - sum += prop.average_price(atype_id:atype_id) + if prop.average_price.present? + sum += prop.average_price(atype_id: atype_id) + end end res = sum / c end res @@ -78,11 +80,13 @@ sum = 0.0 c = self.all.count if c > 0 self.all.each do |prop| - sum += prop.average_price_busy(atype_id:atype_id) + if prop.average_price_busy.present? + sum += prop.average_price_busy(atype_id: atype_id) + end end res = sum / c end res @@ -109,11 +113,13 @@ end price_sum = 0.0 ars.each do |area| - price_sum += area.price_value + if area.price_value.present? + price_sum += area.price_value + end end if ars.count != 0 price_sum*1.0 / ars.count else @@ -136,11 +142,13 @@ price_sum = 0.0 ars.each do |area| if area.is_busy? busy_areas_count += 1 - price_sum += area.price_value + if area.price_value.present? + price_sum += area.price_value + end end end if busy_areas_count != 0 price_sum*1.0 / busy_areas_count @@ -191,18 +199,22 @@ end def square_value sum = 0.0 areas.all.each do |area| - sum += area.square_value + if area.square_value.present? + sum += area.square_value + end end sum end def power_price_value sum = 0.0 areas.all.each do |area| - sum += area.power_price_value + if area.power_price_value.present? + sum += area.power_price_value + end end sum end end \ No newline at end of file