diff --git a/app/forms/state_file/nc_sales_use_tax_form.rb b/app/forms/state_file/nc_sales_use_tax_form.rb index d5b622f7ae..9d219e2d12 100644 --- a/app/forms/state_file/nc_sales_use_tax_form.rb +++ b/app/forms/state_file/nc_sales_use_tax_form.rb @@ -22,7 +22,7 @@ def initialize(intake = nil, params = nil) params[:sales_use_tax] = nil end if params[:sales_use_tax_calculation_method] == "automated" - params[:sales_use_tax] = intake.calculate_sales_use_tax + params[:sales_use_tax] = intake.calculate_sales_use_tax(automated: true) end super(intake, params) end @@ -33,4 +33,4 @@ def save @intake.update!(attributes) end end -end \ No newline at end of file +end diff --git a/app/models/state_file_nc_intake.rb b/app/models/state_file_nc_intake.rb index d4c9901b6a..9593755efb 100644 --- a/app/models/state_file_nc_intake.rb +++ b/app/models/state_file_nc_intake.rb @@ -114,9 +114,13 @@ def sanitize_county_details end end - def calculate_sales_use_tax - nc_taxable_income = calculator.lines[:NCD400_LINE_14].value - calculator.calculate_use_tax(nc_taxable_income) + def calculate_sales_use_tax(automated: false) + if automated + calculator.line_or_zero(:NCD400_LINE_18) + else + nc_taxable_income = calculator.lines[:NCD400_LINE_14].value + calculator.calculate_use_tax(nc_taxable_income) + end end def disaster_relief_county diff --git a/app/views/state_file/questions/nc_review/edit.html.erb b/app/views/state_file/questions/nc_review/edit.html.erb index 8cdf96f94c..5064b9ca5f 100644 --- a/app/views/state_file/questions/nc_review/edit.html.erb +++ b/app/views/state_file/questions/nc_review/edit.html.erb @@ -85,7 +85,7 @@

<%=t(".use_tax_applied", filing_year: current_tax_year) %>

<%=current_intake.untaxed_out_of_state_purchases_yes? ? t("general.affirmative") : t("general.negative") %>

<% if current_intake.untaxed_out_of_state_purchases_yes? %> -

<%=t(".use_tax_amount") %>

+

<%=t(".use_tax_amount") %>

<%=number_to_currency(current_intake.sales_use_tax, precision: 2)%>

