From 7edaf098c061c9ec6a2feefd7e54dc1c34be7738 Mon Sep 17 00:00:00 2001 From: natdeanlewissoftwire Date: Tue, 1 Nov 2022 11:16:07 +0000 Subject: [PATCH] feat: fix general needs validation behaviour --- app/models/lettings_log.rb | 8 ++++---- app/models/validations/soft_validations.rb | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/app/models/lettings_log.rb b/app/models/lettings_log.rb index 7c437f046..27d9b0d21 100644 --- a/app/models/lettings_log.rb +++ b/app/models/lettings_log.rb @@ -436,16 +436,16 @@ class LettingsLog < Log end def soft_min_for_period - beds = needstype == 2 ? 0 : beds - la = needstype == 2 ? Location.find(location_id).location_code : la + beds = needstype == 2 ? 0 : self.beds + 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_value_for_period(soft_min)} #{SUFFIX_FROM_PERIOD[period].presence || 'every week'}" end def soft_max_for_period - beds = needstype == 2 ? 0 : beds - la = needstype == 2 ? Location.find(location_id).location_code : la + beds = needstype == 2 ? 0 : self.beds + 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_value_for_period(soft_max)} #{SUFFIX_FROM_PERIOD[period].presence || 'every week'}" diff --git a/app/models/validations/soft_validations.rb b/app/models/validations/soft_validations.rb index c932e42cb..7a9635fd2 100644 --- a/app/models/validations/soft_validations.rb +++ b/app/models/validations/soft_validations.rb @@ -28,8 +28,8 @@ module Validations::SoftValidations def rent_in_soft_min_range? return unless brent && weekly_value(brent) && startdate - beds = needstype == 2 ? 0 : beds - la = needstype == 2 ? Location.find(location_id).location_code : la + beds = needstype == 2 ? 0 : self.beds + 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.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? return unless brent && weekly_value(brent) && startdate - beds = needstype == 2 ? 0 : beds - la = needstype == 2 ? Location.find(location_id).location_code : la + beds = needstype == 2 ? 0 : self.beds + 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.present? && weekly_value(brent).between?(rent_range.soft_max, rent_range.hard_max)