Skip to content

Commit 8af239c

Browse files
committed
Fix logic
1 parent b6058af commit 8af239c

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

app/services/multi_tenant_service.rb

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,9 +99,13 @@ def filing_years(now = DateTime.now)
9999
if service_type == :ctc || service_type == :state_file
100100
[current_tax_year]
101101
else
102-
Rails.configuration.tax_year_filing_seasons.select do |_, (season_start, _)|
102+
years = Rails.configuration.tax_year_filing_seasons.select do |_, (season_start, _)|
103103
now > season_start - 3.months
104-
end.keys.sort.reverse.take(3).reverse.freeze
104+
end.keys.sort.reverse.take(3)
105+
106+
years += [years.last - 1] if now < Rails.configuration.tax_year_filing_seasons[years.first].last
107+
108+
years.freeze
105109
end
106110
end
107111

spec/services/multi_tenant_service_spec.rb

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,10 @@
4545

4646
it "returns just the current year for ctc and valid filing years for gyr when using DateTime.now" do
4747
fake_time = Rails.configuration.tax_year_filing_seasons[2020][1] + 3.years - 1.day
48+
# this is May 16, 2024 in which the deadline has passes and thus should show 3 years of filing
4849
Timecop.freeze(fake_time) do
4950
expect(described_class.new(:ctc).filing_years).to eq [2023]
50-
expect(described_class.new(:gyr).filing_years).to eq [2023, 2022, 2021, 2020]
51+
expect(described_class.new(:gyr).filing_years).to eq [2023, 2022, 2021]
5152
end
5253
end
5354

@@ -66,19 +67,19 @@
6667
end
6768
end
6869

69-
context "GYR 2025 after tax deadline before end of in progress intake" do
70+
context "GYR 2025 after tax deadline but before end of login" do
7071
it "returns 2022, 2023, 2024" do
7172
fake_time = DateTime.parse("2025-06-23")
7273

7374
expect(described_class.new(:gyr).filing_years(fake_time)).to eq [2024, 2023, 2022]
7475
end
7576
end
7677

77-
context "GYR 2025 after end of in progress intake" do
78-
it "returns 2022, 2023, 2024" do
78+
context "GYR 2025 after end of login" do
79+
it "returns 2022, 2023, 2024 and 2025" do
7980
fake_time = DateTime.parse("2025-12-21")
8081

81-
expect(described_class.new(:gyr).filing_years(fake_time)).to eq [2024, 2023, 2022]
82+
expect(described_class.new(:gyr).filing_years(fake_time)).to eq [2025, 2024, 2023, 2022]
8283
end
8384
end
8485
end

0 commit comments

Comments
 (0)