diff --git a/api/pom.xml b/api/pom.xml index 23e3a22..685722a 100644 --- a/api/pom.xml +++ b/api/pom.xml @@ -10,7 +10,7 @@ ca.bc.gov.educ educ-grad-rule-engine-api - 1.8.57 + 1.8.58 educ-grad-rule-engine-api Rule Engine API for GRAD team diff --git a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/BaseRule.java b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/BaseRule.java new file mode 100644 index 0000000..80ca022 --- /dev/null +++ b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/BaseRule.java @@ -0,0 +1,18 @@ +package ca.bc.gov.educ.api.ruleengine.rule; + +import java.util.Calendar; +import java.util.Date; + +public abstract class BaseRule implements Rule { + + Date toLastDayOfMonth(Date date) { + if(date != null) { + Calendar cal = Calendar.getInstance(); + cal.setTime(date); + cal.set(Calendar.DAY_OF_MONTH, cal.getActualMaximum(Calendar.DAY_OF_MONTH)); + return cal.getTime(); + } + return null; + } + +} diff --git a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/CareerProgramMatchRule.java b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/CareerProgramMatchRule.java index 297dd92..6ca78b0 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/CareerProgramMatchRule.java +++ b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/CareerProgramMatchRule.java @@ -38,6 +38,11 @@ public RuleData fire() { List requirementsMet = new ArrayList<>(); List requirementsNotMet = new ArrayList<>(); + List courseRequirements = ruleProcessorData.getCourseRequirements(); + if(courseRequirements == null) { + courseRequirements = new ArrayList<>(); + } + List courseList = RuleProcessorRuleUtils.getUniqueStudentCourses( obj.getStudentCoursesOptionalProgram(), ruleProcessorData.isProjected()); List careerProgramRulesMatch = obj.getOptionalProgramRules() @@ -57,8 +62,16 @@ public RuleData fire() { while (studentCourseIterator.hasNext()) { StudentCourse sc = studentCourseIterator.next(); - for(OptionalProgramRequirement pR:careerProgramRulesMatch) { - if((pR.getOptionalProgramRequirementCode().getRequiredLevel() == null || pR.getOptionalProgramRequirementCode().getRequiredLevel().trim().compareTo("") == 0) && (sc.getWorkExpFlag() != null && sc.getWorkExpFlag().equalsIgnoreCase("Y"))) { + List matchedCourseRequirements = courseRequirements.stream() + .filter(cr -> sc.getCourseCode().compareTo(cr.getCourseCode()) == 0 + && sc.getCourseLevel().compareTo(cr.getCourseLevel()) == 0) + .toList(); + + for(OptionalProgramRequirement pR:careerProgramRulesMatch) { + long matchedCount = matchedCourseRequirements.stream() + .filter(cr -> cr.getRuleCode().getCourseRequirementCode().compareTo(pR.getOptionalProgramRequirementCode().getOptProReqCode()) == 0) + .count(); + if(matchedCount > 0 && (pR.getOptionalProgramRequirementCode().getRequiredLevel() == null || pR.getOptionalProgramRequirementCode().getRequiredLevel().trim().compareTo("") == 0)) { requiredCredits = Integer.parseInt(pR.getOptionalProgramRequirementCode().getRequiredCredits()); if (totalCredits + sc.getCredits() <= requiredCredits) { totalCredits += sc.getCredits(); diff --git a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/ExcludeAfterProgramCutoffRule.java b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/ExcludeAfterProgramCutoffRule.java index ee8960c..f9de997 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/ExcludeAfterProgramCutoffRule.java +++ b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/ExcludeAfterProgramCutoffRule.java @@ -21,7 +21,7 @@ @Component @NoArgsConstructor @AllArgsConstructor -public class ExcludeAfterProgramCutoffRule implements Rule { +public class ExcludeAfterProgramCutoffRule extends BaseRule implements Rule { private static Logger logger = LoggerFactory.getLogger(ExcludeAfterProgramCutoffRule.class); @Autowired @@ -40,7 +40,7 @@ public RuleData fire() { String sessionDate = studentCourse.getSessionDate() + "/01"; try { - Date temp = RuleEngineApiUtils.parseDate(sessionDate, "yyyy/MM/dd"); + Date temp = toLastDayOfMonth(RuleEngineApiUtils.parseDate(sessionDate, "yyyy/MM/dd")); sessionDate = RuleEngineApiUtils.formatDate(temp, "yyyy-MM-dd"); } catch (ParseException pe) { logger.error("ERROR: {}",pe.getMessage()); diff --git a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/ExcludeValidationCoursesRule.java b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/ExcludeValidationCoursesRule.java index d4af81c..a909d76 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/ExcludeValidationCoursesRule.java +++ b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/ExcludeValidationCoursesRule.java @@ -3,6 +3,7 @@ import ca.bc.gov.educ.api.ruleengine.dto.RuleData; import ca.bc.gov.educ.api.ruleengine.dto.RuleProcessorData; import ca.bc.gov.educ.api.ruleengine.dto.StudentCourse; +import ca.bc.gov.educ.api.ruleengine.util.RuleEngineApiUtils; import ca.bc.gov.educ.api.ruleengine.util.RuleProcessorRuleUtils; import lombok.AllArgsConstructor; import lombok.Data; @@ -12,13 +13,15 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; +import java.text.ParseException; +import java.util.Date; import java.util.List; @Data @Component @NoArgsConstructor @AllArgsConstructor -public class ExcludeValidationCoursesRule implements Rule { +public class ExcludeValidationCoursesRule extends BaseRule implements Rule { private static Logger logger = LoggerFactory.getLogger(ExcludeValidationCoursesRule.class); @@ -33,8 +36,14 @@ public RuleData fire() { for (StudentCourse studentCourse : studentCourseList) { String sessionDate = studentCourse.getSessionDate() + "/01"; + try { + Date temp = toLastDayOfMonth(RuleEngineApiUtils.parseDate(sessionDate, "yyyy/MM/dd")); + sessionDate = RuleEngineApiUtils.formatDate(temp, "yyyy/MM/dd"); + } catch (ParseException pe) { + logger.error("ERROR: {}",pe.getMessage()); + } String cName = studentCourse.getCourseCode()+studentCourse.getCourseLevel(); - if (studentCourse.getProvExamCourse().compareTo("Y")==0 && sessionDate.equalsIgnoreCase("2005/06/01") && (cName.compareTo("SS11") == 0 + if (studentCourse.getProvExamCourse().compareTo("Y")==0 && sessionDate.equalsIgnoreCase("2005/06/30") && (cName.compareTo("SS11") == 0 || cName.compareTo("SCH11") == 0 || cName.compareTo("FNS12") == 0)) { studentCourse.setValidationCourse(true); diff --git a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/IncompleteCoursesRule.java b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/IncompleteCoursesRule.java index 77fe894..5413228 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/IncompleteCoursesRule.java +++ b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/IncompleteCoursesRule.java @@ -21,7 +21,7 @@ @Component @NoArgsConstructor @AllArgsConstructor -public class IncompleteCoursesRule implements Rule { +public class IncompleteCoursesRule extends BaseRule implements Rule { private static Logger logger = LoggerFactory.getLogger(IncompleteCoursesRule.class); @Autowired @@ -36,7 +36,7 @@ public RuleData fire() { String sessionDate = studentCourse.getSessionDate() + "/01"; try { - Date temp = RuleEngineApiUtils.parseDate(sessionDate, "yyyy/MM/dd"); + Date temp = toLastDayOfMonth(RuleEngineApiUtils.parseDate(sessionDate, "yyyy/MM/dd")); sessionDate = RuleEngineApiUtils.formatDate(temp, "yyyy-MM-dd"); } catch (ParseException pe) { logger.error("ERROR: {}" , pe.getMessage()); diff --git a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/MatchCreditsRule.java b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/MatchCreditsRule.java index 21a7b20..5a2fb91 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/MatchCreditsRule.java +++ b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/MatchCreditsRule.java @@ -19,7 +19,7 @@ @Component @NoArgsConstructor @AllArgsConstructor -public class MatchCreditsRule implements Rule { +public class MatchCreditsRule extends BaseRule implements Rule { private static Logger logger = LoggerFactory.getLogger(MatchCreditsRule.class); @@ -140,7 +140,7 @@ public void splitSortStudentCourses(List studentCourses, Date adu String courseSessionDate = sc.getSessionDate() + "/01"; Date temp = null; try { - temp = RuleEngineApiUtils.parseDate(courseSessionDate, "yyyy/MM/dd"); + temp = toLastDayOfMonth(RuleEngineApiUtils.parseDate(courseSessionDate, "yyyy/MM/dd")); } catch (ParseException e) { logger.debug(e.getMessage()); } diff --git a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/MinAdultCoursesRule.java b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/MinAdultCoursesRule.java index 5a940d7..78c1306 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/MinAdultCoursesRule.java +++ b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/MinAdultCoursesRule.java @@ -21,7 +21,7 @@ @Component @NoArgsConstructor @AllArgsConstructor -public class MinAdultCoursesRule implements Rule { +public class MinAdultCoursesRule extends BaseRule implements Rule { private static Logger logger = LoggerFactory.getLogger(MinAdultCoursesRule.class); @@ -66,7 +66,7 @@ public RuleData fire() { String courseSessionDate = sc.getSessionDate() + "/01"; Date temp = null; try { - temp = RuleEngineApiUtils.parseDate(courseSessionDate, "yyyy/MM/dd"); + temp = toLastDayOfMonth(RuleEngineApiUtils.parseDate(courseSessionDate, "yyyy/MM/dd")); } catch (ParseException e) { logger.debug(e.getMessage()); } @@ -137,7 +137,7 @@ public RuleData fire() { String courseSessionDate = sc.getSessionDate() + "/01"; Date temp = null; try { - temp = RuleEngineApiUtils.parseDate(courseSessionDate, "yyyy/MM/dd"); + temp = toLastDayOfMonth(RuleEngineApiUtils.parseDate(courseSessionDate, "yyyy/MM/dd")); } catch (ParseException e) { logger.debug(e.getMessage()); } diff --git a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/RegistrationsDuplicateAssmtRule.java b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/RegistrationsDuplicateAssmtRule.java index 51b837c..1d16118 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/RegistrationsDuplicateAssmtRule.java +++ b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/RegistrationsDuplicateAssmtRule.java @@ -21,7 +21,7 @@ @Component @NoArgsConstructor @AllArgsConstructor -public class RegistrationsDuplicateAssmtRule implements Rule { +public class RegistrationsDuplicateAssmtRule extends BaseRule implements Rule { private static Logger logger = LoggerFactory.getLogger(RegistrationsDuplicateAssmtRule.class); @@ -44,8 +44,8 @@ public RuleData fire() { && !studentAssessmentsList.get(i).isDuplicate() && !studentAssessmentsList.get(j).isDuplicate()) { try { - Date sessionDate1 = RuleEngineApiUtils.parseDate(studentAssessmentsList.get(i).getSessionDate() + "/01", "yyyy/MM/dd"); - Date sessionDate2 = RuleEngineApiUtils.parseDate(studentAssessmentsList.get(j).getSessionDate() + "/01", "yyyy/MM/dd"); + Date sessionDate1 = toLastDayOfMonth(RuleEngineApiUtils.parseDate(studentAssessmentsList.get(i).getSessionDate() + "/01", "yyyy/MM/dd")); + Date sessionDate2 = toLastDayOfMonth(RuleEngineApiUtils.parseDate(studentAssessmentsList.get(j).getSessionDate() + "/01", "yyyy/MM/dd")); String sDate1 = RuleEngineApiUtils.formatDate(sessionDate1, RuleEngineApiConstants.DEFAULT_DATE_FORMAT); String sDate2 = RuleEngineApiUtils.formatDate(sessionDate2, RuleEngineApiConstants.DEFAULT_DATE_FORMAT); diff --git a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/RegistrationsDuplicateCrseRule.java b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/RegistrationsDuplicateCrseRule.java index 78ec763..93c91a4 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/RegistrationsDuplicateCrseRule.java +++ b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/RegistrationsDuplicateCrseRule.java @@ -20,7 +20,7 @@ @Component @NoArgsConstructor @AllArgsConstructor -public class RegistrationsDuplicateCrseRule implements Rule { +public class RegistrationsDuplicateCrseRule extends BaseRule implements Rule { private static Logger logger = LoggerFactory.getLogger(RegistrationsDuplicateCrseRule.class); @@ -37,8 +37,10 @@ public RuleData fire() { boolean inProgressCourse2 = false; boolean isCompletedCourse1 = false; boolean isCompletedCourse2 = false; - for (int i = 0; i < studentCourseList.size() - 1; i++) { + studentCourseList.sort(Comparator.comparing(StudentCourse::getCourseCode)); + + for (int i = 0; i < studentCourseList.size() - 1; i++) { for (int j = i + 1; j < studentCourseList.size(); j++) { if (studentCourseList.get(i).getCourseCode().equals(studentCourseList.get(j).getCourseCode()) && !studentCourseList.get(i).isDuplicate() @@ -51,8 +53,8 @@ public RuleData fire() { continue; } try { - Date sessionDate1 = RuleEngineApiUtils.parseDate(studentCourseList.get(i).getSessionDate() + "/01", "yyyy/MM/dd"); - Date sessionDate2 = RuleEngineApiUtils.parseDate(studentCourseList.get(j).getSessionDate() + "/01", "yyyy/MM/dd"); + Date sessionDate1 = toLastDayOfMonth(RuleEngineApiUtils.parseDate(studentCourseList.get(i).getSessionDate() + "/01", "yyyy/MM/dd")); + Date sessionDate2 = toLastDayOfMonth(RuleEngineApiUtils.parseDate(studentCourseList.get(j).getSessionDate() + "/01", "yyyy/MM/dd")); String sDate1 = RuleEngineApiUtils.formatDate(sessionDate1, RuleEngineApiConstants.DEFAULT_DATE_FORMAT); String sDate2 = RuleEngineApiUtils.formatDate(sessionDate2, RuleEngineApiConstants.DEFAULT_DATE_FORMAT); diff --git a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/RegistrationsFailedCrseRule.java b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/RegistrationsFailedCrseRule.java index 3212289..62333a8 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/RegistrationsFailedCrseRule.java +++ b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/RegistrationsFailedCrseRule.java @@ -21,7 +21,7 @@ @Component @NoArgsConstructor @AllArgsConstructor -public class RegistrationsFailedCrseRule implements Rule { +public class RegistrationsFailedCrseRule extends BaseRule implements Rule { private static Logger logger = LoggerFactory.getLogger(RegistrationsFailedCrseRule.class); @@ -36,7 +36,7 @@ public RuleData fire() { boolean inProgressCourse = false; for (StudentCourse studentCourse : studentCourseList) { try { - Date sessionDate = RuleEngineApiUtils.parseDate(studentCourse.getSessionDate() + "/01", "yyyy/MM/dd"); + Date sessionDate = toLastDayOfMonth(RuleEngineApiUtils.parseDate(studentCourse.getSessionDate() + "/01", "yyyy/MM/dd")); String sDate = RuleEngineApiUtils.formatDate(sessionDate, RuleEngineApiConstants.DEFAULT_DATE_FORMAT); String today = RuleEngineApiUtils.formatDate(cal.getTime(), RuleEngineApiConstants.DEFAULT_DATE_FORMAT); int diff = RuleEngineApiUtils.getDifferenceInMonths(sDate,today); diff --git a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/RegistrationsRule.java b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/RegistrationsRule.java index d56c605..d4b630b 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/RegistrationsRule.java +++ b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/rule/RegistrationsRule.java @@ -21,7 +21,7 @@ @Component @NoArgsConstructor @AllArgsConstructor -public class RegistrationsRule implements Rule { +public class RegistrationsRule extends BaseRule implements Rule { private static Logger logger = LoggerFactory.getLogger(RegistrationsRule.class); @@ -37,7 +37,7 @@ public RuleData fire() { String sessionDate = studentCourse.getSessionDate() + "/01"; try { - Date temp = RuleEngineApiUtils.parseDate(sessionDate, "yyyy/MM/dd"); + Date temp = toLastDayOfMonth(RuleEngineApiUtils.parseDate(sessionDate, "yyyy/MM/dd")); sessionDate = RuleEngineApiUtils.formatDate(temp, "yyyy-MM-dd"); } catch (ParseException pe) { logger.error("ERROR: {}",pe.getMessage()); diff --git a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/util/RuleEngineApiUtils.java b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/util/RuleEngineApiUtils.java index f84598c..472ee9f 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/util/RuleEngineApiUtils.java +++ b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/util/RuleEngineApiUtils.java @@ -14,10 +14,7 @@ import java.text.SimpleDateFormat; import java.time.LocalDate; import java.time.Period; -import java.util.ArrayList; -import java.util.Collections; -import java.util.Date; -import java.util.List; +import java.util.*; import java.util.stream.Collectors; public class RuleEngineApiUtils { @@ -50,7 +47,7 @@ public static Date parsingTraxDate(String sessionDate) { Date temp; Date sDate = null; try { - temp = RuleEngineApiUtils.parseDate(actualSessionDate, RuleEngineApiConstants.DATE_FORMAT); + temp = toLastDayOfMonth(RuleEngineApiUtils.parseDate(actualSessionDate, RuleEngineApiConstants.DATE_FORMAT)); String sDates = RuleEngineApiUtils.formatDate(temp, RuleEngineApiConstants.DATE_FORMAT); sDate = RuleEngineApiUtils.parseDate(sDates, RuleEngineApiConstants.DATE_FORMAT); } catch (ParseException pe) { @@ -140,12 +137,12 @@ public static List getCloneOptionalProgramRule(List< public static boolean checkDateForRestrictedCourses(String startDate,String endDate,String currentSessionDate) { try { - Date sDate = parseDate(startDate+"/01",RuleEngineApiConstants.DATE_FORMAT); + Date sDate = toLastDayOfMonth(parseDate(startDate+"/01",RuleEngineApiConstants.DATE_FORMAT)); if(endDate != null) { - Date eDate = parseDate(endDate + "/01", RuleEngineApiConstants.DATE_FORMAT); - return parseDate(currentSessionDate + "/01", RuleEngineApiConstants.DATE_FORMAT).after(sDate) && parseDate(currentSessionDate + "/01", "yyyy/MM/dd").before(eDate); + Date eDate = toLastDayOfMonth(parseDate(endDate + "/01", RuleEngineApiConstants.DATE_FORMAT)); + return toLastDayOfMonth(parseDate(currentSessionDate + "/01", RuleEngineApiConstants.DATE_FORMAT)).after(sDate) && toLastDayOfMonth(parseDate(currentSessionDate + "/01", "yyyy/MM/dd")).before(eDate); }else { - return parseDate(currentSessionDate + "/01", RuleEngineApiConstants.DATE_FORMAT).after(sDate); + return toLastDayOfMonth(parseDate(currentSessionDate + "/01", RuleEngineApiConstants.DATE_FORMAT)).after(sDate); } } catch (ParseException e) { logger.error(ERROR_MSG,e.getMessage()); @@ -159,9 +156,9 @@ public static boolean compareCourseSessionDates(String sessionDate1,String sessi sessionDate2 = sessionDate2 + "/01"; try { - Date temp1 = RuleEngineApiUtils.parseDate(sessionDate1, "yyyy/MM/dd"); + Date temp1 = toLastDayOfMonth(RuleEngineApiUtils.parseDate(sessionDate1, "yyyy/MM/dd")); sessionDate1 = RuleEngineApiUtils.formatDate(temp1, "yyyy-MM-dd"); - Date temp2 = RuleEngineApiUtils.parseDate(sessionDate2, "yyyy/MM/dd"); + Date temp2 = toLastDayOfMonth(RuleEngineApiUtils.parseDate(sessionDate2, "yyyy/MM/dd")); sessionDate2 = RuleEngineApiUtils.formatDate(temp2, "yyyy-MM-dd"); } catch (ParseException pe) { logger.error("ERROR: {}",pe.getMessage()); @@ -179,8 +176,18 @@ public static boolean compareCourseSessionDates(String sessionDate1,String sessi // Courses with both finalLG(Letter Grade) & finalPercentage have some values public static boolean isCompletedCourse(String finalGrade, Double finalPercentage) { if (finalGrade != null && finalPercentage != null) { - return !"".equalsIgnoreCase(finalGrade.trim()) && finalPercentage.compareTo(0.0) > 0; + return !"".equalsIgnoreCase(finalGrade.trim()) && finalPercentage.compareTo(0.0D) > 0; } return false; } + + static Date toLastDayOfMonth(Date date) { + if(date != null) { + Calendar cal = Calendar.getInstance(); + cal.setTime(date); + cal.set(Calendar.DAY_OF_MONTH, cal.getActualMaximum(Calendar.DAY_OF_MONTH)); + return cal.getTime(); + } + return null; + } } diff --git a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/util/RuleProcessorRuleUtils.java b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/util/RuleProcessorRuleUtils.java index 024e2f8..796f44d 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/ruleengine/util/RuleProcessorRuleUtils.java +++ b/api/src/main/java/ca/bc/gov/educ/api/ruleengine/util/RuleProcessorRuleUtils.java @@ -11,6 +11,7 @@ import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.ArrayList; +import java.util.Calendar; import java.util.Date; import java.util.List; import java.util.stream.Collectors; @@ -162,8 +163,9 @@ public static String getGradDate(List studentCourses) { for (StudentCourse studentCourse : studentCourses) { try { - if (dateFormat.parse(studentCourse.getSessionDate() + "/01").compareTo(gradDate) > 0) { - gradDate = dateFormat.parse(studentCourse.getSessionDate() + "/01"); + Date dateTocompare = toLastDayOfMonth(dateFormat.parse(studentCourse.getSessionDate() + "/01")); + if (dateTocompare.compareTo(gradDate) > 0) { + gradDate = dateTocompare; } } catch (ParseException e) { logger.debug("Error {}",e.getMessage()); @@ -193,4 +195,14 @@ public static void updateCourseLevelForCLC(List studentCourses, S } }); } + + static Date toLastDayOfMonth(Date date) { + if(date != null) { + Calendar cal = Calendar.getInstance(); + cal.setTime(date); + cal.set(Calendar.DAY_OF_MONTH, cal.getActualMaximum(Calendar.DAY_OF_MONTH)); + return cal.getTime(); + } + return null; + } } diff --git a/api/src/test/resources/SCCP-130319387-fail.json b/api/src/test/resources/SCCP-130319387-fail.json index 441b53b..6c95cd6 100644 --- a/api/src/test/resources/SCCP-130319387-fail.json +++ b/api/src/test/resources/SCCP-130319387-fail.json @@ -23,7 +23,7 @@ "statusCode": "A", "memo": null, "trueStudentID": null, - "program": "2018-EN", + "program": "SCCP", "schoolOfRecord": "01919003", "schoolOfRecordName": "REVELSTOKE SECONDARY", "schoolOfRecordindependentAffiliation": "", @@ -199,6 +199,19 @@ "isActiveRule": "Y" } }, + { + "programAlgoRuleID": "c70b587f-af3d-d11b-e053-9ae9228eda21", + "graduationProgramCode": "SCCP", + "sortOrder": 22, + "algorithmRuleCode": { + "algoRuleCode": "CRSE_REGISTRATION_DUPLICATE_RULE", + "ruleImplementation": "RegistrationsDuplicateCrseRule", + "label": "Course Registrations rule", + "description": "Checks if the student achievement record (e.g., course) session date is still current or future dated (e.g. from today YYYYMM) or later) and no final result or special case exists.", + "displayOrder": 30, + "isActiveRule": "Y" + } + }, { "programAlgoRuleID": "c70b587f-af82-d11b-e053-9ae9228eda21", "graduationProgramCode": "SCCP", @@ -443,9 +456,58 @@ "customizedCourseName": "", "gradReqMet": "", "gradReqMetDetail": "", - "completedCoursePercentage": 92.0, + "completedCoursePercentage": 0.0, + "completedCourseLetterGrade": "A", + "interimPercent": 0.0, + "interimLetterGrade": "A", + "bestSchoolPercent": null, + "bestExamPercent": null, + "equivOrChallenge": "", + "fineArtsAppliedSkills": "", + "metLitNumRequirement": null, + "credits": 4, + "creditsUsedForGrad": 0, + "relatedCourse": "", + "relatedCourseName": null, + "relatedLevel": "", + "hasRelatedCourse": "N", + "genericCourseType": "", + "language": "", + "workExpFlag": " ", + "specialCase": null, + "toWriteFlag": null, + "provExamCourse": "N", + "leftOverCredits": null, + "projected": false, + "failed": false, + "duplicate": false, + "used": false, + "notCompleted": false, + "grade10Course": false, + "usedInMatchRule": false, + "restricted": false, + "locallyDeveloped": false, + "cutOffCourse": false, + "careerPrep": false, + "lessCreditCourse": false, + "validationCourse": false, + "boardAuthorityAuthorized": false, + "independentDirectedStudies": false, + "notEligibleForElective": false + }, + { + "pen": "130319387", + "courseCode": "TEAD", + "courseName": "ENGINE AND DRIVETRAIN 12", + "originalCredits": 4, + "courseLevel": "12", + "sessionDate": "2021/06", + "customizedCourseName": "", + "gradReqMet": "", + "gradReqMetDetail": "", + "completedCoursePercentage": 0.0, "completedCourseLetterGrade": "A", - "interimPercent": 92.0, + "interimPercent": 0.0, "interimLetterGrade": "A", "bestSchoolPercent": null, "bestExamPercent": null, @@ -492,9 +554,9 @@ "customizedCourseName": "", "gradReqMet": "", "gradReqMetDetail": "", - "completedCoursePercentage": 90.0, + "completedCoursePercentage": 0.0, "completedCourseLetterGrade": "A", - "interimPercent": 90.0, + "interimPercent": 0.0, "interimLetterGrade": "A", "bestSchoolPercent": null, "bestExamPercent": null, @@ -3272,7 +3334,7 @@ "requirementsMet": null, "gradStatus": { "pen": null, - "program": "2018-EN", + "program": "SCCP", "programCompletionDate": null, "gpa": null, "honoursStanding": null, diff --git a/api/src/test/resources/SCCP-130319387.json b/api/src/test/resources/SCCP-130319387.json index 08d92ac..c62efab 100644 --- a/api/src/test/resources/SCCP-130319387.json +++ b/api/src/test/resources/SCCP-130319387.json @@ -23,7 +23,7 @@ "statusCode": "A", "memo": null, "trueStudentID": null, - "program": "2018-EN", + "program": "SCCP", "schoolOfRecord": "01919003", "schoolOfRecordName": "REVELSTOKE SECONDARY", "schoolOfRecordindependentAffiliation": "", @@ -199,6 +199,19 @@ "isActiveRule": "Y" } }, + { + "programAlgoRuleID": "c70b587f-af3d-d11b-e053-9ae9228eda21", + "graduationProgramCode": "SCCP", + "sortOrder": 22, + "algorithmRuleCode": { + "algoRuleCode": "CRSE_REGISTRATION_DUPLICATE_RULE", + "ruleImplementation": "RegistrationsDuplicateCrseRule", + "label": "Course Registrations rule", + "description": "Checks if the student achievement record (e.g., course) session date is still current or future dated (e.g. from today YYYYMM) or later) and no final result or special case exists.", + "displayOrder": 30, + "isActiveRule": "Y" + } + }, { "programAlgoRuleID": "c70b587f-af82-d11b-e053-9ae9228eda21", "graduationProgramCode": "SCCP", @@ -369,9 +382,9 @@ "leftOverCredits": null, "projected": false, "failed": false, - "duplicate": false, + "duplicate": true, "used": false, - "notCompleted": false, + "notCompleted": true, "grade10Course": false, "usedInMatchRule": false, "restricted": false, @@ -420,7 +433,7 @@ "failed": false, "duplicate": false, "used": false, - "notCompleted": false, + "notCompleted": true, "grade10Course": false, "usedInMatchRule": false, "restricted": false, @@ -443,7 +456,7 @@ "customizedCourseName": "", "gradReqMet": "", "gradReqMetDetail": "", - "completedCoursePercentage": 92.0, + "completedCoursePercentage": 80.0, "completedCourseLetterGrade": "A", "interimPercent": 92.0, "interimLetterGrade": "A", @@ -879,13 +892,13 @@ "courseCode": "TSITA", "courseName": "EXPLORE: TRADES SAMPLER (ITA) 12B", "originalCredits": 4, - "courseLevel": "12B", + "courseLevel": "12A", "sessionDate": "2021/06", "customizedCourseName": "", "gradReqMet": "", "gradReqMetDetail": "", "completedCoursePercentage": 80.0, - "completedCourseLetterGrade": "B", + "completedCourseLetterGrade": "A", "interimPercent": 80.0, "interimLetterGrade": "B", "bestSchoolPercent": null, @@ -3272,7 +3285,7 @@ "requirementsMet": null, "gradStatus": { "pen": null, - "program": "2018-EN", + "program": "SCCP", "programCompletionDate": "2022/05", "gpa": null, "honoursStanding": null,