Skip to content

Commit 725b027

Browse files
authored
Add annuities (#21623)
1 parent af03e32 commit 725b027

File tree

7 files changed

+197
-2
lines changed

7 files changed

+197
-2
lines changed

modules/income_and_assets/lib/income_and_assets/pdf_fill/forms/va21p0969.rb

Lines changed: 144 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -566,6 +566,110 @@ class Va21p0969 < ::PdfFill::Forms::FormBase
566566
question_text: 'DO YOU HAVE ANY ADDITIONAL AUTHORITY OR CONTROL OF THE TRUST?'
567567
}
568568
},
569+
# 9a
570+
'annuity' => { key: 'F[0].#subform[8].DependentsEstablishedAnnuity9a[0]' },
571+
'annuities' => {
572+
limit: 1,
573+
first_key: 'establishedDate',
574+
# 9b
575+
'establishedDate' => {
576+
'month' => { key: "F[0].#subform[8].DateAnnuityWasEstablishedMonth[#{ITERATOR}]" },
577+
'day' => { key: "F[0].#subform[8].DateAnnuityWasEstablishedDay[#{ITERATOR}]" },
578+
'year' => { key: "F[0].#subform[8].DateAnnuityWasEstablishedYear[#{ITERATOR}]" }
579+
},
580+
'establishedDateOverflow' => {
581+
question_num: 9,
582+
question_suffix: '(b)',
583+
question_text: 'SPECIFY DATE ANNUITY WAS ESTABLISHED'
584+
},
585+
# 9c
586+
'marketValueAtEstablishment' => {
587+
'millions' => { key: "F[0].#subform[8].MarketAnnuity1_9c[#{ITERATOR}]" },
588+
'thousands' => { key: "F[0].#subform[8].MarketAnnuity2_9c[#{ITERATOR}]" },
589+
'dollars' => { key: "F[0].#subform[8].MarketAnnuity3_9c[#{ITERATOR}]" },
590+
'cents' => { key: "F[0].#subform[8].MarketAnnuity4_9c[#{ITERATOR}]" }
591+
},
592+
'marketValueAtEstablishmentOverflow' => {
593+
question_num: 9,
594+
question_suffix: '(c)',
595+
question_text: 'SPECIFY MARKET VALUE OF ASSET AT TIME OF ANNUITY PURCHASE'
596+
},
597+
# 9d
598+
'addedFundsAfterEstablishment' => { key: 'F[0].#subform[8].AddedFundsToAnnuity9d[0]' },
599+
'addedFundsAfterEstablishmentOverflow' => {
600+
question_num: 9,
601+
question_suffix: '(d)',
602+
question_text: 'HAVE YOU ADDED FUNDS TO THE ANNUITY IN THE CURRENT OR PRIOR THREE YEARS?'
603+
},
604+
# 9e
605+
'addedFundsDate' => {
606+
'month' => { key: "F[0].#subform[8].DateAdditionalFundsTransferredMonth[#{ITERATOR}]" },
607+
'day' => { key: "F[0].#subform[8].DateAdditionalFundsTransferredDay[#{ITERATOR}]" },
608+
'year' => { key: "F[0].#subform[8].DateAdditionalFundsTransferredYear[#{ITERATOR}]" }
609+
},
610+
'addedFundsDateOverflow' => {
611+
question_num: 9,
612+
question_suffix: '(e)',
613+
question_text: 'WHEN DID YOU ADD FUNDS?'
614+
},
615+
# 9f
616+
'addedFundsAmount' => {
617+
'millions' => { key: "F[0].#subform[8].HowMuchTransferred1_9f[#{ITERATOR}]" },
618+
'thousands' => { key: "F[0].#subform[8].HowMuchTransferred2_9f[#{ITERATOR}]" },
619+
'dollars' => { key: "F[0].#subform[8].HowMuchTransferred3_9f[#{ITERATOR}]" },
620+
'cents' => { key: "F[0].#subform[8].HowMuchTransferred4_9f[#{ITERATOR}]" }
621+
},
622+
'addedFundsAmountOverflow' => {
623+
question_num: 9,
624+
question_suffix: '(f)',
625+
question_text: 'HOW MUCH DID YOU ADD?'
626+
},
627+
# 9g
628+
'revocable' => { key: "F[0].#subform[8].Annuity9g[#{ITERATOR}]" },
629+
'revocableOverflow' => {
630+
question_num: 9,
631+
question_suffix: '(g)',
632+
question_text: 'IS THE ANNUITY REVOCABLE OR IRREVOCABLE?'
633+
},
634+
# 9h
635+
'receivingIncomeFromAnnuity' => { key: "F[0].#subform[8].ReceiveIncomeFromAnnuity9h[#{ITERATOR}]" },
636+
'receivingIncomeFromAnnuityOverflow' => {
637+
question_num: 9,
638+
question_suffix: '(h)',
639+
question_text: 'DO YOU RECEIVE INCOME FROM THE ANNUNITY?'
640+
},
641+
# 9i
642+
'annualReceivedIncome' => {
643+
'millions' => { key: "F[0].#subform[8].AnnualAmountReceived1_9i[#{ITERATOR}]" },
644+
'thousands' => { key: "F[0].#subform[8].AnnualAmountReceived2_9i[#{ITERATOR}]" },
645+
'dollars' => { key: "F[0].#subform[8].AnnualAmountReceived3_9i[#{ITERATOR}]" },
646+
'cents' => { key: "F[0].#subform[8].AnnualAmountReceived4_9i[#{ITERATOR}]" }
647+
},
648+
'annualReceivedIncomeOverflow' => {
649+
question_num: 9,
650+
question_suffix: '(i)',
651+
question_text: 'IF YES IN 9H, PROVIDE ANNUAL AMOUNT RECEIVED'
652+
},
653+
# 9j
654+
'canBeLiquidated' => { key: "F[0].#subform[8].AnnuityLiquidated9j[#{ITERATOR}]" },
655+
'canBeLiquidatedOverflow' => {
656+
question_num: 9,
657+
question_suffix: '(j)',
658+
question_text: 'CAN THE ANNUITY BE LIQUIDATED?'
659+
},
660+
# 9k
661+
'surrenderValue' => {
662+
'millions' => { key: "F[0].#subform[8].SurrenderValue1_9k[#{ITERATOR}]" },
663+
'thousands' => { key: "F[0].#subform[8].SurrenderValue2_9k[#{ITERATOR}]" },
664+
'dollars' => { key: "F[0].#subform[8].SurrenderValue3_9k[#{ITERATOR}]" },
665+
'cents' => { key: "F[0].#subform[8].SurrenderValue4_9k[#{ITERATOR}]" }
666+
},
667+
'surrenderValueOverflow' => {
668+
question_num: 9,
669+
question_suffix: '(k)',
670+
question_text: 'IF YES IN 9J, PROVIDE THE SURRENDER VALUE'
671+
}
672+
},
569673
# Section 11
570674
# 11a
571675
'discontinuedIncome' => { key: 'F[0].#subform[9].DependentReceiveIncome11a[0]' },
@@ -665,6 +769,7 @@ def merge_fields(_options = {})
665769
expand_owned_assets
666770
expand_asset_transfers
667771
expand_trusts
772+
expand_annuities
668773
expand_discontinued_incomes
669774

