Browse Source

feat: fix general needs validation behaviour

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

8
app/models/lettings_log.rb

@ -436,16 +436,16 @@ class LettingsLog < Log
end end
def soft_min_for_period def soft_min_for_period
beds = needstype == 2 ? 0 : beds beds = needstype == 2 ? 0 : self.beds
la = needstype == 2 ? Location.find(location_id).location_code : 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
"#{soft_value_for_period(soft_min)} #{SUFFIX_FROM_PERIOD[period].presence || 'every week'}" "#{soft_value_for_period(soft_min)} #{SUFFIX_FROM_PERIOD[period].presence || 'every week'}"
end end
def soft_max_for_period def soft_max_for_period
beds = needstype == 2 ? 0 : beds beds = needstype == 2 ? 0 : self.beds
la = needstype == 2 ? Location.find(location_id).location_code : 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
"#{soft_value_for_period(soft_max)} #{SUFFIX_FROM_PERIOD[period].presence || 'every week'}" "#{soft_value_for_period(soft_max)} #{SUFFIX_FROM_PERIOD[period].presence || 'every week'}"

8
app/models/validations/soft_validations.rb

@ -28,8 +28,8 @@ 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 : beds beds = needstype == 2 ? 0 : self.beds
la = needstype == 2 ? Location.find(location_id).location_code : 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)
rent_range.present? && weekly_value(brent).between?(rent_range.hard_min, rent_range.soft_min) rent_range.present? && weekly_value(brent).between?(rent_range.hard_min, rent_range.soft_min)
@ -38,8 +38,8 @@ 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 : beds beds = needstype == 2 ? 0 : self.beds
la = needstype == 2 ? Location.find(location_id).location_code : 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)
rent_range.present? && weekly_value(brent).between?(rent_range.soft_max, rent_range.hard_max) rent_range.present? && weekly_value(brent).between?(rent_range.soft_max, rent_range.hard_max)

Loading…
Cancel
Save