history update position

This commit is contained in:
mamoss 2025-08-26 13:47:43 +07:00
parent 0df264e900
commit 910e568973
10 changed files with 625 additions and 16 deletions

View file

@ -59,7 +59,6 @@ import {
createUser,
getRoles,
deleteUser,
enableStatus,
getUserByUsername,
getRoleMappings,
removeUserRoles,
@ -92,6 +91,10 @@ import { ProfileInsignia, CreateProfileInsignia } from "../entities/ProfileInsig
import { ProfileInsigniaHistory } from "../entities/ProfileInsigniaHistory";
import { Gender } from "../entities/Gender";
import { ProfileAvatar } from "../entities/ProfileAvatar";
import {
CreatePosMasterHistoryEmployee,
CreatePosMasterHistoryOfficer,
} from "../services/PositionService";
@Route("api/v1/org/command")
@Tags("Command")
@Security("bearerAuth")
@ -3154,8 +3157,12 @@ export class CommandController extends Controller {
posMaster.lastUpdatedAt = new Date();
posMaster.conditionReason = _null;
posMaster.isCondition = false;
if (posMasterOld != null) await this.posMasterRepository.save(posMasterOld);
if (posMasterOld != null) {
await this.posMasterRepository.save(posMasterOld);
await CreatePosMasterHistoryOfficer(posMasterOld.id, req);
}
await this.posMasterRepository.save(posMaster);
await CreatePosMasterHistoryOfficer(posMaster.id, req);
const positionNew = await this.positionRepository.findOne({
where: {
@ -3342,8 +3349,12 @@ export class CommandController extends Controller {
posMaster.current_holderId = item.profileId;
posMaster.lastUpdatedAt = new Date();
posMaster.next_holderId = null;
if (posMasterOld != null) await this.employeePosMasterRepository.save(posMasterOld);
if (posMasterOld != null) {
await this.employeePosMasterRepository.save(posMasterOld);
await CreatePosMasterHistoryEmployee(posMasterOld.id, req);
}
await this.employeePosMasterRepository.save(posMaster);
await CreatePosMasterHistoryEmployee(posMaster.id, req);
const positionNew = await this.employeePositionRepository.findOne({
where: {
@ -3573,6 +3584,7 @@ export class CommandController extends Controller {
posMaster.conditionReason = _null;
posMaster.isCondition = false;
await this.posMasterRepository.save(posMaster);
await CreatePosMasterHistoryOfficer(posMaster.id, req);
const positionNew = await this.positionRepository.findOne({
where: {
posMasterId: posMaster.id,
@ -6030,8 +6042,12 @@ export class CommandController extends Controller {
posMaster.lastUpdatedAt = new Date();
posMaster.conditionReason = _null;
posMaster.isCondition = false;
if (posMasterOld != null) await this.posMasterRepository.save(posMasterOld);
if (posMasterOld != null) {
await this.posMasterRepository.save(posMasterOld);
await CreatePosMasterHistoryOfficer(posMasterOld.id, req);
}
await this.posMasterRepository.save(posMaster);
await CreatePosMasterHistoryOfficer(posMaster.id, req);
const positionNew = await this.positionRepository.findOne({
where: {
@ -6411,8 +6427,12 @@ export class CommandController extends Controller {
posMaster.current_holderId = profile.id;
posMaster.lastUpdatedAt = new Date();
posMaster.next_holderId = null;
if (posMasterOld != null) await this.employeePosMasterRepository.save(posMasterOld);
if (posMasterOld != null) {
await this.employeePosMasterRepository.save(posMasterOld);
await CreatePosMasterHistoryEmployee(posMasterOld.id, req);
}
await this.employeePosMasterRepository.save(posMaster);
await CreatePosMasterHistoryEmployee(posMaster.id, req);
const clsTempPosmaster = await this.employeeTempPosMasterRepository.find({
where: {