-
Notifications
You must be signed in to change notification settings - Fork 13
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 754 implement form 502 xml pdf two income subtraction #5012
Merged
mpidcock
merged 33 commits into
main
from
FYST-754-implement-form-502-xml-pdf-two-income-subtraction
Nov 27, 2024
Merged
Changes from all commits
Commits
Show all changes
33 commits
Select commit
Hold shift + click to select a range
e975d02
WIP: preliminary implementation with no income
mpidcock 4933874
WIP: add tests with hardcoded values for spouse and primary
mpidcock 86ed380
WIP: implement first pass at data sources for worksheet calculations
mpidcock 3a1986f
Add TwoIncome calculation to xml & pdf
mpidcock 4d07b8f
WIP add labels and minor fixes
mpidcock 522da0d
WIP #calculate_fed_income base case tests passing
mpidcock 8cfc8f8
WIP #calculate_fed_income base case tests passing
mpidcock 14c32c8
WIP test #calculate_fed_subtractions
mpidcock 7299cf1
WIP test #calculate_line_2
mpidcock 187af36
WIP test #calculate_line_4
mpidcock e355e92
WIP test #calculate_line_2
mpidcock b4809e1
WIP test math calculations
mpidcock aee0d99
WIP handle nil and non-MFJ
mpidcock 4e85dfc
WIP add some missing federal info editor fields
mpidcock ecef327
WIP fix tests
mpidcock b3b5768
WIP update MFJ/MFS ssns to match new trait
mpidcock 18d1df9
WIP nil safety and cosmetics
mpidcock f182b0e
more tests
mpidcock cd9fe69
add line 14 to line 15 calculations
mpidcock ac5b37c
update subtractions to use caluclation methods
mpidcock a36b52a
code review feedback
mpidcock 8253798
add labels
mpidcock 272f350
don't use setter for interest_reports
mpidcock aa027e7
cleanup
mpidcock 3ef8915
add line 14 test
mpidcock 2b92f3d
code review feedback
mpidcock 43a352c
use json for 1099G info instead
mpidcock c7dcf70
Merge branch 'refs/heads/main' into FYST-754-implement-form-502-xml-p…
mpidcock 6600cc4
Merge branch 'refs/heads/main' into FYST-754-implement-form-502-xml-p…
mpidcock 0fa7f68
add acceptance testing scenarios
mpidcock 1be6233
fix scenario 9 w2
mpidcock 1f854ae
Remove acceptance testing scenarios
mpidcock 28ff738
Merge branch 'refs/heads/main' into FYST-754-implement-form-502-xml-p…
mpidcock File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,127 @@ | ||
module Efile | ||
module Md | ||
class TwoIncomeSubtractionWorksheet < ::Efile::TaxCalculator | ||
# https://www.marylandtaxes.gov/forms/worksheets/Two-income-worksheet.pdf | ||
|
||
attr_accessor :lines, :value_access_tracker | ||
|
||
def initialize(value_access_tracker:, lines:, intake:) | ||
@value_access_tracker = value_access_tracker | ||
@lines = lines | ||
@intake = intake | ||
@direct_file_data = intake.direct_file_data | ||
@direct_file_json_data = intake.direct_file_json_data | ||
end | ||
|
||
def calculate | ||
set_line(:MD_TWO_INCOME_WK_LINE_1_A, -> { calculate_line_1 :primary }) | ||
set_line(:MD_TWO_INCOME_WK_LINE_2_A, -> { calculate_line_2 :primary }) | ||
set_line(:MD_TWO_INCOME_WK_LINE_3_A, -> { calculate_line_3 :primary }) | ||
set_line(:MD_TWO_INCOME_WK_LINE_4_A, -> { calculate_line_4 :primary }) | ||
set_line(:MD_TWO_INCOME_WK_LINE_5_A, -> { calculate_line_5 :primary }) | ||
set_line(:MD_TWO_INCOME_WK_LINE_1_B, -> { calculate_line_1 :spouse }) | ||
set_line(:MD_TWO_INCOME_WK_LINE_2_B, -> { calculate_line_2 :spouse }) | ||
set_line(:MD_TWO_INCOME_WK_LINE_3_B, -> { calculate_line_3 :spouse }) | ||
set_line(:MD_TWO_INCOME_WK_LINE_4_B, -> { calculate_line_4 :spouse }) | ||
set_line(:MD_TWO_INCOME_WK_LINE_5_B, -> { calculate_line_5 :spouse }) | ||
set_line(:MD_TWO_INCOME_WK_LINE_6, :calculate_line_6) | ||
set_line(:MD_TWO_INCOME_WK_LINE_7, :calculate_line_7) | ||
end | ||
|
||
def calculate_fed_income(primary_or_spouse) | ||
filer_ssn = @intake.send(primary_or_spouse).ssn | ||
|
||
wage_income = @direct_file_data.w2s | ||
.select { |w2| w2.EmployeeSSN == filer_ssn } | ||
.sum { |w2| w2.WagesAmt&.round } | ||
|
||
interest_income = @direct_file_json_data.interest_reports | ||
.select { |interest_report| interest_report.recipient_tin.delete("-") == filer_ssn } | ||
.sum { |interest_report| | ||
(interest_report.amount_1099&.round || 0) + (interest_report.amount_no_1099&.round || 0) | ||
} | ||
|
||
retirement_income = @intake.state_file1099_rs | ||
.select { |form1099r| form1099r.recipient_ssn == filer_ssn } | ||
.sum { |form1099r| form1099r.taxable_amount&.round } | ||
|
||
unemployment_income = find_filer_json_for(primary_or_spouse)&.form_1099_gs_total&.round || 0 | ||
|
||
wage_income + | ||
interest_income + | ||
retirement_income + | ||
unemployment_income | ||
end | ||
|
||
def calculate_fed_subtractions(primary_or_spouse) | ||
filer_json = find_filer_json_for(primary_or_spouse) | ||
|
||
student_loan_interest = { | ||
primary: @intake.primary_student_loan_interest_ded_amount&.round, | ||
spouse: @intake.spouse_student_loan_interest_ded_amount&.round, | ||
}[primary_or_spouse] | ||
|
||
educator_expenses = filer_json&.educator_expenses&.round || 0 | ||
|
||
hsa_total_deductible_amount = filer_json&.hsa_total_deductible_amount&.round || 0 | ||
|
||
student_loan_interest + | ||
educator_expenses + | ||
hsa_total_deductible_amount | ||
end | ||
|
||
private | ||
|
||
def calculate_line_1(primary_or_spouse) | ||
calculate_fed_income(primary_or_spouse) - calculate_fed_subtractions(primary_or_spouse) | ||
end | ||
|
||
def calculate_line_2(primary_or_spouse) | ||
@intake.state_file_w2s | ||
.select { |w2| w2.employee_ssn == @intake.send(primary_or_spouse).ssn } | ||
.sum { |w2| w2.box14_stpickup&.round || 0 } | ||
end | ||
|
||
def calculate_line_3(primary_or_spouse) | ||
filer = primary_or_spouse == :primary ? "A" : "B" | ||
line_or_zero("MD_TWO_INCOME_WK_LINE_1_#{filer}") + | ||
line_or_zero("MD_TWO_INCOME_WK_LINE_2_#{filer}") | ||
end | ||
|
||
def calculate_line_4(primary_or_spouse) | ||
cdc_expenses = (@direct_file_data.total_qualifying_dependent_care_expenses || 0) / 2 | ||
|
||
# NOTE: Stub alert - this data relies on 1099R followup questions, which have been deprioritized | ||
pension_exclusion = 0 | ||
military_retirement_exclusion = 0 | ||
|
||
cdc_expenses + | ||
pension_exclusion + | ||
military_retirement_exclusion | ||
end | ||
|
||
def calculate_line_5(primary_or_spouse) | ||
filer = primary_or_spouse == :primary ? "A" : "B" | ||
line_or_zero("MD_TWO_INCOME_WK_LINE_3_#{filer}") - | ||
line_or_zero("MD_TWO_INCOME_WK_LINE_4_#{filer}") | ||
end | ||
|
||
def calculate_line_6 | ||
lower_income = [@lines[:MD_TWO_INCOME_WK_LINE_5_A].value, | ||
@lines[:MD_TWO_INCOME_WK_LINE_5_B].value].min | ||
[lower_income, 0].max | ||
end | ||
|
||
def calculate_line_7 | ||
@lines[:MD_TWO_INCOME_WK_LINE_6].value.clamp(0, 1_200) | ||
end | ||
|
||
def find_filer_json_for(primary_or_spouse) | ||
@direct_file_json_data.filers | ||
.find { |df_filer_data| | ||
df_filer_data.tin.delete("-") == @intake.send(primary_or_spouse).ssn | ||
} | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
spec/fixtures/state_file/fed_return_jsons/md/minimal_with_spouse.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
{ | ||
"familyAndHousehold": [], | ||
"filers": [ | ||
{ | ||
"firstName": "Beaches", | ||
"middleInitial": "T", | ||
"lastName": "Yarn Mat", | ||
"dateOfBirth": "1950-01-01", | ||
"isPrimaryFiler": true, | ||
"tin": "123-45-6789" | ||
}, | ||
{ | ||
"firstName": "Pebble", | ||
"middleInitial": "Y", | ||
"lastName": "Yarn Mat", | ||
"dateOfBirth": "1950-01-01", | ||
"isPrimaryFiler": false, | ||
"tin": "987-65-4321" | ||
} | ||
] | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like this extraction!