diff --git a/src/controllers/SalaryPeriodController.ts b/src/controllers/SalaryPeriodController.ts index 02cea59..fdc1f50 100644 --- a/src/controllers/SalaryPeriodController.ts +++ b/src/controllers/SalaryPeriodController.ts @@ -1418,6 +1418,40 @@ export class SalaryPeriodController extends Controller { return new HttpSuccess(salaryPeriod); } + /** + * API รายการรอบเงินเดือน by year + * + * @summary SLR_020 - รายการรอบเงินเดือน by year + * + */ + @Get("active/{year}") + async GetListsSalaryPeriodByYear( + @Path() year: number, + @Query("page") page: number = 1, + @Query("pageSize") pageSize: number = 10, + @Query("keyword") keyword?: string, + ) { + const [salaryPeriod, total] = await AppDataSource.getRepository(SalaryPeriod) + .createQueryBuilder("salaryPeriod") + .andWhere(year != 0 ? "salaryPeriod.year LIKE :year" : "1=1", { year: `${year}` }) + .select([ + "salaryPeriod.id", + "salaryPeriod.period", + "salaryPeriod.isActive", + "salaryPeriod.isClose", + "salaryPeriod.effectiveDate", + "salaryPeriod.status", + "salaryPeriod.year", + "salaryPeriod.revisionId", + ]) + .orderBy("salaryPeriod.effectiveDate", "DESC") + .skip((page - 1) * pageSize) + .take(pageSize) + .getManyAndCount(); + + return new HttpSuccess({ data: salaryPeriod, total }); + } + /** * API รายการรอบเงินเดือน *