Skip to content

Commit

Permalink
FYST-909 W2 UI Updates (#4932)
Browse files Browse the repository at this point in the history
  • Loading branch information
tahsinaislam authored Oct 30, 2024
1 parent 16c9a13 commit 29f5aa3
Show file tree
Hide file tree
Showing 12 changed files with 166 additions and 34 deletions.
1 change: 1 addition & 0 deletions app/controllers/state_file/questions/w2_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ def form_params

def load_w2
@w2 = current_intake.state_file_w2s.find(params[:id])
@box14_codes = StateFile::StateInformationService.w2_supported_box14_codes(current_state_code)
end
end
end
Expand Down
4 changes: 4 additions & 0 deletions app/models/state_file_w2.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
# Table name: state_file_w2s
#
# id :bigint not null, primary key
# box14_stpickup :decimal(12, 2)
# employee_name :string
# employee_ssn :string
# employer_name :string
Expand Down Expand Up @@ -79,6 +80,9 @@ def validate_tax_amts
errors.add(:local_income_tax_amount, I18n.t("state_file.questions.w2.edit.wages_amt_error", wages_amount: w2.WagesAmt))
errors.add(:state_income_tax_amount, I18n.t("state_file.questions.w2.edit.wages_amt_error", wages_amount: w2.WagesAmt))
end
if state_wages_amount.present? && state_wages_amount > w2.WagesAmt
errors.add(:state_wages_amount, I18n.t("state_file.questions.w2.edit.state_wages_exceed_amt_error", wages_amount: w2.WagesAmt))
end
end
end

Expand Down
14 changes: 14 additions & 0 deletions app/services/state_file/state_information_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ class StateInformationService
:vita_link,
:voucher_form_name,
:voucher_path,
:w2_supported_box14_codes,
:w2_include_local_income_boxes,
].freeze

class << self
Expand Down Expand Up @@ -74,6 +76,8 @@ def state_intake_class_names
vita_link: "https://airtable.com/appnKuyQXMMCPSvVw/pag0hcyC6juDxamHo/form",
voucher_form_name: "Form AZ-140V",
voucher_path: "/pdfs/AZ-140V.pdf",
w2_supported_box14_codes: [],
w2_include_local_income_boxes: false
},
id: {
intake_class: StateFileIdIntake,
Expand All @@ -94,6 +98,8 @@ def state_intake_class_names
vita_link: "",
voucher_form_name: "",
voucher_path: "",
w2_supported_box14_codes: [],
w2_include_local_income_boxes: false
},
md: {
intake_class: StateFileMdIntake,
Expand All @@ -114,6 +120,8 @@ def state_intake_class_names
vita_link: "",
voucher_form_name: "",
voucher_path: "",
w2_supported_box14_codes: ["STPICKUP"],
w2_include_local_income_boxes: true
},
nc: {
intake_class: StateFileNcIntake,
Expand All @@ -136,6 +144,8 @@ def state_intake_class_names
vita_link: "",
voucher_form_name: "Form D-400V",
voucher_path: "/pdfs/d400v-TY2023.pdf",
w2_supported_box14_codes: [],
w2_include_local_income_boxes: false
},
nj: {
intake_class: StateFileNjIntake,
Expand All @@ -158,6 +168,8 @@ def state_intake_class_names
vita_link: "",
voucher_form_name: "NJ Voucher Form",
voucher_path: "",
w2_supported_box14_codes: [],
w2_include_local_income_boxes: false
},
ny: {
intake_class: StateFileNyIntake,
Expand All @@ -181,6 +193,8 @@ def state_intake_class_names
vita_link: "https://airtable.com/appQS3abRZGjT8wII/pagtpLaX0wokBqnuA/form",
voucher_form_name: "Form IT-201-V",
voucher_path: "/pdfs/it201v_1223.pdf",
w2_supported_box14_codes: [],
w2_include_local_income_boxes: false
}
}.with_indifferent_access)
end
Expand Down
60 changes: 44 additions & 16 deletions app/views/state_file/questions/w2/edit.html.erb
Original file line number Diff line number Diff line change
@@ -1,15 +1,27 @@
<% content_for :card do %>
<h1 class="form-question"><%= t(".instructions_1", employer_name: @employer_name , total_wages_amt: number_to_currency(@wages_amt)) %></h1>
<h2 class="form-question"><%= t(".instructions_2") %></h2>
<h1 class="form-question"><%= t(".instructions_1_html", employer: @w2.employer_name) %></h1>
<%= form_with model: @w2, url: { action: :update }, method: :patch, local: true, builder: VitaMinFormBuilder, html: { class: 'form-card form-card--long' } do |f| %>
<% if params[:return_to_review].present? %>
<%= hidden_field_tag "return_to_review", params[:return_to_review] %>
<% end %>
<div class="white-group">
<div class="form-question spacing-below-25">
<div class="text--bold spacing-below-15"><%=t("general.state") %></div>
<div><%= current_state_name %></div>
</div>
<p class="text--bold spacing-below-5"><%= @w2.employee_name %></p>
<p class="spacing-below-25"><%= @w2.employer_name %></p>

