Skip to content

Commit

Permalink
burial sending update
Browse files Browse the repository at this point in the history
  • Loading branch information
wayne-weibel committed Oct 23, 2024
1 parent 47fe544 commit ce9d008
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 24 deletions.
38 changes: 15 additions & 23 deletions app/models/saved_claim/burial.rb
Original file line number Diff line number Diff line change
Expand Up @@ -62,35 +62,27 @@ def business_line
'NCA'
end

def send_confirmation_email
return if parsed_form['claimantEmail'].blank?

facility_name, street_address, city_state_zip = regional_office
first_name = parsed_form.dig('veteranFullName', 'first')
last_initial = "#{parsed_form.dig('veteranFullName', 'last')&.first}."

VANotify::EmailJob.perform_async(
parsed_form['claimantEmail'],
Settings.vanotify.services.va_gov.template_id.burial_claim_confirmation_email_template_id,
{
'form_name' => 'Burial Benefit Claim (Form 21P-530)',
'confirmation_number' => guid,
'deceased_veteran_first_name_last_initial' => "#{first_name} #{last_initial}",
'benefits_claimed' => benefits_claimed,
'facility_name' => facility_name,
'street_address' => street_address,
'city_state_zip' => city_state_zip,
'first_name' => parsed_form.dig('claimantFullName', 'first')&.upcase.presence,
'date_submitted' => Time.zone.today.strftime('%B %d, %Y')
}
)
##
# utility function to retrieve claimant first name from form
#
# @return [String] the claimant first name
#
def veteran_first_name
parsed_form.dig('veteranFullName', 'first')
end

def veteran_last_name
parsed_form.dig('veteranFullName', 'last')
end

def claimaint_first_name
parsed_form.dig('claimantFullName', 'first')
end

def benefits_claimed
claimed = []
claimed << 'Burial Allowance' if parsed_form['burialAllowance']
claimed << 'Plot Allowance' if parsed_form['plotAllowance']
claimed << 'Transportation' if parsed_form['transportation']
" - #{claimed.join(" \n - ")}"
end
end
5 changes: 5 additions & 0 deletions app/sidekiq/lighthouse/submit_benefits_intake_claim.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
require 'benefits_intake_service/service'
require 'simple_forms_api_submission/metadata_validator'
require 'pdf_info'
require 'va_notify/notification_email/burial'

module Lighthouse
class SubmitBenefitsIntakeClaim
Expand Down Expand Up @@ -182,6 +183,10 @@ def check_zipcode(address)

def send_confirmation_email
@claim.respond_to?(:send_confirmation_email) && @claim.send_confirmation_email

if %w[21P-530V2 21P-530].include?(claim&.form_id)

Check failure on line 187 in app/sidekiq/lighthouse/submit_benefits_intake_claim.rb

View workflow job for this annotation

GitHub Actions / Linting and Security

Style/IfUnlessModifier: Favor modifier `if` usage when having a single-line body. Another good alternative is the usage of control flow `&&`/`||`.
Burials::NotificationEmail.new(@claim).deliver(:confirmation)
end
rescue => e
Rails.logger.warn('Lighthouse::SubmitBenefitsIntakeClaim send_confirmation_email failed',
generate_log_details(e))
Expand Down
2 changes: 2 additions & 0 deletions config/settings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1415,6 +1415,8 @@ vanotify:
error: null
received: null
burials: *vanotify_services_burial
21p_530: *vanotify_services_burial
21p_530v2: *vanotify_services_burial
mock: false
links:
connected_applications: https://www.va.gov/profile/connected-applications
Expand Down
33 changes: 33 additions & 0 deletions lib/va_notify/notification_email/burial.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# frozen_string_literal: true

require 'va_notify/notification_email/saved_claim'

module Burials
class NotificationEmail < ::VANotify::NotificationEmail::SavedClaim
# @see VANotify::NotificationEmail::SavedClaim
def initialize(saved_claim)
super(saved_claim, service_name: 'burials')
end

private

def personalization
default = super

facility_name, street_address, city_state_zip = claim.regional_office
veteran_name = "#{claim.veteran_first_name} #{claim.veteran_last_name&.first}"
benefits_claimed = " - #{claim.benefits_claimed.join(" \n - ")}"

default.merge({
'form_name' => 'Burial Benefit Claim (Form 21P-530)',

Check failure on line 22 in lib/va_notify/notification_email/burial.rb

View workflow job for this annotation

GitHub Actions / Linting and Security

Layout/FirstHashElementIndentation: Use 2 spaces for indentation in a hash, relative to the first position after the preceding left parenthesis.
'deceased_veteran_first_name_last_initial' => veteran_name,
'benefits_claimed' => benefits_claimed,
'facility_name' => facility_name,
'street_address' => street_address,
'city_state_zip' => city_state_zip,
# override default
'first_name' => claim.claimaint_first_name&.upcase
})

Check failure on line 30 in lib/va_notify/notification_email/burial.rb

View workflow job for this annotation

GitHub Actions / Linting and Security

Layout/FirstHashElementIndentation: Indent the right brace the same as the first position after the preceding left parenthesis.
end
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,6 @@ def form_submission_polling
#
def send_confirmation_email
Pensions::NotificationEmail.new(@claim).deliver(:confirmation)
# @claim.respond_to?(:send_confirmation_email) && @claim.send_confirmation_email
rescue => e
@pension_monitor.track_send_confirmation_email_failure(@claim, @intake_service, @user_account_uuid, e)
end
Expand Down

0 comments on commit ce9d008

Please sign in to comment.