@@ -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
9731117end
0 commit comments