From 63fb3b06b3bb46281811a528da123378d3972b4e Mon Sep 17 00:00:00 2001 From: Carolyn Date: Mon, 10 Mar 2025 17:56:44 +0000 Subject: [PATCH] don't use variables from the future --- app/services/csv/lettings_log_csv_service.rb | 2 +- app/services/csv/sales_log_csv_service.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/services/csv/lettings_log_csv_service.rb b/app/services/csv/lettings_log_csv_service.rb index 0a187d524..edf1b7edf 100644 --- a/app/services/csv/lettings_log_csv_service.rb +++ b/app/services/csv/lettings_log_csv_service.rb @@ -289,7 +289,7 @@ module Csv exact_match = options.find { |definition| definition.year == @year } next exact_match if exact_match - options.max_by(&:year) + options.select { |opt| opt.year < @year }.max_by(&:year) end end diff --git a/app/services/csv/sales_log_csv_service.rb b/app/services/csv/sales_log_csv_service.rb index 08ce178e3..e30202e8b 100644 --- a/app/services/csv/sales_log_csv_service.rb +++ b/app/services/csv/sales_log_csv_service.rb @@ -184,7 +184,7 @@ module Csv exact_match = options.find { |definition| definition.year == @year } next exact_match if exact_match - options.max_by(&:year) + options.select { |opt| opt.year < @year }.max_by(&:year) end end