-
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 4 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,29 @@ | ||
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_1, :calculate_line_1) | ||
set_line(:MD502_SU_LINE_AB, :calculate_line_ab) | ||
end | ||
|
||
private | ||
|
||
def calculate_line_1 | ||
calculate_line_ab | ||
end | ||
|
||
def calculate_line_ab | ||
@direct_file_json_data.interest_reports.sum(&:interest_on_government_bonds).round | ||
end | ||
end | ||
end | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
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) | ||
@xml_document = builder.new(submission).document | ||
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] similar to previous comment -- doesn't look like this instance variable is referenced anywhere in this class. could it be removed? |
||
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 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
require "rails_helper" | ||
|
||
RSpec.describe PdfFiller::Md502SuPdf do | ||
include PdfSpecHelper | ||
let(:intake) { create :state_file_md_intake } | ||
let(:submission) { create :efile_submission, tax_return: nil, data_source: intake } | ||
let(:pdf) { described_class.new(submission) } | ||
|
||
describe "#hash_for_pdf" do | ||
let(:file_path) { described_class.new(submission).output_file.path } | ||
let(:pdf_fields) { filled_in_values(file_path) } | ||
|
||
it 'uses field names that exist in the pdf' do | ||
missing_fields = pdf.hash_for_pdf.keys.map { |k| k.to_s.gsub("'", "'").to_s } - pdf_fields.keys | ||
expect(missing_fields).to eq([]) | ||
end | ||
|
||
context 'without interest reports' do | ||
let(:primary_ssn) { "345678901" } | ||
let(:spouse_ssn) { "987654321" } | ||
let(:intake) do | ||
create( | ||
:state_file_md_intake, | ||
primary_first_name: "Janet", | ||
primary_middle_initial: "G", | ||
primary_last_name: "Jormp", | ||
spouse_first_name: "Jane", | ||
spouse_middle_initial: "M", | ||
spouse_last_name: "Jomp", | ||
) | ||
end | ||
|
||
before do | ||
intake.direct_file_data.primary_ssn = primary_ssn | ||
intake.direct_file_data.spouse_ssn = spouse_ssn | ||
end | ||
|
||
it "sets fields to the correct values" do | ||
expect(pdf_fields["Your First Name"]).to eq "Janet" | ||
expect(pdf_fields["Text1"]).to eq "G" | ||
expect(pdf_fields["Your Last Name"]).to eq "Jormp" | ||
expect(pdf_fields["Your Social Security Number"]).to eq primary_ssn | ||
expect(pdf_fields["Spouses First Name"]).to eq "Jane" | ||
expect(pdf_fields["Text2"]).to eq "M" | ||
expect(pdf_fields["Spouses Last Name"]).to eq "Jomp" | ||
expect(pdf_fields["Spouses Social Security Number"]).to eq spouse_ssn | ||
expect(pdf_fields["ab Income from US Government obligations See Instruction 13 ab"]).to eq("0") | ||
expect(pdf_fields["appropriate code letters TOTAL 1"]).to eq("0") | ||
end | ||
end | ||
|
||
context 'with interest report' do | ||
let(:intake) { create(:state_file_md_intake, :df_data_1099_int) } | ||
it "sets fields to the correct values" do | ||
expect(pdf_fields["Your First Name"]).to eq "Mary" | ||
expect(pdf_fields["Text1"]).to eq "A" | ||
expect(pdf_fields["Your Last Name"]).to eq "Lando" | ||
expect(pdf_fields["Your Social Security Number"]).to eq "123456789" | ||
expect(pdf_fields["Spouses First Name"]).to eq "" | ||
expect(pdf_fields["Text2"]).to eq "" | ||
expect(pdf_fields["Spouses Last Name"]).to eq "" | ||
expect(pdf_fields["Spouses Social Security Number"]).to eq "" | ||
expect(pdf_fields["ab Income from US Government obligations See Instruction 13 ab"]).to eq("2") | ||
expect(pdf_fields["appropriate code letters TOTAL 1"]).to eq("2") | ||
end | ||
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.
[pebble] aside from the assignment on line 10, the intake isn't referenced so i don't believe we need to allocate an instance variable for it.
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.
ah, this is what happens when you're new and copy pasta what you've seen in other files, you're completely right. there's no need to allocate an instance variable.