2024-02-19 15:23:03 +07:00
import {
Controller ,
Get ,
Post ,
Route ,
Security ,
Tags ,
Body ,
Path ,
Request ,
SuccessResponse ,
Response ,
} from "tsoa" ;
import { AppDataSource } from "../database/data-source" ;
import HttpSuccess from "../interfaces/http-success" ;
import HttpStatusCode from "../interfaces/http-status" ;
import HttpError from "../interfaces/http-error" ;
2024-10-24 10:48:41 +07:00
import { In , Not , IsNull , MoreThan , Double , Brackets } from "typeorm" ;
2024-02-19 15:23:03 +07:00
import { Salarys } from "../entities/Salarys" ;
import { SalaryRanks } from "../entities/SalaryRanks" ;
import { PosType } from "../entities/PosType" ;
import { PosLevel } from "../entities/PosLevel" ;
2024-03-18 13:07:09 +07:00
import { SalaryPeriod } from "../entities/SalaryPeriod" ;
import { SalaryOrg } from "../entities/SalaryOrg" ;
import { SalaryProfile } from "../entities/SalaryProfile" ;
2024-03-18 17:30:54 +07:00
import Extension from "../interfaces/extension" ;
import { SalaryEmployee } from "../entities/SalaryEmployee" ;
import { SalaryRankEmployee } from "../entities/SalaryRankEmployee" ;
2024-03-21 15:29:39 +07:00
import { EmployeePosType } from "../entities/EmployeePosType" ;
import { EmployeePosLevel } from "../entities/EmployeePosLevel" ;
import { SalaryOrgEmployee } from "../entities/SalaryOrgEmployee" ;
import { SalaryProfileEmployee } from "../entities/SalaryProfileEmployee" ;
2024-09-03 15:18:23 +07:00
import { setLogDataDiff } from "../interfaces/utils" ;
2024-08-23 14:10:34 +07:00
import { RequestWithUser } from "../middlewares/user" ;
2025-04-28 10:48:58 +07:00
import permission from "../interfaces/permission" ;
2024-08-23 14:10:34 +07:00
2024-04-26 10:03:29 +07:00
import CallAPI from "../interfaces/call-api" ;
#1002,#1004,#1006,#1008,#1013,#1015,#1024,#1028,#1036,#1038,#1044,#1047,#1050
2025-01-27 17:14:13 +07:00
import { isNotEmittedStatement } from "typescript" ;
2025-05-16 17:21:23 +07:00
import { SalaryFormulaEmployee } from "../entities/SalaryFormulaEmployee" ;
2024-02-19 15:23:03 +07:00
@Route ( "api/v1/salary/report" )
@Tags ( "Report" )
2025-05-19 11:39:09 +07:00
@Security ( "bearerAuth" )
2024-02-19 15:23:03 +07:00
@Response (
HttpStatusCode . INTERNAL_SERVER_ERROR ,
"เกิดข้อผิดพลาด ไม่สามารถแสดงรายการได้ กรุณาลองใหม่ในภายหลัง" ,
)
@SuccessResponse ( HttpStatusCode . OK , "สำเร็จ" )
export class ReportController extends Controller {
2024-03-21 15:29:39 +07:00
private salaryPeriodRepository = AppDataSource . getRepository ( SalaryPeriod ) ;
2024-02-19 15:23:03 +07:00
private salaryRepository = AppDataSource . getRepository ( Salarys ) ;
2024-03-18 17:30:54 +07:00
private salaryEmployeeRepository = AppDataSource . getRepository ( SalaryEmployee ) ;
2024-02-19 15:23:03 +07:00
private salaryRankRepository = AppDataSource . getRepository ( SalaryRanks ) ;
2024-03-18 17:30:54 +07:00
private salaryEmployeeRankRepository = AppDataSource . getRepository ( SalaryRankEmployee ) ;
2024-02-19 15:23:03 +07:00
private poTypeRepository = AppDataSource . getRepository ( PosType ) ;
private posLevelRepository = AppDataSource . getRepository ( PosLevel ) ;
2024-03-18 13:07:09 +07:00
private salaryOrgRepository = AppDataSource . getRepository ( SalaryOrg ) ;
2024-03-21 15:29:39 +07:00
private salaryOrgEmployeeRepository = AppDataSource . getRepository ( SalaryOrgEmployee ) ;
2024-03-18 13:07:09 +07:00
private salaryProfileRepository = AppDataSource . getRepository ( SalaryProfile ) ;
2024-03-21 15:29:39 +07:00
private salaryProfileEmployeeRepository = AppDataSource . getRepository ( SalaryProfileEmployee ) ;
2025-05-16 17:21:23 +07:00
private salaryFormulaEmployeeRepository = AppDataSource . getRepository ( SalaryFormulaEmployee ) ;
2024-02-19 15:23:03 +07:00
/ * *
2024-03-18 13:50:24 +07:00
* API ร า ย ง า น อ ั ต ร า เ ง ิ น เ ด ื อ น
2024-02-19 15:23:03 +07:00
*
2024-03-18 13:50:24 +07:00
* @summary ร า ย ง า น อ ั ต ร า เ ง ิ น เ ด ื อ น
2024-02-19 15:23:03 +07:00
*
* @param { string } id Guid , * Id ผ ั ง เ ง ิ น เ ด ื อ น
* /
2024-03-18 13:50:24 +07:00
@Get ( "{id}" )
2024-02-19 15:23:03 +07:00
async SalaryReport ( @Path ( ) id : string ) {
const salarys = await this . salaryRepository . findOne ( {
2024-03-18 17:30:54 +07:00
where : { id : id } ,
2024-02-19 15:23:03 +07:00
} ) ;
if ( ! salarys ) {
2024-02-28 13:35:08 +07:00
throw new HttpError ( HttpStatusCode . NOT_FOUND , "ไม่พบข้อมูลผังเงินเดือนนี้" ) ;
2024-02-19 15:23:03 +07:00
}
const posType = await this . poTypeRepository . findOne ( {
where : { id : salarys.posTypeId } ,
} ) ;
const posLevel = await this . posLevelRepository . findOne ( {
where : { id : salarys.posLevelId } ,
} ) ;
const salaryRank = await this . salaryRankRepository . find ( {
where : {
salaryId : salarys.id ,
} ,
select : [
"id" ,
"salary" ,
"salaryHalf" ,
"salaryHalfSpecial" ,
"salaryFull" ,
"salaryFullSpecial" ,
"salaryFullHalf" ,
"salaryFullHalfSpecial" ,
] ,
order : {
salary : "DESC" ,
salaryHalf : "DESC" ,
2024-03-18 17:30:54 +07:00
} ,
2024-02-19 15:23:03 +07:00
} ) ;
2024-09-03 15:18:23 +07:00
const mapSalaryRank = salaryRank . map ( ( item ) = > ( {
2024-02-19 15:23:03 +07:00
// no: index + 1,
// id: item.id,
2024-03-18 17:30:54 +07:00
salary : item.salary == null || item . salary == 0 ? "" : item . salary . toLocaleString ( ) ,
salaryHalf :
item . salaryHalf == null || item . salaryHalf == 0
? ""
: item . salaryHalf . toLocaleString ( ) +
( item . salaryHalfSpecial == null || item . salaryHalfSpecial == 0
? ""
: " (" + item . salaryHalfSpecial . toLocaleString ( ) + "*)" ) ,
salaryFull :
item . salaryFull == null || item . salaryFull == 0
? ""
: item . salaryFull . toLocaleString ( ) +
( item . salaryFullSpecial == null || item . salaryFullSpecial == 0
? ""
: " (" + item . salaryFullSpecial . toLocaleString ( ) + "*)" ) ,
salaryFullHalf :
item . salaryFullHalf == null || item . salaryFullHalf == 0
? ""
: item . salaryFullHalf . toLocaleString ( ) +
( item . salaryFullHalfSpecial == null || item . salaryFullHalfSpecial == 0
? ""
: " (" + item . salaryFullHalfSpecial . toLocaleString ( ) + "*)" ) ,
2024-02-19 15:23:03 +07:00
} ) ) ;
2024-03-18 17:30:54 +07:00
return new HttpSuccess ( {
template : "SalaryRank" ,
reportName : "SalaryRank" ,
data : {
2024-07-03 00:36:33 +07:00
nameType : "ผังข้าราชการกรุงเทพมหานครสามัญ" ,
2024-02-19 15:31:07 +07:00
level : posLevel?.posLevelName == null ? "" : posLevel ? . posLevelName ,
type : posType ? . posTypeName == null ? "" : posType ? . posTypeName ,
2024-03-18 17:30:54 +07:00
date :
salarys . date == null
? ""
: salarys . date . getDate ( ) +
" " +
Extension . ToThaiMonth ( salarys . date . getMonth ( ) + 1 ) +
" " +
Extension . ToThaiYear ( salarys . date . getFullYear ( ) ) ,
startDate :
salarys . startDate == null
? ""
: salarys . startDate . getDate ( ) +
" " +
Extension . ToThaiMonth ( salarys . startDate . getMonth ( ) + 1 ) +
" " +
Extension . ToThaiYear ( salarys . startDate . getFullYear ( ) ) ,
endDate :
salarys . endDate == null
? ""
: salarys . endDate . getDate ( ) +
" " +
Extension . ToThaiMonth ( salarys . endDate . getMonth ( ) + 1 ) +
" " +
Extension . ToThaiYear ( salarys . endDate . getFullYear ( ) ) ,
2024-02-19 15:31:07 +07:00
details : salarys.details == null ? "" : salarys . details ,
2024-03-18 17:30:54 +07:00
salaryRanks : mapSalaryRank ,
} ,
2024-02-19 15:31:07 +07:00
} ) ;
2024-03-18 13:07:09 +07:00
}
2024-03-18 17:30:54 +07:00
/ * *
* API ร า ย ง า น อ ั ต ร า เ ง ิ น เ ด ื อ น ล ู ก จ ้ า ง
*
* @summary ร า ย ง า น อ ั ต ร า เ ง ิ น เ ด ื อ น ล ู ก จ ้ า ง
*
* @param { string } id Guid , * Id ผ ั ง เ ง ิ น เ ด ื อ น ล ู ก จ ้ า ง
* /
@Get ( "employee/{id}" )
async SalaryEmployeeReport ( @Path ( ) id : string ) {
const salarys = await this . salaryEmployeeRepository . findOne ( {
where : { id : id } ,
} ) ;
if ( ! salarys ) {
throw new HttpError ( HttpStatusCode . NOT_FOUND , "ไม่พบข้อมูลผังเงินเดือนนี้" ) ;
}
const salaryRank = await this . salaryEmployeeRankRepository . find ( {
where : {
salaryEmployeeId : salarys.id ,
} ,
select : [ "id" , "step" , "salaryMonth" , "salaryDay" ] ,
order : {
step : "ASC" ,
salaryMonth : "ASC" ,
} ,
} ) ;
2024-09-03 15:18:23 +07:00
const mapSalaryRank = salaryRank . map ( ( item ) = > ( {
2024-03-18 17:30:54 +07:00
step : item.step == null || item . step == 0 ? "" : item . step . toLocaleString ( ) ,
salaryMonth :
item . salaryMonth == null || item . salaryMonth == 0 ? "" : item . salaryMonth . toLocaleString ( ) ,
salaryDay :
item . salaryDay == null || item . salaryDay == 0 ? "" : item . salaryDay . toLocaleString ( ) ,
} ) ) ;
return new HttpSuccess ( {
template : "SalaryRankEmployee" ,
reportName : "SalaryRankEmployee" ,
data : {
date : Extension.ToThaiFullDate ( new Date ( ) ) ,
group : salarys.group == null || salarys . group == 0 ? "" : salarys . group . toLocaleString ( ) ,
salaryRanks : mapSalaryRank ,
} ,
} ) ;
}
2024-03-18 13:07:09 +07:00
/ * *
2024-04-09 15:54:49 +07:00
* API ร า ย ช ื ่ อ ข ้ า ร า ช ก า ร ผ ู ้ ท ี ่ ค ร อ ง ต ำ แ ห น ่ ง ณ ว ั น ท ี ่ 1 ม ี น า ค ม ( ร อ บ เ ม ษ า ย น ) แ ล ะ ณ ว ั น ท ี ่ 1 ก ั น ย า ย น ( ร อ บ ต ุ ล า ค ม )
2024-03-18 13:07:09 +07:00
*
2024-04-09 15:54:49 +07:00
* @summary ร า ย ช ื ่ อ ข ้ า ร า ช ก า ร ผ ู ้ ท ี ่ ค ร อ ง ต ำ แ ห น ่ ง ณ ว ั น ท ี ่ 1 ม ี น า ค ม ( ร อ บ เ ม ษ า ย น ) แ ล ะ ณ ว ั น ท ี ่ 1 ก ั น ย า ย น ( ร อ บ ต ุ ล า ค ม )
2024-03-18 13:07:09 +07:00
*
* /
2024-07-05 11:25:35 +07:00
@Get ( "gov-01/{rootId}/{salaryPeriodId}/{group}" )
async SalaryReport1 (
@Path ( ) rootId : string ,
@Path ( ) salaryPeriodId : string ,
@Path ( ) group : string ,
) {
2024-03-19 22:34:09 +07:00
const salaryPeriod = await this . salaryPeriodRepository . findOne ( {
where : {
id : salaryPeriodId ,
} ,
} ) ;
if ( ! salaryPeriod ) {
throw new HttpError ( HttpStatusCode . NOT_FOUND , "ไม่พบข้อมูลการขึ้นเงินเดือน" ) ;
}
2024-07-05 11:25:35 +07:00
const convertGroup = group . toUpperCase ( ) ;
2024-06-27 11:53:49 +07:00
const _salaryPeriod = await this . salaryProfileRepository . find ( {
2024-03-18 13:07:09 +07:00
relations : [ "salaryOrg" , "salaryOrg.salaryPeriod" ] ,
where : {
salaryOrg : {
snapshot : "SNAP1" ,
rootId : rootId ,
2024-07-05 11:25:35 +07:00
group : convertGroup ,
2024-03-18 13:07:09 +07:00
salaryPeriodId : salaryPeriodId ,
} ,
} ,
order : {
2024-06-27 11:53:49 +07:00
orgShortName : "ASC" ,
posMasterNo : "ASC" ,
2024-03-18 13:07:09 +07:00
} ,
} ) ;
2024-06-27 11:53:49 +07:00
// const _salaryPeriod1 = await this.salaryProfileRepository.find({
// relations: ["salaryOrg", "salaryOrg.salaryPeriod"],
// where: {
// salaryOrg: {
// snapshot: "SNAP1",
// rootId: rootId,
// salaryPeriodId: salaryPeriodId,
// group: "GROUP1",
// },
// type: "HAFT",
// },
// order: {
// citizenId: "ASC",
// isReserve: "ASC",
// },
// });
// const _salaryPeriod2 = await this.salaryProfileRepository.find({
// relations: ["salaryOrg", "salaryOrg.salaryPeriod"],
// where: {
// salaryOrg: {
// snapshot: "SNAP1",
// rootId: rootId,
// salaryPeriodId: salaryPeriodId,
// group: "GROUP1",
// },
// type: "FULL",
// },
// order: {
// citizenId: "ASC",
// isReserve: "ASC",
// },
// });
// const _salaryPeriod3 = await this.salaryProfileRepository.find({
// relations: ["salaryOrg", "salaryOrg.salaryPeriod"],
// where: {
// salaryOrg: {
// snapshot: "SNAP1",
// rootId: rootId,
// salaryPeriodId: salaryPeriodId,
// group: "GROUP1",
// },
// type: "NONE",
// },
// order: {
// citizenId: "ASC",
// isReserve: "ASC",
// },
// });
// const _salaryPeriod4 = await this.salaryProfileRepository.find({
// relations: ["salaryOrg", "salaryOrg.salaryPeriod"],
// where: {
// salaryOrg: {
// snapshot: "SNAP1",
// rootId: rootId,
// salaryPeriodId: salaryPeriodId,
// group: "GROUP2",
// },
// type: "HAFT",
// },
// order: {
// citizenId: "ASC",
// isReserve: "ASC",
// },
// });
// const _salaryPeriod5 = await this.salaryProfileRepository.find({
// relations: ["salaryOrg", "salaryOrg.salaryPeriod"],
// where: {
// salaryOrg: {
// snapshot: "SNAP1",
// rootId: rootId,
// salaryPeriodId: salaryPeriodId,
// group: "GROUP2",
// },
// type: "FULL",
// },
// order: {
// citizenId: "ASC",
// isReserve: "ASC",
// },
// });
// const _salaryPeriod6 = await this.salaryProfileRepository.find({
// relations: ["salaryOrg", "salaryOrg.salaryPeriod"],
// where: {
// salaryOrg: {
// snapshot: "SNAP1",
// rootId: rootId,
// salaryPeriodId: salaryPeriodId,
// group: "GROUP2",
// },
// type: "NONE",
// },
// order: {
// citizenId: "ASC",
// isReserve: "ASC",
// },
// });
2024-03-18 13:07:09 +07:00
2024-06-27 11:53:49 +07:00
// const _salaryPeriod = _salaryPeriod1.concat(
// _salaryPeriod2,
// _salaryPeriod3,
// _salaryPeriod4,
// _salaryPeriod5,
// _salaryPeriod6,
// );
2024-03-20 18:05:57 +07:00
if ( ! _salaryPeriod ) {
2024-03-18 13:07:09 +07:00
throw new HttpError ( HttpStatusCode . NOT_FOUND , "ไม่พบข้อมูล" ) ;
}
2024-04-05 16:35:18 +07:00
const _root = await this . salaryOrgRepository . findOne ( {
where : {
rootId : rootId ,
salaryPeriodId : salaryPeriodId ,
2024-04-09 09:25:55 +07:00
} ,
} ) ;
2024-04-05 16:35:18 +07:00
const root = _root ? . root == null ? "" : _root . root ;
// const agency = _salaryPeriod[0] == null ? "" : _salaryPeriod[0].root;
2024-03-18 13:07:09 +07:00
2024-03-20 18:05:57 +07:00
const formattedData = _salaryPeriod . map ( ( profile , index ) = > {
2024-03-18 13:07:09 +07:00
const fullNameParts = [
2024-03-21 10:25:48 +07:00
profile . child4 ,
profile . child3 ,
profile . child2 ,
profile . child1 ,
profile . root ,
2024-03-18 13:07:09 +07:00
] ;
2024-07-05 11:25:35 +07:00
const affiliation = fullNameParts
2024-03-18 13:07:09 +07:00
. filter ( ( part ) = > part !== undefined && part !== null )
2025-04-04 13:45:33 +07:00
. join ( "\n" ) ;
2025-07-11 14:23:54 +07:00
2024-07-05 11:25:35 +07:00
const fullName = ` ${ profile . prefix } ${ profile . firstName } ${ profile . lastName } ` ;
2024-03-18 13:07:09 +07:00
return {
no : Extension.ToThaiNumber ( ( index + 1 ) . toLocaleString ( ) ) ,
2024-03-21 10:25:48 +07:00
fullName : fullName ,
2024-07-05 11:25:35 +07:00
affiliation : affiliation ,
2024-03-21 10:25:48 +07:00
posLevel : profile.posLevel ,
2024-03-18 13:07:09 +07:00
posNumber :
2024-04-09 09:25:55 +07:00
Extension . ToThaiNumber ( profile . orgShortName ) +
2025-04-05 18:12:02 +07:00
" " +
2024-04-09 09:25:55 +07:00
Extension . ToThaiNumber ( profile . posMasterNo . toLocaleString ( ) ) ,
2024-03-21 10:25:48 +07:00
amount : profile.amount ? Extension . ToThaiNumber ( profile . amount . toLocaleString ( ) ) : null ,
2024-03-18 13:07:09 +07:00
reason : null ,
} ;
} ) ;
2024-03-19 22:34:09 +07:00
return new HttpSuccess ( {
2024-03-20 18:05:57 +07:00
template : salaryPeriod.period == "APR" ? "gov1-01" : "gov2-01" ,
reportName : salaryPeriod.period == "APR" ? "gov1-01" : "gov2-01" ,
2024-03-19 22:34:09 +07:00
data : {
2024-03-21 10:25:48 +07:00
year : Extension.ToThaiNumber ( String ( Extension . ToThaiYear ( salaryPeriod . year ) ) ) ,
2024-04-05 16:35:18 +07:00
agency : root ,
2024-03-19 22:34:09 +07:00
data : formattedData ,
} ,
} ) ;
2024-03-18 13:07:09 +07:00
}
/ * *
2024-04-01 13:31:39 +07:00
* API บ ั ญ ช ี ก า ร ค ำ น ว ณ โ ค ว ต า เ ล ื ่ อ น เ ง ิ น เ ด ื อ น ร อ บ เ ม ษ า ย น แ ล ะ ต ุ ล า ค ม
2024-03-18 13:07:09 +07:00
*
2024-04-01 13:31:39 +07:00
* @summary บ ั ญ ช ี ก า ร ค ำ น ว ณ โ ค ว ต า เ ล ื ่ อ น เ ง ิ น เ ด ื อ น ร อ บ เ ม ษ า ย น แ ล ะ ต ุ ล า ค ม
2024-03-18 13:07:09 +07:00
*
* /
2024-03-20 18:05:57 +07:00
@Get ( "gov-02/{rootId}/{salaryPeriodId}" )
2024-03-19 22:34:09 +07:00
async SalaryReport2 ( @Path ( ) rootId : string , @Path ( ) salaryPeriodId : string ) {
const salaryPeriod = await this . salaryPeriodRepository . findOne ( {
2024-03-18 13:07:09 +07:00
where : {
2024-03-19 22:34:09 +07:00
id : salaryPeriodId ,
} ,
} ) ;
if ( ! salaryPeriod ) {
throw new HttpError ( HttpStatusCode . NOT_FOUND , "ไม่พบข้อมูลการขึ้นเงินเดือน" ) ;
}
2024-03-20 18:05:57 +07:00
const _salaryPeriod = await this . salaryOrgRepository . find ( {
2024-03-19 22:34:09 +07:00
relations : [ "salaryPeriod" , "salaryProfiles" ] ,
where : {
snapshot : "SNAP1" ,
rootId : rootId ,
salaryPeriodId : salaryPeriodId ,
2024-03-18 13:07:09 +07:00
} ,
2024-03-19 22:34:09 +07:00
} ) ;
2024-04-05 16:35:18 +07:00
2024-03-19 22:34:09 +07:00
const agency =
2024-03-20 18:05:57 +07:00
_salaryPeriod [ 0 ] == null || _salaryPeriod [ 0 ] . salaryProfiles [ 0 ] == null
2024-03-19 22:34:09 +07:00
? ""
2024-03-20 18:05:57 +07:00
: _salaryPeriod [ 0 ] . salaryProfiles [ 0 ] . root ;
if ( salaryPeriod . period == "APR" ) {
let data1 = _salaryPeriod . find ( ( x ) = > x . group == "GROUP2" ) ;
let formattedData1 ;
if ( data1 != null ) {
formattedData1 = {
2024-04-05 17:42:39 +07:00
total : Extension.ToThaiNumber ( data1 . total . toLocaleString ( ) ) ,
2025-04-05 18:12:02 +07:00
fifteenPercent : Extension.ToThaiNumber (
` ${ data1 . fifteenPercent . toLocaleString ( ) } . ${ data1 . fifteenPoint . toLocaleString ( ) } ` ,
) ,
2024-03-20 18:05:57 +07:00
full : Extension.ToThaiNumber (
2024-04-05 17:42:39 +07:00
data1 . salaryProfiles . filter ( ( x ) = > x . type == "FULL" ) . length . toLocaleString ( ) ,
2024-03-20 18:05:57 +07:00
) ,
haft : Extension.ToThaiNumber (
2024-04-05 17:42:39 +07:00
data1 . salaryProfiles . filter ( ( x ) = > x . type == "HAFT" ) . length . toLocaleString ( ) ,
2024-03-20 18:05:57 +07:00
) ,
notPromoted : Extension.ToThaiNumber (
2024-04-05 17:42:39 +07:00
data1 . salaryProfiles . filter ( ( x ) = > x . type == "NONE" ) . length . toLocaleString ( ) ,
2024-03-20 18:05:57 +07:00
) ,
reason : null ,
} ;
}
let data2 = _salaryPeriod . find ( ( x ) = > x . group == "GROUP1" ) ;
let formattedData2 ;
if ( data2 != null ) {
formattedData2 = {
2024-04-05 17:42:39 +07:00
total : Extension.ToThaiNumber ( data2 . total . toLocaleString ( ) ) ,
2025-04-05 18:12:02 +07:00
fifteenPercent : Extension.ToThaiNumber (
` ${ data2 . fifteenPercent . toLocaleString ( ) } . ${ data2 . fifteenPoint . toLocaleString ( ) } ` ,
) ,
2024-03-20 18:05:57 +07:00
full : Extension.ToThaiNumber (
data2 . salaryProfiles
. filter (
( x ) = >
x . posLevel == "อาวุโส" ||
x . posLevel == "ชำนาญการพิเศษ" ||
( x . posLevel == "ต้น" && x . posType == "อำนวยการ" ) ,
)
. filter ( ( x ) = > x . type == "FULL" )
2024-04-05 17:42:39 +07:00
. length . toLocaleString ( ) ,
2024-03-20 18:05:57 +07:00
) ,
haft : Extension.ToThaiNumber (
data2 . salaryProfiles
. filter (
( x ) = >
x . posLevel == "อาวุโส" ||
x . posLevel == "ชำนาญการพิเศษ" ||
( x . posLevel == "ต้น" && x . posType == "อำนวยการ" ) ,
)
. filter ( ( x ) = > x . type == "HAFT" )
2024-04-05 17:42:39 +07:00
. length . toLocaleString ( ) ,
2024-03-20 18:05:57 +07:00
) ,
notPromoted : Extension.ToThaiNumber (
data2 . salaryProfiles
. filter (
( x ) = >
x . posLevel == "อาวุโส" ||
x . posLevel == "ชำนาญการพิเศษ" ||
( x . posLevel == "ต้น" && x . posType == "อำนวยการ" ) ,
)
. filter ( ( x ) = > x . type == "NONE" )
2024-04-05 17:42:39 +07:00
. length . toLocaleString ( ) ,
2024-03-20 18:05:57 +07:00
) ,
reason : null ,
} ;
}
let data3 = _salaryPeriod . find ( ( x ) = > x . group == "GROUP1" ) ;
let formattedData3 ;
if ( data3 != null ) {
formattedData3 = {
2024-04-05 17:42:39 +07:00
total : Extension.ToThaiNumber ( data3 . total . toLocaleString ( ) ) ,
2025-04-05 18:12:02 +07:00
fifteenPercent : Extension.ToThaiNumber (
` ${ data3 . fifteenPercent . toLocaleString ( ) } . ${ data3 . fifteenPoint . toLocaleString ( ) } ` ,
) ,
2024-03-20 18:05:57 +07:00
full : Extension.ToThaiNumber (
data3 . salaryProfiles
. filter (
( x ) = >
x . posLevel == "ปฏิบัติงาน" ||
x . posLevel == "ชำนาญงาน" ||
x . posLevel == "ปฏิบัติการ" ||
x . posLevel == "ชำนาญการ" ,
)
. filter ( ( x ) = > x . type == "FULL" )
2024-04-05 17:42:39 +07:00
. length . toLocaleString ( ) ,
2024-03-20 18:05:57 +07:00
) ,
haft : Extension.ToThaiNumber (
data3 . salaryProfiles
. filter (
( x ) = >
x . posLevel == "ปฏิบัติงาน" ||
x . posLevel == "ชำนาญงาน" ||
x . posLevel == "ปฏิบัติการ" ||
x . posLevel == "ชำนาญการ" ,
)
. filter ( ( x ) = > x . type == "HAFT" )
2024-04-05 17:42:39 +07:00
. length . toLocaleString ( ) ,
2024-03-20 18:05:57 +07:00
) ,
notPromoted : Extension.ToThaiNumber (
data3 . salaryProfiles
. filter (
( x ) = >
x . posLevel == "ปฏิบัติงาน" ||
x . posLevel == "ชำนาญงาน" ||
x . posLevel == "ปฏิบัติการ" ||
x . posLevel == "ชำนาญการ" ,
)
. filter ( ( x ) = > x . type == "NONE" )
2024-04-05 17:42:39 +07:00
. length . toLocaleString ( ) ,
2024-03-20 18:05:57 +07:00
) ,
reason : null ,
} ;
}
let data4 = _salaryPeriod . find ( ( x ) = > x . group == "GROUP1" ) ;
let formattedData4 ;
if ( data4 != null ) {
formattedData4 = {
2024-04-05 17:42:39 +07:00
total : Extension.ToThaiNumber ( data4 . total . toLocaleString ( ) ) ,
2025-04-05 18:12:02 +07:00
fifteenPercent : Extension.ToThaiNumber (
` ${ data4 . fifteenPercent . toLocaleString ( ) } . ${ data4 . fifteenPoint . toLocaleString ( ) } ` ,
) ,
2024-03-20 18:05:57 +07:00
full : Extension.ToThaiNumber (
2024-04-05 17:42:39 +07:00
data4 . salaryProfiles . filter ( ( x ) = > x . type == "FULL" ) . length . toLocaleString ( ) ,
2024-03-20 18:05:57 +07:00
) ,
haft : Extension.ToThaiNumber (
2024-04-05 17:42:39 +07:00
data4 . salaryProfiles . filter ( ( x ) = > x . type == "HAFT" ) . length . toLocaleString ( ) ,
2024-03-20 18:05:57 +07:00
) ,
notPromoted : Extension.ToThaiNumber (
2024-04-05 17:42:39 +07:00
data4 . salaryProfiles . filter ( ( x ) = > x . type == "NONE" ) . length . toLocaleString ( ) ,
2024-03-20 18:05:57 +07:00
) ,
reason : null ,
} ;
}
2024-03-18 13:07:09 +07:00
2024-03-20 18:05:57 +07:00
return new HttpSuccess ( {
template : "gov1-02" ,
reportName : "gov1-02" ,
data : {
2024-04-09 16:47:04 +07:00
// date: Extension.ToThaiNumber(
2024-04-25 00:53:57 +07:00
// Extension.ToThaiFullDate2(new Date(`${salaryPeriod.year}-03-01`)),
2024-04-09 16:47:04 +07:00
// ),
2024-03-21 10:25:48 +07:00
year : Extension.ToThaiNumber ( String ( Extension . ToThaiYear ( salaryPeriod . year ) ) ) ,
2024-04-25 00:53:57 +07:00
yearSlice : Extension.ToThaiNumber (
String ( Extension . ToThaiYear ( salaryPeriod . year ) ) . slice ( - 2 ) ,
) ,
2024-04-09 16:47:04 +07:00
// dateNow: Extension.ToThaiNumber(Extension.ToThaiShortDate(new Date())),
2024-03-20 18:05:57 +07:00
agency : agency ,
data1 : formattedData1 ,
data2 : formattedData2 ,
data3 : formattedData3 ,
data4 : formattedData4 ,
} ,
} ) ;
} else {
let data1 = _salaryPeriod . find ( ( x ) = > x . group == "GROUP2" ) ;
2024-03-20 19:30:13 +07:00
const _salaryPeriodAPR1 = await this . salaryOrgRepository . findOne ( {
2024-03-20 18:05:57 +07:00
where : {
snapshot : "SNAP1" ,
2024-03-20 19:30:13 +07:00
group : "GROUP1" ,
rootId : rootId ,
salaryPeriod : {
period : "APR" ,
year : salaryPeriod.year ,
} ,
} ,
2024-04-09 09:25:55 +07:00
relations : { salaryProfiles : true } ,
2024-03-20 19:30:13 +07:00
} ) ;
const _salaryPeriodAPR2 = await this . salaryOrgRepository . findOne ( {
where : {
snapshot : "SNAP1" ,
group : "GROUP2" ,
2024-03-20 18:05:57 +07:00
rootId : rootId ,
salaryPeriod : {
period : "APR" ,
year : salaryPeriod.year ,
} ,
} ,
2024-04-09 09:25:55 +07:00
relations : { salaryProfiles : true } ,
2024-03-20 18:05:57 +07:00
} ) ;
let formattedData1 ;
if ( data1 != null ) {
const haftSalary = data1 . salaryProfiles
. filter ( ( x ) = > x . type == "HAFT" )
. reduce ( ( accumulator , object : any ) = > {
return (
accumulator +
2024-03-20 19:30:13 +07:00
( object . amountUse == null ? 0 : object.amountUse ) +
2024-03-20 18:05:57 +07:00
( object . amountSpecial == null ? 0 : object.amountSpecial )
) ;
} , 0 ) ;
const fullSalary = data1 . salaryProfiles
. filter ( ( x ) = > x . type == "FULL" )
. reduce ( ( accumulator , object : any ) = > {
return (
accumulator +
2024-03-20 19:30:13 +07:00
( object . amountUse == null ? 0 : object.amountUse ) +
2024-03-20 18:05:57 +07:00
( object . amountSpecial == null ? 0 : object.amountSpecial )
) ;
} , 0 ) ;
const fullHaftSalary = data1 . salaryProfiles
2024-03-20 19:30:13 +07:00
. filter ( ( x ) = > x . type == "FULLHAFT" )
2024-03-20 18:05:57 +07:00
. reduce ( ( accumulator , object : any ) = > {
return (
accumulator +
2024-03-20 19:30:13 +07:00
( object . amountUse == null ? 0 : object.amountUse ) +
2024-03-20 18:05:57 +07:00
( object . amountSpecial == null ? 0 : object.amountSpecial )
) ;
} , 0 ) ;
formattedData1 = {
2024-04-05 17:42:39 +07:00
totalSalary : Extension.ToThaiNumber ( data1 . currentAmount . toLocaleString ( ) ) ,
totalUser : Extension.ToThaiNumber ( data1 . total . toLocaleString ( ) ) ,
sixPercentAmount : Extension.ToThaiNumber ( data1 . sixPercentAmount . toLocaleString ( ) ) ,
spentAmount : Extension.ToThaiNumber ( data1 . spentAmount . toLocaleString ( ) ) ,
2024-04-09 09:25:55 +07:00
remainingAmount : Extension.ToThaiNumber ( data1 . remainingAmount . toLocaleString ( ) ) ,
2025-04-05 18:12:02 +07:00
fifteenPercentOld : Extension.ToThaiNumber (
` ${ _salaryPeriodAPR2 == null ? 0 : _salaryPeriodAPR2.fifteenPercent.toLocaleString ( ) } . ${ _salaryPeriodAPR2 == null ? 0 : _salaryPeriodAPR2.fifteenPoint.toLocaleString ( ) } ` ,
) ,
totalOld : Extension.ToThaiNumber (
2024-04-09 09:25:55 +07:00
( _salaryPeriodAPR2 == null || _salaryPeriodAPR2 . salaryProfiles . length == 0
? 0
: _salaryPeriodAPR2 . salaryProfiles . filter ( ( x ) = > x . type == "FULL" ) . length
) . toLocaleString ( ) ,
2024-03-20 19:30:13 +07:00
) ,
2024-03-20 18:05:57 +07:00
haft : Extension.ToThaiNumber (
2024-04-05 17:42:39 +07:00
data1 . salaryProfiles . filter ( ( x ) = > x . type == "HAFT" ) . length . toLocaleString ( ) ,
2024-03-20 18:05:57 +07:00
) ,
full : Extension.ToThaiNumber (
2024-04-05 17:42:39 +07:00
data1 . salaryProfiles . filter ( ( x ) = > x . type == "FULL" ) . length . toLocaleString ( ) ,
2024-03-20 18:05:57 +07:00
) ,
fullHaft : Extension.ToThaiNumber (
2024-03-20 19:30:13 +07:00
data1 . salaryProfiles . filter ( ( x ) = > x . type == "FULLHAFT" ) . length . toString ( ) ,
2024-03-20 18:05:57 +07:00
) ,
notPromoted : Extension.ToThaiNumber (
2024-04-05 17:42:39 +07:00
data1 . salaryProfiles . filter ( ( x ) = > x . type == "NONE" ) . length . toLocaleString ( ) ,
2024-03-20 18:05:57 +07:00
) ,
2024-04-05 17:42:39 +07:00
haftSalary : Extension.ToThaiNumber ( haftSalary . toLocaleString ( ) ) ,
fullSalary : Extension.ToThaiNumber ( fullSalary . toLocaleString ( ) ) ,
fullHaftSalary : Extension.ToThaiNumber ( fullHaftSalary . toLocaleString ( ) ) ,
2024-04-09 09:25:55 +07:00
total : Extension.ToThaiNumber (
( haftSalary + fullSalary + fullHaftSalary ) . toLocaleString ( ) ,
) ,
2024-03-20 18:05:57 +07:00
summary : Extension.ToThaiNumber (
(
data1 . sixPercentAmount -
data1 . spentAmount -
haftSalary -
fullSalary -
fullHaftSalary
2024-04-05 17:42:39 +07:00
) . toLocaleString ( ) ,
2024-03-20 18:05:57 +07:00
) ,
reason : null ,
} ;
}
let data2 = _salaryPeriod . find ( ( x ) = > x . group == "GROUP1" ) ;
let formattedData2 ;
if ( data2 != null ) {
const haftSalary = data2 . salaryProfiles
. filter ( ( x ) = > x . type == "HAFT" )
. filter (
( x ) = >
x . posLevel == "อาวุโส" ||
x . posLevel == "ชำนาญการพิเศษ" ||
( x . posLevel == "ต้น" && x . posType == "อำนวยการ" ) ,
)
. reduce ( ( accumulator , object : any ) = > {
return (
accumulator +
2024-03-20 19:30:13 +07:00
( object . amountUse == null ? 0 : object.amountUse ) +
2024-03-20 18:05:57 +07:00
( object . amountSpecial == null ? 0 : object.amountSpecial )
) ;
} , 0 ) ;
const fullSalary = data2 . salaryProfiles
. filter ( ( x ) = > x . type == "FULL" )
. filter (
( x ) = >
x . posLevel == "อาวุโส" ||
x . posLevel == "ชำนาญการพิเศษ" ||
( x . posLevel == "ต้น" && x . posType == "อำนวยการ" ) ,
)
. reduce ( ( accumulator , object : any ) = > {
return (
accumulator +
2024-03-20 19:30:13 +07:00
( object . amountUse == null ? 0 : object.amountUse ) +
2024-03-20 18:05:57 +07:00
( object . amountSpecial == null ? 0 : object.amountSpecial )
) ;
} , 0 ) ;
const fullHaftSalary = data2 . salaryProfiles
2024-03-20 19:30:13 +07:00
. filter ( ( x ) = > x . type == "FULLHAFT" )
2024-03-20 18:05:57 +07:00
. filter (
( x ) = >
x . posLevel == "อาวุโส" ||
x . posLevel == "ชำนาญการพิเศษ" ||
( x . posLevel == "ต้น" && x . posType == "อำนวยการ" ) ,
)
. reduce ( ( accumulator , object : any ) = > {
return (
accumulator +
2024-03-20 19:30:13 +07:00
( object . amountUse == null ? 0 : object.amountUse ) +
2024-03-20 18:05:57 +07:00
( object . amountSpecial == null ? 0 : object.amountSpecial )
) ;
} , 0 ) ;
formattedData2 = {
2024-04-05 17:42:39 +07:00
totalSalary : Extension.ToThaiNumber ( data2 . currentAmount . toLocaleString ( ) ) ,
totalUser : Extension.ToThaiNumber ( data2 . total . toLocaleString ( ) ) ,
sixPercentAmount : Extension.ToThaiNumber ( data2 . sixPercentAmount . toLocaleString ( ) ) ,
spentAmount : Extension.ToThaiNumber ( data2 . spentAmount . toLocaleString ( ) ) ,
2024-04-09 09:25:55 +07:00
remainingAmount : Extension.ToThaiNumber ( data2 . remainingAmount . toLocaleString ( ) ) ,
2025-04-05 18:12:02 +07:00
fifteenPercentOld : Extension.ToThaiNumber (
` ${ _salaryPeriodAPR1 == null ? 0 : _salaryPeriodAPR1.fifteenPercent.toLocaleString ( ) } . ${ _salaryPeriodAPR1 == null ? 0 : _salaryPeriodAPR1.fifteenPoint.toLocaleString ( ) } ` ,
) ,
2024-03-20 19:30:13 +07:00
totalOld : Extension.ToThaiNumber (
2024-04-09 09:25:55 +07:00
( _salaryPeriodAPR1 == null || _salaryPeriodAPR1 . salaryProfiles . length == 0
? 0
: _salaryPeriodAPR1 . salaryProfiles
. filter (
( x ) = >
x . posLevel == "อาวุโส" ||
x . posLevel == "ชำนาญการพิเศษ" ||
( x . posLevel == "ต้น" && x . posType == "อำนวยการ" ) ,
)
. filter ( ( x ) = > x . type == "FULL" ) . length
) . toLocaleString ( ) ,
2024-03-20 19:30:13 +07:00
) ,
2024-03-20 18:05:57 +07:00
haft : Extension.ToThaiNumber (
data2 . salaryProfiles
. filter (
( x ) = >
x . posLevel == "อาวุโส" ||
x . posLevel == "ชำนาญการพิเศษ" ||
( x . posLevel == "ต้น" && x . posType == "อำนวยการ" ) ,
)
. filter ( ( x ) = > x . type == "HAFT" )
2024-04-05 17:42:39 +07:00
. length . toLocaleString ( ) ,
2024-03-20 18:05:57 +07:00
) ,
full : Extension.ToThaiNumber (
data2 . salaryProfiles
. filter (
( x ) = >
x . posLevel == "อาวุโส" ||
x . posLevel == "ชำนาญการพิเศษ" ||
( x . posLevel == "ต้น" && x . posType == "อำนวยการ" ) ,
)
. filter ( ( x ) = > x . type == "FULL" )
2024-04-05 17:42:39 +07:00
. length . toLocaleString ( ) ,
2024-03-20 18:05:57 +07:00
) ,
fullHaft : Extension.ToThaiNumber (
data2 . salaryProfiles
. filter (
( x ) = >
x . posLevel == "อาวุโส" ||
x . posLevel == "ชำนาญการพิเศษ" ||
( x . posLevel == "ต้น" && x . posType == "อำนวยการ" ) ,
)
2024-03-20 19:30:13 +07:00
. filter ( ( x ) = > x . type == "FULLHAFT" )
2024-04-05 17:42:39 +07:00
. length . toLocaleString ( ) ,
2024-03-20 18:05:57 +07:00
) ,
notPromoted : Extension.ToThaiNumber (
data2 . salaryProfiles
. filter (
( x ) = >
x . posLevel == "อาวุโส" ||
x . posLevel == "ชำนาญการพิเศษ" ||
( x . posLevel == "ต้น" && x . posType == "อำนวยการ" ) ,
)
. filter ( ( x ) = > x . type == "NONE" )
2024-04-05 17:42:39 +07:00
. length . toLocaleString ( ) ,
2024-03-20 18:05:57 +07:00
) ,
2024-04-05 17:42:39 +07:00
haftSalary : Extension.ToThaiNumber ( haftSalary . toLocaleString ( ) ) ,
fullSalary : Extension.ToThaiNumber ( fullSalary . toLocaleString ( ) ) ,
fullHaftSalary : Extension.ToThaiNumber ( fullHaftSalary . toLocaleString ( ) ) ,
2024-04-09 09:25:55 +07:00
total : Extension.ToThaiNumber (
( haftSalary + fullSalary + fullHaftSalary ) . toLocaleString ( ) ,
) ,
2024-03-20 18:05:57 +07:00
summary : Extension.ToThaiNumber (
(
data2 . sixPercentAmount -
data2 . spentAmount -
haftSalary -
fullSalary -
fullHaftSalary
2024-04-05 17:42:39 +07:00
) . toLocaleString ( ) ,
2024-03-20 18:05:57 +07:00
) ,
reason : null ,
} ;
}
let data3 = _salaryPeriod . find ( ( x ) = > x . group == "GROUP1" ) ;
let formattedData3 ;
if ( data3 != null ) {
const haftSalary = data3 . salaryProfiles
. filter ( ( x ) = > x . type == "HAFT" )
. filter (
( x ) = >
x . posLevel == "ปฏิบัติงาน" ||
x . posLevel == "ชำนาญงาน" ||
x . posLevel == "ปฏิบัติการ" ||
x . posLevel == "ชำนาญการ" ,
)
. reduce ( ( accumulator , object : any ) = > {
return (
accumulator +
2024-03-20 19:30:13 +07:00
( object . amountUse == null ? 0 : object.amountUse ) +
2024-03-20 18:05:57 +07:00
( object . amountSpecial == null ? 0 : object.amountSpecial )
) ;
} , 0 ) ;
const fullSalary = data3 . salaryProfiles
. filter ( ( x ) = > x . type == "FULL" )
. filter (
( x ) = >
x . posLevel == "ปฏิบัติงาน" ||
x . posLevel == "ชำนาญงาน" ||
x . posLevel == "ปฏิบัติการ" ||
x . posLevel == "ชำนาญการ" ,
)
. reduce ( ( accumulator , object : any ) = > {
return (
accumulator +
2024-03-20 19:30:13 +07:00
( object . amountUse == null ? 0 : object.amountUse ) +
2024-03-20 18:05:57 +07:00
( object . amountSpecial == null ? 0 : object.amountSpecial )
) ;
} , 0 ) ;
const fullHaftSalary = data3 . salaryProfiles
2024-03-20 19:30:13 +07:00
. filter ( ( x ) = > x . type == "FULLHAFT" )
2024-03-20 18:05:57 +07:00
. filter (
( x ) = >
x . posLevel == "ปฏิบัติงาน" ||
x . posLevel == "ชำนาญงาน" ||
x . posLevel == "ปฏิบัติการ" ||
x . posLevel == "ชำนาญการ" ,
)
. reduce ( ( accumulator , object : any ) = > {
return (
accumulator +
2024-03-20 19:30:13 +07:00
( object . amountUse == null ? 0 : object.amountUse ) +
2024-03-20 18:05:57 +07:00
( object . amountSpecial == null ? 0 : object.amountSpecial )
) ;
} , 0 ) ;
formattedData3 = {
2024-04-05 17:42:39 +07:00
totalSalary : Extension.ToThaiNumber ( data3 . currentAmount . toLocaleString ( ) ) ,
totalUser : Extension.ToThaiNumber ( data3 . total . toLocaleString ( ) ) ,
sixPercentAmount : Extension.ToThaiNumber ( data3 . sixPercentAmount . toLocaleString ( ) ) ,
spentAmount : Extension.ToThaiNumber ( data3 . spentAmount . toLocaleString ( ) ) ,
2024-04-09 09:25:55 +07:00
remainingAmount : Extension.ToThaiNumber ( data3 . remainingAmount . toLocaleString ( ) ) ,
2025-04-05 18:12:02 +07:00
fifteenPercentOld : Extension.ToThaiNumber (
` ${ _salaryPeriodAPR1 == null ? 0 : _salaryPeriodAPR1.fifteenPercent.toLocaleString ( ) } . ${ _salaryPeriodAPR1 == null ? 0 : _salaryPeriodAPR1.fifteenPoint.toLocaleString ( ) } ` ,
) ,
2024-03-20 19:30:13 +07:00
totalOld : Extension.ToThaiNumber (
2024-04-09 09:25:55 +07:00
( _salaryPeriodAPR1 == null || _salaryPeriodAPR1 . salaryProfiles . length == 0
? 0
: _salaryPeriodAPR1 . salaryProfiles
. filter ( ( x ) = > x . type == "FULL" )
. filter (
( x ) = >
x . posLevel == "ปฏิบัติงาน" ||
x . posLevel == "ชำนาญงาน" ||
x . posLevel == "ปฏิบัติการ" ||
x . posLevel == "ชำนาญการ" ,
) . length
) . toLocaleString ( ) ,
2024-03-20 19:30:13 +07:00
) ,
2024-03-20 18:05:57 +07:00
haft : Extension.ToThaiNumber (
data3 . salaryProfiles
. filter ( ( x ) = > x . type == "HAFT" )
. filter (
( x ) = >
x . posLevel == "ปฏิบัติงาน" ||
x . posLevel == "ชำนาญงาน" ||
x . posLevel == "ปฏิบัติการ" ||
x . posLevel == "ชำนาญการ" ,
)
2024-04-05 17:42:39 +07:00
. length . toLocaleString ( ) ,
2024-03-20 18:05:57 +07:00
) ,
full : Extension.ToThaiNumber (
data3 . salaryProfiles
. filter ( ( x ) = > x . type == "FULL" )
. filter (
( x ) = >
x . posLevel == "ปฏิบัติงาน" ||
x . posLevel == "ชำนาญงาน" ||
x . posLevel == "ปฏิบัติการ" ||
x . posLevel == "ชำนาญการ" ,
)
2024-04-05 17:42:39 +07:00
. length . toLocaleString ( ) ,
2024-03-20 18:05:57 +07:00
) ,
fullHaft : Extension.ToThaiNumber (
data3 . salaryProfiles
2024-03-20 19:30:13 +07:00
. filter ( ( x ) = > x . type == "FULLHAFT" )
2024-03-20 18:05:57 +07:00
. filter (
( x ) = >
x . posLevel == "ปฏิบัติงาน" ||
x . posLevel == "ชำนาญงาน" ||
x . posLevel == "ปฏิบัติการ" ||
x . posLevel == "ชำนาญการ" ,
)
2024-04-05 17:42:39 +07:00
. length . toLocaleString ( ) ,
2024-03-20 18:05:57 +07:00
) ,
notPromoted : Extension.ToThaiNumber (
data3 . salaryProfiles
. filter ( ( x ) = > x . type == "NONE" )
. filter (
( x ) = >
x . posLevel == "ปฏิบัติงาน" ||
x . posLevel == "ชำนาญงาน" ||
x . posLevel == "ปฏิบัติการ" ||
x . posLevel == "ชำนาญการ" ,
)
2024-04-05 17:42:39 +07:00
. length . toLocaleString ( ) ,
2024-03-20 18:05:57 +07:00
) ,
2024-04-05 17:42:39 +07:00
haftSalary : Extension.ToThaiNumber ( haftSalary . toLocaleString ( ) ) ,
fullSalary : Extension.ToThaiNumber ( fullSalary . toLocaleString ( ) ) ,
fullHaftSalary : Extension.ToThaiNumber ( fullHaftSalary . toLocaleString ( ) ) ,
2024-04-09 09:25:55 +07:00
total : Extension.ToThaiNumber (
( haftSalary + fullSalary + fullHaftSalary ) . toLocaleString ( ) ,
) ,
2024-03-20 18:05:57 +07:00
summary : Extension.ToThaiNumber (
(
data3 . sixPercentAmount -
data3 . spentAmount -
haftSalary -
fullSalary -
fullHaftSalary
2024-04-05 17:42:39 +07:00
) . toLocaleString ( ) ,
2024-03-20 18:05:57 +07:00
) ,
reason : null ,
} ;
}
let data4 = _salaryPeriod . find ( ( x ) = > x . group == "GROUP1" ) ;
let formattedData4 ;
if ( data4 != null ) {
const haftSalary = data4 . salaryProfiles
. filter ( ( x ) = > x . type == "HAFT" )
. reduce ( ( accumulator , object : any ) = > {
return (
accumulator +
2024-03-20 19:30:13 +07:00
( object . amountUse == null ? 0 : object.amountUse ) +
2024-03-20 18:05:57 +07:00
( object . amountSpecial == null ? 0 : object.amountSpecial )
) ;
} , 0 ) ;
const fullSalary = data4 . salaryProfiles
. filter ( ( x ) = > x . type == "FULL" )
. reduce ( ( accumulator , object : any ) = > {
return (
accumulator +
2024-03-20 19:30:13 +07:00
( object . amountUse == null ? 0 : object.amountUse ) +
2024-03-20 18:05:57 +07:00
( object . amountSpecial == null ? 0 : object.amountSpecial )
) ;
} , 0 ) ;
const fullHaftSalary = data4 . salaryProfiles
2024-03-20 19:30:13 +07:00
. filter ( ( x ) = > x . type == "FULLHAFT" )
2024-03-20 18:05:57 +07:00
. reduce ( ( accumulator , object : any ) = > {
return (
accumulator +
2024-03-20 19:30:13 +07:00
( object . amountUse == null ? 0 : object.amountUse ) +
2024-03-20 18:05:57 +07:00
( object . amountSpecial == null ? 0 : object.amountSpecial )
) ;
} , 0 ) ;
formattedData4 = {
2024-04-05 17:42:39 +07:00
totalSalary : Extension.ToThaiNumber ( data4 . currentAmount . toLocaleString ( ) ) ,
totalUser : Extension.ToThaiNumber ( data4 . total . toLocaleString ( ) ) ,
sixPercentAmount : Extension.ToThaiNumber ( data4 . sixPercentAmount . toLocaleString ( ) ) ,
spentAmount : Extension.ToThaiNumber ( data4 . spentAmount . toLocaleString ( ) ) ,
2024-04-09 09:25:55 +07:00
remainingAmount : Extension.ToThaiNumber ( data4 . remainingAmount . toLocaleString ( ) ) ,
2025-04-05 18:12:02 +07:00
fifteenPercentOld : Extension.ToThaiNumber (
` ${ _salaryPeriodAPR1 == null ? 0 : _salaryPeriodAPR1.fifteenPercent.toLocaleString ( ) } . ${ _salaryPeriodAPR1 == null ? 0 : _salaryPeriodAPR1.fifteenPoint.toLocaleString ( ) } ` ,
) ,
2024-03-20 19:30:13 +07:00
totalOld : Extension.ToThaiNumber (
2024-04-09 09:25:55 +07:00
( _salaryPeriodAPR1 == null || _salaryPeriodAPR1 . salaryProfiles . length == 0
? 0
: _salaryPeriodAPR1 . salaryProfiles . filter ( ( x ) = > x . type == "FULL" ) . length
) . toLocaleString ( ) ,
2024-03-20 19:30:13 +07:00
) ,
2024-03-20 18:05:57 +07:00
haft : Extension.ToThaiNumber (
2024-04-05 17:42:39 +07:00
data4 . salaryProfiles . filter ( ( x ) = > x . type == "HAFT" ) . length . toLocaleString ( ) ,
2024-03-20 18:05:57 +07:00
) ,
full : Extension.ToThaiNumber (
2024-04-05 17:42:39 +07:00
data4 . salaryProfiles . filter ( ( x ) = > x . type == "FULL" ) . length . toLocaleString ( ) ,
2024-03-20 18:05:57 +07:00
) ,
fullHaft : Extension.ToThaiNumber (
2024-04-05 17:42:39 +07:00
data4 . salaryProfiles . filter ( ( x ) = > x . type == "FULLHAFT" ) . length . toLocaleString ( ) ,
2024-03-20 18:05:57 +07:00
) ,
notPromoted : Extension.ToThaiNumber (
2024-04-05 17:42:39 +07:00
data4 . salaryProfiles . filter ( ( x ) = > x . type == "NONE" ) . length . toLocaleString ( ) ,
2024-03-20 18:05:57 +07:00
) ,
2024-04-05 17:42:39 +07:00
haftSalary : Extension.ToThaiNumber ( haftSalary . toLocaleString ( ) ) ,
fullSalary : Extension.ToThaiNumber ( fullSalary . toLocaleString ( ) ) ,
fullHaftSalary : Extension.ToThaiNumber ( fullHaftSalary . toLocaleString ( ) ) ,
2024-04-09 09:25:55 +07:00
total : Extension.ToThaiNumber (
( haftSalary + fullSalary + fullHaftSalary ) . toLocaleString ( ) ,
) ,
2024-03-20 18:05:57 +07:00
summary : Extension.ToThaiNumber (
(
data4 . sixPercentAmount -
data4 . spentAmount -
haftSalary -
fullSalary -
fullHaftSalary
2024-04-05 17:42:39 +07:00
) . toLocaleString ( ) ,
2024-03-20 18:05:57 +07:00
) ,
reason : null ,
} ;
}
return new HttpSuccess ( {
template : "gov2-02" ,
reportName : "gov2-02" ,
data : {
2024-04-09 16:47:04 +07:00
// date: Extension.ToThaiNumber(
// Extension.ToThaiFullDate2(new Date(`${salaryPeriod.year}-03-01`)),
// ),
2024-03-21 10:25:48 +07:00
year : Extension.ToThaiNumber ( String ( Extension . ToThaiYear ( salaryPeriod . year ) ) ) ,
2024-04-25 00:53:57 +07:00
yearSlice : Extension.ToThaiNumber (
String ( Extension . ToThaiYear ( salaryPeriod . year ) ) . slice ( - 2 ) ,
) ,
2024-04-09 16:47:04 +07:00
// dateNow: Extension.ToThaiNumber(Extension.ToThaiShortDate(new Date())),
2024-03-20 18:05:57 +07:00
agency : agency ,
data1 : formattedData1 ,
data2 : formattedData2 ,
data3 : formattedData3 ,
data4 : formattedData4 ,
} ,
} ) ;
}
2024-03-18 13:07:09 +07:00
}
/ * *
2024-04-10 18:15:42 +07:00
* API ร า ย ช ื ่ อ ข ้ า ร า ช ก า ร ท ี ่ ไ ด ้ ร ั บ ก า ร เ ส น อ ข อ เ ล ื ่ อ น ห น ึ ่ ง ข ั ้ น ร อ บ เ ม ษ า ย น แ ล ะ ท ั ้ ง ป ี ส อ ง ข ั ้ น ร อ บ ต ุ ล า ค ม
2024-03-18 13:07:09 +07:00
*
2024-04-10 18:15:42 +07:00
* @summary ร า ย ช ื ่ อ ข ้ า ร า ช ก า ร ท ี ่ ไ ด ้ ร ั บ ก า ร เ ส น อ ข อ เ ล ื ่ อ น ห น ึ ่ ง ข ั ้ น ร อ บ เ ม ษ า ย น แ ล ะ ท ั ้ ง ป ี ส อ ง ข ั ้ น ร อ บ ต ุ ล า ค ม
2024-03-18 13:07:09 +07:00
*
* @param { string } rootId Guid , * Id Root
* @param { string } salaryPeriodId Guid , * Id Period
* /
2024-07-05 15:12:42 +07:00
@Get ( "gov-03/{rootId}/{salaryPeriodId}/{group}" )
2024-07-08 09:21:24 +07:00
async SalaryReport3 (
@Path ( ) rootId : string ,
@Path ( ) salaryPeriodId : string ,
@Path ( ) group : string ,
) {
2024-03-18 13:07:09 +07:00
const salaryPeriod = await this . salaryPeriodRepository . findOne ( {
where : {
id : salaryPeriodId ,
isActive : true ,
} ,
} ) ;
if ( ! salaryPeriod ) {
throw new HttpError ( HttpStatusCode . NOT_FOUND , "ไม่พบรอบการขึ้นเงินเดือน" ) ;
}
2024-07-05 15:12:42 +07:00
const convertGroup = group . toUpperCase ( ) ;
const salaryOrg = await this . salaryOrgRepository . findOne ( {
2024-03-22 17:44:56 +07:00
where : {
salaryPeriodId : salaryPeriodId ,
rootId : rootId ,
2024-07-03 18:00:49 +07:00
snapshot : "SNAP1" ,
2024-07-05 15:12:42 +07:00
group : convertGroup ,
2024-03-18 13:07:09 +07:00
} ,
} ) ;
2025-06-27 13:51:38 +07:00
//รอบเมษา
2024-06-27 14:06:55 +07:00
if ( salaryPeriod . period === "APR" ) {
let salaryProfileGroup1 : any ;
let salaryProfileGroup2 : any ;
2024-07-05 15:12:42 +07:00
if ( salaryOrg ) {
2024-06-27 14:06:55 +07:00
salaryProfileGroup1 = await this . salaryProfileRepository . find ( {
where : {
2024-07-05 15:12:42 +07:00
salaryOrgId : salaryOrg?.id ,
2024-06-27 14:06:55 +07:00
type : "FULL" , //หนึ่งขั้น
} ,
} ) ;
2024-07-02 15:25:34 +07:00
}
2025-02-25 14:59:02 +07:00
// const rootName = await this.salaryOrgRepository.findOne({
// where: {
// rootId: rootId,
// },
// select: ["root"],
// });
2025-03-10 12:53:11 +07:00
2025-02-25 14:59:02 +07:00
//รอบปีก่อนหน้า
const salaryPeriodIncrease2_APR = await this . salaryPeriodRepository . findOne ( {
2024-03-21 18:18:50 +07:00
where : {
period : "APR" ,
2025-02-25 14:59:02 +07:00
year : salaryPeriod.year - 1 ,
2024-03-21 18:18:50 +07:00
isActive : true ,
} ,
} ) ;
2025-02-25 14:59:02 +07:00
const salaryPeriodIncrease2_OCT = await this . salaryPeriodRepository . findOne ( {
2024-03-21 18:18:50 +07:00
where : {
period : "OCT" ,
2025-02-25 14:59:02 +07:00
year : salaryPeriod.year - 1 ,
2024-03-21 18:18:50 +07:00
isActive : true ,
} ,
} ) ;
2025-02-25 14:59:02 +07:00
let salaryOrg2_APR = null ;
if ( salaryPeriodIncrease2_APR ) {
salaryOrg2_APR = await this . salaryOrgRepository . findOne ( {
2025-01-29 15:21:47 +07:00
where : {
2025-02-25 14:59:02 +07:00
salaryPeriodId : salaryPeriodIncrease2_APR?.id ,
2025-01-29 15:21:47 +07:00
// rootId: rootId,
2025-02-25 14:59:02 +07:00
// root: rootName?.root,
2025-03-10 12:53:11 +07:00
rootId : salaryOrg?.rootDnaId ,
2025-01-29 15:21:47 +07:00
snapshot : "SNAP1" ,
group : convertGroup ,
} ,
} ) ;
}
2025-02-03 15:47:29 +07:00
2025-02-25 14:59:02 +07:00
let salaryOrg2_OCT = null ;
if ( salaryPeriodIncrease2_OCT ) {
salaryOrg2_OCT = await this . salaryOrgRepository . findOne ( {
2025-02-03 15:47:29 +07:00
where : {
2025-02-25 14:59:02 +07:00
salaryPeriodId : salaryPeriodIncrease2_OCT?.id ,
2025-02-03 15:47:29 +07:00
// rootId: rootId,
2025-02-25 14:59:02 +07:00
// root: rootName?.root,
2025-03-10 12:53:11 +07:00
rootId : salaryOrg?.rootDnaId ,
2025-02-03 15:47:29 +07:00
snapshot : "SNAP1" ,
group : convertGroup ,
} ,
} ) ;
2025-01-29 15:21:47 +07:00
}
2024-07-05 15:12:42 +07:00
2025-02-25 14:59:02 +07:00
const salaryProfile2 = await this . salaryProfileRepository . find ( {
2024-03-21 18:18:50 +07:00
where : {
2025-02-25 14:59:02 +07:00
salaryOrgId : In ( [ salaryOrg2_APR ? . id , salaryOrg2_OCT ? . id ] ) ,
2025-02-03 15:47:29 +07:00
type : Not ( In ( [ "NONE" , "PENDING" ] ) ) ,
2024-03-21 18:18:50 +07:00
} ,
} ) ;
2025-02-25 14:59:02 +07:00
2025-03-10 12:53:11 +07:00
//รอบปีก่อนๆ
const salaryPeriodIncrease1_APR = await this . salaryPeriodRepository . findOne ( {
2024-03-21 18:18:50 +07:00
where : {
period : "APR" ,
2025-02-25 14:59:02 +07:00
year : salaryPeriod.year - 2 ,
2024-03-21 18:18:50 +07:00
isActive : true ,
} ,
} ) ;
2025-02-25 14:59:02 +07:00
const salaryPeriodIncrease1_OCT = await this . salaryPeriodRepository . findOne ( {
2024-03-21 18:18:50 +07:00
where : {
period : "OCT" ,
2025-02-25 14:59:02 +07:00
year : salaryPeriod.year - 2 ,
2024-03-21 18:18:50 +07:00
isActive : true ,
} ,
} ) ;
2025-02-25 14:59:02 +07:00
let salaryOrg1_APR = null ;
if ( salaryPeriodIncrease1_APR ) {
salaryOrg1_APR = await this . salaryOrgRepository . findOne ( {
2025-01-29 15:21:47 +07:00
where : {
2025-02-25 14:59:02 +07:00
salaryPeriodId : salaryPeriodIncrease1_APR?.id ,
2025-01-29 15:21:47 +07:00
// rootId: rootId,
2025-02-25 14:59:02 +07:00
// root: rootName?.root,
2025-03-10 12:53:11 +07:00
rootId : salaryOrg2_APR?.rootDnaId ,
2025-01-29 15:21:47 +07:00
snapshot : "SNAP1" ,
group : convertGroup ,
} ,
} ) ;
}
2024-07-08 09:21:24 +07:00
2025-02-25 14:59:02 +07:00
let salaryOrg1_OCT = null ;
if ( salaryPeriodIncrease1_OCT ) {
salaryOrg1_OCT = await this . salaryOrgRepository . findOne ( {
2025-01-29 15:21:47 +07:00
where : {
2025-02-25 14:59:02 +07:00
salaryPeriodId : salaryPeriodIncrease1_OCT?.id ,
2025-01-29 15:21:47 +07:00
// rootId: rootId,
2025-02-25 14:59:02 +07:00
// root: rootName?.root,
2025-03-10 12:53:11 +07:00
rootId : salaryOrg2_APR?.rootDnaId ,
2025-01-29 15:21:47 +07:00
snapshot : "SNAP1" ,
group : convertGroup ,
} ,
} ) ;
}
2025-02-03 15:47:29 +07:00
2025-02-25 14:59:02 +07:00
const salaryProfile1 = await this . salaryProfileRepository . find ( {
2024-03-21 18:18:50 +07:00
where : {
2025-02-25 14:59:02 +07:00
salaryOrgId : In ( [ salaryOrg1_APR ? . id , salaryOrg1_OCT ? . id ] ) ,
2025-02-03 15:47:29 +07:00
type : Not ( In ( [ "NONE" , "PENDING" ] ) ) ,
2024-03-21 18:18:50 +07:00
} ,
} ) ;
2025-07-11 11:43:38 +07:00
const year = salaryPeriod . year ? Extension . ToThaiNumber ( String ( Extension . ToThaiYear ( salaryPeriod . year ) ) ) : "" ;
const yearIncrease1 = salaryPeriod . year ? Extension . ToThaiNumber (
2024-03-22 11:31:56 +07:00
String ( Extension . ToThaiYear ( salaryPeriod . year - 2 ) ) ,
2025-07-11 11:43:38 +07:00
) : "" ;
const yearIncrease2 = salaryPeriod . year ? Extension . ToThaiNumber (
2024-03-22 11:31:56 +07:00
String ( Extension . ToThaiYear ( salaryPeriod . year - 1 ) ) ,
2025-07-11 11:43:38 +07:00
) : "" ;
2024-03-22 17:44:56 +07:00
const fifteenPercent_Group1 =
2024-07-05 15:12:42 +07:00
salaryOrg ? . fifteenPercent == undefined || salaryOrg ? . fifteenPercent == null
2024-03-22 11:31:56 +07:00
? "๐ "
2024-07-05 15:12:42 +07:00
: Extension . ToThaiNumber ( String ( salaryOrg ? . fifteenPercent ) ) ;
2024-03-22 17:44:56 +07:00
const fifteenPoint_Group1 =
2024-07-05 15:12:42 +07:00
salaryOrg ? . fifteenPoint == undefined || salaryOrg ? . fifteenPoint == null
2024-03-22 11:31:56 +07:00
? ".๐ ๐ "
2024-07-05 15:12:42 +07:00
: "." + Extension . ToThaiNumber ( String ( salaryOrg ? . fifteenPoint ) ) ;
2024-03-22 17:44:56 +07:00
const fifteenPercent_Group2 =
2024-07-05 15:12:42 +07:00
salaryOrg ? . fifteenPercent == undefined || salaryOrg ? . fifteenPercent == null
2024-03-22 17:44:56 +07:00
? "๐ "
2024-07-05 15:12:42 +07:00
: Extension . ToThaiNumber ( String ( salaryOrg ? . fifteenPercent ) ) ;
2024-03-22 17:44:56 +07:00
const fifteenPoint_Group2 =
2024-07-05 15:12:42 +07:00
salaryOrg ? . fifteenPoint == undefined || salaryOrg ? . fifteenPoint == null
2024-03-22 17:44:56 +07:00
? ".๐ ๐ "
2024-07-05 15:12:42 +07:00
: "." + Extension . ToThaiNumber ( String ( salaryOrg ? . fifteenPoint ) ) ;
2024-03-21 18:18:50 +07:00
return new HttpSuccess ( {
template : "gov1-03" ,
reportName : "gov1-03" ,
data : {
year : year ,
yearIncrease1 : yearIncrease1 ,
yearIncrease2 : yearIncrease2 ,
2025-07-11 11:43:38 +07:00
yearIncreaseSlice : yearIncrease2?yearIncrease2.slice ( - 2 ) : "" ,
yearSlice : year?year.slice ( - 2 ) : "" ,
2024-03-22 17:44:56 +07:00
point : fifteenPercent_Group1 + fifteenPoint_Group1 ,
pointGroup2 : fifteenPercent_Group2 + fifteenPoint_Group2 ,
2024-07-05 15:12:42 +07:00
root : salaryOrg?.root ,
2024-06-27 14:06:55 +07:00
profile : salaryProfileGroup1
? salaryProfileGroup1 . map ( ( item : any , index : any ) = > ( {
no : Extension.ToThaiNumber ( String ( index + 1 ) ) ,
2024-07-05 11:25:35 +07:00
affiliation :
2025-04-04 13:45:33 +07:00
( item . child4 == undefined && item . child4 == null ? "" : item . child4 + "\n" ) +
( item . child3 == undefined && item . child3 == null ? "" : item . child3 + "\n" ) +
( item . child2 == undefined && item . child2 == null ? "" : item . child2 + "\n" ) +
( item . child1 == undefined && item . child1 == null ? "" : item . child1 + "\n" ) +
2024-07-05 11:25:35 +07:00
( item . root == undefined && item . root == null ? "" : item . root ) ,
// สังกัด
fullName : item.prefix + item . firstName + " " + item . lastName ,
2024-06-27 14:06:55 +07:00
posLevel : item.posLevel ,
posMasterNo :
Extension . ToThaiNumber ( item . orgShortName ) +
2025-04-05 18:12:02 +07:00
" " +
2024-06-27 14:06:55 +07:00
Extension . ToThaiNumber ( String ( item . posMasterNo . toLocaleString ( ) ) ) ,
amount :
item . amount == undefined || item . amount == null
? "๐ "
: Extension . ToThaiNumber ( String ( item . amount . toLocaleString ( ) ) ) ,
salaryIncrease1 :
2024-07-05 15:12:42 +07:00
salaryProfile1 . length > 0
2024-06-27 14:06:55 +07:00
? ( ( ) = > {
2024-07-05 15:12:42 +07:00
const filteredType = salaryProfile1
2024-06-27 14:06:55 +07:00
. filter ( ( profile ) = > profile . citizenId === item . citizenId )
. map ( ( profile ) = > profile . type ) ;
const Type = filteredType [ 0 ] ;
return Type === "HAFT"
? "ครึ่งขั้น"
: Type === "FULL"
? "หนึ่งขั้น"
: "ไม่ได้เลื่อนขั้น" ;
} ) ( )
2025-02-04 15:27:05 +07:00
: "-" , //การเลื่อนเงินเดือนปีก่อนๆหน้า
2024-06-27 14:06:55 +07:00
salaryIncrease2 :
2024-07-05 15:12:42 +07:00
salaryProfile2 . length > 0
2024-06-27 14:06:55 +07:00
? ( ( ) = > {
2024-07-05 15:12:42 +07:00
const filteredType = salaryProfile2
2024-06-27 14:06:55 +07:00
. filter ( ( profile ) = > profile . citizenId === item . citizenId )
. map ( ( profile ) = > profile . type ) ;
const Type = filteredType [ 0 ] ;
return Type === "HAFT"
? "ครึ่งขั้น"
: Type === "FULL"
? "หนึ่งขั้น"
: "ไม่ได้เลื่อนขั้น" ;
} ) ( )
2025-02-04 15:27:05 +07:00
: "-" , //การเลื่อนเงินเดือนปีก่อนหน้า
2024-07-08 09:21:24 +07:00
score : item.result , //ผลการประเมินฯ
remark : item.remark , //หมายเหตุ
2024-06-27 14:06:55 +07:00
} ) )
: null ,
2025-06-27 13:51:38 +07:00
// profileGroup2: salaryProfileGroup2
// ? salaryProfileGroup2.map((item: any, index: any) => ({
// no: Extension.ToThaiNumber(String(index + 1)),
// affiliation:
// (item.child4 == undefined && item.child4 == null ? "" : item.child4 + "\n") +
// (item.child3 == undefined && item.child3 == null ? "" : item.child3 + "\n") +
// (item.child2 == undefined && item.child2 == null ? "" : item.child2 + "\n") +
// (item.child1 == undefined && item.child1 == null ? "" : item.child1 + "\n") +
// (item.root == undefined && item.root == null ? "" : item.root),
// // สังกัด/ชื่อ-นามสกุล
// fullName: item.prefix + item.firstName + " " + item.lastName,
// posLevel: item.posLevel,
// posMasterNo:
// Extension.ToThaiNumber(item.orgShortName) +
// " " +
// Extension.ToThaiNumber(String(item.posMasterNo.toLocaleString())),
// amount:
// item.amount == undefined || item.amount == null
// ? "๐ "
// : Extension.ToThaiNumber(String(item.amount.toLocaleString())),
// salaryIncrease1:
// salaryProfile1.length > 0
// ? (() => {
// const filteredType = salaryProfile1
// .filter((profile) => profile.citizenId === item.citizenId)
// .map((profile) => profile.type);
// const Type = filteredType[0];
// return Type === "HAFT"
// ? "ครึ่งขั้น"
// : Type === "FULL"
// ? "หนึ่งขั้น"
// : "ไม่ได้เลื่อนขั้น";
// })()
// : "-", //การเลื่อนเงินเดือนปีก่อนๆหน้า
// salaryIncrease2:
// salaryProfile2.length > 0
// ? (() => {
// const filteredType = salaryProfile2
// .filter((profile) => profile.citizenId === item.citizenId)
// .map((profile) => profile.type);
// const Type = filteredType[0];
// return Type === "HAFT"
// ? "ครึ่งขั้น"
// : Type === "FULL"
// ? "หนึ่งขั้น"
// : "ไม่ได้เลื่อนขั้น";
// })()
// : "-", //การเลื่อนเงินเดือนปีก่อนหน้า
// score: item.result, //ผลการประเมินฯ
// remark: item.remark, //หมายเหตุ
// }))
// : null,
2024-06-27 14:06:55 +07:00
} ,
2024-03-21 18:18:50 +07:00
} ) ;
2025-06-27 13:51:38 +07:00
//รอบตุลา
2025-07-11 11:43:38 +07:00
} else if ( salaryPeriod . period === "OCT" ) {
2024-03-22 17:44:56 +07:00
// find period APR
2024-03-21 18:18:50 +07:00
const salaryPeriod_APR = await this . salaryPeriodRepository . findOne ( {
where : {
period : "APR" ,
year : salaryPeriod?.year ,
isActive : true ,
} ,
} ) ;
2024-07-05 15:12:42 +07:00
const salaryOrg_APR = await this . salaryOrgRepository . findOne ( {
2024-03-21 18:18:50 +07:00
where : {
salaryPeriodId : salaryPeriod_APR?.id ,
rootId : rootId ,
2024-07-03 18:00:49 +07:00
snapshot : "SNAP1" ,
2024-07-05 15:12:42 +07:00
group : convertGroup ,
2024-03-22 11:31:56 +07:00
} ,
2024-03-21 18:18:50 +07:00
} ) ;
2025-07-11 11:43:38 +07:00
2024-07-05 15:12:42 +07:00
const salaryProfile_APR = await this . salaryProfileRepository . find ( {
2024-03-21 18:18:50 +07:00
where : {
2024-07-05 15:12:42 +07:00
salaryOrgId : salaryOrg_APR?.id ,
2025-02-03 15:47:29 +07:00
type : Not ( In ( [ "NONE" , "PENDING" ] ) ) ,
2024-03-22 11:31:56 +07:00
} ,
2024-03-21 18:18:50 +07:00
} ) ;
//end period APR
2024-03-18 13:07:09 +07:00
2025-02-03 15:47:29 +07:00
const salaryProfile_current = await this . salaryProfileRepository . find ( {
2024-03-22 17:44:56 +07:00
where : {
2024-07-05 15:12:42 +07:00
salaryOrgId : salaryOrg?.id ,
2024-03-22 11:31:56 +07:00
type : In ( [ "FULLHAFT" , "FULL" ] ) ,
} ,
2024-03-21 18:18:50 +07:00
} ) ;
2025-02-03 15:47:29 +07:00
// const salaryProfileGroup2 = await this.salaryProfileRepository.find({
// where: {
// salaryOrgId: salaryOrg?.id,
// type: In(["FULLHAFT", "FULL"]),
// },
// });
2024-03-22 11:31:56 +07:00
2024-03-21 18:18:50 +07:00
//รอบปีก่อนๆ
const salaryPeriodIncrease1_APR = await this . salaryPeriodRepository . findOne ( {
where : {
period : "APR" ,
year : salaryPeriod.year - 2 ,
isActive : true ,
} ,
} ) ;
const salaryPeriodIncrease1_OCT = await this . salaryPeriodRepository . findOne ( {
where : {
period : "OCT" ,
year : salaryPeriod.year - 2 ,
isActive : true ,
} ,
} ) ;
2025-01-29 15:21:47 +07:00
let salaryOrg1_APR = null ;
2025-02-03 15:47:29 +07:00
if ( salaryPeriodIncrease1_APR ) {
salaryOrg1_APR = await this . salaryOrgRepository . findOne ( {
2025-01-29 15:21:47 +07:00
where : {
salaryPeriodId : salaryPeriodIncrease1_APR?.id ,
// rootId: rootId,
2025-07-11 11:43:38 +07:00
root : salaryOrg?.root ,
2025-01-29 15:21:47 +07:00
snapshot : "SNAP1" ,
group : convertGroup ,
} ,
} ) ;
}
2025-02-03 15:47:29 +07:00
2025-01-29 15:21:47 +07:00
let salaryOrg1_OCT = null ;
2025-02-03 15:47:29 +07:00
if ( salaryPeriodIncrease1_OCT ) {
salaryOrg1_OCT = await this . salaryOrgRepository . findOne ( {
where : {
salaryPeriodId : salaryPeriodIncrease1_OCT?.id ,
// rootId: rootId,
2025-07-11 11:43:38 +07:00
root : salaryOrg?.root ,
2025-02-03 15:47:29 +07:00
snapshot : "SNAP1" ,
group : convertGroup ,
} ,
} ) ;
2025-01-29 15:21:47 +07:00
}
2024-07-05 15:12:42 +07:00
const salaryProfile1 = await this . salaryProfileRepository . find ( {
2024-03-21 18:18:50 +07:00
where : {
2024-07-05 15:12:42 +07:00
salaryOrgId : In ( [ salaryOrg1_APR ? . id , salaryOrg1_OCT ? . id ] ) ,
2025-02-03 15:47:29 +07:00
type : Not ( In ( [ "NONE" , "PENDING" ] ) ) ,
2024-03-21 18:18:50 +07:00
} ,
} ) ;
2024-03-22 17:44:56 +07:00
2024-03-21 18:18:50 +07:00
//รอบปีก่อนหน้า
const salaryPeriodIncrease2_APR = await this . salaryPeriodRepository . findOne ( {
where : {
period : "APR" ,
year : salaryPeriod.year - 1 ,
isActive : true ,
} ,
} ) ;
const salaryPeriodIncrease2_OCT = await this . salaryPeriodRepository . findOne ( {
where : {
period : "OCT" ,
year : salaryPeriod.year - 1 ,
isActive : true ,
} ,
} ) ;
2025-01-29 15:21:47 +07:00
let salaryOrg2_APR = null ;
2025-02-03 15:47:29 +07:00
if ( salaryPeriodIncrease2_APR ) {
salaryOrg2_APR = await this . salaryOrgRepository . findOne ( {
2025-01-29 15:21:47 +07:00
where : {
salaryPeriodId : salaryPeriodIncrease2_APR?.id ,
// rootId: rootId,
2025-07-11 11:43:38 +07:00
root : salaryOrg?.root ,
2025-01-29 15:21:47 +07:00
snapshot : "SNAP1" ,
group : convertGroup ,
} ,
} ) ;
}
2024-07-08 09:21:24 +07:00
2025-01-29 15:21:47 +07:00
let salaryOrg2_OCT = null ;
2025-02-03 15:47:29 +07:00
if ( salaryPeriodIncrease2_OCT ) {
2025-01-29 15:21:47 +07:00
salaryOrg2_OCT = await this . salaryOrgRepository . findOne ( {
where : {
salaryPeriodId : salaryPeriodIncrease2_OCT?.id ,
// rootId: rootId,
2025-07-11 11:43:38 +07:00
root : salaryOrg?.root ,
2025-01-29 15:21:47 +07:00
snapshot : "SNAP1" ,
group : convertGroup ,
} ,
} ) ;
}
2024-07-05 15:12:42 +07:00
const salaryProfile2 = await this . salaryProfileRepository . find ( {
2025-02-03 15:47:29 +07:00
//เอามาหาว่าทั้งปีได้เลื่อนขั้นไหม
2024-03-21 18:18:50 +07:00
where : {
2024-07-05 15:12:42 +07:00
salaryOrgId : In ( [ salaryOrg2_APR ? . id , salaryOrg2_OCT ? . id ] ) ,
2025-02-03 15:47:29 +07:00
type : Not ( In ( [ "NONE" , "PENDING" ] ) ) ,
2024-03-21 18:18:50 +07:00
} ,
} ) ;
2025-07-11 11:43:38 +07:00
const year = salaryPeriod . year ? Extension . ToThaiNumber ( String ( Extension . ToThaiYear ( salaryPeriod . year ) ) ) : "" ;
const yearIncrease1 = salaryPeriod . year ? Extension . ToThaiNumber (
2024-03-22 11:31:56 +07:00
String ( Extension . ToThaiYear ( salaryPeriod . year - 2 ) ) ,
2025-07-11 11:43:38 +07:00
) : "" ;
const yearIncrease2 = salaryPeriod . year ? Extension . ToThaiNumber (
2024-03-22 11:31:56 +07:00
String ( Extension . ToThaiYear ( salaryPeriod . year - 1 ) ) ,
2025-07-11 11:43:38 +07:00
) : "" ;
2024-03-22 11:31:56 +07:00
const fifteenPercent =
2024-07-05 15:12:42 +07:00
salaryOrg ? . fifteenPercent == undefined || salaryOrg ? . fifteenPercent == null
2024-03-22 11:31:56 +07:00
? "๐ "
2024-07-05 15:12:42 +07:00
: Extension . ToThaiNumber ( String ( salaryOrg ? . fifteenPercent ) ) ;
2024-03-22 11:31:56 +07:00
const fifteenPoint =
2024-07-05 15:12:42 +07:00
salaryOrg ? . fifteenPoint == undefined || salaryOrg ? . fifteenPoint == null
2024-03-22 11:31:56 +07:00
? ".๐ ๐ "
2024-07-05 15:12:42 +07:00
: "." + Extension . ToThaiNumber ( String ( salaryOrg ? . fifteenPoint ) ) ;
2024-03-22 17:44:56 +07:00
const fifteenPercent_Group2 =
2024-07-05 15:12:42 +07:00
salaryOrg ? . fifteenPercent == undefined || salaryOrg ? . fifteenPercent == null
2024-03-22 17:44:56 +07:00
? "๐ "
2024-07-05 15:12:42 +07:00
: Extension . ToThaiNumber ( String ( salaryOrg ? . fifteenPercent ) ) ;
2024-03-22 18:04:20 +07:00
const fifteenPoint_Group2 =
2024-07-05 15:12:42 +07:00
salaryOrg ? . fifteenPoint == undefined || salaryOrg ? . fifteenPoint == null
2024-03-22 18:04:20 +07:00
? ".๐ ๐ "
2024-07-05 15:12:42 +07:00
: "." + Extension . ToThaiNumber ( String ( salaryOrg ? . fifteenPoint ) ) ;
2024-03-21 18:18:50 +07:00
return new HttpSuccess ( {
template : "gov2-03" ,
reportName : "gov2-03" ,
data : {
year : year ,
yearIncrease1 : yearIncrease1 ,
yearIncrease2 : yearIncrease2 ,
2025-07-11 11:43:38 +07:00
yearIncreaseSlice : yearIncrease2?yearIncrease2.slice ( - 2 ) : "" ,
yearSlice : year?year.slice ( - 2 ) : "" ,
2024-03-21 18:18:50 +07:00
point : fifteenPercent + fifteenPoint ,
2024-03-22 17:44:56 +07:00
pointGroup2 : fifteenPercent_Group2 + fifteenPoint_Group2 ,
2024-07-05 15:12:42 +07:00
root : salaryOrg?.root ,
2025-02-03 15:47:29 +07:00
profile : salaryProfile_current
? salaryProfile_current
. filter ( ( item : any ) = >
2025-06-27 13:51:38 +07:00
salaryProfile_APR . some ( ( x : any ) = >
x . citizenId === item . citizenId &&
(
x . type === "HAFT" && [ "FULLHAFT" ] . includes ( item . type ) ||
x . type === "FULL" && [ "FULL" , "FULLHAFT" ] . includes ( item . type )
)
)
2025-02-03 15:47:29 +07:00
)
. map ( ( item : any , index : any ) = > ( {
no : Extension.ToThaiNumber ( String ( index + 1 ) ) ,
affiliation :
2025-04-04 13:45:33 +07:00
( item . child4 == undefined && item . child4 == null ? "" : item . child4 + "\n" ) +
( item . child3 == undefined && item . child3 == null ? "" : item . child3 + "\n" ) +
( item . child2 == undefined && item . child2 == null ? "" : item . child2 + "\n" ) +
( item . child1 == undefined && item . child1 == null ? "" : item . child1 + "\n" ) +
2025-02-03 15:47:29 +07:00
( item . root == undefined && item . root == null ? "" : item . root ) ,
fullName : item.prefix + item . firstName + " " + item . lastName ,
posLevel : item.posLevel ,
posMasterNo :
Extension . ToThaiNumber ( item . orgShortName ) +
2025-04-05 18:12:02 +07:00
" " +
2025-02-03 15:47:29 +07:00
Extension . ToThaiNumber ( String ( item . posMasterNo . toLocaleString ( ) ) ) ,
amount :
item . amount == undefined || item . amount == null
? "๐ "
: Extension . ToThaiNumber ( String ( item . amount . toLocaleString ( ) ) ) ,
salaryIncrease1 :
salaryProfile1 . length > 0
? ( ( ) = > {
const filteredType = salaryProfile1
. filter ( ( profile ) = > profile . citizenId === item . citizenId )
. map ( ( profile ) = > profile . type ) ;
const Type = filteredType [ 0 ] ;
return Type === "HAFT"
? "ครึ่งขั้น"
: Type === "FULL"
? "หนึ่งขั้น"
: Type === "FULLHAFT"
? "หนึ่งขั้นครึ่ง"
: "ไม่ได้เลื่อนขั้น" ;
} ) ( )
2025-02-04 15:27:05 +07:00
: "-" , //การเลื่อนเงินเดือนปีก่อนๆหน้า
2025-02-03 15:47:29 +07:00
salaryIncrease2 :
salaryProfile2 . length > 0
? ( ( ) = > {
const filteredType = salaryProfile2
. filter ( ( profile ) = > profile . citizenId === item . citizenId )
. map ( ( profile ) = > profile . type ) ;
const Type = filteredType [ 0 ] ;
return Type === "HAFT"
? "ครึ่งขั้น"
: Type === "FULL"
? "หนึ่งขั้น"
: Type === "FULLHAFT"
? "หนึ่งขั้นครึ่ง"
: "ไม่ได้เลื่อนขั้น" ;
} ) ( )
2025-02-04 15:27:05 +07:00
: "-" , //การเลื่อนเงินเดือนปีก่อนหน้า
2025-02-03 15:47:29 +07:00
salaryIncreaseAPR :
salaryProfile_APR . length > 0
? ( ( ) = > {
const filteredType = salaryProfile_APR
. filter ( ( profile ) = > profile . citizenId === item . citizenId )
. map ( ( profile ) = > profile . type ) ;
const Type = filteredType [ 0 ] ;
return Type === "HAFT"
? "ครึ่งขั้น"
: Type === "FULL"
? "หนึ่งขั้น"
: Type === "FULLHAFT"
? "หนึ่งขั้นครึ่ง"
: "ไม่ได้เลื่อนขั้น" ;
} ) ( )
2025-02-04 15:27:05 +07:00
: "-" , //การเลื่อนเงินเดือนรอบเมษา
2025-02-03 15:47:29 +07:00
Type :
item . type === "FULL"
? "หนึ่งขั้น"
: item . type === "FULLHAFT"
? "หนึ่งขั้นครึ่ง"
2025-02-04 15:27:05 +07:00
: "-" ,
2025-02-21 19:00:24 +07:00
score1 : item.result ? ? "-" , //ผลการประเมินฯ ครั้งที่ 1
2025-02-04 15:27:05 +07:00
score2 : "-" , //ผลการประเมินฯ ครั้งที่ 2
2025-02-03 15:47:29 +07:00
} ) )
2024-07-02 15:25:34 +07:00
: null ,
2025-06-27 13:51:38 +07:00
// profileGroup2: salaryProfile_current
// ? salaryProfile_current
// .filter((item: any) =>
// salaryProfile_APR.some((x: any) => x.citizenId === item.citizenId),
// )
// .map((item: any, index: any) => ({
// no: Extension.ToThaiNumber(String(index + 1)),
// affiliation:
// (item.child4 == undefined && item.child4 == null ? "" : item.child4 + "\n") +
// (item.child3 == undefined && item.child3 == null ? "" : item.child3 + "\n") +
// (item.child2 == undefined && item.child2 == null ? "" : item.child2 + "\n") +
// (item.child1 == undefined && item.child1 == null ? "" : item.child1 + "\n") +
// (item.root == undefined && item.root == null ? "" : item.root),
// fullName: item.prefix + item.firstName + " " + item.lastName,
// posLevel: item.posLevel,
// posMasterNo:
// Extension.ToThaiNumber(item.orgShortName) +
// " " +
// Extension.ToThaiNumber(String(item.posMasterNo.toLocaleString())),
// amount:
// item.amount == undefined || item.amount == null
// ? "๐ "
// : Extension.ToThaiNumber(String(item.amount.toLocaleString())),
// salaryIncrease1:
// salaryProfile1.length > 0
// ? (() => {
// const filteredType = salaryProfile1
// .filter((profile) => profile.citizenId === item.citizenId)
// .map((profile) => profile.type);
// const Type = filteredType[0];
// return Type === "HAFT"
// ? "ครึ่งขั้น"
// : Type === "FULL"
// ? "หนึ่งขั้น"
// : Type === "FULLHAFT"
// ? "หนึ่งขั้นครึ่ง"
// : "ไม่ได้เลื่อนขั้น";
// })()
// : "-", //การเลื่อนเงินเดือนปีก่อนๆหน้า
// salaryIncrease2:
// salaryProfile2.length > 0
// ? (() => {
// const filteredType = salaryProfile2
// .filter((profile) => profile.citizenId === item.citizenId)
// .map((profile) => profile.type);
// const Type = filteredType[0];
// return Type === "HAFT"
// ? "ครึ่งขั้น"
// : Type === "FULL"
// ? "หนึ่งขั้น"
// : Type === "FULLHAFT"
// ? "หนึ่งขั้นครึ่ง"
// : "ไม่ได้เลื่อนขั้น";
// })()
// : "-", //การเลื่อนเงินเดือนปีก่อนหน้า
// salaryIncreaseAPR:
// salaryProfile_APR.length > 0
// ? (() => {
// const filteredType = salaryProfile_APR
// .filter((profile) => profile.citizenId === item.citizenId)
// .map((profile) => profile.type);
// const Type = filteredType[0];
// return Type === "HAFT"
// ? "ครึ่งขั้น"
// : Type === "FULL"
// ? "หนึ่งขั้น"
// : Type === "FULLHAFT"
// ? "หนึ่งขั้นครึ่ง"
// : "ไม่ได้เลื่อนขั้น";
// })()
// : "-", //การเลื่อนเงินเดือนรอบเมษา
// Type:
// item.type === "FULL"
// ? "หนึ่งขั้น"
// : item.type === "FULLHAFT"
// ? "หนึ่งขั้นครึ่ง"
// : "-",
// score1: item.result ?? "-", //ผลการประเมินฯ ครั้งที่ 1
// score2: "-", //ผลการประเมินฯ ครั้งที่ 2
// }))
// : null,
2024-03-21 18:18:50 +07:00
} ,
} ) ;
}
2024-03-18 13:07:09 +07:00
}
2024-03-21 09:51:42 +07:00
/ * *
2024-03-27 15:30:41 +07:00
* API แ บ บ 1 ก ท บ ั ญ ช ี ร า ย ช ื ่ อ ผ ู ้ ส ม ค ว ร ไ ด ้ เ ล ื ่ อ น เ ง ิ น เ ด ื อ น ร อ บ เ ม ษ า ย น แ ล ะ ต ุ ล า ค ม
2024-03-18 13:07:09 +07:00
*
2024-03-27 15:30:41 +07:00
* @summary แ บ บ 1 ก ท บ ั ญ ช ี ร า ย ช ื ่ อ ผ ู ้ ส ม ค ว ร ไ ด ้ เ ล ื ่ อ น เ ง ิ น เ ด ื อ น ร อ บ เ ม ษ า ย น แ ล ะ ต ุ ล า ค ม
2024-03-18 13:07:09 +07:00
*
* @param { string } rootId Guid , * Id Root
* @param { string } salaryPeriodId Guid , * Id Period
* /
2025-06-25 17:31:26 +07:00
@Get ( "gov-04/{rootId}/{salaryPeriodId}/{group}/{type}" )
2024-07-05 11:25:35 +07:00
async SalaryReport4 (
@Path ( ) rootId : string ,
@Path ( ) salaryPeriodId : string ,
@Path ( ) group : string ,
2025-06-25 17:31:26 +07:00
@Path ( ) type : string = 'ALL'
2024-07-05 11:25:35 +07:00
) {
2024-03-21 09:51:42 +07:00
const salaryPeriod = await this . salaryPeriodRepository . findOne ( {
where : {
id : salaryPeriodId ,
} ,
} ) ;
if ( ! salaryPeriod ) {
throw new HttpError ( HttpStatusCode . NOT_FOUND , "ไม่พบรอบการขึ้นเงินเดือน" ) ;
}
2024-07-05 11:25:35 +07:00
const convertGroup = group . toUpperCase ( ) ;
2025-06-25 17:31:26 +07:00
let condition : any = {
salaryOrg : {
snapshot : "SNAP2" ,
rootId : rootId ,
group : convertGroup ,
salaryPeriodId : salaryPeriodId ,
} ,
} ;
// condition.type = In(["HAFT", "FULL", "FULLHAFT"]);
condition . isRetired = salaryPeriod . period === "APR" ? In ( [ true , false ] ) : false ; //กรองเฉพาะคนที่ไม่เกษียณเฉพาะรอบตุลา
if ( salaryPeriod . period == "APR" ) {
if ( type == "HAFT" ) {
condition . type = "HAFT" ;
} else if ( type == "FULL" ) {
condition . type = "FULL" ;
}
} else {
if ( type == "HAFT" ) {
condition . type = "HAFT" ;
} else if ( type == "FULL" ) {
condition . type = "FULL" ;
} else if ( type == "FULLHAFT" ) {
condition . type = "FULLHAFT" ;
}
}
2024-03-21 10:25:48 +07:00
const _salaryPeriod = await this . salaryProfileRepository . find ( {
relations : [ "salaryOrg" , "salaryOrg.salaryPeriod" ] ,
2025-06-25 17:31:26 +07:00
where : condition ,
2024-03-21 09:51:42 +07:00
order : {
salaryOrg : {
group : "ASC" ,
} ,
type : "DESC" ,
2024-03-21 10:25:48 +07:00
orgShortName : "ASC" ,
2024-03-21 09:51:42 +07:00
posMasterNo : "ASC" ,
} ,
} ) ;
2024-04-05 16:35:18 +07:00
const _root = await this . salaryOrgRepository . findOne ( {
where : {
rootId : rootId ,
salaryPeriodId : salaryPeriodId ,
2024-04-09 09:25:55 +07:00
} ,
} ) ;
2024-04-05 16:35:18 +07:00
const root = _root ? . root == null ? "" : _root . root ;
// const agency = _salaryPeriod[0] == null ? "" : _salaryPeriod[0].root;
2024-03-21 10:25:48 +07:00
const formattedData = _salaryPeriod . map ( ( profile , index ) = > {
return {
no : Extension.ToThaiNumber ( String ( index + 1 ) ) ,
fullname : profile.prefix + profile . firstName + " " + profile . lastName ,
log_group : profile.salaryOrg.group ,
log_type : profile.type ,
log_isNext : profile.isNext ,
2024-07-05 11:25:35 +07:00
// position:
// profile.position +
2025-01-29 10:13:43 +07:00
// " " +
// (profile.child4 == undefined && profile.child4 == null ? "" : profile.child4 + " ") +
// (profile.child3 == undefined && profile.child3 == null ? "" : profile.child3 + " ") +
// (profile.child2 == undefined && profile.child2 == null ? "" : profile.child2 + " ") +
// (profile.child1 == undefined && profile.child1 == null ? "" : profile.child1 + " ") +
2024-07-05 11:25:35 +07:00
// (profile.root == undefined && profile.root == null ? "" : profile.root),
2025-04-05 18:12:02 +07:00
position :
2025-06-17 18:17:49 +07:00
( profile . position ? profile . position : "-" ) +
( profile . posExecutive
? ` \ n ${ profile . positionExecutiveField ? ` ${ profile . posExecutive } ( ${ profile . positionExecutiveField } ) ` : profile . posExecutive } `
: "" ) ,
2024-07-05 11:25:35 +07:00
affiliation :
2025-04-04 13:45:33 +07:00
( profile . child4 == undefined && profile . child4 == null ? "" : profile . child4 + "\n" ) +
( profile . child3 == undefined && profile . child3 == null ? "" : profile . child3 + "\n" ) +
( profile . child2 == undefined && profile . child2 == null ? "" : profile . child2 + "\n" ) +
( profile . child1 == undefined && profile . child1 == null ? "" : profile . child1 + "\n" ) +
2024-03-21 10:25:48 +07:00
( profile . root == undefined && profile . root == null ? "" : profile . root ) ,
posLevel : profile.posLevel ,
2024-04-09 09:25:55 +07:00
orgShortName :
Extension . ToThaiNumber ( profile . orgShortName ) +
2025-04-05 18:12:02 +07:00
" " +
2024-04-09 09:25:55 +07:00
Extension . ToThaiNumber ( String ( profile . posMasterNo . toLocaleString ( ) ) ) ,
2024-03-21 10:25:48 +07:00
amount :
profile . amount == undefined || profile . amount == null || profile . amount == 0
? ""
2024-04-01 14:11:06 +07:00
: Extension . ToThaiNumber ( String ( profile . amount . toLocaleString ( ) ) ) ,
2024-03-21 10:25:48 +07:00
amountSpecial :
( profile . positionSalaryAmount == undefined ||
profile . positionSalaryAmount == null ||
profile . positionSalaryAmount == 0
? ""
2024-04-01 14:11:06 +07:00
: Extension . ToThaiNumber ( String ( profile . positionSalaryAmount . toLocaleString ( ) ) ) ) +
2024-03-21 10:25:48 +07:00
( profile . amountSpecial == undefined ||
profile . amountSpecial == null ||
profile . amountSpecial == 0
? ""
2024-04-01 14:11:06 +07:00
: ` ( ${ Extension . ToThaiNumber ( String ( profile . amountSpecial . toLocaleString ( ) ) ) } ) ` ) ,
#1002,#1004,#1006,#1008,#1013,#1015,#1024,#1028,#1036,#1038,#1044,#1047,#1050
2025-01-27 17:14:13 +07:00
score : profile.result ? Extension . ToThaiNumber ( profile . result ) : "-" , //สรุปผลการประเมินฯ ระดับและคะแนน
2024-03-21 10:25:48 +07:00
remark :
` ${ profile . type === "FULL" ? "หนึ่งขั้น" : "" } \ n ` +
` ${ profile . type === "FULLHAFT" ? "หนึ่งขั้นครึ่ง" : "" } \ n ` +
` ${ profile . amountSpecial > 0 ? "ได้รับค่าตอบแทนพิเศษ\n" : "" } ` +
` ${ profile . isNext === true ? "(ได้รับเงินเดือนสูงกว่าขั้นสูงฯ)" : "" } ` , // หมายเหตุ
} ;
} ) ;
2024-03-21 09:51:42 +07:00
return new HttpSuccess ( {
2024-03-21 10:25:48 +07:00
template : salaryPeriod.period == "APR" ? "gov1-04" : "gov2-04" ,
reportName : salaryPeriod.period == "APR" ? "gov1-04" : "gov2-04" ,
2024-03-21 09:51:42 +07:00
data : {
2024-03-21 10:25:48 +07:00
year : Extension.ToThaiNumber ( String ( Extension . ToThaiYear ( salaryPeriod . year ) ) ) ,
effectiveDate : salaryPeriod.effectiveDate ,
2024-04-05 16:35:18 +07:00
root : root ,
2024-03-21 10:25:48 +07:00
profile : formattedData ,
2024-03-21 09:51:42 +07:00
} ,
} ) ;
}
2024-03-18 13:07:09 +07:00
2024-03-18 16:11:13 +07:00
/ * *
2024-03-27 15:30:41 +07:00
* API แ บ บ 1 ก ท บ ั ญ ช ี ร า ย ช ื ่ อ ผ ู ้ ส ม ค ว ร ไ ด ้ เ ล ื ่ อ น เ ง ิ น เ ด ื อ น ร อ บ เ ม ษ า ย น แ ล ะ ต ุ ล า ค ม ( เ ก ษ ี ย ณ อ า ย ุ ร า ช ก า ร )
2024-03-18 16:11:13 +07:00
*
2024-03-27 15:30:41 +07:00
* @summary แ บ บ 1 ก ท บ ั ญ ช ี ร า ย ช ื ่ อ ผ ู ้ ส ม ค ว ร ไ ด ้ เ ล ื ่ อ น เ ง ิ น เ ด ื อ น ร อ บ เ ม ษ า ย น แ ล ะ ต ุ ล า ค ม ( เ ก ษ ี ย ณ อ า ย ุ ร า ช ก า ร )
*
* @param { string } rootId Guid , * Id Root
* @param { string } salaryPeriodId Guid , * Id Period
* /
2024-07-05 11:25:35 +07:00
@Get ( "gov-04-01/{rootId}/{salaryPeriodId}/{group}" )
2024-07-08 09:21:24 +07:00
async SalaryReport4Retire (
@Path ( ) rootId : string ,
@Path ( ) salaryPeriodId : string ,
@Path ( ) group : string ,
) {
2024-03-27 15:30:41 +07:00
const salaryPeriod = await this . salaryPeriodRepository . findOne ( {
where : {
id : salaryPeriodId ,
} ,
} ) ;
if ( ! salaryPeriod ) {
throw new HttpError ( HttpStatusCode . NOT_FOUND , "ไม่พบรอบการขึ้นเงินเดือน" ) ;
}
2024-07-05 11:25:35 +07:00
const convertGroup = group . toUpperCase ( ) ;
2024-03-27 15:30:41 +07:00
const _salaryPeriod = await this . salaryProfileRepository . find ( {
relations : [ "salaryOrg" , "salaryOrg.salaryPeriod" ] ,
where : {
salaryOrg : {
snapshot : "SNAP2" ,
rootId : rootId ,
2024-07-05 11:25:35 +07:00
group : convertGroup ,
2024-03-27 15:30:41 +07:00
salaryPeriodId : salaryPeriodId ,
} ,
2024-04-09 09:25:55 +07:00
type : In ( [ "HAFT" , "FULL" , "FULLHAFT" ] ) ,
2024-07-03 18:00:49 +07:00
isRetired : true , //กรองเฉพาะคนที่เกษียณ
2024-03-27 15:30:41 +07:00
} ,
order : {
salaryOrg : {
group : "ASC" ,
} ,
type : "DESC" ,
orgShortName : "ASC" ,
posMasterNo : "ASC" ,
} ,
} ) ;
2024-04-05 16:35:18 +07:00
const _root = await this . salaryOrgRepository . findOne ( {
where : {
rootId : rootId ,
2024-07-05 11:25:35 +07:00
group : convertGroup ,
2024-04-05 16:35:18 +07:00
salaryPeriodId : salaryPeriodId ,
2024-04-09 09:25:55 +07:00
} ,
} ) ;
2024-04-05 16:35:18 +07:00
const root = _root ? . root == null ? "" : _root . root ;
// const agency = _salaryPeriod[0] == null ? "" : _salaryPeriod[0].root;
2024-03-27 15:30:41 +07:00
const formattedData = _salaryPeriod . map ( ( profile , index ) = > {
return {
no : Extension.ToThaiNumber ( String ( index + 1 ) ) ,
fullname : profile.prefix + profile . firstName + " " + profile . lastName ,
log_group : profile.salaryOrg.group ,
log_type : profile.type ,
log_isNext : profile.isNext ,
2025-04-05 18:12:02 +07:00
position :
2025-06-17 18:17:49 +07:00
( profile . position ? profile . position : "-" ) +
( profile . posExecutive
? ` \ n ${ profile . positionExecutiveField ? ` ${ profile . posExecutive } ( ${ profile . positionExecutiveField } ) ` : profile . posExecutive } `
: "" ) ,
2024-07-05 11:25:35 +07:00
affiliation :
2025-04-04 13:45:33 +07:00
( profile . child4 == undefined && profile . child4 == null ? "" : profile . child4 + "\n" ) +
( profile . child3 == undefined && profile . child3 == null ? "" : profile . child3 + "\n" ) +
( profile . child2 == undefined && profile . child2 == null ? "" : profile . child2 + "\n" ) +
( profile . child1 == undefined && profile . child1 == null ? "" : profile . child1 + "\n" ) +
2024-03-27 15:30:41 +07:00
( profile . root == undefined && profile . root == null ? "" : profile . root ) ,
posLevel : profile.posLevel ,
2024-04-09 09:25:55 +07:00
orgShortName :
Extension . ToThaiNumber ( profile . orgShortName ) +
2025-04-05 18:12:02 +07:00
" " +
2024-04-09 09:25:55 +07:00
Extension . ToThaiNumber ( String ( profile . posMasterNo . toLocaleString ( ) ) ) ,
2024-03-27 15:30:41 +07:00
amount :
profile . amount == undefined || profile . amount == null || profile . amount == 0
? ""
2024-04-01 14:11:06 +07:00
: Extension . ToThaiNumber ( String ( profile . amount . toLocaleString ( ) ) ) ,
2024-03-27 15:30:41 +07:00
amountSpecial :
( profile . positionSalaryAmount == undefined ||
profile . positionSalaryAmount == null ||
profile . positionSalaryAmount == 0
? ""
2024-04-01 14:11:06 +07:00
: Extension . ToThaiNumber ( String ( profile . positionSalaryAmount . toLocaleString ( ) ) ) ) +
2024-03-27 15:30:41 +07:00
( profile . amountSpecial == undefined ||
profile . amountSpecial == null ||
profile . amountSpecial == 0
? ""
2024-04-01 14:11:06 +07:00
: ` ( ${ Extension . ToThaiNumber ( String ( profile . amountSpecial . toLocaleString ( ) ) ) } ) ` ) ,
#1002,#1004,#1006,#1008,#1013,#1015,#1024,#1028,#1036,#1038,#1044,#1047,#1050
2025-01-27 17:14:13 +07:00
score : profile.result ? Extension . ToThaiNumber ( profile . result ) : "-" , //สรุปผลการประเมินฯ ระดับและคะแนน
2024-03-27 15:30:41 +07:00
remark :
` ${ profile . type === "FULL" ? "หนึ่งขั้น" : "" } \ n ` +
` ${ profile . type === "FULLHAFT" ? "หนึ่งขั้นครึ่ง" : "" } \ n ` +
` ${ profile . amountSpecial > 0 ? "ได้รับค่าตอบแทนพิเศษ\n" : "" } ` +
` ${ profile . isNext === true ? "(ได้รับเงินเดือนสูงกว่าขั้นสูงฯ)" : "" } ` , // หมายเหตุ
} ;
} ) ;
return new HttpSuccess ( {
2024-07-09 00:03:27 +07:00
template : salaryPeriod.period == "APR" ? "gov1-04" : "gov2-04-01" ,
reportName : salaryPeriod.period == "APR" ? "gov1-04" : "gov2-04-01" ,
2024-03-27 15:30:41 +07:00
data : {
year : Extension.ToThaiNumber ( String ( Extension . ToThaiYear ( salaryPeriod . year ) ) ) ,
effectiveDate : salaryPeriod.effectiveDate ,
2024-04-05 16:35:18 +07:00
root : root ,
2024-03-27 15:30:41 +07:00
profile : formattedData ,
} ,
} ) ;
}
/ * *
* API แ บ บ 2 ก ท บ ั ญ ช ี ร า ย ช ื ่ อ ผ ู ้ ไ ม ่ ส ม ค ว ร ไ ด ้ เ ล ื ่ อ น เ ง ิ น เ ด ื อ น ร อ บ เ ม ษ า ย น แ ล ะ ต ุ ล า ค ม
*
* @summary แ บ บ 2 ก ท บ ั ญ ช ี ร า ย ช ื ่ อ ผ ู ้ ไ ม ่ ส ม ค ว ร ไ ด ้ เ ล ื ่ อ น เ ง ิ น เ ด ื อ น ร อ บ เ ม ษ า ย น แ ล ะ ต ุ ล า ค ม
2024-03-18 16:11:13 +07:00
*
* @param { string } rootId Guid , * Id Root
* @param { string } salaryPeriodId Guid , * Id Period
* /
2024-07-05 11:25:35 +07:00
@Get ( "gov-05/{rootId}/{salaryPeriodId}/{group}" )
async SalaryReport5 (
@Path ( ) rootId : string ,
@Path ( ) salaryPeriodId : string ,
@Path ( ) group : string ,
) {
2024-03-18 16:11:13 +07:00
const salaryPeriod = await this . salaryPeriodRepository . findOne ( {
where : {
id : salaryPeriodId ,
} ,
} ) ;
if ( ! salaryPeriod ) {
throw new HttpError ( HttpStatusCode . NOT_FOUND , "ไม่พบรอบการขึ้นเงินเดือน" ) ;
}
2024-07-05 11:25:35 +07:00
const convertGroup = group . toUpperCase ( ) ;
2024-03-21 10:25:48 +07:00
const _salaryPeriod = await this . salaryProfileRepository . find ( {
relations : [ "salaryOrg" , "salaryOrg.salaryPeriod" ] ,
2024-03-18 16:11:13 +07:00
where : {
2024-03-21 10:25:48 +07:00
salaryOrg : {
snapshot : "SNAP2" ,
rootId : rootId ,
2024-07-05 11:25:35 +07:00
group : convertGroup ,
2024-03-21 10:25:48 +07:00
salaryPeriodId : salaryPeriodId ,
} ,
type : "NONE" , //ไม่ได้เลื่อน
2024-04-25 00:53:57 +07:00
isRetired : salaryPeriod.period === "APR" ? In ( [ true , false ] ) : false , //กรองเฉพาะคนที่ไม่เกษียณเฉพาะรอบตุลา
2024-03-27 15:30:41 +07:00
} ,
order : {
salaryOrg : {
group : "ASC" ,
} ,
orgShortName : "ASC" ,
posMasterNo : "ASC" ,
} ,
} ) ;
2024-04-05 16:35:18 +07:00
const _root = await this . salaryOrgRepository . findOne ( {
where : {
rootId : rootId ,
2024-07-05 11:25:35 +07:00
group : convertGroup ,
2024-04-05 16:35:18 +07:00
salaryPeriodId : salaryPeriodId ,
2024-04-09 09:25:55 +07:00
} ,
} ) ;
2024-04-05 16:35:18 +07:00
const root = _root ? . root == null ? "" : _root . root ;
// const agency = _salaryPeriod[0] == null ? "" : _salaryPeriod[0].root;
2024-03-27 15:30:41 +07:00
const formattedData = _salaryPeriod . map ( ( profile , index ) = > {
const fullNameParts = [
profile . child4 ,
profile . child3 ,
profile . child2 ,
profile . child1 ,
profile . root ,
] ;
2024-07-05 11:25:35 +07:00
const affiliation = fullNameParts
2024-03-27 15:30:41 +07:00
. filter ( ( part ) = > part !== undefined && part !== null )
2025-04-04 13:45:33 +07:00
. join ( "\n" ) ;
2024-03-27 15:30:41 +07:00
return {
no : Extension.ToThaiNumber ( ( index + 1 ) . toLocaleString ( ) ) ,
fullname : profile.prefix + profile . firstName + " " + profile . lastName ,
2025-04-05 18:12:02 +07:00
position :
2025-06-17 18:17:49 +07:00
( profile . position ? profile . position : "-" ) +
( profile . posExecutive
? ` \ n ${ profile . positionExecutiveField ? ` ${ profile . posExecutive } ( ${ profile . positionExecutiveField } ) ` : profile . posExecutive } `
: "" ) ,
2024-07-05 11:25:35 +07:00
affiliation : affiliation ,
2024-03-27 15:30:41 +07:00
posLevel : profile.posLevel ,
posNumber :
2024-04-09 09:25:55 +07:00
Extension . ToThaiNumber ( profile . orgShortName ) +
2025-04-05 18:12:02 +07:00
" " +
2024-04-09 09:25:55 +07:00
Extension . ToThaiNumber ( profile . posMasterNo . toLocaleString ( ) ) ,
2024-03-27 15:30:41 +07:00
amount : profile.amount ? Extension . ToThaiNumber ( profile . amount . toLocaleString ( ) ) : null ,
2025-01-24 14:14:14 +07:00
reason : profile.remark , //เหตุผล
#1002,#1004,#1006,#1008,#1013,#1015,#1024,#1028,#1036,#1038,#1044,#1047,#1050
2025-01-27 17:14:13 +07:00
score : profile.result ? Extension . ToThaiNumber ( profile . result ) : "-" , //สรุปผลการประเมินฯ ระดับและคะแนน
2025-01-24 14:14:14 +07:00
remark : null , //หมายเหตุ
2024-03-27 15:30:41 +07:00
} ;
} ) ;
return new HttpSuccess ( {
template : salaryPeriod.period == "APR" ? "gov1-05" : "gov2-05" ,
reportName : salaryPeriod.period == "APR" ? "gov1-05" : "gov2-05" ,
data : {
year : Extension.ToThaiNumber ( String ( Extension . ToThaiYear ( salaryPeriod . year ) ) ) ,
2024-04-05 16:35:18 +07:00
agency : root ,
2024-03-27 15:30:41 +07:00
data : formattedData ,
} ,
} ) ;
}
/ * *
* API แ บ บ 2 ก ท บ ั ญ ช ี ร า ย ช ื ่ อ ผ ู ้ ไ ม ่ ส ม ค ว ร ไ ด ้ เ ล ื ่ อ น เ ง ิ น เ ด ื อ น ร อ บ เ ม ษ า ย น แ ล ะ ต ุ ล า ค ม ( เ ก ษ ี ย ณ อ า ย ุ ร า ช ก า ร )
*
* @summary แ บ บ 2 ก ท บ ั ญ ช ี ร า ย ช ื ่ อ ผ ู ้ ไ ม ่ ส ม ค ว ร ไ ด ้ เ ล ื ่ อ น เ ง ิ น เ ด ื อ น ร อ บ เ ม ษ า ย น แ ล ะ ต ุ ล า ค ม ( เ ก ษ ี ย ณ อ า ย ุ ร า ช ก า ร )
*
* @param { string } rootId Guid , * Id Root
* @param { string } salaryPeriodId Guid , * Id Period
* /
2024-07-05 11:25:35 +07:00
@Get ( "gov-05-01/{rootId}/{salaryPeriodId}/{group}" )
2024-07-08 09:21:24 +07:00
async SalaryReport5retire (
@Path ( ) rootId : string ,
@Path ( ) salaryPeriodId : string ,
@Path ( ) group : string ,
) {
2024-03-27 15:30:41 +07:00
const salaryPeriod = await this . salaryPeriodRepository . findOne ( {
where : {
id : salaryPeriodId ,
} ,
} ) ;
if ( ! salaryPeriod ) {
throw new HttpError ( HttpStatusCode . NOT_FOUND , "ไม่พบรอบการขึ้นเงินเดือน" ) ;
}
2024-07-05 11:25:35 +07:00
const convertGroup = group . toUpperCase ( ) ;
2024-03-27 15:30:41 +07:00
const _salaryPeriod = await this . salaryProfileRepository . find ( {
relations : [ "salaryOrg" , "salaryOrg.salaryPeriod" ] ,
where : {
salaryOrg : {
snapshot : "SNAP2" ,
rootId : rootId ,
2024-07-05 11:25:35 +07:00
group : convertGroup ,
2024-03-27 15:30:41 +07:00
salaryPeriodId : salaryPeriodId ,
} ,
type : "NONE" , //ไม่ได้เลื่อน
2024-04-05 16:35:18 +07:00
isRetired : true , //กรองเฉพาะคนที่เกษียณ
2024-03-18 16:11:13 +07:00
} ,
order : {
2024-03-21 10:25:48 +07:00
salaryOrg : {
group : "ASC" ,
} ,
orgShortName : "ASC" ,
posMasterNo : "ASC" ,
2024-03-18 16:11:13 +07:00
} ,
} ) ;
2024-04-05 16:35:18 +07:00
const _root = await this . salaryOrgRepository . findOne ( {
where : {
rootId : rootId ,
2024-07-05 11:25:35 +07:00
group : convertGroup ,
2024-04-05 16:35:18 +07:00
salaryPeriodId : salaryPeriodId ,
2024-04-09 09:25:55 +07:00
} ,
} ) ;
2024-04-05 16:35:18 +07:00
const root = _root ? . root == null ? "" : _root . root ;
// const agency = _salaryPeriod[0] == null ? "" : _salaryPeriod[0].root;
2024-03-18 16:11:13 +07:00
2024-03-21 10:25:48 +07:00
const formattedData = _salaryPeriod . map ( ( profile , index ) = > {
const fullNameParts = [
profile . child4 ,
profile . child3 ,
profile . child2 ,
profile . child1 ,
profile . root ,
] ;
2024-07-05 11:25:35 +07:00
const affiliation = fullNameParts
2024-03-21 10:25:48 +07:00
. filter ( ( part ) = > part !== undefined && part !== null )
2025-04-04 13:45:33 +07:00
. join ( "\n" ) ;
2024-03-21 10:25:48 +07:00
return {
no : Extension.ToThaiNumber ( ( index + 1 ) . toLocaleString ( ) ) ,
fullname : profile.prefix + profile . firstName + " " + profile . lastName ,
2025-04-05 18:12:02 +07:00
position :
2025-06-17 18:17:49 +07:00
( profile . position ? profile . position : "-" ) +
( profile . posExecutive
? ` \ n ${ profile . positionExecutiveField ? ` ${ profile . posExecutive } ( ${ profile . positionExecutiveField } ) ` : profile . posExecutive } `
: "" ) ,
2024-07-05 11:25:35 +07:00
affiliation : affiliation ,
2024-03-21 10:25:48 +07:00
posLevel : profile.posLevel ,
2025-02-03 15:47:29 +07:00
posNumber :
profile . orgShortName || profile . posMasterNo
? Extension . ToThaiNumber ( profile . orgShortName ) +
2025-04-05 18:12:02 +07:00
" " +
2025-02-03 15:47:29 +07:00
Extension . ToThaiNumber ( profile . posMasterNo . toLocaleString ( ) )
: "-" ,
2025-01-28 17:31:40 +07:00
amount : profile.amount ? Extension . ToThaiNumber ( profile . amount . toLocaleString ( ) ) : "-" ,
2024-04-05 17:19:07 +07:00
reason : null , //เหตุผล
#1002,#1004,#1006,#1008,#1013,#1015,#1024,#1028,#1036,#1038,#1044,#1047,#1050
2025-01-27 17:14:13 +07:00
score : profile.result ? Extension . ToThaiNumber ( profile . result ) : "-" , //สรุปผลการประเมินฯ ระดับและคะแนน
2024-07-08 09:21:24 +07:00
remark : profile.remark , //หมายเหตุ
2024-03-21 10:25:48 +07:00
} ;
} ) ;
return new HttpSuccess ( {
2024-07-09 00:03:27 +07:00
template : salaryPeriod.period == "APR" ? "gov1-05" : "gov2-05-01" ,
reportName : salaryPeriod.period == "APR" ? "gov1-05" : "gov2-05-01" ,
2024-03-21 10:25:48 +07:00
data : {
year : Extension.ToThaiNumber ( String ( Extension . ToThaiYear ( salaryPeriod . year ) ) ) ,
2024-04-05 16:35:18 +07:00
agency : root ,
2024-03-21 10:25:48 +07:00
data : formattedData ,
} ,
} ) ;
2024-03-18 16:11:13 +07:00
}
2024-03-18 17:30:54 +07:00
// /* API แบบ 3 กท บัญชีแสดงวันลาครึ่งปี ขรก
// *
// * @summary แบบ 3 กท บัญชีแสดงวันลาครึ่งปี ขรก
// *
// * @param {string} rootId Guid, *Id Root
// * @param {string} salaryPeriodId Guid, *Id Period
// */
2024-03-21 09:51:42 +07:00
// @Get("gov-06/{rootId}/{salaryPeriodId}")
2024-03-18 17:30:54 +07:00
// async SalaryReport6(){
2024-03-18 16:11:13 +07:00
2024-03-18 17:30:54 +07:00
// }
2024-03-18 16:11:13 +07:00
2024-03-18 13:07:09 +07:00
/ * *
2024-04-10 11:14:57 +07:00
* API ค ำ ส ั ่ ง เ ล ื ่ อ น เ ง ิ น เ ด ื อ น ร อ บ เ ม ษ า ย น แ ล ะ ร อ บ ต ุ ล า ค ม
2024-03-18 13:07:09 +07:00
*
2024-04-10 11:14:57 +07:00
* @summary ค ำ ส ั ่ ง เ ล ื ่ อ น เ ง ิ น เ ด ื อ น ร อ บ เ ม ษ า ย น แ ล ะ ร อ บ ต ุ ล า ค ม
2024-03-18 13:07:09 +07:00
*
* @param { string } rootId Guid , * Id Root
* @param { string } salaryPeriodId Guid , * Id Period
* /
2024-07-05 11:25:35 +07:00
@Get ( "gov-07/{rootId}/{salaryPeriodId}/{group}" )
async SalaryReport7 (
@Path ( ) rootId : string ,
@Path ( ) salaryPeriodId : string ,
@Path ( ) group : string ,
) {
2024-03-18 13:07:09 +07:00
const salaryPeriod = await this . salaryPeriodRepository . findOne ( {
where : {
id : salaryPeriodId ,
2024-04-25 00:53:57 +07:00
isActive : true ,
2024-03-18 13:07:09 +07:00
} ,
} ) ;
if ( ! salaryPeriod ) {
throw new HttpError ( HttpStatusCode . NOT_FOUND , "ไม่พบรอบการขึ้นเงินเดือน" ) ;
}
2024-07-05 11:25:35 +07:00
const convertGroup = group . toUpperCase ( ) ;
2024-03-18 13:07:09 +07:00
const salaryProfile = await this . salaryProfileRepository . find ( {
where : {
2025-02-03 15:47:29 +07:00
type : Not ( In ( [ "NONE" , "PENDING" ] ) ) ,
isReserve : Not ( true ) ,
2024-03-20 13:54:34 +07:00
salaryOrg : {
snapshot : "SNAP2" ,
rootId : rootId ,
2024-07-05 11:25:35 +07:00
group : convertGroup ,
2024-03-20 13:54:34 +07:00
salaryPeriodId : salaryPeriodId ,
salaryPeriod : {
2024-04-10 11:14:57 +07:00
period : salaryPeriod.period === "APR" ? "APR" : "OCT" ,
2024-03-20 13:54:34 +07:00
} ,
} ,
2024-03-18 13:07:09 +07:00
} ,
order : {
2024-03-20 13:54:34 +07:00
type : "DESC" ,
orgShortName : "ASC" ,
2024-03-18 13:07:09 +07:00
posMasterNo : "ASC" ,
} ,
} ) ;
2024-04-05 16:35:18 +07:00
const _root = await this . salaryOrgRepository . findOne ( {
where : {
rootId : rootId ,
2024-07-05 11:25:35 +07:00
group : convertGroup ,
2024-04-05 16:35:18 +07:00
salaryPeriodId : salaryPeriodId ,
2024-04-09 09:25:55 +07:00
} ,
} ) ;
2024-04-05 16:35:18 +07:00
const root = _root ? . root == null ? "" : _root . root ;
// const agency = salaryProfile[0] == null ? "" : salaryProfile[0].root;
2024-08-23 14:10:34 +07:00
2024-03-20 13:54:34 +07:00
const formattedData = salaryProfile . map ( ( item , index ) = > ( {
2024-03-18 13:07:09 +07:00
no : Extension.ToThaiNumber ( String ( index + 1 ) ) ,
fullname : item.prefix + item . firstName + " " + item . lastName ,
2025-04-05 18:12:02 +07:00
position :
2025-06-17 18:17:49 +07:00
( item . position ? item . position : "-" ) +
( item . posExecutive
? ` \ n ${ item . positionExecutiveField ? ` ${ item . posExecutive } ( ${ item . positionExecutiveField } ) ` : item . posExecutive } `
: "" ) ,
2024-07-05 11:25:35 +07:00
affiliation :
2025-04-04 13:45:33 +07:00
( item . child4 == undefined && item . child4 == null ? "" : item . child4 + "\n" ) +
( item . child3 == undefined && item . child3 == null ? "" : item . child3 + "\n" ) +
( item . child2 == undefined && item . child2 == null ? "" : item . child2 + "\n" ) +
( item . child1 == undefined && item . child1 == null ? "" : item . child1 + "\n" ) +
2024-03-20 13:54:34 +07:00
( item . root == undefined && item . root == null ? "" : item . root ) ,
2024-03-18 13:07:09 +07:00
posType : item.posType ,
posLevel : item.posLevel ,
2025-01-29 10:13:43 +07:00
posExecutive : item.posExecutive ? item . posExecutive : "-" ,
2024-08-23 14:10:34 +07:00
fullPositionName : item.posExecutive
? item . position + " (" + item . posExecutive + ")"
2025-01-29 10:13:43 +07:00
: item . position || "-" ,
2024-04-09 09:25:55 +07:00
posMasterNo :
Extension . ToThaiNumber ( item . orgShortName ) +
2025-04-05 18:12:02 +07:00
" " +
2024-04-09 09:25:55 +07:00
Extension . ToThaiNumber ( String ( item . posMasterNo . toLocaleString ( ) ) ) ,
2024-03-18 13:07:09 +07:00
amount :
item . amount == undefined || item . amount == null
? "๐ "
2024-04-01 14:11:06 +07:00
: Extension . ToThaiNumber ( String ( item . amount . toLocaleString ( ) ) ) ,
2024-03-18 13:07:09 +07:00
positionSalaryAmount :
item . positionSalaryAmount == undefined || item . positionSalaryAmount == null
? "๐ "
2024-04-01 14:11:06 +07:00
: Extension . ToThaiNumber ( String ( item . positionSalaryAmount . toLocaleString ( ) ) ) +
2024-03-20 13:54:34 +07:00
( item . amountSpecial > 0
2025-02-04 15:27:05 +07:00
? ` ( ${ Extension . ToThaiNumber ( String ( item . amountSpecial ) ) } ) `
2025-01-29 15:21:47 +07:00
: "" ) ,
2025-01-28 17:31:40 +07:00
remark : [
2025-02-03 15:47:29 +07:00
item . type === "FULL" ? "หนึ่งขั้น" : "" ,
item . type === "FULLHAFT" ? "หนึ่งขั้นครึ่ง" : "" ,
item . amountSpecial > 0 ? "ได้รับค่าตอบแทนพิเศษ" : "" ,
item . isNext === true ? "(ได้รับเงินเดือนสูงกว่าขั้นสูงฯ)" : "" ,
]
. filter ( Boolean )
. join ( "\n" ) ,
2024-03-18 13:07:09 +07:00
} ) ) ;
2024-03-20 13:54:34 +07:00
return new HttpSuccess ( {
2024-04-10 11:14:57 +07:00
template : salaryPeriod.period === "APR" ? "gov1-07" : "gov2-08" ,
reportName : salaryPeriod.period === "APR" ? "gov1-07" : "gov2-08" ,
2024-03-20 13:54:34 +07:00
data : {
2024-03-21 10:25:48 +07:00
year : Extension.ToThaiNumber ( String ( Extension . ToThaiYear ( salaryPeriod . year ) ) ) ,
2024-03-20 13:54:34 +07:00
yearOld : Extension.ToThaiNumber ( ( salaryPeriod . year + 542 ) . toString ( ) ) ,
2024-04-25 00:53:57 +07:00
date :
salaryPeriod . period === "APR"
? Extension . ToThaiNumber (
Extension . ToThaiFullDate ( new Date ( ` ${ salaryPeriod . year } -04-01 ` ) ) ,
)
: Extension . ToThaiNumber (
Extension . ToThaiFullDate ( new Date ( ` ${ salaryPeriod . year } -10-01 ` ) ) ,
) ,
2024-04-05 16:35:18 +07:00
agency : root ,
2024-03-20 13:54:34 +07:00
data : formattedData ,
} ,
} ) ;
2024-03-18 13:07:09 +07:00
}
2024-04-10 11:43:23 +07:00
/ * *
* API ค ำ ส ั ่ ง เ ล ื ่ อ น เ ง ิ น เ ด ื อ น ข ้ า ร า ช ก า ร เ ก ษ ี ย ณ ร อ บ ต ุ ล า ค ม
*
* @summary ค ำ ส ั ่ ง เ ล ื ่ อ น เ ง ิ น เ ด ื อ น ข ้ า ร า ช ก า ร เ ก ษ ี ย ณ ร อ บ ต ุ ล า ค ม
*
* @param { string } rootId Guid , * Id Root
* @param { string } salaryPeriodId Guid , * Id Period
* /
2024-07-05 11:25:35 +07:00
@Get ( "gov-07-01/{rootId}/{salaryPeriodId}/{group}" )
2024-07-08 09:21:24 +07:00
async SalaryReport7retire (
@Path ( ) rootId : string ,
@Path ( ) salaryPeriodId : string ,
@Path ( ) group : string ,
) {
2024-04-10 11:43:23 +07:00
const salaryPeriod = await this . salaryPeriodRepository . findOne ( {
where : {
id : salaryPeriodId ,
period : "OCT" ,
isActive : true ,
} ,
} ) ;
if ( ! salaryPeriod ) {
throw new HttpError ( HttpStatusCode . NOT_FOUND , "ไม่พบรอบการขึ้นเงินเดือน" ) ;
}
2024-07-05 11:25:35 +07:00
const convertGroup = group . toUpperCase ( ) ;
2024-04-10 11:43:23 +07:00
const salaryProfile = await this . salaryProfileRepository . find ( {
where : {
salaryOrg : {
snapshot : "SNAP2" ,
rootId : rootId ,
2024-07-05 11:25:35 +07:00
group : convertGroup ,
2024-04-10 11:43:23 +07:00
salaryPeriodId : salaryPeriodId ,
salaryPeriod : {
2024-04-25 00:53:57 +07:00
period : salaryPeriod.period ,
2024-04-10 11:43:23 +07:00
} ,
} ,
2024-04-25 00:53:57 +07:00
isRetired : true , // เฉพาะคนที่เกษียณ
2025-02-21 19:00:24 +07:00
type : Not ( In ( [ "NONE" , "PENDING" ] ) ) ,
2024-04-10 11:43:23 +07:00
} ,
order : {
type : "DESC" ,
orgShortName : "ASC" ,
posMasterNo : "ASC" ,
} ,
} ) ;
const _root = await this . salaryOrgRepository . findOne ( {
where : {
rootId : rootId ,
2024-07-05 11:25:35 +07:00
group : convertGroup ,
2024-04-10 11:43:23 +07:00
salaryPeriodId : salaryPeriodId ,
} ,
} ) ;
const root = _root ? . root == null ? "" : _root . root ;
const formattedData = salaryProfile . map ( ( item , index ) = > ( {
no : Extension.ToThaiNumber ( String ( index + 1 ) ) ,
fullname : item.prefix + item . firstName + " " + item . lastName ,
2025-04-05 18:12:02 +07:00
position :
2025-06-17 18:17:49 +07:00
( item . position ? item . position : "-" ) +
( item . posExecutive
? ` \ n ${ item . positionExecutiveField ? ` ${ item . posExecutive } ( ${ item . positionExecutiveField } ) ` : item . posExecutive } `
: "" ) ,
2024-07-05 11:25:35 +07:00
affiliation :
2025-04-04 13:45:33 +07:00
( item . child4 == undefined && item . child4 == null ? "" : item . child4 + "\n" ) +
( item . child3 == undefined && item . child3 == null ? "" : item . child3 + "\n" ) +
( item . child2 == undefined && item . child2 == null ? "" : item . child2 + "\n" ) +
( item . child1 == undefined && item . child1 == null ? "" : item . child1 + "\n" ) +
2024-04-10 11:43:23 +07:00
( item . root == undefined && item . root == null ? "" : item . root ) ,
posType : item.posType ,
posLevel : item.posLevel ,
posMasterNo :
Extension . ToThaiNumber ( item . orgShortName ) +
2025-04-05 18:12:02 +07:00
" " +
2024-04-10 11:43:23 +07:00
Extension . ToThaiNumber ( String ( item . posMasterNo . toLocaleString ( ) ) ) ,
amount :
item . amount == undefined || item . amount == null
? "๐ "
: Extension . ToThaiNumber ( String ( item . amount . toLocaleString ( ) ) ) ,
positionSalaryAmount :
item . positionSalaryAmount == undefined || item . positionSalaryAmount == null
? "๐ "
: Extension . ToThaiNumber ( String ( item . positionSalaryAmount . toLocaleString ( ) ) ) +
( item . amountSpecial > 0
? ` ( ${ Extension . ToThaiNumber ( String ( item . positionSalaryAmount ) ) } ) `
: "" ) ,
remark :
` ${ item . type === "FULL" ? "หนึ่งขั้น" : "" } \ n ` +
` ${ item . type === "FULLHAFT" ? "หนึ่งขั้นครึ่ง" : "" } \ n ` +
` ${ item . amountSpecial > 0 ? "ได้รับค่าตอบแทนพิเศษ\n" : "" } ` +
` ${ item . isNext === true ? "(ได้รับเงินเดือนสูงกว่าขั้นสูงฯ)" : "" } ` ,
} ) ) ;
return new HttpSuccess ( {
template : "gov2-07" ,
reportName : "gov2-07" ,
data : {
year : Extension.ToThaiNumber ( String ( Extension . ToThaiYear ( salaryPeriod . year ) ) ) ,
yearOld : Extension.ToThaiNumber ( ( salaryPeriod . year + 542 ) . toString ( ) ) ,
2024-04-25 00:53:57 +07:00
date : Extension.ToThaiNumber (
Extension . ToThaiFullDate ( new Date ( ` ${ salaryPeriod . year } -10-01 ` ) ) ,
) ,
2024-04-10 11:43:23 +07:00
agency : root ,
data : formattedData ,
} ,
} ) ;
}
2024-03-18 13:07:09 +07:00
/ * *
2024-04-10 12:12:36 +07:00
* APIคำสั่งค่าตอบแทนพิเศษ แ ล ะ ผ ู ้ ไ ม ่ ไ ด ้ เ ล ื ่ อ น ร อ บ เ ม ษ า ย น แ ล ะ ร อ บ ต ุ ล า ค ม
2024-03-18 13:07:09 +07:00
*
2024-04-10 12:12:36 +07:00
* @summary ค ำ ส ั ่ ง ค ่ า ต อ บ แ ท น พ ิ เ ศ ษ แ ล ะ ผ ู ้ ไ ม ่ ไ ด ้ เ ล ื ่ อ น ร อ บ เ ม ษ า ย น แ ล ะ ร อ บ ต ุ ล า ค ม
2024-03-18 13:07:09 +07:00
*
* @param { string } rootId Guid , * Id Root
* @param { string } salaryPeriodId Guid , * Id Period
* /
2024-07-05 15:12:42 +07:00
@Get ( "gov-08/{rootId}/{salaryPeriodId}/{group}" )
2024-07-08 09:21:24 +07:00
async SalaryReport8 (
@Path ( ) rootId : string ,
@Path ( ) salaryPeriodId : string ,
@Path ( ) group : string ,
) {
2024-03-18 13:07:09 +07:00
const salaryPeriod = await this . salaryPeriodRepository . findOne ( {
where : {
id : salaryPeriodId ,
2024-04-10 12:12:36 +07:00
// period: "APR",
2024-03-18 13:07:09 +07:00
isActive : true ,
} ,
} ) ;
if ( ! salaryPeriod ) {
throw new HttpError ( HttpStatusCode . NOT_FOUND , "ไม่พบรอบการขึ้นเงินเดือน" ) ;
}
2024-07-05 15:12:42 +07:00
const convertGroup = group . toUpperCase ( ) ;
const salaryOrg = await this . salaryOrgRepository . findOne ( {
2024-03-18 13:07:09 +07:00
where : {
salaryPeriodId : salaryPeriodId ,
rootId : rootId ,
snapshot : "SNAP2" ,
2024-07-05 15:12:42 +07:00
group : convertGroup ,
2024-03-18 13:07:09 +07:00
} ,
relations : [ "salaryProfiles" ] ,
} ) ;
2024-07-09 00:03:27 +07:00
2024-03-18 13:07:09 +07:00
const salaryProfileSpecial = await this . salaryProfileRepository . find ( {
2024-04-05 15:01:48 +07:00
relations : [ "salaryOrg" ] ,
2024-03-18 13:07:09 +07:00
where : {
2024-07-05 15:12:42 +07:00
salaryOrgId : In ( [ salaryOrg ? . id ] ) ,
2024-07-08 16:58:53 +07:00
amountSpecial : MoreThan ( 0 ) ,
2024-03-18 13:07:09 +07:00
} ,
select : [
"id" ,
"prefix" ,
"firstName" ,
"lastName" ,
"root" ,
#1002,#1004,#1006,#1008,#1013,#1015,#1024,#1028,#1036,#1038,#1044,#1047,#1050
2025-01-27 17:14:13 +07:00
"child1" ,
"child2" ,
"child3" ,
"child4" ,
2024-03-18 13:07:09 +07:00
"position" ,
"posType" ,
"posLevel" ,
"orgShortName" ,
"posMasterNo" ,
"amount" ,
"amountSpecial" ,
2024-07-08 17:46:32 +07:00
"remark" ,
2024-03-18 13:07:09 +07:00
] ,
order : {
2024-04-05 15:01:48 +07:00
salaryOrg : {
2024-04-09 09:25:55 +07:00
group : "ASC" ,
2024-04-05 15:01:48 +07:00
} ,
2024-03-18 13:07:09 +07:00
posMasterNo : "ASC" ,
} ,
} ) ;
const salaryProfileNoAmount = await this . salaryProfileRepository . find ( {
2024-04-05 15:01:48 +07:00
relations : [ "salaryOrg" ] ,
2024-03-18 13:07:09 +07:00
where : {
2024-07-05 15:12:42 +07:00
salaryOrgId : In ( [ salaryOrg ? . id ] ) ,
2024-04-05 14:08:15 +07:00
// amountUse: IsNull() || 0,
// positionSalaryAmount: IsNull() || 0,
2024-04-09 09:25:55 +07:00
type : "NONE" ,
2024-03-18 13:07:09 +07:00
} ,
select : [
"id" ,
"prefix" ,
"firstName" ,
"lastName" ,
"root" ,
#1002,#1004,#1006,#1008,#1013,#1015,#1024,#1028,#1036,#1038,#1044,#1047,#1050
2025-01-27 17:14:13 +07:00
"child1" ,
"child2" ,
"child3" ,
"child4" ,
2024-03-18 13:07:09 +07:00
"position" ,
"posType" ,
"posLevel" ,
"orgShortName" ,
"posMasterNo" ,
"amount" ,
2024-07-08 18:14:12 +07:00
"remark" ,
2024-03-18 13:07:09 +07:00
] ,
order : {
2024-04-05 15:01:48 +07:00
salaryOrg : {
2024-04-09 09:25:55 +07:00
group : "ASC" ,
2024-04-05 15:01:48 +07:00
} ,
2024-03-18 13:07:09 +07:00
posMasterNo : "ASC" ,
} ,
} ) ;
#1002,#1004,#1006,#1008,#1013,#1015,#1024,#1028,#1036,#1038,#1044,#1047,#1050
2025-01-27 17:14:13 +07:00
2024-03-18 13:07:09 +07:00
const profileSpecial = salaryProfileSpecial . map ( ( item , index ) = > ( {
no : Extension.ToThaiNumber ( String ( index + 1 ) ) ,
fullname : item.prefix + item . firstName + " " + item . lastName ,
2025-04-05 18:12:02 +07:00
position :
2025-06-17 18:17:49 +07:00
( item . position ? item . position : "-" ) +
( item . posExecutive
? ` \ n ${ item . positionExecutiveField ? ` ${ item . posExecutive } ( ${ item . positionExecutiveField } ) ` : item . posExecutive } `
: "" ) ,
2024-07-05 11:25:35 +07:00
affiliation :
2025-04-04 13:45:33 +07:00
( item . child4 == undefined && item . child4 == null ? "" : item . child4 + "\n" ) +
( item . child3 == undefined && item . child3 == null ? "" : item . child3 + "\n" ) +
( item . child2 == undefined && item . child2 == null ? "" : item . child2 + "\n" ) +
( item . child1 == undefined && item . child1 == null ? "" : item . child1 + "\n" ) +
2024-07-05 11:25:35 +07:00
( item . root == undefined && item . root == null ? "" : item . root ) ,
2024-03-18 13:07:09 +07:00
posType : item.posType ,
posLevel : item.posLevel ,
2024-04-09 09:25:55 +07:00
posMasterNo :
Extension . ToThaiNumber ( item . orgShortName ) +
2025-04-05 18:12:02 +07:00
" " +
2024-04-09 09:25:55 +07:00
Extension . ToThaiNumber ( String ( item . posMasterNo . toLocaleString ( ) ) ) ,
2024-03-18 13:07:09 +07:00
amount :
item . amount == undefined || item . amount == null
? "๐ "
2024-04-01 14:11:06 +07:00
: Extension . ToThaiNumber ( String ( item . amount . toLocaleString ( ) ) ) ,
2024-03-18 13:07:09 +07:00
amountSpecial :
item . amountSpecial == undefined || item . amountSpecial == null
? "๐ "
2024-04-01 14:11:06 +07:00
: Extension . ToThaiNumber ( String ( item . amountSpecial . toLocaleString ( ) ) ) ,
2025-01-23 16:29:20 +07:00
remark : item.remark ? ? "" ,
2024-03-18 13:07:09 +07:00
} ) ) ;
const profileNoAmount = salaryProfileNoAmount . map ( ( item , index ) = > ( {
no : Extension.ToThaiNumber ( String ( index + 1 ) ) ,
fullname : item.prefix + item . firstName + " " + item . lastName ,
2025-04-05 18:12:02 +07:00
position :
2025-06-17 18:17:49 +07:00
( item . position ? item . position : "-" ) +
( item . posExecutive
? ` \ n ${ item . positionExecutiveField ? ` ${ item . posExecutive } ( ${ item . positionExecutiveField } ) ` : item . posExecutive } `
: "" ) ,
2024-07-05 11:25:35 +07:00
affiliation :
2025-04-04 13:45:33 +07:00
( item . child4 == undefined && item . child4 == null ? "" : item . child4 + "\n" ) +
( item . child3 == undefined && item . child3 == null ? "" : item . child3 + "\n" ) +
( item . child2 == undefined && item . child2 == null ? "" : item . child2 + "\n" ) +
( item . child1 == undefined && item . child1 == null ? "" : item . child1 + "\n" ) +
2024-07-05 11:25:35 +07:00
( item . root == undefined && item . root == null ? "" : item . root ) ,
2024-03-18 13:07:09 +07:00
posType : item.posType ,
posLevel : item.posLevel ,
2024-04-09 09:25:55 +07:00
posMasterNo :
Extension . ToThaiNumber ( item . orgShortName ) +
2025-04-05 18:12:02 +07:00
" " +
2024-04-09 09:25:55 +07:00
Extension . ToThaiNumber ( String ( item . posMasterNo . toLocaleString ( ) ) ) ,
2024-03-18 13:07:09 +07:00
amount :
item . amount == undefined || item . amount == null
? "๐ "
2024-04-05 15:01:48 +07:00
: Extension . ToThaiNumber ( String ( item . amount . toLocaleString ( ) ) ) ,
2025-01-23 16:29:20 +07:00
remark : item.remark ? ? "" ,
2024-03-18 13:07:09 +07:00
} ) ) ;
2024-04-01 13:31:39 +07:00
return new HttpSuccess ( {
2024-04-10 12:12:36 +07:00
template : salaryPeriod.period === "APR" ? "gov1-08" : "gov2-09" ,
reportName : salaryPeriod.period === "APR" ? "gov1-08" : "gov2-09" ,
2024-04-01 13:31:39 +07:00
data : {
year : Extension.ToThaiNumber ( String ( Extension . ToThaiYear ( salaryPeriod . year ) ) ) ,
2024-04-25 00:53:57 +07:00
date :
salaryPeriod . period === "APR"
? Extension . ToThaiNumber (
Extension . ToThaiFullDate ( new Date ( ` ${ salaryPeriod . year } -04-01 ` ) ) ,
)
: Extension . ToThaiNumber (
Extension . ToThaiFullDate ( new Date ( ` ${ salaryPeriod . year } -10-01 ` ) ) ,
) ,
2024-07-05 15:12:42 +07:00
agency : salaryOrg?.root ,
2024-04-01 13:31:39 +07:00
profileSpecial : profileSpecial ,
profileNoAmount : profileNoAmount ,
} ,
} ) ;
2024-03-18 13:07:09 +07:00
}
2024-03-21 15:29:39 +07:00
2025-02-11 19:45:59 +07:00
/ * *
* API เ ง ิ น เ ด ื อ น แ บ บ บ ั ญ ช ี ถ ื อ จ ่ า ย ( จ . ๑ ๘ ) ข อ ง ข ้ า ร า ช ก า ร ก ร ุ ง เ ท พ ม ห า น ค ร ส า ม ั ญ
*
* @summary เ ง ิ น เ ด ื อ น แ บ บ บ ั ญ ช ี ถ ื อ จ ่ า ย ( จ . ๑ ๘ ) ข อ ง ข ้ า ร า ช ก า ร ก ร ุ ง เ ท พ ม ห า น ค ร ส า ม ั ญ
*
* @param { string } rootId Guid , * Id Root
* @param { string } salaryPeriodId Guid , * Id Period
* /
@Get ( "gov-10/{rootId}/{salaryPeriodId}/{group}" )
async SalaryReport10 (
@Path ( ) rootId : string ,
@Path ( ) salaryPeriodId : string ,
@Path ( ) group : string ,
) {
2025-02-25 14:59:02 +07:00
const salaryPeriod = await this . salaryPeriodRepository . findOne ( {
where : {
id : salaryPeriodId ,
// period: "OCT",??
isActive : true ,
} ,
} ) ;
if ( ! salaryPeriod ) {
throw new HttpError ( HttpStatusCode . NOT_FOUND , "ไม่พบรอบการขึ้นเงินเดือน" ) ;
}
//ปีก่อนหน้า
const salaryOldPeriod = await this . salaryPeriodRepository . findOne ( {
where : {
year : salaryPeriod?.year - 1 ,
period : "OCT" ,
} ,
} ) ;
const convertGroup = group . toUpperCase ( ) ;
const salaryOrg = await this . salaryOrgRepository . findOne ( {
where : {
salaryPeriodId : salaryPeriodId ,
rootId : rootId ,
snapshot : "SNAP2" ,
group : convertGroup ,
} ,
relations : [ "salaryProfiles" ] ,
} ) ;
//ปีก่อนหน้า
let salaryOrgPrevious = null ;
if ( salaryOldPeriod ) {
salaryOrgPrevious = await this . salaryOrgRepository . findOne ( {
where : {
salaryPeriodId : salaryOldPeriod?.id ,
rootDnaId : salaryOrg?.rootDnaId ,
snapshot : "SNAP1" ,
group : convertGroup ,
} ,
} ) ;
}
const salaryProfile = await this . salaryProfileRepository . find ( {
relations : [ "salaryOrg" ] ,
where : {
salaryOrgId : In ( [ salaryOrg ? . id ] ) ,
// amountSpecial: MoreThan(0),
} ,
order : {
salaryOrg : {
group : "ASC" ,
} ,
posMasterNo : "ASC" ,
} ,
} ) ;
const salaryProfilePrevious = await this . salaryProfileRepository . find ( {
relations : [ "salaryOrg" ] ,
where : {
salaryOrgId : In ( [ salaryOrgPrevious ? . id ] ) ,
} ,
order : {
salaryOrg : {
group : "ASC" ,
} ,
posMasterNo : "ASC" ,
} ,
} ) ;
const formattedData = salaryProfile . map ( ( item , index ) = > ( {
no : Extension.ToThaiNumber ( String ( index + 1 ) ) ,
fullname : item.prefix + item . firstName + " " + item . lastName ,
2025-03-10 12:53:11 +07:00
root : item.root ? ? "-" ,
2025-04-05 18:12:02 +07:00
position :
2025-06-17 18:17:49 +07:00
( item . position ? item . position : "-" ) +
( item . posExecutive
? ` \ n ${ item . positionExecutiveField ? ` ${ item . posExecutive } ( ${ item . positionExecutiveField } ) ` : item . posExecutive } `
: "" ) ,
2025-02-25 14:59:02 +07:00
posMasterNo :
2025-03-10 12:53:11 +07:00
Extension . ToThaiNumber ( item . orgShortName ) +
2025-04-05 18:12:02 +07:00
" " +
2025-03-10 12:53:11 +07:00
Extension . ToThaiNumber ( String ( item . posMasterNo ) ) ,
posTypeCurrent : item.posType ? ? "-" ,
posLevelCurrent : item.posLevel ? ? "-" ,
amountCurrent : item.amount ? Extension . ToThaiNumber ( item . amount . toLocaleString ( ) ) : "-" ,
posTypePrevious :
salaryProfilePrevious . length > 0
? ( ( ) = > {
const filteredType = salaryProfilePrevious
. filter ( ( profile ) = > profile . citizenId === item . citizenId )
. map ( ( profile ) = > profile . posType ) ;
const posType = filteredType [ 0 ] ;
return posType ? posType : "-" ;
} ) ( )
: "-" ,
posLevelPrevious :
salaryProfilePrevious . length > 0
? ( ( ) = > {
const filteredLevel = salaryProfilePrevious
. filter ( ( profile ) = > profile . citizenId === item . citizenId )
. map ( ( profile ) = > profile . posLevel ) ;
const posLevel = filteredLevel [ 0 ] ;
return posLevel ? posLevel : "-" ;
} ) ( )
: "-" ,
amountPrevious :
salaryProfilePrevious . length > 0
? ( ( ) = > {
const filteredAmount = salaryProfilePrevious
. filter ( ( profile ) = > profile . citizenId === item . citizenId )
. map ( ( profile ) = > profile . amount ) ;
const amount = filteredAmount [ 0 ] ;
return amount ? Extension . ToThaiNumber ( amount . toLocaleString ( ) ) : "-" ;
} ) ( )
: "-" ,
deduction : "-" , //เงินปรับลด
promote : item.amountUse ? Extension . ToThaiNumber ( item . amountUse . toLocaleString ( ) ) : "-" , //เงินเลื่อนขั้น
qualification : "-" , //เงินปรับวุฒิ
2025-02-25 14:59:02 +07:00
adjustRate : "-" , //เงินปรับอัตรา
newRate : "-" , //อัตราตั้งใหม่
specialPromote : "-" , //ลำดับการเลื่อนกรณีพิเศษ
2025-03-10 12:53:11 +07:00
remark : item.remark ? ? "-" ,
2025-02-25 14:59:02 +07:00
temporaryPayment : "-" , //ถือจ่ายชั่วคราวขั้น
2025-03-10 12:53:11 +07:00
} ) ) ;
2025-02-11 19:45:59 +07:00
return new HttpSuccess ( {
template : "gov2-10" ,
reportName : "gov2-10" ,
data : {
2025-02-25 14:59:02 +07:00
data : formattedData ,
2025-02-11 19:45:59 +07:00
} ,
} ) ;
}
2024-03-21 15:29:39 +07:00
/ * *
* API 01 - บ ั ญ ช ี ค ำ น ว ณ โ ค ว ต า
*
* @summary 01 - บ ั ญ ช ี ค ำ น ว ณ โ ค ว ต า
*
* /
2024-04-01 17:19:32 +07:00
@Get ( "emp-01/{rootId}/{salaryPeriodId}" )
2024-03-22 18:02:51 +07:00
async SalaryReportEmp1_1 ( @Path ( ) rootId : string , @Path ( ) salaryPeriodId : string ) {
2024-03-21 15:29:39 +07:00
const salaryPeriod = await this . salaryPeriodRepository . findOne ( {
where : {
id : salaryPeriodId ,
} ,
} ) ;
if ( ! salaryPeriod ) {
throw new HttpError ( HttpStatusCode . NOT_FOUND , "ไม่พบข้อมูลการขึ้นเงินเดือน" ) ;
}
const _salaryPeriod = await this . salaryOrgEmployeeRepository . findOne ( {
relations : [ "salaryPeriod" , "salaryProfiles" ] ,
where : {
snapshot : "SNAP2" ,
2025-01-23 16:29:20 +07:00
group : "GROUP1" ,
2024-03-21 15:29:39 +07:00
rootId : rootId ,
salaryPeriodId : salaryPeriodId ,
} ,
} ) ;
const agency =
_salaryPeriod == null || _salaryPeriod . salaryProfiles [ 0 ] == null
? ""
: _salaryPeriod . salaryProfiles [ 0 ] . root ;
2024-03-22 18:02:51 +07:00
return new HttpSuccess ( {
template : "emp1-01" ,
reportName : "emp1-01" ,
data : {
year : Extension.ToThaiNumber ( String ( Extension . ToThaiYear ( salaryPeriod . year ) ) ) ,
agency : agency ,
total : _salaryPeriod == null ? "" : Extension . ToThaiNumber ( _salaryPeriod . total . toString ( ) ) ,
fifteenPercent :
_salaryPeriod == null
? ""
2025-04-05 18:12:02 +07:00
: Extension . ToThaiNumber (
` ${ _salaryPeriod . fifteenPercent . toLocaleString ( ) } . ${ _salaryPeriod . fifteenPoint . toLocaleString ( ) } ` ,
) ,
2024-03-22 18:02:51 +07:00
full :
_salaryPeriod == null
? ""
: Extension . ToThaiNumber (
_salaryPeriod . salaryProfiles . filter ( ( x ) = > x . type == "FULL" ) . length . toString ( ) ,
) ,
haft :
_salaryPeriod == null
? ""
: Extension . ToThaiNumber (
_salaryPeriod . salaryProfiles . filter ( ( x ) = > x . type == "HAFT" ) . length . toString ( ) ,
) ,
notPromoted :
_salaryPeriod == null
? ""
: Extension . ToThaiNumber (
_salaryPeriod . salaryProfiles . filter ( ( x ) = > x . type == "NONE" ) . length . toString ( ) ,
) ,
reason : null ,
} ,
} ) ;
2024-03-21 15:29:39 +07:00
}
/ * *
* API 02 - ร า ย ช ื ่ อ ล ู ก จ ้ า ง ป ร ะ จ ำ ผ ู ้ ค ร อ ง ต ำ แ ห น ่ ง ณ ว ั น ท ี ่ 1 ม ี น า ค ม
*
* @summary 02 - ร า ย ช ื ่ อ ล ู ก จ ้ า ง ป ร ะ จ ำ ผ ู ้ ค ร อ ง ต ำ แ ห น ่ ง ณ ว ั น ท ี ่ 1 ม ี น า ค ม
*
* /
2024-04-01 17:19:32 +07:00
@Get ( "emp-02/{rootId}/{salaryPeriodId}" )
2024-03-22 18:02:51 +07:00
async SalaryReportEmp1_2 ( @Path ( ) rootId : string , @Path ( ) salaryPeriodId : string ) {
2024-03-21 15:29:39 +07:00
const salaryPeriod = await this . salaryPeriodRepository . findOne ( {
where : {
id : salaryPeriodId ,
} ,
} ) ;
if ( ! salaryPeriod ) {
throw new HttpError ( HttpStatusCode . NOT_FOUND , "ไม่พบข้อมูลการขึ้นเงินเดือน" ) ;
}
const _salaryPeriod = await this . salaryProfileEmployeeRepository . find ( {
relations : [ "salaryOrg" , "salaryOrg.salaryPeriod" ] ,
where : {
salaryOrg : {
snapshot : "SNAP1" ,
rootId : rootId ,
salaryPeriodId : salaryPeriodId ,
} ,
} ,
order : {
amount : "ASC" ,
2025-05-19 11:39:09 +07:00
rootOrder : "ASC" ,
child1Order : "ASC" ,
child2Order : "ASC" ,
child3Order : "ASC" ,
child4Order : "ASC" ,
posMasterNo : "ASC" ,
2024-03-21 15:29:39 +07:00
} ,
} ) ;
if ( ! _salaryPeriod ) {
throw new HttpError ( HttpStatusCode . NOT_FOUND , "ไม่พบข้อมูล" ) ;
}
const agency = _salaryPeriod [ 0 ] == null ? "" : _salaryPeriod [ 0 ] . root ;
const formattedData = _salaryPeriod . map ( ( profile , index ) = > {
const fullNameParts = [
profile . child4 ,
profile . child3 ,
profile . child2 ,
profile . child1 ,
profile . root ,
] ;
2024-07-08 16:58:53 +07:00
const affiliation = fullNameParts
2024-03-21 15:29:39 +07:00
. filter ( ( part ) = > part !== undefined && part !== null )
2025-04-04 13:45:33 +07:00
. join ( "\n" ) ;
2024-07-08 16:58:53 +07:00
const fullName = ` ${ profile . prefix } ${ profile . firstName } ${ profile . lastName } ` ;
2024-03-21 15:29:39 +07:00
return {
no : Extension.ToThaiNumber ( ( index + 1 ) . toLocaleString ( ) ) ,
fullName : fullName ,
2024-07-08 16:58:53 +07:00
affiliation : affiliation ,
2024-03-21 15:29:39 +07:00
position : profile.position ,
2024-04-09 09:25:55 +07:00
posLevel : profile.posLevel
? ` ${ profile . posTypeShort } ${ Extension . ToThaiNumber ( profile . posLevel . toLocaleString ( ) ) } `
: null ,
2024-03-21 15:29:39 +07:00
posNumber :
2024-04-09 09:25:55 +07:00
Extension . ToThaiNumber ( profile . orgShortName ) +
2025-04-05 18:12:02 +07:00
" " +
2024-04-09 09:25:55 +07:00
Extension . ToThaiNumber ( profile . posMasterNo . toLocaleString ( ) ) ,
2024-03-21 15:29:39 +07:00
amount : profile.amount ? Extension . ToThaiNumber ( profile . amount . toLocaleString ( ) ) : null ,
reason : null ,
} ;
} ) ;
return new HttpSuccess ( {
2024-03-22 18:02:51 +07:00
template : "emp1-02" ,
reportName : "emp1-02" ,
2024-03-21 15:29:39 +07:00
data : {
year : Extension.ToThaiNumber ( String ( Extension . ToThaiYear ( salaryPeriod . year ) ) ) ,
agency : agency ,
data : formattedData ,
} ,
} ) ;
}
/ * *
* API 03 - ร า ย ช ื ่ อ ล ู ก จ ้ า ง ป ร ะ จ ำ ท ี ่ ไ ด ้ ร ั บ ก า ร เ ส น อ ข อ เ ล ื ่ อ น ข ั ้ น ค ่ า จ ้ า ง ห น ึ ่ ง ข ั ้ น
*
* @summary 03 - ร า ย ช ื ่ อ ล ู ก จ ้ า ง ป ร ะ จ ำ ท ี ่ ไ ด ้ ร ั บ ก า ร เ ส น อ ข อ เ ล ื ่ อ น ข ั ้ น ค ่ า จ ้ า ง ห น ึ ่ ง ข ั ้ น
*
* /
2024-04-01 17:19:32 +07:00
@Get ( "emp-03/{rootId}/{salaryPeriodId}" )
2024-03-22 18:02:51 +07:00
async SalaryReportEmp1_3 ( @Path ( ) rootId : string , @Path ( ) salaryPeriodId : string ) {
2024-03-21 15:29:39 +07:00
const salaryPeriod = await this . salaryPeriodRepository . findOne ( {
where : {
id : salaryPeriodId ,
} ,
} ) ;
if ( ! salaryPeriod ) {
throw new HttpError ( HttpStatusCode . NOT_FOUND , "ไม่พบข้อมูลการขึ้นเงินเดือน" ) ;
}
const _salaryPeriod = await this . salaryProfileEmployeeRepository . find ( {
relations : [ "salaryOrg" , "salaryOrg.salaryPeriod" ] ,
where : {
2024-03-22 11:31:56 +07:00
type : "FULL" ,
2024-03-21 15:29:39 +07:00
salaryOrg : {
snapshot : "SNAP1" ,
rootId : rootId ,
salaryPeriodId : salaryPeriodId ,
} ,
} ,
order : {
2025-01-22 14:21:41 +07:00
result : "DESC" ,
2025-05-19 11:39:09 +07:00
rootOrder : "ASC" ,
child1Order : "ASC" ,
child2Order : "ASC" ,
child3Order : "ASC" ,
child4Order : "ASC" ,
posMasterNo : "ASC" ,
2024-03-21 15:29:39 +07:00
} ,
} ) ;
if ( ! _salaryPeriod ) {
throw new HttpError ( HttpStatusCode . NOT_FOUND , "ไม่พบข้อมูล" ) ;
}
const agency = _salaryPeriod [ 0 ] == null ? "" : _salaryPeriod [ 0 ] . root ;
const fifteenPercent =
2025-02-10 15:47:10 +07:00
( _salaryPeriod [ 0 ] ? . salaryOrg == null || _salaryPeriod [ 0 ] ? . salaryOrg ? . fifteenPercent == null
2024-03-21 15:29:39 +07:00
? ""
2025-02-10 15:47:10 +07:00
: _salaryPeriod [ 0 ] ? . salaryOrg ? . fifteenPercent . toString ( ) ) +
2024-03-21 15:29:39 +07:00
"." +
2025-02-10 15:47:10 +07:00
( _salaryPeriod [ 0 ] ? . salaryOrg == null || _salaryPeriod [ 0 ] ? . salaryOrg ? . fifteenPoint == null
2024-03-21 15:29:39 +07:00
? "๐ ๐ "
2025-02-10 15:47:10 +07:00
: _salaryPeriod [ 0 ] ? . salaryOrg ? . fifteenPoint . toString ( ) ) ;
2024-03-21 15:29:39 +07:00
const formattedData = _salaryPeriod . map ( ( profile , index ) = > {
2025-01-22 14:21:41 +07:00
const fullName = ` ${ profile . prefix } ${ profile . firstName } ${ profile . lastName } ` ;
2024-03-21 15:29:39 +07:00
const fullNameParts = [
profile . child4 ,
profile . child3 ,
profile . child2 ,
profile . child1 ,
profile . root ,
#1002,#1004,#1006,#1008,#1013,#1015,#1024,#1028,#1036,#1038,#1044,#1047,#1050
2025-01-27 17:14:13 +07:00
fullName ,
2025-01-22 14:21:41 +07:00
] ;
const affiliationParts = [
profile . child4 ,
profile . child3 ,
profile . child2 ,
profile . child1 ,
#1002,#1004,#1006,#1008,#1013,#1015,#1024,#1028,#1036,#1038,#1044,#1047,#1050
2025-01-27 17:14:13 +07:00
profile . root ,
2024-03-21 15:29:39 +07:00
] ;
2025-01-22 14:21:41 +07:00
const affiliation = affiliationParts
2024-03-21 15:29:39 +07:00
. filter ( ( part ) = > part !== undefined && part !== null )
2025-04-04 13:45:33 +07:00
. join ( "\n" ) ;
2025-01-22 14:21:41 +07:00
const fullName_aff = fullNameParts
. filter ( ( part ) = > part !== undefined && part !== null && part !== "" )
2025-04-04 13:45:33 +07:00
. join ( "\n" ) ;
2024-03-21 15:29:39 +07:00
return {
no : Extension.ToThaiNumber ( ( index + 1 ) . toLocaleString ( ) ) ,
2025-01-22 14:21:41 +07:00
fullName : fullName_aff ,
2024-07-08 16:58:53 +07:00
affiliation : affiliation ,
2024-03-21 15:29:39 +07:00
position : profile.position ,
2024-04-09 09:25:55 +07:00
posLevel : profile.posLevel
? ` ${ profile . posTypeShort } ${ Extension . ToThaiNumber ( profile . posLevel . toLocaleString ( ) ) } `
2025-01-28 17:31:40 +07:00
: "-" ,
2025-02-03 15:47:29 +07:00
posNumber :
profile . orgShortName || profile . posMasterNo
? Extension . ToThaiNumber ( profile . orgShortName ) +
2025-04-05 18:12:02 +07:00
" " +
2025-02-03 15:47:29 +07:00
Extension . ToThaiNumber ( profile . posMasterNo . toLocaleString ( ) )
: "-" ,
2025-01-28 17:31:40 +07:00
amount : profile.amount ? Extension . ToThaiNumber ( profile . amount . toLocaleString ( ) ) : "-" ,
#1002,#1004,#1006,#1008,#1013,#1015,#1024,#1028,#1036,#1038,#1044,#1047,#1050
2025-01-27 17:14:13 +07:00
score : profile.result ? Extension . ToThaiNumber ( profile . result ) : "-" ,
2024-07-08 09:21:24 +07:00
reason : profile.remark ,
2024-03-21 15:29:39 +07:00
} ;
} ) ;
return new HttpSuccess ( {
2024-03-22 18:02:51 +07:00
template : "emp1-03" ,
reportName : "emp1-03" ,
2024-03-21 15:29:39 +07:00
data : {
year : Extension.ToThaiNumber ( String ( Extension . ToThaiYear ( salaryPeriod . year ) ) ) ,
fifteenPercent : Extension.ToThaiNumber ( fifteenPercent ) ,
yearShort : Extension.ToThaiNumber (
String ( Extension . ToThaiYear ( salaryPeriod . year ) ) . substr ( - 2 ) ,
) ,
yearShortOld : Extension.ToThaiNumber (
String ( Extension . ToThaiYear ( salaryPeriod . year - 1 ) ) . substr ( - 2 ) ,
) ,
agency : agency ,
data : formattedData ,
} ,
} ) ;
}
/ * *
* API 04 - แ บ บ ล จ . ก ท ม . 1 - ร า ย ช ื ่ อ ล ู ก จ ้ า ง ผ ู ้ ส ม ค ว ร ไ ด ้ เ ล ื ่ อ น ข ั ้ น ค ่ า จ ้ า ง
*
* @summary 04 - แ บ บ ล จ . ก ท ม . 1 - ร า ย ช ื ่ อ ล ู ก จ ้ า ง ผ ู ้ ส ม ค ว ร ไ ด ้ เ ล ื ่ อ น ข ั ้ น ค ่ า จ ้ า ง
*
* /
2025-06-04 13:52:02 +07:00
@Get ( "emp-04/{rootId}/{salaryPeriodId}/{type}" )
async SalaryReportEmp1_4 ( @Path ( ) rootId : string , @Path ( ) salaryPeriodId : string , @Path ( ) type : string = 'ALL' ) {
2024-03-21 15:29:39 +07:00
const salaryPeriod = await this . salaryPeriodRepository . findOne ( {
where : {
id : salaryPeriodId ,
} ,
} ) ;
if ( ! salaryPeriod ) {
throw new HttpError ( HttpStatusCode . NOT_FOUND , "ไม่พบข้อมูลการขึ้นเงินเดือน" ) ;
}
2025-05-27 17:45:05 +07:00
let condition : any = {
salaryOrg : {
snapshot : "SNAP2" ,
rootId : rootId ,
salaryPeriodId : salaryPeriodId ,
} ,
} ;
2025-06-04 13:52:02 +07:00
condition . type = In ( [ "HAFT" , "FULL" , "FULLHAFT" ] ) ;
2025-05-27 17:45:05 +07:00
if ( salaryPeriod . period == "APR" ) {
2025-06-04 13:52:02 +07:00
if ( type == "HAFT" ) {
condition . type = "HAFT" ;
} else if ( type == "FULL" ) {
condition . type = "FULL" ;
}
2025-05-27 17:45:05 +07:00
} else {
2025-06-04 13:52:02 +07:00
if ( type == "HAFT" ) {
condition . type = "HAFT" ;
} else if ( type == "FULL" ) {
condition . type = "FULL" ;
} else if ( type == "FULLHAFT" ) {
condition . type = "FULLHAFT" ;
}
2025-05-27 17:45:05 +07:00
}
2024-03-21 16:34:30 +07:00
const _salaryPeriod = await this . salaryProfileEmployeeRepository . find ( {
2024-03-21 15:29:39 +07:00
relations : [ "salaryOrg" , "salaryOrg.salaryPeriod" ] ,
2025-05-27 17:45:05 +07:00
where : condition ,
2024-03-21 15:29:39 +07:00
order : {
2024-03-21 16:34:30 +07:00
amount : "ASC" ,
2025-05-19 11:39:09 +07:00
rootOrder : "ASC" ,
child1Order : "ASC" ,
child2Order : "ASC" ,
child3Order : "ASC" ,
child4Order : "ASC" ,
posMasterNo : "ASC" ,
2024-03-21 15:29:39 +07:00
} ,
} ) ;
if ( ! _salaryPeriod ) {
throw new HttpError ( HttpStatusCode . NOT_FOUND , "ไม่พบข้อมูล" ) ;
}
const agency = _salaryPeriod [ 0 ] == null ? "" : _salaryPeriod [ 0 ] . root ;
const formattedData = _salaryPeriod . map ( ( profile , index ) = > {
const fullNameParts = [
profile . child4 ,
profile . child3 ,
profile . child2 ,
profile . child1 ,
profile . root ,
] ;
2024-07-08 16:58:53 +07:00
const affiliation = fullNameParts
2024-03-21 15:29:39 +07:00
. filter ( ( part ) = > part !== undefined && part !== null )
2025-04-04 13:45:33 +07:00
. join ( "\n" ) ;
2024-07-08 16:58:53 +07:00
const fullName = ` ${ profile . prefix } ${ profile . firstName } ${ profile . lastName } ` ;
2024-03-21 15:29:39 +07:00
return {
no : Extension.ToThaiNumber ( ( index + 1 ) . toLocaleString ( ) ) ,
fullName : fullName ,
2024-07-08 16:58:53 +07:00
affiliation : affiliation ,
2024-03-21 16:34:30 +07:00
position : profile.position ,
2024-04-09 09:25:55 +07:00
posLevel : profile.posLevel
? ` ${ profile . posTypeShort } ${ Extension . ToThaiNumber ( profile . posLevel . toLocaleString ( ) ) } `
2025-01-24 14:14:14 +07:00
: "-" ,
#1002,#1004,#1006,#1008,#1013,#1015,#1024,#1028,#1036,#1038,#1044,#1047,#1050
2025-01-27 17:14:13 +07:00
posNumber :
2025-04-05 18:12:02 +07:00
profile . orgShortName || profile . posMasterNo
#1002,#1004,#1006,#1008,#1013,#1015,#1024,#1028,#1036,#1038,#1044,#1047,#1050
2025-01-27 17:14:13 +07:00
? Extension . ToThaiNumber ( profile . orgShortName ) +
2025-04-05 18:12:02 +07:00
" " +
#1002,#1004,#1006,#1008,#1013,#1015,#1024,#1028,#1036,#1038,#1044,#1047,#1050
2025-01-27 17:14:13 +07:00
Extension . ToThaiNumber ( profile . posMasterNo . toLocaleString ( ) )
: "-" ,
2025-01-24 14:14:14 +07:00
amount : profile.amount ? Extension . ToThaiNumber ( profile . amount . toLocaleString ( ) ) : "-" ,
2024-03-21 16:34:30 +07:00
positionSalaryAmount : profile.positionSalaryAmount
? Extension . ToThaiNumber ( profile . positionSalaryAmount . toLocaleString ( ) )
2025-01-24 14:14:14 +07:00
: "-" ,
#1002,#1004,#1006,#1008,#1013,#1015,#1024,#1028,#1036,#1038,#1044,#1047,#1050
2025-01-27 17:14:13 +07:00
score : profile.result ? Extension . ToThaiNumber ( profile . result ) : "-" , //สรุปผลการประเมินฯ ระดับและคะแนน
2024-07-08 09:21:24 +07:00
reason : profile.remark ,
2024-03-21 15:29:39 +07:00
} ;
} ) ;
return new HttpSuccess ( {
2024-03-22 18:02:51 +07:00
template : "emp1-04" ,
reportName : "emp1-04" ,
2024-03-21 15:29:39 +07:00
data : {
year : Extension.ToThaiNumber ( String ( Extension . ToThaiYear ( salaryPeriod . year ) ) ) ,
agency : agency ,
data : formattedData ,
} ,
} ) ;
}
2025-05-27 17:45:05 +07:00
2024-03-21 15:29:39 +07:00
/ * *
* API 05 - แ บ บ ล จ . ก ท ม . 1 - 1 - ร า ย ช ื ่ อ ล ู ก จ ้ า ง ผ ู ้ ส ม ค ว ร ไ ด ้ ร ั บ ค ่ า ต อ บ แ ท น พ ิ เ ศ ษ
*
* @summary 05 - แ บ บ ล จ . ก ท ม . 1 - 1 - ร า ย ช ื ่ อ ล ู ก จ ้ า ง ผ ู ้ ส ม ค ว ร ไ ด ้ ร ั บ ค ่ า ต อ บ แ ท น พ ิ เ ศ ษ
*
* /
2024-04-01 17:19:32 +07:00
@Get ( "emp-05/{rootId}/{salaryPeriodId}" )
2024-03-22 18:02:51 +07:00
async SalaryReportEmp1_5 ( @Path ( ) rootId : string , @Path ( ) salaryPeriodId : string ) {
2024-03-21 15:29:39 +07:00
const salaryPeriod = await this . salaryPeriodRepository . findOne ( {
where : {
id : salaryPeriodId ,
} ,
} ) ;
if ( ! salaryPeriod ) {
throw new HttpError ( HttpStatusCode . NOT_FOUND , "ไม่พบข้อมูลการขึ้นเงินเดือน" ) ;
}
2024-03-21 16:34:30 +07:00
const _salaryPeriod = await this . salaryProfileEmployeeRepository . find ( {
2024-03-21 15:29:39 +07:00
relations : [ "salaryOrg" , "salaryOrg.salaryPeriod" ] ,
where : {
2024-03-21 16:34:30 +07:00
type : In ( [ "HAFT" , "FULL" , "FULLHAFT" ] ) ,
2025-01-28 17:31:40 +07:00
amountSpecial : MoreThan ( 0 ) ,
2024-03-22 11:31:56 +07:00
isNext : true ,
2024-03-21 15:29:39 +07:00
salaryOrg : {
2024-03-21 16:34:30 +07:00
snapshot : "SNAP2" ,
2024-03-21 15:29:39 +07:00
rootId : rootId ,
salaryPeriodId : salaryPeriodId ,
} ,
} ,
order : {
2024-03-21 16:34:30 +07:00
amount : "ASC" ,
2025-05-19 11:39:09 +07:00
rootOrder : "ASC" ,
child1Order : "ASC" ,
child2Order : "ASC" ,
child3Order : "ASC" ,
child4Order : "ASC" ,
posMasterNo : "ASC" ,
2024-03-21 15:29:39 +07:00
} ,
} ) ;
if ( ! _salaryPeriod ) {
throw new HttpError ( HttpStatusCode . NOT_FOUND , "ไม่พบข้อมูล" ) ;
}
const agency = _salaryPeriod [ 0 ] == null ? "" : _salaryPeriod [ 0 ] . root ;
const formattedData = _salaryPeriod . map ( ( profile , index ) = > {
const fullNameParts = [
profile . child4 ,
profile . child3 ,
profile . child2 ,
profile . child1 ,
profile . root ,
] ;
2024-07-08 16:58:53 +07:00
const affiliation = fullNameParts
2024-03-21 15:29:39 +07:00
. filter ( ( part ) = > part !== undefined && part !== null )
2025-04-04 13:45:33 +07:00
. join ( "\n" ) ;
2024-07-08 16:58:53 +07:00
const fullName = ` ${ profile . prefix } ${ profile . firstName } ${ profile . lastName } ` ;
2024-03-21 15:29:39 +07:00
return {
no : Extension.ToThaiNumber ( ( index + 1 ) . toLocaleString ( ) ) ,
fullName : fullName ,
2024-07-08 16:58:53 +07:00
affiliation : affiliation ,
2025-02-03 15:47:29 +07:00
position : profile.position ? ? "-" ,
2024-04-09 09:25:55 +07:00
posLevel : profile.posLevel
? ` ${ profile . posTypeShort } ${ Extension . ToThaiNumber ( profile . posLevel . toLocaleString ( ) ) } `
2025-01-24 14:14:14 +07:00
: "-" ,
2025-02-03 15:47:29 +07:00
posNumber :
profile . orgShortName || profile . posMasterNo
? Extension . ToThaiNumber ( profile . orgShortName ) +
2025-04-05 18:12:02 +07:00
" " +
2025-02-03 15:47:29 +07:00
Extension . ToThaiNumber ( profile . posMasterNo . toLocaleString ( ) )
: "-" ,
2025-01-24 14:14:14 +07:00
amount : profile.amount ? Extension . ToThaiNumber ( profile . amount . toLocaleString ( ) ) : "-" ,
2024-03-21 16:34:30 +07:00
positionSalaryAmount : profile.positionSalaryAmount
? Extension . ToThaiNumber ( profile . positionSalaryAmount . toLocaleString ( ) )
2025-01-24 14:14:14 +07:00
: "-" ,
2024-04-09 11:54:57 +07:00
amountSpecialFormated :
2024-03-22 11:31:56 +07:00
profile . amountSpecial > 0
? "(" + Extension . ToThaiNumber ( profile . amountSpecial . toString ( ) ) + ")"
2025-01-28 17:31:40 +07:00
: "-" ,
2024-04-09 11:54:57 +07:00
amountSpecial :
#1002,#1004,#1006,#1008,#1013,#1015,#1024,#1028,#1036,#1038,#1044,#1047,#1050
2025-01-27 17:14:13 +07:00
profile . amountSpecial > 0
? Extension . ToThaiNumber ( profile . amountSpecial . toLocaleString ( ) )
2025-01-28 17:31:40 +07:00
: "-" ,
#1002,#1004,#1006,#1008,#1013,#1015,#1024,#1028,#1036,#1038,#1044,#1047,#1050
2025-01-27 17:14:13 +07:00
score : profile.result ? Extension . ToThaiNumber ( profile . result ) : "-" , //สรุปผลการประเมินฯ ระดับและคะแนน
2024-07-08 09:21:24 +07:00
reason : profile.remark ,
2024-03-21 15:29:39 +07:00
} ;
} ) ;
return new HttpSuccess ( {
2024-03-22 18:02:51 +07:00
template : "emp1-05" ,
reportName : "emp1-05" ,
2024-03-21 15:29:39 +07:00
data : {
year : Extension.ToThaiNumber ( String ( Extension . ToThaiYear ( salaryPeriod . year ) ) ) ,
agency : agency ,
data : formattedData ,
} ,
} ) ;
}
/ * *
* API 06 - แ บ บ ล จ . ก ท ม . 2 - ร า ย ช ื ่ อ ล ู ก จ ้ า ง ผ ู ้ ไ ม ่ ส ม ค ว ร เ ล ื ่ อ น ข ั ้ น ค ่ า จ ้ า ง
*
* @summary 06 - แ บ บ ล จ . ก ท ม . 2 - ร า ย ช ื ่ อ ล ู ก จ ้ า ง ผ ู ้ ไ ม ่ ส ม ค ว ร เ ล ื ่ อ น ข ั ้ น ค ่ า จ ้ า ง
*
* /
2024-04-01 17:19:32 +07:00
@Get ( "emp-06/{rootId}/{salaryPeriodId}" )
2024-03-22 18:02:51 +07:00
async SalaryReportEmp1_6 ( @Path ( ) rootId : string , @Path ( ) salaryPeriodId : string ) {
2024-03-21 15:29:39 +07:00
const salaryPeriod = await this . salaryPeriodRepository . findOne ( {
where : {
id : salaryPeriodId ,
} ,
} ) ;
if ( ! salaryPeriod ) {
throw new HttpError ( HttpStatusCode . NOT_FOUND , "ไม่พบข้อมูลการขึ้นเงินเดือน" ) ;
}
2024-03-21 16:34:30 +07:00
const _salaryPeriod = await this . salaryProfileEmployeeRepository . find ( {
2024-03-21 15:29:39 +07:00
relations : [ "salaryOrg" , "salaryOrg.salaryPeriod" ] ,
where : {
2024-03-21 16:34:30 +07:00
type : In ( [ "NONE" ] ) ,
2024-03-21 15:29:39 +07:00
salaryOrg : {
2024-03-21 16:34:30 +07:00
snapshot : "SNAP2" ,
2024-03-21 15:29:39 +07:00
rootId : rootId ,
salaryPeriodId : salaryPeriodId ,
} ,
} ,
order : {
2024-03-21 16:34:30 +07:00
amount : "ASC" ,
2025-05-19 11:39:09 +07:00
rootOrder : "ASC" ,
child1Order : "ASC" ,
child2Order : "ASC" ,
child3Order : "ASC" ,
child4Order : "ASC" ,
posMasterNo : "ASC" ,
2024-03-21 15:29:39 +07:00
} ,
} ) ;
if ( ! _salaryPeriod ) {
throw new HttpError ( HttpStatusCode . NOT_FOUND , "ไม่พบข้อมูล" ) ;
}
const agency = _salaryPeriod [ 0 ] == null ? "" : _salaryPeriod [ 0 ] . root ;
const formattedData = _salaryPeriod . map ( ( profile , index ) = > {
const fullNameParts = [
profile . child4 ,
profile . child3 ,
profile . child2 ,
profile . child1 ,
profile . root ,
] ;
2024-07-08 16:58:53 +07:00
const affiliation = fullNameParts
2024-03-21 15:29:39 +07:00
. filter ( ( part ) = > part !== undefined && part !== null )
2025-04-04 13:45:33 +07:00
. join ( "\n" ) ;
2024-07-08 16:58:53 +07:00
const fullName = ` ${ profile . prefix } ${ profile . firstName } ${ profile . lastName } ` ;
2024-03-21 15:29:39 +07:00
return {
no : Extension.ToThaiNumber ( ( index + 1 ) . toLocaleString ( ) ) ,
fullName : fullName ,
2024-07-08 16:58:53 +07:00
affiliation : affiliation ,
2025-02-03 15:47:29 +07:00
position : profile.position ? ? "-" ,
2024-04-09 09:25:55 +07:00
posLevel : profile.posLevel
? ` ${ profile . posTypeShort } ${ Extension . ToThaiNumber ( profile . posLevel . toLocaleString ( ) ) } `
2025-01-24 14:14:14 +07:00
: "-" ,
2025-02-03 15:47:29 +07:00
posNumber :
profile . orgShortName || profile . posMasterNo
? Extension . ToThaiNumber ( profile . orgShortName ) +
2025-04-05 18:12:02 +07:00
" " +
2025-02-03 15:47:29 +07:00
Extension . ToThaiNumber ( profile . posMasterNo . toLocaleString ( ) )
: "-" ,
2025-01-24 14:14:14 +07:00
amount : profile.amount ? Extension . ToThaiNumber ( profile . amount . toLocaleString ( ) ) : "-" ,
2024-03-21 16:34:30 +07:00
positionSalaryAmount : profile.positionSalaryAmount
? Extension . ToThaiNumber ( profile . positionSalaryAmount . toLocaleString ( ) )
2025-01-24 14:14:14 +07:00
: "-" ,
2025-01-28 17:31:40 +07:00
reasonSign : "" ,
#1002,#1004,#1006,#1008,#1013,#1015,#1024,#1028,#1036,#1038,#1044,#1047,#1050
2025-01-27 17:14:13 +07:00
score : profile.result ? Extension . ToThaiNumber ( profile . result ) : "-" , //สรุปผลการประเมินฯ ระดับและคะแนน
2024-07-08 09:21:24 +07:00
reason : profile.remark , //เหตุผลที่ไม่สมควรหรือไม่อาจเลื่อนขั้นค่าจ้าง
2024-03-21 15:29:39 +07:00
} ;
} ) ;
return new HttpSuccess ( {
2024-03-22 18:02:51 +07:00
template : "emp1-06" ,
reportName : "emp1-06" ,
2024-03-21 15:29:39 +07:00
data : {
year : Extension.ToThaiNumber ( String ( Extension . ToThaiYear ( salaryPeriod . year ) ) ) ,
agency : agency ,
data : formattedData ,
} ,
} ) ;
}
/ * *
* API 07 - แ บ บ ล จ . ก ท ม . 2 - 1 - ร า ย ช ื ่ อ ล ู ก จ ้ า ง ผ ู ้ ไ ม ่ ส ม ค ว ร ไ ด ้ ร ั บ ค ่ า ต อ บ แ ท น พ ิ เ ศ ษ
*
* @summary 07 - แ บ บ ล จ . ก ท ม . 2 - 1 - ร า ย ช ื ่ อ ล ู ก จ ้ า ง ผ ู ้ ไ ม ่ ส ม ค ว ร ไ ด ้ ร ั บ ค ่ า ต อ บ แ ท น พ ิ เ ศ ษ
*
* /
2024-04-01 17:19:32 +07:00
@Get ( "emp-07/{rootId}/{salaryPeriodId}" )
2024-03-22 18:02:51 +07:00
async SalaryReportEmp1_7 ( @Path ( ) rootId : string , @Path ( ) salaryPeriodId : string ) {
2024-03-21 15:29:39 +07:00
const salaryPeriod = await this . salaryPeriodRepository . findOne ( {
where : {
id : salaryPeriodId ,
} ,
} ) ;
if ( ! salaryPeriod ) {
throw new HttpError ( HttpStatusCode . NOT_FOUND , "ไม่พบข้อมูลการขึ้นเงินเดือน" ) ;
}
2024-03-21 16:34:30 +07:00
const _salaryPeriod = await this . salaryProfileEmployeeRepository . find ( {
2024-03-21 15:29:39 +07:00
relations : [ "salaryOrg" , "salaryOrg.salaryPeriod" ] ,
where : {
2025-05-01 17:39:55 +07:00
type : In ( [ "NONE" ] ) ,
// amountSpecial: MoreThan(0),xx
2024-03-21 15:29:39 +07:00
salaryOrg : {
2024-03-21 16:34:30 +07:00
snapshot : "SNAP2" ,
2024-03-21 15:29:39 +07:00
rootId : rootId ,
salaryPeriodId : salaryPeriodId ,
} ,
} ,
order : {
2024-03-21 16:34:30 +07:00
amount : "ASC" ,
2025-05-19 11:39:09 +07:00
rootOrder : "ASC" ,
child1Order : "ASC" ,
child2Order : "ASC" ,
child3Order : "ASC" ,
child4Order : "ASC" ,
posMasterNo : "ASC" ,
2024-03-21 15:29:39 +07:00
} ,
} ) ;
if ( ! _salaryPeriod ) {
throw new HttpError ( HttpStatusCode . NOT_FOUND , "ไม่พบข้อมูล" ) ;
}
const agency = _salaryPeriod [ 0 ] == null ? "" : _salaryPeriod [ 0 ] . root ;
2025-05-16 17:21:23 +07:00
//หาคนที่เงินเดือนเท่ากับเงินเดือนสูงสุดในกลุ่ม
const filteredProfiles = await Promise . all (
_salaryPeriod . map ( async ( profile ) = > {
const salaryRankMax = await this . salaryEmployeeRankRepository
. createQueryBuilder ( "rank" )
. leftJoin ( "rank.salaryEmployee_" , "emp" )
. where ( "emp.isActive = :isActive" , { isActive : true } )
. andWhere ( "emp.group = :group" , { group : profile.group } )
. orderBy ( "rank.step" , "DESC" )
. getOne ( ) ;
const match =
salaryRankMax != null &&
profile . salaryLevel != null &&
profile . salaryLevel === salaryRankMax . step &&
profile . amount === salaryRankMax . salaryMonth ;
if ( ! match ) return null ;
return { profile , salaryRankMax } ;
} )
) ;
const validProfiles = filteredProfiles . filter ( ( item ) : item is { profile : any , salaryRankMax : any } = > item !== null ) ;
const formattedData = validProfiles . map ( ( { profile } , index ) = > {
2024-03-21 15:29:39 +07:00
const fullNameParts = [
profile . child4 ,
profile . child3 ,
profile . child2 ,
profile . child1 ,
profile . root ,
] ;
2025-05-16 17:21:23 +07:00
2024-07-08 16:58:53 +07:00
const affiliation = fullNameParts
2024-03-21 15:29:39 +07:00
. filter ( ( part ) = > part !== undefined && part !== null )
2025-04-04 13:45:33 +07:00
. join ( "\n" ) ;
2024-07-08 16:58:53 +07:00
const fullName = ` ${ profile . prefix } ${ profile . firstName } ${ profile . lastName } ` ;
2025-05-16 17:21:23 +07:00
2024-03-21 15:29:39 +07:00
return {
no : Extension.ToThaiNumber ( ( index + 1 ) . toLocaleString ( ) ) ,
fullName : fullName ,
2024-07-08 16:58:53 +07:00
affiliation : affiliation ,
2025-02-03 15:47:29 +07:00
position : profile.position ? ? "-" ,
2024-04-09 09:25:55 +07:00
posLevel : profile.posLevel
? ` ${ profile . posTypeShort } ${ Extension . ToThaiNumber ( profile . posLevel . toLocaleString ( ) ) } `
2025-01-23 16:29:20 +07:00
: "-" ,
#1002,#1004,#1006,#1008,#1013,#1015,#1024,#1028,#1036,#1038,#1044,#1047,#1050
2025-01-27 17:14:13 +07:00
posNumber :
profile . orgShortName || profile . posMasterNo
? Extension . ToThaiNumber ( profile . orgShortName ) +
2025-04-05 18:12:02 +07:00
" " +
#1002,#1004,#1006,#1008,#1013,#1015,#1024,#1028,#1036,#1038,#1044,#1047,#1050
2025-01-27 17:14:13 +07:00
Extension . ToThaiNumber ( profile . posMasterNo . toLocaleString ( ) )
: "-" ,
2025-05-16 17:21:23 +07:00
amount : profile.amount
? Extension . ToThaiNumber ( profile . amount . toLocaleString ( ) )
: "-" ,
2024-03-21 16:34:30 +07:00
positionSalaryAmount : profile.positionSalaryAmount
? Extension . ToThaiNumber ( profile . positionSalaryAmount . toLocaleString ( ) )
2025-01-23 16:29:20 +07:00
: "-" ,
2025-01-28 17:31:40 +07:00
reasonSign : "" ,
2025-05-16 17:21:23 +07:00
score : profile.result
? Extension . ToThaiNumber ( profile . result )
: "-" ,
reason : profile.remark ,
2024-03-21 15:29:39 +07:00
} ;
} ) ;
2025-05-16 17:21:23 +07:00
2024-03-21 15:29:39 +07:00
return new HttpSuccess ( {
2024-03-22 18:02:51 +07:00
template : "emp1-07" ,
reportName : "emp1-07" ,
2024-03-21 15:29:39 +07:00
data : {
year : Extension.ToThaiNumber ( String ( Extension . ToThaiYear ( salaryPeriod . year ) ) ) ,
agency : agency ,
data : formattedData ,
} ,
} ) ;
}
2025-05-16 17:21:23 +07:00
2024-03-21 16:34:30 +07:00
// /**
// * API 08-แบบ ลจ.กทม.3-บัญชีแสดงวันลาในครึ่งปีของลูกจ้าง
// *
// * @summary 08-แบบ ลจ.กทม.3-บัญชีแสดงวันลาในครึ่งปีของลูกจ้าง
// *
// */
// @Get("emp-08/{rootId}/{salaryPeriodId}")
2024-03-22 18:02:51 +07:00
// async SalaryReportEmp1_8(@Path() rootId: string, @Path() salaryPeriodId: string) {
2024-03-21 16:34:30 +07:00
// const salaryPeriod = await this.salaryPeriodRepository.findOne({
// where: {
// id: salaryPeriodId,
// },
// });
// if (!salaryPeriod) {
// throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลการขึ้นเงินเดือน");
// }
// }
2024-03-21 15:29:39 +07:00
/ * *
* API 09 - บ ั ญ ช ี ร า ย ช ื ่ อ ล ู ก จ ้ า ง ป ร ะ จ ำ ผ ู ้ ไ ม ่ ไ ด ้ ร ั บ เ ล ื ่ อ น ข ั ้ น ค ่ า จ ้ า ง ใ น ว ั น ท ี ่ 1 เ ม ษ า ย ้ อ น ห ล ั ง 3 ค ร ั ้ ง
*
* @summary 09 - บ ั ญ ช ี ร า ย ช ื ่ อ ล ู ก จ ้ า ง ป ร ะ จ ำ ผ ู ้ ไ ม ่ ไ ด ้ ร ั บ เ ล ื ่ อ น ข ั ้ น ค ่ า จ ้ า ง ใ น ว ั น ท ี ่ 1 เ ม ษ า ย ้ อ น ห ล ั ง 3 ค ร ั ้ ง
*
* /
2024-04-01 17:19:32 +07:00
@Get ( "emp-09/{rootId}/{salaryPeriodId}" )
2024-03-22 18:02:51 +07:00
async SalaryReportEmp1_9 ( @Path ( ) rootId : string , @Path ( ) salaryPeriodId : string ) {
2024-03-21 15:29:39 +07:00
const salaryPeriod = await this . salaryPeriodRepository . findOne ( {
where : {
id : salaryPeriodId ,
2024-03-25 15:57:38 +07:00
period : "APR" ,
2024-03-27 16:00:02 +07:00
isActive : true ,
2024-03-21 15:29:39 +07:00
} ,
} ) ;
if ( ! salaryPeriod ) {
throw new HttpError ( HttpStatusCode . NOT_FOUND , "ไม่พบข้อมูลการขึ้นเงินเดือน" ) ;
}
2024-03-25 15:57:38 +07:00
const salaryPeriodAPR = await this . salaryPeriodRepository . findOne ( {
where : {
id : salaryPeriodId ,
year : salaryPeriod.year - 1 ,
period : "APR" ,
2024-03-27 16:00:02 +07:00
isActive : true ,
2024-03-25 15:57:38 +07:00
} ,
} ) ;
const salaryPeriodOCT = await this . salaryPeriodRepository . findOne ( {
where : {
id : salaryPeriodId ,
year : salaryPeriod.year - 1 ,
period : "OCT" ,
2024-03-27 16:00:02 +07:00
isActive : true ,
2024-03-25 15:57:38 +07:00
} ,
} ) ;
const _salaryProfileEmp = await this . salaryProfileEmployeeRepository . find ( {
2024-03-27 16:00:02 +07:00
relations : [ "salaryOrg" ] ,
2024-03-21 15:29:39 +07:00
where : {
salaryOrg : {
2024-03-25 15:57:38 +07:00
snapshot : "SNAP2" ,
2024-03-21 15:29:39 +07:00
rootId : rootId ,
salaryPeriodId : salaryPeriodId ,
} ,
2024-03-27 16:00:02 +07:00
type : "NONE" ,
2024-03-21 15:29:39 +07:00
} ,
order : {
2025-05-19 11:39:09 +07:00
rootOrder : "ASC" ,
child1Order : "ASC" ,
child2Order : "ASC" ,
child3Order : "ASC" ,
child4Order : "ASC" ,
2024-03-21 15:29:39 +07:00
orgShortName : "ASC" ,
posMasterNo : "ASC" ,
} ,
} ) ;
2024-03-25 15:57:38 +07:00
if ( ! _salaryProfileEmp ) {
2024-03-21 15:29:39 +07:00
throw new HttpError ( HttpStatusCode . NOT_FOUND , "ไม่พบข้อมูล" ) ;
}
2024-03-27 16:00:02 +07:00
2024-03-25 15:57:38 +07:00
const _salaryProfileEmpAPR = await this . salaryProfileEmployeeRepository . find ( {
2024-03-27 16:00:02 +07:00
relations : [ "salaryOrg" ] ,
2024-03-25 15:57:38 +07:00
where : {
salaryOrg : {
snapshot : "SNAP2" ,
rootId : rootId ,
salaryPeriodId : salaryPeriodAPR?.id ,
2024-03-27 16:00:02 +07:00
} ,
} ,
2024-03-25 15:57:38 +07:00
} ) ;
const _salaryProfileEmpOCT = await this . salaryProfileEmployeeRepository . find ( {
2024-03-27 16:00:02 +07:00
relations : [ "salaryOrg" ] ,
2024-03-25 15:57:38 +07:00
where : {
salaryOrg : {
snapshot : "SNAP2" ,
rootId : rootId ,
salaryPeriodId : salaryPeriodOCT?.id ,
2024-03-27 16:00:02 +07:00
} ,
} ,
2024-03-25 15:57:38 +07:00
} ) ;
2024-03-21 15:29:39 +07:00
2024-03-25 15:57:38 +07:00
const agency = _salaryProfileEmp [ 0 ] == null ? "" : _salaryProfileEmp [ 0 ] . root ;
const formattedData = _salaryProfileEmp . map ( ( profile , index ) = > {
2024-03-21 15:29:39 +07:00
const fullNameParts = [
profile . child4 ,
profile . child3 ,
profile . child2 ,
profile . child1 ,
profile . root ,
] ;
2024-07-08 16:58:53 +07:00
const affiliation = fullNameParts
2024-03-21 15:29:39 +07:00
. filter ( ( part ) = > part !== undefined && part !== null )
2025-04-04 13:45:33 +07:00
. join ( "\n" ) ;
2024-07-08 16:58:53 +07:00
const fullName = ` ${ profile . prefix } ${ profile . firstName } ${ profile . lastName } ` ;
2024-03-21 15:29:39 +07:00
return {
no : Extension.ToThaiNumber ( ( index + 1 ) . toLocaleString ( ) ) ,
fullName : fullName ,
2024-07-08 16:58:53 +07:00
affiliation : affiliation ,
2025-02-03 15:47:29 +07:00
position : profile.position ? ? "-" ,
2024-03-21 15:29:39 +07:00
posNumber :
2024-04-09 09:25:55 +07:00
Extension . ToThaiNumber ( profile . orgShortName ) +
2025-04-05 18:12:02 +07:00
" " +
2024-04-09 09:25:55 +07:00
Extension . ToThaiNumber ( profile . posMasterNo . toLocaleString ( ) ) ,
2024-03-25 15:57:38 +07:00
amount : profile.amount ? Extension . ToThaiNumber ( profile . amount . toLocaleString ( ) ) : "๐ " ,
2024-03-27 16:00:02 +07:00
type1 :
_salaryProfileEmpAPR . length > 0
? ( ( ) = > {
const _profile = _salaryProfileEmpAPR
. filter ( ( profileAPR ) = > profileAPR . citizenId === profile . citizenId )
. map ( ( profile ) = > ( {
type : profile . type ,
isNext : profile.isNext ,
positionSalaryAmountPer : profile.positionSalaryAmountPer ,
} ) ) ;
if ( _profile [ 0 ] . isNext ) {
return _profile [ 0 ] . positionSalaryAmountPer === 0.02
? "๒%"
: _profile [ 0 ] . positionSalaryAmountPer === 0.04
? "๔%"
: "๖%" ;
}
return _profile [ 0 ] . type === "HALF"
? "๐ .๕ ขั้น"
: _profile [ 0 ] . type === "FULL"
? "๑ ขั้น"
: "ไม่ได้เลื่อนขั้นฯ" ;
} ) ( )
: null , //เมษา ปีก่อนหน้า
type2 :
_salaryProfileEmpOCT . length > 0
? ( ( ) = > {
const _profile = _salaryProfileEmpOCT
. filter ( ( profileOCT ) = > profileOCT . citizenId === profile . citizenId )
. map ( ( profile ) = > ( {
type : profile . type ,
isNext : profile.isNext ,
positionSalaryAmountPer : profile.positionSalaryAmountPer ,
} ) ) ;
if ( _profile [ 0 ] . isNext ) {
return _profile [ 0 ] . positionSalaryAmountPer === 0.02
? "๒%"
: _profile [ 0 ] . positionSalaryAmountPer === 0.04
? "๔%"
: "๖%" ;
}
return _profile [ 0 ] . type === "HALF"
? "๐ .๕ ขั้น"
: _profile [ 0 ] . type === "FULL"
? "๑ ขั้น"
: "ไม่ได้เลื่อนขั้นฯ" ;
} ) ( )
: null , //ตุลา ปีก่อนหน้า
type :
profile . isNext === true
? profile . positionSalaryAmountPer === 0.02
? "๒%"
: profile . positionSalaryAmountPer === 0.04
? "๔%"
: "๖%"
: profile . type === "HALF"
? "๐ .๕ ขั้น"
: profile . type === "FULL"
? "๑ ขั้น"
: "ไม่ได้เลื่อนขั้นฯ" ,
#1002,#1004,#1006,#1008,#1013,#1015,#1024,#1028,#1036,#1038,#1044,#1047,#1050
2025-01-27 17:14:13 +07:00
score : profile.result ? Extension . ToThaiNumber ( profile . result ) : "-" , //ผลการประเมิน
2024-07-08 09:21:24 +07:00
remark : profile.remark , //หมายเหตุ
2024-03-21 15:29:39 +07:00
} ;
} ) ;
return new HttpSuccess ( {
2024-03-22 18:02:51 +07:00
template : "emp1-09" ,
reportName : "emp1-09" ,
2024-03-21 15:29:39 +07:00
data : {
year : Extension.ToThaiNumber ( String ( Extension . ToThaiYear ( salaryPeriod . year ) ) ) ,
2024-03-27 16:00:02 +07:00
yearBeforeSlice : Extension.ToThaiNumber (
String ( Extension . ToThaiYear ( salaryPeriod . year - 1 ) ) . slice ( - 2 ) ,
) ,
yearSlice : Extension.ToThaiNumber (
String ( Extension . ToThaiYear ( salaryPeriod . year ) ) . slice ( - 2 ) ,
) ,
2024-03-21 15:29:39 +07:00
agency : agency ,
data : formattedData ,
} ,
} ) ;
}
2024-03-25 15:57:38 +07:00
2024-04-01 17:19:32 +07:00
/ * *
* API 10 - ร า ย ช ื ่ อ ล ู ก จ ้ า ง ป ร ะ จ ำ ผ ู ้ ม ี ผ ล ก า ร ป ร ะ เ ม ิ น ด ี เ ด ่ น
*
* @summary 10 - ร า ย ช ื ่ อ ล ู ก จ ้ า ง ป ร ะ จ ำ ผ ู ้ ม ี ผ ล ก า ร ป ร ะ เ ม ิ น ด ี เ ด ่ น
*
* /
@Get ( "emp-10/{rootId}/{salaryPeriodId}" )
async SalaryReportEmp1_10 ( @Path ( ) rootId : string , @Path ( ) salaryPeriodId : string ) {
const salaryPeriod = await this . salaryPeriodRepository . findOne ( {
where : {
id : salaryPeriodId ,
2024-04-05 14:22:26 +07:00
isActive : true ,
2024-04-01 17:19:32 +07:00
} ,
} ) ;
if ( ! salaryPeriod ) {
throw new HttpError ( HttpStatusCode . NOT_FOUND , "ไม่พบข้อมูลการขึ้นเงินเดือน" ) ;
}
const salaryProfileEmp = await this . salaryProfileEmployeeRepository . find ( {
relations : [ "salaryOrg" ] ,
where : {
salaryOrg : {
snapshot : "SNAP2" ,
rootId : rootId ,
salaryPeriodId : salaryPeriodId ,
} ,
2025-05-01 17:39:55 +07:00
isGood : true ,
2024-04-01 17:19:32 +07:00
type : Not ( "NONE" ) ,
} ,
order : {
2025-05-19 11:39:09 +07:00
rootOrder : "ASC" ,
child1Order : "ASC" ,
child2Order : "ASC" ,
child3Order : "ASC" ,
child4Order : "ASC" ,
2024-04-01 17:19:32 +07:00
orgShortName : "ASC" ,
posMasterNo : "ASC" ,
} ,
} ) ;
if ( ! salaryProfileEmp ) {
throw new HttpError ( HttpStatusCode . NOT_FOUND , "ไม่พบข้อมูล" ) ;
}
const agency = salaryProfileEmp [ 0 ] == null ? "" : salaryProfileEmp [ 0 ] . root ;
const formattedData = salaryProfileEmp . map ( ( profile , index ) = > {
const fullNameParts = [
profile . child4 ,
profile . child3 ,
profile . child2 ,
profile . child1 ,
profile . root ,
] ;
2024-07-08 16:58:53 +07:00
const affiliation = fullNameParts
2024-04-01 17:19:32 +07:00
. filter ( ( part ) = > part !== undefined && part !== null )
2025-04-04 13:45:33 +07:00
. join ( "\n" ) ;
2024-07-08 16:58:53 +07:00
const fullName = ` ${ profile . prefix } ${ profile . firstName } ${ profile . lastName } ` ;
2024-04-01 17:19:32 +07:00
return {
no : Extension.ToThaiNumber ( ( index + 1 ) . toLocaleString ( ) ) ,
fullName : fullName ,
2024-07-08 16:58:53 +07:00
affiliation : affiliation ,
#1002,#1004,#1006,#1008,#1013,#1015,#1024,#1028,#1036,#1038,#1044,#1047,#1050
2025-01-27 17:14:13 +07:00
position : profile.position ? ? "-" ,
2024-04-25 00:53:57 +07:00
posLevel : profile.posLevel
2025-01-29 15:21:47 +07:00
? ` ${ profile . posTypeShort } ${ Extension . ToThaiNumber ( profile . posLevel . toLocaleString ( ) ) } `
2025-01-24 14:14:14 +07:00
: "-" ,
2024-04-05 14:22:26 +07:00
} ;
2024-04-01 17:19:32 +07:00
} ) ;
return new HttpSuccess ( {
template : "emp1-10" ,
reportName : "emp1-10" ,
data : {
#1002,#1004,#1006,#1008,#1013,#1015,#1024,#1028,#1036,#1038,#1044,#1047,#1050
2025-01-27 17:14:13 +07:00
yearOld : salaryPeriod.year
? Extension . ToThaiNumber ( String ( Extension . ToThaiYear ( salaryPeriod . year - 1 ) ) )
: "" ,
year : salaryPeriod.year
? Extension . ToThaiNumber ( String ( Extension . ToThaiYear ( salaryPeriod . year ) ) )
: "" ,
2024-04-01 17:19:32 +07:00
agency : agency ,
data : formattedData ,
} ,
} ) ;
}
2024-03-21 15:29:39 +07:00
/ * *
* API 11 - ค ำ ส ั ่ ง
*
* @summary 11 - ค ำ ส ั ่ ง
*
* /
2024-04-01 17:19:32 +07:00
@Get ( "emp-11/{rootId}/{salaryPeriodId}" )
2024-03-22 18:02:51 +07:00
async SalaryReportEmp1_11 ( @Path ( ) rootId : string , @Path ( ) salaryPeriodId : string ) {
2024-03-21 15:29:39 +07:00
const salaryPeriod = await this . salaryPeriodRepository . findOne ( {
where : {
id : salaryPeriodId ,
} ,
} ) ;
if ( ! salaryPeriod ) {
throw new HttpError ( HttpStatusCode . NOT_FOUND , "ไม่พบข้อมูลการขึ้นเงินเดือน" ) ;
}
const _salaryPeriod = await this . salaryProfileRepository . find ( {
relations : [ "salaryOrg" , "salaryOrg.salaryPeriod" ] ,
where : {
salaryOrg : {
snapshot : "SNAP1" ,
rootId : rootId ,
salaryPeriodId : salaryPeriodId ,
} ,
} ,
order : {
orgShortName : "ASC" ,
posMasterNo : "ASC" ,
} ,
} ) ;
if ( ! _salaryPeriod ) {
throw new HttpError ( HttpStatusCode . NOT_FOUND , "ไม่พบข้อมูล" ) ;
}
const agency = _salaryPeriod [ 0 ] == null ? "" : _salaryPeriod [ 0 ] . root ;
const formattedData = _salaryPeriod . map ( ( profile , index ) = > {
const fullNameParts = [
profile . child4 ,
profile . child3 ,
profile . child2 ,
profile . child1 ,
profile . root ,
` ${ profile . prefix } ${ profile . firstName } ${ profile . lastName } ` ,
] ;
const fullName = fullNameParts
. filter ( ( part ) = > part !== undefined && part !== null )
2025-01-29 10:13:43 +07:00
. join ( " " ) ;
2024-03-21 15:29:39 +07:00
return {
no : Extension.ToThaiNumber ( ( index + 1 ) . toLocaleString ( ) ) ,
fullName : fullName ,
posLevel : profile.posLevel ,
posNumber :
2024-04-09 09:25:55 +07:00
Extension . ToThaiNumber ( profile . orgShortName ) +
2025-04-05 18:12:02 +07:00
" " +
2024-04-09 09:25:55 +07:00
Extension . ToThaiNumber ( profile . posMasterNo . toLocaleString ( ) ) ,
2024-03-21 15:29:39 +07:00
amount : profile.amount ? Extension . ToThaiNumber ( profile . amount . toLocaleString ( ) ) : null ,
reason : null ,
} ;
} ) ;
return new HttpSuccess ( {
2024-03-22 18:02:51 +07:00
template : "emp1-11" ,
reportName : "emp1-11" ,
2024-03-21 15:29:39 +07:00
data : {
year : Extension.ToThaiNumber ( String ( Extension . ToThaiYear ( salaryPeriod . year ) ) ) ,
agency : agency ,
data : formattedData ,
} ,
} ) ;
}
/ * *
* API 12 - บ ั ญ ช ี ร า ย ล ะ เ อ ี ย ด ผ ู ้ ไ ด ้ ร ั บ อ ั ต ร า ค ่ า จ ้ า ง ส ู ง ก ว ่ า ข ั ้ น ส ู ง ( แ น บ ท ้ า ย ค ำ ส ั ่ ง )
*
* @summary 12 - บ ั ญ ช ี ร า ย ล ะ เ อ ี ย ด ผ ู ้ ไ ด ้ ร ั บ อ ั ต ร า ค ่ า จ ้ า ง ส ู ง ก ว ่ า ข ั ้ น ส ู ง ( แ น บ ท ้ า ย ค ำ ส ั ่ ง )
*
* /
2024-04-01 17:19:32 +07:00
@Get ( "emp-12/{rootId}/{salaryPeriodId}" )
2024-03-22 18:02:51 +07:00
async SalaryReportEmp1_12 ( @Path ( ) rootId : string , @Path ( ) salaryPeriodId : string ) {
2024-03-21 15:29:39 +07:00
const salaryPeriod = await this . salaryPeriodRepository . findOne ( {
where : {
id : salaryPeriodId ,
} ,
} ) ;
if ( ! salaryPeriod ) {
throw new HttpError ( HttpStatusCode . NOT_FOUND , "ไม่พบข้อมูลการขึ้นเงินเดือน" ) ;
}
2024-03-21 16:34:30 +07:00
const _salaryPeriod = await this . salaryProfileEmployeeRepository . find ( {
2024-03-21 15:29:39 +07:00
relations : [ "salaryOrg" , "salaryOrg.salaryPeriod" ] ,
where : {
2024-03-21 16:34:30 +07:00
type : In ( [ "HAFT" , "FULL" , "FULLHAFT" ] ) ,
2025-05-01 16:31:25 +07:00
isNext : true ,
2024-03-21 15:29:39 +07:00
salaryOrg : {
2024-03-21 16:34:30 +07:00
snapshot : "SNAP2" ,
2024-03-21 15:29:39 +07:00
rootId : rootId ,
salaryPeriodId : salaryPeriodId ,
} ,
} ,
order : {
2025-05-19 11:39:09 +07:00
rootOrder : "ASC" ,
child1Order : "ASC" ,
child2Order : "ASC" ,
child3Order : "ASC" ,
child4Order : "ASC" ,
posMasterNo : "ASC" ,
2024-03-21 16:34:30 +07:00
positionSalaryAmount : "ASC" ,
2024-03-21 15:29:39 +07:00
} ,
} ) ;
if ( ! _salaryPeriod ) {
throw new HttpError ( HttpStatusCode . NOT_FOUND , "ไม่พบข้อมูล" ) ;
}
const agency = _salaryPeriod [ 0 ] == null ? "" : _salaryPeriod [ 0 ] . root ;
const formattedData = _salaryPeriod . map ( ( profile , index ) = > {
const fullNameParts = [
profile . child4 ,
profile . child3 ,
profile . child2 ,
profile . child1 ,
profile . root ,
] ;
2024-07-08 16:58:53 +07:00
const affiliation = fullNameParts
2024-03-21 15:29:39 +07:00
. filter ( ( part ) = > part !== undefined && part !== null )
2025-04-04 13:45:33 +07:00
. join ( "\n" ) ;
2024-07-08 16:58:53 +07:00
const fullName = ` ${ profile . prefix } ${ profile . firstName } ${ profile . lastName } ` ;
2024-03-21 15:29:39 +07:00
return {
no : Extension.ToThaiNumber ( ( index + 1 ) . toLocaleString ( ) ) ,
fullName : fullName ,
2024-07-08 16:58:53 +07:00
affiliation : affiliation ,
2024-03-21 16:34:30 +07:00
position : profile.position ,
2024-04-09 09:25:55 +07:00
posLevel : profile.posLevel
? ` ${ profile . posTypeShort } ${ Extension . ToThaiNumber ( profile . posLevel . toLocaleString ( ) ) } `
2025-01-24 14:14:14 +07:00
: "-" ,
#1002,#1004,#1006,#1008,#1013,#1015,#1024,#1028,#1036,#1038,#1044,#1047,#1050
2025-01-27 17:14:13 +07:00
posNumber :
profile . orgShortName || profile . posMasterNo
? Extension . ToThaiNumber ( profile . orgShortName ) +
2025-04-05 18:12:02 +07:00
" " +
#1002,#1004,#1006,#1008,#1013,#1015,#1024,#1028,#1036,#1038,#1044,#1047,#1050
2025-01-27 17:14:13 +07:00
Extension . ToThaiNumber ( profile . posMasterNo . toLocaleString ( ) )
: "-" ,
2025-01-24 14:14:14 +07:00
amount : profile.amount ? Extension . ToThaiNumber ( profile . amount . toLocaleString ( ) ) : "-" ,
2024-03-21 16:34:30 +07:00
positionSalaryAmount : profile.positionSalaryAmount
? Extension . ToThaiNumber ( profile . positionSalaryAmount . toLocaleString ( ) )
2025-01-24 14:14:14 +07:00
: "-" ,
#1002,#1004,#1006,#1008,#1013,#1015,#1024,#1028,#1036,#1038,#1044,#1047,#1050
2025-01-27 17:14:13 +07:00
score : profile.result ? Extension . ToThaiNumber ( profile . result ) : "-" , //สรุปผลการประเมินฯ ระดับและคะแนน
2024-03-21 16:34:30 +07:00
remark :
` ${ profile . type === "FULL" ? "หนึ่งขั้น" : "" } \ n ` +
` ${ profile . type === "FULLHAFT" ? "หนึ่งขั้นครึ่ง" : "" } \ n ` +
` ${ profile . amountSpecial > 0 ? "ได้รับค่าตอบแทนพิเศษ\n" : "" } ` +
` ${ profile . isNext === true ? "(ได้รับเงินเดือนสูงกว่าขั้นสูงฯ)" : "" } ` , // หมายเหตุ
2024-03-21 15:29:39 +07:00
} ;
} ) ;
return new HttpSuccess ( {
2024-03-22 18:02:51 +07:00
template : "emp1-12" ,
reportName : "emp1-12" ,
2024-03-21 15:29:39 +07:00
data : {
year : Extension.ToThaiNumber ( String ( Extension . ToThaiYear ( salaryPeriod . year ) ) ) ,
agency : agency ,
data : formattedData ,
} ,
} ) ;
}
/ * *
* API 13 - บ ั ญ ช ี ร า ย ช ื ่ อ ล ู ก จ ้ า ง ป ร ะ จ ำ ผ ู ้ ไ ม ่ ไ ด ้ ร ั บ ก า ร เ ล ื ่ อ น ข ั ้ น ค ่ า จ ้ า ง
*
* @summary 13 - บ ั ญ ช ี ร า ย ช ื ่ อ ล ู ก จ ้ า ง ป ร ะ จ ำ ผ ู ้ ไ ม ่ ไ ด ้ ร ั บ ก า ร เ ล ื ่ อ น ข ั ้ น ค ่ า จ ้ า ง
*
* /
2024-04-01 17:19:32 +07:00
@Get ( "emp-13/{rootId}/{salaryPeriodId}" )
2024-03-22 18:02:51 +07:00
async SalaryReportEmp1_13 ( @Path ( ) rootId : string , @Path ( ) salaryPeriodId : string ) {
2024-03-21 15:29:39 +07:00
const salaryPeriod = await this . salaryPeriodRepository . findOne ( {
where : {
id : salaryPeriodId ,
} ,
} ) ;
if ( ! salaryPeriod ) {
throw new HttpError ( HttpStatusCode . NOT_FOUND , "ไม่พบข้อมูลการขึ้นเงินเดือน" ) ;
}
2024-03-21 16:34:30 +07:00
const _salaryPeriod = await this . salaryProfileEmployeeRepository . find ( {
2024-03-21 15:29:39 +07:00
relations : [ "salaryOrg" , "salaryOrg.salaryPeriod" ] ,
where : {
2024-03-21 16:34:30 +07:00
type : In ( [ "NONE" ] ) ,
2024-03-21 15:29:39 +07:00
salaryOrg : {
2024-03-21 16:34:30 +07:00
snapshot : "SNAP2" ,
2024-03-21 15:29:39 +07:00
rootId : rootId ,
salaryPeriodId : salaryPeriodId ,
} ,
} ,
order : {
2025-05-19 11:39:09 +07:00
rootOrder : "ASC" ,
child1Order : "ASC" ,
child2Order : "ASC" ,
child3Order : "ASC" ,
child4Order : "ASC" ,
posMasterNo : "ASC" ,
2024-03-21 16:34:30 +07:00
positionSalaryAmount : "ASC" ,
2024-03-21 15:29:39 +07:00
} ,
} ) ;
if ( ! _salaryPeriod ) {
throw new HttpError ( HttpStatusCode . NOT_FOUND , "ไม่พบข้อมูล" ) ;
}
const agency = _salaryPeriod [ 0 ] == null ? "" : _salaryPeriod [ 0 ] . root ;
const formattedData = _salaryPeriod . map ( ( profile , index ) = > {
const fullNameParts = [
profile . child4 ,
profile . child3 ,
profile . child2 ,
profile . child1 ,
profile . root ,
] ;
2024-07-08 16:58:53 +07:00
const affiliation = fullNameParts
2024-03-21 15:29:39 +07:00
. filter ( ( part ) = > part !== undefined && part !== null )
2025-04-04 13:45:33 +07:00
. join ( "\n" ) ;
2024-07-08 16:58:53 +07:00
const fullName = ` ${ profile . prefix } ${ profile . firstName } ${ profile . lastName } ` ;
2024-03-21 15:29:39 +07:00
return {
no : Extension.ToThaiNumber ( ( index + 1 ) . toLocaleString ( ) ) ,
fullName : fullName ,
2024-07-08 16:58:53 +07:00
affiliation : affiliation ,
2025-02-03 15:47:29 +07:00
position : profile.position ? ? "-" ,
2024-04-09 09:25:55 +07:00
posLevel : profile.posLevel
? ` ${ profile . posTypeShort } ${ Extension . ToThaiNumber ( profile . posLevel . toLocaleString ( ) ) } `
2025-01-24 14:14:14 +07:00
: "-" ,
#1002,#1004,#1006,#1008,#1013,#1015,#1024,#1028,#1036,#1038,#1044,#1047,#1050
2025-01-27 17:14:13 +07:00
posNumber :
profile . orgShortName || profile . posMasterNo
? Extension . ToThaiNumber ( profile . orgShortName ) +
2025-04-05 18:12:02 +07:00
" " +
#1002,#1004,#1006,#1008,#1013,#1015,#1024,#1028,#1036,#1038,#1044,#1047,#1050
2025-01-27 17:14:13 +07:00
Extension . ToThaiNumber ( profile . posMasterNo . toLocaleString ( ) )
: "-" ,
2025-01-24 14:14:14 +07:00
amount : profile.amount ? Extension . ToThaiNumber ( profile . amount . toLocaleString ( ) ) : "-" ,
#1002,#1004,#1006,#1008,#1013,#1015,#1024,#1028,#1036,#1038,#1044,#1047,#1050
2025-01-27 17:14:13 +07:00
score : profile.result ? Extension . ToThaiNumber ( profile . result ) : "-" , //สรุปผลการประเมินฯ ระดับและคะแนน
2024-07-08 09:21:24 +07:00
reason : profile.remark , // หมายเหตุ
2024-03-21 15:29:39 +07:00
} ;
} ) ;
return new HttpSuccess ( {
2024-03-22 18:02:51 +07:00
template : "emp1-13" ,
reportName : "emp1-13" ,
2024-03-21 15:29:39 +07:00
data : {
year : Extension.ToThaiNumber ( String ( Extension . ToThaiYear ( salaryPeriod . year ) ) ) ,
agency : agency ,
data : formattedData ,
} ,
} ) ;
}
2024-04-25 00:53:57 +07:00
/ * *
2024-04-09 15:15:23 +07:00
* API 14 - บ ั ญ ช ี ร า ย ช ื ่ อ ล ู ก จ ้ า ง ป ร ะ จ ำ ผ ู ้ ไ ม ่ ไ ด ้ ร ั บ ค ่ า ต อ บ แ ท น พ ิ เ ศ ษ
2024-03-21 15:29:39 +07:00
*
2024-04-09 15:15:23 +07:00
* @summary 14 - บ ั ญ ช ี ร า ย ช ื ่ อ ล ู ก จ ้ า ง ป ร ะ จ ำ ผ ู ้ ไ ม ่ ไ ด ้ ร ั บ ค ่ า ต อ บ แ ท น พ ิ เ ศ ษ
2024-03-21 15:29:39 +07:00
*
* /
2024-04-25 00:53:57 +07:00
@Get ( "emp-14/{rootId}/{salaryPeriodId}" )
async SalaryReportEmp1_14 ( @Path ( ) rootId : string , @Path ( ) salaryPeriodId : string ) {
const salaryPeriod = await this . salaryPeriodRepository . findOne ( {
where : {
id : salaryPeriodId ,
} ,
} ) ;
if ( ! salaryPeriod ) {
throw new HttpError ( HttpStatusCode . NOT_FOUND , "ไม่พบข้อมูลการขึ้นเงินเดือน" ) ;
}
const _salaryPeriod = await this . salaryProfileEmployeeRepository . find ( {
relations : [ "salaryOrg" , "salaryOrg.salaryPeriod" ] ,
where : {
isNext : false ,
salaryOrg : {
snapshot : "SNAP2" ,
rootId : rootId ,
salaryPeriodId : salaryPeriodId ,
} ,
} ,
order : {
2025-05-19 11:39:09 +07:00
rootOrder : "ASC" ,
child1Order : "ASC" ,
child2Order : "ASC" ,
child3Order : "ASC" ,
child4Order : "ASC" ,
posMasterNo : "ASC" ,
2024-04-25 00:53:57 +07:00
positionSalaryAmount : "ASC" ,
} ,
} ) ;
if ( ! _salaryPeriod ) {
throw new HttpError ( HttpStatusCode . NOT_FOUND , "ไม่พบข้อมูล" ) ;
}
const agency = _salaryPeriod [ 0 ] == null ? "" : _salaryPeriod [ 0 ] . root ;
const formattedData = _salaryPeriod . map ( ( profile , index ) = > {
const fullNameParts = [
profile . child4 ,
profile . child3 ,
profile . child2 ,
profile . child1 ,
profile . root ,
] ;
2024-07-08 16:58:53 +07:00
const affiliation = fullNameParts
2024-04-25 00:53:57 +07:00
. filter ( ( part ) = > part !== undefined && part !== null )
2025-04-04 13:45:33 +07:00
. join ( "\n" ) ;
2024-07-08 16:58:53 +07:00
const fullName = ` ${ profile . prefix } ${ profile . firstName } ${ profile . lastName } ` ;
2024-04-25 00:53:57 +07:00
return {
no : Extension.ToThaiNumber ( ( index + 1 ) . toLocaleString ( ) ) ,
fullName : fullName ,
2024-07-08 16:58:53 +07:00
affiliation : affiliation ,
#1002,#1004,#1006,#1008,#1013,#1015,#1024,#1028,#1036,#1038,#1044,#1047,#1050
2025-01-27 17:14:13 +07:00
position : profile.position ? ? "-" ,
2024-04-25 00:53:57 +07:00
posLevel : profile.posLevel
? ` ${ profile . posTypeShort } ${ Extension . ToThaiNumber ( profile . posLevel . toLocaleString ( ) ) } `
2025-01-24 10:21:39 +07:00
: "-" ,
#1002,#1004,#1006,#1008,#1013,#1015,#1024,#1028,#1036,#1038,#1044,#1047,#1050
2025-01-27 17:14:13 +07:00
posNumber :
profile . orgShortName || profile . posMasterNo
? Extension . ToThaiNumber ( profile . orgShortName ) +
2025-04-05 18:12:02 +07:00
" " +
#1002,#1004,#1006,#1008,#1013,#1015,#1024,#1028,#1036,#1038,#1044,#1047,#1050
2025-01-27 17:14:13 +07:00
Extension . ToThaiNumber ( profile . posMasterNo . toLocaleString ( ) )
: "-" ,
2025-01-24 10:21:39 +07:00
amount : profile.amount ? Extension . ToThaiNumber ( profile . amount . toLocaleString ( ) ) : "-" ,
2024-04-25 00:53:57 +07:00
reason : null , // หมายเหตุ
} ;
} ) ;
return new HttpSuccess ( {
template : "emp1-14" ,
reportName : "emp1-14" ,
data : {
year : Extension.ToThaiNumber ( String ( Extension . ToThaiYear ( salaryPeriod . year ) ) ) ,
agency : agency ,
data : formattedData ,
} ,
} ) ;
}
2024-03-21 15:29:39 +07:00
/ * *
* API 15 - บ ั ญ ช ี ร า ย ล ะ เ อ ี ย ด ล ู ก จ ้ า ง ป ร ะ จ ำ ท ี ่ ไ ด ้ ร ั บ ค ่ า ต อ บ แ ท น พ ิ เ ศ ษ ( แ น บ ท ้ า ย ค ำ ส ั ่ ง )
*
* @summary 15 - บ ั ญ ช ี ร า ย ล ะ เ อ ี ย ด ล ู ก จ ้ า ง ป ร ะ จ ำ ท ี ่ ไ ด ้ ร ั บ ค ่ า ต อ บ แ ท น พ ิ เ ศ ษ ( แ น บ ท ้ า ย ค ำ ส ั ่ ง )
*
* /
2024-04-01 17:19:32 +07:00
@Get ( "emp-15/{rootId}/{salaryPeriodId}" )
2024-03-22 18:02:51 +07:00
async SalaryReportEmp1_15 ( @Path ( ) rootId : string , @Path ( ) salaryPeriodId : string ) {
2024-03-21 15:29:39 +07:00
const salaryPeriod = await this . salaryPeriodRepository . findOne ( {
where : {
id : salaryPeriodId ,
} ,
} ) ;
if ( ! salaryPeriod ) {
throw new HttpError ( HttpStatusCode . NOT_FOUND , "ไม่พบข้อมูลการขึ้นเงินเดือน" ) ;
}
2024-03-21 16:34:30 +07:00
const _salaryPeriod = await this . salaryProfileEmployeeRepository . find ( {
2024-03-21 15:29:39 +07:00
relations : [ "salaryOrg" , "salaryOrg.salaryPeriod" ] ,
where : {
2025-05-01 17:39:55 +07:00
// isNext: true,
amountSpecial : MoreThan ( 0 ) ,
2024-03-21 15:29:39 +07:00
salaryOrg : {
2024-03-21 16:34:30 +07:00
snapshot : "SNAP2" ,
2024-03-21 15:29:39 +07:00
rootId : rootId ,
salaryPeriodId : salaryPeriodId ,
} ,
} ,
order : {
2025-05-19 11:39:09 +07:00
rootOrder : "ASC" ,
child1Order : "ASC" ,
child2Order : "ASC" ,
child3Order : "ASC" ,
child4Order : "ASC" ,
posMasterNo : "ASC" ,
2024-03-21 16:34:30 +07:00
positionSalaryAmount : "ASC" ,
2024-03-21 15:29:39 +07:00
} ,
} ) ;
if ( ! _salaryPeriod ) {
throw new HttpError ( HttpStatusCode . NOT_FOUND , "ไม่พบข้อมูล" ) ;
}
const agency = _salaryPeriod [ 0 ] == null ? "" : _salaryPeriod [ 0 ] . root ;
const formattedData = _salaryPeriod . map ( ( profile , index ) = > {
const fullNameParts = [
profile . child4 ,
profile . child3 ,
profile . child2 ,
profile . child1 ,
profile . root ,
] ;
2024-07-08 16:58:53 +07:00
const affiliation = fullNameParts
2024-03-21 15:29:39 +07:00
. filter ( ( part ) = > part !== undefined && part !== null )
2025-04-04 13:45:33 +07:00
. join ( "\n" ) ;
2024-07-08 16:58:53 +07:00
const fullName = ` ${ profile . prefix } ${ profile . firstName } ${ profile . lastName } ` ;
2024-03-21 15:29:39 +07:00
return {
no : Extension.ToThaiNumber ( ( index + 1 ) . toLocaleString ( ) ) ,
fullName : fullName ,
2024-07-08 16:58:53 +07:00
affiliation : affiliation ,
#1002,#1004,#1006,#1008,#1013,#1015,#1024,#1028,#1036,#1038,#1044,#1047,#1050
2025-01-27 17:14:13 +07:00
position : profile.position ? ? "-" ,
2024-04-09 09:25:55 +07:00
posLevel : profile.posLevel
? ` ${ profile . posTypeShort } ${ Extension . ToThaiNumber ( profile . posLevel . toLocaleString ( ) ) } `
2025-01-24 10:21:39 +07:00
: "-" ,
#1002,#1004,#1006,#1008,#1013,#1015,#1024,#1028,#1036,#1038,#1044,#1047,#1050
2025-01-27 17:14:13 +07:00
posNumber :
profile . orgShortName || profile . posMasterNo
? Extension . ToThaiNumber ( profile . orgShortName ) +
2025-04-05 18:12:02 +07:00
" " +
#1002,#1004,#1006,#1008,#1013,#1015,#1024,#1028,#1036,#1038,#1044,#1047,#1050
2025-01-27 17:14:13 +07:00
Extension . ToThaiNumber ( profile . posMasterNo . toLocaleString ( ) )
: "-" ,
2024-03-22 12:32:17 +07:00
amount : profile.positionSalaryAmount
? Extension . ToThaiNumber ( profile . positionSalaryAmount . toLocaleString ( ) )
2025-01-24 10:21:39 +07:00
: "-" ,
2024-03-22 12:32:17 +07:00
precentTwo :
2024-03-27 12:11:09 +07:00
profile . positionSalaryAmountPer == 0.02
2025-05-01 17:59:58 +07:00
? Extension . ToThaiNumber ( profile . amountSpecial . toLocaleString ( ) )
2025-01-24 10:21:39 +07:00
: "-" , //ร้อยละ 2
2024-03-22 12:32:17 +07:00
precentFour :
2024-03-27 12:11:09 +07:00
profile . positionSalaryAmountPer == 0.04
2025-05-01 17:59:58 +07:00
? Extension . ToThaiNumber ( profile . amountSpecial . toLocaleString ( ) )
2025-01-24 10:21:39 +07:00
: "-" , //ร้อยละ 4
2024-03-21 16:34:30 +07:00
reason : null , // หมายเหตุ
2024-03-21 15:29:39 +07:00
} ;
} ) ;
return new HttpSuccess ( {
2024-03-22 18:02:51 +07:00
template : "emp1-15" ,
reportName : "emp1-15" ,
2024-03-21 15:29:39 +07:00
data : {
year : Extension.ToThaiNumber ( String ( Extension . ToThaiYear ( salaryPeriod . year ) ) ) ,
agency : agency ,
data : formattedData ,
} ,
} ) ;
}
/ * *
* API 17 - ค ำ ส ั ่ ง
*
* @summary 17 - ค ำ ส ั ่ ง
*
* /
2024-04-01 17:19:32 +07:00
@Get ( "emp-17/{rootId}/{salaryPeriodId}" )
2024-03-22 18:02:51 +07:00
async SalaryReportEmp1_17 ( @Path ( ) rootId : string , @Path ( ) salaryPeriodId : string ) {
2024-03-21 15:29:39 +07:00
const salaryPeriod = await this . salaryPeriodRepository . findOne ( {
where : {
id : salaryPeriodId ,
} ,
} ) ;
if ( ! salaryPeriod ) {
throw new HttpError ( HttpStatusCode . NOT_FOUND , "ไม่พบข้อมูลการขึ้นเงินเดือน" ) ;
}
const _salaryPeriod = await this . salaryProfileRepository . find ( {
relations : [ "salaryOrg" , "salaryOrg.salaryPeriod" ] ,
where : {
salaryOrg : {
snapshot : "SNAP1" ,
rootId : rootId ,
salaryPeriodId : salaryPeriodId ,
} ,
} ,
order : {
orgShortName : "ASC" ,
posMasterNo : "ASC" ,
} ,
} ) ;
if ( ! _salaryPeriod ) {
throw new HttpError ( HttpStatusCode . NOT_FOUND , "ไม่พบข้อมูล" ) ;
}
const agency = _salaryPeriod [ 0 ] == null ? "" : _salaryPeriod [ 0 ] . root ;
const formattedData = _salaryPeriod . map ( ( profile , index ) = > {
const fullNameParts = [
profile . child4 ,
profile . child3 ,
profile . child2 ,
profile . child1 ,
profile . root ,
` ${ profile . prefix } ${ profile . firstName } ${ profile . lastName } ` ,
] ;
const fullName = fullNameParts
. filter ( ( part ) = > part !== undefined && part !== null )
2025-01-29 10:13:43 +07:00
. join ( " " ) ;
2024-03-21 15:29:39 +07:00
return {
no : Extension.ToThaiNumber ( ( index + 1 ) . toLocaleString ( ) ) ,
fullName : fullName ,
posLevel : profile.posLevel ,
posNumber :
2024-04-09 09:25:55 +07:00
Extension . ToThaiNumber ( profile . orgShortName ) +
2025-04-05 18:12:02 +07:00
" " +
2024-04-09 09:25:55 +07:00
Extension . ToThaiNumber ( profile . posMasterNo . toLocaleString ( ) ) ,
2024-03-21 15:29:39 +07:00
amount : profile.amount ? Extension . ToThaiNumber ( profile . amount . toLocaleString ( ) ) : null ,
reason : null ,
} ;
} ) ;
return new HttpSuccess ( {
2024-03-22 18:02:51 +07:00
template : "emp1-17" ,
reportName : "emp1-17" ,
2024-03-21 15:29:39 +07:00
data : {
year : Extension.ToThaiNumber ( String ( Extension . ToThaiYear ( salaryPeriod . year ) ) ) ,
agency : agency ,
data : formattedData ,
} ,
} ) ;
}
/ * *
* API 18 - ค ำ ส ั ่ ง
*
* @summary 18 - ค ำ ส ั ่ ง
*
* /
2024-04-01 17:19:32 +07:00
@Get ( "emp-18/{rootId}/{salaryPeriodId}" )
2024-03-22 18:02:51 +07:00
async SalaryReportEmp1_18 ( @Path ( ) rootId : string , @Path ( ) salaryPeriodId : string ) {
const salaryPeriod = await this . salaryPeriodRepository . findOne ( {
where : {
id : salaryPeriodId ,
} ,
} ) ;
if ( ! salaryPeriod ) {
throw new HttpError ( HttpStatusCode . NOT_FOUND , "ไม่พบข้อมูลการขึ้นเงินเดือน" ) ;
}
const _salaryPeriod = await this . salaryProfileRepository . find ( {
relations : [ "salaryOrg" , "salaryOrg.salaryPeriod" ] ,
where : {
salaryOrg : {
snapshot : "SNAP1" ,
rootId : rootId ,
salaryPeriodId : salaryPeriodId ,
} ,
} ,
order : {
orgShortName : "ASC" ,
posMasterNo : "ASC" ,
} ,
} ) ;
if ( ! _salaryPeriod ) {
throw new HttpError ( HttpStatusCode . NOT_FOUND , "ไม่พบข้อมูล" ) ;
}
const agency = _salaryPeriod [ 0 ] == null ? "" : _salaryPeriod [ 0 ] . root ;
const formattedData = _salaryPeriod . map ( ( profile , index ) = > {
const fullNameParts = [
profile . child4 ,
profile . child3 ,
profile . child2 ,
profile . child1 ,
profile . root ,
` ${ profile . prefix } ${ profile . firstName } ${ profile . lastName } ` ,
] ;
const fullName = fullNameParts
. filter ( ( part ) = > part !== undefined && part !== null )
2025-01-29 10:13:43 +07:00
. join ( " " ) ;
2024-03-22 18:02:51 +07:00
return {
no : Extension.ToThaiNumber ( ( index + 1 ) . toLocaleString ( ) ) ,
fullName : fullName ,
posLevel : profile.posLevel ,
posNumber :
2024-04-09 09:25:55 +07:00
Extension . ToThaiNumber ( profile . orgShortName ) +
2025-04-05 18:12:02 +07:00
" " +
2024-04-09 09:25:55 +07:00
Extension . ToThaiNumber ( profile . posMasterNo . toLocaleString ( ) ) ,
2024-03-22 18:02:51 +07:00
amount : profile.amount ? Extension . ToThaiNumber ( profile . amount . toLocaleString ( ) ) : null ,
reason : null ,
} ;
} ) ;
return new HttpSuccess ( {
template : "emp1-18" ,
reportName : "emp1-18" ,
data : {
year : Extension.ToThaiNumber ( String ( Extension . ToThaiYear ( salaryPeriod . year ) ) ) ,
agency : agency ,
data : formattedData ,
} ,
} ) ;
}
/ * *
* API 01 - บ ั ญ ช ี ก า ร ค ำ น ว ณ ว ง เ ง ิ น เ ล ื ่ อ น ข ั ้ น ค ่ า จ ้ า ง ล ู ก จ ้ า ง ป ร ะ จ ำ ก ร ุ ง เ ท พ ม ห า น ค ร
*
* @summary 01 - บ ั ญ ช ี ก า ร ค ำ น ว ณ ว ง เ ง ิ น เ ล ื ่ อ น ข ั ้ น ค ่ า จ ้ า ง ล ู ก จ ้ า ง ป ร ะ จ ำ ก ร ุ ง เ ท พ ม ห า น ค ร
*
* /
@Get ( "emp2-01/{rootId}/{salaryPeriodId}" )
async SalaryReportEmp2_1 ( @Path ( ) rootId : string , @Path ( ) salaryPeriodId : string ) {
const salaryPeriod = await this . salaryPeriodRepository . findOne ( {
where : {
id : salaryPeriodId ,
} ,
} ) ;
2025-07-11 13:08:05 +07:00
//*****ปิด Throw ทั้งหมดเพราะ FE อยากได้ preview report เปล่าแทน*****
// if (!salaryPeriod) {
// throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลการขึ้นเงินเดือน");
// }
2024-03-26 16:59:14 +07:00
const salaryPeriodAPR = await this . salaryPeriodRepository . findOne ( {
2024-03-22 18:02:51 +07:00
where : {
2025-07-11 13:08:05 +07:00
year : salaryPeriod?.year ,
2024-03-26 16:59:14 +07:00
period : "APR" ,
2024-03-22 18:02:51 +07:00
} ,
2024-03-26 16:59:14 +07:00
} ) ;
2025-07-11 13:08:05 +07:00
// if (!salaryPeriodAPR) {
// throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลการขึ้นเงินเดือนรอบเดือนเมษายน");
// }
2024-03-26 16:59:14 +07:00
const aprSnap2 = await this . salaryOrgEmployeeRepository . findOne ( {
relations : [ "salaryPeriod" , "salaryProfiles" ] ,
where : {
snapshot : "SNAP2" ,
rootId : rootId ,
2025-07-11 13:08:05 +07:00
salaryPeriodId : salaryPeriodAPR?.id ,
2024-03-22 18:02:51 +07:00
} ,
} ) ;
2025-07-11 13:08:05 +07:00
// if (!aprSnap2) {
// throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล");
// }
2024-03-22 18:02:51 +07:00
2024-03-26 16:59:14 +07:00
const octSnap1 = await this . salaryOrgEmployeeRepository . findOne ( {
relations : [ "salaryPeriod" , "salaryProfiles" ] ,
where : {
snapshot : "SNAP1" ,
group : "GROUP1" ,
rootId : rootId ,
salaryPeriodId : salaryPeriodId ,
} ,
} ) ;
2024-03-22 18:02:51 +07:00
2025-07-11 13:08:05 +07:00
// if (!octSnap1) {
// throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล");
// }
2024-03-22 18:02:51 +07:00
2024-03-26 16:59:14 +07:00
const octSnap2 = await this . salaryOrgEmployeeRepository . findOne ( {
relations : [ "salaryPeriod" , "salaryProfiles" ] ,
where : {
snapshot : "SNAP2" ,
group : "GROUP1" ,
rootId : rootId ,
salaryPeriodId : salaryPeriodId ,
} ,
2024-03-22 18:02:51 +07:00
} ) ;
2025-07-11 13:08:05 +07:00
// if (!octSnap2) {
// throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล");
// }
2024-03-27 16:00:02 +07:00
let fullHaftTotalAmount : any = 0 ;
let fullHaftCount : any = 0 ;
let fullTotalAmount : any = 0 ;
let fullCount : any = 0 ;
let haftTotalAmount : any = 0 ;
let haftCount : any = 0 ;
let noneCount : any = 0 ;
2024-03-26 16:59:14 +07:00
if ( octSnap2 && octSnap2 . salaryProfiles ) {
2024-03-27 16:00:02 +07:00
octSnap2 . salaryProfiles . forEach ( ( profile : any ) = > {
2024-03-26 16:59:14 +07:00
switch ( profile . type ) {
case "FULLHAFT" :
2024-04-11 17:22:20 +07:00
// fullHaftTotalAmount += profile.amount ?? 0;
fullHaftTotalAmount += profile . amountUse > 0 ? profile.amountUse : 0 ;
2024-03-26 16:59:14 +07:00
fullHaftCount ++ ;
break ;
case "FULL" :
2024-04-11 17:22:20 +07:00
// fullTotalAmount += profile.amount ?? 0;
fullTotalAmount += profile . amountUse > 0 ? profile.amountUse : 0 ;
2024-03-26 16:59:14 +07:00
fullCount ++ ;
break ;
case "HAFT" :
2024-04-11 17:22:20 +07:00
// haftTotalAmount += profile.amount ?? 0;
haftTotalAmount += profile . amountUse > 0 ? profile.amountUse : 0 ;
2024-03-26 16:59:14 +07:00
haftCount ++ ;
break ;
case "NONE" :
noneCount ++ ;
break ;
default :
break ;
}
} ) ;
}
const emp2step = new Set ( ) ;
if ( octSnap2 && aprSnap2 ) {
2024-03-27 16:00:02 +07:00
octSnap2 . salaryProfiles . forEach ( ( octProfile ) = > {
aprSnap2 . salaryProfiles . forEach ( ( aprProfile ) = > {
if (
octProfile . citizenId === aprProfile . citizenId &&
( ( octProfile . type === "FULL" && aprProfile . type === "FULL" ) ||
( octProfile . type === "HAFT" && aprProfile . type === "FULLHAFT" ) ||
( octProfile . type === "FULLHAFT" && aprProfile . type === "HAFT" ) )
) {
emp2step . add ( octProfile . citizenId ) ;
}
2024-03-26 16:59:14 +07:00
} ) ;
2024-03-27 16:00:02 +07:00
} ) ;
2024-03-26 16:59:14 +07:00
}
2024-03-27 16:00:02 +07:00
const totalEmp2step = emp2step . size ? ? 0 ;
2024-03-26 16:59:14 +07:00
2024-04-10 14:54:52 +07:00
// const agency = octSnap1.salaryProfiles[0] == null ? "" : octSnap1.salaryProfiles[0].root;
2024-03-22 18:02:51 +07:00
return new HttpSuccess ( {
2024-03-26 16:59:14 +07:00
template : "emp2-01" ,
reportName : "emp2-01" ,
2024-03-22 18:02:51 +07:00
data : {
2025-07-11 13:08:05 +07:00
year : salaryPeriod?.year?Extension.ToThaiNumber ( String ( Extension . ToThaiYear ( salaryPeriod . year ) ) ) : "" ,
yearShort : salaryPeriod?.year?Extension.ToThaiNumber ( String ( Extension . ToThaiYear ( salaryPeriod . year ) ) ) . slice (
2024-03-27 16:00:02 +07:00
- 2 ,
2025-07-11 13:08:05 +07:00
) : "" ,
agency : octSnap1?.root == null ? "" : octSnap1 . root ,
2024-04-10 14:54:52 +07:00
totalUser : octSnap1 == null ? "" : Extension . ToThaiNumber ( octSnap1 . total . toLocaleString ( ) ) ,
2024-03-27 16:00:02 +07:00
totalSalary :
2024-04-10 14:54:52 +07:00
octSnap1 == null ? "" : Extension . ToThaiNumber ( octSnap1 . currentAmount . toLocaleString ( ) ) ,
2024-03-27 16:00:02 +07:00
sixPercent :
2024-04-25 00:53:57 +07:00
octSnap1 == null
? ""
: Extension . ToThaiNumber ( octSnap1 . sixPercentAmount . toLocaleString ( ) ) ,
2024-03-27 16:00:02 +07:00
remainingAmountApr :
2024-04-11 17:22:20 +07:00
// aprSnap2 == null ? "" : Extension.ToThaiNumber(aprSnap2.useAmount.toLocaleString()), //จำนวนเงินที่ใช้เลื่อนขั้นค่าจ้างไปแล้วในวันที่ 1 เม.ย.
2025-07-11 13:08:05 +07:00
aprSnap2 != null && octSnap2 ? Extension . ToThaiNumber ( octSnap2 ? . spentAmount . toLocaleString ( ) ) : "" ,
2024-03-27 16:00:02 +07:00
remainingAmountOct :
2024-04-11 17:22:20 +07:00
//octSnap2 == null ? "" : Extension.ToThaiNumber(octSnap2.spentAmount.toLocaleString()), //เหลือเงินใช้เลื่อนขั้นค่าจ้างในวันที่ 1 ต.ค.
2024-04-25 00:53:57 +07:00
octSnap2 == null
? ""
: Extension . ToThaiNumber (
( octSnap2 . sixPercentAmount - octSnap2 . spentAmount ) . toLocaleString ( ) ,
) ,
2024-04-10 14:54:52 +07:00
totalOld : aprSnap2 == null ? "" : Extension . ToThaiNumber ( aprSnap2 . total . toLocaleString ( ) ) , //จำนวน(คน)(โควตาเลื่อนขั้นค่าจ้าง)
2025-04-05 18:12:02 +07:00
fifteenPercentOld : Extension.ToThaiNumber (
2025-07-11 13:08:05 +07:00
` ${ aprSnap2 ? . fifteenPercent . toLocaleString ( ) } . ${ aprSnap2 ? . fifteenPoint . toLocaleString ( ) } ` ,
2025-04-05 18:12:02 +07:00
) ,
2024-03-27 16:00:02 +07:00
totalUseOld :
2024-04-10 14:54:52 +07:00
aprSnap2 == null ? "" : Extension . ToThaiNumber ( aprSnap2 . quantityUsed . toLocaleString ( ) ) , //พิจารณาให้(คน)(โควตาเลื่อนขั้นค่าจ้าง)
full2 : totalEmp2step == null ? "" : Extension . ToThaiNumber ( totalEmp2step . toLocaleString ( ) ) , //เลื่อนขั้นค่าจ้างรวมทั้งปีสองขั้นจำนวน(คน)
2024-04-25 00:53:57 +07:00
fullHaft :
fullHaftCount == null ? "" : Extension . ToThaiNumber ( fullHaftCount . toLocaleString ( ) ) , //จำนวน(คน)(หนึ่งขั้นครึ่ง)
2024-03-27 16:00:02 +07:00
fullHaftSalary :
2024-04-25 00:53:57 +07:00
fullHaftTotalAmount == null
? ""
: Extension . ToThaiNumber ( fullHaftTotalAmount . toLocaleString ( ) ) , //ใช้เงิน(หนึ่งขั้นครึ่ง)
2024-04-10 14:54:52 +07:00
full : fullCount == null ? "" : Extension . ToThaiNumber ( fullCount . toLocaleString ( ) ) , //จำนวน(คน)(หนึ่งขั้น)
2024-03-27 16:00:02 +07:00
fullSalary :
2024-04-10 14:54:52 +07:00
fullTotalAmount == null ? "" : Extension . ToThaiNumber ( fullTotalAmount . toLocaleString ( ) ) , //ใช้เงิน(หนึ่งขั้น)
haft : haftCount == null ? "" : Extension . ToThaiNumber ( haftCount . toLocaleString ( ) ) , //จำนวน(คน)(ครึ่งขั้น)
2024-03-27 16:00:02 +07:00
haftSalary :
2024-04-10 14:54:52 +07:00
haftTotalAmount == null ? "" : Extension . ToThaiNumber ( haftTotalAmount . toLocaleString ( ) ) , //ใช้เงิน(ครึ่งขั้น)
notPromoted : noneCount == null ? "" : Extension . ToThaiNumber ( noneCount . toLocaleString ( ) ) , //ไม่ได้เลื่อนขั้นค่าจ้างจำนวน(คน)
total : octSnap2 == null ? "" : Extension . ToThaiNumber ( octSnap2 . useAmount . toLocaleString ( ) ) , //รวมใช้เงิน
2024-03-27 16:00:02 +07:00
summary :
2024-04-10 14:54:52 +07:00
octSnap2 == null ? "" : Extension . ToThaiNumber ( octSnap2 . remainingAmount . toLocaleString ( ) ) , //เหลือเงิน
2024-03-22 18:02:51 +07:00
} ,
} ) ;
}
/ * *
* API 02 - ร า ย ช ื ่ อ ล ู ก จ ้ า ง ป ร ะ จ ำ ก ร ุ ง เ ท พ ม ห า น ค ร ผ ู ้ ค ร อ ง ต ำ แ ห น ่ ง
*
* @summary 02 - ร า ย ช ื ่ อ ล ู ก จ ้ า ง ป ร ะ จ ำ ก ร ุ ง เ ท พ ม ห า น ค ร ผ ู ้ ค ร อ ง ต ำ แ ห น ่ ง
*
* /
@Get ( "emp2-02/{rootId}/{salaryPeriodId}" )
async SalaryReportEmp2_2 ( @Path ( ) rootId : string , @Path ( ) salaryPeriodId : string ) {
const salaryPeriod = await this . salaryPeriodRepository . findOne ( {
where : {
id : salaryPeriodId ,
2024-03-27 16:00:02 +07:00
period : "OCT" ,
2024-03-22 18:02:51 +07:00
} ,
} ) ;
if ( ! salaryPeriod ) {
throw new HttpError ( HttpStatusCode . NOT_FOUND , "ไม่พบข้อมูลการขึ้นเงินเดือน" ) ;
}
2024-03-27 16:00:02 +07:00
const salaryPeriodAPR = await this . salaryPeriodRepository . findOne ( {
where : {
period : "APR" ,
year : salaryPeriod?.year ,
} ,
} ) ;
if ( ! salaryPeriodAPR ) {
throw new HttpError ( HttpStatusCode . NOT_FOUND , "ไม่พบข้อมูลการขึ้นเงินเดือน" ) ;
}
const salaryPeriodAPRProfile = await this . salaryProfileEmployeeRepository . find ( {
relations : [ "salaryOrg" ] ,
where : {
salaryOrg : {
snapshot : "SNAP2" ,
rootId : rootId ,
salaryPeriodId : salaryPeriodAPR?.id ,
} ,
} ,
} ) ;
#1002,#1004,#1006,#1008,#1013,#1015,#1024,#1028,#1036,#1038,#1044,#1047,#1050
2025-01-27 17:14:13 +07:00
const salaryPeriodOCTProfile = await this . salaryProfileEmployeeRepository . find ( {
relations : [ "salaryOrg" ] ,
where : {
salaryOrg : {
snapshot : "SNAP2" ,
rootId : rootId ,
salaryPeriodId : salaryPeriod?.id ,
} ,
} ,
} ) ;
2025-07-11 13:08:05 +07:00
// let octPreviousYear:any = null;
// let octPreviousYear2:any = null;
// if (salaryPeriod?.year) {
// const yearMi1 = salaryPeriod.year - 1;
// const yearMi2 = salaryPeriod.year - 2;
2024-03-27 16:00:02 +07:00
2025-07-11 13:08:05 +07:00
// octPreviousYear = await this.salaryPeriodRepository.findOne({
// where: {
// period: "OCT",
// year: yearMi1,
// },
// });
// octPreviousYear2 = await this.salaryPeriodRepository.findOne({
// where: {
// period: "OCT",
// year: yearMi2,
// },
// });
// }
2024-03-27 16:00:02 +07:00
const octPreviousYear = await this . salaryPeriodRepository . findOne ( {
where : {
period : "OCT" ,
year : salaryPeriod?.year - 1 ,
} ,
} ) ;
const octPreviousYear2 = await this . salaryPeriodRepository . findOne ( {
where : {
period : "OCT" ,
year : salaryPeriod?.year - 2 ,
} ,
} ) ;
2024-04-05 14:22:26 +07:00
let octPreviousYearProfile : SalaryProfileEmployee [ ] = [ ] ;
2024-03-27 16:00:02 +07:00
if ( octPreviousYear ) {
2024-04-05 14:22:26 +07:00
octPreviousYearProfile = await this . salaryProfileEmployeeRepository . find ( {
relations : [ "salaryOrg" ] ,
where : {
salaryOrg : {
snapshot : "SNAP2" ,
rootId : rootId ,
salaryPeriodId : octPreviousYear?.id ,
} ,
} ,
} ) ;
2024-03-27 16:00:02 +07:00
}
2024-04-05 14:22:26 +07:00
let octPreviousYearProfile2 : SalaryProfileEmployee [ ] = [ ] ;
2024-03-27 16:00:02 +07:00
if ( octPreviousYear2 ) {
2024-04-05 14:22:26 +07:00
octPreviousYearProfile2 = await this . salaryProfileEmployeeRepository . find ( {
relations : [ "salaryOrg" ] ,
where : {
salaryOrg : {
snapshot : "SNAP2" ,
salaryPeriodId : octPreviousYear2?.id ,
rootId : rootId ,
} ,
} ,
} ) ;
2024-03-27 16:00:02 +07:00
}
2024-03-26 16:59:14 +07:00
const _salaryPeriod = await this . salaryProfileEmployeeRepository . find ( {
2024-03-22 18:02:51 +07:00
relations : [ "salaryOrg" , "salaryOrg.salaryPeriod" ] ,
where : {
salaryOrg : {
snapshot : "SNAP1" ,
rootId : rootId ,
salaryPeriodId : salaryPeriodId ,
} ,
} ,
order : {
2025-05-19 11:39:09 +07:00
rootOrder : "ASC" ,
child1Order : "ASC" ,
child2Order : "ASC" ,
child3Order : "ASC" ,
child4Order : "ASC" ,
2024-03-22 18:02:51 +07:00
orgShortName : "ASC" ,
posMasterNo : "ASC" ,
} ,
} ) ;
if ( ! _salaryPeriod ) {
throw new HttpError ( HttpStatusCode . NOT_FOUND , "ไม่พบข้อมูล" ) ;
}
2024-04-10 14:54:52 +07:00
const _root = await this . salaryOrgEmployeeRepository . findOne ( {
where : {
rootId : rootId ,
salaryPeriodId : salaryPeriodId ,
} ,
} ) ;
// const agency = _salaryPeriod[0] == null ? "" : _salaryPeriod[0].root;
2024-03-22 18:02:51 +07:00
2024-03-27 16:00:02 +07:00
const formattedData = _salaryPeriod . map ( ( profile : any , index : number ) = > {
if ( ! profile ) {
2024-04-05 14:22:26 +07:00
return null ;
2024-03-27 16:00:02 +07:00
}
2024-03-22 18:02:51 +07:00
const fullNameParts = [
profile . child4 ,
profile . child3 ,
profile . child2 ,
profile . child1 ,
profile . root ,
] ;
2024-07-08 16:58:53 +07:00
const affiliation = fullNameParts
2024-03-22 18:02:51 +07:00
. filter ( ( part ) = > part !== undefined && part !== null )
2025-04-04 13:45:33 +07:00
. join ( "\n" ) ;
2024-07-08 16:58:53 +07:00
const fullName = ` ${ profile . prefix } ${ profile . firstName } ${ profile . lastName } ` ;
2024-03-22 18:02:51 +07:00
return {
no : Extension.ToThaiNumber ( ( index + 1 ) . toLocaleString ( ) ) ,
fullName : fullName ,
2024-07-08 16:58:53 +07:00
affiliation : affiliation ,
2025-02-03 15:47:29 +07:00
position : profile.position ? ? "-" ,
2024-03-22 18:02:51 +07:00
posNumber :
2024-04-09 09:25:55 +07:00
Extension . ToThaiNumber ( profile . orgShortName ) +
2025-04-05 18:12:02 +07:00
" " +
2024-04-09 09:25:55 +07:00
Extension . ToThaiNumber ( profile . posMasterNo . toLocaleString ( ) ) ,
#1002,#1004,#1006,#1008,#1013,#1015,#1024,#1028,#1036,#1038,#1044,#1047,#1050
2025-01-27 17:14:13 +07:00
amount : profile.amount ? Extension . ToThaiNumber ( profile . amount . toLocaleString ( ) ) : "-" ,
2024-04-05 14:22:26 +07:00
yearOld2 :
2025-02-03 15:47:29 +07:00
octPreviousYear2 == null ? "-" : Extension . ToThaiNumber ( octPreviousYear2 . year . toString ( ) ) ,
2024-03-27 16:00:02 +07:00
typeOld2 :
2024-04-05 14:22:26 +07:00
octPreviousYear2 && octPreviousYearProfile2 . length > 0
? ( ( ) = > {
const _profile = octPreviousYearProfile2 . filter (
( profileOCT2 ) = > profileOCT2 . citizenId === profile . citizenId ,
) ;
2024-03-27 16:00:02 +07:00
if ( _profile . length > 0 ) {
2024-03-28 10:26:34 +07:00
return _profile [ 0 ] ? . type === "HAFT"
2024-04-05 14:22:26 +07:00
? "๐ .๕ ขั้น"
: _profile [ 0 ] ? . type === "FULL"
2024-03-27 16:00:02 +07:00
? "๑ ขั้น"
2024-03-28 10:26:34 +07:00
: profile ? . type === "FULLHAFT"
2024-04-05 14:22:26 +07:00
? "๑.๕ ขั้น"
: "ไม่ได้เลื่อนขั้นฯ" ;
2024-03-27 16:00:02 +07:00
}
return null ;
2024-04-05 14:22:26 +07:00
} ) ( )
#1002,#1004,#1006,#1008,#1013,#1015,#1024,#1028,#1036,#1038,#1044,#1047,#1050
2025-01-27 17:14:13 +07:00
: "-" ,
2024-04-05 14:22:26 +07:00
yearOld :
#1002,#1004,#1006,#1008,#1013,#1015,#1024,#1028,#1036,#1038,#1044,#1047,#1050
2025-01-27 17:14:13 +07:00
octPreviousYear == null ? "-" : Extension . ToThaiNumber ( octPreviousYear . year . toString ( ) ) ,
2024-03-27 16:00:02 +07:00
typeOld1 :
2024-04-05 14:22:26 +07:00
octPreviousYear && octPreviousYearProfile . length > 0
? ( ( ) = > {
const _profile = octPreviousYearProfile . filter (
( profileOCT ) = > profileOCT . citizenId === profile . citizenId ,
) ;
2024-03-27 16:00:02 +07:00
if ( _profile . length > 0 ) {
2024-04-05 14:22:26 +07:00
return _profile [ 0 ] ? . type === "HAFT"
? "๐ .๕ ขั้น"
: _profile [ 0 ] ? . type === "FULL"
? "๑ ขั้น"
: profile ? . type === "FULLHAFT"
2024-03-27 16:00:02 +07:00
? "๑.๕ ขั้น"
: "ไม่ได้เลื่อนขั้นฯ" ;
}
return null ;
2024-04-05 14:22:26 +07:00
} ) ( )
#1002,#1004,#1006,#1008,#1013,#1015,#1024,#1028,#1036,#1038,#1044,#1047,#1050
2025-01-27 17:14:13 +07:00
: "-" ,
2024-03-27 16:00:02 +07:00
typeOld :
salaryPeriodAPRProfile . length > 0
? ( ( ) = > {
const _profile = salaryPeriodAPRProfile
. filter ( ( profileAPR ) = > profileAPR . citizenId === profile . citizenId )
. map ( ( profile ) = > ( {
type : profile . type ,
} ) ) ;
2024-04-05 14:22:26 +07:00
return _profile [ 0 ] ? . type === "HAFT"
2024-03-27 16:00:02 +07:00
? "๐ .๕ ขั้น"
: _profile [ 0 ] ? . type === "FULL"
2024-04-05 14:22:26 +07:00
? "๑ ขั้น"
: profile ? . type === "FULLHAFT"
? "๑.๕ ขั้น"
: "ไม่ได้เลื่อนขั้นฯ" ;
2024-03-27 16:00:02 +07:00
} ) ( )
#1002,#1004,#1006,#1008,#1013,#1015,#1024,#1028,#1036,#1038,#1044,#1047,#1050
2025-01-27 17:14:13 +07:00
: "-" , //เมษา ปีเดียวกัน
2024-03-27 16:00:02 +07:00
type :
#1002,#1004,#1006,#1008,#1013,#1015,#1024,#1028,#1036,#1038,#1044,#1047,#1050
2025-01-27 17:14:13 +07:00
salaryPeriodOCTProfile . length > 0
? ( ( ) = > {
const _profile = salaryPeriodOCTProfile
. filter ( ( profileOCT ) = > profileOCT . citizenId === profile . citizenId )
. map ( ( profile ) = > ( {
type : profile . type ,
} ) ) ;
return _profile [ 0 ] ? . type === "HAFT"
? "๐ .๕ ขั้น"
: _profile [ 0 ] ? . type === "FULL"
? "๑ ขั้น"
: _profile [ 0 ] ? . type === "FULLHAFT"
? "๑.๕ ขั้น"
: "ไม่ได้เลื่อนขั้นฯ" ;
} ) ( )
: "-" , //ตุลา ปีเดียวกัน
2024-03-22 18:02:51 +07:00
} ;
} ) ;
return new HttpSuccess ( {
2024-03-26 16:59:14 +07:00
template : "emp2-02" ,
reportName : "emp2-02" ,
2024-03-22 18:02:51 +07:00
data : {
2025-07-11 13:08:05 +07:00
year : salaryPeriod?.year?Extension.ToThaiNumber ( String ( Extension . ToThaiYear ( salaryPeriod . year ) ) ) : "" ,
yearOld : salaryPeriod?.year?Extension.ToThaiNumber ( String ( Extension . ToThaiYear ( salaryPeriod . year - 1 ) ) ) : "" ,
yearOld2 : salaryPeriod?.year?Extension.ToThaiNumber ( String ( Extension . ToThaiYear ( salaryPeriod . year - 2 ) ) ) : "" ,
2024-04-10 14:54:52 +07:00
agency : _root?.root == null ? "" : _root ? . root ,
2024-03-22 18:02:51 +07:00
data : formattedData ,
} ,
} ) ;
}
/ * *
* API 03 - ร า ย ช ื ่ อ ล ู ก จ ้ า ง ป ร ะ จ ำ ก ร ุ ง เ ท พ ม ห า น ค ร ผ ู ้ ไ ด ้ ร ั บ ก า ร เ ส น อ ข อ เ ล ื ่ อ น ข ั ้ น ค ่ า จ ้ า ง ร ว ม ท ั ้ ง ป ี ส อ ง ข ั ้ น
*
* @summary 03 - ร า ย ช ื ่ อ ล ู ก จ ้ า ง ป ร ะ จ ำ ก ร ุ ง เ ท พ ม ห า น ค ร ผ ู ้ ไ ด ้ ร ั บ ก า ร เ ส น อ ข อ เ ล ื ่ อ น ข ั ้ น ค ่ า จ ้ า ง ร ว ม ท ั ้ ง ป ี ส อ ง ข ั ้ น
*
* /
@Get ( "emp2-03/{rootId}/{salaryPeriodId}" )
async SalaryReportEmp2_3 ( @Path ( ) rootId : string , @Path ( ) salaryPeriodId : string ) {
const salaryPeriod = await this . salaryPeriodRepository . findOne ( {
where : {
id : salaryPeriodId ,
2024-03-29 14:09:42 +07:00
period : "OCT" ,
2024-04-05 14:22:26 +07:00
isActive : true ,
2024-03-22 18:02:51 +07:00
} ,
} ) ;
if ( ! salaryPeriod ) {
throw new HttpError ( HttpStatusCode . NOT_FOUND , "ไม่พบข้อมูลการขึ้นเงินเดือน" ) ;
}
2024-03-29 11:27:56 +07:00
const fifteenPoint = await this . salaryOrgEmployeeRepository . findOne ( {
2024-04-05 14:22:26 +07:00
where : {
2024-03-29 11:27:56 +07:00
salaryPeriodId : salaryPeriodId ,
rootId : rootId ,
2024-03-29 14:09:42 +07:00
snapshot : "SNAP2" ,
2024-04-05 14:22:26 +07:00
} ,
2024-03-29 14:09:42 +07:00
} ) ;
2024-03-29 11:27:56 +07:00
const fifteenPercentData =
2024-03-29 14:09:42 +07:00
fifteenPoint ? . fifteenPercent == undefined || fifteenPoint ? . fifteenPercent == null
? "๐ "
: Extension . ToThaiNumber ( String ( fifteenPoint ? . fifteenPercent ) ) ;
2024-03-29 11:27:56 +07:00
const fifteenPointData =
fifteenPoint ? . fifteenPoint == undefined || fifteenPoint ? . fifteenPoint == null
? ".๐ ๐ "
: "." + Extension . ToThaiNumber ( String ( fifteenPoint ? . fifteenPoint ) ) ;
2024-04-05 14:22:26 +07:00
2024-03-29 14:09:42 +07:00
const _salaryProfileEmployee = await this . salaryProfileEmployeeRepository . find ( {
2024-04-05 14:22:26 +07:00
relations : [ "salaryOrg" ] ,
where : {
2025-02-03 15:47:29 +07:00
type : Not ( In ( [ "NONE" , "PENDING" ] ) ) ,
2024-04-05 14:22:26 +07:00
salaryOrg : {
snapshot : "SNAP2" ,
rootId : rootId ,
salaryPeriodId : salaryPeriodId ,
2024-03-29 11:27:56 +07:00
} ,
2024-04-05 14:22:26 +07:00
} ,
order : {
2025-05-19 11:39:09 +07:00
rootOrder : "ASC" ,
child1Order : "ASC" ,
child2Order : "ASC" ,
child3Order : "ASC" ,
child4Order : "ASC" ,
2024-04-05 14:22:26 +07:00
orgShortName : "ASC" ,
posMasterNo : "ASC" ,
2025-02-03 15:47:29 +07:00
result : "DESC" ,
2024-04-05 14:22:26 +07:00
} ,
} ) ;
2024-03-29 11:27:56 +07:00
2024-03-29 14:09:42 +07:00
if ( ! _salaryProfileEmployee ) {
2024-03-29 11:27:56 +07:00
throw new HttpError ( HttpStatusCode . NOT_FOUND , "ไม่พบข้อมูล" ) ;
}
2024-04-05 14:22:26 +07:00
2024-03-29 14:09:42 +07:00
const aprSalaryPeriodCurrent = await this . salaryPeriodRepository . findOne ( {
where : {
period : "APR" ,
year : salaryPeriod.year ,
2024-04-05 14:22:26 +07:00
isActive : true ,
2024-03-29 14:09:42 +07:00
} ,
} ) ;
2024-03-29 11:27:56 +07:00
const octPreviousYear = await this . salaryPeriodRepository . findOne ( {
where : {
period : "OCT" ,
year : salaryPeriod?.year - 1 ,
2024-04-05 14:22:26 +07:00
isActive : true ,
2024-03-22 18:02:51 +07:00
} ,
2024-03-29 11:27:56 +07:00
} ) ;
2024-03-29 14:09:42 +07:00
const aprPreviousYear2 = await this . salaryPeriodRepository . findOne ( {
2024-03-29 11:27:56 +07:00
where : {
2024-03-29 14:09:42 +07:00
period : "APR" ,
year : salaryPeriod?.year - 1 ,
2024-04-05 14:22:26 +07:00
isActive : true ,
2024-03-22 18:02:51 +07:00
} ,
} ) ;
2024-03-29 14:09:42 +07:00
let aprPreviousYearProfileCurrent : SalaryProfileEmployee [ ] = [ ] ;
if ( aprSalaryPeriodCurrent ) {
aprPreviousYearProfileCurrent = await this . salaryProfileEmployeeRepository . find ( {
relations : [ "salaryOrg" ] ,
where : {
2025-02-03 15:47:29 +07:00
type : Not ( In ( [ "NONE" , "PENDING" ] ) ) ,
2024-03-29 14:09:42 +07:00
salaryOrg : {
snapshot : "SNAP2" ,
rootId : rootId ,
salaryPeriodId : aprSalaryPeriodCurrent?.id ,
} ,
} ,
} ) ;
}
2024-03-29 11:27:56 +07:00
let octPreviousYearProfile : SalaryProfileEmployee [ ] = [ ] ;
if ( octPreviousYear ) {
octPreviousYearProfile = await this . salaryProfileEmployeeRepository . find ( {
relations : [ "salaryOrg" ] ,
where : {
2025-02-03 15:47:29 +07:00
type : Not ( In ( [ "NONE" , "PENDING" ] ) ) ,
2024-03-29 11:27:56 +07:00
salaryOrg : {
snapshot : "SNAP2" ,
rootId : rootId ,
salaryPeriodId : octPreviousYear?.id ,
} ,
} ,
} ) ;
}
2024-03-22 18:02:51 +07:00
2024-03-29 14:09:42 +07:00
let aprPreviousYearProfile2 : SalaryProfileEmployee [ ] = [ ] ;
if ( aprPreviousYear2 ) {
aprPreviousYearProfile2 = await this . salaryProfileEmployeeRepository . find ( {
2024-03-29 11:27:56 +07:00
relations : [ "salaryOrg" ] ,
where : {
2025-02-03 15:47:29 +07:00
type : Not ( In ( [ "NONE" , "PENDING" ] ) ) ,
2024-03-29 11:27:56 +07:00
salaryOrg : {
snapshot : "SNAP2" ,
2024-03-29 14:09:42 +07:00
salaryPeriodId : aprPreviousYear2?.id ,
2024-03-29 11:27:56 +07:00
rootId : rootId ,
} ,
} ,
} ) ;
2024-03-22 18:02:51 +07:00
}
2025-02-03 15:47:29 +07:00
// ฟังก์ชันที่ใช้ตรวจสอบการตรงตามเงื่อนไข
const checkTypeMatch = ( type1 : any , type2 : any ) = > {
if ( type1 === "FULL" && type2 === "FULL" ) return true ;
if ( type1 === "HAFT" && type2 === "FULLHAFT" ) return true ;
if ( type1 === "FULLHAFT" && type2 === "HAFT" ) return true ;
return false ;
} ;
const formattedData = _salaryProfileEmployee
. filter ( ( profile ) = > {
const matchingProfile = aprPreviousYearProfileCurrent . find (
( profileAPR ) = > profileAPR . citizenId === profile . citizenId ,
) ;
2025-02-21 19:00:24 +07:00
if ( ! matchingProfile ) return false ;
2025-02-03 15:47:29 +07:00
const typeMatch = checkTypeMatch ( matchingProfile . type , profile . type ) ;
return typeMatch ;
} )
. map ( ( profile , index ) = > {
const fullNameParts = [
profile . child4 ,
profile . child3 ,
profile . child2 ,
profile . child1 ,
profile . root ,
] ;
const affiliation = fullNameParts
. filter ( ( part ) = > part !== undefined && part !== null )
2025-04-04 13:45:33 +07:00
. join ( "\n" ) ;
2025-02-03 15:47:29 +07:00
const fullName = ` ${ profile . prefix } ${ profile . firstName } ${ profile . lastName } ` ;
return {
no : Extension.ToThaiNumber ( ( index + 1 ) . toLocaleString ( ) ) ,
fullName : fullName ,
affiliation : affiliation ,
position : profile.position ? ? "-" ,
posLevel : profile.posLevel
2025-02-04 15:27:05 +07:00
? ` ${ profile . posTypeShort } ${ Extension . ToThaiNumber ( profile . posLevel . toLocaleString ( ) ) } `
2025-01-28 17:31:40 +07:00
: "-" ,
2025-02-03 15:47:29 +07:00
posNumber :
profile . orgShortName || profile . posMasterNo
? Extension . ToThaiNumber ( profile . orgShortName ) +
2025-04-05 18:12:02 +07:00
" " +
2025-02-03 15:47:29 +07:00
Extension . ToThaiNumber ( String ( profile . posMasterNo . toLocaleString ( ) ) )
: "-" ,
amount : profile.amount ? Extension . ToThaiNumber ( profile . amount . toLocaleString ( ) ) : "-" ,
// เมษา ปีก่อนหน้า
typeOld2 :
aprPreviousYear2 && aprPreviousYearProfile2 . length > 0
? ( ( ) = > {
const _profile = aprPreviousYearProfile2 . filter (
( profileAPR2 ) = > profileAPR2 . citizenId === profile . citizenId ,
) ;
if ( _profile . length > 0 ) {
return _profile [ 0 ] ? . type === "HAFT"
? "๐ .๕ ขั้น"
: _profile [ 0 ] ? . type === "FULL"
? "๑ ขั้น"
: profile ? . type === "FULLHAFT"
? "๑.๕ ขั้น"
: "ไม่ได้เลื่อนขั้นฯ" ;
}
return null ;
} ) ( )
: "-" ,
yearOld :
octPreviousYear == null
? null
: Extension . ToThaiNumber ( octPreviousYear . year . toString ( ) ) ,
// ตุลา ปีก่อนหน้า
typeOld1 :
octPreviousYear && octPreviousYearProfile . length > 0
? ( ( ) = > {
const _profile = octPreviousYearProfile . filter (
( profileOCT ) = > profileOCT . citizenId === profile . citizenId ,
) ;
if ( _profile . length > 0 ) {
return _profile [ 0 ] ? . type === "HAFT"
? "๐ .๕ ขั้น"
: _profile [ 0 ] ? . type === "FULL"
? "๑ ขั้น"
: profile ? . type === "FULLHAFT"
? "๑.๕ ขั้น"
: "ไม่ได้เลื่อนขั้นฯ" ;
}
return null ;
} ) ( )
: "-" ,
typeOld :
aprPreviousYearProfileCurrent . length > 0
? ( ( ) = > {
const _profile = aprPreviousYearProfileCurrent . filter (
( profileAPR ) = > profileAPR . citizenId === profile . citizenId ,
) ;
const _type = _profile [ 0 ] ? . type ;
return _type === "HAFT"
2024-04-05 14:22:26 +07:00
? "๐ .๕ ขั้น"
2025-02-03 15:47:29 +07:00
: _type === "FULL"
2024-04-05 14:22:26 +07:00
? "๑ ขั้น"
2025-02-03 15:47:29 +07:00
: _type === "FULLHAFT"
2024-03-29 14:09:42 +07:00
? "๑.๕ ขั้น"
: "ไม่ได้เลื่อนขั้นฯ" ;
2025-02-03 15:47:29 +07:00
} ) ( )
: "-" , // เมษา
type :
profile . type === "HAFT"
? "๐ .๕ ขั้น"
: profile . type === "FULL"
? "๑ ขั้น"
: profile . type === "FULLHAFT"
? "๑.๕ ขั้น"
: "ไม่ได้เลื่อนขั้นฯ" ,
score1 : profile.result ? ? "-" ,
score2 : "-" ,
} ;
} ) ;
2024-03-22 18:02:51 +07:00
return new HttpSuccess ( {
2024-03-29 11:27:56 +07:00
template : "emp2-03" ,
2024-04-05 14:22:26 +07:00
reportName : "emp2-03" ,
2024-03-22 18:02:51 +07:00
data : {
year : Extension.ToThaiNumber ( String ( Extension . ToThaiYear ( salaryPeriod . year ) ) ) ,
2024-04-05 14:22:26 +07:00
yearOld : Extension.ToThaiNumber ( String ( Extension . ToThaiYear ( salaryPeriod . year - 1 ) ) ) ,
yearShort : Extension.ToThaiNumber ( String ( Extension . ToThaiYear ( salaryPeriod . year ) ) ) . slice (
- 2 ,
) ,
yearShortOld : Extension.ToThaiNumber (
String ( Extension . ToThaiYear ( salaryPeriod . year - 1 ) ) ,
) . slice ( - 2 ) ,
2024-03-29 11:27:56 +07:00
fifteenPercent : fifteenPercentData + fifteenPointData ,
2024-04-10 14:54:52 +07:00
agency : fifteenPoint?.root == null ? "" : fifteenPoint ? . root ,
2024-03-22 18:02:51 +07:00
data : formattedData ,
} ,
} ) ;
}
2024-04-05 14:22:26 +07:00
2024-03-22 18:02:51 +07:00
/ * *
* API 04 - บ ั ญ ช ี ร า ย ช ื ่ อ ล ู ก จ ้ า ง ป ร ะ จ ำ ก ร ุ ง เ ท พ ม ห า น ค ร ผ ู ้ ส ม ค ว ร ไ ด ้ เ ล ื ่ อ น ข ั ้ น ค ่ า จ ้ า ง ( แ บ บ ล จ . ก ท ม . 1 )
*
* @summary 04 - บ ั ญ ช ี ร า ย ช ื ่ อ ล ู ก จ ้ า ง ป ร ะ จ ำ ก ร ุ ง เ ท พ ม ห า น ค ร ผ ู ้ ส ม ค ว ร ไ ด ้ เ ล ื ่ อ น ข ั ้ น ค ่ า จ ้ า ง ( แ บ บ ล จ . ก ท ม . 1 )
*
* /
2025-06-04 15:32:01 +07:00
@Get ( "emp2-04/{rootId}/{salaryPeriodId}/{type}" )
async SalaryReportEmp2_4 ( @Path ( ) rootId : string , @Path ( ) salaryPeriodId : string , @Path ( ) type : string = 'ALL' ) {
2024-03-22 18:02:51 +07:00
const salaryPeriod = await this . salaryPeriodRepository . findOne ( {
where : {
id : salaryPeriodId ,
emp2-(04, 06, 08, 10, 12, 14, 16, 18, 19, 20, 22, 24)
2024-03-28 17:21:32 +07:00
period : "OCT" ,
2024-04-05 14:22:26 +07:00
isActive : true ,
2024-03-22 18:02:51 +07:00
} ,
} ) ;
if ( ! salaryPeriod ) {
throw new HttpError ( HttpStatusCode . NOT_FOUND , "ไม่พบข้อมูลการขึ้นเงินเดือน" ) ;
}
2025-06-04 15:32:01 +07:00
let condition : any = {
salaryOrg : {
snapshot : "SNAP2" ,
rootId : rootId ,
salaryPeriodId : salaryPeriodId ,
} ,
} ;
condition . type = Not ( "NONE" ) ;
if ( salaryPeriod . period == "APR" ) {
if ( type == "HAFT" ) {
condition . type = "HAFT" ;
} else if ( type == "FULL" ) {
condition . type = "FULL" ;
}
} else {
if ( type == "HAFT" ) {
condition . type = "HAFT" ;
} else if ( type == "FULL" ) {
condition . type = "FULL" ;
} else if ( type == "FULLHAFT" ) {
condition . type = "FULLHAFT" ;
}
}
emp2-(04, 06, 08, 10, 12, 14, 16, 18, 19, 20, 22, 24)
2024-03-28 17:21:32 +07:00
const _salaryProfileEmp = await this . salaryProfileEmployeeRepository . find ( {
2024-03-22 18:02:51 +07:00
relations : [ "salaryOrg" , "salaryOrg.salaryPeriod" ] ,
2025-06-04 15:32:01 +07:00
where : condition ,
2024-03-22 18:02:51 +07:00
order : {
2025-05-19 11:39:09 +07:00
rootOrder : "ASC" ,
child1Order : "ASC" ,
child2Order : "ASC" ,
child3Order : "ASC" ,
child4Order : "ASC" ,
2024-03-22 18:02:51 +07:00
orgShortName : "ASC" ,
posMasterNo : "ASC" ,
} ,
} ) ;
emp2-(04, 06, 08, 10, 12, 14, 16, 18, 19, 20, 22, 24)
2024-03-28 17:21:32 +07:00
if ( ! _salaryProfileEmp ) {
2024-03-22 18:02:51 +07:00
throw new HttpError ( HttpStatusCode . NOT_FOUND , "ไม่พบข้อมูล" ) ;
}
2024-04-10 14:54:52 +07:00
const _root = await this . salaryOrgEmployeeRepository . findOne ( {
where : {
rootId : rootId ,
salaryPeriodId : salaryPeriodId ,
} ,
} ) ;
// const agency = _salaryProfileEmp[0] == null ? "" : _salaryProfileEmp[0].root;
2024-03-22 18:02:51 +07:00
emp2-(04, 06, 08, 10, 12, 14, 16, 18, 19, 20, 22, 24)
2024-03-28 17:21:32 +07:00
const formattedData = _salaryProfileEmp . map ( ( profile , index ) = > {
2024-03-22 18:02:51 +07:00
const fullNameParts = [
profile . child4 ,
profile . child3 ,
profile . child2 ,
profile . child1 ,
profile . root ,
] ;
2024-07-08 16:58:53 +07:00
const affiliation = fullNameParts
2024-03-22 18:02:51 +07:00
. filter ( ( part ) = > part !== undefined && part !== null )
2025-04-04 13:45:33 +07:00
. join ( "\n" ) ;
2024-07-08 16:58:53 +07:00
const fullName = ` ${ profile . prefix } ${ profile . firstName } ${ profile . lastName } ` ;
2024-03-22 18:02:51 +07:00
return {
no : Extension.ToThaiNumber ( ( index + 1 ) . toLocaleString ( ) ) ,
fullName : fullName ,
2024-07-08 16:58:53 +07:00
affiliation : affiliation ,
2025-02-03 15:47:29 +07:00
position : profile.position ? ? "-" ,
2025-01-29 15:21:47 +07:00
//pos\n
2025-02-03 15:47:29 +07:00
// profile.position +
// "\n" +
// (profile.child4 == undefined && profile.child4 == null ? "" : profile.child4 + " ") +
// (profile.child3 == undefined && profile.child3 == null ? "" : profile.child3 + " ") +
// (profile.child2 == undefined && profile.child2 == null ? "" : profile.child2 + " ") +
// (profile.child1 == undefined && profile.child1 == null ? "" : profile.child1 + " ") +
// (profile.root == undefined && profile.root == null ? "" : profile.root),
2025-01-29 15:46:39 +07:00
posLevel : profile.posLevel
? ` ${ profile . posTypeShort } ${ Extension . ToThaiNumber ( profile . posLevel . toLocaleString ( ) ) } `
: "-" ,
#1002,#1004,#1006,#1008,#1013,#1015,#1024,#1028,#1036,#1038,#1044,#1047,#1050
2025-01-27 17:14:13 +07:00
posNumber :
profile . orgShortName || profile . posMasterNo
? Extension . ToThaiNumber ( profile . orgShortName ) +
2025-04-05 18:12:02 +07:00
" " +
#1002,#1004,#1006,#1008,#1013,#1015,#1024,#1028,#1036,#1038,#1044,#1047,#1050
2025-01-27 17:14:13 +07:00
Extension . ToThaiNumber ( profile . posMasterNo . toLocaleString ( ) )
: "-" ,
2025-01-24 14:14:14 +07:00
amount : profile.amount ? Extension . ToThaiNumber ( profile . amount . toLocaleString ( ) ) : "-" ,
emp2-(04, 06, 08, 10, 12, 14, 16, 18, 19, 20, 22, 24)
2024-03-28 17:21:32 +07:00
positionSalaryAmount : profile.positionSalaryAmount
? Extension . ToThaiNumber ( profile . positionSalaryAmount . toLocaleString ( ) )
2025-01-24 14:14:14 +07:00
: "-" ,
#1002,#1004,#1006,#1008,#1013,#1015,#1024,#1028,#1036,#1038,#1044,#1047,#1050
2025-01-27 17:14:13 +07:00
score : profile.result ? Extension . ToThaiNumber ( profile . result ) : "-" ,
2025-01-24 17:24:48 +07:00
// reason: profile.remark,
#1002,#1004,#1006,#1008,#1013,#1015,#1024,#1028,#1036,#1038,#1044,#1047,#1050
2025-01-27 17:14:13 +07:00
reason :
` ${ profile . type === "FULL" ? "หนึ่งขั้น" : "" } \ n ` +
` ${ profile . type === "FULLHAFT" ? "หนึ่งขั้นครึ่ง" : "" } \ n ` +
` ${ profile . amountSpecial > 0 ? "ได้รับค่าตอบแทนพิเศษ\n" : "" } ` +
` ${ profile . isNext === true ? "(ได้รับเงินเดือนสูงกว่าขั้นสูงฯ)" : "" } ` , // หมายเหตุ
2024-03-22 18:02:51 +07:00
} ;
} ) ;
return new HttpSuccess ( {
emp2-(04, 06, 08, 10, 12, 14, 16, 18, 19, 20, 22, 24)
2024-03-28 17:21:32 +07:00
template : "emp2-04" ,
reportName : "emp2-04" ,
2024-03-22 18:02:51 +07:00
data : {
year : Extension.ToThaiNumber ( String ( Extension . ToThaiYear ( salaryPeriod . year ) ) ) ,
2024-04-10 14:54:52 +07:00
agency : _root?.root == null ? "" : _root ? . root ,
2024-03-22 18:02:51 +07:00
data : formattedData ,
} ,
} ) ;
}
/ * *
* API 05 - บ ั ญ ช ี ร า ย ช ื ่ อ ล ู ก จ ้ า ง ป ร ะ จ ำ ก ร ุ ง เ ท พ ม ห า น ค ร ผ ู ้ ส ม ค ว ร ไ ด ้ ร ั บ ค ่ า ต อ บ แ ท น พ ิ เ ศ ษ ( แ บ บ ล จ . ก ท ม . 1 / 1 )
*
* @summary 05 - บ ั ญ ช ี ร า ย ช ื ่ อ ล ู ก จ ้ า ง ป ร ะ จ ำ ก ร ุ ง เ ท พ ม ห า น ค ร ผ ู ้ ส ม ค ว ร ไ ด ้ ร ั บ ค ่ า ต อ บ แ ท น พ ิ เ ศ ษ ( แ บ บ ล จ . ก ท ม . 1 / 1 )
*
* /
@Get ( "emp2-05/{rootId}/{salaryPeriodId}" )
async SalaryReportEmp2_5 ( @Path ( ) rootId : string , @Path ( ) salaryPeriodId : string ) {
const salaryPeriod = await this . salaryPeriodRepository . findOne ( {
where : {
id : salaryPeriodId ,
} ,
} ) ;
if ( ! salaryPeriod ) {
throw new HttpError ( HttpStatusCode . NOT_FOUND , "ไม่พบข้อมูลการขึ้นเงินเดือน" ) ;
}
2024-03-29 11:27:56 +07:00
const _salaryPeriod = await this . salaryProfileEmployeeRepository . find ( {
2024-04-05 14:22:26 +07:00
relations : [ "salaryOrg" , "salaryOrg.salaryPeriod" ] ,
where : {
type : Not ( "NONE" ) ,
2025-05-01 17:39:55 +07:00
amountSpecial : MoreThan ( 0 ) ,
2024-04-05 14:22:26 +07:00
salaryOrg : {
snapshot : "SNAP2" ,
rootId : rootId ,
salaryPeriodId : salaryPeriodId ,
2024-03-29 11:27:56 +07:00
} ,
2024-04-05 14:22:26 +07:00
} ,
order : {
2025-05-19 11:39:09 +07:00
rootOrder : "ASC" ,
child1Order : "ASC" ,
child2Order : "ASC" ,
child3Order : "ASC" ,
child4Order : "ASC" ,
2024-04-05 14:22:26 +07:00
orgShortName : "ASC" ,
posMasterNo : "ASC" ,
} ,
} ) ;
2024-03-22 18:02:51 +07:00
if ( ! _salaryPeriod ) {
throw new HttpError ( HttpStatusCode . NOT_FOUND , "ไม่พบข้อมูล" ) ;
}
2024-04-10 14:54:52 +07:00
const _root = await this . salaryOrgEmployeeRepository . findOne ( {
where : {
rootId : rootId ,
salaryPeriodId : salaryPeriodId ,
} ,
} ) ;
// const agency = _salaryPeriod[0] == null ? "" : _salaryPeriod[0].root;
2024-03-22 18:02:51 +07:00
const formattedData = _salaryPeriod . map ( ( profile , index ) = > {
const fullNameParts = [
profile . child4 ,
profile . child3 ,
profile . child2 ,
profile . child1 ,
profile . root ,
] ;
2024-07-08 16:58:53 +07:00
const affiliation = fullNameParts
2024-03-22 18:02:51 +07:00
. filter ( ( part ) = > part !== undefined && part !== null )
2025-04-04 13:45:33 +07:00
. join ( "\n" ) ;
2024-07-08 16:58:53 +07:00
const fullName = ` ${ profile . prefix } ${ profile . firstName } ${ profile . lastName } ` ;
2024-03-22 18:02:51 +07:00
return {
no : Extension.ToThaiNumber ( ( index + 1 ) . toLocaleString ( ) ) ,
fullName : fullName ,
2024-07-08 16:58:53 +07:00
affiliation : affiliation ,
2024-03-29 11:27:56 +07:00
position : profile.position ,
2025-02-04 15:27:05 +07:00
posLevel : profile.posLevel
? ` ${ profile . posTypeShort } ${ Extension . ToThaiNumber ( profile . posLevel . toLocaleString ( ) ) } `
: "-" ,
2024-03-22 18:02:51 +07:00
posNumber :
2024-04-09 09:25:55 +07:00
Extension . ToThaiNumber ( profile . orgShortName ) +
2025-04-05 18:12:02 +07:00
" " +
2024-04-09 09:25:55 +07:00
Extension . ToThaiNumber ( profile . posMasterNo . toLocaleString ( ) ) ,
2024-04-05 14:22:26 +07:00
positionSalaryAmount : profile.positionSalaryAmount
? Extension . ToThaiNumber ( profile . positionSalaryAmount . toLocaleString ( ) )
2025-02-04 15:27:05 +07:00
: "-" ,
2024-04-05 14:22:26 +07:00
amountSpecial : profile.amountSpecial
? Extension . ToThaiNumber ( profile . amountSpecial . toLocaleString ( ) )
2025-02-04 15:27:05 +07:00
: "-" ,
2025-02-21 19:00:24 +07:00
score : profile.result ? ? "-" ,
2024-03-22 18:02:51 +07:00
reason : null ,
} ;
} ) ;
return new HttpSuccess ( {
2024-03-29 11:27:56 +07:00
template : "emp2-05" ,
2024-04-05 14:22:26 +07:00
reportName : "emp2-05" ,
2024-03-22 18:02:51 +07:00
data : {
year : Extension.ToThaiNumber ( String ( Extension . ToThaiYear ( salaryPeriod . year ) ) ) ,
2024-04-10 14:54:52 +07:00
agency : _root?.root == null ? "" : _root ? . root ,
2024-03-22 18:02:51 +07:00
data : formattedData ,
} ,
} ) ;
}
/ * *
* API 06 - บ ั ญ ช ี ร า ย ช ื ่ อ ล ู ก จ ้ า ง ป ร ะ จ ำ ก ร ุ ง เ ท พ ม ห า น ค ร ผ ู ้ ไ ม ่ ส ม ค ว ร เ ล ื ่ อ น ข ั ้ น ค ่ า จ ้ า ง ( แ บ บ ล จ . ก ท ม . 2 )
*
* @summary 06 - บ ั ญ ช ี ร า ย ช ื ่ อ ล ู ก จ ้ า ง ป ร ะ จ ำ ก ร ุ ง เ ท พ ม ห า น ค ร ผ ู ้ ไ ม ่ ส ม ค ว ร เ ล ื ่ อ น ข ั ้ น ค ่ า จ ้ า ง ( แ บ บ ล จ . ก ท ม . 2 )
*
* /
@Get ( "emp2-06/{rootId}/{salaryPeriodId}" )
async SalaryReportEmp2_6 ( @Path ( ) rootId : string , @Path ( ) salaryPeriodId : string ) {
const salaryPeriod = await this . salaryPeriodRepository . findOne ( {
where : {
id : salaryPeriodId ,
emp2-(04, 06, 08, 10, 12, 14, 16, 18, 19, 20, 22, 24)
2024-03-28 17:21:32 +07:00
period : "OCT" ,
2024-04-05 14:22:26 +07:00
isActive : true ,
2024-03-22 18:02:51 +07:00
} ,
} ) ;
if ( ! salaryPeriod ) {
throw new HttpError ( HttpStatusCode . NOT_FOUND , "ไม่พบข้อมูลการขึ้นเงินเดือน" ) ;
}
emp2-(04, 06, 08, 10, 12, 14, 16, 18, 19, 20, 22, 24)
2024-03-28 17:21:32 +07:00
const _salaryProfileEmp = await this . salaryProfileEmployeeRepository . find ( {
2024-03-22 18:02:51 +07:00
relations : [ "salaryOrg" , "salaryOrg.salaryPeriod" ] ,
where : {
salaryOrg : {
emp2-(04, 06, 08, 10, 12, 14, 16, 18, 19, 20, 22, 24)
2024-03-28 17:21:32 +07:00
snapshot : "SNAP2" ,
2024-03-22 18:02:51 +07:00
rootId : rootId ,
salaryPeriodId : salaryPeriodId ,
} ,
2024-04-05 14:22:26 +07:00
type : "NONE" ,
2024-03-22 18:02:51 +07:00
} ,
order : {
2025-05-19 11:39:09 +07:00
rootOrder : "ASC" ,
child1Order : "ASC" ,
child2Order : "ASC" ,
child3Order : "ASC" ,
child4Order : "ASC" ,
2024-03-22 18:02:51 +07:00
orgShortName : "ASC" ,
posMasterNo : "ASC" ,
} ,
} ) ;
emp2-(04, 06, 08, 10, 12, 14, 16, 18, 19, 20, 22, 24)
2024-03-28 17:21:32 +07:00
if ( ! _salaryProfileEmp ) {
2024-03-22 18:02:51 +07:00
throw new HttpError ( HttpStatusCode . NOT_FOUND , "ไม่พบข้อมูล" ) ;
}
2024-04-10 14:54:52 +07:00
const _root = await this . salaryOrgEmployeeRepository . findOne ( {
where : {
rootId : rootId ,
salaryPeriodId : salaryPeriodId ,
} ,
} ) ;
// const agency = _salaryProfileEmp[0] == null ? "" : _salaryProfileEmp[0].root;
2024-03-22 18:02:51 +07:00
emp2-(04, 06, 08, 10, 12, 14, 16, 18, 19, 20, 22, 24)
2024-03-28 17:21:32 +07:00
const formattedData = _salaryProfileEmp . map ( ( profile , index ) = > {
2024-03-22 18:02:51 +07:00
const fullNameParts = [
profile . child4 ,
profile . child3 ,
profile . child2 ,
profile . child1 ,
profile . root ,
] ;
2024-07-08 16:58:53 +07:00
const affiliation = fullNameParts
2024-03-22 18:02:51 +07:00
. filter ( ( part ) = > part !== undefined && part !== null )
2025-04-04 13:45:33 +07:00
. join ( "\n" ) ;
2025-01-24 10:21:39 +07:00
2024-07-08 16:58:53 +07:00
const fullName = ` ${ profile . prefix } ${ profile . firstName } ${ profile . lastName } ` ;
2024-03-22 18:02:51 +07:00
return {
no : Extension.ToThaiNumber ( ( index + 1 ) . toLocaleString ( ) ) ,
fullName : fullName ,
2024-07-08 16:58:53 +07:00
affiliation : affiliation ,
2025-01-24 14:14:14 +07:00
position : profile.position ? ? "-" ,
#1002,#1004,#1006,#1008,#1013,#1015,#1024,#1028,#1036,#1038,#1044,#1047,#1050
2025-01-27 17:14:13 +07:00
posLevel : profile.posLevel
2025-01-29 15:21:47 +07:00
? ` ${ profile . posTypeShort } ${ Extension . ToThaiNumber ( profile . posLevel . toLocaleString ( ) ) } `
#1002,#1004,#1006,#1008,#1013,#1015,#1024,#1028,#1036,#1038,#1044,#1047,#1050
2025-01-27 17:14:13 +07:00
: "-" ,
posNumber :
profile . orgShortName || profile . posMasterNo
? Extension . ToThaiNumber ( profile . orgShortName ) +
2025-04-05 18:12:02 +07:00
" " +
#1002,#1004,#1006,#1008,#1013,#1015,#1024,#1028,#1036,#1038,#1044,#1047,#1050
2025-01-27 17:14:13 +07:00
Extension . ToThaiNumber ( profile . posMasterNo . toLocaleString ( ) )
: "-" ,
2025-01-24 10:21:39 +07:00
amount : profile.amount ? Extension . ToThaiNumber ( profile . amount . toLocaleString ( ) ) : "-" ,
emp2-(04, 06, 08, 10, 12, 14, 16, 18, 19, 20, 22, 24)
2024-03-28 17:21:32 +07:00
positionSalaryAmount : profile.positionSalaryAmount
? Extension . ToThaiNumber ( profile . positionSalaryAmount . toLocaleString ( ) )
2025-01-24 10:21:39 +07:00
: "-" ,
#1002,#1004,#1006,#1008,#1013,#1015,#1024,#1028,#1036,#1038,#1044,#1047,#1050
2025-01-27 17:14:13 +07:00
score : profile.result ? Extension . ToThaiNumber ( profile . result ) : "-" ,
2024-07-08 09:21:24 +07:00
reason : profile.remark ,
2024-08-23 14:10:34 +07:00
remark : null ,
2024-03-22 18:02:51 +07:00
} ;
} ) ;
return new HttpSuccess ( {
emp2-(04, 06, 08, 10, 12, 14, 16, 18, 19, 20, 22, 24)
2024-03-28 17:21:32 +07:00
template : "emp2-06" ,
reportName : "emp2-06" ,
2024-03-22 18:02:51 +07:00
data : {
year : Extension.ToThaiNumber ( String ( Extension . ToThaiYear ( salaryPeriod . year ) ) ) ,
2024-04-10 14:54:52 +07:00
agency : _root?.root == null ? "" : _root ? . root ,
2024-03-22 18:02:51 +07:00
data : formattedData ,
} ,
} ) ;
}
/ * *
* API 07 - บ ั ญ ช ี ร า ย ช ื ่ อ ล ู ก จ ้ า ง ป ร ะ จ ำ ก ร ุ ง เ ท พ ม ห า น ค ร ผ ู ้ ไ ม ่ ส ม ค ว ร ไ ด ้ ร ั บ ค ่ า ต อ บ แ ท น พ ิ เ ศ ษ ( แ บ บ ล จ . ก ท ม . 2 / 1 )
*
* @summary 07 - บ ั ญ ช ี ร า ย ช ื ่ อ ล ู ก จ ้ า ง ป ร ะ จ ำ ก ร ุ ง เ ท พ ม ห า น ค ร ผ ู ้ ไ ม ่ ส ม ค ว ร ไ ด ้ ร ั บ ค ่ า ต อ บ แ ท น พ ิ เ ศ ษ ( แ บ บ ล จ . ก ท ม . 2 / 1 )
*
* /
@Get ( "emp2-07/{rootId}/{salaryPeriodId}" )
async SalaryReportEmp2_7 ( @Path ( ) rootId : string , @Path ( ) salaryPeriodId : string ) {
const salaryPeriod = await this . salaryPeriodRepository . findOne ( {
where : {
id : salaryPeriodId ,
} ,
} ) ;
if ( ! salaryPeriod ) {
throw new HttpError ( HttpStatusCode . NOT_FOUND , "ไม่พบข้อมูลการขึ้นเงินเดือน" ) ;
}
2024-03-29 11:27:56 +07:00
const _salaryPeriod = await this . salaryProfileEmployeeRepository . find ( {
2024-04-05 14:22:26 +07:00
relations : [ "salaryOrg" , "salaryOrg.salaryPeriod" ] ,
where : {
2025-05-01 17:39:55 +07:00
type : In ( [ "NONE" ] ) ,
// amountSpecial: MoreThan(0),xx
2024-04-05 14:22:26 +07:00
salaryOrg : {
snapshot : "SNAP2" ,
rootId : rootId ,
salaryPeriodId : salaryPeriodId ,
2024-03-29 11:27:56 +07:00
} ,
2024-04-05 14:22:26 +07:00
} ,
order : {
2025-05-19 11:39:09 +07:00
rootOrder : "ASC" ,
child1Order : "ASC" ,
child2Order : "ASC" ,
child3Order : "ASC" ,
child4Order : "ASC" ,
2024-04-05 14:22:26 +07:00
orgShortName : "ASC" ,
posMasterNo : "ASC" ,
} ,
} ) ;
2024-03-22 18:02:51 +07:00
if ( ! _salaryPeriod ) {
throw new HttpError ( HttpStatusCode . NOT_FOUND , "ไม่พบข้อมูล" ) ;
}
2024-04-10 14:54:52 +07:00
const _root = await this . salaryOrgEmployeeRepository . findOne ( {
where : {
rootId : rootId ,
salaryPeriodId : salaryPeriodId ,
} ,
} ) ;
// const agency = _salaryPeriod[0] == null ? "" : _salaryPeriod[0].root;
2024-03-22 18:02:51 +07:00
2025-05-16 17:21:23 +07:00
//หาคนที่เงินเดือนเท่ากับเงินเดือนสูงสุดในกลุ่ม
const filteredProfiles = await Promise . all (
_salaryPeriod . map ( async ( profile ) = > {
const salaryRankMax = await this . salaryEmployeeRankRepository
. createQueryBuilder ( "rank" )
. leftJoin ( "rank.salaryEmployee_" , "emp" )
. where ( "emp.isActive = :isActive" , { isActive : true } )
. andWhere ( "emp.group = :group" , { group : profile.group } )
. orderBy ( "rank.step" , "DESC" )
. getOne ( ) ;
const match =
salaryRankMax != null &&
profile . salaryLevel != null &&
profile . salaryLevel === salaryRankMax . step &&
profile . amount === salaryRankMax . salaryMonth ;
if ( ! match ) return null ;
return { profile , salaryRankMax } ;
} )
) ;
const validProfiles = filteredProfiles . filter ( ( item ) : item is { profile : any , salaryRankMax : any } = > item !== null ) ;
const formattedData = validProfiles . map ( ( { profile } , index ) = > {
2024-03-22 18:02:51 +07:00
const fullNameParts = [
profile . child4 ,
profile . child3 ,
profile . child2 ,
profile . child1 ,
profile . root ,
] ;
2024-07-12 10:22:36 +07:00
const affiliation = fullNameParts
2024-03-22 18:02:51 +07:00
. filter ( ( part ) = > part !== undefined && part !== null )
2025-04-04 13:45:33 +07:00
. join ( "\n" ) ;
2024-07-12 10:22:36 +07:00
const fullName = ` ${ profile . prefix } ${ profile . firstName } ${ profile . lastName } ` ;
2024-03-22 18:02:51 +07:00
return {
no : Extension.ToThaiNumber ( ( index + 1 ) . toLocaleString ( ) ) ,
fullName : fullName ,
2024-07-12 10:22:36 +07:00
affiliation : affiliation ,
#1002,#1004,#1006,#1008,#1013,#1015,#1024,#1028,#1036,#1038,#1044,#1047,#1050
2025-01-27 17:14:13 +07:00
position : profile.position ? ? "-" ,
posLevel : profile.posLevel
2025-01-29 15:21:47 +07:00
? ` ${ profile . posTypeShort } ${ Extension . ToThaiNumber ( profile . posLevel . toLocaleString ( ) ) } `
#1002,#1004,#1006,#1008,#1013,#1015,#1024,#1028,#1036,#1038,#1044,#1047,#1050
2025-01-27 17:14:13 +07:00
: "-" ,
posNumber :
profile . orgShortName || profile . posMasterNo
? Extension . ToThaiNumber ( profile . orgShortName ) +
2025-04-05 18:12:02 +07:00
" " +
#1002,#1004,#1006,#1008,#1013,#1015,#1024,#1028,#1036,#1038,#1044,#1047,#1050
2025-01-27 17:14:13 +07:00
Extension . ToThaiNumber ( profile . posMasterNo . toLocaleString ( ) )
: "-" ,
2025-01-23 16:45:51 +07:00
amount : profile.amount ? Extension . ToThaiNumber ( profile . amount . toLocaleString ( ) ) : "-" ,
2025-01-24 14:28:05 +07:00
reason : profile.remark ,
#1002,#1004,#1006,#1008,#1013,#1015,#1024,#1028,#1036,#1038,#1044,#1047,#1050
2025-01-27 17:14:13 +07:00
score : profile.result ? Extension . ToThaiNumber ( profile . result ) : "-" ,
2025-01-24 14:28:05 +07:00
signature : null ,
2024-03-22 18:02:51 +07:00
} ;
} ) ;
return new HttpSuccess ( {
2024-03-29 11:27:56 +07:00
template : "emp2-07" ,
2024-04-05 14:22:26 +07:00
reportName : "emp2-07" ,
2024-03-22 18:02:51 +07:00
data : {
year : Extension.ToThaiNumber ( String ( Extension . ToThaiYear ( salaryPeriod . year ) ) ) ,
2024-04-10 14:54:52 +07:00
agency : _root?.root == null ? "" : _root ? . root ,
2024-03-22 18:02:51 +07:00
data : formattedData ,
} ,
} ) ;
}
/ * *
* API 08 - บ ั ญ ช ี แ ส ด ง ว ั น ล า ใ น ค ร ึ ่ ง ป ี ท ี ่ แ ล ้ ว ม า ข อ ง ล ู ก จ ้ า ง ป ร ะ จ ำ ก ร ุ ง เ ท พ ม ห า น ค ร ( แ บ บ ล จ . ก ท ม . 3 )
*
* @summary 08 - บ ั ญ ช ี แ ส ด ง ว ั น ล า ใ น ค ร ึ ่ ง ป ี ท ี ่ แ ล ้ ว ม า ข อ ง ล ู ก จ ้ า ง ป ร ะ จ ำ ก ร ุ ง เ ท พ ม ห า น ค ร ( แ บ บ ล จ . ก ท ม . 3 )
*
* /
@Get ( "emp2-08/{rootId}/{salaryPeriodId}" )
async SalaryReportEmp2_8 ( @Path ( ) rootId : string , @Path ( ) salaryPeriodId : string ) {
const salaryPeriod = await this . salaryPeriodRepository . findOne ( {
where : {
id : salaryPeriodId ,
} ,
} ) ;
if ( ! salaryPeriod ) {
throw new HttpError ( HttpStatusCode . NOT_FOUND , "ไม่พบข้อมูลการขึ้นเงินเดือน" ) ;
}
const _salaryPeriod = await this . salaryProfileRepository . find ( {
relations : [ "salaryOrg" , "salaryOrg.salaryPeriod" ] ,
where : {
salaryOrg : {
snapshot : "SNAP1" ,
rootId : rootId ,
salaryPeriodId : salaryPeriodId ,
} ,
} ,
order : {
2025-05-19 11:39:09 +07:00
rootOrder : "ASC" ,
child1Order : "ASC" ,
child2Order : "ASC" ,
child3Order : "ASC" ,
child4Order : "ASC" ,
2024-03-22 18:02:51 +07:00
orgShortName : "ASC" ,
posMasterNo : "ASC" ,
} ,
} ) ;
if ( ! _salaryPeriod ) {
throw new HttpError ( HttpStatusCode . NOT_FOUND , "ไม่พบข้อมูล" ) ;
}
2024-04-10 14:54:52 +07:00
const _root = await this . salaryOrgEmployeeRepository . findOne ( {
where : {
rootId : rootId ,
salaryPeriodId : salaryPeriodId ,
} ,
} ) ;
// const agency = _salaryPeriod[0] == null ? "" : _salaryPeriod[0].root;
2024-03-22 18:02:51 +07:00
const formattedData = _salaryPeriod . map ( ( profile , index ) = > {
const fullNameParts = [
profile . child4 ,
profile . child3 ,
profile . child2 ,
profile . child1 ,
profile . root ,
] ;
2024-07-12 10:22:36 +07:00
const affiliation = fullNameParts
2024-03-22 18:02:51 +07:00
. filter ( ( part ) = > part !== undefined && part !== null )
2025-04-04 13:45:33 +07:00
. join ( "\n" ) ;
2024-07-12 10:22:36 +07:00
const fullName = ` ${ profile . prefix } ${ profile . firstName } ${ profile . lastName } ` ;
2024-03-22 18:02:51 +07:00
return {
no : Extension.ToThaiNumber ( ( index + 1 ) . toLocaleString ( ) ) ,
fullName : fullName ,
2024-07-12 10:22:36 +07:00
affiliation : affiliation ,
2024-03-22 18:02:51 +07:00
posLevel : profile.posLevel ,
posNumber :
2024-04-09 09:25:55 +07:00
Extension . ToThaiNumber ( profile . orgShortName ) +
2025-04-05 18:12:02 +07:00
" " +
2024-04-09 09:25:55 +07:00
Extension . ToThaiNumber ( profile . posMasterNo . toLocaleString ( ) ) ,
2024-03-22 18:02:51 +07:00
amount : profile.amount ? Extension . ToThaiNumber ( profile . amount . toLocaleString ( ) ) : null ,
reason : null ,
} ;
} ) ;
return new HttpSuccess ( {
template : salaryPeriod.period == "APR" ? "gov1-01" : "gov2-01" ,
reportName : salaryPeriod.period == "APR" ? "gov1-01" : "gov2-01" ,
data : {
year : Extension.ToThaiNumber ( String ( Extension . ToThaiYear ( salaryPeriod . year ) ) ) ,
2024-04-10 14:54:52 +07:00
agency : _root?.root == null ? "" : _root ? . root ,
2024-03-22 18:02:51 +07:00
data : formattedData ,
} ,
} ) ;
}
/ * *
* API 09 - ร า ย ช ื ่ อ ล ู ก จ ้ า ง ป ร ะ จ ำ ก ร ุ ง เ ท พ ม ห า น ค ร ท ี ่ ค ร บ เ ก ษ ี ย ณ อ า ย ุ ร า ช ก า ร
*
* @summary 09 - ร า ย ช ื ่ อ ล ู ก จ ้ า ง ป ร ะ จ ำ ก ร ุ ง เ ท พ ม ห า น ค ร ท ี ่ ค ร บ เ ก ษ ี ย ณ อ า ย ุ ร า ช ก า ร
*
* /
@Get ( "emp2-09/{rootId}/{salaryPeriodId}" )
async SalaryReportEmp2_9 ( @Path ( ) rootId : string , @Path ( ) salaryPeriodId : string ) {
const salaryPeriod = await this . salaryPeriodRepository . findOne ( {
where : {
id : salaryPeriodId ,
} ,
} ) ;
if ( ! salaryPeriod ) {
throw new HttpError ( HttpStatusCode . NOT_FOUND , "ไม่พบข้อมูลการขึ้นเงินเดือน" ) ;
}
2024-04-05 14:22:26 +07:00
2024-03-29 11:27:56 +07:00
const _salaryPeriodTarget = await this . salaryProfileEmployeeRepository . find ( {
2024-04-05 14:22:26 +07:00
relations : [ "salaryOrg" , "salaryOrg.salaryPeriod" ] ,
where : {
isRetired : true ,
salaryOrg : {
snapshot : "SNAP2" ,
rootId : rootId ,
salaryPeriodId : salaryPeriodId ,
2024-03-29 11:27:56 +07:00
} ,
2024-04-05 14:22:26 +07:00
} ,
order : {
2025-05-19 11:39:09 +07:00
rootOrder : "ASC" ,
child1Order : "ASC" ,
child2Order : "ASC" ,
child3Order : "ASC" ,
child4Order : "ASC" ,
2024-04-05 14:22:26 +07:00
orgShortName : "ASC" ,
posMasterNo : "ASC" ,
} ,
} ) ;
2024-03-29 11:27:56 +07:00
if ( ! _salaryPeriodTarget ) {
throw new HttpError ( HttpStatusCode . NOT_FOUND , "ไม่พบข้อมูล" ) ;
}
const octPreviousYear = await this . salaryPeriodRepository . findOne ( {
where : {
period : "OCT" ,
year : salaryPeriod?.year - 1 ,
2024-03-22 18:02:51 +07:00
} ,
2024-03-29 11:27:56 +07:00
} ) ;
const octPreviousYear2 = await this . salaryPeriodRepository . findOne ( {
where : {
period : "OCT" ,
year : salaryPeriod?.year - 2 ,
2024-03-22 18:02:51 +07:00
} ,
} ) ;
2024-03-29 11:27:56 +07:00
let octPreviousYearProfile : SalaryProfileEmployee [ ] = [ ] ;
if ( octPreviousYear ) {
octPreviousYearProfile = await this . salaryProfileEmployeeRepository . find ( {
relations : [ "salaryOrg" ] ,
where : {
isRetired : true ,
salaryOrg : {
snapshot : "SNAP2" ,
rootId : rootId ,
salaryPeriodId : octPreviousYear?.id ,
} ,
} ,
} ) ;
2024-03-22 18:02:51 +07:00
}
2024-03-29 11:27:56 +07:00
let octPreviousYearProfile2 : SalaryProfileEmployee [ ] = [ ] ;
if ( octPreviousYear2 ) {
octPreviousYearProfile2 = await this . salaryProfileEmployeeRepository . find ( {
relations : [ "salaryOrg" ] ,
where : {
isRetired : true ,
salaryOrg : {
snapshot : "SNAP2" ,
salaryPeriodId : octPreviousYear2?.id ,
rootId : rootId ,
} ,
} ,
} ) ;
}
2024-04-10 14:54:52 +07:00
const _root = await this . salaryOrgEmployeeRepository . findOne ( {
where : {
rootId : rootId ,
salaryPeriodId : salaryPeriodId ,
} ,
} ) ;
// const agency = _salaryPeriodTarget[0] == null ? "" : _salaryPeriodTarget[0].root;
2024-03-29 11:27:56 +07:00
const formattedData = _salaryPeriodTarget . map ( ( profile , index ) = > {
2024-03-22 18:02:51 +07:00
const fullNameParts = [
profile . child4 ,
profile . child3 ,
profile . child2 ,
profile . child1 ,
profile . root ,
] ;
2024-07-12 10:22:36 +07:00
const affiliation = fullNameParts
2024-03-22 18:02:51 +07:00
. filter ( ( part ) = > part !== undefined && part !== null )
2025-04-04 13:45:33 +07:00
. join ( "\n" ) ;
2024-07-12 10:22:36 +07:00
const fullName = ` ${ profile . prefix } ${ profile . firstName } ${ profile . lastName } ` ;
2024-03-22 18:02:51 +07:00
return {
no : Extension.ToThaiNumber ( ( index + 1 ) . toLocaleString ( ) ) ,
fullName : fullName ,
2024-07-12 10:22:36 +07:00
affiliation : affiliation ,
2024-03-29 11:27:56 +07:00
position : profile.position ,
2025-05-13 09:49:13 +07:00
posLevel : profile.posLevel ? Extension . ToThaiNumber ( profile . posLevel . toString ( ) ) : null ,
2024-03-22 18:02:51 +07:00
posNumber :
2024-04-09 09:25:55 +07:00
Extension . ToThaiNumber ( profile . orgShortName ) +
2025-04-05 18:12:02 +07:00
" " +
2024-04-09 09:25:55 +07:00
Extension . ToThaiNumber ( profile . posMasterNo . toLocaleString ( ) ) ,
2024-03-22 18:02:51 +07:00
amount : profile.amount ? Extension . ToThaiNumber ( profile . amount . toLocaleString ( ) ) : null ,
2024-03-29 11:27:56 +07:00
typeOld2 :
2024-04-05 14:22:26 +07:00
octPreviousYear2 && octPreviousYearProfile2 . length > 0
? ( ( ) = > {
const _profile = octPreviousYearProfile2 . filter (
( profileOCT2 ) = > profileOCT2 . citizenId === profile . citizenId ,
) ;
if ( _profile . length > 0 ) {
return _profile [ 0 ] ? . type === "HAFT"
2024-03-29 11:27:56 +07:00
? "๐ .๕ ขั้น"
: _profile [ 0 ] ? . type === "FULL"
2024-04-05 14:22:26 +07:00
? "๑ ขั้น"
: profile ? . type === "FULLHAFT"
? "๑.๕ ขั้น"
: "ไม่ได้เลื่อนขั้นฯ" ;
}
return null ;
} ) ( )
: null ,
yearOld :
octPreviousYear == null ? null : Extension . ToThaiNumber ( octPreviousYear . year . toString ( ) ) ,
typeOld1 :
octPreviousYear && octPreviousYearProfile . length > 0
? ( ( ) = > {
const _profile = octPreviousYearProfile . filter (
( profileOCT ) = > profileOCT . citizenId === profile . citizenId ,
) ;
if ( _profile . length > 0 ) {
return _profile [ 0 ] ? . type === "HAFT"
2024-03-29 11:27:56 +07:00
? "๐ .๕ ขั้น"
: _profile [ 0 ] ? . type === "FULL"
2024-04-05 14:22:26 +07:00
? "๑ ขั้น"
: profile ? . type === "FULLHAFT"
? "๑.๕ ขั้น"
: "ไม่ได้เลื่อนขั้นฯ" ;
}
return null ;
} ) ( )
: null ,
typeOld :
_salaryPeriodTarget . length > 0
? ( ( ) = > {
const _profile = _salaryPeriodTarget
. filter ( ( profileAPR ) = > profileAPR . citizenId === profile . citizenId )
. map ( ( profile ) = > ( {
type : profile . type ,
} ) ) ;
return _profile [ 0 ] ? . type === "HAFT"
? "๐ .๕ ขั้น"
: _profile [ 0 ] ? . type === "FULL"
2024-03-29 11:27:56 +07:00
? "๑ ขั้น"
: profile ? . type === "FULLHAFT"
2024-04-05 14:22:26 +07:00
? "๑.๕ ขั้น"
: "ไม่ได้เลื่อนขั้นฯ" ;
} ) ( )
: null , //เมษา ปีเดียวกัน
type :
profile . type === "HAFT"
? "๐ .๕ ขั้น"
: profile . type === "FULL"
2024-03-29 11:27:56 +07:00
? "๑ ขั้น"
2024-04-05 14:22:26 +07:00
: profile . type === "FULLHAFT"
? "๑.๕ ขั้น"
: "ไม่ได้เลื่อนขั้นฯ" ,
2024-07-08 09:21:24 +07:00
score1 : profile.result ,
2024-04-05 14:22:26 +07:00
score2 : null ,
2024-07-08 09:21:24 +07:00
reason : profile.remark ,
2024-03-22 18:02:51 +07:00
} ;
} ) ;
return new HttpSuccess ( {
2024-03-29 11:27:56 +07:00
template : "emp2-09" ,
2024-04-05 14:22:26 +07:00
reportName : "emp2-09" ,
2024-03-22 18:02:51 +07:00
data : {
year : Extension.ToThaiNumber ( String ( Extension . ToThaiYear ( salaryPeriod . year ) ) ) ,
2024-04-05 14:22:26 +07:00
yearShort : Extension.ToThaiNumber ( String ( Extension . ToThaiYear ( salaryPeriod . year ) ) ) . slice (
- 2 ,
) ,
yearShortOld : Extension.ToThaiNumber (
String ( Extension . ToThaiYear ( salaryPeriod . year - 1 ) ) ,
) . slice ( - 2 ) ,
2024-04-10 14:54:52 +07:00
agency : _root?.root == null ? "" : _root ? . root ,
2024-03-22 18:02:51 +07:00
data : formattedData ,
} ,
} ) ;
}
/ * *
* API 10 - บ ั ญ ช ี ร า ย ช ื ่ อ ล ู ก จ ้ า ง ป ร ะ จ ำ ก ร ุ ง เ ท พ ม ห า น ค ร ผ ู ้ ไ ม ่ ไ ด ้ ร ั บ ก า ร เ ล ื ่ อ น ข ั ้ น ค ่ า จ ้ า ง / ค ่ า ต อ บ แ ท น พ ิ เ ศ ษ
*
* @summary 10 - บ ั ญ ช ี ร า ย ช ื ่ อ ล ู ก จ ้ า ง ป ร ะ จ ำ ก ร ุ ง เ ท พ ม ห า น ค ร ผ ู ้ ไ ม ่ ไ ด ้ ร ั บ ก า ร เ ล ื ่ อ น ข ั ้ น ค ่ า จ ้ า ง / ค ่ า ต อ บ แ ท น พ ิ เ ศ ษ
*
* /
@Get ( "emp2-10/{rootId}/{salaryPeriodId}" )
async SalaryReportEmp2_10 ( @Path ( ) rootId : string , @Path ( ) salaryPeriodId : string ) {
const salaryPeriod = await this . salaryPeriodRepository . findOne ( {
where : {
id : salaryPeriodId ,
emp2-(04, 06, 08, 10, 12, 14, 16, 18, 19, 20, 22, 24)
2024-03-28 17:21:32 +07:00
period : "OCT" ,
2024-04-05 14:22:26 +07:00
isActive : true ,
2024-03-22 18:02:51 +07:00
} ,
} ) ;
if ( ! salaryPeriod ) {
throw new HttpError ( HttpStatusCode . NOT_FOUND , "ไม่พบข้อมูลการขึ้นเงินเดือน" ) ;
}
emp2-(04, 06, 08, 10, 12, 14, 16, 18, 19, 20, 22, 24)
2024-03-28 17:21:32 +07:00
const _salaryProfileEmp = await this . salaryProfileEmployeeRepository . find ( {
2024-03-22 18:02:51 +07:00
relations : [ "salaryOrg" , "salaryOrg.salaryPeriod" ] ,
where : {
salaryOrg : {
emp2-(04, 06, 08, 10, 12, 14, 16, 18, 19, 20, 22, 24)
2024-03-28 17:21:32 +07:00
snapshot : "SNAP2" ,
2024-03-22 18:02:51 +07:00
rootId : rootId ,
salaryPeriodId : salaryPeriodId ,
} ,
2024-04-05 14:22:26 +07:00
type : "NONE" ,
2024-03-22 18:02:51 +07:00
} ,
order : {
2025-05-19 11:39:09 +07:00
rootOrder : "ASC" ,
child1Order : "ASC" ,
child2Order : "ASC" ,
child3Order : "ASC" ,
child4Order : "ASC" ,
2024-03-22 18:02:51 +07:00
orgShortName : "ASC" ,
posMasterNo : "ASC" ,
} ,
} ) ;
emp2-(04, 06, 08, 10, 12, 14, 16, 18, 19, 20, 22, 24)
2024-03-28 17:21:32 +07:00
if ( ! _salaryProfileEmp ) {
2024-03-22 18:02:51 +07:00
throw new HttpError ( HttpStatusCode . NOT_FOUND , "ไม่พบข้อมูล" ) ;
}
2024-04-10 14:54:52 +07:00
const _root = await this . salaryOrgEmployeeRepository . findOne ( {
where : {
rootId : rootId ,
salaryPeriodId : salaryPeriodId ,
} ,
} ) ;
// const agency = _salaryProfileEmp[0] == null ? "" : _salaryProfileEmp[0].root;
2024-03-22 18:02:51 +07:00
emp2-(04, 06, 08, 10, 12, 14, 16, 18, 19, 20, 22, 24)
2024-03-28 17:21:32 +07:00
const formattedData = _salaryProfileEmp . map ( ( profile , index ) = > {
2024-03-22 18:02:51 +07:00
const fullNameParts = [
profile . child4 ,
profile . child3 ,
profile . child2 ,
profile . child1 ,
profile . root ,
] ;
2024-07-12 10:22:36 +07:00
const affiliation = fullNameParts
2024-03-22 18:02:51 +07:00
. filter ( ( part ) = > part !== undefined && part !== null )
2025-04-04 13:45:33 +07:00
. join ( "\n" ) ;
2024-07-12 10:22:36 +07:00
const fullName = ` ${ profile . prefix } ${ profile . firstName } ${ profile . lastName } ` ;
2024-03-22 18:02:51 +07:00
return {
no : Extension.ToThaiNumber ( ( index + 1 ) . toLocaleString ( ) ) ,
fullName : fullName ,
2024-07-12 10:22:36 +07:00
affiliation : affiliation ,
2025-02-03 15:47:29 +07:00
position : profile.position ? ? "-" ,
2025-01-29 15:21:47 +07:00
//pos\n
2025-02-03 15:47:29 +07:00
// profile.position +
// "\n" +
// (profile.child4 == undefined && profile.child4 == null ? "" : profile.child4 + " ") +
// (profile.child3 == undefined && profile.child3 == null ? "" : profile.child3 + " ") +
// (profile.child2 == undefined && profile.child2 == null ? "" : profile.child2 + " ") +
// (profile.child1 == undefined && profile.child1 == null ? "" : profile.child1 + " ") +
// (profile.root == undefined && profile.root == null ? "" : profile.root),
posLevel : profile.posLevel
? ` ${ profile . posTypeShort } ${ Extension . ToThaiNumber ( profile . posLevel . toLocaleString ( ) ) } `
: "-" ,
2024-03-22 18:02:51 +07:00
posNumber :
2024-04-09 09:25:55 +07:00
Extension . ToThaiNumber ( profile . orgShortName ) +
2025-04-05 18:12:02 +07:00
" " +
2024-04-09 09:25:55 +07:00
Extension . ToThaiNumber ( profile . posMasterNo . toLocaleString ( ) ) ,
2025-02-03 15:47:29 +07:00
amount : profile.amount ? Extension . ToThaiNumber ( profile . amount . toLocaleString ( ) ) : "-" ,
emp2-(04, 06, 08, 10, 12, 14, 16, 18, 19, 20, 22, 24)
2024-03-28 17:21:32 +07:00
positionSalaryAmount : profile.positionSalaryAmount
? Extension . ToThaiNumber ( profile . positionSalaryAmount . toLocaleString ( ) )
2025-02-03 15:47:29 +07:00
: "-" ,
2025-02-05 14:19:14 +07:00
reason1 : "-" , //เหตุผลที่ไม่ได้เลื่อนขั้น
reason2 : "-" , //เหตุผลที่ไม่ได้เลื่อนขั้น
reason3 : "-" , //เหตุผลที่ไม่ได้เลื่อนขั้น
#1002,#1004,#1006,#1008,#1013,#1015,#1024,#1028,#1036,#1038,#1044,#1047,#1050
2025-01-27 17:14:13 +07:00
score : profile.result ? Extension . ToThaiNumber ( profile . result ) : "-" ,
2024-07-08 09:21:24 +07:00
reason : profile.remark ,
2024-03-22 18:02:51 +07:00
} ;
} ) ;
emp2-(04, 06, 08, 10, 12, 14, 16, 18, 19, 20, 22, 24)
2024-03-28 17:21:32 +07:00
const year = Extension . ToThaiNumber ( String ( Extension . ToThaiYear ( salaryPeriod . year ) ) ) ;
2024-04-05 14:22:26 +07:00
const yearOld = Extension . ToThaiNumber ( String ( Extension . ToThaiYear ( salaryPeriod . year - 1 ) ) ) ;
2024-03-22 18:02:51 +07:00
return new HttpSuccess ( {
emp2-(04, 06, 08, 10, 12, 14, 16, 18, 19, 20, 22, 24)
2024-03-28 17:21:32 +07:00
template : "emp2-10" ,
reportName : "emp2-10" ,
2024-03-22 18:02:51 +07:00
data : {
emp2-(04, 06, 08, 10, 12, 14, 16, 18, 19, 20, 22, 24)
2024-03-28 17:21:32 +07:00
year : year ,
yearSlice : year.slice ( - 2 ) ,
yearOldSlice : yearOld.slice ( - 2 ) ,
2024-04-10 14:54:52 +07:00
agency : _root?.root == null ? "" : _root ? . root ,
2024-03-22 18:02:51 +07:00
data : formattedData ,
} ,
} ) ;
}
2024-03-29 11:27:56 +07:00
2024-03-22 18:02:51 +07:00
/ * *
* API 11 - ร า ย ช ื ่ อ ล ู ก จ ้ า ง ป ร ะ จ ำ ผ ู ้ ม ี ผ ล ก า ร ป ร ะ เ ม ิ น ป ร ะ ส ิ ท ธ ิ ภ า พ แ ล ะ ป ร ะ ส ิ ท ธ ิ ผ ล ก า ร ป ฏ ิ บ ั ต ิ ง า น อ ย ู ่ ใ น ร ะ ด ั บ ด ี เ ด ่ น
*
* @summary 11 - ร า ย ช ื ่ อ ล ู ก จ ้ า ง ป ร ะ จ ำ ผ ู ้ ม ี ผ ล ก า ร ป ร ะ เ ม ิ น ป ร ะ ส ิ ท ธ ิ ภ า พ แ ล ะ ป ร ะ ส ิ ท ธ ิ ผ ล ก า ร ป ฏ ิ บ ั ต ิ ง า น อ ย ู ่ ใ น ร ะ ด ั บ ด ี เ ด ่ น
*
* /
@Get ( "emp2-11/{rootId}/{salaryPeriodId}" )
async SalaryReportEmp2_11 ( @Path ( ) rootId : string , @Path ( ) salaryPeriodId : string ) {
const salaryPeriod = await this . salaryPeriodRepository . findOne ( {
where : {
id : salaryPeriodId ,
} ,
} ) ;
if ( ! salaryPeriod ) {
throw new HttpError ( HttpStatusCode . NOT_FOUND , "ไม่พบข้อมูลการขึ้นเงินเดือน" ) ;
}
2024-03-29 17:35:28 +07:00
const _salaryPeriod = await this . salaryProfileEmployeeRepository . find ( {
2024-04-05 14:22:26 +07:00
relations : [ "salaryOrg" , "salaryOrg.salaryPeriod" ] ,
where : {
2025-05-01 17:39:55 +07:00
isGood : true ,
2024-04-05 14:22:26 +07:00
salaryOrg : {
snapshot : "SNAP2" ,
rootId : rootId ,
salaryPeriodId : salaryPeriodId ,
2024-03-29 17:35:28 +07:00
} ,
2024-04-05 14:22:26 +07:00
} ,
order : {
2025-05-19 11:39:09 +07:00
rootOrder : "ASC" ,
child1Order : "ASC" ,
child2Order : "ASC" ,
child3Order : "ASC" ,
child4Order : "ASC" ,
2024-04-05 14:22:26 +07:00
orgShortName : "ASC" ,
posMasterNo : "ASC" ,
} ,
} ) ;
2024-03-22 18:02:51 +07:00
if ( ! _salaryPeriod ) {
throw new HttpError ( HttpStatusCode . NOT_FOUND , "ไม่พบข้อมูล" ) ;
}
const agency = _salaryPeriod [ 0 ] == null ? "" : _salaryPeriod [ 0 ] . root ;
const formattedData = _salaryPeriod . map ( ( profile , index ) = > {
2024-08-23 14:10:34 +07:00
const fullNameParts = [
2024-03-22 18:02:51 +07:00
profile . child4 ,
profile . child3 ,
profile . child2 ,
profile . child1 ,
profile . root ,
] ;
2024-07-12 10:22:36 +07:00
const affiliation = fullNameParts
2024-03-22 18:02:51 +07:00
. filter ( ( part ) = > part !== undefined && part !== null )
2025-04-04 13:45:33 +07:00
. join ( "\n" ) ;
2024-07-12 10:22:36 +07:00
const fullName = ` ${ profile . prefix } ${ profile . firstName } ${ profile . lastName } ` ;
2024-03-22 18:02:51 +07:00
return {
no : Extension.ToThaiNumber ( ( index + 1 ) . toLocaleString ( ) ) ,
fullName : fullName ,
2024-07-12 10:22:36 +07:00
affiliation : affiliation ,
2024-03-29 17:35:28 +07:00
position : profile.position ,
2024-04-25 00:53:57 +07:00
posLevel : profile.posLevel
2025-02-03 15:47:29 +07:00
? ` ${ profile . posTypeShort } ${ Extension . ToThaiNumber ( profile . posLevel . toLocaleString ( ) ) } `
: "-" ,
2024-03-22 18:02:51 +07:00
} ;
} ) ;
return new HttpSuccess ( {
2024-03-29 17:35:28 +07:00
template : "emp2-11" ,
reportName : "emp2-11" ,
2024-03-22 18:02:51 +07:00
data : {
year : Extension.ToThaiNumber ( String ( Extension . ToThaiYear ( salaryPeriod . year ) ) ) ,
agency : agency ,
data : formattedData ,
} ,
} ) ;
}
2024-03-29 11:27:56 +07:00
2024-03-22 18:02:51 +07:00
/ * *
* API 12 - ค ำ ส ั ่ ง เ ล ื ่ อ น ข ั ้ น ค ่ า จ ้ า ง แ ล ะ ใ ห ้ ล ู ก จ ้ า ง ป ร ะ จ ำ ก ร ุ ง เ ท พ ม ห า น ค ร ไ ด ้ ร ั บ อ ั ต ร า ค ่ า จ ้ า ง ส ู ง ก ว ่ า อ ั ต ร า ค ่ า จ ้ า ง ข ั ้ น ส ู ง ข อ ง ต ำ แ ห น ่ ง ท ี ่ ไ ด ้ ร ั บ แ ต ่ ง ต ั ้ ง ใ น แ ต ่ ล ะ ร ะ ด ั บ ท ี ่ เ ก ษ ี ย ณ อ า ย ุ ร า ช ก า ร
*
* @summary 12 - ค ำ ส ั ่ ง เ ล ื ่ อ น ข ั ้ น ค ่ า จ ้ า ง แ ล ะ ใ ห ้ ล ู ก จ ้ า ง ป ร ะ จ ำ ก ร ุ ง เ ท พ ม ห า น ค ร ไ ด ้ ร ั บ อ ั ต ร า ค ่ า จ ้ า ง ส ู ง ก ว ่ า อ ั ต ร า ค ่ า จ ้ า ง ข ั ้ น ส ู ง ข อ ง ต ำ แ ห น ่ ง ท ี ่ ไ ด ้ ร ั บ แ ต ่ ง ต ั ้ ง ใ น แ ต ่ ล ะ ร ะ ด ั บ ท ี ่ เ ก ษ ี ย ณ อ า ย ุ ร า ช ก า ร
*
* /
@Get ( "emp2-12/{rootId}/{salaryPeriodId}" )
async SalaryReportEmp2_12 ( @Path ( ) rootId : string , @Path ( ) salaryPeriodId : string ) {
const salaryPeriod = await this . salaryPeriodRepository . findOne ( {
where : {
id : salaryPeriodId ,
emp2-(04, 06, 08, 10, 12, 14, 16, 18, 19, 20, 22, 24)
2024-03-28 17:21:32 +07:00
period : "OCT" ,
2024-04-05 14:22:26 +07:00
isActive : true ,
2024-03-22 18:02:51 +07:00
} ,
} ) ;
if ( ! salaryPeriod ) {
throw new HttpError ( HttpStatusCode . NOT_FOUND , "ไม่พบข้อมูลการขึ้นเงินเดือน" ) ;
}
emp2-(04, 06, 08, 10, 12, 14, 16, 18, 19, 20, 22, 24)
2024-03-28 17:21:32 +07:00
const salaryOrg = await this . salaryOrgEmployeeRepository . findOne ( {
2024-03-22 18:02:51 +07:00
where : {
emp2-(04, 06, 08, 10, 12, 14, 16, 18, 19, 20, 22, 24)
2024-03-28 17:21:32 +07:00
snapshot : "SNAP2" ,
rootId : rootId ,
salaryPeriodId : salaryPeriodId ,
2024-04-05 14:22:26 +07:00
} ,
2024-03-22 18:02:51 +07:00
} ) ;
emp2-(04, 06, 08, 10, 12, 14, 16, 18, 19, 20, 22, 24)
2024-03-28 17:21:32 +07:00
if ( ! salaryOrg ) {
2024-03-22 18:02:51 +07:00
throw new HttpError ( HttpStatusCode . NOT_FOUND , "ไม่พบข้อมูล" ) ;
}
return new HttpSuccess ( {
2024-04-05 14:22:26 +07:00
template : "emp2-12" ,
emp2-(04, 06, 08, 10, 12, 14, 16, 18, 19, 20, 22, 24)
2024-03-28 17:21:32 +07:00
reportName : "emp2-12" ,
2024-03-22 18:02:51 +07:00
} ) ;
}
2024-04-05 14:22:26 +07:00
2024-03-22 18:02:51 +07:00
/ * *
* API 13 - บ ั ญ ช ี ร า ย ล ะ เ อ ี ย ด แ ส ด ง ก า ร เ ล ื ่ อ น ข ั ้ น ค ่ า จ ้ า ง แ ล ะ ใ ห ้ ล ู ก จ ้ า ง ป ร ะ จ ำ ก ร ุ ง เ ท พ ม ห า น ค ร ไ ด ้ ร ั บ อ ั ต ร า ค ่ า จ ้ า ง ส ู ง ก ว ่ า อ ั ต ร า ค ่ า จ ้ า ง ข ั ้ น ส ู ง ข อ ง ต ำ แ ห น ่ ง ท ี ่ ไ ด ้ ร ั บ แ ต ่ ง ต ั ้ ง ใ น แ ต ่ ล ะ ร ะ ด ั บ ท ี ่ เ ก ษ ี ย ณ อ า ย ุ ร า ช ก า ร
*
* @summary 13 - บ ั ญ ช ี ร า ย ล ะ เ อ ี ย ด แ ส ด ง ก า ร เ ล ื ่ อ น ข ั ้ น ค ่ า จ ้ า ง แ ล ะ ใ ห ้ ล ู ก จ ้ า ง ป ร ะ จ ำ ก ร ุ ง เ ท พ ม ห า น ค ร ไ ด ้ ร ั บ อ ั ต ร า ค ่ า จ ้ า ง ส ู ง ก ว ่ า อ ั ต ร า ค ่ า จ ้ า ง ข ั ้ น ส ู ง ข อ ง ต ำ แ ห น ่ ง ท ี ่ ไ ด ้ ร ั บ แ ต ่ ง ต ั ้ ง ใ น แ ต ่ ล ะ ร ะ ด ั บ ท ี ่ เ ก ษ ี ย ณ อ า ย ุ ร า ช ก า ร
*
* /
@Get ( "emp2-13/{rootId}/{salaryPeriodId}" )
async SalaryReportEmp2_13 ( @Path ( ) rootId : string , @Path ( ) salaryPeriodId : string ) {
const salaryPeriod = await this . salaryPeriodRepository . findOne ( {
where : {
id : salaryPeriodId ,
} ,
} ) ;
if ( ! salaryPeriod ) {
throw new HttpError ( HttpStatusCode . NOT_FOUND , "ไม่พบข้อมูลการขึ้นเงินเดือน" ) ;
}
2024-03-29 17:35:28 +07:00
const salaryProfile = await this . salaryProfileEmployeeRepository . find ( {
2024-04-05 14:22:26 +07:00
relations : [ "salaryOrg" , "salaryOrg.salaryPeriod" ] ,
where : {
isRetired : true ,
isNext : true ,
salaryOrg : {
snapshot : "SNAP2" ,
rootId : rootId ,
salaryPeriodId : salaryPeriodId ,
2024-03-29 17:35:28 +07:00
} ,
2024-04-05 14:22:26 +07:00
} ,
order : {
2025-05-19 11:39:09 +07:00
rootOrder : "ASC" ,
child1Order : "ASC" ,
child2Order : "ASC" ,
child3Order : "ASC" ,
child4Order : "ASC" ,
2024-04-05 14:22:26 +07:00
orgShortName : "ASC" ,
posMasterNo : "ASC" ,
} ,
} ) ;
2024-03-29 17:35:28 +07:00
if ( ! salaryProfile ) {
2024-03-22 18:02:51 +07:00
throw new HttpError ( HttpStatusCode . NOT_FOUND , "ไม่พบข้อมูล" ) ;
}
2024-03-29 17:35:28 +07:00
const agency = salaryProfile [ 0 ] == null ? "" : salaryProfile [ 0 ] . root ;
2024-03-22 18:02:51 +07:00
2024-03-29 17:35:28 +07:00
const formattedData = salaryProfile . map ( ( profile , index ) = > {
2024-08-23 14:10:34 +07:00
const fullNameParts = [
2024-03-22 18:02:51 +07:00
profile . child4 ,
profile . child3 ,
profile . child2 ,
profile . child1 ,
profile . root ,
] ;
2024-07-12 10:22:36 +07:00
const affiliation = fullNameParts
2024-03-22 18:02:51 +07:00
. filter ( ( part ) = > part !== undefined && part !== null )
2025-04-04 13:45:33 +07:00
. join ( "\n" ) ;
2024-07-12 10:22:36 +07:00
const fullName = ` ${ profile . prefix } ${ profile . firstName } ${ profile . lastName } ` ;
2024-03-22 18:02:51 +07:00
return {
no : Extension.ToThaiNumber ( ( index + 1 ) . toLocaleString ( ) ) ,
fullName : fullName ,
2024-07-12 10:22:36 +07:00
affiliation : affiliation ,
2024-03-29 17:35:28 +07:00
position : profile.position ,
2024-03-22 18:02:51 +07:00
posLevel : profile.posLevel ,
posNumber :
2024-04-09 09:25:55 +07:00
Extension . ToThaiNumber ( profile . orgShortName ) +
2025-04-05 18:12:02 +07:00
" " +
2024-04-09 09:25:55 +07:00
Extension . ToThaiNumber ( profile . posMasterNo . toLocaleString ( ) ) ,
2024-03-22 18:02:51 +07:00
amount : profile.amount ? Extension . ToThaiNumber ( profile . amount . toLocaleString ( ) ) : null ,
2024-04-05 14:22:26 +07:00
positionSalaryAmount : profile.positionSalaryAmount
? Extension . ToThaiNumber ( profile . positionSalaryAmount . toLocaleString ( ) )
: null ,
2024-03-22 18:02:51 +07:00
reason : null ,
} ;
} ) ;
2024-04-05 14:22:26 +07:00
2024-03-22 18:02:51 +07:00
return new HttpSuccess ( {
2024-03-29 17:35:28 +07:00
template : "emp2-13" ,
reportName : "emp2-13" ,
2024-03-22 18:02:51 +07:00
data : {
year : Extension.ToThaiNumber ( String ( Extension . ToThaiYear ( salaryPeriod . year ) ) ) ,
agency : agency ,
data : formattedData ,
} ,
} ) ;
}
2024-03-29 11:27:56 +07:00
2024-03-22 18:02:51 +07:00
/ * *
* API 14 - บ ั ญ ช ี ร า ย ช ื ่ อ ล ู ก จ ้ า ง ป ร ะ จ ำ ก ร ุ ง เ ท พ ม ห า น ค ร ผ ู ้ ไ ม ่ ไ ด ้ ร ั บ ก า ร เ ล ื ่ อ น ข ั ้ น ค ่ า จ ้ า ง ท ี ่ เ ก ษ ี ย ณ อ า ย ุ ร า ช ก า ร
*
* @summary 14 - บ ั ญ ช ี ร า ย ช ื ่ อ ล ู ก จ ้ า ง ป ร ะ จ ำ ก ร ุ ง เ ท พ ม ห า น ค ร ผ ู ้ ไ ม ่ ไ ด ้ ร ั บ ก า ร เ ล ื ่ อ น ข ั ้ น ค ่ า จ ้ า ง ท ี ่ เ ก ษ ี ย ณ อ า ย ุ ร า ช ก า ร
*
* /
@Get ( "emp2-14/{rootId}/{salaryPeriodId}" )
async SalaryReportEmp2_14 ( @Path ( ) rootId : string , @Path ( ) salaryPeriodId : string ) {
const salaryPeriod = await this . salaryPeriodRepository . findOne ( {
where : {
id : salaryPeriodId ,
emp2-(04, 06, 08, 10, 12, 14, 16, 18, 19, 20, 22, 24)
2024-03-28 17:21:32 +07:00
period : "OCT" ,
2024-04-05 14:22:26 +07:00
isActive : true ,
2024-03-22 18:02:51 +07:00
} ,
} ) ;
if ( ! salaryPeriod ) {
throw new HttpError ( HttpStatusCode . NOT_FOUND , "ไม่พบข้อมูลการขึ้นเงินเดือน" ) ;
}
emp2-(04, 06, 08, 10, 12, 14, 16, 18, 19, 20, 22, 24)
2024-03-28 17:21:32 +07:00
const _salaryProfileEmp = await this . salaryProfileEmployeeRepository . find ( {
2024-03-22 18:02:51 +07:00
relations : [ "salaryOrg" , "salaryOrg.salaryPeriod" ] ,
where : {
salaryOrg : {
emp2-(04, 06, 08, 10, 12, 14, 16, 18, 19, 20, 22, 24)
2024-03-28 17:21:32 +07:00
snapshot : "SNAP2" ,
2024-03-22 18:02:51 +07:00
rootId : rootId ,
salaryPeriodId : salaryPeriodId ,
} ,
emp2-(04, 06, 08, 10, 12, 14, 16, 18, 19, 20, 22, 24)
2024-03-28 17:21:32 +07:00
type : "NONE" ,
2024-04-05 14:22:26 +07:00
isRetired : true ,
2024-03-22 18:02:51 +07:00
} ,
order : {
2025-05-19 11:39:09 +07:00
rootOrder : "ASC" ,
child1Order : "ASC" ,
child2Order : "ASC" ,
child3Order : "ASC" ,
child4Order : "ASC" ,
2024-03-22 18:02:51 +07:00
orgShortName : "ASC" ,
posMasterNo : "ASC" ,
} ,
} ) ;
emp2-(04, 06, 08, 10, 12, 14, 16, 18, 19, 20, 22, 24)
2024-03-28 17:21:32 +07:00
if ( ! _salaryProfileEmp ) {
2024-03-22 18:02:51 +07:00
throw new HttpError ( HttpStatusCode . NOT_FOUND , "ไม่พบข้อมูล" ) ;
}
emp2-(04, 06, 08, 10, 12, 14, 16, 18, 19, 20, 22, 24)
2024-03-28 17:21:32 +07:00
const agency = _salaryProfileEmp [ 0 ] == null ? "" : _salaryProfileEmp [ 0 ] . root ;
2024-03-22 18:02:51 +07:00
emp2-(04, 06, 08, 10, 12, 14, 16, 18, 19, 20, 22, 24)
2024-03-28 17:21:32 +07:00
const formattedData = _salaryProfileEmp . map ( ( profile , index ) = > {
2024-08-23 14:10:34 +07:00
const fullNameParts = [
2024-03-22 18:02:51 +07:00
profile . child4 ,
profile . child3 ,
profile . child2 ,
profile . child1 ,
profile . root ,
] ;
2024-07-12 10:22:36 +07:00
const affiliation = fullNameParts
2024-03-22 18:02:51 +07:00
. filter ( ( part ) = > part !== undefined && part !== null )
2025-04-04 13:45:33 +07:00
. join ( "\n" ) ;
2024-07-12 10:22:36 +07:00
const fullName = ` ${ profile . prefix } ${ profile . firstName } ${ profile . lastName } ` ;
2024-03-22 18:02:51 +07:00
return {
no : Extension.ToThaiNumber ( ( index + 1 ) . toLocaleString ( ) ) ,
fullName : fullName ,
2024-07-12 10:22:36 +07:00
affiliation : affiliation ,
2025-02-03 15:47:29 +07:00
position : profile.position ? ? "-" ,
2025-01-29 15:21:47 +07:00
//pos\n
2025-02-03 15:47:29 +07:00
// profile.position +
// "\n" +
// (profile.child4 == undefined && profile.child4 == null ? "" : profile.child4 + " ") +
// (profile.child3 == undefined && profile.child3 == null ? "" : profile.child3 + " ") +
// (profile.child2 == undefined && profile.child2 == null ? "" : profile.child2 + " ") +
// (profile.child1 == undefined && profile.child1 == null ? "" : profile.child1 + " ") +
// (profile.root == undefined && profile.root == null ? "" : profile.root),
2024-03-22 18:02:51 +07:00
posLevel : profile.posLevel ,
posNumber :
2024-04-09 09:25:55 +07:00
Extension . ToThaiNumber ( profile . orgShortName ) +
2025-04-05 18:12:02 +07:00
" " +
2024-04-09 09:25:55 +07:00
Extension . ToThaiNumber ( profile . posMasterNo . toLocaleString ( ) ) ,
2024-03-22 18:02:51 +07:00
amount : profile.amount ? Extension . ToThaiNumber ( profile . amount . toLocaleString ( ) ) : null ,
emp2-(04, 06, 08, 10, 12, 14, 16, 18, 19, 20, 22, 24)
2024-03-28 17:21:32 +07:00
positionSalaryAmount : profile.positionSalaryAmount
? Extension . ToThaiNumber ( profile . positionSalaryAmount . toLocaleString ( ) )
: null ,
2025-05-01 17:35:22 +07:00
reason : profile.remark ? profile.remark : null ,
2024-03-22 18:02:51 +07:00
} ;
} ) ;
return new HttpSuccess ( {
emp2-(04, 06, 08, 10, 12, 14, 16, 18, 19, 20, 22, 24)
2024-03-28 17:21:32 +07:00
template : "emp2-14" ,
reportName : "emp2-14" ,
2024-03-22 18:02:51 +07:00
data : {
year : Extension.ToThaiNumber ( String ( Extension . ToThaiYear ( salaryPeriod . year ) ) ) ,
agency : agency ,
data : formattedData ,
} ,
} ) ;
}
/ * *
* API 15 - บ ั ญ ช ี ร า ย ช ื ่ อ ล ู ก จ ้ า ง ป ร ะ จ ำ ก ร ุ ง เ ท พ ม ห า น ค ร ผ ู ้ ไ ม ่ ไ ด ้ ร ั บ ค ่ า ต อ บ แ ท น พ ิ เ ศ ษ ท ี ่ เ ก ษ ี ย ณ อ า ย ุ ร า ช ก า ร
*
* @summary 15 - บ ั ญ ช ี ร า ย ช ื ่ อ ล ู ก จ ้ า ง ป ร ะ จ ำ ก ร ุ ง เ ท พ ม ห า น ค ร ผ ู ้ ไ ม ่ ไ ด ้ ร ั บ ค ่ า ต อ บ แ ท น พ ิ เ ศ ษ ท ี ่ เ ก ษ ี ย ณ อ า ย ุ ร า ช ก า ร
*
* /
@Get ( "emp2-15/{rootId}/{salaryPeriodId}" )
async SalaryReportEmp2_15 ( @Path ( ) rootId : string , @Path ( ) salaryPeriodId : string ) {
const salaryPeriod = await this . salaryPeriodRepository . findOne ( {
where : {
id : salaryPeriodId ,
} ,
} ) ;
if ( ! salaryPeriod ) {
throw new HttpError ( HttpStatusCode . NOT_FOUND , "ไม่พบข้อมูลการขึ้นเงินเดือน" ) ;
}
2024-03-29 11:27:56 +07:00
const _salaryPeriod = await this . salaryProfileEmployeeRepository . find ( {
2024-04-05 14:22:26 +07:00
relations : [ "salaryOrg" , "salaryOrg.salaryPeriod" ] ,
where : {
isRetired : true ,
2025-05-01 17:39:55 +07:00
type : In ( [ "NONE" ] ) ,
// amountSpecial: MoreThan(0),xxx
2024-04-05 14:22:26 +07:00
salaryOrg : {
snapshot : "SNAP2" ,
rootId : rootId ,
salaryPeriodId : salaryPeriodId ,
2024-03-29 11:27:56 +07:00
} ,
2024-04-05 14:22:26 +07:00
} ,
order : {
2025-05-19 11:39:09 +07:00
rootOrder : "ASC" ,
child1Order : "ASC" ,
child2Order : "ASC" ,
child3Order : "ASC" ,
child4Order : "ASC" ,
2024-04-05 14:22:26 +07:00
orgShortName : "ASC" ,
posMasterNo : "ASC" ,
} ,
} ) ;
2024-03-22 18:02:51 +07:00
if ( ! _salaryPeriod ) {
throw new HttpError ( HttpStatusCode . NOT_FOUND , "ไม่พบข้อมูล" ) ;
}
const agency = _salaryPeriod [ 0 ] == null ? "" : _salaryPeriod [ 0 ] . root ;
2025-05-16 17:21:23 +07:00
//หาคนที่เงินเดือนเท่ากับเงินเดือนสูงสุดในกลุ่ม
const filteredProfiles = await Promise . all (
_salaryPeriod . map ( async ( profile ) = > {
const salaryRankMax = await this . salaryEmployeeRankRepository
. createQueryBuilder ( "rank" )
. leftJoin ( "rank.salaryEmployee_" , "emp" )
. where ( "emp.isActive = :isActive" , { isActive : true } )
. andWhere ( "emp.group = :group" , { group : profile.group } )
. orderBy ( "rank.step" , "DESC" )
. getOne ( ) ;
const match =
salaryRankMax != null &&
profile . salaryLevel != null &&
profile . salaryLevel === salaryRankMax . step &&
profile . amount === salaryRankMax . salaryMonth ;
if ( ! match ) return null ;
return { profile , salaryRankMax } ;
} )
) ;
const validProfiles = filteredProfiles . filter ( ( item ) : item is { profile : any , salaryRankMax : any } = > item !== null ) ;
const formattedData = validProfiles . map ( ( { profile } , index ) = > {
2024-03-22 18:02:51 +07:00
const fullNameParts = [
profile . child4 ,
profile . child3 ,
profile . child2 ,
profile . child1 ,
profile . root ,
] ;
2024-07-12 10:22:36 +07:00
const affiliation = fullNameParts
2024-03-22 18:02:51 +07:00
. filter ( ( part ) = > part !== undefined && part !== null )
2025-04-04 13:45:33 +07:00
. join ( "\n" ) ;
2024-07-12 10:22:36 +07:00
const fullName = ` ${ profile . prefix } ${ profile . firstName } ${ profile . lastName } ` ;
2024-08-23 14:10:34 +07:00
2024-03-22 18:02:51 +07:00
return {
no : Extension.ToThaiNumber ( ( index + 1 ) . toLocaleString ( ) ) ,
fullName : fullName ,
2024-07-12 10:22:36 +07:00
affiliation : affiliation ,
2024-03-29 11:27:56 +07:00
position : profile.position ,
2024-04-25 00:53:57 +07:00
posLevel : profile.posLevel
? Extension . ToThaiNumber ( profile . posLevel . toLocaleString ( ) )
: null ,
2024-03-22 18:02:51 +07:00
posNumber :
2024-04-09 09:25:55 +07:00
Extension . ToThaiNumber ( profile . orgShortName ) +
2025-04-05 18:12:02 +07:00
" " +
2024-04-09 09:25:55 +07:00
Extension . ToThaiNumber ( profile . posMasterNo . toLocaleString ( ) ) ,
2024-03-22 18:02:51 +07:00
amount : profile.amount ? Extension . ToThaiNumber ( profile . amount . toLocaleString ( ) ) : null ,
reason : null ,
} ;
} ) ;
return new HttpSuccess ( {
2024-03-29 11:27:56 +07:00
template : "emp2-15" ,
2024-04-05 14:22:26 +07:00
reportName : "emp2-15" ,
2024-03-22 18:02:51 +07:00
data : {
year : Extension.ToThaiNumber ( String ( Extension . ToThaiYear ( salaryPeriod . year ) ) ) ,
agency : agency ,
data : formattedData ,
} ,
} ) ;
}
/ * *
* API 16 - ค ำ ส ั ่ ง เ ล ื ่ อ น ข ั ้ น ค ่ า จ ้ า ง แ ล ะ ใ ห ้ ล ู ก จ ้ า ง ป ร ะ จ ำ ก ร ุ ง เ ท พ ม ห า น ค ร ไ ด ้ ร ั บ อ ั ต ร า ค ่ า จ ้ า ง ส ู ง ก ว ่ า อ ั ต ร า ค ่ า จ ้ า ง ข ั ้ น ส ู ง ข อ ง ต ำ แ ห น ่ ง ท ี ่ ไ ด ้ ร ั บ แ ต ่ ง ต ั ้ ง ใ น แ ต ่ ล ะ ร ะ ด ั บ
*
* @summary 16 - ค ำ ส ั ่ ง เ ล ื ่ อ น ข ั ้ น ค ่ า จ ้ า ง แ ล ะ ใ ห ้ ล ู ก จ ้ า ง ป ร ะ จ ำ ก ร ุ ง เ ท พ ม ห า น ค ร ไ ด ้ ร ั บ อ ั ต ร า ค ่ า จ ้ า ง ส ู ง ก ว ่ า อ ั ต ร า ค ่ า จ ้ า ง ข ั ้ น ส ู ง ข อ ง ต ำ แ ห น ่ ง ท ี ่ ไ ด ้ ร ั บ แ ต ่ ง ต ั ้ ง ใ น แ ต ่ ล ะ ร ะ ด ั บ
*
* /
@Get ( "emp2-16/{rootId}/{salaryPeriodId}" )
async SalaryReportEmp2_16 ( @Path ( ) rootId : string , @Path ( ) salaryPeriodId : string ) {
const salaryPeriod = await this . salaryPeriodRepository . findOne ( {
where : {
id : salaryPeriodId ,
emp2-(04, 06, 08, 10, 12, 14, 16, 18, 19, 20, 22, 24)
2024-03-28 17:21:32 +07:00
period : "OCT" ,
2024-04-05 14:22:26 +07:00
isActive : true ,
2024-03-22 18:02:51 +07:00
} ,
} ) ;
if ( ! salaryPeriod ) {
throw new HttpError ( HttpStatusCode . NOT_FOUND , "ไม่พบข้อมูลการขึ้นเงินเดือน" ) ;
}
emp2-(04, 06, 08, 10, 12, 14, 16, 18, 19, 20, 22, 24)
2024-03-28 17:21:32 +07:00
const salaryOrg = await this . salaryOrgEmployeeRepository . findOne ( {
2024-03-22 18:02:51 +07:00
where : {
emp2-(04, 06, 08, 10, 12, 14, 16, 18, 19, 20, 22, 24)
2024-03-28 17:21:32 +07:00
snapshot : "SNAP2" ,
rootId : rootId ,
salaryPeriodId : salaryPeriodId ,
2024-04-05 14:22:26 +07:00
} ,
2024-03-22 18:02:51 +07:00
} ) ;
emp2-(04, 06, 08, 10, 12, 14, 16, 18, 19, 20, 22, 24)
2024-03-28 17:21:32 +07:00
if ( ! salaryOrg ) {
2024-03-22 18:02:51 +07:00
throw new HttpError ( HttpStatusCode . NOT_FOUND , "ไม่พบข้อมูล" ) ;
}
return new HttpSuccess ( {
2024-04-05 14:22:26 +07:00
template : "emp2-16" ,
emp2-(04, 06, 08, 10, 12, 14, 16, 18, 19, 20, 22, 24)
2024-03-28 17:21:32 +07:00
reportName : "emp2-16" ,
2024-03-22 18:02:51 +07:00
} ) ;
}
2024-03-29 11:27:56 +07:00
2024-03-22 18:02:51 +07:00
/ * *
* API 17 - บ ั ญ ช ี ร า ย ล ะ เ อ ี ย ด แ ส ด ง ก า ร เ ล ื ่ อ น ข ั ้ น ค ่ า จ ้ า ง แ ล ะ ใ ห ้ ล ู ก จ ้ า ง ป ร ะ จ ำ ก ร ุ ง เ ท พ ม ห า น ค ร ไ ด ้ ร ั บ อ ั ต ร า ค ่ า จ ้ า ง ส ู ง ก ว ่ า อ ั ต ร า ค ่ า จ ้ า ง ข ั ้ น ส ู ง ข อ ง ต ำ แ ห น ่ ง ท ี ่ ไ ด ้ ร ั บ แ ต ่ ง ต ั ้ ง ใ น แ ต ่ ล ะ ร ะ ด ั บ ( แ น บ ท ้ า ย ค ำ ส ั ่ ง )
*
* @summary 17 - บ ั ญ ช ี ร า ย ล ะ เ อ ี ย ด แ ส ด ง ก า ร เ ล ื ่ อ น ข ั ้ น ค ่ า จ ้ า ง แ ล ะ ใ ห ้ ล ู ก จ ้ า ง ป ร ะ จ ำ ก ร ุ ง เ ท พ ม ห า น ค ร ไ ด ้ ร ั บ อ ั ต ร า ค ่ า จ ้ า ง ส ู ง ก ว ่ า อ ั ต ร า ค ่ า จ ้ า ง ข ั ้ น ส ู ง ข อ ง ต ำ แ ห น ่ ง ท ี ่ ไ ด ้ ร ั บ แ ต ่ ง ต ั ้ ง ใ น แ ต ่ ล ะ ร ะ ด ั บ ( แ น บ ท ้ า ย ค ำ ส ั ่ ง )
*
* /
@Get ( "emp2-17/{rootId}/{salaryPeriodId}" )
async SalaryReportEmp2_17 ( @Path ( ) rootId : string , @Path ( ) salaryPeriodId : string ) {
const salaryPeriod = await this . salaryPeriodRepository . findOne ( {
where : {
id : salaryPeriodId ,
} ,
} ) ;
if ( ! salaryPeriod ) {
throw new HttpError ( HttpStatusCode . NOT_FOUND , "ไม่พบข้อมูลการขึ้นเงินเดือน" ) ;
}
2024-03-29 17:35:28 +07:00
const salaryProfile = await this . salaryProfileEmployeeRepository . find ( {
2024-04-05 14:22:26 +07:00
relations : [ "salaryOrg" , "salaryOrg.salaryPeriod" ] ,
where : {
isNext : true ,
salaryOrg : {
snapshot : "SNAP2" ,
rootId : rootId ,
salaryPeriodId : salaryPeriodId ,
2024-03-29 17:35:28 +07:00
} ,
2024-04-05 14:22:26 +07:00
} ,
order : {
2025-05-19 11:39:09 +07:00
rootOrder : "ASC" ,
child1Order : "ASC" ,
child2Order : "ASC" ,
child3Order : "ASC" ,
child4Order : "ASC" ,
2024-04-05 14:22:26 +07:00
orgShortName : "ASC" ,
posMasterNo : "ASC" ,
2025-02-03 15:47:29 +07:00
type : "DESC" ,
2024-04-05 14:22:26 +07:00
} ,
} ) ;
2024-03-29 17:35:28 +07:00
if ( ! salaryProfile ) {
2024-03-22 18:02:51 +07:00
throw new HttpError ( HttpStatusCode . NOT_FOUND , "ไม่พบข้อมูล" ) ;
}
2024-03-29 17:35:28 +07:00
const agency = salaryProfile [ 0 ] == null ? "" : salaryProfile [ 0 ] . root ;
2024-03-22 18:02:51 +07:00
2024-03-29 17:35:28 +07:00
const formattedData = salaryProfile . map ( ( profile , index ) = > {
2024-03-22 18:02:51 +07:00
const fullNameParts = [
profile . child4 ,
profile . child3 ,
profile . child2 ,
profile . child1 ,
profile . root ,
] ;
2024-07-12 10:22:36 +07:00
const affiliation = fullNameParts
2024-03-22 18:02:51 +07:00
. filter ( ( part ) = > part !== undefined && part !== null )
2025-04-04 13:45:33 +07:00
. join ( "\n" ) ;
2024-07-12 10:22:36 +07:00
const fullName = ` ${ profile . prefix } ${ profile . firstName } ${ profile . lastName } ` ;
2024-03-22 18:02:51 +07:00
return {
no : Extension.ToThaiNumber ( ( index + 1 ) . toLocaleString ( ) ) ,
fullName : fullName ,
2024-07-12 10:22:36 +07:00
affiliation : affiliation ,
2025-02-03 15:47:29 +07:00
position : profile.position ? ? "-" ,
2024-04-25 00:53:57 +07:00
posLevel : profile.posLevel
2025-02-04 15:27:05 +07:00
? ` ${ profile . posTypeShort } ${ Extension . ToThaiNumber ( profile . posLevel . toLocaleString ( ) ) } `
2025-01-28 17:31:40 +07:00
: "-" ,
2025-02-03 15:47:29 +07:00
posNumber :
profile . orgShortName || profile . posMasterNo
? Extension . ToThaiNumber ( profile . orgShortName ) +
2025-04-05 18:12:02 +07:00
" " +
2025-02-03 15:47:29 +07:00
Extension . ToThaiNumber ( profile . posMasterNo . toLocaleString ( ) )
: "-" ,
2025-01-28 17:31:40 +07:00
amount : profile.amount ? Extension . ToThaiNumber ( profile . amount . toLocaleString ( ) ) : "-" ,
2024-04-05 14:22:26 +07:00
positionSalaryAmount : profile.positionSalaryAmount
? Extension . ToThaiNumber ( profile . positionSalaryAmount . toLocaleString ( ) )
2025-01-28 17:31:40 +07:00
: "-" ,
2025-02-03 15:47:29 +07:00
reason :
profile . type === "HAFT"
? "๐ .๕ ขั้น"
: profile . type === "FULL"
? "๑ ขั้น"
: profile . type === "FULLHAFT"
? "๑.๕ ขั้น"
: null ,
2024-03-22 18:02:51 +07:00
} ;
} ) ;
2024-04-05 14:22:26 +07:00
2024-03-22 18:02:51 +07:00
return new HttpSuccess ( {
2024-03-29 17:35:28 +07:00
template : "emp2-17" ,
reportName : "emp2-17" ,
2024-03-22 18:02:51 +07:00
data : {
year : Extension.ToThaiNumber ( String ( Extension . ToThaiYear ( salaryPeriod . year ) ) ) ,
agency : agency ,
data : formattedData ,
} ,
} ) ;
}
2024-03-29 11:27:56 +07:00
2024-03-22 18:02:51 +07:00
/ * *
* API 18 - บ ั ญ ช ี ร า ย ช ื ่ อ ล ู ก จ ้ า ง ป ร ะ จ ำ ก ร ุ ง เ ท พ ม ห า น ค ร ผ ู ้ ไ ม ่ ไ ด ้ ร ั บ ก า ร เ ล ื ่ อ น ข ั ้ น ค ่ า จ ้ า ง
*
* @summary 18 - บ ั ญ ช ี ร า ย ช ื ่ อ ล ู ก จ ้ า ง ป ร ะ จ ำ ก ร ุ ง เ ท พ ม ห า น ค ร ผ ู ้ ไ ม ่ ไ ด ้ ร ั บ ก า ร เ ล ื ่ อ น ข ั ้ น ค ่ า จ ้ า ง
*
* /
@Get ( "emp2-18/{rootId}/{salaryPeriodId}" )
async SalaryReportEmp2_18 ( @Path ( ) rootId : string , @Path ( ) salaryPeriodId : string ) {
const salaryPeriod = await this . salaryPeriodRepository . findOne ( {
where : {
id : salaryPeriodId ,
emp2-(04, 06, 08, 10, 12, 14, 16, 18, 19, 20, 22, 24)
2024-03-28 17:21:32 +07:00
period : "OCT" ,
2024-04-05 14:22:26 +07:00
isActive : true ,
2024-03-22 18:02:51 +07:00
} ,
} ) ;
if ( ! salaryPeriod ) {
throw new HttpError ( HttpStatusCode . NOT_FOUND , "ไม่พบข้อมูลการขึ้นเงินเดือน" ) ;
}
emp2-(04, 06, 08, 10, 12, 14, 16, 18, 19, 20, 22, 24)
2024-03-28 17:21:32 +07:00
const _salaryProfileEmp = await this . salaryProfileEmployeeRepository . find ( {
2024-03-22 18:02:51 +07:00
relations : [ "salaryOrg" , "salaryOrg.salaryPeriod" ] ,
where : {
salaryOrg : {
emp2-(04, 06, 08, 10, 12, 14, 16, 18, 19, 20, 22, 24)
2024-03-28 17:21:32 +07:00
snapshot : "SNAP2" ,
2024-03-22 18:02:51 +07:00
rootId : rootId ,
salaryPeriodId : salaryPeriodId ,
} ,
2025-02-03 15:47:29 +07:00
type : In ( [ "NONE" , "PENDING" ] ) ,
2024-04-05 14:22:26 +07:00
isRetired : false ,
2024-03-22 18:02:51 +07:00
} ,
order : {
2025-05-19 11:39:09 +07:00
rootOrder : "ASC" ,
child1Order : "ASC" ,
child2Order : "ASC" ,
child3Order : "ASC" ,
child4Order : "ASC" ,
#1002,#1004,#1006,#1008,#1013,#1015,#1024,#1028,#1036,#1038,#1044,#1047,#1050
2025-01-27 17:14:13 +07:00
type : "DESC" ,
2024-03-22 18:02:51 +07:00
orgShortName : "ASC" ,
posMasterNo : "ASC" ,
} ,
} ) ;
emp2-(04, 06, 08, 10, 12, 14, 16, 18, 19, 20, 22, 24)
2024-03-28 17:21:32 +07:00
if ( ! _salaryProfileEmp ) {
2024-03-22 18:02:51 +07:00
throw new HttpError ( HttpStatusCode . NOT_FOUND , "ไม่พบข้อมูล" ) ;
}
emp2-(04, 06, 08, 10, 12, 14, 16, 18, 19, 20, 22, 24)
2024-03-28 17:21:32 +07:00
const agency = _salaryProfileEmp [ 0 ] == null ? "" : _salaryProfileEmp [ 0 ] . root ;
2024-03-22 18:02:51 +07:00
emp2-(04, 06, 08, 10, 12, 14, 16, 18, 19, 20, 22, 24)
2024-03-28 17:21:32 +07:00
const formattedData = _salaryProfileEmp . map ( ( profile , index ) = > {
2024-03-22 18:02:51 +07:00
const fullNameParts = [
profile . child4 ,
profile . child3 ,
profile . child2 ,
profile . child1 ,
profile . root ,
] ;
2024-07-12 10:22:36 +07:00
const affiliation = fullNameParts
2024-03-22 18:02:51 +07:00
. filter ( ( part ) = > part !== undefined && part !== null )
2025-04-04 13:45:33 +07:00
. join ( "\n" ) ;
2025-01-23 16:29:20 +07:00
2024-07-12 10:22:36 +07:00
const fullName = ` ${ profile . prefix } ${ profile . firstName } ${ profile . lastName } ` ;
2024-03-22 18:02:51 +07:00
return {
no : Extension.ToThaiNumber ( ( index + 1 ) . toLocaleString ( ) ) ,
fullName : fullName ,
2024-07-12 10:22:36 +07:00
affiliation : affiliation ,
2025-02-03 15:47:29 +07:00
position : profile.position ? profile . position : "-" ,
2024-04-25 00:53:57 +07:00
posLevel : profile.posLevel
? Extension . ToThaiNumber ( profile . posLevel . toLocaleString ( ) )
2025-01-23 16:29:20 +07:00
: "-" ,
2024-03-22 18:02:51 +07:00
posNumber :
2024-04-09 09:25:55 +07:00
Extension . ToThaiNumber ( profile . orgShortName ) +
2025-04-05 18:12:02 +07:00
" " +
2024-04-09 09:25:55 +07:00
Extension . ToThaiNumber ( profile . posMasterNo . toLocaleString ( ) ) ,
2025-01-23 16:29:20 +07:00
amount : profile.amount ? Extension . ToThaiNumber ( profile . amount . toLocaleString ( ) ) : "-" ,
emp2-(04, 06, 08, 10, 12, 14, 16, 18, 19, 20, 22, 24)
2024-03-28 17:21:32 +07:00
positionSalaryAmount : profile.positionSalaryAmount
? Extension . ToThaiNumber ( profile . positionSalaryAmount . toLocaleString ( ) )
2025-01-23 16:29:20 +07:00
: "-" ,
#1002,#1004,#1006,#1008,#1013,#1015,#1024,#1028,#1036,#1038,#1044,#1047,#1050
2025-01-27 17:14:13 +07:00
reason : profile.remark ? ? null ,
2024-03-22 18:02:51 +07:00
} ;
} ) ;
return new HttpSuccess ( {
emp2-(04, 06, 08, 10, 12, 14, 16, 18, 19, 20, 22, 24)
2024-03-28 17:21:32 +07:00
template : "emp2-18" ,
reportName : "emp2-18" ,
2024-03-22 18:02:51 +07:00
data : {
year : Extension.ToThaiNumber ( String ( Extension . ToThaiYear ( salaryPeriod . year ) ) ) ,
agency : agency ,
data : formattedData ,
} ,
} ) ;
}
/ * *
* API 20 - บ ั ญ ช ี ร า ย ล ะ เ อ ี ย ด ใ ห ้ ล ู ก จ ้ า ง ป ร ะ จ ำ ก ร ุ ง เ ท พ ม ห า น ค ร ไ ด ้ ร ั บ ค ่ า ต อ บ แ ท น พ ิ เ ศ ษ ( แ น บ ท ้ า ย ค ำ ส ั ่ ง )
*
* @summary 20 - บ ั ญ ช ี ร า ย ล ะ เ อ ี ย ด ใ ห ้ ล ู ก จ ้ า ง ป ร ะ จ ำ ก ร ุ ง เ ท พ ม ห า น ค ร ไ ด ้ ร ั บ ค ่ า ต อ บ แ ท น พ ิ เ ศ ษ ( แ น บ ท ้ า ย ค ำ ส ั ่ ง )
*
* /
@Get ( "emp2-20/{rootId}/{salaryPeriodId}" )
async SalaryReportEmp2_20 ( @Path ( ) rootId : string , @Path ( ) salaryPeriodId : string ) {
const salaryPeriod = await this . salaryPeriodRepository . findOne ( {
where : {
id : salaryPeriodId ,
emp2-(04, 06, 08, 10, 12, 14, 16, 18, 19, 20, 22, 24)
2024-03-28 17:21:32 +07:00
period : "OCT" ,
2024-04-05 14:22:26 +07:00
isActive : true ,
2024-03-22 18:02:51 +07:00
} ,
} ) ;
if ( ! salaryPeriod ) {
throw new HttpError ( HttpStatusCode . NOT_FOUND , "ไม่พบข้อมูลการขึ้นเงินเดือน" ) ;
}
emp2-(04, 06, 08, 10, 12, 14, 16, 18, 19, 20, 22, 24)
2024-03-28 17:21:32 +07:00
const _salaryProfileEmp = await this . salaryProfileEmployeeRepository . find ( {
2024-03-22 18:02:51 +07:00
relations : [ "salaryOrg" , "salaryOrg.salaryPeriod" ] ,
where : {
2025-02-03 15:47:29 +07:00
type : Not ( In ( [ "NONE" , "PENDING" ] ) ) ,
2025-01-28 17:31:40 +07:00
amountSpecial : MoreThan ( 0 ) ,
2024-03-22 18:02:51 +07:00
salaryOrg : {
emp2-(04, 06, 08, 10, 12, 14, 16, 18, 19, 20, 22, 24)
2024-03-28 17:21:32 +07:00
snapshot : "SNAP2" ,
2024-03-22 18:02:51 +07:00
rootId : rootId ,
salaryPeriodId : salaryPeriodId ,
} ,
} ,
order : {
2025-05-19 11:39:09 +07:00
rootOrder : "ASC" ,
child1Order : "ASC" ,
child2Order : "ASC" ,
child3Order : "ASC" ,
child4Order : "ASC" ,
2025-01-28 17:31:40 +07:00
type : "DESC" ,
2024-03-22 18:02:51 +07:00
orgShortName : "ASC" ,
posMasterNo : "ASC" ,
} ,
} ) ;
emp2-(04, 06, 08, 10, 12, 14, 16, 18, 19, 20, 22, 24)
2024-03-28 17:21:32 +07:00
if ( ! _salaryProfileEmp ) {
2024-03-22 18:02:51 +07:00
throw new HttpError ( HttpStatusCode . NOT_FOUND , "ไม่พบข้อมูล" ) ;
}
emp2-(04, 06, 08, 10, 12, 14, 16, 18, 19, 20, 22, 24)
2024-03-28 17:21:32 +07:00
const agency = _salaryProfileEmp [ 0 ] == null ? "" : _salaryProfileEmp [ 0 ] . root ;
2024-03-22 18:02:51 +07:00
emp2-(04, 06, 08, 10, 12, 14, 16, 18, 19, 20, 22, 24)
2024-03-28 17:21:32 +07:00
const formattedData = _salaryProfileEmp . map ( ( profile , index ) = > {
2024-03-22 18:02:51 +07:00
const fullNameParts = [
profile . child4 ,
profile . child3 ,
profile . child2 ,
profile . child1 ,
profile . root ,
] ;
2024-07-12 10:22:36 +07:00
const affiliation = fullNameParts
2024-03-22 18:02:51 +07:00
. filter ( ( part ) = > part !== undefined && part !== null )
2025-01-29 10:13:43 +07:00
. join ( " " ) ;
2025-01-28 17:31:40 +07:00
const positionParts = [
profile . position ,
profile . child4 ,
profile . child3 ,
profile . child2 ,
profile . child1 ,
profile . root ,
] ;
const position = positionParts
. filter ( ( part ) = > part !== undefined && part !== null )
2025-04-04 13:45:33 +07:00
. join ( "\n" ) ;
2025-01-28 17:31:40 +07:00
2024-07-12 10:22:36 +07:00
const fullName = ` ${ profile . prefix } ${ profile . firstName } ${ profile . lastName } ` ;
2024-03-22 18:02:51 +07:00
return {
no : Extension.ToThaiNumber ( ( index + 1 ) . toLocaleString ( ) ) ,
fullName : fullName ,
2024-07-12 10:22:36 +07:00
affiliation : affiliation ,
2025-01-28 17:31:40 +07:00
position : position ,
2024-04-25 00:53:57 +07:00
posLevel : profile.posLevel
? Extension . ToThaiNumber ( profile . posLevel . toLocaleString ( ) )
2025-01-28 17:31:40 +07:00
: "-" ,
2024-03-22 18:02:51 +07:00
posNumber :
2024-04-09 09:25:55 +07:00
Extension . ToThaiNumber ( profile . orgShortName ) +
2025-04-05 18:12:02 +07:00
" " +
2024-04-09 09:25:55 +07:00
Extension . ToThaiNumber ( profile . posMasterNo . toLocaleString ( ) ) ,
emp2-(04, 06, 08, 10, 12, 14, 16, 18, 19, 20, 22, 24)
2024-03-28 17:21:32 +07:00
positionSalaryAmount : profile.positionSalaryAmount
? Extension . ToThaiNumber ( profile . positionSalaryAmount . toLocaleString ( ) )
2025-01-28 17:31:40 +07:00
: "-" ,
emp2-(04, 06, 08, 10, 12, 14, 16, 18, 19, 20, 22, 24)
2024-03-28 17:21:32 +07:00
precentTwo :
2025-01-28 17:31:40 +07:00
profile . positionSalaryAmountPer == 0.02
emp2-(04, 06, 08, 10, 12, 14, 16, 18, 19, 20, 22, 24)
2024-03-28 17:21:32 +07:00
? Extension . ToThaiNumber ( profile . amountSpecial . toLocaleString ( ) )
2025-01-28 17:31:40 +07:00
: "-" , //ร้อยละ 2
emp2-(04, 06, 08, 10, 12, 14, 16, 18, 19, 20, 22, 24)
2024-03-28 17:21:32 +07:00
precentFour :
2025-01-28 17:31:40 +07:00
profile . positionSalaryAmountPer == 0.04
emp2-(04, 06, 08, 10, 12, 14, 16, 18, 19, 20, 22, 24)
2024-03-28 17:21:32 +07:00
? Extension . ToThaiNumber ( profile . amountSpecial . toLocaleString ( ) )
2025-01-28 17:31:40 +07:00
: "-" , //ร้อยละ 4
emp2-(04, 06, 08, 10, 12, 14, 16, 18, 19, 20, 22, 24)
2024-03-28 17:21:32 +07:00
precentSix :
2025-01-28 17:31:40 +07:00
profile . positionSalaryAmountPer == 0.06
2024-04-05 14:22:26 +07:00
? Extension . ToThaiNumber ( profile . amountSpecial . toLocaleString ( ) )
2025-01-28 17:31:40 +07:00
: "-" , //ร้อยละ 6
2024-03-22 18:02:51 +07:00
reason : null ,
} ;
} ) ;
return new HttpSuccess ( {
emp2-(04, 06, 08, 10, 12, 14, 16, 18, 19, 20, 22, 24)
2024-03-28 17:21:32 +07:00
template : "emp2-20" ,
reportName : "emp2-20" ,
2024-03-22 18:02:51 +07:00
data : {
year : Extension.ToThaiNumber ( String ( Extension . ToThaiYear ( salaryPeriod . year ) ) ) ,
agency : agency ,
data : formattedData ,
} ,
} ) ;
}
emp2-(04, 06, 08, 10, 12, 14, 16, 18, 19, 20, 22, 24)
2024-03-28 17:21:32 +07:00
2024-03-22 18:02:51 +07:00
/ * *
* API 21 - บ ั ญ ช ี ร า ย ช ื ่ อ ล ู ก จ ้ า ง ป ร ะ จ ำ ก ร ุ ง เ ท พ ม ห า น ค ร ผ ู ้ ไ ม ่ ไ ด ้ ร ั บ ค ่ า ต อ บ แ ท น พ ิ เ ศ ษ
*
* @summary 21 - บ ั ญ ช ี ร า ย ช ื ่ อ ล ู ก จ ้ า ง ป ร ะ จ ำ ก ร ุ ง เ ท พ ม ห า น ค ร ผ ู ้ ไ ม ่ ไ ด ้ ร ั บ ค ่ า ต อ บ แ ท น พ ิ เ ศ ษ
*
* /
@Get ( "emp2-21/{rootId}/{salaryPeriodId}" )
async SalaryReportEmp2_21 ( @Path ( ) rootId : string , @Path ( ) salaryPeriodId : string ) {
const salaryPeriod = await this . salaryPeriodRepository . findOne ( {
where : {
id : salaryPeriodId ,
} ,
} ) ;
if ( ! salaryPeriod ) {
throw new HttpError ( HttpStatusCode . NOT_FOUND , "ไม่พบข้อมูลการขึ้นเงินเดือน" ) ;
}
2024-03-29 11:27:56 +07:00
const _salaryPeriod = await this . salaryProfileEmployeeRepository . find ( {
2024-04-05 14:22:26 +07:00
relations : [ "salaryOrg" , "salaryOrg.salaryPeriod" ] ,
where : {
2025-05-01 17:39:55 +07:00
type : In ( [ "NONE" ] ) ,
// amountSpecial: MoreThan(0),xxx
2024-04-05 14:22:26 +07:00
salaryOrg : {
snapshot : "SNAP2" ,
rootId : rootId ,
salaryPeriodId : salaryPeriodId ,
2024-03-29 11:27:56 +07:00
} ,
2024-04-05 14:22:26 +07:00
} ,
order : {
2025-05-19 11:39:09 +07:00
rootOrder : "ASC" ,
child1Order : "ASC" ,
child2Order : "ASC" ,
child3Order : "ASC" ,
child4Order : "ASC" ,
2024-04-05 14:22:26 +07:00
orgShortName : "ASC" ,
posMasterNo : "ASC" ,
} ,
} ) ;
2024-03-22 18:02:51 +07:00
if ( ! _salaryPeriod ) {
throw new HttpError ( HttpStatusCode . NOT_FOUND , "ไม่พบข้อมูล" ) ;
}
const agency = _salaryPeriod [ 0 ] == null ? "" : _salaryPeriod [ 0 ] . root ;
2025-05-16 17:21:23 +07:00
//หาคนที่เงินเดือนเท่ากับเงินเดือนสูงสุดในกลุ่ม
const filteredProfiles = await Promise . all (
_salaryPeriod . map ( async ( profile ) = > {
const salaryRankMax = await this . salaryEmployeeRankRepository
. createQueryBuilder ( "rank" )
. leftJoin ( "rank.salaryEmployee_" , "emp" )
. where ( "emp.isActive = :isActive" , { isActive : true } )
. andWhere ( "emp.group = :group" , { group : profile.group } )
. orderBy ( "rank.step" , "DESC" )
. getOne ( ) ;
const match =
salaryRankMax != null &&
profile . salaryLevel != null &&
profile . salaryLevel === salaryRankMax . step &&
profile . amount === salaryRankMax . salaryMonth ;
if ( ! match ) return null ;
return { profile , salaryRankMax } ;
} )
) ;
const validProfiles = filteredProfiles . filter ( ( item ) : item is { profile : any , salaryRankMax : any } = > item !== null ) ;
const formattedData = validProfiles . map ( ( { profile } , index ) = > {
2024-03-22 18:02:51 +07:00
const fullNameParts = [
profile . child4 ,
profile . child3 ,
profile . child2 ,
profile . child1 ,
profile . root ,
] ;
2024-07-12 10:22:36 +07:00
const affiliation = fullNameParts
2024-03-22 18:02:51 +07:00
. filter ( ( part ) = > part !== undefined && part !== null )
2025-04-04 13:45:33 +07:00
. join ( "\n" ) ;
2024-07-12 10:22:36 +07:00
const fullName = ` ${ profile . prefix } ${ profile . firstName } ${ profile . lastName } ` ;
2024-03-22 18:02:51 +07:00
return {
no : Extension.ToThaiNumber ( ( index + 1 ) . toLocaleString ( ) ) ,
fullName : fullName ,
2024-07-12 10:22:36 +07:00
affiliation : affiliation ,
#1002,#1004,#1006,#1008,#1013,#1015,#1024,#1028,#1036,#1038,#1044,#1047,#1050
2025-01-27 17:14:13 +07:00
position : profile.position ? ? "-" ,
2024-04-25 00:53:57 +07:00
posLevel : profile.posLevel
2025-02-03 15:47:29 +07:00
? ` ${ profile . posTypeShort } ${ Extension . ToThaiNumber ( profile . posLevel . toLocaleString ( ) ) } `
: "-" ,
2024-03-22 18:02:51 +07:00
posNumber :
#1002,#1004,#1006,#1008,#1013,#1015,#1024,#1028,#1036,#1038,#1044,#1047,#1050
2025-01-27 17:14:13 +07:00
profile . orgShortName || profile . posMasterNo
? Extension . ToThaiNumber ( profile . orgShortName ) +
2025-04-05 18:12:02 +07:00
" " +
#1002,#1004,#1006,#1008,#1013,#1015,#1024,#1028,#1036,#1038,#1044,#1047,#1050
2025-01-27 17:14:13 +07:00
Extension . ToThaiNumber ( profile . posMasterNo . toLocaleString ( ) )
: "-" ,
2025-01-23 16:29:20 +07:00
amount : profile.amount ? Extension . ToThaiNumber ( profile . amount . toLocaleString ( ) ) : "-" ,
2024-03-22 18:02:51 +07:00
reason : null ,
} ;
} ) ;
return new HttpSuccess ( {
2024-03-29 11:27:56 +07:00
template : "emp2-21" ,
2024-04-05 14:22:26 +07:00
reportName : "emp2-21" ,
2024-03-22 18:02:51 +07:00
data : {
year : Extension.ToThaiNumber ( String ( Extension . ToThaiYear ( salaryPeriod . year ) ) ) ,
agency : agency ,
data : formattedData ,
} ,
} ) ;
}
/ * *
* API 22 - ค ำ ส ั ่ ง แ ก ้ ไ ข ค ำ ส ั ่ ง เ ล ื ่ อ น ข ั ้ น ค ่ า จ ้ า ง ล ู ก จ ้ า ง ป ร ะ จ ำ ก ร ุ ง เ ท พ ม ห า น ค ร ( เ ฉ พ า ะ ร า ย )
*
* @summary 22 - ค ำ ส ั ่ ง แ ก ้ ไ ข ค ำ ส ั ่ ง เ ล ื ่ อ น ข ั ้ น ค ่ า จ ้ า ง ล ู ก จ ้ า ง ป ร ะ จ ำ ก ร ุ ง เ ท พ ม ห า น ค ร ( เ ฉ พ า ะ ร า ย )
*
* /
@Get ( "emp2-22/{rootId}/{salaryPeriodId}" )
async SalaryReportEmp2_22 ( @Path ( ) rootId : string , @Path ( ) salaryPeriodId : string ) {
const salaryPeriod = await this . salaryPeriodRepository . findOne ( {
where : {
id : salaryPeriodId ,
emp2-(04, 06, 08, 10, 12, 14, 16, 18, 19, 20, 22, 24)
2024-03-28 17:21:32 +07:00
period : "OCT" ,
2024-04-05 14:22:26 +07:00
isActive : true ,
2024-03-22 18:02:51 +07:00
} ,
} ) ;
if ( ! salaryPeriod ) {
throw new HttpError ( HttpStatusCode . NOT_FOUND , "ไม่พบข้อมูลการขึ้นเงินเดือน" ) ;
}
emp2-(04, 06, 08, 10, 12, 14, 16, 18, 19, 20, 22, 24)
2024-03-28 17:21:32 +07:00
const salaryOrg = await this . salaryOrgEmployeeRepository . findOne ( {
2024-03-22 18:02:51 +07:00
where : {
emp2-(04, 06, 08, 10, 12, 14, 16, 18, 19, 20, 22, 24)
2024-03-28 17:21:32 +07:00
snapshot : "SNAP2" ,
rootId : rootId ,
salaryPeriodId : salaryPeriodId ,
2024-04-05 14:22:26 +07:00
} ,
2024-03-22 18:02:51 +07:00
} ) ;
emp2-(04, 06, 08, 10, 12, 14, 16, 18, 19, 20, 22, 24)
2024-03-28 17:21:32 +07:00
if ( ! salaryOrg ) {
2024-03-22 18:02:51 +07:00
throw new HttpError ( HttpStatusCode . NOT_FOUND , "ไม่พบข้อมูล" ) ;
}
return new HttpSuccess ( {
2024-04-05 14:22:26 +07:00
template : "emp2-22" ,
emp2-(04, 06, 08, 10, 12, 14, 16, 18, 19, 20, 22, 24)
2024-03-28 17:21:32 +07:00
reportName : "emp2-22" ,
2024-03-22 18:02:51 +07:00
} ) ;
}
/ * *
* API 23 - บ ั ญ ช ี ร า ย ล ะ เ อ ี ย ด แ ส ด ง ก า ร เ ล ื ่ อ น ข ั ้ น ค ่ า จ ้ า ง แ ล ะ ใ ห ้ ล ู ก จ ้ า ง ป ร ะ จ ำ ก ร ุ ง เ ท พ ม ห า น ค ร ไ ด ้ ร ั บ อ ั ต ร า ค ่ า จ ้ า ง ส ู ง ก ว ่ า อ ั ต ร า ค ่ า จ ้ า ง ข ั ้ น ส ู ง ข อ ง ต ำ แ ห น ่ ง ท ี ่ ไ ด ้ ร ั บ แ ต ่ ง ต ั ้ ง ใ น แ ต ่ ล ะ ร ะ ด ั บ ( แ น บ ท ้ า ย ค ำ ส ั ่ ง )
*
* @summary 23 - บ ั ญ ช ี ร า ย ล ะ เ อ ี ย ด แ ส ด ง ก า ร เ ล ื ่ อ น ข ั ้ น ค ่ า จ ้ า ง แ ล ะ ใ ห ้ ล ู ก จ ้ า ง ป ร ะ จ ำ ก ร ุ ง เ ท พ ม ห า น ค ร ไ ด ้ ร ั บ อ ั ต ร า ค ่ า จ ้ า ง ส ู ง ก ว ่ า อ ั ต ร า ค ่ า จ ้ า ง ข ั ้ น ส ู ง ข อ ง ต ำ แ ห น ่ ง ท ี ่ ไ ด ้ ร ั บ แ ต ่ ง ต ั ้ ง ใ น แ ต ่ ล ะ ร ะ ด ั บ ( แ น บ ท ้ า ย ค ำ ส ั ่ ง )
*
* /
@Get ( "emp2-23/{rootId}/{salaryPeriodId}" )
async SalaryReportEmp2_23 ( @Path ( ) rootId : string , @Path ( ) salaryPeriodId : string ) {
const salaryPeriod = await this . salaryPeriodRepository . findOne ( {
where : {
id : salaryPeriodId ,
} ,
} ) ;
if ( ! salaryPeriod ) {
throw new HttpError ( HttpStatusCode . NOT_FOUND , "ไม่พบข้อมูลการขึ้นเงินเดือน" ) ;
}
const _salaryPeriod = await this . salaryProfileRepository . find ( {
relations : [ "salaryOrg" , "salaryOrg.salaryPeriod" ] ,
where : {
salaryOrg : {
snapshot : "SNAP1" ,
rootId : rootId ,
salaryPeriodId : salaryPeriodId ,
} ,
} ,
order : {
2025-05-19 11:39:09 +07:00
rootOrder : "ASC" ,
child1Order : "ASC" ,
child2Order : "ASC" ,
child3Order : "ASC" ,
child4Order : "ASC" ,
2024-03-22 18:02:51 +07:00
orgShortName : "ASC" ,
posMasterNo : "ASC" ,
} ,
} ) ;
if ( ! _salaryPeriod ) {
throw new HttpError ( HttpStatusCode . NOT_FOUND , "ไม่พบข้อมูล" ) ;
}
const agency = _salaryPeriod [ 0 ] == null ? "" : _salaryPeriod [ 0 ] . root ;
const formattedData = _salaryPeriod . map ( ( profile , index ) = > {
const fullNameParts = [
profile . child4 ,
profile . child3 ,
profile . child2 ,
profile . child1 ,
profile . root ,
` ${ profile . prefix } ${ profile . firstName } ${ profile . lastName } ` ,
] ;
const fullName = fullNameParts
. filter ( ( part ) = > part !== undefined && part !== null )
2025-01-29 10:13:43 +07:00
. join ( " " ) ;
2024-03-22 18:02:51 +07:00
return {
no : Extension.ToThaiNumber ( ( index + 1 ) . toLocaleString ( ) ) ,
fullName : fullName ,
2024-04-25 00:53:57 +07:00
posLevel : profile.posLevel
? Extension . ToThaiNumber ( profile . posLevel . toLocaleString ( ) )
: null ,
2024-03-22 18:02:51 +07:00
posNumber :
2024-04-09 09:25:55 +07:00
Extension . ToThaiNumber ( profile . orgShortName ) +
2025-04-05 18:12:02 +07:00
" " +
2024-04-09 09:25:55 +07:00
Extension . ToThaiNumber ( profile . posMasterNo . toLocaleString ( ) ) ,
2024-03-22 18:02:51 +07:00
amount : profile.amount ? Extension . ToThaiNumber ( profile . amount . toLocaleString ( ) ) : null ,
reason : null ,
} ;
} ) ;
return new HttpSuccess ( {
template : salaryPeriod.period == "APR" ? "gov1-01" : "gov2-01" ,
reportName : salaryPeriod.period == "APR" ? "gov1-01" : "gov2-01" ,
data : {
year : Extension.ToThaiNumber ( String ( Extension . ToThaiYear ( salaryPeriod . year ) ) ) ,
agency : agency ,
data : formattedData ,
} ,
} ) ;
}
/ * *
* API 24 - ค ำ ส ั ่ ง ย ก เ ล ิ ก ค ำ ส ั ่ ง เ ล ื ่ อ น ข ั ้ น ค ่ า จ ้ า ง ล ู ก จ ้ า ง ป ร ะ จ ำ ก ร ุ ง เ ท พ ม ห า น ค ร ( เ ฉ พ า ะ ร า ย )
*
* @summary 24 - ค ำ ส ั ่ ง ย ก เ ล ิ ก ค ำ ส ั ่ ง เ ล ื ่ อ น ข ั ้ น ค ่ า จ ้ า ง ล ู ก จ ้ า ง ป ร ะ จ ำ ก ร ุ ง เ ท พ ม ห า น ค ร ( เ ฉ พ า ะ ร า ย )
*
* /
@Get ( "emp2-24/{rootId}/{salaryPeriodId}" )
async SalaryReportEmp2_24 ( @Path ( ) rootId : string , @Path ( ) salaryPeriodId : string ) {
const salaryPeriod = await this . salaryPeriodRepository . findOne ( {
where : {
id : salaryPeriodId ,
emp2-(04, 06, 08, 10, 12, 14, 16, 18, 19, 20, 22, 24)
2024-03-28 17:21:32 +07:00
period : "OCT" ,
2024-04-05 14:22:26 +07:00
isActive : true ,
2024-03-22 18:02:51 +07:00
} ,
} ) ;
if ( ! salaryPeriod ) {
throw new HttpError ( HttpStatusCode . NOT_FOUND , "ไม่พบข้อมูลการขึ้นเงินเดือน" ) ;
}
emp2-(04, 06, 08, 10, 12, 14, 16, 18, 19, 20, 22, 24)
2024-03-28 17:21:32 +07:00
const salaryOrg = await this . salaryOrgEmployeeRepository . findOne ( {
2024-03-22 18:02:51 +07:00
where : {
emp2-(04, 06, 08, 10, 12, 14, 16, 18, 19, 20, 22, 24)
2024-03-28 17:21:32 +07:00
snapshot : "SNAP2" ,
rootId : rootId ,
salaryPeriodId : salaryPeriodId ,
2024-04-05 14:22:26 +07:00
} ,
2024-03-22 18:02:51 +07:00
} ) ;
emp2-(04, 06, 08, 10, 12, 14, 16, 18, 19, 20, 22, 24)
2024-03-28 17:21:32 +07:00
if ( ! salaryOrg ) {
2024-03-22 18:02:51 +07:00
throw new HttpError ( HttpStatusCode . NOT_FOUND , "ไม่พบข้อมูล" ) ;
}
return new HttpSuccess ( {
2024-04-05 14:22:26 +07:00
template : "blank" ,
emp2-(04, 06, 08, 10, 12, 14, 16, 18, 19, 20, 22, 24)
2024-03-28 17:21:32 +07:00
reportName : "emp2-24" ,
2024-03-22 18:02:51 +07:00
} ) ;
}
2024-03-29 11:27:56 +07:00
2024-03-22 18:02:51 +07:00
/ * *
* API 25 - แ บ บ ฟ อ ร ์ ม บ ั ญ ช ี ถ ื อ จ ่ า ย อ ั ต ร า ค ่ า จ ้ า ง ล ู ก จ ้ า ง ป ร ะ จ ำ ก ร ุ ง เ ท พ ม ห า น ค ร
*
* @summary 25 - แ บ บ ฟ อ ร ์ ม บ ั ญ ช ี ถ ื อ จ ่ า ย อ ั ต ร า ค ่ า จ ้ า ง ล ู ก จ ้ า ง ป ร ะ จ ำ ก ร ุ ง เ ท พ ม ห า น ค ร
*
* /
@Get ( "emp2-25/{rootId}/{salaryPeriodId}" )
async SalaryReportEmp2_25 ( @Path ( ) rootId : string , @Path ( ) salaryPeriodId : string ) {
2024-03-29 17:35:28 +07:00
//งวดปีปัจจุบัน
const salaryPeriodOCT = await this . salaryPeriodRepository . findOne ( {
2024-03-21 15:29:39 +07:00
where : {
id : salaryPeriodId ,
} ,
} ) ;
2024-03-29 17:35:28 +07:00
if ( ! salaryPeriodOCT ) {
2024-03-21 15:29:39 +07:00
throw new HttpError ( HttpStatusCode . NOT_FOUND , "ไม่พบข้อมูลการขึ้นเงินเดือน" ) ;
}
2024-03-29 17:35:28 +07:00
const salaryPeriodAPR = await this . salaryPeriodRepository . findOne ( {
where : {
period : "APR" ,
year : salaryPeriodOCT.year ,
} ,
} ) ;
if ( ! salaryPeriodAPR ) {
throw new HttpError ( HttpStatusCode . NOT_FOUND , "ไม่พบข้อมูลการขึ้นเงินเดือน" ) ;
}
2024-04-25 00:53:57 +07:00
let perviousYearAPR : any ;
let perviousYearOCT : any ;
let salaryProfilePerviousAPR : any ;
let salaryProfilePerviousOCT : any ;
2024-04-10 11:16:19 +07:00
2024-03-29 17:35:28 +07:00
//งวดปีก่อนหน้า
2024-04-25 00:53:57 +07:00
perviousYearAPR = await this . salaryPeriodRepository . findOne ( {
2024-04-05 14:22:26 +07:00
where : {
period : "APR" ,
year : salaryPeriodOCT.year - 1 ,
} ,
2024-03-29 17:35:28 +07:00
} ) ;
2024-04-25 00:53:57 +07:00
perviousYearOCT = await this . salaryPeriodRepository . findOne ( {
2024-04-05 14:22:26 +07:00
where : {
period : "OCT" ,
year : salaryPeriodOCT.year - 1 ,
} ,
2024-03-29 17:35:28 +07:00
} ) ;
2024-04-25 00:53:57 +07:00
2024-03-29 17:35:28 +07:00
//ปีก่อนหน้า
2024-04-25 00:53:57 +07:00
if ( perviousYearAPR ) {
2024-04-10 11:44:38 +07:00
salaryProfilePerviousAPR = await this . salaryProfileEmployeeRepository . find ( {
relations : [ "salaryOrg" , "salaryOrg.salaryPeriod" ] ,
where : {
salaryOrg : {
snapshot : "SNAP2" ,
salaryPeriodId : perviousYearAPR.id ,
} ,
2024-03-29 17:35:28 +07:00
} ,
2024-04-10 11:44:38 +07:00
order : {
orgShortName : "ASC" ,
posMasterNo : "ASC" ,
2024-03-29 17:35:28 +07:00
} ,
2024-04-10 11:44:38 +07:00
} ) ;
}
2024-04-25 00:53:57 +07:00
if ( perviousYearOCT ) {
2024-04-10 11:44:38 +07:00
salaryProfilePerviousOCT = await this . salaryProfileEmployeeRepository . find ( {
relations : [ "salaryOrg" , "salaryOrg.salaryPeriod" ] ,
where : {
salaryOrg : {
snapshot : "SNAP2" ,
salaryPeriodId : perviousYearOCT.id ,
} ,
} ,
order : {
orgShortName : "ASC" ,
posMasterNo : "ASC" ,
} ,
} ) ;
}
2024-04-05 14:22:26 +07:00
2024-03-29 17:35:28 +07:00
//ปีปัจุบัน
const salaryProfileCurrentAPR = await this . salaryProfileEmployeeRepository . find ( {
2024-03-21 15:29:39 +07:00
relations : [ "salaryOrg" , "salaryOrg.salaryPeriod" ] ,
where : {
2024-04-05 14:22:26 +07:00
salaryOrg : {
2024-03-29 17:35:28 +07:00
snapshot : "SNAP2" ,
2024-03-21 15:29:39 +07:00
salaryPeriodId : salaryPeriodId ,
} ,
} ,
order : {
orgShortName : "ASC" ,
posMasterNo : "ASC" ,
} ,
} ) ;
2024-03-29 17:35:28 +07:00
if ( ! salaryProfileCurrentAPR ) {
2024-03-21 15:29:39 +07:00
throw new HttpError ( HttpStatusCode . NOT_FOUND , "ไม่พบข้อมูล" ) ;
}
2024-03-29 17:35:28 +07:00
const salaryProfileCurrentOCT = await this . salaryProfileEmployeeRepository . find ( {
2024-04-05 14:22:26 +07:00
relations : [ "salaryOrg" , "salaryOrg.salaryPeriod" ] ,
where : {
salaryOrg : {
snapshot : "SNAP2" ,
salaryPeriodId : salaryPeriodId ,
2024-03-29 17:35:28 +07:00
} ,
2024-04-05 14:22:26 +07:00
} ,
order : {
2025-05-19 11:39:09 +07:00
rootOrder : "ASC" ,
child1Order : "ASC" ,
child2Order : "ASC" ,
child3Order : "ASC" ,
child4Order : "ASC" ,
2024-04-05 14:22:26 +07:00
orgShortName : "ASC" ,
posMasterNo : "ASC" ,
} ,
} ) ;
2024-03-29 17:35:28 +07:00
if ( ! salaryProfileCurrentOCT ) {
throw new HttpError ( HttpStatusCode . NOT_FOUND , "ไม่พบข้อมูล" ) ;
}
const agency = salaryProfileCurrentOCT [ 0 ] == null ? "" : salaryProfileCurrentOCT [ 0 ] . root ;
2024-04-05 14:22:26 +07:00
2024-03-29 17:35:28 +07:00
const formattedData = salaryProfileCurrentOCT . map ( ( profile , index ) = > {
//งวดปีก่อนหน้า
2024-04-10 11:16:19 +07:00
let matchedAPRProfileOld : SalaryProfile | null = null ;
let matchedOCTProfileOld : SalaryProfile | null = null ;
if ( salaryProfilePerviousAPR && salaryProfilePerviousAPR . length > 0 ) {
matchedAPRProfileOld = salaryProfilePerviousAPR . find (
( aprProfile_old : SalaryProfile ) = > aprProfile_old . citizenId === profile . citizenId ,
) ;
}
2024-04-25 00:53:57 +07:00
2024-04-10 11:16:19 +07:00
if ( salaryProfilePerviousOCT && salaryProfilePerviousOCT . length > 0 ) {
matchedOCTProfileOld = salaryProfilePerviousOCT . find (
( octProfile_old : SalaryProfile ) = > octProfile_old . citizenId === profile . citizenId ,
) ;
}
2024-03-29 17:35:28 +07:00
const amountUseAPR_Old = matchedAPRProfileOld ? matchedAPRProfileOld.amountUse : 0 ;
const amountUseOCT_Old = matchedOCTProfileOld ? matchedOCTProfileOld.amountUse : 0 ;
const amountUseOld = amountUseAPR_Old + amountUseOCT_Old ;
2024-04-05 14:22:26 +07:00
2024-03-29 17:35:28 +07:00
//งวดปีปัจจุบัน
2024-04-05 14:22:26 +07:00
const matchedAPRProfile = salaryProfileCurrentAPR . find (
( aprProfile ) = > aprProfile . citizenId === profile . citizenId ,
) ;
const matchedOCTProfile = salaryProfileCurrentOCT . find (
( octProfile ) = > octProfile . citizenId === profile . citizenId ,
) ;
2024-03-29 17:35:28 +07:00
const amountUseAPR = matchedAPRProfile ? matchedAPRProfile.amountUse : 0 ;
const amountUseOCT = matchedOCTProfile ? matchedOCTProfile.amountUse : 0 ;
const amountUse = amountUseAPR + amountUseOCT ;
2024-03-21 15:29:39 +07:00
const fullNameParts = [
profile . child4 ,
profile . child3 ,
profile . child2 ,
profile . child1 ,
profile . root ,
] ;
2024-07-12 10:22:36 +07:00
const affiliation = fullNameParts
2024-03-21 15:29:39 +07:00
. filter ( ( part ) = > part !== undefined && part !== null )
2025-04-04 13:45:33 +07:00
. join ( "\n" ) ;
2024-07-12 10:22:36 +07:00
const fullName = ` ${ profile . prefix } ${ profile . firstName } ${ profile . lastName } ` ;
2024-03-21 15:29:39 +07:00
return {
no : Extension.ToThaiNumber ( ( index + 1 ) . toLocaleString ( ) ) ,
#1002,#1004,#1006,#1008,#1013,#1015,#1024,#1028,#1036,#1038,#1044,#1047,#1050
2025-01-27 17:14:13 +07:00
fullName : fullName ? ? "-" ,
affiliation : affiliation ? ? "-" ,
position : profile.position ? ? "-" ,
2024-04-25 00:53:57 +07:00
posLevel : profile.posLevel
2025-01-29 15:21:47 +07:00
? ` ${ profile . posTypeShort } ${ Extension . ToThaiNumber ( profile . posLevel . toLocaleString ( ) ) } `
2025-01-23 16:29:20 +07:00
: "-" ,
2024-03-21 15:29:39 +07:00
posNumber :
2024-04-09 09:25:55 +07:00
Extension . ToThaiNumber ( profile . orgShortName ) +
2025-04-05 18:12:02 +07:00
" " +
2024-04-09 09:25:55 +07:00
Extension . ToThaiNumber ( profile . posMasterNo . toLocaleString ( ) ) ,
2025-01-23 16:29:20 +07:00
amount : profile.amount ? Extension . ToThaiNumber ( profile . amount . toLocaleString ( ) ) : "-" ,
2024-04-05 14:22:26 +07:00
positionSalaryAmount : profile.positionSalaryAmount
? Extension . ToThaiNumber ( profile . positionSalaryAmount . toLocaleString ( ) )
2025-01-23 16:29:20 +07:00
: "-" ,
amountUseOld : amountUseOld ? Extension . ToThaiNumber ( amountUseOld . toLocaleString ( ) ) : "-" ,
amountUse : amountUse ? Extension . ToThaiNumber ( amountUse . toLocaleString ( ) ) : "-" ,
2024-03-21 15:29:39 +07:00
reason : null ,
} ;
} ) ;
2024-04-05 14:22:26 +07:00
2024-03-21 15:29:39 +07:00
return new HttpSuccess ( {
2024-03-29 17:35:28 +07:00
template : "emp2-25" ,
reportName : "emp2-25" ,
2024-03-21 15:29:39 +07:00
data : {
2024-03-29 17:35:28 +07:00
year : Extension.ToThaiNumber ( String ( Extension . ToThaiYear ( salaryPeriodOCT . year ) ) ) ,
2024-03-21 15:29:39 +07:00
agency : agency ,
data : formattedData ,
} ,
2024-04-05 14:22:26 +07:00
} ) ;
2024-03-21 15:29:39 +07:00
}
2024-04-25 00:53:57 +07:00
2025-02-21 19:00:24 +07:00
// /**
// * API ออกคำสั่ง 33
// *
// * @summary ออกคำสั่ง 33
// *
// * @param {string} id Guid, *Id ผังเงินเดือน
// */
// @Post("command/33/resume")
// async SalaryReport33Resume(
// @Body()
// body: {
// result: {
// id: string;
// refCommandNo: string;
// templateDoc: string;
// mpCee?: string | null;
// refCommandCode?: string | null;
// refCommandName?: string | null;
// }[];
// },
// @Request() request: RequestWithUser,
// ) {
// await Promise.all(
// body.result.map(async (v) => {
// const salary = await this.salaryProfileRepository.findOne({
// where: {
// id: v.id,
// },
// });
// if (salary != null) {
// await new CallAPI()
// .PostData(request, "/org/profile/salary", {
// profileId: salary.profileId,
// date: new Date(),
// amount: salary.positionSalaryAmount,
// positionSalaryAmount: salary.amountSpecial,
// mouthSalaryAmount: null,
// posNo: salary.orgShortName + salary.posMasterNo,
// position: salary.position,
// positionLine: null,
// positionPathSide: null,
// positionExecutive: salary.posExecutive,
// positionType: salary.posType,
// positionLevel: salary.posLevel,
// refCommandNo: v.refCommandNo,
// templateDoc: v.templateDoc,
// refCommandCode: v.refCommandCode,
// refCommandName: v.refCommandName,
// })
// .then(async () => {
// const before = null;
// salary.status = "DONE";
// salary.lastUpdateUserId = request.user.sub;
// salary.lastUpdateFullName = request.user.name;
// salary.lastUpdatedAt = new Date();
// await this.salaryProfileRepository.save(salary, { data: request });
// setLogDataDiff(request, { before, after: salary });
// });
// }
// }),
// );
// return new HttpSuccess();
// }
2024-04-26 10:03:29 +07:00
2025-02-21 19:00:24 +07:00
// /**
// * API ออกคำสั่ง 34
// *
// * @summary ออกคำสั่ง 34
// *
// * @param {string} id Guid, *Id ผังเงินเดือน
// */
// @Post("command/34/resume")
// async SalaryReport34Resume(
// @Body()
// body: {
// result: {
// id: string;
// refCommandNo: string;
// templateDoc: string;
// mpCee?: string | null;
// refCommandCode?: string | null;
// refCommandName?: string | null;
// }[];
// },
// @Request() request: RequestWithUser,
// ) {
// await Promise.all(
// body.result.map(async (v) => {
// const salary = await this.salaryProfileRepository.findOne({
// where: {
// id: v.id,
// },
// });
// if (salary != null) {
// await new CallAPI()
// .PostData(request, "/org/profile/salary", {
// profileId: salary.profileId,
// date: new Date(),
// amount: salary.positionSalaryAmount,
// positionSalaryAmount: salary.amountSpecial,
// mouthSalaryAmount: null,
// posNo: salary.orgShortName + salary.posMasterNo,
// position: salary.position,
// positionLine: null,
// positionPathSide: null,
// positionExecutive: salary.posExecutive,
// positionType: salary.posType,
// positionLevel: salary.posLevel,
// refCommandNo: v.refCommandNo,
// templateDoc: v.templateDoc,
// refCommandCode: v.refCommandCode,
// refCommandName: v.refCommandName,
// })
// .then(async () => {
// const before = null;
// salary.status = "DONE";
// salary.lastUpdateUserId = request.user.sub;
// salary.lastUpdateFullName = request.user.name;
// salary.lastUpdatedAt = new Date();
// await this.salaryProfileRepository.save(salary, { data: request });
// setLogDataDiff(request, { before, after: salary });
// });
// }
// }),
// );
// return new HttpSuccess();
// }
2024-04-26 10:03:29 +07:00
2025-02-21 19:00:24 +07:00
// /**
// * API ออกคำสั่ง 35
// *
// * @summary ออกคำสั่ง 35
// *
// * @param {string} id Guid, *Id ผังเงินเดือน
// */
// @Post("command/35/resume")
// async SalaryReport35Resume(
// @Body()
// body: {
// result: {
// id: string;
// refCommandNo: string;
// templateDoc: string;
// mpCee?: string | null;
// refCommandCode?: string | null;
// refCommandName?: string | null;
// }[];
// },
// @Request() request: RequestWithUser,
// ) {
// await Promise.all(
// body.result.map(async (v) => {
// const salary = await this.salaryProfileRepository.findOne({
// where: {
// id: v.id,
// },
// });
// if (salary != null) {
// await new CallAPI()
// .PostData(request, "/org/profile/salary", {
// profileId: salary.profileId,
// date: new Date(),
// amount: salary.positionSalaryAmount,
// positionSalaryAmount: salary.amountSpecial,
// mouthSalaryAmount: null,
// posNo: salary.orgShortName + salary.posMasterNo,
// position: salary.position,
// positionLine: null,
// positionPathSide: null,
// positionExecutive: salary.posExecutive,
// positionType: salary.posType,
// positionLevel: salary.posLevel,
// refCommandNo: v.refCommandNo,
// templateDoc: v.templateDoc,
// refCommandCode: v.refCommandCode,
// refCommandName: v.refCommandName,
// })
// .then(async () => {
// const before = null;
// salary.status = "DONE";
// salary.lastUpdateUserId = request.user.sub;
// salary.lastUpdateFullName = request.user.name;
// salary.lastUpdatedAt = new Date();
// await this.salaryProfileRepository.save(salary, { data: request });
// setLogDataDiff(request, { before, after: salary });
// });
// }
// }),
// );
// return new HttpSuccess();
// }
2024-04-26 10:03:29 +07:00
2025-02-21 19:00:24 +07:00
// /**
// * API ออกคำสั่ง 36
// *
// * @summary ออกคำสั่ง 36
// *
// * @param {string} id Guid, *Id ผังเงินเดือน
// */
// @Post("command/36/resume")
// async SalaryReport36Resume(
// @Body()
// body: {
// result: {
// id: string;
// refCommandNo: string;
// templateDoc: string;
// mpCee?: string | null;
// refCommandCode?: string | null;
// refCommandName?: string | null;
// }[];
// },
// @Request() request: RequestWithUser,
// ) {
// await Promise.all(
// body.result.map(async (v) => {
// const salary = await this.salaryProfileEmployeeRepository.findOne({
// where: {
// id: v.id,
// },
// });
// if (salary != null) {
// await new CallAPI()
// .PostData(request, "/org/profile-employee/salary", {
// profileEmployeeId: salary.profileId,
// date: new Date(),
// amount: salary.positionSalaryAmount,
// positionSalaryAmount: salary.amountSpecial,
// mouthSalaryAmount: null,
// posNo: salary.orgShortName + salary.posMasterNo,
// position: salary.position,
// // positionLine: null,
// // positionPathSide: null,
// // positionExecutive: null,
// positionType: salary.posType,
// positionLevel: salary.posLevel ? String(salary.posLevel) : null,
// refCommandNo: v.refCommandNo,
// templateDoc: v.templateDoc,
// refCommandCode: v.refCommandCode,
// refCommandName: v.refCommandName,
// })
// .then(async () => {
// const before = null;
// salary.status = "DONE";
// salary.lastUpdateUserId = request.user.sub;
// salary.lastUpdateFullName = request.user.name;
// salary.lastUpdatedAt = new Date();
// await this.salaryProfileEmployeeRepository.save(salary, { data: request });
// setLogDataDiff(request, { before, after: salary });
// });
// }
// }),
// );
// return new HttpSuccess();
// }
2024-04-26 10:03:29 +07:00
2025-02-21 19:00:24 +07:00
// /**
// * API ออกคำสั่ง 37
// *
// * @summary ออกคำสั่ง 37
// *
// * @param {string} id Guid, *Id ผังเงินเดือน
// */
// @Post("command/37/resume")
// async SalaryReport37Resume(
// @Body()
// body: {
// result: {
// id: string;
// refCommandNo: string;
// templateDoc: string;
// mpCee?: string | null;
// refCommandCode?: string | null;
// refCommandName?: string | null;
// }[];
// },
// @Request() request: RequestWithUser,
// ) {
// await Promise.all(
// body.result.map(async (v) => {
// const salary = await this.salaryProfileEmployeeRepository.findOne({
// where: {
// id: v.id,
// },
// });
// if (salary != null) {
// await new CallAPI()
// .PostData(request, "/org/profile-employee/salary", {
// profileEmployeeId: salary.profileId,
// date: new Date(),
// amount: salary.positionSalaryAmount,
// positionSalaryAmount: salary.amountSpecial,
// mouthSalaryAmount: null,
// posNo: salary.orgShortName + salary.posMasterNo,
// position: salary.position,
// positionLine: null,
// positionPathSide: null,
// positionExecutive: null,
// positionType: salary.posType,
// positionLevel: salary.posLevel,
// refCommandNo: v.refCommandNo,
// templateDoc: v.templateDoc,
// refCommandCode: v.refCommandCode,
// refCommandName: v.refCommandName,
// })
// .then(async () => {
// const before = null;
// salary.status = "DONE";
// salary.lastUpdateUserId = request.user.sub;
// salary.lastUpdateFullName = request.user.name;
// salary.lastUpdatedAt = new Date();
// await this.salaryProfileEmployeeRepository.save(salary, { data: request });
// setLogDataDiff(request, { before, after: salary });
// });
// }
// }),
// );
// return new HttpSuccess();
// }
2024-04-26 10:03:29 +07:00
2024-04-25 00:53:57 +07:00
/ * *
* API อ อ ก ค ำ ส ั ่ ง 33
*
* @summary อ อ ก ค ำ ส ั ่ ง 33
*
* @param { string } id Guid , * Id ผ ั ง เ ง ิ น เ ด ื อ น
* /
@Get ( "command/33/{id}" )
async SalaryReport33 ( @Path ( ) id : string ) {
const salary = await this . salaryPeriodRepository . findOne ( {
where : { id : id } ,
} ) ;
if ( ! salary ) {
throw new HttpError ( HttpStatusCode . NOT_FOUND , "ไม่พบข้อมูลการขึ้นเงินเดือน" ) ;
}
const salaryOrgs = await this . salaryOrgRepository . find ( {
2024-04-26 10:03:29 +07:00
where : { salaryPeriodId : salary.id , snapshot : "SNAP2" } ,
2024-04-25 00:53:57 +07:00
} ) ;
const salaryRank = await this . salaryProfileRepository . find ( {
where : {
salaryOrgId : In ( salaryOrgs . map ( ( x ) = > x . id ) ) ,
2024-04-25 14:38:42 +07:00
type : In ( [ "FULLHAFT" , "FULL" , "HAFT" ] ) ,
2024-04-26 10:03:29 +07:00
status : "PENDING" ,
2024-04-25 00:53:57 +07:00
} ,
} ) ;
const _salaryRank = salaryRank . map ( ( item ) = > ( {
id : item.id ,
2025-04-05 18:12:02 +07:00
posMasterNo : ` ${ item . orgShortName } ${ item . posMasterNo } ` ,
2024-10-24 09:30:45 +07:00
positionName : item.position ,
posType : item.posType ,
posLevel : item.posLevel ,
profileId : item.profileId ,
2024-04-25 00:53:57 +07:00
prefix : item.prefix ,
firstName : item.firstName ,
lastName : item.lastName ,
2024-10-24 09:30:45 +07:00
citizenId : item.citizenId ,
2024-04-25 00:53:57 +07:00
} ) ) ;
return new HttpSuccess ( _salaryRank ) ;
}
/ * *
* API อ อ ก ค ำ ส ั ่ ง 34
*
* @summary อ อ ก ค ำ ส ั ่ ง 34
*
* @param { string } id Guid , * Id ผ ั ง เ ง ิ น เ ด ื อ น
* /
@Get ( "command/34/{id}" )
async SalaryReport34 ( @Path ( ) id : string ) {
const salary = await this . salaryPeriodRepository . findOne ( {
where : { id : id } ,
} ) ;
if ( ! salary ) {
throw new HttpError ( HttpStatusCode . NOT_FOUND , "ไม่พบข้อมูลการขึ้นเงินเดือน" ) ;
}
const salaryOrgs = await this . salaryOrgRepository . find ( {
2024-04-26 10:03:29 +07:00
where : { salaryPeriodId : salary.id , snapshot : "SNAP2" } ,
2024-04-25 00:53:57 +07:00
} ) ;
const salaryRank = await this . salaryProfileRepository . find ( {
2024-04-25 14:38:42 +07:00
where : [
{
salaryOrgId : In ( salaryOrgs . map ( ( x ) = > x . id ) ) ,
amountSpecial : MoreThan ( 0 ) ,
2024-04-26 10:03:29 +07:00
status : "PENDING" ,
2024-04-25 14:38:42 +07:00
} ,
{
salaryOrgId : In ( salaryOrgs . map ( ( x ) = > x . id ) ) ,
type : "NONE" ,
2024-04-26 10:03:29 +07:00
status : "PENDING" ,
2024-04-25 14:38:42 +07:00
} ,
] ,
2024-04-25 00:53:57 +07:00
} ) ;
const _salaryRank = salaryRank . map ( ( item ) = > ( {
id : item.id ,
2025-04-05 18:12:02 +07:00
posMasterNo : ` ${ item . orgShortName } ${ item . posMasterNo } ` ,
2024-10-24 09:30:45 +07:00
positionName : item.position ,
posType : item.posType ,
posLevel : item.posLevel ,
profileId : item.profileId ,
2024-04-25 00:53:57 +07:00
prefix : item.prefix ,
firstName : item.firstName ,
lastName : item.lastName ,
2024-10-24 09:30:45 +07:00
citizenId : item.citizenId ,
2024-04-25 00:53:57 +07:00
} ) ) ;
return new HttpSuccess ( _salaryRank ) ;
}
/ * *
* API อ อ ก ค ำ ส ั ่ ง 35
*
* @summary อ อ ก ค ำ ส ั ่ ง 35
*
* @param { string } id Guid , * Id ผ ั ง เ ง ิ น เ ด ื อ น
* /
@Get ( "command/35/{id}" )
async SalaryReport35 ( @Path ( ) id : string ) {
const salary = await this . salaryPeriodRepository . findOne ( {
where : { id : id } ,
} ) ;
if ( ! salary ) {
throw new HttpError ( HttpStatusCode . NOT_FOUND , "ไม่พบข้อมูลการขึ้นเงินเดือน" ) ;
}
const salaryOrgs = await this . salaryOrgRepository . find ( {
2024-04-26 10:03:29 +07:00
where : { salaryPeriodId : salary.id , snapshot : "SNAP2" } ,
2024-04-25 00:53:57 +07:00
} ) ;
const salaryRank = await this . salaryProfileRepository . find ( {
where : {
salaryOrgId : In ( salaryOrgs . map ( ( x ) = > x . id ) ) ,
2024-04-25 14:38:42 +07:00
type : In ( [ "FULLHAFT" , "FULL" , "HAFT" ] ) ,
2024-04-26 10:03:29 +07:00
status : "PENDING" ,
2024-04-25 14:38:42 +07:00
isRetired : true ,
2024-04-25 00:53:57 +07:00
} ,
} ) ;
const _salaryRank = salaryRank . map ( ( item ) = > ( {
id : item.id ,
2025-04-05 18:12:02 +07:00
posMasterNo : ` ${ item . orgShortName } ${ item . posMasterNo } ` ,
2024-10-24 09:30:45 +07:00
positionName : item.position ,
posType : item.posType ,
posLevel : item.posLevel ,
profileId : item.profileId ,
2024-04-25 00:53:57 +07:00
prefix : item.prefix ,
firstName : item.firstName ,
lastName : item.lastName ,
2024-10-24 09:30:45 +07:00
citizenId : item.citizenId ,
2024-04-25 00:53:57 +07:00
} ) ) ;
return new HttpSuccess ( _salaryRank ) ;
}
/ * *
* API อ อ ก ค ำ ส ั ่ ง 36
*
* @summary อ อ ก ค ำ ส ั ่ ง 36
*
* @param { string } id Guid , * Id ผ ั ง เ ง ิ น เ ด ื อ น
* /
@Get ( "command/36/{id}" )
async SalaryReport36 ( @Path ( ) id : string ) {
const salary = await this . salaryPeriodRepository . findOne ( {
where : { id : id } ,
} ) ;
if ( ! salary ) {
throw new HttpError ( HttpStatusCode . NOT_FOUND , "ไม่พบข้อมูลการขึ้นเงินเดือน" ) ;
}
2024-04-25 14:38:42 +07:00
const salaryOrgs = await this . salaryOrgEmployeeRepository . find ( {
2024-04-26 10:03:29 +07:00
where : { salaryPeriodId : salary.id , snapshot : "SNAP2" } ,
2024-04-25 00:53:57 +07:00
} ) ;
2024-04-25 14:38:42 +07:00
const salaryRank = await this . salaryProfileEmployeeRepository . find ( {
2024-04-25 00:53:57 +07:00
where : {
salaryOrgId : In ( salaryOrgs . map ( ( x ) = > x . id ) ) ,
2024-04-25 14:38:42 +07:00
type : In ( [ "FULLHAFT" , "FULL" , "HAFT" ] ) ,
2024-04-26 10:03:29 +07:00
status : "PENDING" ,
2024-04-25 00:53:57 +07:00
} ,
} ) ;
const _salaryRank = salaryRank . map ( ( item ) = > ( {
id : item.id ,
2025-04-05 18:12:02 +07:00
posMasterNo : ` ${ item . orgShortName } ${ item . posMasterNo } ` ,
2024-10-24 09:30:45 +07:00
positionName : item.position ,
posType : item.posType ,
posLevel : ` ${ item . posTypeShort } ${ item . posLevel } ` ,
profileId : item.profileId ,
2024-04-25 00:53:57 +07:00
prefix : item.prefix ,
firstName : item.firstName ,
lastName : item.lastName ,
2024-10-24 09:30:45 +07:00
citizenId : item.citizenId ,
2024-04-25 00:53:57 +07:00
} ) ) ;
return new HttpSuccess ( _salaryRank ) ;
}
/ * *
* API อ อ ก ค ำ ส ั ่ ง 37
*
* @summary อ อ ก ค ำ ส ั ่ ง 37
*
* @param { string } id Guid , * Id ผ ั ง เ ง ิ น เ ด ื อ น
* /
@Get ( "command/37/{id}" )
async SalaryReport37 ( @Path ( ) id : string ) {
const salary = await this . salaryPeriodRepository . findOne ( {
where : { id : id } ,
} ) ;
if ( ! salary ) {
throw new HttpError ( HttpStatusCode . NOT_FOUND , "ไม่พบข้อมูลการขึ้นเงินเดือน" ) ;
}
2024-04-25 14:38:42 +07:00
const salaryOrgs = await this . salaryOrgEmployeeRepository . find ( {
2024-04-26 10:03:29 +07:00
where : { salaryPeriodId : salary.id , snapshot : "SNAP2" } ,
2024-04-25 00:53:57 +07:00
} ) ;
2024-04-25 14:38:42 +07:00
const salaryRank = await this . salaryProfileEmployeeRepository . find ( {
2024-04-25 00:53:57 +07:00
where : {
salaryOrgId : In ( salaryOrgs . map ( ( x ) = > x . id ) ) ,
2024-04-25 14:38:42 +07:00
amountSpecial : MoreThan ( 0 ) ,
2024-04-26 10:03:29 +07:00
status : "PENDING" ,
2024-04-25 00:53:57 +07:00
} ,
} ) ;
const _salaryRank = salaryRank . map ( ( item ) = > ( {
id : item.id ,
2025-04-05 18:12:02 +07:00
posMasterNo : ` ${ item . orgShortName } ${ item . posMasterNo } ` ,
2024-10-24 09:30:45 +07:00
positionName : item.position ,
posType : item.posType ,
posLevel : ` ${ item . posTypeShort } ${ item . posLevel } ` ,
profileId : item.profileId ,
2024-10-24 10:48:41 +07:00
prefix : item.prefix ,
firstName : item.firstName ,
lastName : item.lastName ,
citizenId : item.citizenId ,
} ) ) ;
return new HttpSuccess ( _salaryRank ) ;
}
/ * *
2025-03-19 12:03:25 +07:00
* API อ อ ก ค ำ ส ั ่ ง C - PM - 33
2024-10-24 10:48:41 +07:00
*
2025-03-19 12:03:25 +07:00
* @summary อ อ ก ค ำ ส ั ่ ง C - PM - 33
2024-10-24 10:48:41 +07:00
*
* @param { string } id Guid , * Id ผ ั ง เ ง ิ น เ ด ื อ น
* /
2024-10-24 10:55:58 +07:00
@Post ( "command/C-PM-33/{id}" )
2024-10-24 10:48:41 +07:00
async SalaryReport33Command (
@Path ( ) id : string ,
@Body ( )
body : {
type : string ;
rootId : string ;
} ,
) {
let conditionGroup = "" ;
if ( body . type . trim ( ) . toUpperCase ( ) == "GROUP1.1" ) {
conditionGroup =
2025-04-28 18:25:12 +07:00
"(salaryProfile.posType = 'ทั่วไป' AND salaryProfile.posLevel = 'ชำนาญงาน') OR (salaryProfile.posType = 'ทั่วไป' AND salaryProfile.posLevel = 'ปฏิบัติงาน') OR (salaryProfile.posType = 'วิชาการ' AND salaryProfile.posLevel = 'ปฏิบัติการ') OR (salaryProfile.posType = 'วิชาการ' AND salaryProfile.posLevel = 'ชำนาญการ')" ;
2024-10-24 10:48:41 +07:00
} else if ( body . type . trim ( ) . toUpperCase ( ) == "GROUP1.2" ) {
conditionGroup =
"(salaryProfile.posType = 'ทั่วไป' AND salaryProfile.posLevel = 'อาวุโส') OR (salaryProfile.posType = 'วิชาการ' AND salaryProfile.posLevel = 'ชำนาญการพิเศษ') OR (salaryProfile.posType = 'อำนวยการ' AND salaryProfile.posLevel = 'ต้น')" ;
} else if ( body . type . trim ( ) . toUpperCase ( ) == "GROUP2" ) {
conditionGroup =
"(salaryProfile.posType = 'ทั่วไป' AND salaryProfile.posLevel = 'ทักษะพิเศษ') OR (salaryProfile.posType = 'วิชาการ' AND salaryProfile.posLevel = 'เชี่ยวชาญ') OR (salaryProfile.posType = 'วิชาการ' AND salaryProfile.posLevel = 'ทรงคุณวุฒิ') OR (salaryProfile.posType = 'อำนวยการ' AND salaryProfile.posLevel = 'สูง') OR (salaryProfile.posType = 'บริหาร' AND salaryProfile.posLevel = 'ต้น') OR (salaryProfile.posType = 'บริหาร' AND salaryProfile.posLevel = 'สูง')" ;
} else {
throw new HttpError ( HttpStatusCode . NOT_FOUND , "กลุ่มเป้าหมายไม่ถูกต้อง" ) ;
}
const salary = await this . salaryPeriodRepository . findOne ( {
where : { id : id } ,
} ) ;
if ( ! salary ) {
throw new HttpError ( HttpStatusCode . NOT_FOUND , "ไม่พบข้อมูลการขึ้นเงินเดือน" ) ;
}
const salaryOrgs = await this . salaryOrgRepository . find ( {
where : { salaryPeriodId : salary.id , snapshot : "SNAP2" } ,
} ) ;
let salaryRank = await AppDataSource . getRepository ( SalaryProfile )
. createQueryBuilder ( "salaryProfile" )
. andWhere ( "salaryProfile.rootId LIKE :rootId" , {
rootId : body.type.trim ( ) . toUpperCase ( ) == "GROUP1.1" ? body . rootId : ` %% ` ,
} )
. andWhere ( {
salaryOrgId : In ( salaryOrgs . map ( ( x ) = > x . id ) ) ,
type : In ( [ "FULLHAFT" , "FULL" , "HAFT" ] ) ,
2025-03-19 12:03:25 +07:00
// status: "PENDING",
2024-10-24 10:48:41 +07:00
} )
. andWhere (
new Brackets ( ( qb ) = > {
qb . andWhere ( conditionGroup ) ;
} ) ,
)
2025-03-19 12:03:25 +07:00
. andWhere ( "salaryProfile.status33 = :status" , { status : "PENDING" } )
2024-10-24 10:48:41 +07:00
. select ( [
"salaryProfile.id" ,
"salaryProfile.orgShortName" ,
"salaryProfile.posMasterNo" ,
"salaryProfile.position" ,
"salaryProfile.posType" ,
"salaryProfile.posLevel" ,
"salaryProfile.profileId" ,
"salaryProfile.prefix" ,
"salaryProfile.firstName" ,
"salaryProfile.lastName" ,
"salaryProfile.citizenId" ,
2024-12-06 16:03:45 +07:00
"salaryProfile.amount" ,
"salaryProfile.amountSpecial" ,
"salaryProfile.amountUse" ,
"salaryProfile.positionSalaryAmount" ,
2024-10-24 10:48:41 +07:00
] )
2025-04-05 18:12:02 +07:00
. orderBy ( "salaryProfile.rootOrder" , "ASC" )
. addOrderBy ( "salaryProfile.child1Order" , "ASC" )
. addOrderBy ( "salaryProfile.child2Order" , "ASC" )
. addOrderBy ( "salaryProfile.child3Order" , "ASC" )
. addOrderBy ( "salaryProfile.child4Order" , "ASC" )
. addOrderBy ( "salaryProfile.posMasterNo" , "ASC" )
2024-10-24 10:48:41 +07:00
. getMany ( ) ;
2025-05-01 16:31:25 +07:00
2024-10-24 10:48:41 +07:00
const _salaryRank = salaryRank . map ( ( item ) = > ( {
id : item.id ,
2025-04-05 18:12:02 +07:00
posMasterNo : ` ${ item . orgShortName } ${ item . posMasterNo } ` ,
2024-10-24 10:48:41 +07:00
positionName : item.position ,
posType : item.posType ,
posLevel : item.posLevel ,
profileId : item.profileId ,
prefix : item.prefix ,
firstName : item.firstName ,
lastName : item.lastName ,
citizenId : item.citizenId ,
2024-12-06 16:03:45 +07:00
amount : item.amount ,
amountSpecial : item.amountSpecial ,
amountUse : item.amountUse ,
positionSalaryAmount : item.positionSalaryAmount ,
2024-10-24 10:48:41 +07:00
} ) ) ;
return new HttpSuccess ( _salaryRank ) ;
}
/ * *
2025-03-19 12:03:25 +07:00
* API ร า ย ช ื ่ อ อ อ ก ค ำ ส ั ่ ง C - PM - 34
2024-10-24 10:48:41 +07:00
*
2025-03-19 12:03:25 +07:00
* @summary อ อ ก ค ำ ส ั ่ ง C - PM - 34
2024-10-24 10:48:41 +07:00
*
* @param { string } id Guid , * Id ผ ั ง เ ง ิ น เ ด ื อ น
* /
2024-10-24 10:55:58 +07:00
@Post ( "command/C-PM-34/{id}" )
2024-10-24 10:48:41 +07:00
async SalaryReport34Command (
@Path ( ) id : string ,
@Body ( )
body : {
type : string ;
rootId : string ;
} ,
) {
let conditionGroup = "" ;
if ( body . type . trim ( ) . toUpperCase ( ) == "GROUP1.1" ) {
conditionGroup =
"(salaryProfile.posType = 'ทั่วไป' AND salaryProfile.posLevel = 'ชำนาญงาน') OR (salaryProfile.posType = 'ทั่วไป' AND salaryProfile.posLevel = 'ปฏิบัติงาน') OR (salaryProfile.posType = 'วิชาการ' AND salaryProfile.posLevel = 'ปฏิบัติการ') OR (salaryProfile.posType = 'วิชาการ' AND salaryProfile.posLevel = 'ชำนาญการ')" ;
} else if ( body . type . trim ( ) . toUpperCase ( ) == "GROUP1.2" ) {
conditionGroup =
"(salaryProfile.posType = 'ทั่วไป' AND salaryProfile.posLevel = 'อาวุโส') OR (salaryProfile.posType = 'วิชาการ' AND salaryProfile.posLevel = 'ชำนาญการพิเศษ') OR (salaryProfile.posType = 'อำนวยการ' AND salaryProfile.posLevel = 'ต้น')" ;
} else if ( body . type . trim ( ) . toUpperCase ( ) == "GROUP2" ) {
conditionGroup =
"(salaryProfile.posType = 'ทั่วไป' AND salaryProfile.posLevel = 'ทักษะพิเศษ') OR (salaryProfile.posType = 'วิชาการ' AND salaryProfile.posLevel = 'เชี่ยวชาญ') OR (salaryProfile.posType = 'วิชาการ' AND salaryProfile.posLevel = 'ทรงคุณวุฒิ') OR (salaryProfile.posType = 'อำนวยการ' AND salaryProfile.posLevel = 'สูง') OR (salaryProfile.posType = 'บริหาร' AND salaryProfile.posLevel = 'ต้น') OR (salaryProfile.posType = 'บริหาร' AND salaryProfile.posLevel = 'สูง')" ;
} else {
throw new HttpError ( HttpStatusCode . NOT_FOUND , "กลุ่มเป้าหมายไม่ถูกต้อง" ) ;
}
const salary = await this . salaryPeriodRepository . findOne ( {
where : { id : id } ,
} ) ;
if ( ! salary ) {
throw new HttpError ( HttpStatusCode . NOT_FOUND , "ไม่พบข้อมูลการขึ้นเงินเดือน" ) ;
}
const salaryOrgs = await this . salaryOrgRepository . find ( {
where : { salaryPeriodId : salary.id , snapshot : "SNAP2" } ,
} ) ;
let salaryRank = await AppDataSource . getRepository ( SalaryProfile )
. createQueryBuilder ( "salaryProfile" )
. andWhere ( "salaryProfile.rootId LIKE :rootId" , {
rootId : body.type.trim ( ) . toUpperCase ( ) == "GROUP1.1" ? body . rootId : ` %% ` ,
} )
. andWhere (
new Brackets ( ( qb ) = > {
qb . orWhere ( {
salaryOrgId : In ( salaryOrgs . map ( ( x ) = > x . id ) ) ,
amountSpecial : MoreThan ( 0 ) ,
2024-12-25 18:22:40 +07:00
type : Not ( "NONE" ) ,
2025-03-19 12:03:25 +07:00
// status: "PENDING",
2025-01-10 16:11:34 +07:00
} ) ; / * . o r W h e r e ( {
2024-10-24 10:48:41 +07:00
salaryOrgId : In ( salaryOrgs . map ( ( x ) = > x . id ) ) ,
type : "NONE" ,
status : "PENDING" ,
2024-12-25 18:22:40 +07:00
} ) ; * /
2024-10-24 10:48:41 +07:00
} ) ,
)
. andWhere (
new Brackets ( ( qb ) = > {
qb . andWhere ( conditionGroup ) ;
} ) ,
)
2025-03-19 12:03:25 +07:00
. andWhere ( "salaryProfile.status34 = :status" , { status : "PENDING" } )
2024-10-24 10:48:41 +07:00
. select ( [
"salaryProfile.id" ,
"salaryProfile.orgShortName" ,
"salaryProfile.posMasterNo" ,
"salaryProfile.position" ,
"salaryProfile.posType" ,
"salaryProfile.posLevel" ,
"salaryProfile.profileId" ,
"salaryProfile.prefix" ,
"salaryProfile.firstName" ,
"salaryProfile.lastName" ,
"salaryProfile.citizenId" ,
2024-12-06 16:03:45 +07:00
"salaryProfile.amount" ,
"salaryProfile.amountSpecial" ,
"salaryProfile.amountUse" ,
"salaryProfile.positionSalaryAmount" ,
2024-10-24 10:48:41 +07:00
] )
2025-04-05 18:12:02 +07:00
. orderBy ( "salaryProfile.rootOrder" , "ASC" )
. addOrderBy ( "salaryProfile.child1Order" , "ASC" )
. addOrderBy ( "salaryProfile.child2Order" , "ASC" )
. addOrderBy ( "salaryProfile.child3Order" , "ASC" )
. addOrderBy ( "salaryProfile.child4Order" , "ASC" )
. addOrderBy ( "salaryProfile.posMasterNo" , "ASC" )
2024-10-24 10:48:41 +07:00
. getMany ( ) ;
const _salaryRank = salaryRank . map ( ( item ) = > ( {
id : item.id ,
2025-04-05 18:12:02 +07:00
posMasterNo : ` ${ item . orgShortName } ${ item . posMasterNo } ` ,
2024-10-24 10:48:41 +07:00
positionName : item.position ,
posType : item.posType ,
posLevel : item.posLevel ,
profileId : item.profileId ,
prefix : item.prefix ,
firstName : item.firstName ,
lastName : item.lastName ,
citizenId : item.citizenId ,
2024-12-06 16:03:45 +07:00
amount : item.amount ,
amountSpecial : item.amountSpecial ,
amountUse : item.amountUse ,
positionSalaryAmount : item.positionSalaryAmount ,
2024-10-24 10:48:41 +07:00
} ) ) ;
return new HttpSuccess ( _salaryRank ) ;
}
/ * *
2025-03-19 12:03:25 +07:00
* API อ อ ก ค ำ ส ั ่ ง C - PM - 35
2024-10-24 10:48:41 +07:00
*
2025-03-19 12:03:25 +07:00
* @summary อ อ ก ค ำ ส ั ่ ง C - PM - 35
2024-10-24 10:48:41 +07:00
*
* @param { string } id Guid , * Id ผ ั ง เ ง ิ น เ ด ื อ น
* /
2024-10-24 10:55:58 +07:00
@Post ( "command/C-PM-35/{id}" )
2024-10-24 10:48:41 +07:00
async SalaryReport35Command (
@Path ( ) id : string ,
@Body ( )
body : {
type : string ;
rootId : string ;
} ,
) {
let conditionGroup = "" ;
if ( body . type . trim ( ) . toUpperCase ( ) == "GROUP1.1" ) {
conditionGroup =
"(salaryProfile.posType = 'ทั่วไป' AND salaryProfile.posLevel = 'ชำนาญงาน') OR (salaryProfile.posType = 'ทั่วไป' AND salaryProfile.posLevel = 'ปฏิบัติงาน') OR (salaryProfile.posType = 'วิชาการ' AND salaryProfile.posLevel = 'ปฏิบัติการ') OR (salaryProfile.posType = 'วิชาการ' AND salaryProfile.posLevel = 'ชำนาญการ')" ;
} else if ( body . type . trim ( ) . toUpperCase ( ) == "GROUP1.2" ) {
conditionGroup =
"(salaryProfile.posType = 'ทั่วไป' AND salaryProfile.posLevel = 'อาวุโส') OR (salaryProfile.posType = 'วิชาการ' AND salaryProfile.posLevel = 'ชำนาญการพิเศษ') OR (salaryProfile.posType = 'อำนวยการ' AND salaryProfile.posLevel = 'ต้น')" ;
} else if ( body . type . trim ( ) . toUpperCase ( ) == "GROUP2" ) {
conditionGroup =
"(salaryProfile.posType = 'ทั่วไป' AND salaryProfile.posLevel = 'ทักษะพิเศษ') OR (salaryProfile.posType = 'วิชาการ' AND salaryProfile.posLevel = 'เชี่ยวชาญ') OR (salaryProfile.posType = 'วิชาการ' AND salaryProfile.posLevel = 'ทรงคุณวุฒิ') OR (salaryProfile.posType = 'อำนวยการ' AND salaryProfile.posLevel = 'สูง') OR (salaryProfile.posType = 'บริหาร' AND salaryProfile.posLevel = 'ต้น') OR (salaryProfile.posType = 'บริหาร' AND salaryProfile.posLevel = 'สูง')" ;
} else {
throw new HttpError ( HttpStatusCode . NOT_FOUND , "กลุ่มเป้าหมายไม่ถูกต้อง" ) ;
}
const salary = await this . salaryPeriodRepository . findOne ( {
where : { id : id } ,
} ) ;
if ( ! salary ) {
throw new HttpError ( HttpStatusCode . NOT_FOUND , "ไม่พบข้อมูลการขึ้นเงินเดือน" ) ;
}
const salaryOrgs = await this . salaryOrgRepository . find ( {
where : { salaryPeriodId : salary.id , snapshot : "SNAP2" } ,
} ) ;
let salaryRank = await AppDataSource . getRepository ( SalaryProfile )
. createQueryBuilder ( "salaryProfile" )
. andWhere ( "salaryProfile.rootId LIKE :rootId" , {
rootId : body.type.trim ( ) . toUpperCase ( ) == "GROUP1.1" ? body . rootId : ` %% ` ,
} )
. andWhere ( {
salaryOrgId : In ( salaryOrgs . map ( ( x ) = > x . id ) ) ,
type : In ( [ "FULLHAFT" , "FULL" , "HAFT" ] ) ,
2025-03-19 12:03:25 +07:00
// status: "PENDING",
2024-10-24 10:48:41 +07:00
isRetired : true ,
} )
. andWhere (
new Brackets ( ( qb ) = > {
qb . andWhere ( conditionGroup ) ;
} ) ,
)
2025-03-19 12:03:25 +07:00
. andWhere ( "salaryProfile.status35 = :status" , { status : "PENDING" } )
2025-06-25 15:22:03 +07:00
. andWhere ( "salaryProfile.isRetired = :isRetired" , { isRetired : true } )
2024-10-24 10:48:41 +07:00
. select ( [
"salaryProfile.id" ,
"salaryProfile.orgShortName" ,
"salaryProfile.posMasterNo" ,
"salaryProfile.position" ,
"salaryProfile.posType" ,
"salaryProfile.posLevel" ,
"salaryProfile.profileId" ,
"salaryProfile.prefix" ,
"salaryProfile.firstName" ,
"salaryProfile.lastName" ,
"salaryProfile.citizenId" ,
2024-12-06 16:03:45 +07:00
"salaryProfile.amount" ,
"salaryProfile.amountSpecial" ,
"salaryProfile.amountUse" ,
"salaryProfile.positionSalaryAmount" ,
2024-10-24 10:48:41 +07:00
] )
2025-04-05 18:12:02 +07:00
. orderBy ( "salaryProfile.rootOrder" , "ASC" )
. addOrderBy ( "salaryProfile.child1Order" , "ASC" )
. addOrderBy ( "salaryProfile.child2Order" , "ASC" )
. addOrderBy ( "salaryProfile.child3Order" , "ASC" )
. addOrderBy ( "salaryProfile.child4Order" , "ASC" )
. addOrderBy ( "salaryProfile.posMasterNo" , "ASC" )
2024-10-24 10:48:41 +07:00
. getMany ( ) ;
const _salaryRank = salaryRank . map ( ( item ) = > ( {
id : item.id ,
2025-04-05 18:12:02 +07:00
posMasterNo : ` ${ item . orgShortName } ${ item . posMasterNo } ` ,
2024-10-24 10:48:41 +07:00
positionName : item.position ,
posType : item.posType ,
posLevel : item.posLevel ,
profileId : item.profileId ,
prefix : item.prefix ,
firstName : item.firstName ,
lastName : item.lastName ,
citizenId : item.citizenId ,
2024-12-06 16:03:45 +07:00
amount : item.amount ,
amountSpecial : item.amountSpecial ,
amountUse : item.amountUse ,
positionSalaryAmount : item.positionSalaryAmount ,
2024-10-24 10:48:41 +07:00
} ) ) ;
return new HttpSuccess ( _salaryRank ) ;
}
/ * *
2025-03-19 12:03:25 +07:00
* API อ อ ก ค ำ ส ั ่ ง C - PM - 36
2024-10-24 10:48:41 +07:00
*
2025-03-19 12:03:25 +07:00
* @summary อ อ ก ค ำ ส ั ่ ง C - PM - 36
2024-10-24 10:48:41 +07:00
*
* @param { string } id Guid , * Id ผ ั ง เ ง ิ น เ ด ื อ น
* /
2024-10-24 10:55:58 +07:00
@Post ( "command/C-PM-36/{id}" )
2024-10-24 10:48:41 +07:00
async SalaryReport36Command (
@Path ( ) id : string ,
@Body ( )
body : {
type : string ;
rootId : string ;
2025-06-05 12:13:42 +07:00
// isRetired?: boolean;
2024-10-24 10:48:41 +07:00
} ,
) {
// let conditionGroup = "";
// if (body.type.trim().toUpperCase() == "GROUP1.1") {
// conditionGroup =
// "(salaryProfileEmployee.posType = 'ทั่วไป' AND salaryProfileEmployee.posLevel = 'ชำนาญงาน') OR (salaryProfileEmployee.posType = 'ทั่วไป' AND salaryProfileEmployee.posLevel = 'ปฏิบัติงาน') OR (salaryProfileEmployee.posType = 'วิชาการ' AND salaryProfileEmployee.posLevel = 'ปฏิบัติการ') OR (salaryProfileEmployee.posType = 'วิชาการ' AND salaryProfileEmployee.posLevel = 'ชำนาญการ')";
// } else if (body.type.trim().toUpperCase() == "GROUP1.2") {
// conditionGroup =
// "(salaryProfileEmployee.posType = 'ทั่วไป' AND salaryProfileEmployee.posLevel = 'อาวุโส') OR (salaryProfileEmployee.posType = 'วิชาการ' AND salaryProfileEmployee.posLevel = 'ชำนาญการพิเศษ') OR (salaryProfileEmployee.posType = 'อำนวยการ' AND salaryProfileEmployee.posLevel = 'ต้น')";
// } else if (body.type.trim().toUpperCase() == "GROUP2") {
// conditionGroup =
// "(salaryProfileEmployee.posType = 'ทั่วไป' AND salaryProfileEmployee.posLevel = 'ทักษะพิเศษ') OR (salaryProfileEmployee.posType = 'วิชาการ' AND salaryProfileEmployee.posLevel = 'เชี่ยวชาญ') OR (salaryProfileEmployee.posType = 'วิชาการ' AND salaryProfileEmployee.posLevel = 'ทรงคุณวุฒิ') OR (salaryProfileEmployee.posType = 'อำนวยการ' AND salaryProfileEmployee.posLevel = 'สูง') OR (salaryProfileEmployee.posType = 'บริหาร' AND salaryProfileEmployee.posLevel = 'ต้น') OR (salaryProfileEmployee.posType = 'บริหาร' AND salaryProfileEmployee.posLevel = 'สูง')";
// } else {
// throw new HttpError(HttpStatusCode.NOT_FOUND, "กลุ่มเป้าหมายไม่ถูกต้อง");
// }
const salary = await this . salaryPeriodRepository . findOne ( {
where : { id : id } ,
} ) ;
if ( ! salary ) {
throw new HttpError ( HttpStatusCode . NOT_FOUND , "ไม่พบข้อมูลการขึ้นเงินเดือน" ) ;
}
const salaryOrgs = await this . salaryOrgEmployeeRepository . find ( {
where : { salaryPeriodId : salary.id , snapshot : "SNAP2" } ,
} ) ;
2025-05-27 17:45:05 +07:00
2025-06-05 12:13:42 +07:00
// let condition = "1=1";
// let parameters = {};
2024-10-24 10:48:41 +07:00
2025-06-05 12:13:42 +07:00
// if(body.isRetired === true){
// condition = "salaryProfileEmployee.isRetired = :isRetired"
// parameters = { isRetired: true }
// }
2024-10-24 10:48:41 +07:00
let salaryRank = await AppDataSource . getRepository ( SalaryProfileEmployee )
. createQueryBuilder ( "salaryProfileEmployee" )
// .andWhere("salaryProfileEmployee.rootId LIKE :rootId", {
// rootId: body.type.trim().toUpperCase() == "GROUP1.1" ? body.rootId : `%%`,
// })
. andWhere ( {
salaryOrgId : In ( salaryOrgs . map ( ( x ) = > x . id ) ) ,
type : In ( [ "FULLHAFT" , "FULL" , "HAFT" ] ) ,
2025-03-19 12:03:25 +07:00
// status: "PENDING",
2024-10-24 10:48:41 +07:00
} )
// .andWhere(
// new Brackets((qb) => {
// qb.andWhere(conditionGroup);
// }),
// )
2025-03-19 12:03:25 +07:00
. andWhere ( "salaryProfileEmployee.status36 = :status" , { status : "PENDING" } )
2025-04-28 10:48:58 +07:00
. andWhere ( "salaryProfileEmployee.rootId = :rootId" , { rootId : body.rootId } )
2025-06-05 12:13:42 +07:00
// .andWhere(condition, parameters)
2024-10-24 10:48:41 +07:00
. select ( [
"salaryProfileEmployee.id" ,
"salaryProfileEmployee.orgShortName" ,
"salaryProfileEmployee.posMasterNo" ,
"salaryProfileEmployee.position" ,
"salaryProfileEmployee.posType" ,
2024-12-04 13:37:22 +07:00
"salaryProfileEmployee.posTypeShort" ,
2024-10-24 10:48:41 +07:00
"salaryProfileEmployee.posLevel" ,
"salaryProfileEmployee.profileId" ,
"salaryProfileEmployee.prefix" ,
"salaryProfileEmployee.firstName" ,
"salaryProfileEmployee.lastName" ,
"salaryProfileEmployee.citizenId" ,
2024-12-06 16:03:45 +07:00
"salaryProfileEmployee.amount" ,
"salaryProfileEmployee.amountSpecial" ,
"salaryProfileEmployee.amountUse" ,
"salaryProfileEmployee.positionSalaryAmount" ,
2024-10-24 10:48:41 +07:00
] )
2025-04-10 16:24:47 +07:00
. orderBy ( "salaryProfileEmployee.rootOrder" , "ASC" )
. addOrderBy ( "salaryProfileEmployee.child1Order" , "ASC" )
. addOrderBy ( "salaryProfileEmployee.child2Order" , "ASC" )
. addOrderBy ( "salaryProfileEmployee.child3Order" , "ASC" )
. addOrderBy ( "salaryProfileEmployee.child4Order" , "ASC" )
. addOrderBy ( "salaryProfileEmployee.posMasterNo" , "ASC" )
2024-10-24 10:48:41 +07:00
. getMany ( ) ;
const _salaryRank = salaryRank . map ( ( item ) = > ( {
id : item.id ,
2025-04-05 18:12:02 +07:00
posMasterNo : ` ${ item . orgShortName } ${ item . posMasterNo } ` ,
2024-10-24 10:48:41 +07:00
positionName : item.position ,
posType : item.posType ,
2024-12-04 13:37:22 +07:00
posLevel : ` ${ item . posTypeShort ? ? "" } ${ item . posLevel ? ? "" } ` ,
2024-10-24 10:48:41 +07:00
profileId : item.profileId ,
prefix : item.prefix ,
firstName : item.firstName ,
lastName : item.lastName ,
citizenId : item.citizenId ,
2024-12-06 16:03:45 +07:00
amount : item.amount ,
amountSpecial : item.amountSpecial ,
amountUse : item.amountUse ,
positionSalaryAmount : item.positionSalaryAmount ,
2024-10-24 10:48:41 +07:00
} ) ) ;
return new HttpSuccess ( _salaryRank ) ;
}
/ * *
2025-03-19 12:03:25 +07:00
* API อ อ ก ค ำ ส ั ่ ง C - PM - 37
2024-10-24 10:48:41 +07:00
*
2025-03-19 12:03:25 +07:00
* @summary อ อ ก ค ำ ส ั ่ ง C - PM - 37
2024-10-24 10:48:41 +07:00
*
* @param { string } id Guid , * Id ผ ั ง เ ง ิ น เ ด ื อ น
* /
2024-10-24 10:55:58 +07:00
@Post ( "command/C-PM-37/{id}" )
2024-10-24 10:48:41 +07:00
async SalaryReport37Command (
@Path ( ) id : string ,
@Body ( )
body : {
type : string ;
rootId : string ;
2025-06-05 12:13:42 +07:00
// isRetired?: boolean;
2024-10-24 10:48:41 +07:00
} ,
) {
// let conditionGroup = "";
// if (body.type.trim().toUpperCase() == "GROUP1.1") {
// conditionGroup =
// "(salaryProfileEmployee.posType = 'ทั่วไป' AND salaryProfileEmployee.posLevel = 'ชำนาญงาน') OR (salaryProfileEmployee.posType = 'ทั่วไป' AND salaryProfileEmployee.posLevel = 'ปฏิบัติงาน') OR (salaryProfileEmployee.posType = 'วิชาการ' AND salaryProfileEmployee.posLevel = 'ปฏิบัติการ') OR (salaryProfileEmployee.posType = 'วิชาการ' AND salaryProfileEmployee.posLevel = 'ชำนาญการ')";
// } else if (body.type.trim().toUpperCase() == "GROUP1.2") {
// conditionGroup =
// "(salaryProfileEmployee.posType = 'ทั่วไป' AND salaryProfileEmployee.posLevel = 'อาวุโส') OR (salaryProfileEmployee.posType = 'วิชาการ' AND salaryProfileEmployee.posLevel = 'ชำนาญการพิเศษ') OR (salaryProfileEmployee.posType = 'อำนวยการ' AND salaryProfileEmployee.posLevel = 'ต้น')";
// } else if (body.type.trim().toUpperCase() == "GROUP2") {
// conditionGroup =
// "(salaryProfileEmployee.posType = 'ทั่วไป' AND salaryProfileEmployee.posLevel = 'ทักษะพิเศษ') OR (salaryProfileEmployee.posType = 'วิชาการ' AND salaryProfileEmployee.posLevel = 'เชี่ยวชาญ') OR (salaryProfileEmployee.posType = 'วิชาการ' AND salaryProfileEmployee.posLevel = 'ทรงคุณวุฒิ') OR (salaryProfileEmployee.posType = 'อำนวยการ' AND salaryProfileEmployee.posLevel = 'สูง') OR (salaryProfileEmployee.posType = 'บริหาร' AND salaryProfileEmployee.posLevel = 'ต้น') OR (salaryProfileEmployee.posType = 'บริหาร' AND salaryProfileEmployee.posLevel = 'สูง')";
// } else {
// throw new HttpError(HttpStatusCode.NOT_FOUND, "กลุ่มเป้าหมายไม่ถูกต้อง");
// }
const salary = await this . salaryPeriodRepository . findOne ( {
where : { id : id } ,
} ) ;
if ( ! salary ) {
throw new HttpError ( HttpStatusCode . NOT_FOUND , "ไม่พบข้อมูลการขึ้นเงินเดือน" ) ;
}
const salaryOrgs = await this . salaryOrgEmployeeRepository . find ( {
where : { salaryPeriodId : salary.id , snapshot : "SNAP2" } ,
} ) ;
2025-06-05 12:13:42 +07:00
// let condition = "1=1";
// let parameters = {};
2025-05-27 17:45:05 +07:00
2025-06-05 12:13:42 +07:00
// if(body.isRetired === true){
// condition = "salaryProfileEmployee.isRetired = :isRetired"
// parameters = { isRetired: true }
// }
2025-05-27 17:45:05 +07:00
2024-10-24 10:48:41 +07:00
let salaryRank = await AppDataSource . getRepository ( SalaryProfileEmployee )
. createQueryBuilder ( "salaryProfileEmployee" )
// .andWhere("salaryProfileEmployee.rootId LIKE :rootId", {
// rootId: body.type.trim().toUpperCase() == "GROUP1.1" ? body.rootId : `%%`,
// })
. andWhere ( {
salaryOrgId : In ( salaryOrgs . map ( ( x ) = > x . id ) ) ,
amountSpecial : MoreThan ( 0 ) ,
2025-03-19 12:03:25 +07:00
// status: "PENDING",
2024-10-24 10:48:41 +07:00
} )
// .andWhere(
// new Brackets((qb) => {
// qb.andWhere(conditionGroup);
// }),
// )
2025-03-19 12:03:25 +07:00
. andWhere ( "salaryProfileEmployee.status37 = :status" , { status : "PENDING" } )
2025-05-01 16:31:25 +07:00
. andWhere ( "salaryProfileEmployee.rootId = :rootId" , { rootId : body.rootId } )
2025-06-05 12:13:42 +07:00
// .andWhere(condition, parameters)
2024-10-24 10:48:41 +07:00
. select ( [
"salaryProfileEmployee.id" ,
"salaryProfileEmployee.orgShortName" ,
"salaryProfileEmployee.posMasterNo" ,
"salaryProfileEmployee.position" ,
"salaryProfileEmployee.posType" ,
2024-12-04 13:37:22 +07:00
"salaryProfileEmployee.posTypeShort" ,
2024-10-24 10:48:41 +07:00
"salaryProfileEmployee.posLevel" ,
"salaryProfileEmployee.profileId" ,
"salaryProfileEmployee.prefix" ,
"salaryProfileEmployee.firstName" ,
"salaryProfileEmployee.lastName" ,
"salaryProfileEmployee.citizenId" ,
2024-12-06 16:03:45 +07:00
"salaryProfileEmployee.amount" ,
"salaryProfileEmployee.amountSpecial" ,
"salaryProfileEmployee.amountUse" ,
"salaryProfileEmployee.positionSalaryAmount" ,
2024-10-24 10:48:41 +07:00
] )
2025-04-10 16:24:47 +07:00
. orderBy ( "salaryProfileEmployee.rootOrder" , "ASC" )
. addOrderBy ( "salaryProfileEmployee.child1Order" , "ASC" )
. addOrderBy ( "salaryProfileEmployee.child2Order" , "ASC" )
. addOrderBy ( "salaryProfileEmployee.child3Order" , "ASC" )
. addOrderBy ( "salaryProfileEmployee.child4Order" , "ASC" )
. addOrderBy ( "salaryProfileEmployee.posMasterNo" , "ASC" )
2024-10-24 10:48:41 +07:00
. getMany ( ) ;
const _salaryRank = salaryRank . map ( ( item ) = > ( {
id : item.id ,
2025-04-05 18:12:02 +07:00
posMasterNo : ` ${ item . orgShortName } ${ item . posMasterNo } ` ,
2024-10-24 10:48:41 +07:00
positionName : item.position ,
posType : item.posType ,
2024-12-04 13:37:22 +07:00
posLevel : ` ${ item . posTypeShort ? ? "" } ${ item . posLevel ? ? "" } ` ,
2024-10-24 10:48:41 +07:00
profileId : item.profileId ,
2024-04-25 00:53:57 +07:00
prefix : item.prefix ,
firstName : item.firstName ,
lastName : item.lastName ,
2024-10-24 09:30:45 +07:00
citizenId : item.citizenId ,
2024-12-06 16:03:45 +07:00
amount : item.amount ,
amountSpecial : item.amountSpecial ,
amountUse : item.amountUse ,
positionSalaryAmount : item.positionSalaryAmount ,
2024-04-25 00:53:57 +07:00
} ) ) ;
2025-05-02 11:00:33 +07:00
return new HttpSuccess ( _salaryRank ) ;
2024-04-25 00:53:57 +07:00
}
2025-01-10 16:11:34 +07:00
2025-06-05 12:13:42 +07:00
/ * *
* API อ อ ก ค ำ ส ั ่ ง C - PM - 45
*
* @summary อ อ ก ค ำ ส ั ่ ง C - PM - 45 เ ล ื ่ อ น เ ง ิ น เ ด ื อ น ล ู ก จ ้ า ง เ ก ษ ี ย ณ
*
* @param { string } id Guid , * Id ผ ั ง เ ง ิ น เ ด ื อ น
* /
@Post ( "command/C-PM-45/{id}" )
async SalaryReport45Command (
@Path ( ) id : string ,
@Body ( )
body : {
type : string ;
rootId : string ;
} ,
) {
const salary = await this . salaryPeriodRepository . findOne ( {
where : { id : id } ,
} ) ;
if ( ! salary ) {
throw new HttpError ( HttpStatusCode . NOT_FOUND , "ไม่พบข้อมูลการขึ้นเงินเดือน" ) ;
}
const salaryOrgs = await this . salaryOrgEmployeeRepository . find ( {
where : { salaryPeriodId : salary.id , snapshot : "SNAP2" } ,
} ) ;
let salaryRank = await AppDataSource . getRepository ( SalaryProfileEmployee )
. createQueryBuilder ( "salaryProfileEmployee" )
. andWhere ( {
salaryOrgId : In ( salaryOrgs . map ( ( x ) = > x . id ) ) ,
type : In ( [ "FULLHAFT" , "FULL" , "HAFT" ] ) ,
} )
. andWhere ( "salaryProfileEmployee.status36 = :status" , { status : "PENDING" } )
. andWhere ( "salaryProfileEmployee.rootId = :rootId" , { rootId : body.rootId } )
. andWhere ( "salaryProfileEmployee.isRetired = :isRetired" , { isRetired : true } )
. select ( [
"salaryProfileEmployee.id" ,
"salaryProfileEmployee.orgShortName" ,
"salaryProfileEmployee.posMasterNo" ,
"salaryProfileEmployee.position" ,
"salaryProfileEmployee.posType" ,
"salaryProfileEmployee.posTypeShort" ,
"salaryProfileEmployee.posLevel" ,
"salaryProfileEmployee.profileId" ,
"salaryProfileEmployee.prefix" ,
"salaryProfileEmployee.firstName" ,
"salaryProfileEmployee.lastName" ,
"salaryProfileEmployee.citizenId" ,
"salaryProfileEmployee.amount" ,
"salaryProfileEmployee.amountSpecial" ,
"salaryProfileEmployee.amountUse" ,
"salaryProfileEmployee.positionSalaryAmount" ,
] )
. orderBy ( "salaryProfileEmployee.rootOrder" , "ASC" )
. addOrderBy ( "salaryProfileEmployee.child1Order" , "ASC" )
. addOrderBy ( "salaryProfileEmployee.child2Order" , "ASC" )
. addOrderBy ( "salaryProfileEmployee.child3Order" , "ASC" )
. addOrderBy ( "salaryProfileEmployee.child4Order" , "ASC" )
. addOrderBy ( "salaryProfileEmployee.posMasterNo" , "ASC" )
. getMany ( ) ;
const _salaryRank = salaryRank . map ( ( item ) = > ( {
id : item.id ,
posMasterNo : ` ${ item . orgShortName } ${ item . posMasterNo } ` ,
positionName : item.position ,
posType : item.posType ,
posLevel : ` ${ item . posTypeShort ? ? "" } ${ item . posLevel ? ? "" } ` ,
profileId : item.profileId ,
prefix : item.prefix ,
firstName : item.firstName ,
lastName : item.lastName ,
citizenId : item.citizenId ,
amount : item.amount ,
amountSpecial : item.amountSpecial ,
amountUse : item.amountUse ,
positionSalaryAmount : item.positionSalaryAmount ,
} ) ) ;
return new HttpSuccess ( _salaryRank ) ;
}
/ * *
* API อ อ ก ค ำ ส ั ่ ง C - PM - 46
*
* @summary อ อ ก ค ำ ส ั ่ ง C - PM - 46 เ ง ิ น พ ิ เ ศ ษ ล ู ก จ ้ า ง เ ก ษ ี ย ณ
*
* @param { string } id Guid , * Id ผ ั ง เ ง ิ น เ ด ื อ น
* /
@Post ( "command/C-PM-46/{id}" )
async SalaryReport46Command (
@Path ( ) id : string ,
@Body ( )
body : {
type : string ;
rootId : string ;
} ,
) {
const salary = await this . salaryPeriodRepository . findOne ( {
where : { id : id } ,
} ) ;
if ( ! salary ) {
throw new HttpError ( HttpStatusCode . NOT_FOUND , "ไม่พบข้อมูลการขึ้นเงินเดือน" ) ;
}
const salaryOrgs = await this . salaryOrgEmployeeRepository . find ( {
where : { salaryPeriodId : salary.id , snapshot : "SNAP2" } ,
} ) ;
let salaryRank = await AppDataSource . getRepository ( SalaryProfileEmployee )
. createQueryBuilder ( "salaryProfileEmployee" )
. andWhere ( {
salaryOrgId : In ( salaryOrgs . map ( ( x ) = > x . id ) ) ,
amountSpecial : MoreThan ( 0 ) ,
} )
. andWhere ( "salaryProfileEmployee.status37 = :status" , { status : "PENDING" } )
. andWhere ( "salaryProfileEmployee.rootId = :rootId" , { rootId : body.rootId } )
. andWhere ( "salaryProfileEmployee.isRetired = :isRetired" , { isRetired : true } )
. select ( [
"salaryProfileEmployee.id" ,
"salaryProfileEmployee.orgShortName" ,
"salaryProfileEmployee.posMasterNo" ,
"salaryProfileEmployee.position" ,
"salaryProfileEmployee.posType" ,
"salaryProfileEmployee.posTypeShort" ,
"salaryProfileEmployee.posLevel" ,
"salaryProfileEmployee.profileId" ,
"salaryProfileEmployee.prefix" ,
"salaryProfileEmployee.firstName" ,
"salaryProfileEmployee.lastName" ,
"salaryProfileEmployee.citizenId" ,
"salaryProfileEmployee.amount" ,
"salaryProfileEmployee.amountSpecial" ,
"salaryProfileEmployee.amountUse" ,
"salaryProfileEmployee.positionSalaryAmount" ,
] )
. orderBy ( "salaryProfileEmployee.rootOrder" , "ASC" )
. addOrderBy ( "salaryProfileEmployee.child1Order" , "ASC" )
. addOrderBy ( "salaryProfileEmployee.child2Order" , "ASC" )
. addOrderBy ( "salaryProfileEmployee.child3Order" , "ASC" )
. addOrderBy ( "salaryProfileEmployee.child4Order" , "ASC" )
. addOrderBy ( "salaryProfileEmployee.posMasterNo" , "ASC" )
. getMany ( ) ;
const _salaryRank = salaryRank . map ( ( item ) = > ( {
id : item.id ,
posMasterNo : ` ${ item . orgShortName } ${ item . posMasterNo } ` ,
positionName : item.position ,
posType : item.posType ,
posLevel : ` ${ item . posTypeShort ? ? "" } ${ item . posLevel ? ? "" } ` ,
profileId : item.profileId ,
prefix : item.prefix ,
firstName : item.firstName ,
lastName : item.lastName ,
citizenId : item.citizenId ,
amount : item.amount ,
amountSpecial : item.amountSpecial ,
amountUse : item.amountUse ,
positionSalaryAmount : item.positionSalaryAmount ,
} ) ) ;
return new HttpSuccess ( _salaryRank ) ;
}
2024-10-30 10:23:36 +07:00
/ * *
2025-03-19 12:03:25 +07:00
* API อ อ ก ค ำ ส ั ่ ง C - PM - 33
*
* @summary อ อ ก ค ำ ส ั ่ ง C - PM - 33
*
* @param { string } id Guid , * Id ผ ั ง เ ง ิ น เ ด ื อ น
* /
@Post ( "command33/officer/report" )
async SalaryOfficerReportCommand33 (
@Body ( )
body : {
refIds : string [ ] ;
2025-04-03 11:14:12 +07:00
status : string ;
2025-03-19 12:03:25 +07:00
} ,
@Request ( ) request : RequestWithUser ,
) {
const salaryProfile = await this . salaryProfileRepository . find ( {
where : { id : In ( body . refIds ) } ,
} ) ;
const data = salaryProfile . map ( ( _data ) = > ( {
. . . _data ,
2025-04-03 11:14:12 +07:00
status33 : body.status.trim ( ) . toUpperCase ( ) ,
2025-03-19 12:03:25 +07:00
} ) ) ;
await this . salaryProfileRepository . save ( data ) ;
return new HttpSuccess ( ) ;
}
/ * *
* API อ อ ก ค ำ ส ั ่ ง C - PM - 34
*
* @summary อ อ ก ค ำ ส ั ่ ง C - PM - 34
*
* @param { string } id Guid , * Id ผ ั ง เ ง ิ น เ ด ื อ น
* /
@Post ( "command34/officer/report" )
async SalaryOfficerReportCommand34 (
@Body ( )
body : {
refIds : string [ ] ;
2025-04-03 11:14:12 +07:00
status : string ;
2025-03-19 12:03:25 +07:00
} ,
@Request ( ) request : RequestWithUser ,
) {
const salaryProfile = await this . salaryProfileRepository . find ( {
where : { id : In ( body . refIds ) } ,
} ) ;
const data = salaryProfile . map ( ( _data ) = > ( {
. . . _data ,
2025-04-03 11:14:12 +07:00
status34 : body.status.trim ( ) . toUpperCase ( ) ,
2025-03-19 12:03:25 +07:00
} ) ) ;
await this . salaryProfileRepository . save ( data ) ;
return new HttpSuccess ( ) ;
}
/ * *
* API อ อ ก ค ำ ส ั ่ ง C - PM - 35
2024-10-30 10:23:36 +07:00
*
2025-03-19 12:03:25 +07:00
* @summary อ อ ก ค ำ ส ั ่ ง C - PM - 35
2024-10-30 10:23:36 +07:00
*
* @param { string } id Guid , * Id ผ ั ง เ ง ิ น เ ด ื อ น
* /
2025-03-19 12:03:25 +07:00
@Post ( "command35/officer/report" )
async SalaryOfficerReportCommand35 (
2024-10-30 10:23:36 +07:00
@Body ( )
body : {
refIds : string [ ] ;
2025-04-03 11:14:12 +07:00
status : string ;
2024-10-30 10:23:36 +07:00
} ,
@Request ( ) request : RequestWithUser ,
) {
const salaryProfile = await this . salaryProfileRepository . find ( {
where : { id : In ( body . refIds ) } ,
} ) ;
const data = salaryProfile . map ( ( _data ) = > ( {
. . . _data ,
2025-04-03 11:14:12 +07:00
status35 : body.status.trim ( ) . toUpperCase ( ) ,
2024-10-30 10:23:36 +07:00
} ) ) ;
await this . salaryProfileRepository . save ( data ) ;
return new HttpSuccess ( ) ;
}
2025-03-19 12:03:25 +07:00
/ * *
* API อ อ ก ค ำ ส ั ่ ง C - PM - 36
*
* @summary อ อ ก ค ำ ส ั ่ ง C - PM - 36
*
* @param { string } id Guid , * Id ผ ั ง เ ง ิ น เ ด ื อ น
* /
@Post ( "command36/employee/report" )
async SalaryEmployeeReportCommand36 (
@Body ( )
body : {
refIds : string [ ] ;
2025-04-03 11:14:12 +07:00
status : string ;
2025-03-19 12:03:25 +07:00
} ,
@Request ( ) request : RequestWithUser ,
) {
const salaryProfile = await this . salaryProfileEmployeeRepository . find ( {
where : { id : In ( body . refIds ) } ,
} ) ;
const data = salaryProfile . map ( ( _data ) = > ( {
. . . _data ,
2025-04-03 11:14:12 +07:00
status36 : body.status.trim ( ) . toUpperCase ( ) ,
2025-03-19 12:03:25 +07:00
} ) ) ;
await this . salaryProfileEmployeeRepository . save ( data ) ;
return new HttpSuccess ( ) ;
}
2024-10-30 10:23:36 +07:00
/ * *
2025-03-19 12:03:25 +07:00
* API อ อ ก ค ำ ส ั ่ ง C - PM - 37
2024-10-30 10:23:36 +07:00
*
2025-03-19 12:03:25 +07:00
* @summary อ อ ก ค ำ ส ั ่ ง C - PM - 37
2024-10-30 10:23:36 +07:00
*
* @param { string } id Guid , * Id ผ ั ง เ ง ิ น เ ด ื อ น
* /
2025-03-19 12:03:25 +07:00
@Post ( "command37/employee/report" )
async SalaryEmployeeReportCommand37 (
2024-10-30 10:23:36 +07:00
@Body ( )
body : {
refIds : string [ ] ;
2025-04-03 11:14:12 +07:00
status : string ;
2024-10-30 10:23:36 +07:00
} ,
@Request ( ) request : RequestWithUser ,
) {
const salaryProfile = await this . salaryProfileEmployeeRepository . find ( {
where : { id : In ( body . refIds ) } ,
} ) ;
const data = salaryProfile . map ( ( _data ) = > ( {
. . . _data ,
2025-04-03 11:14:12 +07:00
status37 : body.status.trim ( ) . toUpperCase ( ) ,
2024-10-30 10:23:36 +07:00
} ) ) ;
await this . salaryProfileEmployeeRepository . save ( data ) ;
return new HttpSuccess ( ) ;
}
2024-10-04 17:14:16 +07:00
2024-10-31 13:51:40 +07:00
/ * *
2025-03-19 12:03:25 +07:00
* เ อ ก ส า ร แ น บ ท ้ า ย ข ร ก . C - PM - 33
2024-10-31 13:51:40 +07:00
*
2025-03-19 12:03:25 +07:00
* @summary เ อ ก ส า ร แ น บ ท ้ า ย ข ร ก . C - PM - 33
2024-10-31 13:51:40 +07:00
*
* /
2025-03-19 12:03:25 +07:00
@Post ( "command33/officer/report/attachment" )
async SalaryReportAttachment33 (
2024-10-31 13:51:40 +07:00
@Body ( )
body : {
refIds : {
refId? : string ;
Sequence? : any | null ;
CitizenId? : any | null ;
Prefix? : any | null ;
FirstName? : any | null ;
LastName? : any | null ;
Amount? : any | null ;
PositionSalaryAmount? : any | null ;
MouthSalaryAmount? : any | null ;
RemarkHorizontal? : any | null ;
RemarkVertical? : any | null ;
CommandYear? : any | null ;
} [ ] ;
} ,
@Request ( ) request : RequestWithUser ,
) {
let data = new Array ( ) ;
await Promise . all (
body . refIds . map ( async ( v ) = > {
const salary = await this . salaryProfileRepository . findOne ( {
where : {
id : v.refId ,
} ,
} ) ;
if ( salary != null ) {
const _data = {
no : Extension.ToThaiNumber ( ( data . length + 1 ) . toString ( ) ) ,
fullName : ` ${ v . Prefix } ${ v . FirstName } ${ v . LastName } ` ,
2025-01-10 16:11:34 +07:00
oc :
salary . rootId == null
? salary . position == null
? "-"
: salary . position
: salary . child4 != null
? salary . position == null
? salary . child4 +
"/" +
salary . child3 +
"/" +
salary . child2 +
"/" +
salary . child1 +
"/" +
salary . root
: salary . position +
"/" +
salary . child4 +
"/" +
salary . child3 +
"/" +
salary . child2 +
"/" +
salary . child1 +
"/" +
salary . root
: salary . child3 != null
? salary . position == null
? salary . child3 +
"/" +
salary . child2 +
"/" +
salary . child1 +
"/" +
salary . root
: salary . position +
"/" +
salary . child3 +
"/" +
salary . child2 +
"/" +
salary . child1 +
"/" +
salary . root
: salary . child2 != null
? salary . position == null
? salary . child2 + "/" + salary . child1 + "/" + salary . root
: salary . position +
"/" +
salary . child2 +
"/" +
salary . child1 +
"/" +
salary . root
: salary . child1 != null
? salary . position == null
? salary . child1 + "/" + salary . root
: salary . position + "/" + salary . child1 + "/" + salary . root
: salary . root != null
? salary . position == null
? salary . root
: salary . position + "/" + salary . root
: "-" ,
2024-10-31 13:51:40 +07:00
positionType : salary.posType ? salary . posType : "-" ,
2025-01-10 16:11:34 +07:00
positionLevel : salary.posLevel
? Extension . ToThaiNumber ( salary . posLevel . toString ( ) )
: "-" ,
positionNumber :
salary . orgShortName != null && salary . posMasterNo != null
2025-04-05 18:12:02 +07:00
? Extension . ToThaiNumber ( salary . orgShortName + " " + salary . posMasterNo )
2025-01-10 16:11:34 +07:00
: "-" ,
amount : salary.amount ? Extension . ToThaiNumber ( salary . amount . toLocaleString ( ) ) : "-" ,
positionSalaryAmount : salary.positionSalaryAmount
? Extension . ToThaiNumber ( salary . positionSalaryAmount . toLocaleString ( ) )
: "-" ,
amountSpecial : salary.amountSpecial
? Extension . ToThaiNumber ( salary . amountSpecial . toLocaleString ( ) )
2024-10-31 13:51:40 +07:00
: "-" ,
remark : salary.remark ? salary . remark : "-" ,
remarkVertical : v.RemarkVertical ,
2025-01-10 16:11:34 +07:00
remarkHorizontal : v.RemarkHorizontal ,
} ;
2024-10-31 13:51:40 +07:00
data . push ( _data ) ;
}
} ) ,
) ;
return new HttpSuccess ( data ) ;
}
/ * *
2025-03-19 12:03:25 +07:00
* เ อ ก ส า ร แ น บ ท ้ า ย ข ร ก . C - PM - 34
2024-10-31 13:51:40 +07:00
*
2025-03-19 12:03:25 +07:00
* @summary เ อ ก ส า ร แ น บ ท ้ า ย ข ร ก . C - PM34
2024-10-31 13:51:40 +07:00
*
* /
2025-03-19 12:03:25 +07:00
@Post ( "command34/officer/report/attachment" )
async SalaryReportAttachment34 (
2024-10-31 13:51:40 +07:00
@Body ( )
body : {
refIds : {
refId? : string ;
Sequence? : any | null ;
CitizenId? : any | null ;
Prefix? : any | null ;
FirstName? : any | null ;
LastName? : any | null ;
Amount? : any | null ;
PositionSalaryAmount? : any | null ;
MouthSalaryAmount? : any | null ;
RemarkHorizontal? : any | null ;
RemarkVertical? : any | null ;
CommandYear? : any | null ;
} [ ] ;
} ,
@Request ( ) request : RequestWithUser ,
) {
let data = new Array ( ) ;
await Promise . all (
body . refIds . map ( async ( v ) = > {
2025-03-19 12:03:25 +07:00
const salary = await this . salaryProfileRepository . findOne ( {
2024-10-31 13:51:40 +07:00
where : {
id : v.refId ,
} ,
} ) ;
if ( salary != null ) {
const _data = {
no : Extension.ToThaiNumber ( ( data . length + 1 ) . toString ( ) ) ,
fullName : ` ${ v . Prefix } ${ v . FirstName } ${ v . LastName } ` ,
2025-01-10 16:11:34 +07:00
oc :
salary . rootId == null
? salary . position == null
? "-"
: salary . position
: salary . child4 != null
? salary . position == null
? salary . child4 +
"/" +
salary . child3 +
"/" +
salary . child2 +
"/" +
salary . child1 +
"/" +
salary . root
: salary . position +
"/" +
salary . child4 +
"/" +
salary . child3 +
"/" +
salary . child2 +
"/" +
salary . child1 +
"/" +
salary . root
: salary . child3 != null
? salary . position == null
? salary . child3 +
"/" +
salary . child2 +
"/" +
salary . child1 +
"/" +
salary . root
: salary . position +
"/" +
salary . child3 +
"/" +
salary . child2 +
"/" +
salary . child1 +
"/" +
salary . root
: salary . child2 != null
? salary . position == null
? salary . child2 + "/" + salary . child1 + "/" + salary . root
: salary . position +
"/" +
salary . child2 +
"/" +
salary . child1 +
"/" +
salary . root
: salary . child1 != null
? salary . position == null
? salary . child1 + "/" + salary . root
: salary . position + "/" + salary . child1 + "/" + salary . root
: salary . root != null
? salary . position == null
? salary . root
: salary . position + "/" + salary . root
: "-" ,
2024-10-31 13:51:40 +07:00
positionType : salary.posType ? salary . posType : "-" ,
2025-01-10 16:11:34 +07:00
positionLevel : salary.posLevel
? Extension . ToThaiNumber ( salary . posLevel . toString ( ) )
: "-" ,
positionNumber :
salary . orgShortName != null && salary . posMasterNo != null
2025-04-05 18:12:02 +07:00
? Extension . ToThaiNumber ( salary . orgShortName + " " + salary . posMasterNo )
2025-01-10 16:11:34 +07:00
: "-" ,
amount : salary.amount ? Extension . ToThaiNumber ( salary . amount . toLocaleString ( ) ) : "-" ,
positionSalaryAmount : salary.positionSalaryAmount
? Extension . ToThaiNumber ( salary . positionSalaryAmount . toLocaleString ( ) )
: "-" ,
amountSpecial : salary.amountSpecial
? Extension . ToThaiNumber ( salary . amountSpecial . toLocaleString ( ) )
2024-10-31 13:51:40 +07:00
: "-" ,
remark : salary.remark ? salary . remark : "-" ,
remarkVertical : v.RemarkVertical ,
2025-01-10 16:11:34 +07:00
remarkHorizontal : v.RemarkHorizontal ,
} ;
2024-10-31 13:51:40 +07:00
data . push ( _data ) ;
}
} ) ,
) ;
return new HttpSuccess ( data ) ;
}
2024-10-04 17:14:16 +07:00
/ * *
2025-03-19 12:03:25 +07:00
* เ อ ก ส า ร แ น บ ท ้ า ย ข ร ก . C - PM - 35
2024-10-04 17:14:16 +07:00
*
2025-03-19 12:03:25 +07:00
* @summary เ อ ก ส า ร แ น บ ท ้ า ย ข ร ก . C - PM - 35
2024-10-04 17:14:16 +07:00
*
* /
2025-03-19 12:03:25 +07:00
@Post ( "command35/officer/report/attachment" )
async SalaryReportAttachment35 (
2024-10-04 17:14:16 +07:00
@Body ( )
body : {
refIds : {
2025-03-19 12:03:25 +07:00
refId? : string ;
Sequence? : any | null ;
CitizenId? : any | null ;
Prefix? : any | null ;
FirstName? : any | null ;
LastName? : any | null ;
Amount? : any | null ;
PositionSalaryAmount? : any | null ;
MouthSalaryAmount? : any | null ;
RemarkHorizontal? : any | null ;
RemarkVertical? : any | null ;
CommandYear? : any | null ;
2024-10-04 17:14:16 +07:00
} [ ] ;
} ,
@Request ( ) request : RequestWithUser ,
) {
2025-03-19 12:03:25 +07:00
let data = new Array ( ) ;
2024-10-04 17:14:16 +07:00
await Promise . all (
body . refIds . map ( async ( v ) = > {
const salary = await this . salaryProfileRepository . findOne ( {
where : {
id : v.refId ,
} ,
} ) ;
if ( salary != null ) {
2025-03-19 12:03:25 +07:00
const _data = {
no : Extension.ToThaiNumber ( ( data . length + 1 ) . toString ( ) ) ,
fullName : ` ${ v . Prefix } ${ v . FirstName } ${ v . LastName } ` ,
oc :
salary . rootId == null
? salary . position == null
? "-"
: salary . position
: salary . child4 != null
? salary . position == null
? salary . child4 +
"/" +
salary . child3 +
"/" +
salary . child2 +
"/" +
salary . child1 +
"/" +
salary . root
: salary . position +
"/" +
salary . child4 +
"/" +
salary . child3 +
"/" +
salary . child2 +
"/" +
salary . child1 +
"/" +
salary . root
: salary . child3 != null
? salary . position == null
? salary . child3 +
"/" +
salary . child2 +
"/" +
salary . child1 +
"/" +
salary . root
: salary . position +
"/" +
salary . child3 +
"/" +
salary . child2 +
"/" +
salary . child1 +
"/" +
salary . root
: salary . child2 != null
? salary . position == null
? salary . child2 + "/" + salary . child1 + "/" + salary . root
: salary . position +
"/" +
salary . child2 +
"/" +
salary . child1 +
"/" +
salary . root
: salary . child1 != null
? salary . position == null
? salary . child1 + "/" + salary . root
: salary . position + "/" + salary . child1 + "/" + salary . root
: salary . root != null
? salary . position == null
? salary . root
: salary . position + "/" + salary . root
: "-" ,
positionType : salary.posType ? salary . posType : "-" ,
positionLevel : salary.posLevel
? Extension . ToThaiNumber ( salary . posLevel . toString ( ) )
: "-" ,
positionNumber :
salary . orgShortName != null && salary . posMasterNo != null
2025-04-05 18:12:02 +07:00
? Extension . ToThaiNumber ( salary . orgShortName + " " + salary . posMasterNo )
2025-03-19 12:03:25 +07:00
: "-" ,
amount : salary.amount ? Extension . ToThaiNumber ( salary . amount . toLocaleString ( ) ) : "-" ,
positionSalaryAmount : salary.positionSalaryAmount
? Extension . ToThaiNumber ( salary . positionSalaryAmount . toLocaleString ( ) )
: "-" ,
amountSpecial : salary.amountSpecial
? Extension . ToThaiNumber ( salary . amountSpecial . toLocaleString ( ) )
: "-" ,
remark : salary.remark ? salary . remark : "-" ,
remarkVertical : v.RemarkVertical ,
remarkHorizontal : v.RemarkHorizontal ,
} ;
data . push ( _data ) ;
2024-10-04 17:14:16 +07:00
}
} ) ,
) ;
2025-03-19 12:03:25 +07:00
return new HttpSuccess ( data ) ;
2024-10-04 17:14:16 +07:00
}
/ * *
2025-03-19 12:03:25 +07:00
* เ อ ก ส า ร แ น บ ท ้ า ย ล ู ก จ ้ า ง C - PM - 36
2024-10-04 17:14:16 +07:00
*
2025-03-19 12:03:25 +07:00
* @summary เ อ ก ส า ร แ น บ ท ้ า ย ล ู ก จ ้ า ง C - PM - 36
2024-10-04 17:14:16 +07:00
*
* /
2025-03-19 12:03:25 +07:00
@Post ( "command36/employee/report/attachment" )
async SalaryEmployeeReportAttachment36 (
2024-10-04 17:14:16 +07:00
@Body ( )
body : {
refIds : {
2025-03-19 12:03:25 +07:00
refId? : string ;
Sequence? : any | null ;
CitizenId? : any | null ;
Prefix? : any | null ;
FirstName? : any | null ;
LastName? : any | null ;
Amount? : any | null ;
PositionSalaryAmount? : any | null ;
MouthSalaryAmount? : any | null ;
RemarkHorizontal? : any | null ;
RemarkVertical? : any | null ;
CommandYear? : any | null ;
} [ ] ;
} ,
@Request ( ) request : RequestWithUser ,
) {
let data = new Array ( ) ;
await Promise . all (
body . refIds . map ( async ( v ) = > {
const salary = await this . salaryProfileEmployeeRepository . findOne ( {
where : {
id : v.refId ,
} ,
} ) ;
if ( salary != null ) {
const _data = {
no : Extension.ToThaiNumber ( ( data . length + 1 ) . toString ( ) ) ,
fullName : ` ${ v . Prefix } ${ v . FirstName } ${ v . LastName } ` ,
oc :
salary . rootId == null
? salary . position == null
? "-"
: salary . position
: salary . child4 != null
? salary . position == null
? salary . child4 +
"/" +
salary . child3 +
"/" +
salary . child2 +
"/" +
salary . child1 +
"/" +
salary . root
: salary . position +
"/" +
salary . child4 +
"/" +
salary . child3 +
"/" +
salary . child2 +
"/" +
salary . child1 +
"/" +
salary . root
: salary . child3 != null
? salary . position == null
? salary . child3 +
"/" +
salary . child2 +
"/" +
salary . child1 +
"/" +
salary . root
: salary . position +
"/" +
salary . child3 +
"/" +
salary . child2 +
"/" +
salary . child1 +
"/" +
salary . root
: salary . child2 != null
? salary . position == null
? salary . child2 + "/" + salary . child1 + "/" + salary . root
: salary . position +
"/" +
salary . child2 +
"/" +
salary . child1 +
"/" +
salary . root
: salary . child1 != null
? salary . position == null
? salary . child1 + "/" + salary . root
: salary . position + "/" + salary . child1 + "/" + salary . root
: salary . root != null
? salary . position == null
? salary . root
: salary . position + "/" + salary . root
: "-" ,
positionType : salary.posType ? salary . posType : "-" ,
positionLevel : salary.posLevel
? Extension . ToThaiNumber ( salary . posLevel . toString ( ) )
: "-" ,
positionNumber :
salary . orgShortName != null && salary . posMasterNo != null
2025-04-05 18:12:02 +07:00
? Extension . ToThaiNumber ( salary . orgShortName + " " + salary . posMasterNo )
2025-03-19 12:03:25 +07:00
: "-" ,
amount : salary.amount ? Extension . ToThaiNumber ( salary . amount . toLocaleString ( ) ) : "-" ,
positionSalaryAmount : salary.positionSalaryAmount
? Extension . ToThaiNumber ( salary . positionSalaryAmount . toLocaleString ( ) )
: "-" ,
amountSpecial : salary.amountSpecial
? Extension . ToThaiNumber ( salary . amountSpecial . toLocaleString ( ) )
: "-" ,
remark : salary.remark ? salary . remark : "-" ,
remarkVertical : v.RemarkVertical ,
remarkHorizontal : v.RemarkHorizontal ,
} ;
data . push ( _data ) ;
}
} ) ,
) ;
return new HttpSuccess ( data ) ;
}
/ * *
* เ อ ก ส า ร แ น บ ท ้ า ย ล ู ก จ ้ า ง C - PM - 37
*
* @summary เ อ ก ส า ร แ น บ ท ้ า ย ล ู ก จ ้ า ง C - PM - 37
*
* /
@Post ( "command37/employee/report/attachment" )
async SalaryEmployeeReportAttachment37 (
@Body ( )
body : {
refIds : {
refId? : string ;
Sequence? : any | null ;
CitizenId? : any | null ;
Prefix? : any | null ;
FirstName? : any | null ;
LastName? : any | null ;
Amount? : any | null ;
PositionSalaryAmount? : any | null ;
MouthSalaryAmount? : any | null ;
RemarkHorizontal? : any | null ;
RemarkVertical? : any | null ;
CommandYear? : any | null ;
} [ ] ;
} ,
@Request ( ) request : RequestWithUser ,
) {
let data = new Array ( ) ;
await Promise . all (
body . refIds . map ( async ( v ) = > {
const salary = await this . salaryProfileEmployeeRepository . findOne ( {
where : {
id : v.refId ,
} ,
} ) ;
if ( salary != null ) {
const _data = {
no : Extension.ToThaiNumber ( ( data . length + 1 ) . toString ( ) ) ,
fullName : ` ${ v . Prefix } ${ v . FirstName } ${ v . LastName } ` ,
oc :
salary . rootId == null
? salary . position == null
? "-"
: salary . position
: salary . child4 != null
? salary . position == null
? salary . child4 +
"/" +
salary . child3 +
"/" +
salary . child2 +
"/" +
salary . child1 +
"/" +
salary . root
: salary . position +
"/" +
salary . child4 +
"/" +
salary . child3 +
"/" +
salary . child2 +
"/" +
salary . child1 +
"/" +
salary . root
: salary . child3 != null
? salary . position == null
? salary . child3 +
"/" +
salary . child2 +
"/" +
salary . child1 +
"/" +
salary . root
: salary . position +
"/" +
salary . child3 +
"/" +
salary . child2 +
"/" +
salary . child1 +
"/" +
salary . root
: salary . child2 != null
? salary . position == null
? salary . child2 + "/" + salary . child1 + "/" + salary . root
: salary . position +
"/" +
salary . child2 +
"/" +
salary . child1 +
"/" +
salary . root
: salary . child1 != null
? salary . position == null
? salary . child1 + "/" + salary . root
: salary . position + "/" + salary . child1 + "/" + salary . root
: salary . root != null
? salary . position == null
? salary . root
: salary . position + "/" + salary . root
: "-" ,
positionType : salary.posType ? salary . posType : "-" ,
positionLevel : salary.posLevel
? Extension . ToThaiNumber ( salary . posLevel . toString ( ) )
: "-" ,
positionNumber :
salary . orgShortName != null && salary . posMasterNo != null
2025-04-05 18:12:02 +07:00
? Extension . ToThaiNumber ( salary . orgShortName + " " + salary . posMasterNo )
2025-03-19 12:03:25 +07:00
: "-" ,
amount : salary.amount ? Extension . ToThaiNumber ( salary . amount . toLocaleString ( ) ) : "-" ,
positionSalaryAmount : salary.positionSalaryAmount
? Extension . ToThaiNumber ( salary . positionSalaryAmount . toLocaleString ( ) )
: "-" ,
amountSpecial : salary.amountSpecial
? Extension . ToThaiNumber ( salary . amountSpecial . toLocaleString ( ) )
: "-" ,
remark : salary.remark ? salary . remark : "-" ,
remarkVertical : v.RemarkVertical ,
remarkHorizontal : v.RemarkHorizontal ,
} ;
data . push ( _data ) ;
}
} ) ,
) ;
return new HttpSuccess ( data ) ;
}
/ * *
* API อ อ ก ค ำ ส ั ่ ง C - PM - 33
*
* @summary อ อ ก ค ำ ส ั ่ ง C - PM - 33
*
* @param { string } id Guid , * Id ผ ั ง เ ง ิ น เ ด ื อ น
* /
@Post ( "command33/officer/report/excecute" )
async SalaryReportExcecute33 (
@Body ( )
body : {
refIds : {
refId : string ;
// commandAffectDate: Date | null;//เก่า
commandDateAffect : Date | null ; //ใหม่ (ปรับตาม rabbitMQ ORG)
commandNo : string | null ;
commandYear : number | null ;
commandId : string | null ;
remark : string | null ;
amount : Double | null ;
amountSpecial? : Double | null ;
positionSalaryAmount : Double | null ;
mouthSalaryAmount : Double | null ;
commandCode? : string | null ;
commandName? : string | null ;
commandDateSign : Date | null ;
} [ ] ;
} ,
@Request ( ) request : RequestWithUser ,
) {
await Promise . all (
body . refIds . map ( async ( v ) = > {
const salary = await this . salaryProfileRepository . findOne ( {
where : {
id : v.refId ,
} ,
} ) ;
if ( salary != null ) {
await new CallAPI ( )
. PostData ( request , "/org/profile/salary/update" , {
profileId : salary.profileId ,
commandDateAffect : v.commandDateAffect ,
commandDateSign : v.commandDateSign ,
amount : v.amount ,
amountSpecial : v.amountSpecial ,
positionSalaryAmount : v.positionSalaryAmount ,
mouthSalaryAmount : v.mouthSalaryAmount ,
posNo : salary.posMasterNo.toString ( ) ,
posNoAbb : salary.orgShortName ,
positionName : salary.position ,
positionExecutive : salary.posExecutive ,
2025-06-17 18:17:49 +07:00
positionExecutiveField : salary.positionExecutiveField ,
positionArea : salary.positionArea ,
2025-03-19 12:03:25 +07:00
positionType : salary.posType ,
positionLevel : salary.posLevel ,
commandId : v.commandId ,
remark : v.remark ,
orgRoot : salary.root ,
orgChild1 : salary.child1 ,
orgChild2 : salary.child2 ,
orgChild3 : salary.child3 ,
orgChild4 : salary.child4 ,
commandCode : v.commandCode ,
commandName : v.commandName ,
commandNo : v.commandNo ,
commandYear : v.commandYear ,
} )
. then ( async ( ) = > {
const before = null ;
salary . status33 = "DONE" ;
salary . lastUpdateUserId = request . user . sub ;
salary . lastUpdateFullName = request . user . name ;
salary . lastUpdatedAt = new Date ( ) ;
await this . salaryProfileRepository . save ( salary , { data : request } ) ;
setLogDataDiff ( request , { before , after : salary } ) ;
} ) ;
}
} ) ,
) ;
return new HttpSuccess ( ) ;
}
/ * *
* API อ อ ก ค ำ ส ั ่ ง C - PM - 34
*
* @summary อ อ ก ค ำ ส ั ่ ง C - PM - 34
*
* @param { string } id Guid , * Id ผ ั ง เ ง ิ น เ ด ื อ น
* /
@Post ( "command34/officer/report/excecute" )
async SalaryReportExcecute34 (
@Body ( )
body : {
refIds : {
refId : string ;
// commandAffectDate: Date | null;//เก่า
commandDateAffect : Date | null ; //ใหม่ (ปรับตาม rabbitMQ ORG)
commandNo : string | null ;
commandYear : number | null ;
commandId : string | null ;
remark : string | null ;
amount : Double | null ;
amountSpecial? : Double | null ;
positionSalaryAmount : Double | null ;
mouthSalaryAmount : Double | null ;
commandCode? : string | null ;
commandName? : string | null ;
commandDateSign : Date | null ;
} [ ] ;
} ,
@Request ( ) request : RequestWithUser ,
) {
await Promise . all (
body . refIds . map ( async ( v ) = > {
const salary = await this . salaryProfileRepository . findOne ( {
where : {
id : v.refId ,
} ,
} ) ;
if ( salary != null ) {
await new CallAPI ( )
. PostData ( request , "/org/profile/salary/update" , {
profileId : salary.profileId ,
commandDateAffect : v.commandDateAffect ,
commandDateSign : v.commandDateSign ,
amount : v.amount ,
amountSpecial : v.amountSpecial ,
positionSalaryAmount : v.positionSalaryAmount ,
mouthSalaryAmount : v.mouthSalaryAmount ,
posNo : salary.posMasterNo.toString ( ) ,
posNoAbb : salary.orgShortName ,
positionName : salary.position ,
positionExecutive : salary.posExecutive ,
2025-06-17 18:17:49 +07:00
positionExecutiveField : salary.positionExecutiveField ,
positionArea : salary.positionArea ,
2025-03-19 12:03:25 +07:00
positionType : salary.posType ,
positionLevel : salary.posLevel ,
commandId : v.commandId ,
remark : v.remark ,
orgRoot : salary.root ,
orgChild1 : salary.child1 ,
orgChild2 : salary.child2 ,
orgChild3 : salary.child3 ,
orgChild4 : salary.child4 ,
commandCode : v.commandCode ,
commandName : v.commandName ,
commandNo : v.commandNo ,
commandYear : v.commandYear ,
} )
. then ( async ( ) = > {
const before = null ;
salary . status34 = "DONE" ;
salary . lastUpdateUserId = request . user . sub ;
salary . lastUpdateFullName = request . user . name ;
salary . lastUpdatedAt = new Date ( ) ;
await this . salaryProfileRepository . save ( salary , { data : request } ) ;
setLogDataDiff ( request , { before , after : salary } ) ;
} ) ;
}
} ) ,
) ;
return new HttpSuccess ( ) ;
}
/ * *
* API อ อ ก ค ำ ส ั ่ ง C - PM - 35
*
* @summary อ อ ก ค ำ ส ั ่ ง C - PM - 35
*
* @param { string } id Guid , * Id ผ ั ง เ ง ิ น เ ด ื อ น
* /
@Post ( "command35/officer/report/excecute" )
async SalaryReportExcecute35 (
@Body ( )
body : {
refIds : {
refId : string ;
// commandAffectDate: Date | null;//เก่า
commandDateAffect : Date | null ; //ใหม่ (ปรับตาม rabbitMQ ORG)
commandNo : string | null ;
commandYear : number | null ;
commandId : string | null ;
remark : string | null ;
amount : Double | null ;
amountSpecial? : Double | null ;
positionSalaryAmount : Double | null ;
mouthSalaryAmount : Double | null ;
commandCode? : string | null ;
commandName? : string | null ;
commandDateSign : Date | null ;
} [ ] ;
} ,
@Request ( ) request : RequestWithUser ,
) {
await Promise . all (
body . refIds . map ( async ( v ) = > {
const salary = await this . salaryProfileRepository . findOne ( {
where : {
id : v.refId ,
} ,
} ) ;
if ( salary != null ) {
await new CallAPI ( )
. PostData ( request , "/org/profile/salary/update" , {
profileId : salary.profileId ,
commandDateAffect : v.commandDateAffect ,
commandDateSign : v.commandDateSign ,
amount : v.amount ,
amountSpecial : v.amountSpecial ,
positionSalaryAmount : v.positionSalaryAmount ,
mouthSalaryAmount : v.mouthSalaryAmount ,
posNo : salary.posMasterNo.toString ( ) ,
posNoAbb : salary.orgShortName ,
positionName : salary.position ,
positionExecutive : salary.posExecutive ,
2025-06-17 18:17:49 +07:00
positionExecutiveField : salary.positionExecutiveField ,
positionArea : salary.positionArea ,
2025-03-19 12:03:25 +07:00
positionType : salary.posType ,
positionLevel : salary.posLevel ,
commandId : v.commandId ,
remark : v.remark ,
orgRoot : salary.root ,
orgChild1 : salary.child1 ,
orgChild2 : salary.child2 ,
orgChild3 : salary.child3 ,
orgChild4 : salary.child4 ,
commandCode : v.commandCode ,
commandName : v.commandName ,
commandNo : v.commandNo ,
commandYear : v.commandYear ,
} )
. then ( async ( ) = > {
const before = null ;
salary . status35 = "DONE" ;
salary . lastUpdateUserId = request . user . sub ;
salary . lastUpdateFullName = request . user . name ;
salary . lastUpdatedAt = new Date ( ) ;
await this . salaryProfileRepository . save ( salary , { data : request } ) ;
setLogDataDiff ( request , { before , after : salary } ) ;
} ) ;
}
} ) ,
) ;
return new HttpSuccess ( ) ;
}
/ * *
* API อ อ ก ค ำ ส ั ่ ง C - PM - 36
*
* @summary อ อ ก ค ำ ส ั ่ ง C - PM - 36
*
* @param { string } id Guid , * Id ผ ั ง เ ง ิ น เ ด ื อ น
* /
@Post ( "command36/employee/report/excecute" )
async SalaryEmployeeReportExcecute36 (
@Body ( )
body : {
refIds : {
refId : string ;
// commandAffectDate: Date | null;//เก่า
commandDateAffect : Date | null ; //ใหม่ (ปรับตาม rabbitMQ ORG)
commandDateSign? : Date | null ;
commandNo : string | null ;
commandYear : number | null ;
commandId : string | null ;
commandCode? : string | null ;
commandName? : string | null ;
templateDoc? : string | null ;
amount : Double | null ;
amountSpecial? : Double | null ;
positionSalaryAmount : Double | null ;
mouthSalaryAmount : Double | null ;
mpCee? : string | null ;
refCommandCode? : string | null ;
refCommandName? : string | null ;
remark? : string | null ;
} [ ] ;
} ,
@Request ( ) request : RequestWithUser ,
) {
await Promise . all (
body . refIds . map ( async ( v ) = > {
const salary = await this . salaryProfileEmployeeRepository . findOne ( {
where : {
id : v.refId ,
} ,
} ) ;
2025-04-05 18:12:02 +07:00
2025-03-19 12:03:25 +07:00
if ( salary != null ) {
await new CallAPI ( )
. PostData ( request , "/org/profile-employee/salary/update" , {
profileEmployeeId : salary.profileId ,
commandDateAffect : v.commandDateAffect ,
commandDateSign : v.commandDateSign ,
amount : v.amount ,
amountSpecial : v.amountSpecial ,
positionSalaryAmount : v.positionSalaryAmount ,
mouthSalaryAmount : v.mouthSalaryAmount ,
posNo : salary.posMasterNo != null ? salary . posMasterNo . toString ( ) : null ,
posNoAbb : salary.orgShortName ,
positionName : salary.position ,
positionType : salary.posType ,
2025-04-05 18:12:02 +07:00
positionLevel :
( salary . posTypeShort != null ? salary . posTypeShort + " " : "" ) +
( salary . posLevel != null ? salary . posLevel . toString ( ) : "" ) ,
2025-03-19 12:03:25 +07:00
remark : v.remark ,
orgRoot : salary.root ,
orgChild1 : salary.child1 ,
orgChild2 : salary.child2 ,
orgChild3 : salary.child3 ,
orgChild4 : salary.child4 ,
commandCode : v.commandCode ,
commandName : v.commandName ,
commandNo : v.commandNo ,
commandYear : v.commandYear ,
commandId : v.commandId ,
2025-05-01 16:31:25 +07:00
salaryLevel :
salary . salaryLevel && salary . salaryLevelNew
? salary . salaryLevelNew
: salary . salaryLevel ,
2025-05-27 17:45:05 +07:00
group : salary.groupNew ? ? salary . group ,
2025-03-19 12:03:25 +07:00
} )
. then ( async ( ) = > {
const before = null ;
salary . status36 = "DONE" ;
salary . lastUpdateUserId = request . user . sub ;
salary . lastUpdateFullName = request . user . name ;
salary . lastUpdatedAt = new Date ( ) ;
await this . salaryProfileEmployeeRepository . save ( salary , { data : request } ) ;
setLogDataDiff ( request , { before , after : salary } ) ;
} ) ;
}
} ) ,
) ;
return new HttpSuccess ( ) ;
}
/ * *
* API อ อ ก ค ำ ส ั ่ ง C - PM - 37
*
* @summary อ อ ก ค ำ ส ั ่ ง C - PM - 37
*
* @param { string } id Guid , * Id ผ ั ง เ ง ิ น เ ด ื อ น
* /
@Post ( "command37/employee/report/excecute" )
async SalaryEmployeeReportExcecute37 (
@Body ( )
body : {
refIds : {
refId : string ;
// commandAffectDate: Date | null;//เก่า
commandDateAffect : Date | null ; //ใหม่ (ปรับตาม rabbitMQ ORG)
commandDateSign? : Date | null ;
commandNo : string | null ;
commandYear : number | null ;
commandId : string | null ;
commandCode? : string | null ;
commandName? : string | null ;
templateDoc? : string | null ;
amount : Double | null ;
amountSpecial? : Double | null ;
positionSalaryAmount : Double | null ;
mouthSalaryAmount : Double | null ;
mpCee? : string | null ;
refCommandCode? : string | null ;
refCommandName? : string | null ;
remark? : string | null ;
} [ ] ;
} ,
@Request ( ) request : RequestWithUser ,
2024-10-04 17:14:16 +07:00
) {
await Promise . all (
body . refIds . map ( async ( v ) = > {
const salary = await this . salaryProfileEmployeeRepository . findOne ( {
where : {
id : v.refId ,
} ,
} ) ;
2025-03-10 12:53:11 +07:00
2024-10-04 17:14:16 +07:00
if ( salary != null ) {
await new CallAPI ( )
2024-11-15 14:52:52 +07:00
. PostData ( request , "/org/profile-employee/salary/update" , {
2024-10-04 17:14:16 +07:00
profileEmployeeId : salary.profileId ,
2025-02-21 19:00:24 +07:00
commandDateAffect : v.commandDateAffect ,
commandDateSign : v.commandDateSign ,
2024-10-30 10:23:36 +07:00
amount : v.amount ,
2025-01-20 17:26:32 +07:00
amountSpecial : v.amountSpecial ,
2024-10-30 10:23:36 +07:00
positionSalaryAmount : v.positionSalaryAmount ,
mouthSalaryAmount : v.mouthSalaryAmount ,
2025-03-10 12:53:11 +07:00
posNo : salary.posMasterNo != null ? salary . posMasterNo . toString ( ) : null ,
2025-02-21 19:00:24 +07:00
posNoAbb : salary.orgShortName ,
positionName : salary.position ,
2024-10-04 17:14:16 +07:00
positionType : salary.posType ,
2025-04-05 18:12:02 +07:00
positionLevel :
( salary . posTypeShort != null ? salary . posTypeShort + " " : "" ) +
( salary . posLevel != null ? salary . posLevel . toString ( ) : "" ) ,
2025-02-21 19:00:24 +07:00
remark : v.remark ,
orgRoot : salary.root ,
orgChild1 : salary.child1 ,
orgChild2 : salary.child2 ,
orgChild3 : salary.child3 ,
orgChild4 : salary.child4 ,
commandCode : v.commandCode ,
commandName : v.commandName ,
commandNo : v.commandNo ,
commandYear : v.commandYear ,
2025-02-26 11:02:33 +07:00
commandId : v.commandId ,
2025-05-01 16:31:25 +07:00
salaryLevel :
salary . salaryLevel && salary . salaryLevelNew
? salary . salaryLevelNew
: salary . salaryLevel ,
2025-05-27 17:45:05 +07:00
group : salary.groupNew ? ? salary . group ,
2024-10-04 17:14:16 +07:00
} )
. then ( async ( ) = > {
const before = null ;
2025-03-19 12:03:25 +07:00
salary . status37 = "DONE" ;
2024-10-04 17:14:16 +07:00
salary . lastUpdateUserId = request . user . sub ;
salary . lastUpdateFullName = request . user . name ;
salary . lastUpdatedAt = new Date ( ) ;
await this . salaryProfileEmployeeRepository . save ( salary , { data : request } ) ;
setLogDataDiff ( request , { before , after : salary } ) ;
} ) ;
}
} ) ,
) ;
return new HttpSuccess ( ) ;
}
2024-10-30 10:23:36 +07:00
2024-10-24 09:30:45 +07:00
/ * *
2025-03-19 12:03:25 +07:00
* API อ อ ก ค ำ ส ั ่ ง C - PM - 33
2024-10-24 09:30:45 +07:00
*
2025-03-19 12:03:25 +07:00
* @summary อ อ ก ค ำ ส ั ่ ง C - PM - 33
2024-10-24 09:30:45 +07:00
*
* @param { string } id Guid , * Id ผ ั ง เ ง ิ น เ ด ื อ น
* /
2025-03-19 12:03:25 +07:00
@Post ( "command33/officer/report/delete" )
async SalaryOfficerReportCommandDelete33 (
2024-10-24 09:30:45 +07:00
@Body ( )
body : {
refIds : string [ ] ;
} ,
@Request ( ) request : RequestWithUser ,
) {
const salaryProfile = await this . salaryProfileRepository . find ( {
where : { id : In ( body . refIds ) } ,
} ) ;
const data = salaryProfile . map ( ( _data ) = > ( {
. . . _data ,
2025-03-19 12:03:25 +07:00
status33 : "PENDING" ,
2024-10-24 09:30:45 +07:00
} ) ) ;
await this . salaryProfileRepository . save ( data ) ;
return new HttpSuccess ( ) ;
}
2024-10-30 10:23:36 +07:00
2024-10-24 09:30:45 +07:00
/ * *
2025-03-19 12:03:25 +07:00
* API อ อ ก ค ำ ส ั ่ ง C - PM - 34
2024-10-24 09:30:45 +07:00
*
2025-03-19 12:03:25 +07:00
* @summary อ อ ก ค ำ ส ั ่ ง C - PM - 34
2024-10-24 09:30:45 +07:00
*
* @param { string } id Guid , * Id ผ ั ง เ ง ิ น เ ด ื อ น
* /
2025-03-19 12:03:25 +07:00
@Post ( "command34/officer/report/delete" )
async SalaryOfficerReportCommandDelete34 (
@Body ( )
body : {
refIds : string [ ] ;
} ,
@Request ( ) request : RequestWithUser ,
) {
const salaryProfile = await this . salaryProfileRepository . find ( {
where : { id : In ( body . refIds ) } ,
} ) ;
const data = salaryProfile . map ( ( _data ) = > ( {
. . . _data ,
status34 : "PENDING" ,
} ) ) ;
await this . salaryProfileRepository . save ( data ) ;
return new HttpSuccess ( ) ;
}
/ * *
* API อ อ ก ค ำ ส ั ่ ง C - PM - 35
*
* @summary อ อ ก ค ำ ส ั ่ ง C - PM - 35
*
* @param { string } id Guid , * Id ผ ั ง เ ง ิ น เ ด ื อ น
* /
@Post ( "command35/officer/report/delete" )
async SalaryOfficerReportCommandDelete35 (
@Body ( )
body : {
refIds : string [ ] ;
} ,
@Request ( ) request : RequestWithUser ,
) {
const salaryProfile = await this . salaryProfileRepository . find ( {
where : { id : In ( body . refIds ) } ,
} ) ;
const data = salaryProfile . map ( ( _data ) = > ( {
. . . _data ,
status35 : "PENDING" ,
} ) ) ;
await this . salaryProfileRepository . save ( data ) ;
return new HttpSuccess ( ) ;
}
/ * *
* API อ อ ก ค ำ ส ั ่ ง C - PM - 36
*
* @summary อ อ ก ค ำ ส ั ่ ง C - PM - 36
*
* @param { string } id Guid , * Id ผ ั ง เ ง ิ น เ ด ื อ น
* /
@Post ( "command36/employee/report/delete" )
async SalaryEmployeeReportCommandDelete36 (
@Body ( )
body : {
refIds : string [ ] ;
} ,
@Request ( ) request : RequestWithUser ,
) {
const salaryProfile = await this . salaryProfileEmployeeRepository . find ( {
where : { id : In ( body . refIds ) } ,
} ) ;
const data = salaryProfile . map ( ( _data ) = > ( {
. . . _data ,
status36 : "PENDING" ,
} ) ) ;
await this . salaryProfileEmployeeRepository . save ( data ) ;
return new HttpSuccess ( ) ;
}
/ * *
* API อ อ ก ค ำ ส ั ่ ง C - PM - 37
*
* @summary อ อ ก ค ำ ส ั ่ ง C - PM - 37
*
* @param { string } id Guid , * Id ผ ั ง เ ง ิ น เ ด ื อ น
* /
@Post ( "command37/employee/report/delete" )
async SalaryEmployeeReportCommandDelete37 (
2024-10-24 09:30:45 +07:00
@Body ( )
body : {
refIds : string [ ] ;
} ,
@Request ( ) request : RequestWithUser ,
) {
const salaryProfile = await this . salaryProfileEmployeeRepository . find ( {
where : { id : In ( body . refIds ) } ,
} ) ;
const data = salaryProfile . map ( ( _data ) = > ( {
. . . _data ,
2025-03-19 12:03:25 +07:00
status37 : "PENDING" ,
2024-10-24 09:30:45 +07:00
} ) ) ;
await this . salaryProfileEmployeeRepository . save ( data ) ;
2024-10-04 17:14:16 +07:00
return new HttpSuccess ( ) ;
}
2024-02-19 15:23:03 +07:00
}