Skip to content
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
Expand Up @@ -271,6 +271,48 @@ public boolean includedInCollectionThisSchoolYearForDistrictWithNonZeroFteWithSc
return false;
}

public boolean includedInCollectionThisSchoolYearForAuthWithNonZeroFteWithSchoolTypeNotOnline(StudentRuleData studentRuleData) {
// non-zero fte is checked in query
validationRulesService.setupMergedStudentIdValues(studentRuleData);
List<SchoolTombstone> allSchools = this.restUtils.getAllSchoolTombstones();
List<UUID> independentSchoolIDsWithSameAuthorityID = allSchools.stream()
.filter(school -> school.getIndependentAuthorityId() != null && school.getIndependentAuthorityId().equals(studentRuleData.getSchool().getIndependentAuthorityId()))
.map(school -> UUID.fromString(school.getSchoolId()))
.toList();
List<SdcSchoolCollectionStudentEntity> historicalCollections = sdcSchoolCollectionStudentRepository.findStudentInCurrentFiscalWithInSameAuthority(independentSchoolIDsWithSameAuthorityID, studentRuleData.getHistoricStudentIds(), "3");

for (SdcSchoolCollectionStudentEntity studentEntity : historicalCollections) {
String schoolId = studentEntity.getSdcSchoolCollection().getSchoolID().toString();
Optional<SchoolTombstone> school = restUtils.getSchoolBySchoolID(schoolId);
if (school.isPresent() && FacilityTypeCodes.getOnlineFacilityTypeCodes().stream().noneMatch(code -> code.equals(school.get().getFacilityTypeCode()))) {
return true;
}

}
return false;
}

public boolean includedInCollectionThisSchoolYearForAuthWithNonZeroFteWithSchoolTypeOnlineInGradeKto9(StudentRuleData studentRuleData) {
// non-zero fte is checked in query
validationRulesService.setupMergedStudentIdValues(studentRuleData);
List<SchoolTombstone> allSchools = this.restUtils.getAllSchoolTombstones();
List<UUID> independentSchoolIDsWithSameAuthorityID = allSchools.stream()
.filter(school -> school.getIndependentAuthorityId() != null && school.getIndependentAuthorityId().equals(studentRuleData.getSchool().getIndependentAuthorityId()))
.map(school -> UUID.fromString(school.getSchoolId()))
.toList();
List<SdcSchoolCollectionStudentEntity> historicalCollections = sdcSchoolCollectionStudentRepository.findStudentInCurrentFiscalWithInSameAuthority(independentSchoolIDsWithSameAuthorityID, studentRuleData.getHistoricStudentIds(), "3");

for (SdcSchoolCollectionStudentEntity studentEntity : historicalCollections) {
String schoolId = studentEntity.getSdcSchoolCollection().getSchoolID().toString();
Optional<SchoolTombstone> school = restUtils.getSchoolBySchoolID(schoolId);
if (school.isPresent() && FacilityTypeCodes.getOnlineFacilityTypeCodes().contains(school.get().getFacilityTypeCode()) && SchoolGradeCodes.getKToNineGrades().contains(studentEntity.getEnrolledGradeCode())) {
return true;
}

}
return false;
}

