Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into FYST-818-md-military-…
Browse files Browse the repository at this point in the history
…retirement-subtraction

Co-authored-by: Tahsina Islam <[email protected]>
  • Loading branch information
anisharamnani and tahsinaislam committed Feb 7, 2025
2 parents 563742e + 3c2dfe4 commit 371fab2
Show file tree
Hide file tree
Showing 34 changed files with 751 additions and 275 deletions.
1 change: 1 addition & 0 deletions app/controllers/flows_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -665,6 +665,7 @@ def self.az_attributes(first_name: 'Testuser', last_name: 'Testuser', filing_sta
email_notification_opt_in: "yes",
phone_number: "+15005550006",
sms_notification_opt_in: "yes",
made_az322_contributions: "yes",
)
status_specific_attributes = case filing_status
when :married_filing_jointly, :married_filing_separately
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ module StateFile
module Questions
class AzCharitableContributionsController < QuestionsController
include ReturnToReviewConcern

private
end
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ module Questions
class AzPublicSchoolContributionsController < QuestionsController
include ReturnToReviewConcern

before_action :set_contribution_count

def self.navigation_actions
[:index, :new]
end
Expand All @@ -24,20 +26,22 @@ def build_contribution
end

def create
@az322_contribution = current_intake.az322_contributions.build(az322_contribution_params)
@az322_contributions = current_intake.az322_contributions
if @az322_contribution.made_contribution_no?
return redirect_to next_path
end
@az322_contribution = current_intake.az322_contributions.build
@az322_contribution.assign_attributes(az322_contribution_params)

if current_intake.valid?(:az322) && @az322_contribution.valid?
if came_from_old_page || (current_intake.valid?(:az322_form_create) && @az322_contribution.valid?)
@az322_contribution.save
redirect_to action: :index, return_to_review: params[:return_to_review]
else
render :new
end
end

# remove this after it has been deployed
def came_from_old_page
params["az322_contribution"].include?("made_contribution") && current_intake.valid? && @az322_contribution.valid?
end

def edit
@az322_contribution = current_intake.az322_contributions.find(params[:id])
end
Expand All @@ -46,11 +50,6 @@ def update
@az322_contribution = current_intake.az322_contributions.find(params[:id])
@az322_contribution.assign_attributes(az322_contribution_params)

if @az322_contribution.made_contribution_no?
@az322_contribution.destroy
return redirect_to action: :index, return_to_review: params[:return_to_review]
end

if @az322_contribution.valid?
@az322_contribution.save
redirect_to action: :index, return_to_review: params[:return_to_review]
Expand All @@ -69,16 +68,22 @@ def destroy

private

def contributions
@contributions ||= current_intake.az322_contributions
end

def set_contribution_count = @contribution_count = contributions.count

def az322_contribution_params
params.require(:az322_contribution).permit(
:made_contribution,
:school_name,
:ctds_code,
:district_name,
:amount,
:date_of_contribution_day,
:date_of_contribution_month,
:date_of_contribution_year
:date_of_contribution_year,
state_file_az_intake_attributes: [:made_az322_contributions]
)
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ def az321_contribution_params
params.require(:az321_contribution).permit(
:charity_name, :charity_code, :amount,
:date_of_contribution_day, :date_of_contribution_month,
:date_of_contribution_year, :made_az321_contributions,
:date_of_contribution_year,
state_file_az_intake_attributes: [:made_az321_contributions]
)
end
Expand Down
26 changes: 19 additions & 7 deletions app/controllers/state_file/questions/income_review_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,23 @@ def self.show?(intake)
intake.direct_file_data.fed_ssb.positive? || intake.direct_file_data.fed_taxable_ssb.positive?
end

def set_sorted_vars
def set_sorted_vars
@w2s = current_intake.state_file_w2s&.sort_by { |w2| [w2.employee_name, w2.employer_name] }
@w2_warnings = @w2s.map do |w2|
w2_count_for_filer = @w2s.count { |comparison_w2| w2.employee_ssn == comparison_w2.employee_ssn }
[w2.id, should_show_warning?(w2, w2_count_for_filer)]
end.to_h
end

def edit
if invalid_income_form?(current_intake)
@invalid_income_form_error = I18n.t("state_file.questions.income_review.edit.invalid_income_form_error")
end
end

