Merge branch 'develop'

This commit is contained in:
kittapath 2024-12-10 11:52:30 +07:00
commit bf0c30151a
24 changed files with 350 additions and 72 deletions

View file

@ -1,5 +1,5 @@
name: release-test
run-name: release-test ${{ github.actor }}
name: release
run-name: release ${{ github.actor }}
on:
push:
tags:
@ -9,11 +9,11 @@ env:
REGISTRY: docker.frappet.com
IMAGE_NAME: ehr/bma-ehr-org-service
DEPLOY_HOST: frappet.com
# COMPOSE_PATH: /home/frappet/docker/bma-ehr
COMPOSE_PATH: /home/frappet/docker/bma/bma-ehr-org
jobs:
# act workflow_dispatch -W .github/workflows/release.yaml --input IMAGE_VER=latest -s DOCKER_USER=admin -s DOCKER_PASS=FPTadmin2357 -s SSH_PASSWORD=FPTadmin2357
release-test:
release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
@ -67,21 +67,40 @@ jobs:
docker compose pull
docker compose up -d
echo "${{ steps.gen_ver.outputs.image_ver }}"> success
- uses: snow-actions/line-notify@v1.1.0
- name: Notify Discord Success
if: success()
with:
access_token: ${{ secrets.TOKEN_LINE }}
message: |
-Success✅✅✅
Image: ${{env.IMAGE_NAME}}
Version: ${{ steps.gen_ver.outputs.IMAGE_VER }}
By: ${{github.actor}}
- uses: snow-actions/line-notify@v1.1.0
run: |
curl -H "Content-Type: application/json" \
-X POST \
-d '{
"embeds": [{
"title": "✅ Deployment Success!",
"description": "**Details:**\n- Image: `${{env.IMAGE_NAME}}`\n- Version: `${{ steps.gen_ver.outputs.image_ver }}`\n- Deployed by: `${{github.actor}}`",
"color": 3066993,
"footer": {
"text": "Release Notification",
"icon_url": "https://example.com/success-icon.png"
},
"timestamp": "'$(date -u +%Y-%m-%dT%H:%M:%SZ)'"
}]
}' \
${{ secrets.DISCORD_WEBHOOK }}
- name: Notify Discord Failure
if: failure()
with:
access_token: ${{ secrets.TOKEN_LINE }}
message: |
-Failure❌❌❌
Image: ${{env.IMAGE_NAME}}
Version: ${{ steps.gen_ver.outputs.IMAGE_VER }}
By: ${{github.actor}}
run: |
curl -H "Content-Type: application/json" \
-X POST \
-d '{
"embeds": [{
"title": "❌ Deployment Failed!",
"description": "**Details:**\n- Image: `${{env.IMAGE_NAME}}`\n- Version: `${{ steps.gen_ver.outputs.image_ver }}`\n- Attempted by: `${{github.actor}}`",
"color": 15158332,
"footer": {
"text": "Release Notification",
"icon_url": "https://example.com/failure-icon.png"
},
"timestamp": "'$(date -u +%Y-%m-%dT%H:%M:%SZ)'"
}]
}' \
${{ secrets.DISCORD_WEBHOOK }}

View file

@ -128,4 +128,56 @@ export class ApiKeyController extends Controller {
});
return new HttpSuccess(apiName);
}
/**
* API Api Key
*
* @summary Api Key (ADMIN)
*
*/
@Post("history")
async getHistory(
@Body()
requestBody: {
startDate: Date;
endDate: Date;
apiNameId: string | null;
},
@Request() request: RequestWithUser,
) {
if (requestBody.apiNameId) {
const apiName = await this.apiNameRepository.findOne({
where: { id: requestBody.apiNameId },
});
if (!apiName)
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบรายการ Web Service นี้ในระบบ");
}
const apiHistory = await AppDataSource.getRepository(ApiHistory)
.createQueryBuilder("apiHistory")
.leftJoinAndSelect("apiHistory.apiKey", "apiKey")
.leftJoinAndSelect("apiHistory.apiName", "apiName")
.andWhere(requestBody.apiNameId ? `apiHistory.apiNameId = :apiNameId` : "1=1", {
apiNameId: requestBody.apiNameId,
})
.andWhere(
`apiHistory.createdAt >= DATE(:startDate) AND apiHistory.createdAt <= DATE(:endDate)`,
{
startDate: new Date(requestBody.startDate),
endDate: new Date(
requestBody.endDate.setDate(new Date(requestBody.endDate).getDate() + 1),
),
},
)
.orderBy("apiHistory.createdAt", "DESC")
.getMany();
const result = apiHistory.map((x) => ({
id: x.id,
apiName: x.apiName.name,
apiKey: x.apiKey.name,
createdAt: x.createdAt,
ipApi: x.ipApi,
}));
return new HttpSuccess(result);
}
}