public boolean reportedInOnlineSchoolInAnyPreviousCollectionThisSchoolYear(StudentRuleData studentRuleData) {
validationRulesService.setupMergedStudentIdValues(studentRuleData);
List<SdcSchoolCollectionStudentEntity> historicalCollections = sdcSchoolCollectionStudentRepository.findStudentInCurrentFiscalInAllDistrict(studentRuleData.getHistoricStudentIds(), "3");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,28 @@ public FteCalculationResult calculateFte(StudentRuleData studentData) {
return fteCalculationResult;
}

// v103
var includedInCollectionThisSchoolYearForAuthWithNonZeroFteWithSchoolTypeNotOnline = fteCalculatorUtils.includedInCollectionThisSchoolYearForAuthWithNonZeroFteWithSchoolTypeNotOnline(studentData);
// The student was included in any collection in this school year for the auth with a non-zero FTE
// and was reported in any school with a type different than Online.
if (includedInCollectionThisSchoolYearForAuthWithNonZeroFteWithSchoolTypeNotOnline) {
log.debug("CollectionAndFacilityTypeCalculator: FTE Zero; The authority has already received funding for the student this year. :: " + studentData.getSdcSchoolCollectionStudentEntity().getSdcSchoolCollectionStudentID());
fteCalculationResult.setFte(BigDecimal.ZERO);
fteCalculationResult.setFteZeroReason(ZeroFteReasonCodes.IND_AUTH_DUPLICATE_FUNDING.getCode());
return fteCalculationResult;
}

// v103
var includedInCollectionThisSchoolYearForAuthWithNonZeroFteWithSchoolTypeOnlineInGradeKto9 = fteCalculatorUtils.includedInCollectionThisSchoolYearForAuthWithNonZeroFteWithSchoolTypeOnlineInGradeKto9(studentData);
// The student was included in any collection in this school year for the auth with a non-zero FTE
// and was reported in an Online school in grade K to 9.
if (includedInCollectionThisSchoolYearForAuthWithNonZeroFteWithSchoolTypeOnlineInGradeKto9) {
log.debug("CollectionAndFacilityTypeCalculator: FTE Zero; The authority has already received funding for the student this year. :: " + studentData.getSdcSchoolCollectionStudentEntity().getSdcSchoolCollectionStudentID());
fteCalculationResult.setFte(BigDecimal.ZERO);
fteCalculationResult.setFteZeroReason(ZeroFteReasonCodes.IND_AUTH_DUPLICATE_FUNDING.getCode());
return fteCalculationResult;
}

log.debug("CollectionAndFacilityTypeCalculator: No FTE result, moving to next calculation for student :: " + studentData.getSdcSchoolCollectionStudentEntity().getSdcSchoolCollectionStudentID());
return this.nextCalculator.calculateFte(studentData);
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1086,25 +1086,24 @@ NOT IN (SELECT saga.sdcSchoolCollectionStudentID FROM SdcSagaEntity saga WHERE s
List<SdcSchoolCollectionStudentEntity> findStudentInCurrentFiscalWithInSameDistrict(UUID districtID, List<UUID> assignedStudentIDs, String noOfCollections);

@Query(value="""
SELECT SSCS FROM SdcSchoolCollectionEntity SSC, CollectionEntity C, SdcSchoolCollectionStudentEntity SSCS, SdcDistrictCollectionEntity SDC
WHERE SDC.districtID = :districtID
AND C.collectionID = SDC.collectionEntity.collectionID
SELECT SSCS FROM SdcSchoolCollectionEntity SSC, CollectionEntity C, SdcSchoolCollectionStudentEntity SSCS
WHERE SSC.schoolID IN :schoolIDs
AND C.collectionID = SSC.collectionEntity.collectionID
AND SDC.sdcDistrictCollectionID = SSC.sdcDistrictCollectionID
AND SSC.sdcSchoolCollectionID = SSCS.sdcSchoolCollection.sdcSchoolCollectionID
AND SSCS.assignedStudentId in :assignedStudentIDs
AND C.collectionID != :collectionID
AND SSCS.fte > 0
AND SSCS.sdcSchoolCollectionStudentStatusCode != 'DELETED'
AND C.collectionID IN
(SELECT CE.collectionID FROM CollectionEntity CE WHERE CE.collectionStatusCode = 'COMPLETED' AND CE.snapshotDate < :snapshotDate ORDER BY CE.snapshotDate DESC LIMIT :noOfCollections)
(SELECT CE.collectionID FROM CollectionEntity CE WHERE CE.collectionStatusCode = 'COMPLETED' ORDER BY CE.snapshotDate DESC LIMIT :noOfCollections)
""")
List<SdcSchoolCollectionStudentEntity> findStudentInCurrentFiscalWithInSameDistrict(UUID districtID, List<UUID> assignedStudentIDs, String noOfCollections, UUID collectionID, LocalDate snapshotDate);
List<SdcSchoolCollectionStudentEntity> findStudentInCurrentFiscalWithInSameAuthority(List<UUID> schoolIDs, List<UUID> assignedStudentIDs, String noOfCollections);

@Query(value="""
SELECT SSCS FROM SdcSchoolCollectionEntity SSC, CollectionEntity C, SdcSchoolCollectionStudentEntity SSCS
WHERE SSC.schoolID IN :schoolIDs
SELECT SSCS FROM SdcSchoolCollectionEntity SSC, CollectionEntity C, SdcSchoolCollectionStudentEntity SSCS, SdcDistrictCollectionEntity SDC
WHERE SDC.districtID = :districtID
AND C.collectionID = SDC.collectionEntity.collectionID
AND C.collectionID = SSC.collectionEntity.collectionID
AND SDC.sdcDistrictCollectionID = SSC.sdcDistrictCollectionID
AND SSC.sdcSchoolCollectionID = SSCS.sdcSchoolCollection.sdcSchoolCollectionID
AND SSCS.assignedStudentId in :assignedStudentIDs
AND C.collectionID != :collectionID
Expand All @@ -1113,7 +1112,7 @@ NOT IN (SELECT saga.sdcSchoolCollectionStudentID FROM SdcSagaEntity saga WHERE s
AND C.collectionID IN
(SELECT CE.collectionID FROM CollectionEntity CE WHERE CE.collectionStatusCode = 'COMPLETED' AND CE.snapshotDate < :snapshotDate ORDER BY CE.snapshotDate DESC LIMIT :noOfCollections)
""")
List<SdcSchoolCollectionStudentEntity> findStudentInCurrentFiscalWithInSameAuthority(List<UUID> schoolIDs, List<UUID> assignedStudentIDs, String noOfCollections, UUID collectionID, LocalDate snapshotDate);
List<SdcSchoolCollectionStudentEntity> findStudentInCurrentFiscalWithInSameDistrict(UUID districtID, List<UUID> assignedStudentIDs, String noOfCollections, UUID collectionID, LocalDate snapshotDate);

@Query(value="""
SELECT SSCS FROM SdcSchoolCollectionEntity SSC, CollectionEntity C, SdcSchoolCollectionStudentEntity SSCS
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -219,13 +219,12 @@ public List<SdcSchoolCollectionStudentEntity> getStudentInHistoricalCollectionWi

public List<SdcSchoolCollectionStudentEntity> getStudentInHistoricalCollectionWithInSameAuthority(StudentRuleData studentRuleData, String noOfCollectionsForLookup) {
setupMergedStudentIdValues(studentRuleData);
var collection = studentRuleData.getSdcSchoolCollectionStudentEntity().getSdcSchoolCollection().getCollectionEntity();
List<SchoolTombstone> allSchools = this.restUtils.getAllSchoolTombstones();
List<UUID> independentSchoolIDsWithSameAuthorityID = allSchools.stream()
.filter(school -> school.getIndependentAuthorityId() != null && school.getIndependentAuthorityId().equals(studentRuleData.getSchool().getIndependentAuthorityId()))
.map(school -> UUID.fromString(school.getSchoolId()))
.toList();
return sdcSchoolStudentRepository.findStudentInCurrentFiscalWithInSameAuthority(independentSchoolIDsWithSameAuthorityID, studentRuleData.getHistoricStudentIds(), noOfCollectionsForLookup, collection.getCollectionID(), collection.getSnapshotDate());
return sdcSchoolStudentRepository.findStudentInCurrentFiscalWithInSameAuthority(independentSchoolIDsWithSameAuthorityID, studentRuleData.getHistoricStudentIds(), noOfCollectionsForLookup);
}

public List<SdcSchoolCollectionStudentEntity> findStudentInCurrentFiscal(StudentRuleData studentRuleData, String noOfCollectionsForLookup) {
Expand Down
Loading
Loading