diff --git a/lib/pdf_fill/forms/va21p530v2.rb b/lib/pdf_fill/forms/va21p530v2.rb index 6350a4228cf..06b70f63a83 100644 --- a/lib/pdf_fill/forms/va21p530v2.rb +++ b/lib/pdf_fill/forms/va21p530v2.rb @@ -719,6 +719,9 @@ def merge_fields(_options = {}) expand_cemetery_location + # special case: the UI only has a 'yes' checkbox, so the PDF 'noTransportation' checkbox can never be true. + @form_data['hasTransportation'] = @form_data['transportation'] == true ? 'YES' : nil + # special case: these fields were built as checkboxes instead of radios, so usual radio logic can't be used. burial_expense_responsibility = @form_data['burialExpenseResponsibility'] @form_data['hasBurialExpenseResponsibility'] = burial_expense_responsibility ? 'On' : nil @@ -759,7 +762,6 @@ def merge_fields(_options = {}) govtContributions previouslyReceivedAllowance allowanceStatementOfTruth - transportation ].each do |attr| expand_checkbox_in_place(@form_data, attr) end diff --git a/spec/fixtures/pdf_fill/21P-530V2/merge_fields.json b/spec/fixtures/pdf_fill/21P-530V2/merge_fields.json index 14bc65e70fe..6a3d5430846 100644 --- a/spec/fixtures/pdf_fill/21P-530V2/merge_fields.json +++ b/spec/fixtures/pdf_fill/21P-530V2/merge_fields.json @@ -74,6 +74,7 @@ "signatureDate":"2024-03-21", "veteranSocialSecurityNumber2":{"first":"987", "second":"65", "third":"4322"}, "veteranSocialSecurityNumber3":{"first":"987", "second":"65", "third":"4322"}, + "hasTransportation":"YES", "hasBurialExpenseResponsibility":"On", "noBurialExpenseResponsibility":null, "hasPlotExpenseResponsibility":"On", @@ -93,7 +94,5 @@ "hasPreviouslyReceivedAllowance":"YES", "noPreviouslyReceivedAllowance":null, "hasAllowanceStatementOfTruth":null, - "noAllowanceStatementOfTruth":null, - "hasTransportation":"YES", - "noTransportation":null + "noAllowanceStatementOfTruth":null } \ No newline at end of file diff --git a/spec/lib/pdf_fill/forms/va21p530v2_spec.rb b/spec/lib/pdf_fill/forms/va21p530v2_spec.rb index 58dd79761a1..6810eb956d8 100644 --- a/spec/lib/pdf_fill/forms/va21p530v2_spec.rb +++ b/spec/lib/pdf_fill/forms/va21p530v2_spec.rb @@ -142,5 +142,18 @@ def class_form_data get_fixture('pdf_fill/21P-530V2/merge_fields').to_json ) end + + it 'leaves benefit selections blank on pdf if unselected', run_at: '2024-03-21 00:00:00 EDT' do + unselected_benefits_data = get_fixture('pdf_fill/21P-530V2/kitchen_sink').except( + 'burialAllowance', 'plotAllowance', 'transportation' + ) + expected_merge_data = get_fixture('pdf_fill/21P-530V2/merge_fields').except( + 'burialAllowance', 'plotAllowance', 'transportation' + ) + expected_merge_data['hasTransportation'] = nil + expect(described_class.new(unselected_benefits_data).merge_fields.to_json).to eq( + expected_merge_data.to_json + ) + end end end