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-843 Implement MD502R XML/PDF Part 2: disability, retirement/pension income #5489

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
db52884
Added calculator methods for _disabled determinations for MD502R
arinchoi03 Jan 30, 2025
b4fda28
Add PriTotalPermDisabledIndicator, SecTotalPermDisabledIndicator to XML
arinchoi03 Jan 30, 2025
3ec7133
Check build response errors after each expectation
arinchoi03 Jan 30, 2025
ee3ace0
Add line_data
arinchoi03 Jan 30, 2025
244a5d3
Add additional check to check disability for spouse only if filing_st…
arinchoi03 Jan 30, 2025
3aabfb0
Add disabled indicator on pdf
arinchoi03 Jan 30, 2025
0a5d95c
Fix up specs now that mfj is a factor for calculation
arinchoi03 Jan 30, 2025
b2c25e8
Put TotalPermDisabledIndicator under show_retirement_ui flag
arinchoi03 Jan 30, 2025
1bb8d61
Fix test
arinchoi03 Jan 30, 2025
ada8c63
Update test descriptions
arinchoi03 Jan 30, 2025
d6cc3c7
Merge remote-tracking branch 'origin' into FYST-843-md-implement-form…
arinchoi03 Jan 30, 2025
ca02f3e
Add calculator methods for Line 1A & 1B
arinchoi03 Jan 31, 2025
4509b60
Add calculations for 7a and 7b
arinchoi03 Jan 31, 2025
61e627d
Add line 8 calculations (sum of lines 1a, 1b, 7a, 7b)
arinchoi03 Jan 31, 2025
ae47ae1
Fill out SourceRetirementIncome on 502R
arinchoi03 Jan 31, 2025
d70486b
Fill out MD502R PDF with retirement income info
arinchoi03 Jan 31, 2025
8bf0b1c
Fill out line data
arinchoi03 Jan 31, 2025
72b1216
Refactor methods that will be shared between MD502R and MD502SU
arinchoi03 Jan 31, 2025
40a094b
Fix typo
arinchoi03 Jan 31, 2025
ceae37a
Stub required lines for line 10A and 10B for MD502R
arinchoi03 Jan 31, 2025
29bd64b
Fill out 502R XML/PDF for military/public safety retirement income
arinchoi03 Jan 31, 2025
ffb3280
Update line_data
arinchoi03 Jan 31, 2025
09f842d
Remove space
arinchoi03 Jan 31, 2025
4cb7407
Fix Taxpayer typo to make sure PDF gets filled out
arinchoi03 Jan 31, 2025
3940610
Fix more typos...
arinchoi03 Jan 31, 2025
491d249
Merge remote-tracking branch 'origin' into FYST-843-md-implement-form…
arinchoi03 Feb 4, 2025
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
26 changes: 26 additions & 0 deletions app/lib/efile/line_data.yml
Original file line number Diff line number Diff line change
Expand Up @@ -766,12 +766,38 @@ MD502_SU_LINE_U:
label: "TBD"
MD502_SU_LINE_V:
label: "TBD"
MD502_SU_LINE_U_PRIMARY:
label: "TBD"
MD502_SU_LINE_V_PRIMARY:
label: "TBD"
MD502_SU_LINE_U_SPOUSE:
label: "TBD"
MD502_SU_LINE_V_SPOUSE:
label: "TBD"
MD502_SU_LINE_1:
label: "1 Add lines a. through yc. and enter this amount on line 13 of Form 502 with the appropriate code letters"
MD502R_LINE_PRIMARY_DISABLED:
label: "Is Primary Taxpayer totally and permanently disabled? (intake question)"
MD502R_LINE_SPOUSE_DISABLED:
label: "Is Secondary Taxpayer totally and permanently disabled? (intake question)"
MD502R_LINE_1A:
label: "Retirement income received by Primary Taxpayer as a pension, annuity from employee retirement system qualified under Sections 401(a), 403 or 457(b)"
MD502R_LINE_1B:
label: "Retirement income received by Secondary Taxpayer as a pension, annuity from employee retirement system qualified under Sections 401(a), 403 or 457(b)"
MD502R_LINE_7A:
label: "Other retirement income and foreign retirement income received by Primary Taxpayer"
MD502R_LINE_7B:
label: "Other retirement income and foreign retirement income received by Secondary Taxpayer"
MD502R_LINE_8:
label: "Total of all retirement source income for primary and secondary taxpayers"
MD502R_LINE_9A:
label: "Total social security benefits for primary"
MD502R_LINE_9B:
label: "Total social security benefits for spouse"
MD502R_LINE_10A:
label: "Primary Taxpayer amount of military income subtracted on Form 502SU with code u and amount of Correctional officers, Law Enforcement officers, or fire, rescue, or emergency services personnel income subtracted on Form 502SU with code v"
MD502R_LINE_10B:
label: "Secondary Taxpayer amount of military income subtracted on Form 502SU with code u and amount of Correctional officers, Law Enforcement officers, or fire, rescue, or emergency services personnel income subtracted on Form 502SU with code v"
NCD400_LINE_6:
label: '6 Federal Adjusted Gross Income'
NCD400_LINE_9:
Expand Down
47 changes: 47 additions & 0 deletions app/lib/efile/md/md502_r_calculator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,51 @@ def initialize(value_access_tracker:, lines:, intake:)
end

