diff --git a/api/src/main/java/ca/bc/gov/educ/api/graduation/service/ReportService.java b/api/src/main/java/ca/bc/gov/educ/api/graduation/service/ReportService.java index aad18d48..e86b2f3d 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/graduation/service/ReportService.java +++ b/api/src/main/java/ca/bc/gov/educ/api/graduation/service/ReportService.java @@ -308,12 +308,16 @@ private Transcript getTranscriptData(ca.bc.gov.educ.api.graduation.model.dto.Gra private void createCourseListForTranscript(List studentCourseList, ca.bc.gov.educ.api.graduation.model.dto.GraduationData graduationDataStatus, List tList, String provincially, boolean xml) { Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("PST"), Locale.CANADA); String today = EducGraduationApiUtils.formatDate(cal.getTime(), EducGraduationApiConstants.DEFAULT_DATE_FORMAT); + for (StudentCourse sc : studentCourseList) { Date sessionDate = EducGraduationApiUtils.parseDate(sc.getSessionDate() + "/01", EducGraduationApiConstants.SECONDARY_DATE_FORMAT); String sDate = EducGraduationApiUtils.formatDate(sessionDate, EducGraduationApiConstants.DEFAULT_DATE_FORMAT); int diff = EducGraduationApiUtils.getDifferenceInMonths(sDate, today); boolean notCompletedCourse = xml && diff <= 0; - if (!sc.isDuplicate() && !sc.isFailed() && !sc.isNotCompleted() && !sc.isCutOffCourse() && ((notCompletedCourse) || !sc.isProjected()) && !sc.isValidationCourse()) { + if (!sc.isDuplicate() && !sc.isFailed() && !sc.isNotCompleted() && ((notCompletedCourse) || !sc.isProjected()) && !sc.isValidationCourse()) { + if (sc.isCutOffCourse() && !isValidCutOffCourse(studentCourseList, sc)) { + continue; + } TranscriptResult result = new TranscriptResult(); String equivOrChallenge = ""; if (sc.getEquivOrChallenge() != null) { @@ -335,6 +339,24 @@ private void createCourseListForTranscript(List studentCourseList } } + /** + * check if the given cutoff course is the highest mark among the same courses, then it should be in transcript even though it is duplicate + * @param studentCourseList + * @param cutOffCourse + * @return + */ + private boolean isValidCutOffCourse(List studentCourseList, StudentCourse cutOffCourse) { + List dups = studentCourseList.stream().filter(sc -> + StringUtils.equalsIgnoreCase(sc.getCourseCode(), cutOffCourse.getCourseCode()) && StringUtils.equalsIgnoreCase(sc.getCourseLevel(), cutOffCourse.getCourseLevel()) + ).sorted(Comparator.comparing(StudentCourse::getCompletedCoursePercentage, Comparator.nullsLast(Double::compareTo)).reversed()).toList(); + + if (!dups.isEmpty()) { + StudentCourse topMarkCourse = dups.get(0); + return StringUtils.equalsIgnoreCase(topMarkCourse.getSessionDate(), cutOffCourse.getSessionDate()); + } + return false; + } + private TranscriptCourse setCourseObjForTranscript(StudentCourse sc, ca.bc.gov.educ.api.graduation.model.dto.GraduationData graduationDataStatus) { TranscriptCourse crse = new TranscriptCourse(); crse.setCode(sc.getCourseCode()); @@ -489,7 +511,7 @@ public List removeDuplicatedAssessmentsForTranscript(List new StudentAssessmentDuplicatesWrapper(studentAssessment, xml)) .distinct() .map(StudentAssessmentDuplicatesWrapper::getStudentAssessment) - .collect(Collectors.toList()); + .toList(); } private List getTranscriptResults(ca.bc.gov.educ.api.graduation.model.dto.GraduationData graduationDataStatus, boolean xml, String accessToken) { @@ -805,11 +827,11 @@ private void getStudentCoursesAssessmentsNExams(ReportData data, ca.bc.gov.educ. List studentExamList = sCList .stream() .filter(sc -> "Y".compareTo(sc.getProvExamCourse()) == 0) - .collect(Collectors.toList()); + .toList(); List studentCourseList = sCList .stream() .filter(sc -> "N".compareTo(sc.getProvExamCourse()) == 0) - .collect(Collectors.toList()); + .toList(); List studentAssessmentList = graduationDataStatus.getStudentAssessments().getStudentAssessmentList(); List sCourseList = new ArrayList<>(); List sExamList = new ArrayList<>(); @@ -1025,12 +1047,10 @@ public ReportData prepareCertificateData(GraduationStudentRecord gradResponse, data.setUpdateDate(EducGraduationApiUtils.formatDateForReportJasper(gradResponse.getUpdateDate().toString())); data.setCertificate(getCertificateData(gradResponse, certType)); data.getStudent().setGraduationData(graduationData); - switch (certType.getCertificateTypeCode()) { - case "F", "SCF", "S": - data.getStudent().setFrenchCert(certType.getCertificateTypeCode()); - break; - default: - data.getStudent().setEnglishCert(certType.getCertificateTypeCode()); + if (certType.getCertificateTypeCode().equals("F") || certType.getCertificateTypeCode().equals("SCF") || certType.getCertificateTypeCode().equals("S")) { + data.getStudent().setFrenchCert(certType.getCertificateTypeCode()); + } else { + data.getStudent().setEnglishCert(certType.getCertificateTypeCode()); } return data; } @@ -1182,7 +1202,7 @@ private List getRequirementsMetAchvReport(List scList = optionalStudentCourses.getStudentCourseList() .stream() .filter(sc -> gr.getTranscriptRule() != null && sc.getGradReqMet().contains(gr.getTranscriptRule())) - .collect(Collectors.toList()); + .toList(); List cdList = new ArrayList<>(); scList.forEach(sc -> { AchievementCourse cD = new AchievementCourse(); diff --git a/api/src/test/resources/json/gradstatus.json b/api/src/test/resources/json/gradstatus.json index 445d6d85..973ccc5c 100644 --- a/api/src/test/resources/json/gradstatus.json +++ b/api/src/test/resources/json/gradstatus.json @@ -1370,6 +1370,47 @@ "used": false, "careerPrep": false, "restricted": false + }, + { + "pen": "111111111", + "courseCode": "PH", + "courseName": "PHYSICS 12", + "courseLevel": "11", + "sessionDate": "2023/06", + "customizedCourseName": "", + "gradReqMet": "", + "gradReqMetDetail": "", + "completedCoursePercentage": 67.0, + "completedCourseLetterGrade": "C+", + "interimPercent": 67.0, + "interimLetterGrade": "C+", + "bestSchoolPercent": null, + "bestExamPercent": null, + "equivOrChallenge": "", + "fineArtsAppliedSkills": "", + "metLitNumRequirement": null, + "credits": 4, + "creditsUsedForGrad": 0, + "relatedCourse": "", + "relatedCourseName": null, + "relatedLevel": "", + "hasRelatedCourse": "N", + "genericCourseType": "", + "language": "", + "workExpFlag": null, + "provExamCourse": "N", + "notEligibleForElective": false, + "locallyDeveloped": false, + "independentDirectedStudies": false, + "boardAuthorityAuthorized": false, + "failed": false, + "duplicate": false, + "projected": false, + "notCompleted": false, + "used": false, + "careerPrep": false, + "restricted": false, + "cutOffCourse": true } ] },