def update
if current_intake.allows_w2_editing? && @w2s.any? do |w2|
w2.check_box14_limits = true
!w2.valid?(:state_file_edit)
end
flash[:alert] = I18n.t("state_file.questions.income_review.edit.invalid_w2")
if invalid_income_form?(current_intake)
@invalid_income_form_error = I18n.t("state_file.questions.income_review.edit.invalid_income_form_error")
render :edit
else
update_for_device_id_collection(current_intake&.initial_efile_device_info)
Expand All @@ -34,7 +37,16 @@ def update

private

def invalid_income_form?(intake)
intake.allows_w2_editing? && @w2s.any? do |w2|
w2.check_box14_limits = true
!w2.valid?(:state_file_edit)
end
end

def should_show_warning?(w2, w2_count_for_filer)
return true if w2.wages.positive? && !w2.state_wages_amount.positive?

return false if StateFile::StateInformationService
.w2_supported_box14_codes(w2.state_file_intake.state_code)
.none? { |code| code[:name] == "UI_WF_SWF" || code[:name] == "FLI" }
Expand All @@ -48,7 +60,7 @@ def should_show_warning?(w2, w2_count_for_filer)

ui_wf_swf_max = StateFileW2.find_limit("UI_WF_SWF", w2.state_file_intake.state_code)
return true if ui_wf_swf_max.present? && w2.get_box14_ui_overwrite.to_f > ui_wf_swf_max

fli_max = StateFileW2.find_limit("FLI", w2.state_file_intake.state_code)
return true if fli_max.present? && w2.box14_fli.to_f > fli_max

Expand Down
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 @@ -13,6 +13,7 @@ def prev_path

def edit
@state_code = current_state_code
@w2.valid?(:state_file_edit)
end

def update
Expand Down
1 change: 0 additions & 1 deletion app/forms/state_file/az_charitable_contributions_form.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ class AzCharitableContributionsForm < QuestionsForm
validates :charitable_cash_amount, presence: true, numericality: { greater_than_or_equal_to: 0 }, allow_blank: false, if: -> { charitable_contributions == "yes" }
validates :charitable_noncash_amount, presence: true, numericality: { greater_than_or_equal_to: 0, less_than_or_equal_to: 500 }, allow_blank: false, if: -> { charitable_contributions == "yes" }


def save
if charitable_contributions == "no"
@intake.update(charitable_contributions: "no", charitable_cash_amount: nil, charitable_noncash_amount: nil)
Expand Down
2 changes: 1 addition & 1 deletion app/forms/state_file/income_review_form.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ def save
efile_info&.update!(attributes_for(:state_file_efile_device_info))
end
end
end
end
8 changes: 4 additions & 4 deletions app/helpers/vita_min_form_builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -408,14 +408,14 @@ def vita_min_checkbox_in_set(
container_id = nil
container_class = nil
item_options = item[:options] || {}
if item[:opens_follow_up_with_id]
if item[:opens_follow_up_with_id]
container_class = "question-with-follow-up__question"
item_options["data-follow-up"] = "#" + item[:opens_follow_up_with_id]
elsif item[:follow_up_id]
container_class = "question-with-follow-up__follow-up"
container_id = item[:follow_up_id]
end

joined_classes = ((item[:classes] || []) + ["checkbox"]).join(" ")
checkbox_args = [item[:method], item_options]
checkbox_args += ["yes", "no"] if enum
Expand All @@ -439,10 +439,10 @@ def vita_min_checkbox_set(
legend_class: "",
enum: false,
checkboxes: nil
)
)
checkbox_html = (checkboxes || collection.map do |item|
vita_min_checkbox_in_set(item, enum: enum)
end.join).html_safe
end.join).html_safe

checkbox_container_classes = ["tight-ish-checkboxes"]
includes_follow_up = (collection.any? { |item| item[:opens_follow_up_with_id] }) || (checkbox_html.include? "follow-up")
Expand Down
16 changes: 7 additions & 9 deletions app/models/az322_contribution.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
# ctds_code :string
# date_of_contribution :date
# district_name :string
# made_contribution :integer default("unfilled"), not null
# school_name :string
# created_at :datetime not null
# updated_at :datetime not null
Expand All @@ -18,18 +17,17 @@
# index_az322_contributions_on_state_file_az_intake_id (state_file_az_intake_id)
#
class Az322Contribution < ApplicationRecord
self.ignored_columns = [:made_contribution]

date_accessor :date_of_contribution

belongs_to :state_file_az_intake
accepts_nested_attributes_for :state_file_az_intake, update_only: true

enum made_contribution: { unfilled: 0, yes: 1, no: 2 }, _prefix: :made_contribution

