From 8641d0d55ca82b1329852875b55d16218fe70b40 Mon Sep 17 00:00:00 2001 From: Phil Lee Date: Fri, 8 Nov 2024 16:40:49 +0000 Subject: [PATCH 1/2] set EY notify reply_to ID --- app/mailers/claim_mailer.rb | 1 + app/models/policies/early_years_payments.rb | 3 +-- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/mailers/claim_mailer.rb b/app/mailers/claim_mailer.rb index 0c6d3a39b7..d2dc9a4e13 100644 --- a/app/mailers/claim_mailer.rb +++ b/app/mailers/claim_mailer.rb @@ -126,6 +126,7 @@ def early_years_payment_practitioner_email(claim) template_mail( template_id, to: claim.practitioner_email_address, + reply_to_id: claim.policy.notify_reply_to_id, personalisation: personalisation ) end diff --git a/app/models/policies/early_years_payments.rb b/app/models/policies/early_years_payments.rb index 2354c7a024..6c6f5ed25e 100644 --- a/app/models/policies/early_years_payments.rb +++ b/app/models/policies/early_years_payments.rb @@ -62,9 +62,8 @@ module EarlyYearsPayments :other ] - # TODO: This is needed once the reply-to email address has been added to Gov Notify def notify_reply_to_id - nil + "581f1cd6-3351-4fd6-b408-e53ce8d86a28" end def award_amount From 5c40bc426875d1fa0549b21d1c7647a6939e1a53 Mon Sep 17 00:00:00 2001 From: Phil Lee Date: Mon, 11 Nov 2024 11:20:50 +0000 Subject: [PATCH 2/2] EY submission sends out correct emails --- app/forms/claim_submission_base_form.rb | 2 +- app/mailers/application_mailer.rb | 2 +- app/mailers/early_years_payments_mailer.rb | 44 +++++++++++++++++++ app/models/base_policy.rb | 4 ++ app/models/policies/early_years_payments.rb | 4 ++ .../provider/authenticated/happy_path_spec.rb | 7 ++- 6 files changed, 60 insertions(+), 3 deletions(-) create mode 100644 app/mailers/early_years_payments_mailer.rb diff --git a/app/forms/claim_submission_base_form.rb b/app/forms/claim_submission_base_form.rb index ddf51276e6..58f34f3e8d 100644 --- a/app/forms/claim_submission_base_form.rb +++ b/app/forms/claim_submission_base_form.rb @@ -24,7 +24,7 @@ def save claim.save! end - ClaimMailer.submitted(claim).deliver_later if claim.submitted_at + claim.policy.mailer.submitted(claim).deliver_later ClaimVerifierJob.perform_later(claim) true diff --git a/app/mailers/application_mailer.rb b/app/mailers/application_mailer.rb index 07e660daa5..75c0a6255b 100644 --- a/app/mailers/application_mailer.rb +++ b/app/mailers/application_mailer.rb @@ -48,7 +48,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: "f97480c8-7869-4af6-b50c-413929b8cc88".freeze, CLAIM_PRACTITIONER_NOTIFY_TEMPLATE_ID: "ef21f1d7-8a5c-4261-80b9-e1b78f844575".freeze, CLAIM_REJECTED_NOTIFY_TEMPLATE_ID: "90e32881-1d11-4c6b-b33a-e7ae698de2f2".freeze } diff --git a/app/mailers/early_years_payments_mailer.rb b/app/mailers/early_years_payments_mailer.rb new file mode 100644 index 0000000000..3b89b10438 --- /dev/null +++ b/app/mailers/early_years_payments_mailer.rb @@ -0,0 +1,44 @@ +class EarlyYearsPaymentsMailer < ApplicationMailer + def submitted(claim) + if claim.submitted_at.present? + submitted_by_practitioner_and_send_to_practitioner(claim) + else + submitted_by_provider_and_send_to_provider(claim) + end + end + + private + + def submitted_by_provider_and_send_to_provider(claim) + personalisation = { + nursery_name: claim.eligibility.eligible_ey_provider.nursery_name, + practitioner_first_name: claim.eligibility.practitioner_first_name, + practitioner_last_name: claim.eligibility.practitioner_surname, + ref_number: claim.reference + } + + template_mail( + "149c5999-12fb-4b99-aff5-23a7c3302783", + to: claim.eligibility.eligible_ey_provider.primary_key_contact_email_address, + subject: nil, + reply_to_id: claim.policy.notify_reply_to_id, + personalisation: + ) + end + + def submitted_by_practitioner_and_send_to_practitioner(claim) + personalisation = { + first_name: claim.first_name, + nursery_name: claim.eligibility.eligible_ey_provider.nursery_name, + ref_number: claim.reference + } + + template_mail( + "f97480c8-7869-4af6-b50c-413929b8cc88", + to: claim.email_address, + subject: nil, + reply_to_id: claim.policy.notify_reply_to_id, + personalisation: + ) + end +end diff --git a/app/models/base_policy.rb b/app/models/base_policy.rb index 6d43ac0388..3adc9e1e01 100644 --- a/app/models/base_policy.rb +++ b/app/models/base_policy.rb @@ -70,4 +70,8 @@ def decision_deadline_date(claim) def award_amount_column "award_amount" end + + def mailer + ClaimMailer + end end diff --git a/app/models/policies/early_years_payments.rb b/app/models/policies/early_years_payments.rb index 6c6f5ed25e..ae60443fe3 100644 --- a/app/models/policies/early_years_payments.rb +++ b/app/models/policies/early_years_payments.rb @@ -81,5 +81,9 @@ def approvable?(claim) def decision_deadline_date(claim) claim.eligibility.start_date + RETENTION_PERIOD end + + def mailer + EarlyYearsPaymentsMailer + end end end diff --git a/spec/features/early_years_payment/provider/authenticated/happy_path_spec.rb b/spec/features/early_years_payment/provider/authenticated/happy_path_spec.rb index 7d5556cc8a..e93db1d9da 100644 --- a/spec/features/early_years_payment/provider/authenticated/happy_path_spec.rb +++ b/spec/features/early_years_payment/provider/authenticated/happy_path_spec.rb @@ -77,7 +77,12 @@ expect(page.current_path).to eq "/early-years-payment-provider/check-your-answers" expect(page).to have_content("Check your answers before submitting this claim") fill_in "claim-provider-contact-name-field", with: "John Doe" - click_button "Accept and send" + + expect do + perform_enqueued_jobs { click_on "Accept and send" } + end.to change { Claim.count }.by(1) + .and change { Policies::EarlyYearsPayments::Eligibility.count }.by(1) + .and change { ActionMailer::Base.deliveries.count }.by(2) expect(page.current_path).to eq claim_confirmation_path(Journeys::EarlyYearsPayment::Provider::Authenticated::ROUTING_NAME)