Browse Source

feat: ensure case when beds > 4 is accounted for

pull/959/head
natdeanlewissoftwire 3 years ago
parent
commit
8ac98f9f1b
  1. 4
      app/models/lettings_log.rb
  2. 2
      app/models/validations/financial_validations.rb
  3. 4
      app/models/validations/soft_validations.rb

4
app/models/lettings_log.rb

@ -436,7 +436,7 @@ class LettingsLog < Log
end end
def soft_min_for_period def soft_min_for_period
beds = needstype == 2 ? 0 : self.beds beds = needstype == 2 ? 0 : [self.beds, 4].min
la = needstype == 2 ? Location.find(location_id).location_code : self.la la = needstype == 2 ? Location.find(location_id).location_code : self.la
soft_min = LaRentRange.find_by(start_year: collection_start_year, la:, beds:, lettype:).soft_min soft_min = LaRentRange.find_by(start_year: collection_start_year, la:, beds:, lettype:).soft_min
@ -444,7 +444,7 @@ class LettingsLog < Log
end end
def soft_max_for_period def soft_max_for_period
beds = needstype == 2 ? 0 : self.beds beds = needstype == 2 ? 0 : [self.beds, 4].min
la = needstype == 2 ? Location.find(location_id).location_code : self.la la = needstype == 2 ? Location.find(location_id).location_code : self.la
soft_max = LaRentRange.find_by(start_year: collection_start_year, la:, beds:, lettype:).soft_max soft_max = LaRentRange.find_by(start_year: collection_start_year, la:, beds:, lettype:).soft_max

2
app/models/validations/financial_validations.rb

@ -182,7 +182,7 @@ private
collection_year = record.collection_start_year collection_year = record.collection_start_year
beds = record.needstype == 2 ? 0 : record.beds beds = record.needstype == 2 ? 0 : [record.beds, 4].min
la = record.needstype == 2 ? Location.find(record.location_id).location_code : record.la la = record.needstype == 2 ? Location.find(record.location_id).location_code : record.la
rent_range = LaRentRange.find_by(start_year: collection_year, la:, beds:, lettype: record.lettype) rent_range = LaRentRange.find_by(start_year: collection_year, la:, beds:, lettype: record.lettype)

4
app/models/validations/soft_validations.rb

@ -28,7 +28,7 @@ module Validations::SoftValidations
def rent_in_soft_min_range? def rent_in_soft_min_range?
return unless brent && weekly_value(brent) && startdate return unless brent && weekly_value(brent) && startdate
beds = needstype == 2 ? 0 : self.beds beds = needstype == 2 ? 0 : [self.beds, 4].min
la = needstype == 2 ? Location.find(location_id).location_code : self.la la = needstype == 2 ? Location.find(location_id).location_code : self.la
rent_range = LaRentRange.find_by(start_year: collection_start_year, la:, beds:, lettype: get_lettype) rent_range = LaRentRange.find_by(start_year: collection_start_year, la:, beds:, lettype: get_lettype)
@ -38,7 +38,7 @@ module Validations::SoftValidations
def rent_in_soft_max_range? def rent_in_soft_max_range?
return unless brent && weekly_value(brent) && startdate return unless brent && weekly_value(brent) && startdate
beds = needstype == 2 ? 0 : self.beds beds = needstype == 2 ? 0 : [self.beds, 4].min
la = needstype == 2 ? Location.find(location_id).location_code : self.la la = needstype == 2 ? Location.find(location_id).location_code : self.la
rent_range = LaRentRange.find_by(start_year: collection_start_year, la:, beds:, lettype: get_lettype) rent_range = LaRentRange.find_by(start_year: collection_start_year, la:, beds:, lettype: get_lettype)

Loading…
Cancel
Save