Skip to content

Commit cf2bcab

Browse files
authored
Merge pull request #1518 from bcgov/feature/v99
Changes for V102
2 parents 6b10cbf + b7679db commit cf2bcab

File tree

6 files changed

+20
-82
lines changed

6 files changed

+20
-82
lines changed

api/src/main/java/ca/bc/gov/educ/studentdatacollection/api/calculator/FteCalculatorUtils.java

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
package ca.bc.gov.educ.studentdatacollection.api.calculator;
22

3+
import ca.bc.gov.educ.studentdatacollection.api.constants.StudentValidationFieldCode;
4+
import ca.bc.gov.educ.studentdatacollection.api.constants.StudentValidationIssueSeverityCode;
5+
import ca.bc.gov.educ.studentdatacollection.api.constants.StudentValidationIssueTypeCode;
36
import ca.bc.gov.educ.studentdatacollection.api.constants.v1.CollectionTypeCodes;
47
import ca.bc.gov.educ.studentdatacollection.api.constants.v1.FacilityTypeCodes;
58
import ca.bc.gov.educ.studentdatacollection.api.constants.v1.SchoolCategoryCodes;
@@ -262,25 +265,20 @@ public boolean includedInCollectionThisSchoolYearForDistrictWithNonZeroFteWithSc
262265
public boolean reportedInOnlineSchoolInAnyPreviousCollectionThisSchoolYear(StudentRuleData studentRuleData) {
263266
validationRulesService.setupMergedStudentIdValues(studentRuleData);
264267
List<SdcSchoolCollectionStudentEntity> historicalCollections = sdcSchoolCollectionStudentRepository.findStudentInCurrentFiscalInAllDistrict(studentRuleData.getHistoricStudentIds(), "3");
268+
historicalCollections.add(studentRuleData.getSdcSchoolCollectionStudentEntity());
265269

266270
for (SdcSchoolCollectionStudentEntity studentEntity : historicalCollections) {
267-
String schoolId = studentEntity.getSdcSchoolCollection().getSchoolID().toString();
268-
Optional<SchoolTombstone> school = restUtils.getSchoolBySchoolID(schoolId);
271+
Optional<SchoolTombstone> school = restUtils.getSchoolBySchoolID(studentEntity.getSdcSchoolCollection().getSchoolID().toString());
269272
if (school.isPresent() && FacilityTypeCodes.getOnlineFacilityTypeCodes().contains(school.get().getFacilityTypeCode())) {
270-
BigDecimal fte = studentEntity.getFte();
271-
if (fte != null && fte.compareTo(BigDecimal.ZERO) > 0) {
272-
return true;
273-
}
273+
return true;
274274
}
275275
}
276276
return false;
277277
}
278278

279279
public boolean reportedInOtherDistrictsInPreviousCollectionThisSchoolYearInGrade8Or9WithNonZeroFte(StudentRuleData studentRuleData) {
280280
validationRulesService.setupMergedStudentIdValues(studentRuleData);
281-
String noOfCollectionsForLookup = "3";
282-
List<SdcSchoolCollectionStudentEntity> entity = sdcSchoolCollectionStudentRepository.findStudentInCurrentFiscalInOtherDistrictsNotInGrade8Or9WithNonZeroFte(UUID.fromString(studentRuleData.getSchool().getDistrictId()), studentRuleData.getHistoricStudentIds(), noOfCollectionsForLookup);
283-
return !entity.isEmpty();
281+
return validationRulesService.studentExistsInCurrentFiscalInGrade8Or9(studentRuleData);
284282
}
285283