def calculate
set_line(:MD502R_LINE_PRIMARY_DISABLED, :calculate_primary_disabled)
set_line(:MD502R_LINE_SPOUSE_DISABLED, :calculate_spouse_disabled)
set_line(:MD502R_LINE_1A, :calculate_line_1a)
set_line(:MD502R_LINE_1B, :calculate_line_1b)
set_line(:MD502R_LINE_7A, :calculate_line_7a)
set_line(:MD502R_LINE_7B, :calculate_line_7b)
set_line(:MD502R_LINE_8, :calculate_line_8)
set_line(:MD502R_LINE_9A, :calculate_line_9a)
set_line(:MD502R_LINE_9B, :calculate_line_9b)
set_line(:MD502R_LINE_10A, :calculate_line_10a)
set_line(:MD502R_LINE_10B, :calculate_line_10b)
end

private

def calculate_primary_disabled
@intake.primary_disabled_yes? ? "X" : nil
end

def calculate_spouse_disabled
return unless @intake.filing_status_mfj?

@intake.spouse_disabled_yes? ? "X" : nil
end

def calculate_line_1a
@intake.sum_1099_r_followup_type_for_filer(@intake.filer_1099_rs(:primary), :income_source_pension_annuity_endowment?)
end

def calculate_line_1b
@intake.sum_1099_r_followup_type_for_filer(@intake.filer_1099_rs(:spouse), :income_source_pension_annuity_endowment?)
end

def calculate_line_7a
@intake.sum_1099_r_followup_type_for_filer(@intake.filer_1099_rs(:primary), :income_source_other?)
end

def calculate_line_7b
@intake.sum_1099_r_followup_type_for_filer(@intake.filer_1099_rs(:spouse), :income_source_other?)
end

def calculate_line_8
[line_or_zero(:MD502R_LINE_1A), line_or_zero(:MD502R_LINE_1B), line_or_zero(:MD502R_LINE_7A), line_or_zero(:MD502R_LINE_7B)].sum
end

def calculate_line_9a
if @intake.direct_file_data.fed_ssb.positive?
if @intake.filing_status_mfj?
Expand All @@ -32,6 +71,14 @@ def calculate_line_9b
@intake.spouse_ssb_amount.round
end
end

def calculate_line_10a
line_or_zero(:MD502_SU_LINE_U_PRIMARY) + line_or_zero(:MD502_SU_LINE_V_PRIMARY)
end

def calculate_line_10b
line_or_zero(:MD502_SU_LINE_U_SPOUSE) + line_or_zero(:MD502_SU_LINE_V_SPOUSE)
end
end
end
end
12 changes: 12 additions & 0 deletions app/lib/efile/md/md502_su_calculator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ def calculate
set_line(:MD502_SU_LINE_U, :calculate_line_u) # STUBBED: PLEASE REPLACE, don't forget line_data.yml
set_line(:MD502_SU_LINE_V, :calculate_line_v) # STUBBED: PLEASE REPLACE, don't forget line_data.yml
set_line(:MD502_SU_LINE_1, :calculate_line_1)
set_line(:MD502_SU_LINE_U_PRIMARY, :calculate_line_u_primary) # STUBBED: PLEASE REPLACE, don't forget line_data.yml
set_line(:MD502_SU_LINE_V_PRIMARY, :calculate_line_v_primary) # STUBBED: PLEASE REPLACE, don't forget line_data.yml
set_line(:MD502_SU_LINE_U_SPOUSE, :calculate_line_u_spouse) # STUBBED: PLEASE REPLACE, don't forget line_data.yml
set_line(:MD502_SU_LINE_V_SPOUSE, :calculate_line_v_spouse) # STUBBED: PLEASE REPLACE, don't forget line_data.yml
end

private
Expand All @@ -23,6 +27,14 @@ def calculate_line_ab
@direct_file_json_data.interest_reports.sum(&:interest_on_government_bonds).round
end

def calculate_line_u_primary; end

def calculate_line_v_primary; end

def calculate_line_u_spouse; end

def calculate_line_v_spouse; end

def calculate_line_u; end

