Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix indexing bug #187136591 #4308

Merged
merged 2 commits into from
Mar 5, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions app/controllers/state_file/questions/ny_w2_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ module StateFile
module Questions
class NyW2Controller < AuthenticatedQuestionsController
before_action :load_w2s
before_action :load_w2, only: [:edit, :update]

def self.show?(intake)
Flipper.enabled?(:w2_override) && invalid_w2s(intake).any?
Expand All @@ -19,14 +20,12 @@ def index
end

def edit
@w2 = @w2s[params[:id].to_i]
dfw2 = @w2.state_file_intake.direct_file_data.w2s[@w2.w2_index]
@employer_name = dfw2.EmployerName
@wages_amt = dfw2.WagesAmt
end

def update
@w2 = @w2s[params[:id].to_i]
@w2.assign_attributes(form_params)

if @w2.valid?
Expand All @@ -51,6 +50,11 @@ def load_w2s
@w2s = self.class.w2s_for_intake(current_intake)
end

def load_w2
w2_index = params[:id].to_i
@w2 = @w2s.detect { |w2| w2.w2_index == w2_index }
end

def self.w2s_for_intake(intake)
(intake.direct_file_data.w2s.each_with_index.map do |w2, index|
if invalid_w2?(intake, w2)
Expand Down
Loading