670775
form_data
@@ -968,6 +1073,45 @@ def expand_discontinued_income(income)
9681073

9691074
expanded.merge(overrides)
9701075
end
1076+
1077+
##
1078+
# Expands annuities by processing each annuity entry and setting an indicator
1079+
# based on the presence of annuities.
1080+
#
1081+
# @note Modifies `form_data`
1082+
#
1083+
def expand_annuities
1084+
annuities = form_data['annuities']
1085+
form_data['annuity'] = annuities&.length ? 0 : 1
1086+
form_data['annuities'] = annuities&.map { |annuity| expand_annuity(annuity) }
1087+
end
1088+
1089+
##
1090+
# Expands a annuity's data by processing its attributes and transforming them into structured output
1091+
#
1092+
# @param annuity [Hash]
1093+
# @return [Hash]
1094+
#
1095+
def expand_annuity(annuity)
1096+
market_value = split_currency_amount_lg(annuity['marketValueAtEstablishment'], { 'millions' => 1 })
1097+
expanded = {
1098+
'addedFundsDate' => split_date(annuity['addedFundsDate']),
1099+
'addedFundsAmount' => split_currency_amount_lg(annuity['addedFundsAmount'], { 'millions' => 1 }),
1100+
'addedFundsAfterEstablishment' => annuity['addedFundsAfterEstablishment'] ? 0 : 1,
1101+
'canBeLiquidated' => annuity['canBeLiquidated'] ? 0 : 1,
1102+
'surrenderValue' => split_currency_amount_lg(annuity['surrenderValue'], { 'millions' => 1 }),
1103+
'receivingIncomeFromAnnuity' => annuity['receivingIncomeFromAnnuity'] ? 0 : 1,
1104+
'annualReceivedIncome' => split_currency_amount_lg(annuity['annualReceivedIncome'], { 'millions' => 1 }),
1105+
'revocable' => annuity['revocable'] ? 0 : 1,
1106+
'establishedDate' => split_date(annuity['establishedDate']),
1107+
'marketValueAtEstablishment' => market_value
1108+
}
1109+
overflow = {}
1110+
expanded.each_key do |fieldname|
1111+
overflow["#{fieldname}Overflow"] = annuity[fieldname]
1112+
end
1113+
expanded.merge(overflow)
1114+
end
9711115
end
9721116
end
9731117
end
Binary file not shown.