<% if @box14_codes.present? %>
<p class="spacing-below-5"><%= t(".box14_html") %></p>
<% @box14_codes.each do |code| %>
<div class="form-question spacing-below-25">
<% field_name = "box14_#{code.downcase}" %>
<%= f.vita_min_money_field(
field_name.to_sym,
t(".box14_#{code.downcase}_html"),
classes: ["form-width--long"]
) %>
<%= t(".box14_#{code.downcase}_help_text", year: MultiTenantService.statefile.current_tax_year) %>
</div>
<% end %>
<% end %>
<div class="form-question spacing-below-25">
<%= f.cfa_input_field(:employer_state_id_num, t(".box15_html"), classes: ["form-width--long"]) %>
</div>
Expand All @@ -19,18 +31,34 @@
<div class="form-question spacing-below-25">
<%= f.vita_min_money_field(:state_income_tax_amount, t(".box17_html"), classes: ["form-width--long"]) %>
</div>
<div class="form-question spacing-below-25">
<%= f.vita_min_money_field(:local_wages_and_tips_amount, t(".box18_html"), classes: ["form-width--long"]) %>
</div>
<div class="form-question spacing-below-25">
<%= f.vita_min_money_field(:local_income_tax_amount, t(".box19_html"), classes: ["form-width--long"]) %>
</div>
<div class="form-question spacing-below-25 ny-w2-locality-nm">
<%= f.cfa_input_field(:locality_nm, t(".box20_locality_name"), classes: ["form-width--long"]) %>
</div>
<% if StateFile::StateInformationService.w2_include_local_income_boxes(current_state_code) %>
<div class="form-question spacing-below-25">
<%= f.vita_min_money_field(:local_wages_and_tips_amount, t(".box18_html"), classes: ["form-width--long"]) %>
</div>
<div class="form-question spacing-below-25">
<%= f.vita_min_money_field(:local_income_tax_amount, t(".box19_html"), classes: ["form-width--long"]) %>
</div>
<div class="form-question spacing-below-25 ny-w2-locality-nm">
<%= f.cfa_input_field(:locality_nm, t(".box20_locality_name"), classes: ["form-width--long"]) %>
</div>
<% end %>
</div>

<% if @box14_codes.present? %>
<div class="reveal spacing-above-35">
<p><a href="#" class="reveal__link"><%= t(".what_is_box14") %></a></p>
<div class="reveal__content">
<% @box14_codes.each do |code| %>
<p class="spacing-below-15">
<%= t(".box14_#{code.downcase}_explanation_html", year: MultiTenantService.statefile.current_tax_year) %>
</p>
<% end %>
</div>
</div>
<% end %>

