diff --git a/src/controllers/DevelopmentScholarshipController.ts b/src/controllers/DevelopmentScholarshipController.ts index c9ba84b..b0ed458 100644 --- a/src/controllers/DevelopmentScholarshipController.ts +++ b/src/controllers/DevelopmentScholarshipController.ts @@ -218,6 +218,7 @@ export class DevelopmentScholarshipController extends Controller { .getManyAndCount(); const formattedData = development.map((item) => ({ id: item.id, + year: item.scholarshipYear, citizenId: item.citizenId, fullName: item.prefix + item.firstName + " " + item.lastName, position: item.position, @@ -461,51 +462,61 @@ export class DevelopmentScholarshipController extends Controller { getDevelopment.status = _status; getDevelopment.lastUpdateUserId = request.user.sub; getDevelopment.lastUpdateFullName = request.user.name; + let scholarshipType = ""; if (_status == "GRADUATE") { if (getDevelopment.scholarshipType != null) { switch (getDevelopment.scholarshipType.trim().toUpperCase()) { case "DOMESTICE": - getDevelopment.scholarshipType = "การศึกษาในประเทศ"; + scholarshipType = "การศึกษาในประเทศ"; break; case "NOABROAD": - getDevelopment.scholarshipType = + scholarshipType = "ฝึกอบรมในประเทศที่ส่งไปพัฒนากับหน่วยวงานภายนอก (หลักสูตรที่ไม่มีการไปต่างประเทศ)"; break; case "ABROAD": - getDevelopment.scholarshipType = + scholarshipType = "ฝึกอบรมในประเทศที่ส่งไปพัฒนากับหน่วยวงานภายนอก (หลักสูตรที่มีการไปต่างประเทศ)"; break; case "EXECUTIVE": - getDevelopment.scholarshipType = + scholarshipType = "ฝึกอบรมในประเทศที่ส่งไปพัฒนากับหน่วยวงานภายนอก (หลักสูตรประเภทนักบริหาร)"; break; default: break; } } - let profileEdu = await new CallAPI().PostData(request, "org/profile/educations", { - profileId: getDevelopment.profileId, - institute: getDevelopment.educationalInstitution, - startDate: getDevelopment.startDate, - endDate: getDevelopment.endDate, - finishDate: null, - isEducation: false, - degree: null, - field: getDevelopment.field, - fundName: getDevelopment.scholarshipType, - gpa: null, - country: getDevelopment.studyCountry, - other: null, - duration: getDevelopment.totalPeriod, - durationYear: 0, - note: null, - educationLevel: getDevelopment.degreeLevel, - educationLevelId: null, - isDate: false, - positionPath: null, - positionPathId: null, - }); + let profileEdu = await new CallAPI() + .PostData(request, "org/profile/educations", { + profileId: getDevelopment.profileId, + institute: getDevelopment.educationalInstitution, + startDate: getDevelopment.startDate, + endDate: getDevelopment.endDate, + finishDate: null, + isEducation: false, + degree: null, + field: getDevelopment.field, + fundName: scholarshipType, + gpa: null, + country: getDevelopment.studyCountry, + other: null, + duration: getDevelopment.totalPeriod, + durationYear: 0, + note: null, + educationLevel: getDevelopment.degreeLevel, + educationLevelId: null, + isDate: false, + positionPath: null, + positionPathId: null, + }) + .then(async (x) => { + await this.developmentScholarshipRepository.save(getDevelopment); + }) + .catch((error) => { + console.error("ไม่สามารถบันทึกลงทะเบียนประวัติได้"); + }); } else if (_status == "NOTGRADUATE") { + getDevelopment.status = _status; + await this.developmentScholarshipRepository.save(getDevelopment); } else { throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบสถานะนี้ในระบบ"); }