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

GRAD2-2338: task is completed. #287

Merged
merged 2 commits into from
Sep 22, 2023
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 @@ -1248,7 +1248,7 @@ private void handleAdultStartRule(ConvGradStudent student, Student penStudent, G
if ("AD".equalsIgnoreCase(gradStudent.getStudentGrade())) {
adultStartDate = DateUtils.addYears(dob, student.isAdult19Rule() ? 19 : 18);
} else {
adultStartDate = DateUtils.addYears(dob, 18);
adultStartDate = getAdultStartDate(dob);
}
gradStudent.setAdultStartDate(EducGradDataConversionApiUtils.formatDate(adultStartDate)); // yyyy-MM-dd
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,13 @@
import ca.bc.gov.educ.api.dataconversion.model.ConvGradStudent;
import ca.bc.gov.educ.api.dataconversion.model.ConversionAlert;
import ca.bc.gov.educ.api.dataconversion.model.ConversionStudentSummaryDTO;
import ca.bc.gov.educ.api.dataconversion.util.EducGradDataConversionApiUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.math.NumberUtils;
import org.apache.commons.lang3.time.DateUtils;

import java.util.Arrays;
import java.util.Date;
import java.util.List;

public class StudentBaseService {
Expand Down Expand Up @@ -153,4 +157,19 @@ private boolean isSchoolForProgramFrancophone(String schoolOfRecord) {
return schoolOfRecord.startsWith("093") || "09898009".equalsIgnoreCase(schoolOfRecord) || "09898047".equalsIgnoreCase(schoolOfRecord);
}

/**
*
* @param dob
* @return adultStartDate
*/
protected Date getAdultStartDate(Date dob) {
Date adultStartDate;
String year = EducGradDataConversionApiUtils.formatDate(dob, "yyyy");
if (NumberUtils.isCreatable(year) && Integer.parseInt(year) < 1994) {
adultStartDate = DateUtils.addYears(dob, 19);
} else {
adultStartDate = DateUtils.addMonths(dob, (12*18) + 1);
}
return adultStartDate;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import ca.bc.gov.educ.api.dataconversion.util.RestUtils;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.time.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

Expand Down Expand Up @@ -181,7 +180,7 @@ private void handleProgramChange(String newGradProgram, StudentGradDTO currentSt
private void handleAdultStartDate(StudentGradDTO currentStudent) {
if (StringUtils.equalsIgnoreCase(currentStudent.getNewProgram(), "1950") && StringUtils.isBlank(currentStudent.getAdultStartDate())) {
Date dob = EducGradDataConversionApiUtils.parseDate(currentStudent.getBirthday());
Date adultStartDate = DateUtils.addYears(dob, 18);
Date adultStartDate = getAdultStartDate(dob);
currentStudent.setNewAdultStartDate(EducGradDataConversionApiUtils.formatDate(adultStartDate)); // yyyy-MM-dd
}
}
Expand Down
Loading