Skip to content

Commit

Permalink
Email provider
Browse files Browse the repository at this point in the history
When the claimant submits their application we need to send an email out
to the provider to verify the claim.
This commit adds the mechanism to send the verification email.

Currently we've stubbed the verification deadline, to submission date +
1 week, while we wait on finding out what the actual deadline should be.
We've also set the email template for the claimant email to a,
temporary, empty template so the mailer doesn't error.
  • Loading branch information
rjlynch committed Aug 29, 2024
1 parent 6d89bbe commit a861811
Show file tree
Hide file tree
Showing 6 changed files with 62 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
module Journeys
module FurtherEducationPayments
class ClaimSubmissionForm < ::ClaimSubmissionBaseForm
def save
super

ClaimMailer.further_education_payment_provider_verification_email(claim).deliver_later
end

private

def main_eligibility
Expand Down
6 changes: 6 additions & 0 deletions app/mailers/application_mailer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,10 @@ class ApplicationMailer < Mail::Notify::Mailer
CLAIM_PROVIDER_EMAIL_TEMPLATE_ID: "e0b78a08-601b-40ba-a97f-61fb00a7c951".freeze,
CLAIM_RECEIVED_NOTIFY_TEMPLATE_ID: "149c5999-12fb-4b99-aff5-23a7c3302783".freeze
}
FURTHER_EDUCATION_PAYMENTS = {
CLAIM_PROVIDER_VERIFICATION_EMAIL_TEMPLATE_ID: "9a25fe46-2ee4-4a5c-8d47-0f04f058a87d".freeze,
# FIXME this is just a place holder - it's an empty template
# Correct copy will be added as part of LUPEYALPHA-848
CLAIM_RECEIVED_NOTIFY_TEMPLATE_ID: NOTIFY_TEMPLATE_ID
}
end
21 changes: 21 additions & 0 deletions app/mailers/claim_mailer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,27 @@ def early_years_payment_provider_email(claim, one_time_password, email)
send_mail(template_ids(claim)[:CLAIM_PROVIDER_EMAIL_TEMPLATE_ID], personalisation)
end

def further_education_payment_provider_verification_email(claim)
unknown_policy_check(claim)

personalisation = {
recipient_name: claim.school.name,
claimant_name: claim.full_name,
claim_reference: claim.reference,
claim_submission_date: claim.created_at.to_s(:govuk_date),
verification_due_date: claim.eligibility.verification_deadline.to_s(:govuk_date),
verification_url: Journeys::FurtherEducationPayments::Provider::SlugSequence.verify_claim_url(claim)
}

template_id = template_ids(claim)[:CLAIM_PROVIDER_VERIFICATION_EMAIL_TEMPLATE_ID]

template_mail(
template_id,
to: claim.school.eligible_fe_provider.primary_key_contact_email_address,
personalisation: personalisation
)
end

private

def set_common_instance_variables(claim)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,13 @@ class SlugSequence
]

def self.verify_claim_url(claim)
Rails.application.routes.url_helpers.new_claim_path(
Rails.application.routes.url_helpers.new_claim_url(
module_parent::ROUTING_NAME,
answers: {
claim_id: claim.id
}
},
host: ENV.fetch("CANONICAL_HOSTNAME"),
protocol: "https"
)
end

Expand Down
5 changes: 5 additions & 0 deletions app/models/policies/further_education_payments/eligibility.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,11 @@ def fixed_contract?
def verified?
verification.present?
end

# FIXME LUPEYALPHA-923
def verification_deadline
created_at + 1.week
end
end
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -60,5 +60,25 @@
expect(eligibility.subject_to_disciplinary_action).to eq(answers.subject_to_disciplinary_action)
expect(eligibility.half_teaching_hours).to eq(answers.half_teaching_hours)
end

it "emails the claim provider" do
allow(ClaimVerifierJob).to receive(:perform_later)

perform_enqueued_jobs { subject }

claim = form.claim

expect(claim.school.eligible_fe_provider.primary_key_contact_email_address).to(
have_received_email(
"9a25fe46-2ee4-4a5c-8d47-0f04f058a87d",
recipient_name: claim.school.name,
claimant_name: [answers.first_name, answers.surname].join(" "),
claim_reference: claim.reference,
claim_submission_date: claim.submitted_at.to_s(:govuk_date),
verification_due_date: claim.eligibility.verification_deadline.to_s(:govuk_date),
verification_url: Journeys::FurtherEducationPayments::Provider::SlugSequence.verify_claim_url(claim)
)
)
end
end
end

0 comments on commit a861811

Please sign in to comment.