def calculate_line_v; end
Expand Down
17 changes: 17 additions & 0 deletions app/lib/pdf_filler/md502_r_pdf.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,31 @@ def hash_for_pdf
'Spouses Social Security Number': @xml_document.at('Secondary TaxpayerSSN')&.text,
'Your Age 1': @xml_document.at('PrimaryAge')&.text,
'Spouses Age': @xml_document.at('SecondaryAge')&.text,
You: check_box_if_x(@xml_document.at('PriTotalPermDisabledIndicator')&.text),
Spouse: check_box_if_x(@xml_document.at('SecTotalPermDisabledIndicator')&.text),
}
if Flipper.enabled?(:show_md_ssa)
answers.merge!(
"and Tier II See Instructions for Part 5 9a" => @xml_document.at('PriSSecurityRailRoadBenefits')&.text,
"9b" => @xml_document.at('SecSSecurityRailRoadBenefits')&.text
)
end
if Flipper.enabled?(:show_retirement_ui)
answers.merge!(
'compensation plan or foreign retirement income 1a' => @xml_document.at('SourceRetirementIncome PrimaryTaxpayer EmployeeRetirementSystem')&.text,
'1b' => @xml_document.at('SourceRetirementIncome SecondaryTaxpayer EmployeeRetirementSystem')&.text,
'including foreign retirement income 7a' => @xml_document.at('SourceRetirementIncome PrimaryTaxpayer OtherAndForeign')&.text,
'7b' => @xml_document.at('SourceRetirementIncome SecondaryTaxpayer OtherAndForeign')&.text,
'income on lines 1z 4b and 5b of your federal Form 1040 and line 8t of your federal Schedule 1 8' => @xml_document.at('SourceRetirementIncome TotalPensionsIRAsAnnuities')&.text,
'retirement from code letter v on Form 502SU income subtracted on Maryland Form 502 10a' => @xml_document.at('PriMilLawEnforceIncSub')&.text,
'10b' => @xml_document.at('SecMilLawEnforceIncSub')&.text,
)
end
answers
end

def check_box_if_x(value)
value == "X" ? 'On' : 'Off'
end
end
end
21 changes: 21 additions & 0 deletions app/lib/submission_builder/ty2024/states/md/documents/md502_r.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,29 @@ def document
build_xml_doc("Form502R", documentId: "Form502R") do |xml|
xml.PrimaryAge @intake.calculate_age(@intake.primary_birth_date, inclusive_of_jan_1: false)
xml.SecondaryAge @intake.calculate_age(@intake.spouse_birth_date, inclusive_of_jan_1: false) if @intake.filing_status_mfj?
if Flipper.enabled?(:show_retirement_ui)
add_element_if_present(xml, :PriTotalPermDisabledIndicator, :MD502R_LINE_PRIMARY_DISABLED)
add_element_if_present(xml, :SecTotalPermDisabledIndicator, :MD502R_LINE_SPOUSE_DISABLED)
xml.SourceRetirementIncome do
xml.PrimaryTaxpayer do
add_element_if_present(xml, :EmployeeRetirementSystem, :MD502R_LINE_1A)
add_element_if_present(xml, :OtherAndForeign, :MD502R_LINE_7A)
end

if @intake.filing_status_mfj?
xml.SecondaryTaxpayer do
add_element_if_present(xml, :EmployeeRetirementSystem, :MD502R_LINE_1B)
add_element_if_present(xml, :OtherAndForeign, :MD502R_LINE_7B)
end
end
add_element_if_present(xml, :TotalPensionsIRAsAnnuities, :MD502R_LINE_8)
end
end

add_element_if_present(xml, :PriSSecurityRailRoadBenefits, :MD502R_LINE_9A) if Flipper.enabled?(:show_md_ssa)
add_element_if_present(xml, :PriMilLawEnforceIncSub, :MD502R_LINE_10A) if Flipper.enabled?(:show_retirement_ui)
add_element_if_present(xml, :SecSSecurityRailRoadBenefits, :MD502R_LINE_9B) if Flipper.enabled?(:show_md_ssa)
add_element_if_present(xml, :SecMilLawEnforceIncSub, :MD502R_LINE_10B) if Flipper.enabled?(:show_retirement_ui)
end
end

Expand Down
16 changes: 16 additions & 0 deletions app/models/state_file_md_intake.rb
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,22 @@ def address
end
end

def filer_1099_rs(primary_or_spouse)
state_file1099_rs.filter do |state_file_1099_r|
state_file_1099_r.recipient_ssn == send(primary_or_spouse).ssn
end
end

def sum_1099_r_followup_type_for_filer(filer_1099_rs, followup_type)
Copy link
Contributor

Choose a reason for hiding this comment

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

do we need to pass in the filer_1099_rs here? or instead should we pass in primary or spouse?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ooh we can pass in the primary_or_spouse here and call the filer_1099_rs method from within this method!

filer_1099_rs.sum do |state_file_1099_r|
if state_file_1099_r.state_specific_followup&.send(followup_type)
state_file_1099_r.taxable_amount&.round
else
0
Copy link
Contributor Author

@arinchoi03 arinchoi03 Jan 31, 2025

Choose a reason for hiding this comment

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

there was no strict requirement that if a 1099r followup was not present (or if it didn't match the followup_type for this 1099R) that it should return nilvs0`.

Since handling nil for summation (downstream too, not just in this block) can be tricky, chose to not go down this route unless needed for simplicity

end
end
end

Copy link
Contributor Author

Choose a reason for hiding this comment

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

these methods were added to the intake b/c other calculators will need this logic as well

def extract_apartment_from_mailing_street?
true
end
Expand Down
1 change: 0 additions & 1 deletion spec/factories/state_file_md1099_r_followups.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,5 @@
#
FactoryBot.define do
factory :state_file_md1099_r_followup do

end
end
Loading
Loading