-
Notifications
You must be signed in to change notification settings - Fork 66
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* get evss info on 10203 form submission * don't use after_save * test * Update va10203.rb * AC 1,3,4 * Update school_certifying_officials_mailer.rb * use erb templates for email body * commit * revert * the email * Update school_certifying_officials_mailer_preview.rb * make ci * make ci * Update va10203.rb * unit tests * move config * Update school_certifying_officials_mailer_preview.rb * Update school_certifying_officials_mailer.rb * unit tests * unit tests * unit tests * unit tests * unit tests * unit tests * unit tests * code review changes * Update school_certifying_officials_mailer_spec.rb * Update va10203_spec.rb * vets-json-schema 6.4.0 * preview * Delete school_certifying_officials_mailer_preview.rb * create sidekiq job * linter, va10203_spec * Create send_sco_email_spec.rb * Update send_sco_email.rb * take advantage of params to allow for dynamic testing of SCO emails logic locally * Update school_certifying_officials_mailer_preview.rb * Update school_certifying_officials_mailer_preview.rb
- Loading branch information
1 parent
ca73193
commit c694346
Showing
21 changed files
with
629 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# frozen_string_literal: true | ||
|
||
class SchoolCertifyingOfficialsMailer < TransactionalEmailMailer | ||
SUBJECT = 'Applicant for VA Rogers STEM Scholarship' | ||
GA_CAMPAIGN_NAME = 'school-certifying-officials-10203-submission-notification' | ||
GA_DOCUMENT_PATH = '/email/form' | ||
GA_LABEL = 'school-certifying-officials-10203-submission-notification' | ||
TEMPLATE = 'school_certifying_officials' | ||
|
||
STAGING_RECIPIENTS = %w[ | ||
Delli-Gatti_Michael@bah.com | ||
roth_matthew@bah.com | ||
shawkey_daniel@bah.com | ||
sonntag_adam@bah.com | ||
].freeze | ||
|
||
def build(applicant, recipients, ga_client_id) | ||
@applicant = applicant | ||
opt = { cc: applicant.email } | ||
opt[:bcc] = STAGING_RECIPIENTS.clone if FeatureFlipper.staging_email? | ||
super(recipients, ga_client_id, opt) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,25 @@ | ||
# frozen_string_literal: true | ||
|
||
class TransactionalEmailMailer < ApplicationMailer | ||
def build(email, google_analytics_client_id) | ||
def build(email, google_analytics_client_id, opt = {}) | ||
@google_analytics_client_id = google_analytics_client_id | ||
@google_analytics_tracking_id = Settings.google_analytics_tracking_id | ||
|
||
template = File.read("app/mailers/views/#{self.class::TEMPLATE}.html.erb") | ||
|
||
mail( | ||
to: email, | ||
subject: self.class::SUBJECT, | ||
content_type: 'text/html', | ||
body: ERB.new(template).result(binding) | ||
opt.merge( | ||
to: email, | ||
subject: self.class::SUBJECT, | ||
content_type: 'text/html', | ||
body: ERB.new(template).result(binding) | ||
) | ||
) | ||
end | ||
|
||
def first_initial_last_name(name) | ||
return '' if name.nil? | ||
|
||
"#{name.first[0, 1]} #{name.last}" | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta content='text/html; charset=UTF-8' http-equiv='Content-Type' /> | ||
</head> | ||
<body> | ||
<p>Dear VA School Certifying Official,</p> | ||
|
||
<p>A student enrolled at your school has applied for the Edith Nourse Rogers STEM Scholarship. They will also receive a copy of this letter. We aren’t able to make a formal determination on this student’s eligibility for the STEM Scholarship until we receive the following information from you.</p> | ||
|
||
<p> | ||
<b>Rogers STEM Scholarship Applicant</b> | ||
<br> | ||
Name of Student: <%= first_initial_last_name(@applicant.veteranFullName) %> | ||
<br> | ||
Student’s school email address: <%= @applicant.schoolEmailAddress %> | ||
<br> | ||
Student’s school ID number: <%= @applicant.schoolStudentId %> | ||
</p> | ||
|
||
<p> | ||
<b>If the applicant is an undergraduate</b> | ||
<br> | ||
If the student is currently enrolled in an undergraduate program, please provide the following: | ||
<ul> | ||
<li> | ||
Is the student pursuing a bachelor’s degree in an approved STEM program?: | ||
(<a href="https://benefits.va.gov/gibill/docs/fgib/STEM_Program_List.pdf">Programs approved for the Rogers STEM Scholarship</a>) | ||
</li> | ||
<li>Name of STEM program student is enrolled in:</li> | ||
<li>6-digit CIP Code for the program:</li> | ||
<li>Credit hours completed toward STEM program (specify semester or quarter):</li> | ||
<li>Required credit hours for STEM program (specify semester or quarter):</li> | ||
</ul> | ||
</p> | ||
|
||
<p> | ||
<b>If the applicant is a teaching certificate candidate</b> | ||
<br> | ||
If the student already has an undergraduate degree and is seeking a teaching certification, please provide the following: | ||
<ul> | ||
<li> | ||
Has the student earned a bachelor’s degree in an approved STEM program?: | ||
(<a href="https://benefits.va.gov/gibill/docs/fgib/STEM_Program_List.pdf">Programs approved for the Rogers STEM Scholarship</a>) | ||
</li> | ||
<li>Name of STEM program of degree conferred:</li> | ||
<li>6-digit CIP Code of degree conferred:</li> | ||
<li>Is the student currently enrolled in a program leading to a teaching certification?:</li> | ||
</ul> | ||
</p> | ||
|
||
<p> | ||
<b>A reply is requested as soon as possible, preferably within 14 days.</b> | ||
Please submit your response to <a href="mailto:STEM.VBABUF@va.gov">STEM.VBABUF@va.gov</a>. If we don’t receive a response within that time, we won’t be able to process the student’s application for the Rogers STEM Scholarship. | ||
</p> | ||
|
||
<p>Please submit any questions or concerns to <a href="mailto:STEM.VBABUF@va.gov">STEM.VBABUF@va.gov</a>. Please account for the 14-day time limit when submitting these questions.</p> | ||
|
||
<p>Thank you,</p> | ||
|
||
<p> | ||
Rogers STEM Scholarship Team<br> | ||
VA Buffalo Regional Processing Office<br> | ||
<br> | ||
<br> | ||
VA Form Number: 10203<br> | ||
OMB Control Number: 2900-0878<br> | ||
OMB Expiration Date: 6/30/2023<br> | ||
Respondent Burden: 15 minutes<br> | ||
cc: <%= @applicant.email %> | ||
</p> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
# frozen_string_literal: true | ||
|
||
module EducationForm | ||
class SendSCOEmail | ||
include Sidekiq::Worker | ||
|
||
def perform(user_uuid, claim_id) | ||
@user = User.find(user_uuid) | ||
@claim = SavedClaim::EducationBenefits::VA10203.find(claim_id) | ||
|
||
email_sent(false) | ||
|
||
@gi_bill_status = get_gi_bill_status | ||
if less_than_six_months? | ||
@facility_code = get_facility_code | ||
|
||
if @facility_code.present? | ||
@institution = get_institution | ||
|
||
send_sco_email | ||
end | ||
end | ||
end | ||
|
||
def self.sco_emails(scos) | ||
emails = [] | ||
primary = scos.find { |sco| sco[:priority] == 'Primary' && sco[:email].present? } | ||
secondary = scos.find { |sco| sco[:priority] == 'Secondary' && sco[:email].present? } | ||
|
||
emails.push(primary[:email]) if primary.present? | ||
emails.push(secondary[:email]) if secondary.present? | ||
|
||
emails | ||
end | ||
|
||
private | ||
|
||
def email_sent(sco_email_sent) | ||
application = @claim.parsed_form | ||
application['scoEmailSent'] = sco_email_sent | ||
@claim.form = JSON.generate(application) | ||
@claim.save | ||
end | ||
|
||
def get_gi_bill_status | ||
service = EVSS::GiBillStatus::Service.new(@user) | ||
service.get_gi_bill_status | ||
rescue => e | ||
Rails.logger.error "Failed to retrieve GiBillStatus data: #{e.message}" | ||
{} | ||
end | ||
|
||
def get_facility_code | ||
most_recent = @gi_bill_status.enrollments.max_by(&:begin_date) | ||
|
||
return {} if most_recent.blank? | ||
|
||
most_recent.facility_code | ||
end | ||
|
||
def get_institution | ||
GIDSRedis.new.get_institution_details({ id: @facility_code })[:data][:attributes] | ||
end | ||
|
||
def less_than_six_months? | ||
return false if @gi_bill_status.remaining_entitlement.blank? | ||
|
||
months = @gi_bill_status.remaining_entitlement.months | ||
days = @gi_bill_status.remaining_entitlement.days | ||
|
||
((months * 30) + days) <= 180 | ||
end | ||
|
||
def school_changed? | ||
application = @claim.parsed_form | ||
form_school_name = application['schoolName'] | ||
form_school_city = application['schoolCity'] | ||
form_school_state = application['schoolState'] | ||
|
||
prefill_name = @institution[:name] | ||
prefill_city = @institution[:city] | ||
prefill_state = @institution[:state] | ||
|
||
form_school_name != prefill_name || | ||
form_school_city != prefill_city || | ||
form_school_state != prefill_state | ||
end | ||
|
||
def send_sco_email | ||
return if @institution.blank? || school_changed? | ||
|
||
emails = recipients | ||
|
||
if emails.any? | ||
SchoolCertifyingOfficialsMailer.build(@claim.open_struct_form, emails, nil).deliver_now | ||
email_sent(true) | ||
end | ||
end | ||
|
||
def recipients | ||
scos = @institution[:versioned_school_certifying_officials] | ||
EducationForm::SendSCOEmail.sco_emails(scos) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# frozen_string_literal: true | ||
|
||
FactoryBot.define do | ||
factory :gi_bill_status_response, class: EVSS::GiBillStatus::GiBillStatusResponse do | ||
remaining_entitlement { { months: 0, days: 12 } } | ||
enrollments { | ||
[{ | ||
begin_date: '2012-11-01T04:00:00.000+00:00', | ||
end_date: '2012-12-01T05:00:00.000+00:00', | ||
facility_code: '11902614', | ||
facility_name: 'Purdue University', | ||
participant_id: '11170323', | ||
training_type: 'UNDER_GRAD', | ||
term_id: nil, | ||
hour_type: nil, | ||
full_time_hours: 12, | ||
full_time_credit_hour_under_grad: nil, | ||
vacation_day_count: 0, | ||
on_campus_hours: 12.0, | ||
online_hours: 0.0, | ||
yellow_ribbon_amount: 0.0, | ||
status: 'Approved', | ||
amendments: [] | ||
}] | ||
} | ||
initialize_with { new(status: 200, response: {}) } | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
# frozen_string_literal: true | ||
|
||
FactoryBot.define do | ||
factory :gids_response, class: GI::GIDSResponse do | ||
status { 200 } | ||
body { | ||
{ | ||
data: | ||
{ | ||
attributes: { | ||
name: 'School Name', | ||
city: 'Test', | ||
state: 'TN', | ||
versioned_school_certifying_officials: [ | ||
{ | ||
priority: 'Primary', | ||
email: 'test@edu_sample.com' | ||
}, | ||
{ | ||
priority: 'Secondary', | ||
email: 'test@edu_sample.com' | ||
} | ||
] | ||
} | ||
} | ||
} | ||
} | ||
|
||
trait :empty do | ||
body { | ||
{ | ||
data: { | ||
attributes: {} | ||
} | ||
} | ||
} | ||
end | ||
|
||
trait :no_scos do | ||
body { | ||
{ | ||
data: { | ||
attributes: { | ||
name: 'School Name', | ||
city: 'Test', | ||
state: 'TN', | ||
versioned_school_certifying_officials: [] | ||
} | ||
} | ||
} | ||
} | ||
end | ||
end | ||
end |
Oops, something went wrong.