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

Add 0969 section 4 pdf mapping #19940

Merged
merged 8 commits into from
Jan 14, 2025
Merged
Show file tree
Hide file tree
Changes from all 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
4 changes: 2 additions & 2 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,10 @@ GIT

GIT
remote: https://github.com/department-of-veterans-affairs/vets-json-schema
revision: a84abd360072a0d4aaa8b1984cee2c33e1844335
revision: 75b0a0dd78b479e230867e89989bf3e8262d850c
branch: master
specs:
vets_json_schema (24.7.0)
vets_json_schema (24.7.4)
multi_json (~> 1.0)
script_utils (= 0.0.4)

Expand Down
Binary file modified lib/pdf_fill/forms/pdfs/21P-0969.pdf
Binary file not shown.
133 changes: 133 additions & 0 deletions lib/pdf_fill/forms/va21p0969.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,12 @@ class Va21p0969 < FormBase
'OTHER' => 5
}.freeze

ACCOUNT_INCOME_TYPES = {
'INTEREST' => 0,
'DIVIDENDS' => 1,
'OTHER' => 2
}.freeze

KEY = {
# 1a
'veteranFullName' => {
Expand Down Expand Up @@ -166,6 +172,91 @@ class Va21p0969 < FormBase
question_suffix: '(5)',
question_text: 'SPECIFY INCOME PAYER (Name of business, financial institution, or program, etc.)'
}
},
# 4a
'associatedIncome' => {
key: 'F[0].Page_6[0].DependentsReceiving4a[0]'
},
# 4b - 4f
'associatedIncomes' => {
limit: 5,
first_key: 'recipientRelationship',
'recipientRelationship' => {
key: "F[0].IncomeRecipients4[#{ITERATOR}]"
},
'recipientRelationshipOverflow' => {
question_num: 4,
question_suffix: '(1)',
question_text: "SPECIFY INCOME RECIPIENT'S RELATIONSHIP TO VETERAN"
},
'otherRecipientRelationshipType' => {
key: "F[0].OtherRelationship4[#{ITERATOR}]",
question_num: 4,
question_suffix: '(1)',
question_text: "SPECIFY INCOME RECIPIENT'S RELATIONSHIP TO VETERAN"
},
'recipientName' => {
key: "F[0].NameofIncomeRecipient4[#{ITERATOR}]",
question_num: 4,
question_suffix: '(2)',
question_text:
'SPECIFY NAME OF INCOME RECIPIENT (Only needed if Custodian of child, child, parent, or other)'
},
'payer' => {
key: "F[0].IncomePayer4[#{ITERATOR}]",
question_num: 4,
question_suffix: '(3)',
question_text: 'SPECIFY INCOME PAYER (Name of business, financial institution, or program, etc.)'
},
'incomeType' => {
key: "F[0].TypeOfIncome4[#{ITERATOR}]"
},
'incomeTypeOverflow' => {
question_num: 4,
question_suffix: '(4)',
question_text: 'SPECIFY THE TYPE OF INCOME'
},
'otherIncomeType' => {
key: "F[0].OtherIncomeType4[#{ITERATOR}]",
question_num: 4,
question_suffix: '(4)',
question_text: 'SPECIFY THE TYPE OF INCOME'
},
'grossMonthlyIncome' => {
'thousands' => {
key: "F[0].GrossMonthlyIncome1_4[#{ITERATOR}]"
},
'dollars' => {
key: "F[0].GrossMonthlyIncome2_4[#{ITERATOR}]"
},
'cents' => {
key: "F[0].GrossMonthlyIncome3_4[#{ITERATOR}]"
}
},
'grossMonthlyIncomeOverflow' => {
question_num: 4,
question_suffix: '(5)',
question_text: 'GROSS MONTHLY INCOME'
},
'accountValue' => {
'millions' => {
key: "F[0].ValueOfAccount1_4[#{ITERATOR}]"
},
'thousands' => {
key: "F[0].ValueOfAccount2_4[#{ITERATOR}]"
},
'dollars' => {
key: "F[0].ValueOfAccount3_4[#{ITERATOR}]"
},
'cents' => {
key: "F[0].ValueOfAccount4_4[#{ITERATOR}]"
}
},
'accountValueOverflow' => {
question_num: 4,
question_suffix: '(6)',
question_text: 'VALUE OF ACCOUNT'
}
}
}.freeze

