diff --git a/src/controllers/ProfileAddressController.ts b/src/controllers/ProfileAddressController.ts index 782fcd37..9e283744 100644 --- a/src/controllers/ProfileAddressController.ts +++ b/src/controllers/ProfileAddressController.ts @@ -68,10 +68,10 @@ export class ProfileAddressController extends Controller { * @summary ประวัติแก้ไขที่อยู่ * */ - @Get("history/{addressId}") - public async getProfileAddressHistory(@Path() addressId: string) { + @Get("history/{profileId}") + public async getProfileAddressHistory(@Path() profileId: string) { const record = await this.profileAddressHistoryRepo.find({ - where: { profileId: addressId }, + where: { profileId: profileId }, relations: { registrationProvince: true, registrationDistrict: true, @@ -106,13 +106,13 @@ export class ProfileAddressController extends Controller { * @summary แก้ไขที่อยู่ * */ - @Patch("{addressId}") + @Patch("{profileId}") public async editProfileAddress( @Body() requestBody: UpdateProfileAddress, @Request() req: RequestWithUser, - @Path() addressId: string, + @Path() profileId: string, ) { - const record = await this.profileRepo.findOneBy({ id: addressId }); + const record = await this.profileRepo.findOneBy({ id: profileId }); if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); const history = new ProfileAddressHistory(); @@ -120,7 +120,7 @@ export class ProfileAddressController extends Controller { Object.assign(history, { ...record, id: undefined }); Object.assign(record, requestBody); - history.profileId = addressId; + history.profileId = profileId; history.lastUpdateFullName = req.user.name; record.lastUpdateFullName = req.user.name; diff --git a/src/controllers/ProfileAddressEmployeeController.ts b/src/controllers/ProfileAddressEmployeeController.ts index 8619d92c..12e11049 100644 --- a/src/controllers/ProfileAddressEmployeeController.ts +++ b/src/controllers/ProfileAddressEmployeeController.ts @@ -69,10 +69,10 @@ export class ProfileAddressEmployeeController extends Controller { * @summary ประวัติแก้ไขที่อยู่ * */ - @Get("history/{addressId}") - public async getProfileAddressHistory(@Path() addressId: string) { + @Get("history/{profileId}") + public async getProfileAddressHistory(@Path() profileId: string) { const record = await this.profileAddressHistoryRepo.find({ - where: { profileEmployeeId: addressId }, + where: { profileEmployeeId: profileId }, relations: { registrationProvince: true, registrationDistrict: true, @@ -107,13 +107,13 @@ export class ProfileAddressEmployeeController extends Controller { * @summary แก้ไขที่อยู่ * */ - @Patch("{addressId}") + @Patch("{profileId}") public async editProfileAddress( @Body() requestBody: UpdateProfileAddressEmployee, @Request() req: RequestWithUser, - @Path() addressId: string, + @Path() profileId: string, ) { - const record = await this.profileEmployeeRepo.findOneBy({ id: addressId }); + const record = await this.profileEmployeeRepo.findOneBy({ id: profileId }); if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); const history = new ProfileAddressHistory(); @@ -121,7 +121,7 @@ export class ProfileAddressEmployeeController extends Controller { Object.assign(history, { ...record, id: undefined }); Object.assign(record, requestBody); - history.profileEmployeeId = addressId; + history.profileEmployeeId = profileId; history.lastUpdateFullName = req.user.name; record.lastUpdateFullName = req.user.name; diff --git a/src/controllers/ProfileChangeNameController.ts b/src/controllers/ProfileChangeNameController.ts index 9d995cde..0d3d0740 100644 --- a/src/controllers/ProfileChangeNameController.ts +++ b/src/controllers/ProfileChangeNameController.ts @@ -159,7 +159,7 @@ export class ProfileChangeNameController extends Controller { const chkLastRecord = await this.changeNameRepository.findOne({ where:{ - profileEmployeeId: record.profileEmployeeId + profileId: record.profileId }, order:{ createdAt: "DESC" diff --git a/src/controllers/ProfileChangeNameEmployeeController.ts b/src/controllers/ProfileChangeNameEmployeeController.ts index fcdcfbaf..cfbc377e 100644 --- a/src/controllers/ProfileChangeNameEmployeeController.ts +++ b/src/controllers/ProfileChangeNameEmployeeController.ts @@ -178,7 +178,7 @@ export class ProfileChangeNameEmployeeController extends Controller { await this.profileEmployeeRepo.save(profile); } - return new HttpSuccess([chkLastRecord.id,record.id]); + return new HttpSuccess(); } @Delete("{changeNameId}") diff --git a/src/controllers/ProfileController.ts b/src/controllers/ProfileController.ts index d2c87cf1..3e5cedd6 100644 --- a/src/controllers/ProfileController.ts +++ b/src/controllers/ProfileController.ts @@ -31,7 +31,7 @@ import { OrgRevision } from "../entities/OrgRevision"; import { PosMaster } from "../entities/PosMaster"; import { PosLevel } from "../entities/PosLevel"; import { PosType } from "../entities/PosType"; -import { calculateAge, calculateRetireDate, calculateRetireYear } from "../interfaces/utils"; +import { calculateAge, calculateRetireDate, calculateRetireLaw, calculateRetireYear } from "../interfaces/utils"; import { RequestWithUser } from "../middlewares/user"; import { Position } from "../entities/Position"; @@ -242,7 +242,7 @@ export class ProfileController extends Controller { profile.lastUpdateUserId = request.user.sub; profile.lastUpdateFullName = request.user.name; profile.dateRetire = calculateRetireDate(profile.birthDate); - // profile.dateRetireLaw = calculateRetireDate(profile.birthDate); + profile.dateRetireLaw = calculateRetireLaw(profile.birthDate); await this.profileRepo.save(profile); @@ -383,7 +383,7 @@ export class ProfileController extends Controller { record.lastUpdateUserId = request.user.sub; record.lastUpdateFullName = request.user.name; record.dateRetire = calculateRetireDate(record.birthDate); - // record.dateRetireLaw = calculateRetireDate(record.birthDate); + record.dateRetireLaw = calculateRetireLaw(record.birthDate); await this.profileRepo.save(record); return new HttpSuccess(); diff --git a/src/controllers/ProfileEmployeeController.ts b/src/controllers/ProfileEmployeeController.ts index 05d58bd1..91cf2b11 100644 --- a/src/controllers/ProfileEmployeeController.ts +++ b/src/controllers/ProfileEmployeeController.ts @@ -20,7 +20,7 @@ import HttpStatus from "../interfaces/http-status"; import HttpError from "../interfaces/http-error"; import { Brackets, IsNull, Like, Not } from "typeorm"; import { OrgRevision } from "../entities/OrgRevision"; -import { calculateRetireDate } from "../interfaces/utils"; +import { calculateRetireDate, calculateRetireLaw } from "../interfaces/utils"; import { EmployeePosMaster } from "../entities/EmployeePosMaster"; import { ProfileEmployee, @@ -115,7 +115,7 @@ export class ProfileEmployeeController extends Controller { profile.lastUpdateUserId = request.user.sub; profile.lastUpdateFullName = request.user.name; profile.dateRetire = calculateRetireDate(profile.birthDate); - // profile.dateRetireLaw = calculateRetireDate(profile.birthDate); + profile.dateRetireLaw = calculateRetireLaw(profile.birthDate); await this.profileRepo.save(profile); return new HttpSuccess(); @@ -205,7 +205,7 @@ export class ProfileEmployeeController extends Controller { record.lastUpdateUserId = request.user.sub; record.lastUpdateFullName = request.user.name; record.dateRetire = calculateRetireDate(record.birthDate); - // record.dateRetireLaw = calculateRetireDate(record.birthDate); + record.dateRetireLaw = calculateRetireLaw(record.birthDate); await this.profileRepo.save(record); diff --git a/src/interfaces/utils.ts b/src/interfaces/utils.ts index b791b9e9..5537734a 100644 --- a/src/interfaces/utils.ts +++ b/src/interfaces/utils.ts @@ -41,6 +41,10 @@ export function calculateRetireDate(birthDate: Date) { return new Date(`${yy + 61}-09-30T00:00:00.000+07:00`); } +export function calculateRetireLaw(birthDate: Date) { + let yy = birthDate.getFullYear(); + return new Date(`${yy + 60}-09-30T00:00:00.000+07:00`); +} export function calculateRetireYear(birthDate: Date) { let dd = birthDate.getDate();