View file

@ -1622,12 +1622,16 @@ export class CommandController extends Controller {
remarkVertical?: string | null;
remarkHorizontal?: string | null;
rootId?: string | null;
amount?: Double | null;
amountSpecial?: Double | null;
positionSalaryAmount?: Double | null;
mouthSalaryAmount?: Double | null;
}[];
},
@Request() request: RequestWithUser,
) {
let command = new Command();
let commandCode = null;
let commandCode:string = "";
let null_: any = null;
if (
requestBody.commandId != undefined &&
@ -1707,30 +1711,40 @@ export class CommandController extends Controller {
commandRecive = Object.assign(new CommandRecive(), item);
commandRecive.order = order;
let salaryData = null_;
if (item.profileId) {
salaryData = await this.profileRepository.findOne({
where: {
id: item.profileId,
},
});
let null_: any = 0;
if (!salaryData) {
salaryData = await this.profileEmployeeRepository.findOne({
const excludedCommands = ["C-PM-33", "C-PM-34", "C-PM-35", "C-PM-36", "C-PM-37"];
if (!excludedCommands.includes(commandCode)) {
if (item.profileId) {
salaryData = await this.profileRepository.findOne({
where: {
id: item.profileId,
},
});
let null_: any = 0;
if (!salaryData) {
salaryData = await this.profileEmployeeRepository.findOne({
where: {
id: item.profileId,
},
});
}
commandRecive.amount = salaryData ? salaryData.amount : null_;
commandRecive.positionSalaryAmount = salaryData
? salaryData.positionSalaryAmount
: null_;
commandRecive.mouthSalaryAmount = salaryData ? salaryData.mouthSalaryAmount : null_;
} else {
commandRecive.amount = null_;
commandRecive.positionSalaryAmount = null_;
commandRecive.mouthSalaryAmount = null_;
}
commandRecive.amount = salaryData ? salaryData.amount : null_;
commandRecive.positionSalaryAmount = salaryData
? salaryData.positionSalaryAmount
: null_;
commandRecive.mouthSalaryAmount = salaryData ? salaryData.mouthSalaryAmount : null_;
} else {
commandRecive.amount = null_;
commandRecive.positionSalaryAmount = null_;
commandRecive.mouthSalaryAmount = null_;
commandRecive.amount = item.amount ?? null_;
commandRecive.amountSpecial = item.amountSpecial ?? null_;
commandRecive.positionSalaryAmount = item.positionSalaryAmount ?? null_;
commandRecive.mouthSalaryAmount = item.mouthSalaryAmount ?? null_;
}
commandRecive.remarkVertical =
item.remarkVertical == null ? null_ : item.remarkVertical;
commandRecive.remarkHorizontal =
@ -1898,6 +1912,7 @@ export class CommandController extends Controller {
profileId: string;
date?: Date | null;
amount?: Double | null;
amountSpecial?: Double | null;
positionSalaryAmount?: Double | null;
mouthSalaryAmount?: Double | null;
posNo: string | null;
@ -1917,7 +1932,7 @@ export class CommandController extends Controller {
) {
await Promise.all(
body.data.map(async (item) => {
const profile = await this.profileRepository.findOneBy({ id: item.profileId });
const profile:any = await this.profileRepository.findOneBy({ id: item.profileId });
if (!profile) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลทะเบียนประวัตินี้");
}
@ -2002,6 +2017,8 @@ export class CommandController extends Controller {
profile.posLevelId = positionNew.posLevelId;
profile.posTypeId = positionNew.posTypeId;
profile.position = positionNew.positionName;
profile.amount = item.amount ?? null;
profile.amountSpecial = item.amountSpecial ?? null;
await this.profileRepository.save(profile);
await this.positionRepository.save(positionNew);
}
@ -2020,6 +2037,7 @@ export class CommandController extends Controller {
profileId: string;
date?: Date | null;
amount?: Double | null;
amountSpecial?: Double | null;
positionSalaryAmount?: Double | null;
mouthSalaryAmount?: Double | null;
posNo: string | null;
@ -2036,7 +2054,7 @@ export class CommandController extends Controller {
) {
await Promise.all(
body.data.map(async (item) => {
const profile = await this.profileEmployeeRepository.findOneBy({ id: item.profileId });
const profile:any = await this.profileEmployeeRepository.findOneBy({ id: item.profileId });
if (!profile) {
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
}
@ -2131,7 +2149,8 @@ export class CommandController extends Controller {
profile.position = positionNew.positionName;
profile.employeeOc = posMaster?.orgRoot?.orgRootName ?? null;
profile.positionEmployeePositionId = positionNew.positionName;
profile.amount = item.amount ?? null;
profile.amountSpecial = item.amountSpecial ?? null;
await this.profileEmployeeRepository.save(profile);
await this.employeePositionRepository.save(positionNew);
}
@ -2150,6 +2169,7 @@ export class CommandController extends Controller {
profileId: string;
date?: Date | null;
amount?: Double | null;
amountSpecial?: Double | null;
positionSalaryAmount?: Double | null;
mouthSalaryAmount?: Double | null;
posNo: string | null;
@ -2240,8 +2260,8 @@ export class CommandController extends Controller {
firstName: profile.firstName,
lastName: profile.lastName,
});
// กรณี Keycloak ไม่ถูกลบ ให้ลบซ้ำอีกรอบแล้วสร้างใหม่
if (profile.keycloak != null && userKeycloakId && userKeycloakId.error === "User exists with same username") {
// กรณี Keycloak ไม่ถูกลบ ให้ลบซ้ำอีกรอบแล้วสร้างใหม่ และหากยังไม่สามารถลบได้ให้แสดง Error
if (profile.keycloak != null && userKeycloakId && userKeycloakId.errorMessage === "User exists with same username") {
const delUserKeycloak = await deleteUser(profile.keycloak);
if(delUserKeycloak) {
userKeycloakId = await createUser(profile.citizenId, profile.citizenId, {
@ -2249,6 +2269,9 @@ export class CommandController extends Controller {
lastName: profile.lastName,
});
}
else {
throw new HttpError(HttpStatus.BAD_REQUEST, "พบข้อผิดพลาด ไม่สามารถจัดการผู้ใช้งานได้");
}
}
const list = await getRoles();
let result = false;
@ -2263,6 +2286,8 @@ export class CommandController extends Controller {
})),
);
}
profile.amount = item.amount ?? _null;
profile.amountSpecial = item.amountSpecial ?? _null;
profile.isActive = true;
profile.keycloak = typeof userKeycloakId === "string" ? userKeycloakId : "";
profile.roleKeycloaks = result && roleKeycloak ? [roleKeycloak] : [];
@ -2380,6 +2405,7 @@ export class CommandController extends Controller {
profileId: string;
date?: Date | null;
amount?: Double | null;
amountSpecial?: Double | null;
positionSalaryAmount?: Double | null;
mouthSalaryAmount?: Double | null;
posNo: string | null;
@ -2400,7 +2426,7 @@ export class CommandController extends Controller {
) {
await Promise.all(
body.data.map(async (item) => {
const profile = await this.profileRepository.findOne({
const profile:any = await this.profileRepository.findOne({
where: { id: item.profileId },
relations: ["roleKeycloaks"],
});
@ -2443,6 +2469,8 @@ export class CommandController extends Controller {
profile.posLevelId = _null;
profile.leaveReason = item.leaveReason ?? _null;
profile.dateLeave = item.dateLeave ?? _null;
profile.amount = item.amount ?? _null;
profile.amountSpecial = item.amountSpecial ?? _null;
await this.profileRepository.save(profile, { data: req });
}
Object.assign(data, { ...item, ...meta });
@ -3084,6 +3112,8 @@ export class CommandController extends Controller {
profile.roleKeycloaks = result && roleKeycloak ? [roleKeycloak] : [];
profile.email = item.bodyProfile.email;
profile.dateStart = item.bodyProfile.dateStart;
profile.amount = item.bodyProfile.amount ?? null;
profile.amountSpecial = item.bodyProfile.amountSpecial ?? null;
await this.profileRepository.save(profile);
setLogDataDiff(req, { before, after: profile });
}
@ -3127,13 +3157,17 @@ export class CommandController extends Controller {
where: { profileId: profile.id },
order: { order: "DESC" },
});
const profileSal = new ProfileSalary();
const profileSal: any = new ProfileSalary();
Object.assign(profileSal, { ...item.bodySalarys, ...meta });
const salaryHistory = new ProfileSalaryHistory();
Object.assign(salaryHistory, { ...profileSal, id: undefined });
profileSal.order = dest_item == null ? 1 : dest_item.order + 1;
profileSal.profileId = profile.id;
profileSal.dateGovernment = meta.createdAt;
profileSal.amount = item.bodySalarys.amount ?? null;
profileSal.amountSpecial = item.bodySalarys.amountSpecial ?? null;
profileSal.positionSalaryAmount = item.bodySalarys.positionSalaryAmount ?? null;
profileSal.mouthSalaryAmount = item.bodySalarys.mouthSalaryAmount ?? null;
await this.salaryRepo.save(profileSal, { data: req });
setLogDataDiff(req, { before, after: profileSal });
salaryHistory.profileSalaryId = profileSal.id;
@ -3281,6 +3315,7 @@ export class CommandController extends Controller {
commandYear: number;
templateDoc: string | null;
amount: Double | null;
amountSpecial: Double | null;
positionSalaryAmount: Double | null;
mouthSalaryAmount: Double | null;
}[];
@ -3310,6 +3345,7 @@ export class CommandController extends Controller {
profileEmployeeId: profile.id,
date: new Date(),
amount: item.amount,
amountSpecial: item.amountSpecial,
commandId: item.commandId,
positionSalaryAmount: item.positionSalaryAmount,
mouthSalaryAmount: item.mouthSalaryAmount,
@ -3428,9 +3464,8 @@ export class CommandController extends Controller {
const _null: any = null;
profile.employeeWage = item.amount == null ? _null : item.amount.toString();
profile.dateStart = new Date();
// profile.amount = item.amount == null ? _null : item.amount.toString(); //เผื่อไว้
// profile.positionSalaryAmount = item.positionSalaryAmount == null ? _null : item.positionSalaryAmount.toString();
// profile.mouthSalaryAmount = item.mouthSalaryAmount == null ? _null : item.mouthSalaryAmount.toString();
profile.amount = item.amount == null ? _null : item.amount;
profile.amountSpecial = item.amountSpecial == null ? _null : item.amountSpecial;
await this.profileEmployeeRepository.save(profile);
await this.employeePositionRepository.save(positionNew);

View file

@ -163,10 +163,11 @@ export class OrganizationUnauthorizeController extends Controller {
: item.positions?.find((position) => position.positionIsSelected == true)?.posExecutive
.posExecutiveName;
const amount =
item.current_holder == null || item.current_holder.profileSalary.length == 0
? null
: item.current_holder.profileSalary.sort((a: any, b: any) => b.date - a.date)[0].amount;
// const amount =
// item.current_holder == null || item.current_holder.profileSalary.length == 0
// ? null
// : item.current_holder.profileSalary.sort((a: any, b: any) => b.date - a.date)[0].amount;
const amount = item.current_holder?item.current_holder.amount:null;
let datePeriodStart = new Date(
`${new Date().getFullYear()}-${String(new Date().getMonth() + 1).padStart(2, "0")}-${String(new Date().getDate() + 1).padStart(2, "0")}T00:00:00.000Z`,
);
@ -380,10 +381,11 @@ export class OrganizationUnauthorizeController extends Controller {
orgShortName = item.orgChild4?.orgChild4ShortName;
}
const amount =
item.current_holder == null || item.current_holder.profileSalary.length == 0
? null
: item.current_holder.profileSalary.sort((a: any, b: any) => b.date - a.date)[0].amount;
// const amount =
// item.current_holder == null || item.current_holder.profileSalary.length == 0
// ? null
// : item.current_holder.profileSalary.sort((a: any, b: any) => b.date - a.date)[0].amount;
const amount = item.current_holder?item.current_holder.amount:null;
let datePeriodStart = new Date(
`${new Date().getFullYear()}-${String(new Date().getMonth() + 1).padStart(2, "0")}-${String(new Date().getDate() + 1).padStart(2, "0")}T00:00:00.000Z`,
);

View file

@ -7247,10 +7247,11 @@ export class ProfileController extends Controller {
: item.positions?.find((position) => position.positionIsSelected == true)?.posExecutive
.posExecutiveName;
const amount =
item.current_holder == null || item.current_holder.profileSalary.length == 0
? null
: item.current_holder.profileSalary.sort((a: any, b: any) => b.date - a.date)[0].amount;
// const amount =
// item.current_holder == null || item.current_holder.profileSalary.length == 0
// ? null
// : item.current_holder.profileSalary.sort((a: any, b: any) => b.date - a.date)[0].amount;
const amount = item.current_holder?item.current_holder.amount:null;
let datePeriodStart = new Date(
`${new Date().getFullYear()}-${String(new Date().getMonth() + 1).padStart(2, "0")}-${String(new Date().getDate() + 1).padStart(2, "0")}T00:00:00.000Z`,
);

View file

@ -2950,10 +2950,11 @@ export class ProfileEmployeeController extends Controller {
orgShortName = item.orgChild4?.orgChild4ShortName;
}
const amount =
item.current_holder == null || item.current_holder.profileSalary.length == 0
? null
: item.current_holder.profileSalary.sort((a: any, b: any) => b.date - a.date)[0].amount;
// const amount =
// item.current_holder == null || item.current_holder.profileSalary.length == 0
// ? null
// : item.current_holder.profileSalary.sort((a: any, b: any) => b.date - a.date)[0].amount;
const amount = item.current_holder?item.current_holder.amount:null;
let datePeriodStart = new Date(
`${new Date().getFullYear()}-${String(new Date().getMonth() + 1).padStart(2, "0")}-${String(new Date().getDate() + 1).padStart(2, "0")}T00:00:00.000Z`,
);

View file

@ -2699,10 +2699,11 @@ export class ProfileEmployeeTempController extends Controller {
orgShortName = item.orgChild4?.orgChild4ShortName;
}
const amount =
item.current_holder == null || item.current_holder.profileSalary.length == 0
? null
: item.current_holder.profileSalary.sort((a: any, b: any) => b.date - a.date)[0].amount;
// const amount =
// item.current_holder == null || item.current_holder.profileSalary.length == 0
// ? null
// : item.current_holder.profileSalary.sort((a: any, b: any) => b.date - a.date)[0].amount;
const amount = item.current_holder?item.current_holder.amount:null;
let datePeriodStart = new Date(
`${new Date().getFullYear()}-${String(new Date().getMonth() + 1).padStart(2, "0")}-${String(new Date().getDate() + 1).padStart(2, "0")}T00:00:00.000Z`,
);

View file

@ -122,7 +122,7 @@ export class ProfileSalaryController extends Controller {
createdAt: new Date(),
lastUpdatedAt: new Date(),
};
const _null:any = null;
Object.assign(data, { ...body, ...meta });
const history = new ProfileSalaryHistory();
Object.assign(history, { ...data, id: undefined });
@ -131,6 +131,11 @@ export class ProfileSalaryController extends Controller {
history.profileSalaryId = data.id;
await this.salaryHistoryRepo.save(history, { data: req });
profile.amount = body?.amount??_null;
profile.positionSalaryAmount = body?.positionSalaryAmount??_null;
profile.mouthSalaryAmount = body.mouthSalaryAmount??_null;
await this.profileRepo.save(profile, { data: req });
return new HttpSuccess();
}
@ -173,6 +178,7 @@ export class ProfileSalaryController extends Controller {
let null_:any = null;
profile.amount = body.amount ?? null_;
profile.amountSpecial = body.amountSpecial ?? null_;
profile.positionSalaryAmount = body.positionSalaryAmount ?? null_;
profile.mouthSalaryAmount = body.mouthSalaryAmount ?? null_;
await this.profileRepo.save(profile);

View file

@ -137,12 +137,17 @@ export class ProfileSalaryEmployeeController extends Controller {
Object.assign(data, { ...body, ...meta });
const history = new ProfileSalaryHistory();
Object.assign(history, { ...data, id: undefined });
const _null:any = null;
await this.salaryRepo.save(data, { data: req });
setLogDataDiff(req, { before, after: data });
history.profileSalaryId = data.id;
await this.salaryHistoryRepo.save(history, { data: req });
profile.amount = body?.amount??_null;
profile.positionSalaryAmount = body?.positionSalaryAmount??_null;
profile.mouthSalaryAmount = body.mouthSalaryAmount??_null;
await this.profileRepo.save(profile, { data: req });
return new HttpSuccess();
}
@ -189,6 +194,7 @@ export class ProfileSalaryEmployeeController extends Controller {
let null_:any = null;
profile.amount = body.amount ?? null_;
profile.amountSpecial = body.amountSpecial ?? null_;
profile.positionSalaryAmount = body.positionSalaryAmount ?? null_;
profile.mouthSalaryAmount = body.mouthSalaryAmount ?? null_;
await this.profileRepo.save(profile);

View file

@ -41,7 +41,7 @@ export const AppDataSource = new DataSource({
password: process.env.DB_PASSWORD,
connectorPackage: "mysql2",
synchronize: false,
logging: ["query", "error"],
logging: true,
entities:
process.env.NODE_ENV !== "production"
? ["src/entities/**/*.ts"]

View file

@ -1,6 +1,7 @@
import { Entity, Column, ManyToOne, JoinColumn } from "typeorm";
import { EntityBase } from "./base/Base";
import { ApiKey } from "./ApiKey";
import { ApiName } from "./ApiName";
@Entity("apiHistory")
export class ApiHistory extends EntityBase {
@ -63,4 +64,16 @@ export class ApiHistory extends EntityBase {
@ManyToOne(() => ApiKey, (apiKey) => apiKey.apiHistorys)
@JoinColumn({ name: "apiKeyId" })
apiKey: ApiKey;
@Column({
nullable: true,
length: 40,
comment: "คีย์นอก(FK)ของตาราง ApiName",
default: null,
})
apiNameId: string;
@ManyToOne(() => ApiName, (apiName) => apiName.apiHistorys)
@JoinColumn({ name: "apiNameId" })
apiName: ApiName;
}

View file

@ -1,6 +1,7 @@
import { Entity, Column, ManyToMany, JoinTable } from "typeorm";
import { Entity, Column, ManyToMany, JoinTable, OneToMany } from "typeorm";
import { EntityBase } from "./base/Base";
import { ApiKey } from "./ApiKey";
import { ApiHistory } from "./ApiHistory";
@Entity("apiName")
export class ApiName extends EntityBase {
@ -31,4 +32,7 @@ export class ApiName extends EntityBase {
@ManyToMany(() => ApiKey, (apiKey) => apiKey.apiNames)
@JoinTable()
apiKeys: ApiKey[];
@OneToMany(() => ApiHistory, (v) => v.apiName)
apiHistorys: ApiHistory[];
}

View file

@ -67,6 +67,14 @@ export class CommandRecive extends EntityBase {
})
amount: Double;
@Column({
comment: "เงินพิเศษ",
default: 0,
nullable: true,
type: "double",
})
amountSpecial: Double;
@Column({
comment: "เงินประจำตำแหน่ง",
default: 0,

View file

@ -80,6 +80,12 @@ export class CommandType extends EntityBase {
})
isAttachment: boolean;
@Column({
comment: "สถานะแก้ไขเงินเดือน",
default: true,
})
isSalary: boolean;
@Column({
nullable: true,
comment: "คำอธิบาย",
@ -119,6 +125,9 @@ export class CreateCommandType {
@Column()
isAttachment: boolean;
@Column()
isSalary?: boolean | null;
}
export type UpdateCommandType = Partial<CreateCommandType>;

View file

@ -339,6 +339,14 @@ export class Profile extends EntityBase {
})
amount: Double;
@Column({
comment: "เงินพิเศษ",
default: 0,
nullable: true,
type: "double",
})
amountSpecial: Double;
@Column({
comment: "เงินประจำตำแหน่ง",
default: 0,
@ -778,6 +786,8 @@ export class CreateProfileAllFields {
currentDistrictId: string | null;
currentSubDistrictId: string | null;
currentZipCode: string | null;
amount?: Double | null;
amountSpecial?: Double | null;
}
export type UpdateProfile = {

View file

@ -592,6 +592,14 @@ export class ProfileEmployee extends EntityBase {
})
amount: Double;
@Column({
comment: "เงินพิเศษ",
default: 0,
nullable: true,
type: "double",
})
amountSpecial: Double;
@Column({
comment: "เงินประจำตำแหน่ง",
default: 0,

View file

@ -95,6 +95,14 @@ export class ProfileSalary extends EntityBase {
})
amount: Double;
@Column({
comment: "เงินพิเศษ",
default: 0,
nullable: true,
type: "double",
})
amountSpecial: Double;
@Column({
comment: "เงินประจำตำแหน่ง",
default: 0,
@ -184,6 +192,7 @@ export class CreateProfileSalary {
profileId: string;
date?: Date | null;
amount?: Double | null;
amountSpecial?: Double | null;
positionSalaryAmount?: Double | null;
mouthSalaryAmount?: Double | null;
posNo: string | null;
@ -204,6 +213,7 @@ export class CreateProfileSalaryEmployee {
profileEmployeeId: string | null;
date?: Date | null;
amount?: Double | null;
amountSpecial?: Double | null;
commandId?: string | null;
positionSalaryAmount?: Double | null;
mouthSalaryAmount?: Double | null;
@ -221,6 +231,7 @@ export class CreateProfileSalaryEmployee {
export class UpdateProfileSalaryEmployee {
date?: Date | null;
amount?: Double | null;
amountSpecial?: Double | null;
positionSalaryAmount?: Double | null;
mouthSalaryAmount?: Double | null;
posNo: string | null;
@ -237,6 +248,7 @@ export class UpdateProfileSalaryEmployee {
export type UpdateProfileSalary = {
date?: Date | null;
amount?: Double | null;
amountSpecial?: Double | null;
positionSalaryAmount?: Double | null;
mouthSalaryAmount?: Double | null;
posNo?: string | null;

View file

@ -83,6 +83,14 @@ export class ProfileSalaryHistory extends EntityBase {
})
amount: Double;
@Column({
comment: "เงินพิเศษ",
default: 0,
nullable: true,
type: "double",
})
amountSpecial: Double;
@Column({
comment: "เงินประจำตำแหน่ง",
default: 0,
@ -149,6 +157,7 @@ export class CreateProfileSalaryHistory {
profileId: string;
date?: Date | null;
amount?: Double | null;
amountSpecial?: Double | null;
positionSalaryAmount?: Double | null;
mouthSalaryAmount?: Double | null;
posNo: string | null;
@ -165,6 +174,7 @@ export class CreateProfileSalaryHistory {
export class UpdateProfileSalaryHistory {
date?: Date | null;
amount?: Double | null;
amountSpecial?: Double | null;
positionSalaryAmount?: Double | null;
mouthSalaryAmount?: Double | null;
posNo?: string | null;

View file

@ -0,0 +1,16 @@
import { MigrationInterface, QueryRunner } from "typeorm";
export class UpdateKeyapiAddKeynameId1733318856709 implements MigrationInterface {
name = 'UpdateKeyapiAddKeynameId1733318856709'
public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE \`apiHistory\` ADD \`apiNameId\` varchar(40) NULL COMMENT 'คีย์นอก(FK)ของตาราง ApiName'`);
await queryRunner.query(`ALTER TABLE \`apiHistory\` ADD CONSTRAINT \`FK_0b7ae98d4f342bf920339ada78b\` FOREIGN KEY (\`apiNameId\`) REFERENCES \`apiName\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
}
public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE \`apiHistory\` DROP FOREIGN KEY \`FK_0b7ae98d4f342bf920339ada78b\``);
await queryRunner.query(`ALTER TABLE \`apiHistory\` DROP COLUMN \`apiNameId\``);
}
}

View file

@ -0,0 +1,14 @@
import { MigrationInterface, QueryRunner } from "typeorm";
export class UpdateTableProfileSalaryAddAmountSpecial1733463321778 implements MigrationInterface {
name = 'UpdateTableProfileSalaryAddAmountSpecial1733463321778'
public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE \`profileSalary\` ADD \`amountSpecial\` double NULL COMMENT 'เงินพิเศษ' DEFAULT '0'`);
}
public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE \`profileSalary\` DROP COLUMN \`amountSpecial\``);
}
}

View file

@ -0,0 +1,22 @@
import { MigrationInterface, QueryRunner } from "typeorm";
export class Update3table_addAmountSpecial1733471256767 implements MigrationInterface {
name = 'Update3table_addAmountSpecial1733471256767'
public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE \`profileEmployee\` ADD \`amountSpecial\` double NULL COMMENT 'เงินพิเศษ' DEFAULT '0'`);
await queryRunner.query(`ALTER TABLE \`profileEmployeeHistory\` ADD \`amountSpecial\` double NULL COMMENT 'เงินพิเศษ' DEFAULT '0'`);
await queryRunner.query(`ALTER TABLE \`commandRecive\` ADD \`amountSpecial\` double NULL COMMENT 'เงินพิเศษ' DEFAULT '0'`);
await queryRunner.query(`ALTER TABLE \`profile\` ADD \`amountSpecial\` double NULL COMMENT 'เงินพิเศษ' DEFAULT '0'`);
await queryRunner.query(`ALTER TABLE \`profileHistory\` ADD \`amountSpecial\` double NULL COMMENT 'เงินพิเศษ' DEFAULT '0'`);
}
public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE \`profileHistory\` DROP COLUMN \`amountSpecial\``);
await queryRunner.query(`ALTER TABLE \`profile\` DROP COLUMN \`amountSpecial\``);
await queryRunner.query(`ALTER TABLE \`commandRecive\` DROP COLUMN \`amountSpecial\``);
await queryRunner.query(`ALTER TABLE \`profileEmployeeHistory\` DROP COLUMN \`amountSpecial\``);
await queryRunner.query(`ALTER TABLE \`profileEmployee\` DROP COLUMN \`amountSpecial\``);
}
}

View file

@ -0,0 +1,14 @@
import { MigrationInterface, QueryRunner } from "typeorm";
export class UpdateTableCommandTypeAddIsSalary1733482389096 implements MigrationInterface {
name = 'UpdateTableCommandTypeAddIsSalary1733482389096'
public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE \`commandType\` ADD \`isSalary\` tinyint NOT NULL COMMENT 'สถานะแก้ไขเงินเดือน' DEFAULT 1`);
}
public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE \`commandType\` DROP COLUMN \`isSalary\``);
}
}

View file

@ -0,0 +1,14 @@
import { MigrationInterface, QueryRunner } from "typeorm";
export class UpdateTableAddField1733798795372 implements MigrationInterface {
name = 'UpdateTableAddField1733798795372'
public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE \`profileSalaryHistory\` ADD \`amountSpecial\` double NULL COMMENT 'เงินพิเศษ' DEFAULT '0'`);
}
public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE \`profileSalaryHistory\` DROP COLUMN \`amountSpecial\``);
}
}

View file

@ -98,6 +98,7 @@ async function handler(msg: amqp.ConsumeMessage): Promise<boolean> {
commandId: command.id,
templateDoc: command.positionDetail,
amount: x.amount,
amountSpecial: x.amountSpecial,
positionSalaryAmount: x.positionSalaryAmount,
mouthSalaryAmount: x.mouthSalaryAmount,
})),