<button class="button button--primary button--wide" type="submit">
<%= t("general.continue") %>
<%= t(".save_and_continue") %>
</button>
<% end %>
<% end %>
24 changes: 14 additions & 10 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3102,23 +3102,27 @@ en:
verification_code_label: Enter the 6-digit code
w2:
edit:
box15_html: |
<strong>Box 15</strong>: Employer’s State ID number<br />
If Box 15 is blank on your W-2, enter the number from <strong>Box b Employer Identification number (EIN)</strong> here instead.
box16_html: "<strong>Box 16</strong>: State wages, tips, etc."
box17_html: "<strong>Box 17</strong>: State income tax"
box18_html: "<strong>Box 18</strong>: Local wages, tips, etc."
box19_html: "<strong>Box 19</strong>: Local income tax"
box20_locality_name: "<strong>Box 20</strong>: Locality name"
box14_html: "<strong>Box 14,</strong> Other"
box14_stpickup_explanation_html: For tax year %{year}, we will only process the <strong>STPICKUP</strong> code, which represents any contributions you made to the state retirement system.
box14_stpickup_help_text: For tax year %{year}, we will only process the STPICKUP code. If you do not see this code or have other codes in Box 14, please leave it blank.
box14_stpickup_html: "<strong>STPICKUP</strong>"
box15_html: "<strong>Box 15,</strong> Employer’s State ID number"
box16_html: "<strong>Box 16,</strong> State wages, tips, etc."
box17_html: "<strong>Box 17,</strong> State income tax"
box18_html: "<strong>Box 18,</strong> Local wages, tips, etc."
box19_html: "<strong>Box 19,</strong> Local income tax"
box20_locality_name: "<strong>Box 20,</strong> Locality name"
employer_state_id_error: EIN must be a number. Do not include a dash.
instructions_1: Please review the information below and make sure it matches the state and local taxes on your W-2 from %{employer_name} for %{total_wages_amt}.
instructions_2: If any of these boxes are blank on your W-2, leave them blank here.
instructions_1_html: Please review your state income details for <strong>%{employer}</strong>
local_income_tax_amt_error: Cannot be greater than local wages and tips.
local_wages_and_tips_amt_error: Please enter local wages and tips
locality_nm_missing_error: Please select locality name
save_and_continue: Save and Continue
state_income_tax_amt_error: Cannot be greater than State wages and tips.
state_wages_amt_error: Please enter State wages and tips
state_wages_exceed_amt_error: Total state wages and tips cannot be greater than $%{wages_amount}
wages_amt_error: Total income tax cannot be greater than $%{wages_amount}
what_is_box14: What could be in Box 14?
waiting_to_load_data:
edit:
title_html: Just a moment, we’re transferring your federal tax return to complete parts of your state return. <br/><br/> This usually takes a few minutes. Don’t close this page.
Expand Down
14 changes: 9 additions & 5 deletions config/locales/es.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3091,23 +3091,27 @@ es:
verification_code_label: Ingresa el código de 6 dígitos
w2:
edit:
box15_html: |
<strong>Box 15</strong>: Número de identificación del estado del empleador<br />
Si Box 15 está en blanco en tu W-2, ingresa el número de la <strong>Box b Número de identificación del empleador (EIN)</strong> aquí en su lugar.
box14_html: "<strong>Casilla 14,</strong> Otros"
box14_stpickup_explanation_html: Para el año fiscal %{year}, solo procesaremos el código <strong>STPICKUP</strong>, que representa cualquier contribución que hayas hecho al sistema de jubilación estatal.
box14_stpickup_help_text: Para el año fiscal %{year}, solo procesaremos el código STPICKUP. Si no ves este código o tienes otros códigos en la Casilla 14, déjala en blanco.
box14_stpickup_html: "<strong>STPICKUP</strong>"
box15_html: "<strong>Box 15</strong>: Número de identificación del estado del empleador"
box16_html: "<strong>Box 16</strong>: Salarios estatales, propinas, etc."
box17_html: "<strong>Box 17</strong>: Impuesto sobre la renta estatal"
box18_html: "<strong>Box 18</strong>: Salarios locales, propinas, etc."
box19_html: "<strong>Box 19</strong>: Impuesto sobre la renta local"
box20_locality_name: "<strong>Box 20</strong>: Nombre de la localidad"
employer_state_id_error: El EIN debe ser un número. No incluya un guión.
instructions_1: Revise la información a continuación y asegúrese de que coincida con los impuestos estatales y locales en su W-2 de %{employer_name} a %{total_wages_amt}.
instructions_2: Si alguna de estas casillas está en blanco en tu W-2, déjalas en blanco aquí.
instructions_1_html: Revisa los detalles de tus ingresos estatales para <strong>%{employer}</strong>
local_income_tax_amt_error: No puede ser mayor que los salarios y propinas locales.
local_wages_and_tips_amt_error: Ingresa los salarios y propinas locales
locality_nm_missing_error: Selecciona el nombre de la localidad
save_and_continue: Guardar y Continuar
state_income_tax_amt_error: No puede ser mayor que los salarios y propinas estatales.
state_wages_amt_error: Ingresa los salarios y propinas estatales
state_wages_exceed_amt_error: El total de salarios e ingresos estatales no puede ser mayor que $%{wages_amount}
wages_amt_error: El impuesto sobre la renta total no puede ser mas de $%{wages_amount}
what_is_box14: "¿Qué podría haber en la Casilla 14?"
waiting_to_load_data:
edit:
title_html: Un momento, estamos transfiriendo tu declaración de impuestos federales para completar partes de tu declaración estatales. <br/><br/> Esto suele tomar unos minutos. No cierres la página.
Expand Down
5 changes: 5 additions & 0 deletions db/migrate/20241028204525_add_model_box14_to_state_file_w2.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class AddModelBox14ToStateFileW2 < ActiveRecord::Migration[7.1]
def change
add_column :state_file_w2s, :box14_stpickup, :decimal, precision: 12, scale: 2
end
end
1 change: 1 addition & 0 deletions db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2250,6 +2250,7 @@
end

