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

[FYST-1854] NC Use Tax amount incorrect on Final Review screen #5658

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
4 changes: 2 additions & 2 deletions app/forms/state_file/nc_sales_use_tax_form.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -33,4 +33,4 @@ def save
@intake.update!(attributes)
end
end
end
end
10 changes: 7 additions & 3 deletions app/models/state_file_nc_intake.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion app/views/state_file/questions/nc_review/edit.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@
<p class="text--bold spacing-below-5"><%=t(".use_tax_applied", filing_year: current_tax_year) %></p>
<p><%=current_intake.untaxed_out_of_state_purchases_yes? ? t("general.affirmative") : t("general.negative") %></p>
<% if current_intake.untaxed_out_of_state_purchases_yes? %>
<p class="text--bold spacing-below-5"><%=t(".use_tax_amount") %></p>
<p id="use-tax-amount" class="text--bold spacing-below-5"><%=t(".use_tax_amount") %></p>
<p><%=number_to_currency(current_intake.sales_use_tax, precision: 2)%></p>
<% end %>
<%= link_to t("general.edit"), StateFile::Questions::NcSalesUseTaxController.to_path_helper(return_to_review: "y"), class: "button--small" %>
Expand Down
93 changes: 93 additions & 0 deletions spec/features/state_file/complete_intake_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 9 additions & 0 deletions spec/models/state_file_nc_intake_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading