Skip to content

Commit 3653514

Browse files
authored
Pensions | Adding skeleton section classes; moving expansion logic for Section 7 into its file (#24877)
* Adding skeleton section classes; moving expansion logic for Section 7 into its file
1 parent 5344281 commit 3653514

File tree

8 files changed

+419
-37
lines changed

8 files changed

+419
-37
lines changed
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# frozen_string_literal: true
2+
3+
require_relative '../section'
4+
5+
module Pensions
6+
module PdfFill
7+
# Section II: Vewteran's Contact Information
8+
class Section2 < Section
9+
# Section configuration hash
10+
KEY = {}.freeze
11+
12+
##
13+
# Expand the form data for prior marital history.
14+
#
15+
# @param form_data [Hash] The form data hash.
16+
#
17+
# @return [void]
18+
#
19+
# Note: This method modifies `form_data`
20+
#
21+
def expand(form_data)
22+
# Add expansion logic here
23+
end
24+
end
25+
end
26+
end
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# frozen_string_literal: true
2+
3+
require_relative '../section'
4+
5+
module Pensions
6+
module PdfFill
7+
# Section III: Veteran Service Information
8+
class Section3 < Section
9+
# Section configuration hash
10+
KEY = {}.freeze
11+
12+
##
13+
# Expand the form data for prior marital history.
14+
#
15+
# @param form_data [Hash] The form data hash.
16+
#
17+
# @return [void]
18+
#
19+
# Note: This method modifies `form_data`
20+
#
21+
def expand(form_data)
22+
# Add expansion logic here
23+
end
24+
end
25+
end
26+
end
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# frozen_string_literal: true
2+
3+
require_relative '../section'
4+
5+
module Pensions
6+
module PdfFill
7+
# Section IV: Pension Information
8+
class Section4 < Section
9+
# Section configuration hash
10+
KEY = {}.freeze
11+
12+
##
13+
# Expand the form data for prior marital history.
14+
#
15+
# @param form_data [Hash] The form data hash.
16+
#
17+
# @return [void]
18+
#
19+
# Note: This method modifies `form_data`
20+
#
21+
def expand(form_data)
22+
# Add expansion logic here
23+
end
24+
end
25+
end
26+
end
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# frozen_string_literal: true
2+
3+
require_relative '../section'
4+
5+
module Pensions
6+
module PdfFill
7+
# Section V: Employment History
8+
class Section5 < Section
9+
# Section configuration hash
10+
KEY = {}.freeze
11+
12+
##
13+
# Expand the form data for prior marital history.
14+
#
15+
# @param form_data [Hash] The form data hash.
16+
#
17+
# @return [void]
18+
#
19+
# Note: This method modifies `form_data`
20+
#
21+
def expand(form_data)
22+
# Add expansion logic here
23+
end
24+
end
25+
end
26+
end
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# frozen_string_literal: true
2+
3+
require_relative '../section'
4+
5+
module Pensions
6+
module PdfFill
7+
# Section VI: Marital Status
8+
class Section6 < Section
9+
# Section configuration hash
10+
KEY = {}.freeze
11+
12+
##
13+
# Expand the form data for prior marital history.
14+
#
15+
# @param form_data [Hash] The form data hash.
16+
#
17+
# @return [void]
18+
#
19+
# Note: This method modifies `form_data`
20+
#
21+
def expand(form_data)
22+
# Add expansion logic here
23+
end
24+
end
25+
end
26+
end
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
# frozen_string_literal: true
2+
3+
require_relative '../section'
4+
5+
module Pensions
6+
module PdfFill
7+
# Section VII: Prior Marital History
8+
class Section7 < Section
9+
# Section configuration hash
10+
KEY = {}.freeze
11+
12+
##
13+
# Expand the form data for prior marital history.
14+
#
15+
# @param form_data [Hash] The form data hash.
16+
#
17+
# @return [void]
18+
#
19+
# Note: This method modifies `form_data`
20+
#
21+
def expand(form_data)
22+
expand_prior_marital_history(form_data)
23+
end
24+
25+
##
26+
# Expand prior marital history data.
27+
#
28+
# @param form_data [Hash] The form data hash.
29+
#
30+
# @return [void]
31+
#
32+
# Note: This method modifies `form_data`
33+
#
34+
def expand_prior_marital_history(form_data)
35+
form_data['marriages'] = build_marital_history(form_data['marriages'], 'VETERAN')
36+
form_data['spouseMarriages'] = build_marital_history(form_data['spouseMarriages'], 'SPOUSE')
37+
if form_data['marriages']&.any?
38+
form_data['additionalMarriages'] = to_radio_yes_no(form_data['marriages'].length.to_i > 3)
39+
end
40+
if form_data['spouseMarriages']&.any?
41+
form_data['additionalSpouseMarriages'] = to_radio_yes_no(form_data['spouseMarriages'].length.to_i > 2)
42+
end
43+
end
44+
45+
##
46+
# Build marital history entries.
47+
#
48+
# @param marriages [Array<Hash>] The array of marriage entries.
49+
# @param marriage_for [String] Indicates whether the marriages are for 'VETERAN' or 'SPOUSE'.
50+
#
51+
# @return [Array<Hash>] The processed array of marriage entries.
52+
#
53+
def build_marital_history(marriages, marriage_for = 'VETERAN')
54+
return [] unless marriages.present? && %w[VETERAN SPOUSE].include?(marriage_for)
55+
56+
marriages.map do |marriage|
57+
reason_for_separation = marriage['reasonForSeparation'].to_s
58+
marriage_date_range = {
59+
'from' => marriage['dateOfMarriage'],
60+
'to' => marriage['dateOfSeparation']
61+
}
62+
marriage.merge!({ 'spouseFullNameOverflow' => marriage['spouseFullName']&.values&.join(' '),
63+
'dateOfMarriage' => split_date(marriage['dateOfMarriage']),
64+
'dateOfSeparation' => split_date(marriage['dateOfSeparation']),
65+
'dateRangeOfMarriageOverflow' => build_date_range_string(marriage_date_range),
66+
'reasonForSeparation' => Constants::REASONS_FOR_SEPARATION[reason_for_separation],
67+
'reasonForSeparationOverflow' => reason_for_separation.humanize })
68+
marriage['spouseFullName']['middle'] = marriage['spouseFullName']['middle']&.first
69+
marriage
70+
end
71+
end
72+
end
73+
end
74+
end

0 commit comments

Comments
 (0)