create_table "state_file_w2s", force: :cascade do |t|
t.decimal "box14_stpickup", precision: 12, scale: 2
t.datetime "created_at", null: false
t.string "employee_name"
t.string "employee_ssn"
Expand Down
69 changes: 69 additions & 0 deletions spec/controllers/state_file/questions/w2_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
id: state_file_w2.id,
state_file_w2: {
employer_state_id_num: "12345",
box14_stpickup: 230,
state_wages_amount: 10000,
state_income_tax_amount: 500,
local_wages_and_tips_amount: 40,
Expand All @@ -23,6 +24,52 @@
describe "#edit" do
render_views

context "when state has Box 14 codes" do
let(:intake) { create :state_file_md_intake }

it "shows Box 14 fields" do
get :edit, params: params

expect(response.body).to include("Box 14")
expect(response.body).to include("What could be in Box 14?")
end
end

context "when state does not have Box 14 codes" do
let(:intake) { create :state_file_az_intake }

it "does not show Box 14 fields" do
get :edit, params: params

expect(response.body).not_to include("Box 14")
expect(response.body).not_to include("What could be in Box 14?")
end
end

context "when state includes local income boxes" do
let(:intake) { create :state_file_md_intake }

it "shows local income boxes" do
get :edit, params: params

expect(response.body).to include("Box 18")
expect(response.body).to include("Box 19")
expect(response.body).to include("Box 20")
end
end

context "when state does not include local income boxes" do
let(:intake) { create :state_file_az_intake }

it "does not show local income boxes" do
get :edit, params: params

expect(response.body).not_to include("Box 18")
expect(response.body).not_to include("Box 19")
expect(response.body).not_to include("Box 20")
end
end

it "shows the correct w2's attributes" do
get :edit, params: params

Expand All @@ -40,6 +87,7 @@
state_file_w2.reload
expect(state_file_w2.state_file_intake).to eq intake
expect(state_file_w2.employer_state_id_num).to eq "12345"
expect(state_file_w2.box14_stpickup).to eq 230
expect(state_file_w2.state_wages_amount).to eq 10000
expect(state_file_w2.state_income_tax_amount).to eq 500
expect(state_file_w2.local_wages_and_tips_amount).to eq 40
Expand All @@ -49,6 +97,27 @@
expect(response).to redirect_to(StateFile::Questions::IncomeReviewController.to_path_helper)
end

context "with Box 14 fields" do
let(:intake) { create :state_file_md_intake }
let(:params) do
{
id: state_file_w2.id,
state_file_w2: {
employer_state_id_num: "12345",
state_wages_amount: 10000,
state_income_tax_amount: 500,
box14_stpickup: 230
}
}
end

it "updates Box 14 fields" do
post :update, params: params
state_file_w2.reload
expect(state_file_w2.box14_stpickup).to eq 230
end
end

context "hacking" do
let(:params_with_intake_id) do
params.merge(
Expand Down
3 changes: 2 additions & 1 deletion spec/factories/state_file_w2s.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
# Table name: state_file_w2s
#
# id :bigint not null, primary key
# box14_stpickup :decimal(12, 2)
# employee_name :string
# employee_ssn :string
# employer_name :string
Expand All @@ -28,7 +29,7 @@
employee_name { "Jajko" }
employer_name { "Biszkoptowy Enterprises" }
employer_state_id_num { "12345" }
state_wages_amount { 10000 }
state_wages_amount { 1000 }
state_income_tax_amount { 350 }
local_wages_and_tips_amount { 100 }
local_income_tax_amount { 100 }
Expand Down
4 changes: 2 additions & 2 deletions spec/features/state_file/editing_df_xml_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
fill_in "Return header phone number (primary)", with: "5551112222"

# W2
fill_in "WagesAmt", with: 500
fill_in "WagesAmt", with: 1500
fill_in "WithholdingAmt", with: 300
fill_in "StateWagesAmt", with: 1000
fill_in "StateIncomeTaxAmt", with: 100
Expand Down Expand Up @@ -98,7 +98,7 @@

expect(StateFileAzIntake.last.direct_file_data.interest_reported_amount).to eq 200

expect(StateFileAzIntake.last.direct_file_data.w2s[0].WagesAmt).to eq 500
expect(StateFileAzIntake.last.direct_file_data.w2s[0].WagesAmt).to eq 1500
expect(StateFileAzIntake.last.direct_file_data.w2s[0].WithholdingAmt).to eq 300
expect(StateFileAzIntake.last.direct_file_data.w2s[0].StateWagesAmt).to eq 1000
expect(StateFileAzIntake.last.direct_file_data.w2s[0].StateIncomeTaxAmt).to eq 100
Expand Down
1 change: 1 addition & 0 deletions spec/models/state_file_w2_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
# Table name: state_file_w2s
#
# id :bigint not null, primary key
# box14_stpickup :decimal(12, 2)
# employee_name :string
# employee_ssn :string
# employer_name :string
Expand Down

0 comments on commit 29f5aa3

Please sign in to comment.