Expand All @@ -180,6 +271,7 @@ def merge_fields(_options = {})
expand_veteran_info
expand_claimant_info
expand_unassociated_incomes
expand_associated_incomes

form_data
end
Expand Down Expand Up @@ -242,6 +334,35 @@ def expand_unassociated_income(income)
}
end

def expand_associated_incomes
associated_incomes = form_data['associatedIncomes']
form_data['associatedIncome'] = associated_incomes&.length ? 0 : 1
form_data['associatedIncomes'] = associated_incomes&.map do |income|
expand_associated_income(income)
end
end

def expand_associated_income(income)
recipient_relationship = income['recipientRelationship']
income_type = income['incomeType']
gross_monthly_income = income['grossMonthlyIncome']
account_value = income['accountValue']
{
'recipientRelationship' => RECIPIENTS[recipient_relationship],
'recipientRelationshipOverflow' => recipient_relationship,
'otherRecipientRelationshipType' => income['otherRecipientRelationshipType'],
'recipientName' => income['recipientName'],
'payer' => income['payer'],
'incomeType' => ACCOUNT_INCOME_TYPES[income_type],
'incomeTypeOverflow' => income_type,
'otherIncomeType' => income['otherIncomeType'],
'grossMonthlyIncome' => gross_monthly_income ? split_currency_amount(gross_monthly_income) : {},
'grossMonthlyIncomeOverflow' => gross_monthly_income,
'accountValue' => account_value ? split_account_value(account_value) : {},
'accountValueOverflow' => account_value
}
end

# Format a YYYY-MM-DD date string to MM/DD/YYYY
#
# @param date_string [String] a date string in the format YYYY-MM-DD
Expand All @@ -265,6 +386,18 @@ def split_currency_amount(amount)
}
end

def split_account_value(amount)
return {} if amount.negative? || amount >= 10_000_000

arr = number_to_currency(amount).to_s.split(/[,.$]/).reject(&:empty?)
{
'cents' => get_currency_field(arr, -1, 2),
'dollars' => get_currency_field(arr, -2, 3),
'thousands' => get_currency_field(arr, -3, 3),
'millions' => get_currency_field(arr, -4, 2)
}
end

# :reek:FeatureEnvy
def get_currency_field(arr, neg_i, field_length)
value = arr.length >= -neg_i ? arr[neg_i] : 0
Expand Down
Binary file modified spec/fixtures/pdf_fill/21P-0969/kitchen_sink.pdf
Binary file not shown.
51 changes: 50 additions & 1 deletion spec/fixtures/pdf_fill/21P-0969/merge_fields.json
Original file line number Diff line number Diff line change
Expand Up @@ -103,5 +103,54 @@
"payer": "Personnel Management"
}
],
"unassociatedIncome": "YES"
"associatedIncomes": [
{
"recipientRelationship": 2,
"recipientRelationshipOverflow": "CUSTODIAN",
"otherRecipientRelationshipType": null,
"recipientName": "Jim Brown",
"payer": "Jack Smith",
"incomeType": 0,
"incomeTypeOverflow": "INTEREST",
"otherIncomeType": null,
"grossMonthlyIncome": {
"cents": "00",
"dollars": "345",
"thousands": "12"
},
"grossMonthlyIncomeOverflow": 12345,
"accountValue": {
"cents": "00",
"dollars": "987",
"thousands": "012",
"millions": "00"
},
"accountValueOverflow": 12987
},
{
"recipientRelationship": 5,
"recipientRelationshipOverflow": "OTHER",
"otherRecipientRelationshipType": "Friend",
"recipientName": "Brandon Jones",
"payer": "Harold Washington",
"incomeType": 1,
"incomeTypeOverflow": "DIVIDENDS",
"otherIncomeType": null,
"grossMonthlyIncome": {
"cents": "00",
"dollars": "987",
"thousands": "23"
},
"grossMonthlyIncomeOverflow": 23987,
"accountValue": {
"cents": "00",
"dollars": "900",
"thousands": "009",
"millions": "00"
},
"accountValueOverflow": 9900
}
],
"unassociatedIncome": "YES",
"associatedIncome": 0
}
Binary file modified spec/fixtures/pdf_fill/21P-0969/overflow.pdf
Binary file not shown.
Binary file modified spec/fixtures/pdf_fill/21P-0969/simple.pdf
Binary file not shown.
Loading