Skip to content

Commit c7a6b32

Browse files
authored
[DBEX] set indicator object from submitted string value
1 parent f23980d commit c7a6b32

File tree

6 files changed

+16
-21
lines changed

6 files changed

+16
-21
lines changed

lib/pdf_fill/forms/va210781v2.rb

+11
Original file line numberDiff line numberDiff line change
@@ -619,6 +619,7 @@ def merge_fields(_options = {})
619619

620620
set_treatment_selection
621621
set_reports_selection
622+
set_option_indicator
622623

623624
format_other_behavior_details
624625
format_police_report_location
@@ -674,6 +675,16 @@ def set_reports_selection
674675
@form_data['otherReport'] = reports['other'] ? 4 : nil
675676
end
676677

678+
def set_option_indicator
679+
selected_option = @form_data['optionIndicator']
680+
valid_options = %w[yes no revoke notEnrolled]
681+
682+
return if selected_option.nil? || valid_options.exclude?(selected_option)
683+
684+
@form_data['optionIndicator'] = valid_options.index_with { |_option| false }
685+
@form_data['optionIndicator'][selected_option] = true
686+
end
687+
677688
def format_other_behavior_details
678689
other_behavior = @form_data['behaviors']&.[]('otherBehavior')
679690
return if other_behavior.blank?

spec/fixtures/pdf_fill/21-0781V2/kitchen_sink.json

+1-6
Original file line numberDiff line numberDiff line change
@@ -115,11 +115,6 @@
115115
"noDates": true
116116
}
117117
],
118-
"optionIndicator": {
119-
"yes": false,
120-
"no": false,
121-
"revoke": false,
122-
"notEnrolled": true
123-
},
118+
"optionIndicator": "notEnrolled",
124119
"signatureDate": "2016-01-31"
125120
}

spec/fixtures/pdf_fill/21-0781V2/overflow.json

+1-6
Original file line numberDiff line numberDiff line change
@@ -144,11 +144,6 @@
144144
"noDates": true
145145
}
146146
],
147-
"optionIndicator": {
148-
"yes": false,
149-
"no": false,
150-
"revoke": false,
151-
"notEnrolled": true
152-
},
147+
"optionIndicator": "notEnrolled",
153148
"signatureDate": "2016-01-31"
154149
}

spec/support/disability_compensation_form/all_claims_with_0781v2_fe_submission.json

+1-3
Original file line numberDiff line numberDiff line change
@@ -241,9 +241,7 @@
241241
"noDates": true
242242
}
243243
],
244-
"optionIndicator": {
245-
"notEnrolled": true
246-
},
244+
"optionIndicator": "notEnrolled",
247245
"additionalInformation": "Lorem ipsum dolor sit amet."
248246
}
249247
}

spec/support/disability_compensation_form/form_0781v2.json

+1-3
Original file line numberDiff line numberDiff line change
@@ -116,9 +116,7 @@
116116
"noDates": true
117117
}
118118
],
119-
"optionIndicator": {
120-
"notEnrolled": true
121-
},
119+
"optionIndicator": "notEnrolled",
122120
"additionalInformation": "Lorem ipsum dolor sit amet."
123121
}
124122
}

spec/support/disability_compensation_form/submissions/with_0781v2.json

+1-3
Original file line numberDiff line numberDiff line change
@@ -421,9 +421,7 @@
421421
"noDates": true
422422
}
423423
],
424-
"optionIndicator": {
425-
"notEnrolled": true
426-
},
424+
"optionIndicator": "notEnrolled",
427425
"additionalInformation": "Lorem ipsum dolor sit amet."
428426
}
429427
},

0 commit comments

Comments
 (0)