Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changes for V102 #1518

Merged
merged 1 commit into from
Jan 15, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
package ca.bc.gov.educ.studentdatacollection.api.calculator;

import ca.bc.gov.educ.studentdatacollection.api.constants.StudentValidationFieldCode;
import ca.bc.gov.educ.studentdatacollection.api.constants.StudentValidationIssueSeverityCode;
import ca.bc.gov.educ.studentdatacollection.api.constants.StudentValidationIssueTypeCode;
import ca.bc.gov.educ.studentdatacollection.api.constants.v1.CollectionTypeCodes;
import ca.bc.gov.educ.studentdatacollection.api.constants.v1.FacilityTypeCodes;
import ca.bc.gov.educ.studentdatacollection.api.constants.v1.SchoolCategoryCodes;
Expand Down Expand Up @@ -260,25 +263,20 @@ public boolean includedInCollectionThisSchoolYearForDistrictWithNonZeroFteWithSc
public boolean reportedInOnlineSchoolInAnyPreviousCollectionThisSchoolYear(StudentRuleData studentRuleData) {
validationRulesService.setupMergedStudentIdValues(studentRuleData);
List<SdcSchoolCollectionStudentEntity> historicalCollections = sdcSchoolCollectionStudentRepository.findStudentInCurrentFiscalInAllDistrict(studentRuleData.getHistoricStudentIds(), "3");
historicalCollections.add(studentRuleData.getSdcSchoolCollectionStudentEntity());

for (SdcSchoolCollectionStudentEntity studentEntity : historicalCollections) {
String schoolId = studentEntity.getSdcSchoolCollection().getSchoolID().toString();
Optional<SchoolTombstone> school = restUtils.getSchoolBySchoolID(schoolId);
Optional<SchoolTombstone> school = restUtils.getSchoolBySchoolID(studentEntity.getSdcSchoolCollection().getSchoolID().toString());
if (school.isPresent() && FacilityTypeCodes.getOnlineFacilityTypeCodes().contains(school.get().getFacilityTypeCode())) {
BigDecimal fte = studentEntity.getFte();
if (fte != null && fte.compareTo(BigDecimal.ZERO) > 0) {
return true;
}
return true;
}
}
return false;
}

public boolean reportedInOtherDistrictsInPreviousCollectionThisSchoolYearInGrade8Or9WithNonZeroFte(StudentRuleData studentRuleData) {
validationRulesService.setupMergedStudentIdValues(studentRuleData);
String noOfCollectionsForLookup = "3";
List<SdcSchoolCollectionStudentEntity> entity = sdcSchoolCollectionStudentRepository.findStudentInCurrentFiscalInOtherDistrictsNotInGrade8Or9WithNonZeroFte(UUID.fromString(studentRuleData.getSchool().getDistrictId()), studentRuleData.getHistoricStudentIds(), noOfCollectionsForLookup);
return !entity.isEmpty();
return validationRulesService.studentExistsInCurrentFiscalInGrade8Or9(studentRuleData);
}