286284
private LocalDate getFiscalDateFromCurrentSnapshot(LocalDate currentSnapshotDate){

api/src/main/java/ca/bc/gov/educ/studentdatacollection/api/calculator/impl/CollectionAndFacilityTypeCalculator.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,8 @@ public FteCalculationResult calculateFte(StudentRuleData studentData) {
5959

6060
// v99
6161
// The student was not reported in grade 8 or 9 with FTE>0 in any other districts in any previous collections this school year.
62-
var reportedInAnyPreviousCollectionThisSchoolYearInGrade8Or9WithNonZeroFte = fteCalculatorUtils.reportedInOtherDistrictsInPreviousCollectionThisSchoolYearInGrade8Or9WithNonZeroFte(studentData);
63-
if (reportedInAnyPreviousCollectionThisSchoolYearInGrade8Or9WithNonZeroFte) {
62+
var studentExistsInCurrentFiscalInGrade8Or9 = fteCalculatorUtils.reportedInOtherDistrictsInPreviousCollectionThisSchoolYearInGrade8Or9WithNonZeroFte(studentData);
63+
if (!studentExistsInCurrentFiscalInGrade8Or9) {
6464
log.debug("CollectionAndFacilityTypeCalculator: FTE Zero; Student was not reported in Grade 8 or 9 outside of district this school year. :: " + studentData.getSdcSchoolCollectionStudentEntity().getSdcSchoolCollectionStudentID());
6565
fteCalculationResult.setFte(BigDecimal.ZERO);
6666
fteCalculationResult.setFteZeroReason(ZeroFteReasonCodes.NOT_REPORTED.getCode());

api/src/main/java/ca/bc/gov/educ/studentdatacollection/api/rules/validationrules/impl/SummerStudentOnlineLearningRule.java

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -67,21 +67,19 @@ public List<SdcSchoolCollectionStudentValidationIssue> executeValidation(Student
6767

6868
if (studentRuleData.getSdcSchoolCollectionStudentEntity().getAssignedStudentId() != null) {
6969
var historicalStudentCollection = validationRulesService.getStudentInHistoricalCollectionInAllDistrict(studentRuleData);
70+
historicalStudentCollection.add(studentRuleData.getSdcSchoolCollectionStudentEntity());
7071

7172
for (SdcSchoolCollectionStudentEntity studentEntity : historicalStudentCollection) {
7273
Optional<SchoolTombstone> school = restUtils.getSchoolBySchoolID(studentEntity.getSdcSchoolCollection().getSchoolID().toString());
7374
if (school.isPresent() && FacilityTypeCodes.getOnlineFacilityTypeCodes().contains(school.get().getFacilityTypeCode())) {
74-
BigDecimal fte = studentEntity.getFte();
75-
76-
if (fte != null && fte.compareTo(BigDecimal.ZERO) > 0) {
77-
isOnlineRegistered = true;
78-
break;
79-
}
75+
isOnlineRegistered = true;
76+
break;
8077
}
8178
}
8279

83-
if (!isOnlineRegistered)
80+
if (!isOnlineRegistered) {
8481
errors.add(createValidationIssue(StudentValidationIssueSeverityCode.FUNDING_WARNING, StudentValidationFieldCode.ENROLLED_GRADE_CODE, StudentValidationIssueTypeCode.SUMMER_STUDENT_ONLINE_LEARNING_ERROR));
82+
}
8583
}
8684
return errors;
8785
}

api/src/test/java/ca/bc/gov/educ/studentdatacollection/api/calculator/FteCalculatorUtilsTest.java

Lines changed: 2 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -1631,64 +1631,6 @@ void testReportedInOnlineSchoolInAnyPreviousCollectionThisSchoolYear_NotOnlineSc
16311631
assertFalse(result);
16321632
}
16331633

1634-
@Test
1635-
void testReportedInOnlineSchoolInAnyPreviousCollectionThisSchoolYear_OnlineSchool_InDistrict_ReturnsTrue() {
1636-
// Given
1637-
StudentRuleData studentRuleData = new StudentRuleData();
1638-
SchoolTombstone schoolTombstone = new SchoolTombstone();
1639-
schoolTombstone.setFacilityTypeCode(FacilityTypeCodes.DISTONLINE.getCode());
1640-
schoolTombstone.setDistrictId(UUID.randomUUID().toString());
1641-
studentRuleData.setSchool(schoolTombstone);
1642-
SdcSchoolCollectionStudentEntity student = new SdcSchoolCollectionStudentEntity();
1643-
CollectionEntity collection = createMockCollectionEntity();
1644-
collection.setCollectionTypeCode(CollectionTypeCodes.FEBRUARY.getTypeCode());
1645-
SdcSchoolCollectionEntity sdcSchoolCollectionEntity = createMockSdcSchoolCollectionEntity(collection, null);
1646-
student.setSdcSchoolCollection(sdcSchoolCollectionEntity);
1647-
student.setFte(BigDecimal.TEN);
1648-
student.setEnrolledGradeCode(SchoolGradeCodes.GRADE10.getCode());
1649-
student.setAssignedStudentId(UUID.randomUUID());
1650-
studentRuleData.setSdcSchoolCollectionStudentEntity(student);
1651-
studentRuleData.setHistoricStudentIds(List.of(UUID.randomUUID(), student.getAssignedStudentId()));
1652-
1653-
when(sdcSchoolCollectionStudentRepository.findStudentInCurrentFiscalInAllDistrict(anyList(), any(String.class))).thenReturn(Collections.singletonList(student));
1654-
when(restUtils.getSchoolBySchoolID(anyString())).thenReturn(Optional.of(schoolTombstone));
1655-
1656-
// When
1657-
var result = fteCalculatorUtils.reportedInOnlineSchoolInAnyPreviousCollectionThisSchoolYear(studentRuleData);
1658-
1659-
// Then
1660-
assertTrue(result);
1661-
}
1662-
1663-
@Test
1664-
void testReportedInOnlineSchoolInAnyPreviousCollectionThisSchoolYear_OnlineSchool_NotInDistrict_ReturnsTrue() {
1665-
// Given
1666-
StudentRuleData studentRuleData = new StudentRuleData();
1667-
SchoolTombstone schoolTombstone = new SchoolTombstone();
1668-
schoolTombstone.setFacilityTypeCode(FacilityTypeCodes.DISTONLINE.getCode());
1669-
studentRuleData.setSchool(schoolTombstone);
1670-
SdcSchoolCollectionStudentEntity student = new SdcSchoolCollectionStudentEntity();
1671-
CollectionEntity collection = createMockCollectionEntity();
1672-
collection.setCollectionTypeCode(CollectionTypeCodes.FEBRUARY.getTypeCode());
1673-
SdcSchoolCollectionEntity sdcSchoolCollectionEntity = createMockSdcSchoolCollectionEntity(collection, null);
1674-
student.setSdcSchoolCollection(sdcSchoolCollectionEntity);
1675-
student.setFte(BigDecimal.TEN);
1676-
student.setEnrolledGradeCode(SchoolGradeCodes.GRADE10.getCode());
1677-
student.setCreateDate(LocalDateTime.now());
1678-
student.setAssignedStudentId(UUID.randomUUID());
1679-
studentRuleData.setSdcSchoolCollectionStudentEntity(student);
1680-
studentRuleData.setHistoricStudentIds(List.of(UUID.randomUUID(), student.getAssignedStudentId()));
1681-
1682-
when(sdcSchoolCollectionStudentRepository.findStudentInCurrentFiscalInAllDistrict(anyList(), any(String.class))).thenReturn(Collections.singletonList(student));
1683-
when(restUtils.getSchoolBySchoolID(anyString())).thenReturn(Optional.of(schoolTombstone));
1684-
1685-
// When
1686-
var result = fteCalculatorUtils.reportedInOnlineSchoolInAnyPreviousCollectionThisSchoolYear(studentRuleData);
1687-
1688-
// Then
1689-
assertTrue(result);
1690-
}
1691-
16921634
@Test
16931635
void testReportedInOtherDistrictsInPreviousCollectionThisSchoolYearInGrade8Or9WithNonZeroFte_Grade8Or9_NonZeroFte_ReturnsFalse() {
16941636
// Given
@@ -1798,7 +1740,7 @@ void testReportedInOnlineSchoolInAnyPreviousCollectionThisSchoolYear_OnlineSchoo
17981740
// Given
17991741
StudentRuleData studentRuleData = new StudentRuleData();
18001742
SchoolTombstone schoolTombstone = new SchoolTombstone();
1801-
schoolTombstone.setFacilityTypeCode(FacilityTypeCodes.DISTONLINE.getCode());
1743+
schoolTombstone.setFacilityTypeCode(FacilityTypeCodes.SUMMER.getCode());
18021744
schoolTombstone.setDistrictId(UUID.randomUUID().toString());
18031745
studentRuleData.setSchool(schoolTombstone);
18041746

@@ -1840,7 +1782,7 @@ void testReportedInOnlineSchoolInAnyPreviousCollectionThisSchoolYear_OnlineSchoo
18401782
var result = fteCalculatorUtils.reportedInOnlineSchoolInAnyPreviousCollectionThisSchoolYear(studentRuleData);
18411783

18421784
// Then
1843-
assertFalse(result);
1785+
assertTrue(result);
18441786
}
18451787

18461788
public CollectionEntity createMockCollectionEntity(){

api/src/test/java/ca/bc/gov/educ/studentdatacollection/api/calculator/impl/CollectionAndFacilityTypeCalculatorTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -155,8 +155,8 @@ void testCalculateFte_JulyCollectionAndFacilityTypeDifferentThanSummerSchool_Not
155155

156156
when(fteCalculatorUtils.includedInCollectionThisSchoolYearForDistrictWithNonZeroFteWithSchoolTypeNotOnline(studentData)).thenReturn(false);
157157
when(fteCalculatorUtils.includedInCollectionThisSchoolYearForDistrictWithNonZeroFteWithSchoolTypeOnlineInGradeKto9(studentData)).thenReturn(false);
158-
when(fteCalculatorUtils.reportedInOnlineSchoolInAnyPreviousCollectionThisSchoolYear(studentData)).thenReturn(false);
159-
when(fteCalculatorUtils.reportedInOtherDistrictsInPreviousCollectionThisSchoolYearInGrade8Or9WithNonZeroFte(studentData)).thenReturn(true);
158+
when(fteCalculatorUtils.reportedInOnlineSchoolInAnyPreviousCollectionThisSchoolYear(studentData)).thenReturn(true);
159+
when(fteCalculatorUtils.reportedInOtherDistrictsInPreviousCollectionThisSchoolYearInGrade8Or9WithNonZeroFte(studentData)).thenReturn(false);
160160

161161
// When
162162
FteCalculationResult result = collectionAndFacilityTypeCalculator.calculateFte(studentData);
@@ -198,7 +198,7 @@ void testCalculateFte_JulyCollectionAndFacilityTypeDifferentThanSummerSchool_Not
198198
when(fteCalculatorUtils.includedInCollectionThisSchoolYearForDistrictWithNonZeroFteWithSchoolTypeNotOnline(studentData)).thenReturn(false);
199199
when(fteCalculatorUtils.includedInCollectionThisSchoolYearForDistrictWithNonZeroFteWithSchoolTypeOnlineInGradeKto9(studentData)).thenReturn(false);
200200
when(fteCalculatorUtils.reportedInOnlineSchoolInAnyPreviousCollectionThisSchoolYear(studentData)).thenReturn(false);
201-
when(fteCalculatorUtils.reportedInOtherDistrictsInPreviousCollectionThisSchoolYearInGrade8Or9WithNonZeroFte(studentData)).thenReturn(false);
201+
when(fteCalculatorUtils.reportedInOtherDistrictsInPreviousCollectionThisSchoolYearInGrade8Or9WithNonZeroFte(studentData)).thenReturn(true);
202202

203203
// When
204204
FteCalculationResult result = collectionAndFacilityTypeCalculator.calculateFte(studentData);

api/src/test/java/ca/bc/gov/educ/studentdatacollection/api/rules/SummerRulesProcessorTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -852,7 +852,7 @@ void testSummerStudentOnlineLearningRuleIsExecuted_WithNoErrors_WhenStudentInOnl
852852

853853
val entity = this.createMockSchoolStudentEntity(sdcSchoolCollectionEntity);
854854
school.setSchoolCategoryCode(SchoolCategoryCodes.PUBLIC.getCode());
855-
school.setFacilityTypeCode(FacilityTypeCodes.DIST_LEARN.getCode());
855+
school.setFacilityTypeCode(FacilityTypeCodes.SUMMER.getCode());
856856
PenMatchResult penMatchResult = getPenMatchResult();
857857
penMatchResult.getMatchingRecords().get(0).setStudentID(String.valueOf(assignedStudentID));
858858
when(this.restUtils.getPenMatchResult(any(), any(), anyString())).thenReturn(penMatchResult);

0 commit comments

Comments
 (0)