Skip to content
Merged
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,6 @@ module StateFile
module Questions
class NcSubtractionsController < QuestionsController
include ReturnToReviewConcern
before_action :set_ivars, only: [:edit, :update]

def set_ivars
@subtractions_limit = current_intake.calculator.subtractions_limit
end
end
end
end
6 changes: 3 additions & 3 deletions app/forms/state_file/nc_subtractions_form.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ class NcSubtractionsForm < QuestionsForm

validates :tribal_member, inclusion: { in: %w[yes no], message: :blank }
validates :tribal_wages_amount, presence: true, allow_blank: false, numericality: { greater_than_or_equal_to: 1 }, if: -> { tribal_member == "yes" }
validate :below_subtractions_limit, if: -> { tribal_wages_amount.present? }
validate :below_fed_wages_salaries_tips, if: -> { tribal_wages_amount.present? }

def save
if tribal_member == "no"
Expand All @@ -16,8 +16,8 @@ def save

private

def below_subtractions_limit
amount_limit = @intake.calculator.subtractions_limit
def below_fed_wages_salaries_tips
amount_limit = @intake.direct_file_data.fed_wages_salaries_tips
if self.tribal_wages_amount.to_d > amount_limit
errors.add(:tribal_wages_amount, I18n.t("forms.errors.state_credit.exceeds_limit", limit: amount_limit))
end
Expand Down
4 changes: 0 additions & 4 deletions app/lib/efile/nc/d400_calculator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,6 @@ def calculate_use_tax(nc_taxable_income)
end
end

def subtractions_limit
@direct_file_data.fed_agi - (line_or_zero(:NCD400_S_LINE_18) + line_or_zero(:NCD400_S_LINE_19) + line_or_zero(:NCD400_S_LINE_20) + line_or_zero(:NCD400_S_LINE_21))
end

def analytics_attrs
{}
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<div class="question-with-follow-up__follow-up" id="tribal_member">
<div class="white-group">
<div class="form-group-tight">
<p><%= t(".tribal_wages_question_html", amount_limit: @subtractions_limit) %></p>
<p><%= t(".tribal_wages_question_html", amount_limit: current_intake.direct_file_data.fed_wages_salaries_tips) %></p>
<%= f.vita_min_money_field(:tribal_wages_amount, t(".tribal_wages_field_html"), classes: ["form-width--long"]) %>
</div>
</div>
Expand Down
4 changes: 1 addition & 3 deletions spec/forms/state_file/nc_subtractions_form_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@
let(:intake) { create :state_file_nc_intake }
let(:form) { described_class.new(intake, params) }
before do
intake.direct_file_data.fed_agi = 1060
intake.direct_file_data.fed_taxable_income = 30
intake.direct_file_data.fed_taxable_ssb = 30
intake.direct_file_data.fed_wages_salaries_tips = 1000
end

context "with no radio selected" do
Expand Down
Loading