Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[LUPEYALPHA-877] Send an email to the practitioner when the provider submits a claim #3219

Merged
merged 6 commits into from
Sep 26, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
alkesh marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,14 @@ module EarlyYearsPayment
module Provider
module Authenticated
class ClaimSubmissionForm < ::ClaimSubmissionBaseForm
def save
super

ClaimMailer.early_years_payment_practitioner_email(claim).deliver_later

true
end

private

def main_eligibility
Expand Down
3 changes: 2 additions & 1 deletion app/mailers/application_mailer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ class ApplicationMailer < Mail::Notify::Mailer

EARLY_YEARS_PAYMENTS = {
CLAIM_PROVIDER_EMAIL_TEMPLATE_ID: "e0b78a08-601b-40ba-a97f-61fb00a7c951".freeze,
CLAIM_RECEIVED_NOTIFY_TEMPLATE_ID: "149c5999-12fb-4b99-aff5-23a7c3302783".freeze
CLAIM_RECEIVED_NOTIFY_TEMPLATE_ID: "149c5999-12fb-4b99-aff5-23a7c3302783".freeze,
CLAIM_PRACTITIONER_NOTIFY_TEMPLATE_ID: "ef21f1d7-8a5c-4261-80b9-e1b78f844575".freeze
}
end
20 changes: 20 additions & 0 deletions app/mailers/claim_mailer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,26 @@ def early_years_payment_provider_email(claim, one_time_password, email)
send_mail(template_ids(claim)[:CLAIM_PROVIDER_EMAIL_TEMPLATE_ID], personalisation)
end

def early_years_payment_practitioner_email(claim)
policy_check!(claim, Policies::EarlyYearsPayments)

personalisation = {
full_name: claim.full_name,
setting_name: claim.eligibility.eligible_ey_provider.nursery_name,
ref_number: claim.reference,
# TODO: Reference new route for practitioner journey
complete_claim_url: "https://gov.uk/claim-an-early-years-financial-incentive-payment?claim=#{claim.reference}&email=#{CGI.escape claim.practitioner_email_address}"
}

template_id = template_ids(claim)[:CLAIM_PRACTITIONER_NOTIFY_TEMPLATE_ID]

template_mail(
template_id,
to: claim.practitioner_email_address,
personalisation: personalisation
)
end

def further_education_payment_provider_verification_email(claim)
policy_check!(claim, Policies::FurtherEducationPayments)

Expand Down
4 changes: 4 additions & 0 deletions app/models/policies/early_years_payments/eligibility.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ def policy
def ineligible?
false
end

def eligible_ey_provider
EligibleEyProvider.find_by_urn(nursery_urn)
end
end
end
end
18 changes: 18 additions & 0 deletions spec/mailers/claim_mailer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -359,4 +359,22 @@ class SomePolicy; end
expect(mail.body).to be_empty
end
end

describe "#early_years_payment_practitioner_email" do
let(:mail) { ClaimMailer.early_years_payment_practitioner_email(claim) }
let(:email_address) { "[email protected]" }
let(:practitioner_email_address) { "[email protected]" }
let(:claim) { build(:claim, reference: "TEST123", first_name: "Test", surname: "Practitioner", policy:, email_address:, practitioner_email_address:) }
let(:policy) { Policies::EarlyYearsPayments }
let(:nursery_name) { "Test Nursery" }
let(:eligible_ey_provider) { create(:eligible_ey_provider, nursery_name:) }

before { create(:journey_configuration, :early_years_payment_provider_start) }
before { claim.eligibility.update!(nursery_urn: eligible_ey_provider.urn) }

it "has personalisation keys for: full_name, setting_name, ref_number, complete_claim_url" do
expect(mail[:personalisation].decoded).to eq("{:full_name=>\"Test Practitioner\", :setting_name=>\"Test Nursery\", :ref_number=>\"TEST123\", :complete_claim_url=>\"https://gov.uk/claim-an-early-years-financial-incentive-payment?claim=TEST123&email=practitioner%40example.com\"}")
expect(mail.body).to be_empty
end
end
end
Loading