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-1041 ID form 40 add some lines #4985

Merged
Merged
Show file tree
Hide file tree
Changes from 13 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
22 changes: 21 additions & 1 deletion app/lib/efile/id/id40_calculator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ def calculate
set_line(:ID40_LINE_9, :calculate_line_9)
set_line(:ID40_LINE_10, :calculate_line_10)
set_line(:ID40_LINE_11, :calculate_line_11)
set_line(:ID40_LINE_19, :calculate_line_19)
set_line(:ID40_LINE_20, :calculate_line_20)
set_line(:ID40_LINE_23, :calculate_line_23)
set_line(:ID40_LINE_29, :calculate_line_29)
set_line(:ID40_LINE_32A, :calculate_line_32a)
Expand Down Expand Up @@ -85,6 +87,24 @@ def calculate_line_11
[line_or_zero(:ID40_LINE_9) - line_or_zero(:ID40_LINE_10), 0].max
end

# Subtract the larger of L15 or L16 from L11 but L15 is always 0
# L16 is pulled from df data
def calculate_line_19
[line_or_zero(:ID40_LINE_11) - @direct_file_data.total_itemized_or_standard_deduction_amount, 0].max
end

WKSHT_LINE_2_AMTS = {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[dustiest dust] would you mind using WK as an abbreviation for worksheet? I doubt we're at all consistent about it, but it's what I saw somewhere else and am using it in the story I'm working on. also my brain is auto populating a different vowel sound in WKSHT.....

single: 4673,
married_filing_separately: 4673,
married_filing_jointly: 9346,
head_of_household: 9346,
qualifying_widow: 9346,
}.freeze
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this looks kind of stupid but it's much nicer to access? idk

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

seems ok to me, we do this elsewhere and I like that's close to where it is used

def calculate_line_20
worksheet_line_2_amount = WKSHT_LINE_2_AMTS[@filing_status]
[((worksheet_line_2_amount - line_or_zero(:ID40_LINE_19)) * 5.695).round(2), 0].max
end

def calculate_line_23
line_or_zero(:ID39R_D_LINE_4)
end
Expand All @@ -109,7 +129,7 @@ def calculate_line_32b
end

def calculate_grocery_credit
return 0 if @intake.direct_file_data.claimed_as_dependent?
return 0 if @direct_file_data.claimed_as_dependent?

credit = 0

