-
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 663 implement form 502 su xml pdf part 1 #4942
base: main
Are you sure you want to change the base?
Changes from 9 commits
12b484d
60446d1
b4bf32a
b774206
24a7220
a8d045a
6f52348
f3a4e14
c134305
2b2b355
b5b2caa
fbac69a
0d3f01f
f916e66
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
module Efile | ||
module Md | ||
class Md502SuCalculator < ::Efile::TaxCalculator | ||
attr_reader :lines, :value_access_tracker | ||
|
||
def initialize(value_access_tracker:, lines:, intake:) | ||
@value_access_tracker = value_access_tracker | ||
@lines = lines | ||
intake = intake | ||
@direct_file_json_data = intake.direct_file_json_data | ||
end | ||
|
||
def calculate | ||
set_line(:MD502_SU_LINE_AB, :calculate_line_ab) | ||
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) | ||
end | ||
|
||
private | ||
|
||
def calculate_line_ab | ||
@direct_file_json_data.interest_reports.sum(&:interest_on_government_bonds).round | ||
end | ||
|
||
def calculate_line_u; end | ||
|
||
def calculate_line_v; end | ||
|
||
def calculate_line_1 | ||
line_or_zero(:MD502_SU_LINE_AB) + line_or_zero(:MD502_SU_LINE_U) + line_or_zero(:MD502_SU_LINE_V) | ||
end | ||
end | ||
end | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
module PdfFiller | ||
class Md502SuPdf | ||
include PdfHelper | ||
|
||
def source_pdf_name | ||
"md502SU-TY2023" | ||
end | ||
|
||
def initialize(submission) | ||
@submission = submission | ||
builder = StateFile::StateInformationService.submission_builder_class(:md) | ||
end | ||
|
||
def hash_for_pdf | ||
{ | ||
'Your First Name' => @submission.data_source.primary.first_name, | ||
'Text1' => @submission.data_source.primary.middle_initial, | ||
'Your Last Name' => @submission.data_source.primary.last_name, | ||
'Your Social Security Number' => @submission.data_source.primary.ssn, | ||
'Spouses First Name' => @submission.data_source.spouse.first_name, | ||
'Text2' => @submission.data_source.spouse.middle_initial, | ||
'Spouses Last Name' => @submission.data_source.spouse.last_name, | ||
'Spouses Social Security Number' => @submission.data_source.spouse.ssn, | ||
'ab Income from US Government obligations See Instruction 13 ab' => calculated_fields.fetch(:MD502_SU_LINE_AB), | ||
'appropriate code letters TOTAL 1' => calculated_fields.fetch(:MD502_SU_LINE_1), | ||
} | ||
end | ||
|
||
private | ||
|
||
def calculated_fields | ||
@calculated_fields ||= @submission.data_source.tax_calculator.calculate | ||
end | ||
end | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# frozen_string_literal: true | ||
|
||
module SubmissionBuilder | ||
module Ty2024 | ||
module States | ||
module Md | ||
module Documents | ||
class Md502Su < SubmissionBuilder::Document | ||
include SubmissionBuilder::FormattingMethods | ||
|
||
def document | ||
build_xml_doc("Form502SU", documentId: "Form502SU") do |xml| | ||
xml.Subtractions do |subtractions| | ||
subtractions.Total calculated_fields.fetch(:MD502_SU_LINE_1) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [pebble] is there supposed to be an There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is intentional! the |
||
end | ||
end | ||
end | ||
|
||
private | ||
|
||
def intake | ||
@submission.data_source | ||
end | ||
|
||
def calculated_fields | ||
@md502_su_fields ||= intake.tax_calculator.calculate | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
require 'rails_helper' | ||
|
||
describe Efile::Md::Md502SuCalculator do | ||
let(:intake) { create(:state_file_md_intake) } | ||
let(:main_calculator) do | ||
Efile::Md::Md502Calculator.new( | ||
year: MultiTenantService.statefile.current_tax_year, | ||
intake: intake | ||
) | ||
end | ||
let(:instance) { main_calculator.instance_variable_get(:@md502_su) } | ||
|
||
describe 'line ab' do | ||
before do | ||
instance.calculate | ||
end | ||
|
||
context 'without interest reports' do | ||
it 'does not set line ab' do | ||
expect(instance.lines[:MD502_SU_LINE_AB].value).to eq(0) | ||
end | ||
end | ||
|
||
context 'with interest report' do | ||
let(:intake) { create(:state_file_md_intake, :df_data_1099_int) } | ||
it 'sets line ab' do | ||
expect(instance.lines[:MD502_SU_LINE_AB].value).to eq(2) | ||
end | ||
end | ||
end | ||
|
||
describe 'line 1' do | ||
it 'totals lines a through yc' do | ||
allow(instance).to receive(:calculate_line_ab).and_return 100 | ||
instance.calculate | ||
expect(instance.lines[:MD502_SU_LINE_1].value).to eq(100) | ||
end | ||
end | ||
end |
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.
[specs of dust] I think this would be slightly better with newlines for each pair (esp because the list may grow in the future), but incredibly minor.
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.
happy to do that :)