diff --git a/app/forms/journeys/further_education_payments/claim_submission_form.rb b/app/forms/journeys/further_education_payments/claim_submission_form.rb index d144f29046..6feeb5b2bf 100644 --- a/app/forms/journeys/further_education_payments/claim_submission_form.rb +++ b/app/forms/journeys/further_education_payments/claim_submission_form.rb @@ -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 diff --git a/app/mailers/application_mailer.rb b/app/mailers/application_mailer.rb index 1f696937f3..7f5503c133 100644 --- a/app/mailers/application_mailer.rb +++ b/app/mailers/application_mailer.rb @@ -34,4 +34,10 @@ class ApplicationMailer < Mail::Notify::Mailer EARLY_YEARS_PAYMENTS = { CLAIM_PROVIDER_EMAIL_TEMPLATE_ID: "e0b78a08-601b-40ba-a97f-61fb00a7c951".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 diff --git a/app/mailers/claim_mailer.rb b/app/mailers/claim_mailer.rb index 5e69b8b4f2..0736e6ed1b 100644 --- a/app/mailers/claim_mailer.rb +++ b/app/mailers/claim_mailer.rb @@ -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) diff --git a/app/models/journeys/further_education_payments/provider/slug_sequence.rb b/app/models/journeys/further_education_payments/provider/slug_sequence.rb index a4c90fa449..89e7cb2765 100644 --- a/app/models/journeys/further_education_payments/provider/slug_sequence.rb +++ b/app/models/journeys/further_education_payments/provider/slug_sequence.rb @@ -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 diff --git a/app/models/policies/further_education_payments/eligibility.rb b/app/models/policies/further_education_payments/eligibility.rb index 233d9ce9c9..97a8ff285b 100644 --- a/app/models/policies/further_education_payments/eligibility.rb +++ b/app/models/policies/further_education_payments/eligibility.rb @@ -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 diff --git a/spec/forms/journeys/further_education_payments/claim_submission_form_spec.rb b/spec/forms/journeys/further_education_payments/claim_submission_form_spec.rb index df6a3a5573..070055035a 100644 --- a/spec/forms/journeys/further_education_payments/claim_submission_form_spec.rb +++ b/spec/forms/journeys/further_education_payments/claim_submission_form_spec.rb @@ -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