|
|
|
@ -182,18 +182,19 @@ private
|
|
|
|
|
|
|
|
|
|
collection_year = record.collection_start_year |
|
|
|
|
|
|
|
|
|
beds = if record.needstype == 2 |
|
|
|
|
0 |
|
|
|
|
else |
|
|
|
|
record.beds.nil? ? nil : [record.beds, 4].min |
|
|
|
|
end |
|
|
|
|
la = if record.needstype == 2 |
|
|
|
|
defined?(record.location.location_code) ? record.location.location_code : nil |
|
|
|
|
else |
|
|
|
|
record.la |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
rent_range = LaRentRange.find_by(start_year: collection_year, la:, beds:, lettype: record.lettype) |
|
|
|
|
max_beds_in_rent_ranges = 4 |
|
|
|
|
validation_beds = if record.needstype == 2 |
|
|
|
|
0 |
|
|
|
|
else |
|
|
|
|
record.beds.nil? ? nil : [record.beds, max_beds_in_rent_ranges].min |
|
|
|
|
end |
|
|
|
|
validation_la = if record.needstype == 2 |
|
|
|
|
defined?(record.location.location_code) ? record.location.location_code : nil |
|
|
|
|
else |
|
|
|
|
record.la |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
rent_range = LaRentRange.find_by(start_year: collection_year, la: validation_la, beds: validation_beds, lettype: record.lettype) |
|
|
|
|
|
|
|
|
|
if rent_range.present? && !weekly_value_in_range(record, "brent", rent_range.hard_min, rent_range.hard_max) && record.brent.present? && record.period.present? |
|
|
|
|
if record.weekly_value(record["brent"]) < rent_range.hard_min |
|
|
|
@ -206,7 +207,7 @@ private
|
|
|
|
|
record.errors.add :rent_type, I18n.t("validations.financial.brent.rent_type.below_hard_min") |
|
|
|
|
record.errors.add :needstype, I18n.t("validations.financial.brent.needstype.below_hard_min") |
|
|
|
|
record.errors.add :period, I18n.t("validations.financial.brent.period.below_hard_min") |
|
|
|
|
else |
|
|
|
|
elsif !(record.needstype == 1 && record.beds > max_beds_in_rent_ranges) |
|
|
|
|
record.errors.add :brent, I18n.t("validations.financial.brent.above_hard_max") |
|
|
|
|
record.errors.add :beds, I18n.t("validations.financial.brent.beds.above_hard_max") |
|
|
|
|
record.errors.add :la, I18n.t("validations.financial.brent.la.above_hard_max") |
|
|
|
|