<% end %> <%= link_to t("general.edit"), StateFile::Questions::NcSalesUseTaxController.to_path_helper(return_to_review: "y"), class: "button--small" %> diff --git a/spec/features/state_file/complete_intake_spec.rb b/spec/features/state_file/complete_intake_spec.rb index 18893b99f8..ffb20613ff 100644 --- a/spec/features/state_file/complete_intake_spec.rb +++ b/spec/features/state_file/complete_intake_spec.rb @@ -316,6 +316,99 @@ expect(submission.submission_bundle).to be_present expect(submission.current_state).to eq("queued") end + + it "properly calculates the sales/use tax", required_schema: "nc" do + visit "/" + click_on "Start Test NC" + + expect(page).to have_text I18n.t("state_file.landing_page.edit.nc.title") + click_on I18n.t('general.get_started'), id: "firstCta" + + step_through_eligibility_screener(us_state: "nc") + + step_through_initial_authentication(contact_preference: :email) + + check "Email" + check "Text message" + fill_in "Your phone number", with: "+12025551212" + click_on "Continue" + + click_on I18n.t("general.accept") + click_on I18n.t("state_file.questions.terms_and_conditions.edit.accept") + + step_through_df_data_transfer("Transfer Bert 1099 r") + + select("Buncombe", from: "County") + click_on I18n.t("general.continue") + + choose "state_file_nc_veteran_status_form_primary_veteran_no" + choose "state_file_nc_veteran_status_form_spouse_veteran_no" + click_on I18n.t("general.continue") + + + expect(page).to have_text I18n.t("state_file.questions.nc_sales_use_tax.edit.title.other", year: filing_year, count: 2) + + choose I18n.t("general.affirmative") + choose "state_file_nc_sales_use_tax_form_sales_use_tax_calculation_method_automated" + click_on I18n.t("general.continue") + + # Of the 4 buttons on this page, select the first button that says "Review and edit state info" + click_on I18n.t("state_file.questions.income_review.edit.review_and_edit_state_info"), match: :first + + # take a screenshot + + + click_on I18n.t("general.continue") + + + click_on I18n.t("state_file.questions.income_review.edit.review_and_edit_state_info"), match: :first + expect(page).to have_text(strip_html_tags(I18n.t("state_file.questions.retirement_income.edit.title_html", payer_name: "Elmo Retirement Ltd"))) + + + click_on I18n.t("general.continue") + + + + click_on I18n.t("general.continue") + choose strip_html_tags(I18n.t("state_file.questions.nc_retirement_income_subtraction.edit.income_source_bailey_settlement_html")) + check I18n.t("state_file.questions.nc_retirement_income_subtraction.edit.other") + click_on I18n.t("general.continue") + choose I18n.t("state_file.questions.nc_retirement_income_subtraction.edit.other") + click_on I18n.t("general.continue") + choose I18n.t("state_file.questions.nc_retirement_income_subtraction.edit.other") + click_on I18n.t("general.continue") + choose I18n.t("state_file.questions.nc_retirement_income_subtraction.edit.other") + click_on I18n.t("general.continue") + + + choose I18n.t("general.negative") + click_on I18n.t("general.continue") + + page.save_screenshot("nc_sales_use_tax_5.png") + + click_on I18n.t("general.continue") + + expect(page).to have_text I18n.t("state_file.questions.primary_state_id.state_id.id_type_question.label") + choose I18n.t("state_file.questions.primary_state_id.state_id.id_type_question.drivers_license") + fill_in "state_file_primary_state_id_form_id_number", with: "123456789" + select_cfa_date "state_file_primary_state_id_form_issue_date", Date.new(2020, 1, 1) + check "state_file_primary_state_id_form_non_expiring" + select("Alaska", from: "State") + click_on I18n.t("general.continue") + + expect(page).to have_text I18n.t("state_file.questions.primary_state_id.state_id.id_type_question.label") + choose I18n.t("state_file.questions.primary_state_id.state_id.id_type_question.drivers_license") + fill_in "state_file_spouse_state_id_form_id_number", with: "123456789" + select_cfa_date "state_file_spouse_state_id_form_issue_date", Date.new(2020, 1, 1) + check "state_file_spouse_state_id_form_non_expiring" + select("Alaska", from: "State") + click_on I18n.t("general.continue") + + expect(page).to have_text I18n.t("state_file.questions.shared.abstract_review_header.title") + click_on I18n.t("general.continue") + + expect(page).to have_css("#use-text-amount", text: "$11.00") + end end context "ID", :flow_explorer_screenshot do diff --git a/spec/models/state_file_nc_intake_spec.rb b/spec/models/state_file_nc_intake_spec.rb index b2bb4e5871..ceb03fc93c 100644 --- a/spec/models/state_file_nc_intake_spec.rb +++ b/spec/models/state_file_nc_intake_spec.rb @@ -96,6 +96,15 @@ allow(intake.calculator.lines).to receive(:[]).with(:NCD400_LINE_14).and_return(double(value: 2500)) expect(intake.calculate_sales_use_tax).to eq 2 end + + context "when automated retirement income is present" do + let(:intake) { build :state_file_nc_intake } + + it "calculates the sales use tax using the automated retirement income" do + allow(intake.calculator).to receive(:line_or_zero).with(:NCD400_LINE_18).and_return(11) + expect(intake.calculate_sales_use_tax(automated: true)).to eq 11 + end + end end describe "#sanitize_county_details" do