From c5a5f30c0632f129cb051bfd2eeee5fc5a811426 Mon Sep 17 00:00:00 2001 From: arybakov Date: Wed, 11 Sep 2024 15:58:47 -0600 Subject: [PATCH] GRAD2-2591 Optional Program Completion Date is not being reset when a User UNGRADS a student --- .../api/gradstudent/service/GraduationStatusService.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/api/src/main/java/ca/bc/gov/educ/api/gradstudent/service/GraduationStatusService.java b/api/src/main/java/ca/bc/gov/educ/api/gradstudent/service/GraduationStatusService.java index 46045085..aa1dc479 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/gradstudent/service/GraduationStatusService.java +++ b/api/src/main/java/ca/bc/gov/educ/api/gradstudent/service/GraduationStatusService.java @@ -1118,6 +1118,13 @@ public Pair undoCompletionStudent(UUID if (gradStatusEvent != null) { gradStatusEventRepository.save(gradStatusEvent); } + List studentOptionalProgramEntities = gradStudentOptionalProgramRepository.findByStudentID(studentID); + for(StudentOptionalProgramEntity studentOptionalProgramEntity: studentOptionalProgramEntities) { + studentOptionalProgramEntity.setOptionalProgramCompletionDate(null); + studentOptionalProgramEntity.setStudentOptionalProgramData(null); + gradStudentOptionalProgramRepository.save(studentOptionalProgramEntity); + historyService.createStudentOptionalProgramHistory(studentOptionalProgramEntity,USER_UNDO_CMPL); + } return Pair.of(graduationStatusTransformer.transformToDTOWithModifiedProgramCompletionDate(gradEntity), gradStatusEvent); } else { validation.addErrorAndStop(String.format("Student ID [%s] does not exists", studentID));