Expand Down
4 changes: 4 additions & 0 deletions app/lib/efile/line_data.yml
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,10 @@ ID40_LINE_10:
label: 'Subtractions from Form 39R, Part B, line 24'
ID40_LINE_11:
label: 'Total Adjusted Income. Subtract line 10 from line 9'
ID40_LINE_19:
label: 'Taxable state income'
ID40_LINE_20:
label: 'State income tax'
ID40_LINE_23:
label: 'Total credits from Form 39R, Part D, line 4. Include Form 39R'
ID40_LINE_29:
Expand Down
15 changes: 15 additions & 0 deletions app/lib/pdf_filler/id40_pdf.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,17 @@ def hash_for_pdf
'IncomeL9' => @xml_document.at('Form40 FederalAGI')&.text,
'IncomeL10' => @xml_document.at('Form39R TotalSubtractions')&.text,
'IncomeL11' => @xml_document.at('Form40 StateTotalAdjustedIncome')&.text,
'L12aYourself ' => @xml_document.at('PrimeOver65')&.text == "1" ? "Yes" : "Off",
'L12aSpouse' => @xml_document.at('SpouseOver65')&.text == "1" ? "Yes" : "Off",
'L12bYourself' => @xml_document.at('PrimeBlind')&.text == "1" ? "Yes" : "Off",
'L12bSpouse' => @xml_document.at('SpouseBlind')&.text == "1" ? "Yes" : "Off",
'L12cDependent' => @xml_document.at('ClaimedAsDependent')&.text == "1" ? "Yes" : "Off",
'TxCompL15' => 0,
'TxCompL16' => @xml_document.at('StandardDeduction')&.text,
'TxCompL17' => @xml_document.at('TaxableIncomeState')&.text,
'TxCompL19' => @xml_document.at('TaxableIncomeState')&.text,
'TxCompL20' => round_amount_to_nearest_integer(@xml_document.at('StateIncomeTax')&.text),
'L21' => round_amount_to_nearest_integer(@xml_document.at('StateIncomeTax')&.text),
Comment on lines +55 to +56
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[dust] instead of round_amount_to_nearest_integer could you remove the .text for these and round them? I'm also surprised to see these being rounded in the pdf rather than in the xml or the calculator

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah, so .text isn't converting it to a string, it's getting the contexts of the xml element, which is what's returned from @xml_document.at('<node name>)`. i'm not sure there is a way to get it out as a number, or at least i haven't seen one?

re: rounding, the xml accepts cents for this field (AmountType) but the pdf wants a whole number

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that's the first I've heard of xml wanting/accepting cents but sometimes I guess I have to accept that things are just weird

'CreditsL23' => @xml_document.at('Form39R TotalSupplementalCredits')&.text,
'OtherTaxesL29' => @xml_document.at('StateUseTax')&.text,
'OtherTaxesL32Check' => @xml_document.at('PublicAssistanceIndicator')&.text == "true" ? 'Yes' : 'Off',
Expand Down Expand Up @@ -71,5 +82,9 @@ def formatted_date(date_str, format)

Date.parse(date_str)&.strftime(format)
end

def round_amount_to_nearest_integer(str_value)
str_value.to_f.round
end
end
end
22 changes: 22 additions & 0 deletions app/lib/submission_builder/ty2024/states/id/documents/id40.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,28 @@ def document
end
xml.FederalAGI calculated_fields.fetch(:ID40_LINE_7)
xml.StateTotalAdjustedIncome calculated_fields.fetch(:ID40_LINE_11)

if @direct_file_data.primary_over_65 == "X"
xml.PrimeOver65 1
end
if @intake.filing_status_mfj? && @direct_file_data.spouse_over_65 == "X"
xml.SpouseOver65 1
end

if @direct_file_data.primary_blind == "X"
xml.PrimeBlind 1
end
if @intake.filing_status_mfj? && @direct_file_data.spouse_blind == "X"
xml.SpouseBlind 1
end
if @direct_file_data.primary_claim_as_dependent == "X"
xml.ClaimedAsDependent 1
end

xml.StandardDeduction @direct_file_data.total_itemized_or_standard_deduction_amount
xml.TaxableIncomeState calculated_fields.fetch(:ID40_LINE_19)
xml.StateIncomeTax calculated_fields.fetch(:ID40_LINE_20)

xml.StateUseTax calculated_fields.fetch(:ID40_LINE_29)
xml.PermanentBuildingFund calculated_fields.fetch(:ID40_LINE_32A)
xml.PublicAssistanceIndicator calculated_fields.fetch(:ID40_LINE_32B)
Expand Down
34 changes: 28 additions & 6 deletions app/models/direct_file_data.rb
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ class DirectFileData < DfXmlAccessor
spouse_date_of_death: 'IRS1040 SpouseDeathDt',
spouse_name: 'IRS1040 SpouseNm',
non_resident_alien: 'IRS1040 NRALiteralCd',
primary_over_65: 'IRS1040 Primary65OrOlderInd',
spouse_over_65: 'IRS1040 Spouse65OrOlderInd',
primary_blind: 'IRS1040 PrimaryBlindInd',
spouse_blind: 'IRS1040 SpouseBlindInd',
qualifying_children_under_age_ssn_count: 'IRS1040Schedule8812 QlfyChildUnderAgeSSNCnt',
Expand Down Expand Up @@ -121,6 +123,14 @@ def phone_number=(value)
write_df_xml_value(__method__, value)
end

def cell_phone_number=(value)
write_df_xml_value(__method__, value)
end

def tax_payer_email=(value)
write_df_xml_value(__method__, value)
end

Comment on lines +127 to +134
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added these so i could test that the list of attrs in the test also have setters (see direct_file_data_spec)

def spouse_ssn=(value)
create_or_destroy_df_xml_node(__method__, value, after = "PrimarySSN")

Expand Down Expand Up @@ -211,6 +221,10 @@ def fed_agi=(value)
write_df_xml_value(__method__, value)
end

def total_itemized_or_standard_deduction_amount=(value)
write_df_xml_value(__method__, value)
end

def fed_wages
df_xml_value(__method__)&.to_i || 0
end
Expand Down Expand Up @@ -532,14 +546,22 @@ def fed_w2_state=(value)
write_df_xml_value(__method__, value)
end

def set_primary_blind
create_or_destroy_df_xml_node(:primary_blind, true, 'VirtualCurAcquiredDurTYInd')
write_df_xml_value(:primary_blind, 'X')
def primary_over_65=(value)
write_df_xml_value(__method__, value)
end

def spouse_over_65=(value)
write_df_xml_value(__method__, value)
end

def primary_blind=(value)
create_or_destroy_df_xml_node(__method__, true, 'VirtualCurAcquiredDurTYInd')
write_df_xml_value(__method__, value)
end

def set_spouse_blind
create_or_destroy_df_xml_node(:spouse_blind, true, 'VirtualCurAcquiredDurTYInd')
write_df_xml_value(:spouse_blind, 'X')
def spouse_blind=(value)
create_or_destroy_df_xml_node(__method__, true, 'VirtualCurAcquiredDurTYInd')
write_df_xml_value(__method__, value)
end

def is_primary_blind?
Expand Down
4 changes: 2 additions & 2 deletions spec/factories/state_file_id_intakes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -168,13 +168,13 @@

trait :primary_blind do
after(:build) do |intake|
intake.direct_file_data.set_primary_blind
intake.direct_file_data.primary_blind = "X"
end
end

trait :spouse_blind do
after(:build) do |intake|
intake.direct_file_data.set_spouse_blind
intake.direct_file_data.spouse_blind = "X"
end
end

Expand Down
4 changes: 2 additions & 2 deletions spec/factories/state_file_nj_intakes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -235,13 +235,13 @@

trait :primary_blind do
after(:build) do |intake|
intake.direct_file_data.set_primary_blind
intake.direct_file_data.primary_blind = "X"
end
end

trait :spouse_blind do
after(:build) do |intake|
intake.direct_file_data.set_spouse_blind
intake.direct_file_data.spouse_blind = "X"
end
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@
<SpouseNm>Allen</SpouseNm>
<SpouseDeathDt>2024-07-06</SpouseDeathDt>
<VirtualCurAcquiredDurTYInd>false</VirtualCurAcquiredDurTYInd>
<Primary65OrOlderInd>X</Primary65OrOlderInd>
<PrimaryBlindInd>X</PrimaryBlindInd>
<Spouse65OrOlderInd>X</Spouse65OrOlderInd>
<SpouseBlindInd>X</SpouseBlindInd>
<TotalExemptPrimaryAndSpouseCnt>1</TotalExemptPrimaryAndSpouseCnt>
<DependentDetail>
<DependentFirstNm>Axel</DependentFirstNm>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
<IRS1040 documentId="IRS10400001">
<IndividualReturnFilingStatusCd>1</IndividualReturnFilingStatusCd>
<VirtualCurAcquiredDurTYInd>false</VirtualCurAcquiredDurTYInd>
<Primary65OrOlderInd>X</Primary65OrOlderInd>
<PrimaryBlindInd>X</PrimaryBlindInd>
<TotalExemptPrimaryAndSpouseCnt>1</TotalExemptPrimaryAndSpouseCnt>
<ChldWhoLivedWithYouCnt>0</ChldWhoLivedWithYouCnt>
<OtherDependentsListedCnt>0</OtherDependentsListedCnt>
Expand Down
2 changes: 2 additions & 0 deletions spec/fixtures/state_file/fed_return_xmls/2023/id/paul_mfj.xml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
<IndividualReturnFilingStatusCd>2</IndividualReturnFilingStatusCd>
<SpouseNm>Sydney Revere</SpouseNm>
<VirtualCurAcquiredDurTYInd>false</VirtualCurAcquiredDurTYInd>
<Spouse65OrOlderInd>X</Spouse65OrOlderInd>
<SpouseBlindInd>X</SpouseBlindInd>
<SpouseClaimAsDependentInd>X</SpouseClaimAsDependentInd>
<SpouseBlindInd>X</SpouseBlindInd>
<TotalBoxesCheckedCnt>1</TotalBoxesCheckedCnt>
Expand Down
56 changes: 54 additions & 2 deletions spec/lib/efile/id/id40_calculator_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,59 @@
end
end

describe "Line 19: Idaho taxable income" do
before do
allow(instance).to receive(:calculate_line_11).and_return 50
end

it "enters L11 - L16 if positive number" do
intake.direct_file_data.total_itemized_or_standard_deduction_amount = 40
instance.calculate
expect(instance.lines[:ID40_LINE_19].value).to eq(10)
end

it "enters 0 if difference is negative number" do
intake.direct_file_data.total_itemized_or_standard_deduction_amount = 60
instance.calculate
expect(instance.lines[:ID40_LINE_19].value).to eq(0)
end
end

describe "Line 20: Idaho income tax" do
{
4673 => [:single, :married_filing_separately],
9346 => [:married_filing_jointly, :head_of_household, :qualifying_widow]
}.each do |amount, filing_statuses|
filing_statuses.each do |filing_status|
context "#{filing_status}" do
let(:intake) { create(:state_file_id_intake, filing_status: filing_status) }
let(:calculator_instance) { described_class.new(year: MultiTenantService.statefile.current_tax_year, intake: intake) }
let(:line_19) { 1000 }
before do
allow(calculator_instance).to receive(:calculate_line_19).and_return line_19
end

it "calculates the correct amount" do
expected_result = ((amount - line_19) * 5.695).round(2)
calculator_instance.calculate
expect(calculator_instance.lines[:ID40_LINE_20].value).to eq expected_result
end
end
end
end

context "must be positive value" do
before do
allow(instance).to receive(:calculate_line_19).and_return 10_000
end

it "returns 0 when calc is negative" do
instance.calculate
expect(instance.lines[:ID40_LINE_20].value).to eq 0
end
end
end

describe "Line 29: State Use Tax" do
let(:purchase_amount) { nil }

Expand Down Expand Up @@ -170,7 +223,7 @@
let(:intake) { create(:state_file_id_intake, :filing_requirement) }

before do
intake.direct_file_data.set_primary_blind
intake.direct_file_data.primary_blind = "X"
intake.received_id_public_assistance = "no"
end

Expand All @@ -194,7 +247,6 @@
end
end


describe "Line 43: Grocery Credit" do
context "primary is claimed as dependent" do
let(:intake) { create(:state_file_id_intake, :single_filer_with_json) }
Expand Down
30 changes: 30 additions & 0 deletions spec/lib/pdf_filler/id40_pdf_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,15 @@
primary_last_name: "Idahoan",
)
}
before do
allow_any_instance_of(Efile::Id::Id40Calculator).to receive(:calculate_line_19).and_return(2000)
allow_any_instance_of(Efile::Id::Id40Calculator).to receive(:calculate_line_20).and_return(199.80)
end

it 'sets static fields to the correct values' do
expect(pdf_fields['YearBeginning']).to eq Rails.configuration.statefile_current_tax_year.to_s
expect(pdf_fields['YearEnding']).to eq Rails.configuration.statefile_current_tax_year.to_s
expect(pdf_fields['TxCompL15']).to eq "0" # always 0, not in xml
end

it "sets other fields to the correct values" do
Expand Down Expand Up @@ -68,9 +73,30 @@
expect(pdf_fields['IncomeL9']).to eq '10000'
expect(pdf_fields['IncomeL10']).to eq '0'
expect(pdf_fields['IncomeL11']).to eq '10000'
expect(pdf_fields['L12aYourself ']).to eq 'Yes'
expect(pdf_fields['L12aSpouse']).to eq 'Off'
expect(pdf_fields['L12bYourself']).to eq 'Yes'
expect(pdf_fields['L12bSpouse']).to eq 'Off'
expect(pdf_fields['L12cDependent']).to eq 'Off'
expect(pdf_fields['TxCompL16']).to eq '13850'
expect(pdf_fields['TxCompL17']).to eq '2000' # same as L19
expect(pdf_fields['TxCompL19']).to eq '2000'
expect(pdf_fields['TxCompL20']).to eq '200'
expect(pdf_fields['TxCompL20']).to eq '200'
expect(pdf_fields['L21']).to eq '200' # same as L20
expect(pdf_fields['CreditsL23']).to eq '0'
end

context "when claimed as dependent" do
before do
intake.direct_file_data.primary_claim_as_dependent = "X"
end

it "fills in the correct fields" do
expect(pdf_fields['L12cDependent']).to eq 'Yes'
end
end

context "with dependents" do
before do
create(:state_file_dependent, intake: intake, first_name: "Child", last_name: "One", ssn: "123456789", dob: Date.new(2010, 1, 1))
Expand Down Expand Up @@ -125,6 +151,10 @@
it "sets spouse fields correctly" do
expect(pdf_fields['6bSpouse']).to eq '1' # Spouse not claimed as dependent, so counted here
expect(pdf_fields['6dTotalHousehold']).to eq '2'
expect(pdf_fields['L12aYourself ']).to eq 'Off'
expect(pdf_fields['L12aSpouse']).to eq 'Yes'
expect(pdf_fields['L12bYourself']).to eq 'Off'
expect(pdf_fields['L12bSpouse']).to eq 'Yes'
end
end
end
Expand Down
Loading
Loading