private LocalDate getFiscalDateFromCurrentSnapshot(LocalDate currentSnapshotDate){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ public FteCalculationResult calculateFte(StudentRuleData studentData) {

// v99
// The student was not reported in grade 8 or 9 with FTE>0 in any other districts in any previous collections this school year.
var reportedInAnyPreviousCollectionThisSchoolYearInGrade8Or9WithNonZeroFte = fteCalculatorUtils.reportedInOtherDistrictsInPreviousCollectionThisSchoolYearInGrade8Or9WithNonZeroFte(studentData);
if (reportedInAnyPreviousCollectionThisSchoolYearInGrade8Or9WithNonZeroFte) {
var studentExistsInCurrentFiscalInGrade8Or9 = fteCalculatorUtils.reportedInOtherDistrictsInPreviousCollectionThisSchoolYearInGrade8Or9WithNonZeroFte(studentData);
if (!studentExistsInCurrentFiscalInGrade8Or9) {
log.debug("CollectionAndFacilityTypeCalculator: FTE Zero; Student was not reported in Grade 8 or 9 outside of district this school year. :: " + studentData.getSdcSchoolCollectionStudentEntity().getSdcSchoolCollectionStudentID());
fteCalculationResult.setFte(BigDecimal.ZERO);
fteCalculationResult.setFteZeroReason(ZeroFteReasonCodes.NOT_REPORTED.getCode());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,21 +67,19 @@ public List<SdcSchoolCollectionStudentValidationIssue> executeValidation(Student

if (studentRuleData.getSdcSchoolCollectionStudentEntity().getAssignedStudentId() != null) {
var historicalStudentCollection = validationRulesService.getStudentInHistoricalCollectionInAllDistrict(studentRuleData);
historicalStudentCollection.add(studentRuleData.getSdcSchoolCollectionStudentEntity());

for (SdcSchoolCollectionStudentEntity studentEntity : historicalStudentCollection) {
Optional<SchoolTombstone> school = restUtils.getSchoolBySchoolID(studentEntity.getSdcSchoolCollection().getSchoolID().toString());
if (school.isPresent() && FacilityTypeCodes.getOnlineFacilityTypeCodes().contains(school.get().getFacilityTypeCode())) {
BigDecimal fte = studentEntity.getFte();

if (fte != null && fte.compareTo(BigDecimal.ZERO) > 0) {
isOnlineRegistered = true;
break;
}
isOnlineRegistered = true;
break;
}
}

if (!isOnlineRegistered)
if (!isOnlineRegistered) {
errors.add(createValidationIssue(StudentValidationIssueSeverityCode.FUNDING_WARNING, StudentValidationFieldCode.ENROLLED_GRADE_CODE, StudentValidationIssueTypeCode.SUMMER_STUDENT_ONLINE_LEARNING_ERROR));
}
}
return errors;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1589,64 +1589,6 @@ void testReportedInOnlineSchoolInAnyPreviousCollectionThisSchoolYear_NotOnlineSc
assertFalse(result);
}

@Test
void testReportedInOnlineSchoolInAnyPreviousCollectionThisSchoolYear_OnlineSchool_InDistrict_ReturnsTrue() {
// Given
StudentRuleData studentRuleData = new StudentRuleData();
SchoolTombstone schoolTombstone = new SchoolTombstone();
schoolTombstone.setFacilityTypeCode(FacilityTypeCodes.DISTONLINE.getCode());
schoolTombstone.setDistrictId(UUID.randomUUID().toString());
studentRuleData.setSchool(schoolTombstone);
SdcSchoolCollectionStudentEntity student = new SdcSchoolCollectionStudentEntity();
CollectionEntity collection = createMockCollectionEntity();
collection.setCollectionTypeCode(CollectionTypeCodes.FEBRUARY.getTypeCode());
SdcSchoolCollectionEntity sdcSchoolCollectionEntity = createMockSdcSchoolCollectionEntity(collection, null);
student.setSdcSchoolCollection(sdcSchoolCollectionEntity);
student.setFte(BigDecimal.TEN);
student.setEnrolledGradeCode(SchoolGradeCodes.GRADE10.getCode());
student.setAssignedStudentId(UUID.randomUUID());
studentRuleData.setSdcSchoolCollectionStudentEntity(student);
studentRuleData.setHistoricStudentIds(List.of(UUID.randomUUID(), student.getAssignedStudentId()));

when(sdcSchoolCollectionStudentRepository.findStudentInCurrentFiscalInAllDistrict(anyList(), any(String.class))).thenReturn(Collections.singletonList(student));
when(restUtils.getSchoolBySchoolID(anyString())).thenReturn(Optional.of(schoolTombstone));

// When
var result = fteCalculatorUtils.reportedInOnlineSchoolInAnyPreviousCollectionThisSchoolYear(studentRuleData);

// Then
assertTrue(result);
}

@Test
void testReportedInOnlineSchoolInAnyPreviousCollectionThisSchoolYear_OnlineSchool_NotInDistrict_ReturnsTrue() {
// Given
StudentRuleData studentRuleData = new StudentRuleData();
SchoolTombstone schoolTombstone = new SchoolTombstone();
schoolTombstone.setFacilityTypeCode(FacilityTypeCodes.DISTONLINE.getCode());
studentRuleData.setSchool(schoolTombstone);
SdcSchoolCollectionStudentEntity student = new SdcSchoolCollectionStudentEntity();
CollectionEntity collection = createMockCollectionEntity();
collection.setCollectionTypeCode(CollectionTypeCodes.FEBRUARY.getTypeCode());
SdcSchoolCollectionEntity sdcSchoolCollectionEntity = createMockSdcSchoolCollectionEntity(collection, null);
student.setSdcSchoolCollection(sdcSchoolCollectionEntity);
student.setFte(BigDecimal.TEN);
student.setEnrolledGradeCode(SchoolGradeCodes.GRADE10.getCode());
student.setCreateDate(LocalDateTime.now());
student.setAssignedStudentId(UUID.randomUUID());
studentRuleData.setSdcSchoolCollectionStudentEntity(student);
studentRuleData.setHistoricStudentIds(List.of(UUID.randomUUID(), student.getAssignedStudentId()));

when(sdcSchoolCollectionStudentRepository.findStudentInCurrentFiscalInAllDistrict(anyList(), any(String.class))).thenReturn(Collections.singletonList(student));
when(restUtils.getSchoolBySchoolID(anyString())).thenReturn(Optional.of(schoolTombstone));

// When
var result = fteCalculatorUtils.reportedInOnlineSchoolInAnyPreviousCollectionThisSchoolYear(studentRuleData);

// Then
assertTrue(result);
}

@Test
void testReportedInOtherDistrictsInPreviousCollectionThisSchoolYearInGrade8Or9WithNonZeroFte_Grade8Or9_NonZeroFte_ReturnsFalse() {
// Given
Expand Down Expand Up @@ -1756,7 +1698,7 @@ void testReportedInOnlineSchoolInAnyPreviousCollectionThisSchoolYear_OnlineSchoo
// Given
StudentRuleData studentRuleData = new StudentRuleData();
SchoolTombstone schoolTombstone = new SchoolTombstone();
schoolTombstone.setFacilityTypeCode(FacilityTypeCodes.DISTONLINE.getCode());
schoolTombstone.setFacilityTypeCode(FacilityTypeCodes.SUMMER.getCode());
schoolTombstone.setDistrictId(UUID.randomUUID().toString());
studentRuleData.setSchool(schoolTombstone);

Expand Down Expand Up @@ -1798,7 +1740,7 @@ void testReportedInOnlineSchoolInAnyPreviousCollectionThisSchoolYear_OnlineSchoo
var result = fteCalculatorUtils.reportedInOnlineSchoolInAnyPreviousCollectionThisSchoolYear(studentRuleData);

// Then
assertFalse(result);
assertTrue(result);
}

public CollectionEntity createMockCollectionEntity(){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,8 @@ void testCalculateFte_JulyCollectionAndFacilityTypeDifferentThanSummerSchool_Not

when(fteCalculatorUtils.includedInCollectionThisSchoolYearForDistrictWithNonZeroFteWithSchoolTypeNotOnline(studentData)).thenReturn(false);
when(fteCalculatorUtils.includedInCollectionThisSchoolYearForDistrictWithNonZeroFteWithSchoolTypeOnlineInGradeKto9(studentData)).thenReturn(false);
when(fteCalculatorUtils.reportedInOnlineSchoolInAnyPreviousCollectionThisSchoolYear(studentData)).thenReturn(false);
when(fteCalculatorUtils.reportedInOtherDistrictsInPreviousCollectionThisSchoolYearInGrade8Or9WithNonZeroFte(studentData)).thenReturn(true);
when(fteCalculatorUtils.reportedInOnlineSchoolInAnyPreviousCollectionThisSchoolYear(studentData)).thenReturn(true);
when(fteCalculatorUtils.reportedInOtherDistrictsInPreviousCollectionThisSchoolYearInGrade8Or9WithNonZeroFte(studentData)).thenReturn(false);

// When
FteCalculationResult result = collectionAndFacilityTypeCalculator.calculateFte(studentData);
Expand Down Expand Up @@ -198,7 +198,7 @@ void testCalculateFte_JulyCollectionAndFacilityTypeDifferentThanSummerSchool_Not
when(fteCalculatorUtils.includedInCollectionThisSchoolYearForDistrictWithNonZeroFteWithSchoolTypeNotOnline(studentData)).thenReturn(false);
when(fteCalculatorUtils.includedInCollectionThisSchoolYearForDistrictWithNonZeroFteWithSchoolTypeOnlineInGradeKto9(studentData)).thenReturn(false);
when(fteCalculatorUtils.reportedInOnlineSchoolInAnyPreviousCollectionThisSchoolYear(studentData)).thenReturn(false);
when(fteCalculatorUtils.reportedInOtherDistrictsInPreviousCollectionThisSchoolYearInGrade8Or9WithNonZeroFte(studentData)).thenReturn(false);
when(fteCalculatorUtils.reportedInOtherDistrictsInPreviousCollectionThisSchoolYearInGrade8Or9WithNonZeroFte(studentData)).thenReturn(true);

// When
FteCalculationResult result = collectionAndFacilityTypeCalculator.calculateFte(studentData);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -852,7 +852,7 @@ void testSummerStudentOnlineLearningRuleIsExecuted_WithNoErrors_WhenStudentInOnl

val entity = this.createMockSchoolStudentEntity(sdcSchoolCollectionEntity);
school.setSchoolCategoryCode(SchoolCategoryCodes.PUBLIC.getCode());
school.setFacilityTypeCode(FacilityTypeCodes.DIST_LEARN.getCode());
school.setFacilityTypeCode(FacilityTypeCodes.SUMMER.getCode());
PenMatchResult penMatchResult = getPenMatchResult();
penMatchResult.getMatchingRecords().get(0).setStudentID(String.valueOf(assignedStudentID));
when(this.restUtils.getPenMatchResult(any(), any(), anyString())).thenReturn(penMatchResult);
Expand Down
Loading