validates_inclusion_of :made_contribution, in: ['yes', 'no'], message: ->(_object, _data) { I18n.t("errors.messages.blank") }
validates :school_name, presence: true, if: -> { made_contribution == "yes" }
validates :ctds_code, presence: true, format: { with: /\A\d{9}\z/, message: -> (_object, _data) { I18n.t("validators.ctds_code") }}, if: -> { made_contribution == "yes" }
validates :district_name, presence: true, if: -> { made_contribution == "yes" }
validates :amount, presence: true, numericality: { greater_than: 0 }, if: -> { made_contribution == "yes" }

validates :school_name, presence: true
validates :ctds_code, presence: true, format: { with: /\A\d{9}\z/, message: -> (_object, _data) { I18n.t("validators.ctds_code") }}
validates :district_name, presence: true
validates :amount, presence: true, numericality: { greater_than: 0 }
validates :date_of_contribution,
inclusion: {
in: TAX_YEAR.beginning_of_year..TAX_YEAR.end_of_year
Expand Down
5 changes: 4 additions & 1 deletion app/models/state_file_az_intake.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
# locale :string default("en")
# locked_at :datetime
# made_az321_contributions :integer default("unfilled"), not null
# made_az322_contributions :integer default("unfilled"), not null
# message_tracker :jsonb
# payment_or_deposit_type :integer default("unfilled"), not null
# phone_number :string
Expand Down Expand Up @@ -103,13 +104,15 @@ class StateFileAzIntake < StateFileBaseIntake
enum eligibility_married_filing_separately: { unfilled: 0, yes: 1, no: 2 }, _prefix: :eligibility_married_filing_separately
enum eligibility_529_for_non_qual_expense: { unfilled: 0, yes: 1, no: 2 }, _prefix: :eligibility_529_for_non_qual_expense
enum made_az321_contributions: { unfilled: 0, yes: 1, no: 2 }, _prefix: :made_az321_contributions
enum made_az322_contributions: { unfilled: 0, yes: 1, no: 2 }, _prefix: :made_az322_contributions
enum eligibility_lived_in_state: { unfilled: 0, yes: 1, no: 2 }, _prefix: :eligibility_lived_in_state
enum eligibility_out_of_state_income: { unfilled: 0, yes: 1, no: 2 }, _prefix: :eligibility_out_of_state_income

validates :made_az321_contributions, inclusion: { in: ["yes", "no"]}, on: :az321_form_create
validates :made_az322_contributions, inclusion: { in: ["yes", "no"]}, on: :az322_form_create
validates :az321_contributions, length: { maximum: 10 }
validates :az322_contributions, length: { maximum: 10 }

validates :az322_contributions, length: { maximum: 10 }, on: :az322
def federal_dependent_count_under_17
self.dependents.select{ |dependent| dependent.under_17? }.length
end
Expand Down
7 changes: 3 additions & 4 deletions app/models/state_file_w2.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ class StateFileW2 < ApplicationRecord
with_options on: :state_file_edit do
validates :employer_state_id_num, length: { maximum: 16, message: ->(_object, _data) { I18n.t('state_file.questions.w2.edit.employer_state_id_error') } }
validates :state_wages_amount, numericality: { greater_than_or_equal_to: 0 }, if: -> { state_wages_amount.present? }
validates :state_wages_amount, numericality: { greater_than: 0 }, if: -> { wages.positive? }
validates :state_income_tax_amount, numericality: { greater_than_or_equal_to: 0 }, if: -> { state_income_tax_amount.present? }
validates :local_wages_and_tips_amount, numericality: { greater_than_or_equal_to: 0 }, if: -> { local_wages_and_tips_amount.present? && StateFile::StateInformationService.w2_include_local_income_boxes(state_file_intake.state_code) }
validates :local_income_tax_amount, numericality: { greater_than_or_equal_to: 0 }, if: -> { local_income_tax_amount.present? && StateFile::StateInformationService.w2_include_local_income_boxes(state_file_intake.state_code) }
Expand Down Expand Up @@ -98,10 +99,8 @@ 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
else
if state_income_tax_amount.present? && state_income_tax_amount > w2.WagesAmt
errors.add(:state_income_tax_amount, I18n.t("state_file.questions.w2.edit.wages_amt_error", wages_amount: w2.WagesAmt))
end
elsif state_income_tax_amount.present? && state_income_tax_amount > w2.WagesAmt
errors.add(:state_income_tax_amount, I18n.t("state_file.questions.w2.edit.wages_amt_error", wages_amount: w2.WagesAmt))
end
end
end
Expand Down
2 changes: 2 additions & 0 deletions app/services/state_file/submission_id_lookup.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ md_katie_hoh: 78126520243408u7yc03
md_leonard_qss: 1016422024337luaxoi5
md_meredith_mfj: 101642202433955coif7
md_nellie_single: 7812652024340szbp5qb
md_nra_mfs_bad_w2_brita: 7812652025038yfytztj
md_omar_mfj: 1016422024340a0c6hev
md_percival_hoh: 7812652024354l7dqzzt
md_ray_dependent: 7812652024354bg51kiy
Expand All @@ -64,6 +65,7 @@ nc_selena_1099_r: 7812652025030ik0q77w
nc_superman_mfj: 1016422025017h93wzyp
nc_wylie_mfs: 10164220243274vip4ag
nc_zeus_mfj_deps: 1016422024327ahu7xl7
nj_bad_w2s: 7812652025038l3p00gc
nj_blackburn_mfj: 10164220243470bd1hef
nj_bog_turtle_mfs: 7812652025030jqdd6x3
nj_bon_jovi_health_exempt_deps: 78126520250034nzlizg
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<% @main_heading = t("state_file.questions.az_public_school_contributions.edit.title_html") %>
<% show_yes_no = @contribution_count == 0 %>

<% content_for :page_title, ActionView::Base.full_sanitizer.sanitize(@main_heading) %>
<% content_for :card do %>
Expand All @@ -9,40 +10,42 @@
<% end %>

<div class="question-with-follow-up">
<div class="question-with-follow-up__question">
<div class="white-group">
<%= f.cfa_radio_set(
:made_contribution,
label_text: t('state_file.questions.az_public_school_contributions.edit.made_contribution', count: current_intake.filer_count, year: current_tax_year),
collection: [
{ value: :yes, label: t('general.affirmative'), input_html: { "data-follow-up": "#contribution-details" } },
{ value: :no, label: t('general.negative') }
]
)
%>
</div>
</div>

<div class="reveal">
<button class="reveal__button"><%= t('.which_qualify') %></button>
<div class="reveal__content">
<ul>
<% t(".qualifying_list").each do |list_item| %>
<li><%= list_item %></li>
<% if show_yes_no %>
<div class="question-with-follow-up__question">
<div class="white-group">
<%= f.fields_for(:state_file_az_intake) do |ff| %>
<%= ff.cfa_radio_set(
:made_az322_contributions,
label_text: t('.made_az322_contributions', count: current_intake.filer_count, year: current_tax_year),
collection: [
{ value: :yes, label: t('general.affirmative'), input_html: { "data-follow-up": "#contribution-details", } },
{ value: :no, label: t('general.negative') }
]
) %>
<% end %>
</ul>
<p><%= t(".more_details_html") %></p>
</div>
</div>
</div>
<div class="reveal">
<button class="reveal__button"><%= t('.which_qualify') %></button>
<div class="reveal__content">
<ul>
<% t(".qualifying_list").each do |list_item| %>
<li><%= list_item %></li>
<% end %>
</ul>
<p><%= t(".more_details_html") %></p>
</div>
</div>

<div class="reveal">
<button class="reveal__button"><%= t(".donations_this_year", current_year: current_tax_year + 1) %></button>
<div class="reveal__content">
<p><%= t(".donations_this_year_details_html", current_year: current_tax_year + 1) %></p>
<div class="reveal">
<button class="reveal__button"><%= t(".donations_this_year", current_year: current_tax_year + 1) %></button>
<div class="reveal__content">
<p><%= t(".donations_this_year_details_html", current_year: current_tax_year + 1) %></p>
</div>
</div>
</div>
</div>
<% end %>

<div class="question-with-follow-up__follow-up" id="contribution-details">
<div class="<%= "question-with-follow-up__follow-up" if show_yes_no %>" id="contribution-details">
<div class="white-group">
<p class="form-question spacing-below-25"><%= t('state_file.questions.az_public_school_contributions.edit.additional_info') %></p>
<div class="form-group-tight">
Expand Down Expand Up @@ -82,6 +85,6 @@
</div>
</div>

<%= f.submit t("general.continue"), :class => "button button--primary button--wide" %>
<%= f.submit t("general.continue"), class: "button button--primary button--wide" %>
<% end %>
<% end %>
Loading

0 comments on commit 371fab2

Please sign in to comment.