From 0094eb0f2583bfaebb310034819665d55a8006dd Mon Sep 17 00:00:00 2001
From: Laura Ketola
Date: Fri, 13 Sep 2024 16:01:42 +0300
Subject: [PATCH] VKT(Backend): Improve building free enrollment email contents
---
.../service/PublicEnrollmentEmailService.java | 49 +++++++++++++------
.../enrollment-confirmation.html | 4 +-
2 files changed, 35 insertions(+), 18 deletions(-)
diff --git a/backend/vkt/src/main/java/fi/oph/vkt/service/PublicEnrollmentEmailService.java b/backend/vkt/src/main/java/fi/oph/vkt/service/PublicEnrollmentEmailService.java
index 76c436a94..000362087 100644
--- a/backend/vkt/src/main/java/fi/oph/vkt/service/PublicEnrollmentEmailService.java
+++ b/backend/vkt/src/main/java/fi/oph/vkt/service/PublicEnrollmentEmailService.java
@@ -183,8 +183,12 @@ public void sendFreeEnrollmentConfirmationEmail(
final Person person,
final FreeEnrollmentDetails freeEnrollmentDetails
) {
- final Map templateParams = getEmailParams(enrollment);
- getFreeEmailParams(templateParams, freeEnrollmentDetails, enrollment.getFreeEnrollment().getSource(), "enrollment");
+ final Map templateParams = withFreeEmailParams(
+ getEmailParams(enrollment),
+ freeEnrollmentDetails,
+ enrollment.getFreeEnrollment().getSource(),
+ "enrollment"
+ );
final String recipientName = person.getFirstName() + " " + person.getLastName();
final String recipientAddress = enrollment.getEmail();
@@ -204,8 +208,12 @@ public void sendFreeEnrollmentToQueueConfirmationEmail(
final Person person,
final FreeEnrollmentDetails freeEnrollmentDetails
) {
- final Map templateParams = getEmailParams(enrollment);
- getFreeEmailParams(templateParams, freeEnrollmentDetails, enrollment.getFreeEnrollment().getSource(), "queue");
+ final Map templateParams = withFreeEmailParams(
+ getEmailParams(enrollment),
+ freeEnrollmentDetails,
+ enrollment.getFreeEnrollment().getSource(),
+ "queue"
+ );
final String recipientName = person.getFirstName() + " " + person.getLastName();
final String recipientAddress = enrollment.getEmail();
@@ -225,10 +233,13 @@ public void sendPartiallyFreeEnrollmentConfirmationEmail(
final Person person,
final FreeEnrollmentDetails freeEnrollmentDetails
) throws IOException, InterruptedException {
- final Map templateParams = getEmailParams(enrollment);
- getFreeEmailParams(templateParams, freeEnrollmentDetails, enrollment.getFreeEnrollment().getSource(), "queue");
+ final Map templateParams = withFreeEmailParams(
+ getEmailParams(enrollment),
+ freeEnrollmentDetails,
+ enrollment.getFreeEnrollment().getSource(),
+ "enrollment"
+ );
templateParams.put("isFree", "false");
- templateParams.put("type", "enrollment");
final String recipientName = person.getFirstName() + " " + person.getLastName();
final String recipientAddress = enrollment.getEmail();
@@ -255,10 +266,13 @@ public void sendPartiallyFreeEnrollmentToQueueConfirmationEmail(
final Person person,
final FreeEnrollmentDetails freeEnrollmentDetails
) {
- final Map templateParams = getEmailParams(enrollment);
- getFreeEmailParams(templateParams, freeEnrollmentDetails, enrollment.getFreeEnrollment().getSource(), "queue");
+ final Map templateParams = withFreeEmailParams(
+ getEmailParams(enrollment),
+ freeEnrollmentDetails,
+ enrollment.getFreeEnrollment().getSource(),
+ "queue"
+ );
templateParams.put("isFree", "false");
- templateParams.put("type", "queue");
final String recipientName = person.getFirstName() + " " + person.getLastName();
final String recipientAddress = enrollment.getEmail();
@@ -272,16 +286,17 @@ public void sendPartiallyFreeEnrollmentToQueueConfirmationEmail(
createEmail(recipientName, recipientAddress, subject, body, List.of(), EmailType.ENROLLMENT_TO_QUEUE_CONFIRMATION);
}
- public void getFreeEmailParams(
+ public Map withFreeEmailParams(
Map params,
FreeEnrollmentDetails details,
FreeEnrollmentSource source,
String type
) {
- params.put("isFree", true);
- params.put("type", type);
- params.put("source", source.name());
- params.put(
+ Map freeParams = new HashMap<>(params);
+ freeParams.put("isFree", true);
+ freeParams.put("type", type);
+ freeParams.put("source", source.name());
+ freeParams.put(
"freeExamsLeftFI",
String.format(
"%s: %s/3. %s: %s/3",
@@ -291,7 +306,7 @@ public void getFreeEmailParams(
EnrollmentUtil.getFreeExamsLeft(details.oralSkillCount())
)
);
- params.put(
+ freeParams.put(
"freeExamsLeftSV",
String.format(
"%s: %s/3. %s: %s/3",
@@ -301,5 +316,7 @@ public void getFreeEmailParams(
EnrollmentUtil.getFreeExamsLeft(details.oralSkillCount())
)
);
+
+ return freeParams;
}
}
diff --git a/backend/vkt/src/main/resources/email-templates/enrollment-confirmation.html b/backend/vkt/src/main/resources/email-templates/enrollment-confirmation.html
index 85324b38c..4c2b6315a 100644
--- a/backend/vkt/src/main/resources/email-templates/enrollment-confirmation.html
+++ b/backend/vkt/src/main/resources/email-templates/enrollment-confirmation.html
@@ -40,7 +40,7 @@
Oikeutettu maksuttomaan tutkintoon: Ei
Valitsemasi taidot:
Valitsemasi osakokeet:
- Maksuttomia tutkintokertoja jäljellä:
+ Maksuttomia tutkintokertoja jäljellä:
@@ -102,7 +102,7 @@
Rätt till avgiftsfri examen: Nej
Förmågor som du har valt:
Delprov som du har valt:
- Antal avgiftsfria examina kvar:
+ Antal avgiftsfria examina kvar:
Information om examenstillfället