modules/income_and_assets/spec/fixtures/pdf_fill/21P-0969/merge_fields.json

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -397,6 +397,58 @@
397397
"haveAuthorityOrControlOfTrustOverflow": true
398398
}
399399
],
400+
"annuities": [
401+
{
402+
"addedFundsDate": {
403+
"month": "02",
404+
"day": "02",
405+
"year": "2022"
406+
},
407+
"addedFundsAmount": {
408+
"cents": "22",
409+
"dollars": "222",
410+
"thousands": "222",
411+
"millions": "2"
412+
},
413+
"addedFundsAfterEstablishment": 0,
414+
"canBeLiquidated": 0,
415+
"surrenderValue": {
416+
"cents": "88",
417+
"dollars": "777",
418+
"thousands": "666",
419+
"millions": "5"
420+
},
421+
"receivingIncomeFromAnnuity": 0,
422+
"annualReceivedIncome": {
423+
"cents": "44",
424+
"dollars": "333",
425+
"thousands": "222",
426+
"millions": "1"
427+
},
428+
"revocable": 0,
429+
"establishedDate": {
430+
"month": "01",
431+
"day": "01",
432+
"year": "2020"
433+
},
434+
"marketValueAtEstablishment": {
435+
"cents": "89",
436+
"dollars": "568",
437+
"thousands": "234",
438+
"millions": "1"
439+
},
440+
"addedFundsDateOverflow": "2022-02-02",
441+
"addedFundsAmountOverflow": 2222222.22,
442+
"addedFundsAfterEstablishmentOverflow": true,
443+
"canBeLiquidatedOverflow": true,
444+
"surrenderValueOverflow": 5666777.88,
445+
"receivingIncomeFromAnnuityOverflow": true,
446+
"annualReceivedIncomeOverflow": 1222333.44,
447+
"revocableOverflow": true,
448+
"establishedDateOverflow": "2020-01-01",
449+
"marketValueAtEstablishmentOverflow": 1234568.89
450+
}
451+
],
400452
"discontinuedIncomes": [
401453
{
402454
"grossAnnualAmount": {
@@ -447,5 +499,6 @@
447499
"ownedAsset": 0,
448500
"assetTransfer": 0,
449501
"trust": 0,
502+
"annuity": 0,
450503
"discontinuedIncome": 0
451504
}
Binary file not shown.
Binary file not shown.
Binary file not shown.

modules/income_and_assets/spec/lib/income_and_assets/pdf_fill/forms/va21p0969_spec.rb

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@ def basic_class
1919
# These are temporary changes and will be resolved as the mappings for the other sections get merged in
2020
# Section 6
2121
form_data.delete('royaltiesAndOtherProperties')
22-
# Section 9
23-
form_data.delete('annuities')
2422
# Section 10
2523
form_data.delete('unreportedAssets')
2624
# Section 12

0 commit comments

Comments
 (0)