diff --git a/prisma/schema.prisma b/prisma/schema.prisma index 60503eb..fd3b522 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -14,48 +14,48 @@ datasource db { url = env("DATABASE_URL_DEV") } -model Users { - id String @id @default(dbgenerated("gen_random_uuid()")) @db.Uuid - first_name String - last_name String - email String @unique - phone_number String @unique - residence String? - role Roles @default(GUEST) +// model Users { +// id String @id @default(dbgenerated("gen_random_uuid()")) @db.Uuid +// first_name String +// last_name String +// email String @unique +// phone_number String @unique +// residence String? +// role Roles @default(GUEST) - employee Employees? @relation("UserEmployee") - oauth_sessions OAuthSessions[] @relation("UserOAuthSessions") - preferences Preferences? @relation("UserPreferences") +// employee Employees? @relation("UserEmployee") +// oauth_sessions OAuthSessions[] @relation("UserOAuthSessions") +// preferences Preferences? @relation("UserPreferences") - @@map("users") -} +// @@map("users") +// } -model Employees { - id Int @id @default(autoincrement()) - user Users @relation("UserEmployee", fields: [user_id], references: [id]) - user_id String @unique @db.Uuid - supervisor Employees? @relation("EmployeeSupervisor", fields: [supervisor_id], references: [id]) - supervisor_id Int? +// model Employees { +// id Int @id @default(autoincrement()) +// user Users @relation("UserEmployee", fields: [user_id], references: [id]) +// user_id String @unique @db.Uuid +// supervisor Employees? @relation("EmployeeSupervisor", fields: [supervisor_id], references: [id]) +// supervisor_id Int? - external_payroll_id Int - company_code Int - first_work_day DateTime @db.Date - last_work_day DateTime? @db.Date - job_title String? - is_supervisor Boolean @default(false) +// external_payroll_id Int +// company_code Int +// first_work_day DateTime @db.Date +// last_work_day DateTime? @db.Date +// job_title String? +// is_supervisor Boolean @default(false) - crew Employees[] @relation("EmployeeSupervisor") - timesheet Timesheets[] @relation("TimesheetEmployee") - leave_request LeaveRequests[] @relation("LeaveRequestEmployee") - schedule_presets SchedulePresets[] @relation("SchedulePreset") +// crew Employees[] @relation("EmployeeSupervisor") +// timesheet Timesheets[] @relation("TimesheetEmployee") +// leave_request LeaveRequests[] @relation("LeaveRequestEmployee") +// schedule_presets SchedulePresets[] @relation("SchedulePreset") - @@map("employees") -} +// @@map("employees") +// } model LeaveRequests { id Int @id @default(autoincrement()) - employee Employees @relation("LeaveRequestEmployee", fields: [employee_id], references: [id]) + // employee Employees @relation("LeaveRequestEmployee", fields: [employee_id], references: [id]) employee_id Int bank_code BankCodes @relation("LeaveRequestBankCodes", fields: [bank_code_id], references: [id]) bank_code_id Int @@ -107,7 +107,7 @@ view PayPeriods { model Timesheets { id Int @id @default(autoincrement()) - employee Employees @relation("TimesheetEmployee", fields: [employee_id], references: [id]) + // employee Employees @relation("TimesheetEmployee", fields: [employee_id], references: [id]) employee_id Int start_date DateTime @db.Date @@ -135,7 +135,7 @@ model TimesheetsArchive { model SchedulePresets { id Int @id @default(autoincrement()) - employee Employees @relation("SchedulePreset", fields: [employee_id], references: [id]) + // employee Employees @relation("SchedulePreset", fields: [employee_id], references: [id]) employee_id Int name String @@ -258,7 +258,7 @@ model ExpensesArchive { model OAuthSessions { id String @id @default(cuid()) - user Users @relation("UserOAuthSessions", fields: [user_id], references: [id]) + // user Users @relation("UserOAuthSessions", fields: [user_id], references: [id]) user_id String @db.Uuid application String access_token String @unique @@ -327,7 +327,7 @@ model AttachmentVariants { model Preferences { id Int @id @default(autoincrement()) - user Users @relation("UserPreferences", fields: [user_id], references: [id]) + // user Users @relation("UserPreferences", fields: [user_id], references: [id]) user_id String @unique @db.Uuid notifications Int @default(0) diff --git a/src/app.module.ts b/src/app.module.ts index 901f74e..4519929 100644 --- a/src/app.module.ts +++ b/src/app.module.ts @@ -3,7 +3,7 @@ import { AppController } from './app.controller'; import { AppService } from './app.service'; // import { ArchivalModule } from './modules/archival/archival.module'; import { AuthenticationModule } from './modules/authentication/auth.module'; -import { BankCodesModule } from './modules/bank-codes/bank-codes.module'; +// import { BankCodesModule } from './modules/bank-codes/bank-codes.module'; // import { CsvExportModule } from './modules/exports/csv-exports.module'; import { HealthModule } from './health/health.module'; import { HealthController } from './health/health.controller'; @@ -23,7 +23,7 @@ import { TimeAndAttendanceModule } from 'src/time-and-attendance/time-and-attend @Module({ imports: [ AuthenticationModule, - BankCodesModule, + // BankCodesModule, ConfigModule.forRoot({isGlobal: true}), // CsvExportModule, // CustomersModule, diff --git a/src/modules/archival/controllers/expenses-archive.controller.ts b/src/modules/archival/controllers/expenses-archive.controller.ts index f256b82..ecfd7b8 100644 --- a/src/modules/archival/controllers/expenses-archive.controller.ts +++ b/src/modules/archival/controllers/expenses-archive.controller.ts @@ -1,32 +1,32 @@ -import { UseGuards, Controller, Get, Param, ParseIntPipe, NotFoundException } from "@nestjs/common"; -import { ApiTags, ApiOperation, ApiResponse } from "@nestjs/swagger"; -import { ExpensesArchive,Roles as RoleEnum } from "@prisma/client"; -import { RolesAllowed } from "src/common/decorators/roles.decorators"; -import { ExpensesArchivalService } from "src/time-and-attendance/modules/expenses/services/expenses-archival.service"; +// import { UseGuards, Controller, Get, Param, ParseIntPipe, NotFoundException } from "@nestjs/common"; +// import { ApiTags, ApiOperation, ApiResponse } from "@nestjs/swagger"; +// import { ExpensesArchive,Roles as RoleEnum } from "@prisma/client"; +// import { RolesAllowed } from "src/common/decorators/roles.decorators"; +// import { ExpensesArchivalService } from "src/time-and-attendance/modules/expenses/services/expenses-archival.service"; -@ApiTags('Expense Archives') -// @UseGuards() -@Controller('archives/expenses') -export class ExpensesArchiveController { - constructor(private readonly expensesService: ExpensesArchivalService) {} +// @ApiTags('Expense Archives') +// // @UseGuards() +// @Controller('archives/expenses') +// export class ExpensesArchiveController { +// constructor(private readonly expensesService: ExpensesArchivalService) {} - @Get() - //@RolesAllowed(RoleEnum.ADMIN, RoleEnum.HR, RoleEnum.SUPERVISOR) - @ApiOperation({ summary: 'List of archived expenses'}) - @ApiResponse({ status: 200, description: 'List of archived expenses', isArray: true }) - async findAllArchived(): Promise { - return this.expensesService.findAllArchived(); - } +// @Get() +// //@RolesAllowed(RoleEnum.ADMIN, RoleEnum.HR, RoleEnum.SUPERVISOR) +// @ApiOperation({ summary: 'List of archived expenses'}) +// @ApiResponse({ status: 200, description: 'List of archived expenses', isArray: true }) +// async findAllArchived(): Promise { +// return this.expensesService.findAllArchived(); +// } - @Get() - //@RolesAllowed(RoleEnum.ADMIN, RoleEnum.HR, RoleEnum.SUPERVISOR) - @ApiOperation({ summary: 'Fetch expense in archives with its Id'}) - @ApiResponse({ status: 200, description: 'Archived expense found'}) - async findOneArchived(@Param('id', ParseIntPipe) id: number ): Promise { - try{ - return await this.expensesService.findOneArchived(id); - }catch { - throw new NotFoundException(`Archived expense #${id} not found`); - } - } -} \ No newline at end of file +// @Get() +// //@RolesAllowed(RoleEnum.ADMIN, RoleEnum.HR, RoleEnum.SUPERVISOR) +// @ApiOperation({ summary: 'Fetch expense in archives with its Id'}) +// @ApiResponse({ status: 200, description: 'Archived expense found'}) +// async findOneArchived(@Param('id', ParseIntPipe) id: number ): Promise { +// try{ +// return await this.expensesService.findOneArchived(id); +// }catch { +// throw new NotFoundException(`Archived expense #${id} not found`); +// } +// } +// } \ No newline at end of file diff --git a/src/modules/archival/controllers/leave-requests-archive.controller.ts b/src/modules/archival/controllers/leave-requests-archive.controller.ts index 1c5e4be..ec1b046 100644 --- a/src/modules/archival/controllers/leave-requests-archive.controller.ts +++ b/src/modules/archival/controllers/leave-requests-archive.controller.ts @@ -1,7 +1,7 @@ -import { Controller } from '@nestjs/common'; -import { ApiTags } from '@nestjs/swagger'; +// import { Controller } from '@nestjs/common'; +// import { ApiTags } from '@nestjs/swagger'; -@ApiTags('LeaveRequests Archives') -// @UseGuards() -@Controller('archives/leaveRequests') -export class LeaveRequestsArchiveController {} \ No newline at end of file +// @ApiTags('LeaveRequests Archives') +// // @UseGuards() +// @Controller('archives/leaveRequests') +// export class LeaveRequestsArchiveController {} \ No newline at end of file diff --git a/src/modules/archival/controllers/shifts-archive.controller.ts b/src/modules/archival/controllers/shifts-archive.controller.ts index 7c88288..f322fa1 100644 --- a/src/modules/archival/controllers/shifts-archive.controller.ts +++ b/src/modules/archival/controllers/shifts-archive.controller.ts @@ -1,32 +1,32 @@ -import { Get, Param, ParseIntPipe, NotFoundException, Controller, UseGuards } from "@nestjs/common"; -import { ApiOperation, ApiResponse, ApiTags } from "@nestjs/swagger"; -import { ShiftsArchive, Roles as RoleEnum } from "@prisma/client"; -import { RolesAllowed } from "src/common/decorators/roles.decorators"; -import { ShiftsArchivalService } from "src/time-and-attendance/modules/time-tracker/shifts/services/shifts-archival.service"; +// import { Get, Param, ParseIntPipe, NotFoundException, Controller, UseGuards } from "@nestjs/common"; +// import { ApiOperation, ApiResponse, ApiTags } from "@nestjs/swagger"; +// import { ShiftsArchive, Roles as RoleEnum } from "@prisma/client"; +// import { RolesAllowed } from "src/common/decorators/roles.decorators"; +// import { ShiftsArchivalService } from "src/time-and-attendance/modules/time-tracker/shifts/services/shifts-archival.service"; -@ApiTags('Shift Archives') -// @UseGuards() -@Controller('archives/shifts') -export class ShiftsArchiveController { - constructor(private readonly shiftsService: ShiftsArchivalService) {} +// @ApiTags('Shift Archives') +// // @UseGuards() +// @Controller('archives/shifts') +// export class ShiftsArchiveController { +// constructor(private readonly shiftsService: ShiftsArchivalService) {} - @Get() - //@RolesAllowed(RoleEnum.ADMIN, RoleEnum.HR, RoleEnum.SUPERVISOR) - @ApiOperation({ summary: 'List of archived shifts'}) - @ApiResponse({ status: 200, description: 'List of archived shifts', isArray: true }) - async findAllArchived(): Promise { - return this.shiftsService.findAllArchived(); - } +// @Get() +// //@RolesAllowed(RoleEnum.ADMIN, RoleEnum.HR, RoleEnum.SUPERVISOR) +// @ApiOperation({ summary: 'List of archived shifts'}) +// @ApiResponse({ status: 200, description: 'List of archived shifts', isArray: true }) +// async findAllArchived(): Promise { +// return this.shiftsService.findAllArchived(); +// } - @Get() - //@RolesAllowed(RoleEnum.ADMIN, RoleEnum.HR,RoleEnum.SUPERVISOR) - @ApiOperation({ summary: 'Fetch shift in archives with its Id'}) - @ApiResponse({ status: 200, description: 'Archived shift found'}) - async findOneArchived(@Param('id', ParseIntPipe) id: number ): Promise { - try{ - return await this.shiftsService.findOneArchived(id); - }catch { - throw new NotFoundException(`Archived shift #${id} not found`); - } - } -} \ No newline at end of file +// @Get() +// //@RolesAllowed(RoleEnum.ADMIN, RoleEnum.HR,RoleEnum.SUPERVISOR) +// @ApiOperation({ summary: 'Fetch shift in archives with its Id'}) +// @ApiResponse({ status: 200, description: 'Archived shift found'}) +// async findOneArchived(@Param('id', ParseIntPipe) id: number ): Promise { +// try{ +// return await this.shiftsService.findOneArchived(id); +// }catch { +// throw new NotFoundException(`Archived shift #${id} not found`); +// } +// } +// } \ No newline at end of file diff --git a/src/modules/archival/controllers/timesheets-archive.controller.ts b/src/modules/archival/controllers/timesheets-archive.controller.ts index 3a8f0a2..888dc3c 100644 --- a/src/modules/archival/controllers/timesheets-archive.controller.ts +++ b/src/modules/archival/controllers/timesheets-archive.controller.ts @@ -1,33 +1,33 @@ -import { Controller, Get, NotFoundException, Param, ParseIntPipe, UseGuards } from "@nestjs/common"; -import { ApiOperation, ApiResponse, ApiTags } from "@nestjs/swagger"; -import { RolesAllowed } from "src/common/decorators/roles.decorators"; -import { TimesheetsArchive, Roles as RoleEnum } from '@prisma/client'; -import { TimesheetArchiveService } from "src/time-and-attendance/modules/time-tracker/timesheets/services/timesheet-archive.service"; +// import { Controller, Get, NotFoundException, Param, ParseIntPipe, UseGuards } from "@nestjs/common"; +// import { ApiOperation, ApiResponse, ApiTags } from "@nestjs/swagger"; +// import { RolesAllowed } from "src/common/decorators/roles.decorators"; +// import { TimesheetsArchive, Roles as RoleEnum } from '@prisma/client'; +// import { TimesheetArchiveService } from "src/time-and-attendance/modules/time-tracker/timesheets/services/timesheet-archive.service"; -@ApiTags('Timesheet Archives') -// @UseGuards() -@Controller('archives/timesheets') -export class TimesheetsArchiveController { - constructor(private readonly timesheetsService: TimesheetArchiveService) {} +// @ApiTags('Timesheet Archives') +// // @UseGuards() +// @Controller('archives/timesheets') +// export class TimesheetsArchiveController { +// constructor(private readonly timesheetsService: TimesheetArchiveService) {} - @Get() - //@RolesAllowed(RoleEnum.ADMIN, RoleEnum.HR, RoleEnum.SUPERVISOR) - @ApiOperation({ summary: 'List of archived timesheets'}) - @ApiResponse({ status: 200, description: 'List of archived timesheets', isArray: true }) - async findAllArchived(): Promise { - return this.timesheetsService.findAllArchived(); - } +// @Get() +// //@RolesAllowed(RoleEnum.ADMIN, RoleEnum.HR, RoleEnum.SUPERVISOR) +// @ApiOperation({ summary: 'List of archived timesheets'}) +// @ApiResponse({ status: 200, description: 'List of archived timesheets', isArray: true }) +// async findAllArchived(): Promise { +// return this.timesheetsService.findAllArchived(); +// } - @Get() - //@RolesAllowed(RoleEnum.ADMIN, RoleEnum.HR, RoleEnum.SUPERVISOR) - @ApiOperation({ summary: 'Fetch timesheet in archives with its Id'}) - @ApiResponse({ status: 200, description: 'Archived timesheet found'}) - async findOneArchived(@Param('id', ParseIntPipe) id: number ): Promise { - try{ - return await this.timesheetsService.findOneArchived(id); - }catch { - throw new NotFoundException(`Archived timesheet #${id} not found`); - } - } +// @Get() +// //@RolesAllowed(RoleEnum.ADMIN, RoleEnum.HR, RoleEnum.SUPERVISOR) +// @ApiOperation({ summary: 'Fetch timesheet in archives with its Id'}) +// @ApiResponse({ status: 200, description: 'Archived timesheet found'}) +// async findOneArchived(@Param('id', ParseIntPipe) id: number ): Promise { +// try{ +// return await this.timesheetsService.findOneArchived(id); +// }catch { +// throw new NotFoundException(`Archived timesheet #${id} not found`); +// } +// } -} \ No newline at end of file +// } \ No newline at end of file diff --git a/src/modules/archival/services/archival.service.ts b/src/modules/archival/services/archival.service.ts index ded45eb..bed4191 100644 --- a/src/modules/archival/services/archival.service.ts +++ b/src/modules/archival/services/archival.service.ts @@ -1,38 +1,38 @@ -import { Injectable, Logger } from "@nestjs/common"; -import { Cron } from "@nestjs/schedule"; -import { ExpensesArchivalService } from "src/time-and-attendance/modules/expenses/services/expenses-archival.service"; -import { ShiftsArchivalService } from "src/time-and-attendance/modules/time-tracker/shifts/services/shifts-archival.service"; -import { TimesheetArchiveService } from "src/time-and-attendance/modules/time-tracker/timesheets/services/timesheet-archive.service"; +// import { Injectable, Logger } from "@nestjs/common"; +// import { Cron } from "@nestjs/schedule"; +// import { ExpensesArchivalService } from "src/time-and-attendance/modules/expenses/services/expenses-archival.service"; +// import { ShiftsArchivalService } from "src/time-and-attendance/modules/time-tracker/shifts/services/shifts-archival.service"; +// import { TimesheetArchiveService } from "src/time-and-attendance/modules/time-tracker/timesheets/services/timesheet-archive.service"; -@Injectable() -export class ArchivalService { - private readonly logger = new Logger(ArchivalService.name); +// @Injectable() +// export class ArchivalService { +// private readonly logger = new Logger(ArchivalService.name); - constructor( - private readonly timesheetsService: TimesheetArchiveService, - private readonly expensesService: ExpensesArchivalService, - private readonly shiftsService: ShiftsArchivalService, - ) {} +// constructor( +// private readonly timesheetsService: TimesheetArchiveService, +// private readonly expensesService: ExpensesArchivalService, +// private readonly shiftsService: ShiftsArchivalService, +// ) {} - @Cron('0 0 3 * * 1', {timeZone:'America/Toronto'}) // chaque premier lundi du mois à 03h00 - async handleMonthlyArchival() { - const today = new Date(); - const dayOfMonth = today.getDate(); +// @Cron('0 0 3 * * 1', {timeZone:'America/Toronto'}) // chaque premier lundi du mois à 03h00 +// async handleMonthlyArchival() { +// const today = new Date(); +// const dayOfMonth = today.getDate(); - if (dayOfMonth > 7) { - this.logger.warn('Archive {awaiting 1st monday of the month for archivation process}') - return; - } +// if (dayOfMonth > 7) { +// this.logger.warn('Archive {awaiting 1st monday of the month for archivation process}') +// return; +// } - this.logger.log('monthly archivation in process'); - try { - await this.timesheetsService.archiveOld(); - await this.expensesService.archiveOld(); - await this.shiftsService.archiveOld(); - // await this.leaveRequestsService.archiveExpired(); - this.logger.log('archivation process done'); - } catch (err) { - this.logger.error('an error occured during archivation process ', err); - } - } -} \ No newline at end of file +// this.logger.log('monthly archivation in process'); +// try { +// await this.timesheetsService.archiveOld(); +// await this.expensesService.archiveOld(); +// await this.shiftsService.archiveOld(); +// // await this.leaveRequestsService.archiveExpired(); +// this.logger.log('archivation process done'); +// } catch (err) { +// this.logger.error('an error occured during archivation process ', err); +// } +// } +// } \ No newline at end of file diff --git a/src/modules/attachments/controllers/attachments.controller.ts b/src/modules/attachments/controllers/attachments.controller.ts index 3a75d6a..4999771 100644 --- a/src/modules/attachments/controllers/attachments.controller.ts +++ b/src/modules/attachments/controllers/attachments.controller.ts @@ -4,9 +4,7 @@ import { Controller,NotFoundException, UseInterceptors, Post, Get, Param, Res, UploadedFile, BadRequestException, UnsupportedMediaTypeException, Body, Delete, Query, - DefaultValuePipe, - ParseIntPipe - } from "@nestjs/common"; +} from "@nestjs/common"; import { maxUploadBytes, allowedMimes } from "../config/upload.config"; import { memoryStorage } from 'multer'; import { fileTypeFromBuffer, fileTypeFromFile } from "file-type"; diff --git a/src/modules/bank-codes/bank-codes.module.ts b/src/modules/bank-codes/bank-codes.module.ts index 80ec6e3..816c440 100644 --- a/src/modules/bank-codes/bank-codes.module.ts +++ b/src/modules/bank-codes/bank-codes.module.ts @@ -1,11 +1,11 @@ -import { Module } from "@nestjs/common"; -import { PrismaService } from "src/prisma/prisma.service"; -import { BankCodesControllers } from "./controllers/bank-codes.controller"; -import { BankCodesService } from "./services/bank-codes.service"; +// import { Module } from "@nestjs/common"; +// import { PrismaService } from "src/prisma/prisma.service"; +// import { BankCodesControllers } from "./controllers/bank-codes.controller"; +// import { BankCodesService } from "./services/bank-codes.service"; -@Module({ - controllers: [BankCodesControllers], - providers: [BankCodesService, PrismaService], -}) +// @Module({ +// controllers: [BankCodesControllers], +// providers: [BankCodesService, PrismaService], +// }) -export class BankCodesModule {} \ No newline at end of file +// export class BankCodesModule {} \ No newline at end of file diff --git a/src/modules/bank-codes/controllers/bank-codes.controller.ts b/src/modules/bank-codes/controllers/bank-codes.controller.ts index 678336c..4588bbf 100644 --- a/src/modules/bank-codes/controllers/bank-codes.controller.ts +++ b/src/modules/bank-codes/controllers/bank-codes.controller.ts @@ -1,49 +1,49 @@ -import { Body, Controller, Delete, Get, Param, ParseIntPipe, Patch, Post } from "@nestjs/common"; -import { BankCodesService } from "../services/bank-codes.service"; -import { CreateBankCodeDto } from "../dtos/create-bank-code.dto"; -import { UpdateBankCodeDto } from "../dtos/update-bank-code.dto"; -import { ApiBadRequestResponse, ApiNotFoundResponse, ApiOperation, ApiResponse } from "@nestjs/swagger"; +// import { Body, Controller, Delete, Get, Param, ParseIntPipe, Patch, Post } from "@nestjs/common"; +// import { BankCodesService } from "../services/bank-codes.service"; +// import { CreateBankCodeDto } from "../dtos/create-bank-code.dto"; +// import { UpdateBankCodeDto } from "../dtos/update-bank-code.dto"; +// import { ApiBadRequestResponse, ApiNotFoundResponse, ApiOperation, ApiResponse } from "@nestjs/swagger"; -@Controller('bank-codes') -export class BankCodesControllers { - constructor(private readonly bankCodesService: BankCodesService) {} - //_____________________________________________________________________________________________ - // Deprecated or unused methods - //_____________________________________________________________________________________________ +// @Controller('bank-codes') +// export class BankCodesControllers { +// constructor(private readonly bankCodesService: BankCodesService) {} +// //_____________________________________________________________________________________________ +// // Deprecated or unused methods +// //_____________________________________________________________________________________________ - // @Post() - // @ApiOperation({ summary: 'Create a new bank code' }) - // @ApiResponse({ status: 201, description: 'Bank code successfully created.' }) - // @ApiBadRequestResponse({ description: 'Invalid input data.' }) - // create(@Body() dto: CreateBankCodeDto) { - // return this.bankCodesService.create(dto); - // } +// // @Post() +// // @ApiOperation({ summary: 'Create a new bank code' }) +// // @ApiResponse({ status: 201, description: 'Bank code successfully created.' }) +// // @ApiBadRequestResponse({ description: 'Invalid input data.' }) +// // create(@Body() dto: CreateBankCodeDto) { +// // return this.bankCodesService.create(dto); +// // } - // @Get() - // @ApiOperation({ summary: 'Retrieve all bank codes' }) - // @ApiResponse({ status: 200, description: 'List of bank codes.' }) - // findAll() { - // return this.bankCodesService.findAll(); - // } +// // @Get() +// // @ApiOperation({ summary: 'Retrieve all bank codes' }) +// // @ApiResponse({ status: 200, description: 'List of bank codes.' }) +// // findAll() { +// // return this.bankCodesService.findAll(); +// // } - // @Get(':id') - // @ApiOperation({ summary: 'Retrieve a bank code by its ID' }) - // @ApiNotFoundResponse({ description: 'Bank code not found.' }) - // findOne(@Param('id', ParseIntPipe) id: number){ - // return this.bankCodesService.findOne(id); - // } +// // @Get(':id') +// // @ApiOperation({ summary: 'Retrieve a bank code by its ID' }) +// // @ApiNotFoundResponse({ description: 'Bank code not found.' }) +// // findOne(@Param('id', ParseIntPipe) id: number){ +// // return this.bankCodesService.findOne(id); +// // } - // @Patch(':id') - // @ApiOperation({ summary: 'Update an existing bank code' }) - // @ApiNotFoundResponse({ description: 'Bank code not found.' }) - // update(@Param('id', ParseIntPipe) id: number, @Body() dto: UpdateBankCodeDto) { - // return this.bankCodesService.update(id, dto) - // } +// // @Patch(':id') +// // @ApiOperation({ summary: 'Update an existing bank code' }) +// // @ApiNotFoundResponse({ description: 'Bank code not found.' }) +// // update(@Param('id', ParseIntPipe) id: number, @Body() dto: UpdateBankCodeDto) { +// // return this.bankCodesService.update(id, dto) +// // } - // @Delete(':id') - // @ApiOperation({ summary: 'Delete a bank code' }) - // @ApiNotFoundResponse({ description: 'Bank code not found.' }) - // remove(@Param('id', ParseIntPipe) id: number) { - // return this.bankCodesService.remove(id); - // } -} \ No newline at end of file +// // @Delete(':id') +// // @ApiOperation({ summary: 'Delete a bank code' }) +// // @ApiNotFoundResponse({ description: 'Bank code not found.' }) +// // remove(@Param('id', ParseIntPipe) id: number) { +// // return this.bankCodesService.remove(id); +// // } +// } \ No newline at end of file diff --git a/src/modules/bank-codes/dtos/create-bank-code.dto.ts b/src/modules/bank-codes/dtos/create-bank-code.dto.ts index f2bec7b..a08020a 100644 --- a/src/modules/bank-codes/dtos/create-bank-code.dto.ts +++ b/src/modules/bank-codes/dtos/create-bank-code.dto.ts @@ -1,46 +1,46 @@ -import { ApiProperty } from "@nestjs/swagger"; -import { Type } from "class-transformer"; -import { Allow, IsNotEmpty, IsNumber, IsString } from "class-validator"; +// import { ApiProperty } from "@nestjs/swagger"; +// import { Type } from "class-transformer"; +// import { Allow, IsNotEmpty, IsNumber, IsString } from "class-validator"; -export class CreateBankCodeDto { - @ApiProperty({ - example: 1, - description: 'Unique ID of a bank-code (auto-generated)', - readOnly: true, - }) - @Allow() - id: number; +// export class CreateBankCodeDto { +// @ApiProperty({ +// example: 1, +// description: 'Unique ID of a bank-code (auto-generated)', +// readOnly: true, +// }) +// @Allow() +// id: number; - @ApiProperty({ - example: 'regular, vacation, emergency, sick, parental, etc', - description: 'Type of codes', - }) - @IsString() - @IsNotEmpty() - type: string; +// @ApiProperty({ +// example: 'regular, vacation, emergency, sick, parental, etc', +// description: 'Type of codes', +// }) +// @IsString() +// @IsNotEmpty() +// type: string; - @ApiProperty({ - example: 'shift, expense, leave', - description: 'categorie of the related code', - }) - @IsString() - @IsNotEmpty() - categorie: string; +// @ApiProperty({ +// example: 'shift, expense, leave', +// description: 'categorie of the related code', +// }) +// @IsString() +// @IsNotEmpty() +// categorie: string; - @ApiProperty({ - example: '0, 0.72, 1, 1.5, 2', - description: 'modifier number to apply to salary', - }) - @Type(()=> Number) - @IsNumber() - @IsNotEmpty() - modifier: number; +// @ApiProperty({ +// example: '0, 0.72, 1, 1.5, 2', +// description: 'modifier number to apply to salary', +// }) +// @Type(()=> Number) +// @IsNumber() +// @IsNotEmpty() +// modifier: number; - @ApiProperty({ - example: 'G1, G345, G501, G43, G700', - description: 'codes given by the bank', - }) - @IsString() - @IsNotEmpty() - bank_code: string; -} \ No newline at end of file +// @ApiProperty({ +// example: 'G1, G345, G501, G43, G700', +// description: 'codes given by the bank', +// }) +// @IsString() +// @IsNotEmpty() +// bank_code: string; +// } \ No newline at end of file diff --git a/src/modules/bank-codes/dtos/update-bank-code.dto.ts b/src/modules/bank-codes/dtos/update-bank-code.dto.ts index 4033484..884e544 100644 --- a/src/modules/bank-codes/dtos/update-bank-code.dto.ts +++ b/src/modules/bank-codes/dtos/update-bank-code.dto.ts @@ -1,4 +1,4 @@ -import { PartialType } from "@nestjs/swagger"; -import { CreateBankCodeDto } from "./create-bank-code.dto"; +// import { PartialType } from "@nestjs/swagger"; +// import { CreateBankCodeDto } from "./create-bank-code.dto"; -export class UpdateBankCodeDto extends PartialType(CreateBankCodeDto) {} \ No newline at end of file +// export class UpdateBankCodeDto extends PartialType(CreateBankCodeDto) {} \ No newline at end of file diff --git a/src/modules/bank-codes/services/bank-codes.service.ts b/src/modules/bank-codes/services/bank-codes.service.ts index 5e1549a..fbb8745 100644 --- a/src/modules/bank-codes/services/bank-codes.service.ts +++ b/src/modules/bank-codes/services/bank-codes.service.ts @@ -1,51 +1,51 @@ -import { Injectable, NotFoundException } from "@nestjs/common"; -import { PrismaService } from "src/prisma/prisma.service"; -import { CreateBankCodeDto } from "../dtos/create-bank-code.dto"; -import { BankCodes } from "@prisma/client"; -import { UpdateBankCodeDto } from "../dtos/update-bank-code.dto"; +// import { Injectable, NotFoundException } from "@nestjs/common"; +// import { PrismaService } from "src/prisma/prisma.service"; +// import { CreateBankCodeDto } from "../dtos/create-bank-code.dto"; +// import { BankCodes } from "@prisma/client"; +// import { UpdateBankCodeDto } from "../dtos/update-bank-code.dto"; -@Injectable() -export class BankCodesService { - constructor(private readonly prisma: PrismaService) {} +// @Injectable() +// export class BankCodesService { +// constructor(private readonly prisma: PrismaService) {} - async create(dto: CreateBankCodeDto): Promise{ - return this.prisma.bankCodes.create({ - data: { - type: dto.type, - categorie: dto.categorie, - modifier: dto.modifier, - bank_code: dto.bank_code, - }, - }); - } +// async create(dto: CreateBankCodeDto): Promise{ +// return this.prisma.bankCodes.create({ +// data: { +// type: dto.type, +// categorie: dto.categorie, +// modifier: dto.modifier, +// bank_code: dto.bank_code, +// }, +// }); +// } - findAll() { - return this.prisma.bankCodes.findMany(); - } +// findAll() { +// return this.prisma.bankCodes.findMany(); +// } - async findOne(id: number) { - const bankCode = await this.prisma.bankCodes.findUnique({ where: {id} }); +// async findOne(id: number) { +// const bankCode = await this.prisma.bankCodes.findUnique({ where: {id} }); - if(!bankCode) throw new NotFoundException(`Bank Code #${id} not found`); +// if(!bankCode) throw new NotFoundException(`Bank Code #${id} not found`); - return bankCode; - } +// return bankCode; +// } - async update(id:number, dto: UpdateBankCodeDto) { - return await this.prisma.bankCodes.update({ - where: { id }, - data: { - type: dto.type, - categorie: dto.categorie, - modifier: dto.modifier as any, - bank_code: dto.bank_code, - }, - }); - } +// async update(id:number, dto: UpdateBankCodeDto) { +// return await this.prisma.bankCodes.update({ +// where: { id }, +// data: { +// type: dto.type, +// categorie: dto.categorie, +// modifier: dto.modifier as any, +// bank_code: dto.bank_code, +// }, +// }); +// } - async remove(id: number) { - await this.findOne(id); - return this.prisma.bankCodes.delete({ where: {id} }); - } +// async remove(id: number) { +// await this.findOne(id); +// return this.prisma.bankCodes.delete({ where: {id} }); +// } -} \ No newline at end of file +// } \ No newline at end of file diff --git a/src/modules/customers/dtos/create-customer.dto.ts b/src/modules/customers/dtos/create-customer.dto.ts index 8382f20..8a136ac 100644 --- a/src/modules/customers/dtos/create-customer.dto.ts +++ b/src/modules/customers/dtos/create-customer.dto.ts @@ -1,79 +1,79 @@ -import { ApiProperty } from "@nestjs/swagger"; -import { Type } from "class-transformer"; -import { - Allow, - IsEmail, - IsInt, - IsNotEmpty, - IsOptional, - IsPositive, - IsString, - IsUUID, -} from "class-validator"; +// import { ApiProperty } from "@nestjs/swagger"; +// import { Type } from "class-transformer"; +// import { +// Allow, +// IsEmail, +// IsInt, +// IsNotEmpty, +// IsOptional, +// IsPositive, +// IsString, +// IsUUID, +// } from "class-validator"; -export class CreateCustomerDto { - @ApiProperty({ - example: 1, - description: 'Unique ID of a customer(primary-key, auto-incremented)', - }) - @Allow() - id?: number; +// export class CreateCustomerDto { +// @ApiProperty({ +// example: 1, +// description: 'Unique ID of a customer(primary-key, auto-incremented)', +// }) +// @Allow() +// id?: number; - @ApiProperty({ - example: '0e6e2e1f-b157-4c7c-ae3f-999b3e4f914d', - description: 'UUID of the user linked to that customer', - }) - @IsUUID() - @IsOptional() - user_id?: string; +// @ApiProperty({ +// example: '0e6e2e1f-b157-4c7c-ae3f-999b3e4f914d', +// description: 'UUID of the user linked to that customer', +// }) +// @IsUUID() +// @IsOptional() +// user_id?: string; - @ApiProperty({ - example: 'Gandalf', - description: 'Customer`s first name', - }) - @IsString() - @IsNotEmpty() - first_name: string; +// @ApiProperty({ +// example: 'Gandalf', +// description: 'Customer`s first name', +// }) +// @IsString() +// @IsNotEmpty() +// first_name: string; - @ApiProperty({ - example: 'TheGray', - description: 'Customer`s last name', - }) - @IsString() - @IsNotEmpty() - last_name: string; +// @ApiProperty({ +// example: 'TheGray', +// description: 'Customer`s last name', +// }) +// @IsString() +// @IsNotEmpty() +// last_name: string; - @ApiProperty({ - example: 'you_shall_not_pass@middleEarth.com', - description: 'Customer`s email', - }) - @IsEmail() - @IsOptional() - email: string; +// @ApiProperty({ +// example: 'you_shall_not_pass@middleEarth.com', +// description: 'Customer`s email', +// }) +// @IsEmail() +// @IsOptional() +// email: string; - @ApiProperty({ - example: '8436637464', - description: 'Customer`s phone number', - }) - @IsString() - phone_number: string; +// @ApiProperty({ +// example: '8436637464', +// description: 'Customer`s phone number', +// }) +// @IsString() +// phone_number: string; - @ApiProperty({ - example: '1 Ringbearer`s way, Mount Doom city, ME, T1R 1N6 ', - description: 'Customer`s residence', - required: false, - }) - @IsString() - @IsOptional() - residence?: string; +// @ApiProperty({ +// example: '1 Ringbearer`s way, Mount Doom city, ME, T1R 1N6 ', +// description: 'Customer`s residence', +// required: false, +// }) +// @IsString() +// @IsOptional() +// residence?: string; - @ApiProperty({ - example: '4263253', - description: 'Customer`s invoice number', - required: false, - }) - @Type(() => Number) - @IsInt() - @IsNotEmpty() - invoice_id: number; -} \ No newline at end of file +// @ApiProperty({ +// example: '4263253', +// description: 'Customer`s invoice number', +// required: false, +// }) +// @Type(() => Number) +// @IsInt() +// @IsNotEmpty() +// invoice_id: number; +// } \ No newline at end of file diff --git a/src/modules/customers/dtos/update-customer.dto.ts b/src/modules/customers/dtos/update-customer.dto.ts index fc1ba39..2f52413 100644 --- a/src/modules/customers/dtos/update-customer.dto.ts +++ b/src/modules/customers/dtos/update-customer.dto.ts @@ -1,4 +1,4 @@ -import { PartialType } from "@nestjs/swagger"; -import { CreateCustomerDto } from "./create-customer.dto"; +// import { PartialType } from "@nestjs/swagger"; +// import { CreateCustomerDto } from "./create-customer.dto"; -export class UpdateCustomerDto extends PartialType(CreateCustomerDto) {} \ No newline at end of file +// export class UpdateCustomerDto extends PartialType(CreateCustomerDto) {} \ No newline at end of file diff --git a/src/modules/customers/services/customers.service.ts b/src/modules/customers/services/customers.service.ts index b0b68c8..2662250 100644 --- a/src/modules/customers/services/customers.service.ts +++ b/src/modules/customers/services/customers.service.ts @@ -1,93 +1,93 @@ -import { Injectable } from '@nestjs/common'; +// import { Injectable } from '@nestjs/common'; -@Injectable() -export class CustomersService { +// @Injectable() +// export class CustomersService { -//_____________________________________________________________________________________________ -// Deprecated or unused methods -//_____________________________________________________________________________________________ +// //_____________________________________________________________________________________________ +// // Deprecated or unused methods +// //_____________________________________________________________________________________________ -// constructor(private readonly prisma: PrismaService) {} +// // constructor(private readonly prisma: PrismaService) {} -// async create(dto: CreateCustomerDto): Promise { -// const { -// first_name, -// last_name, -// email, -// phone_number, -// residence, -// invoice_id, -// } = dto; +// // async create(dto: CreateCustomerDto): Promise { +// // const { +// // first_name, +// // last_name, +// // email, +// // phone_number, +// // residence, +// // invoice_id, +// // } = dto; -// return this.prisma.$transaction(async (transaction) => { -// const user: Users = await transaction.users.create({ -// data: { -// first_name, -// last_name, -// email, -// phone_number, -// residence, -// }, -// }); -// return transaction.customers.create({ -// data: { -// user_id: user.id, -// invoice_id, -// }, -// }); -// }); -// } +// // return this.prisma.$transaction(async (transaction) => { +// // const user: Users = await transaction.users.create({ +// // data: { +// // first_name, +// // last_name, +// // email, +// // phone_number, +// // residence, +// // }, +// // }); +// // return transaction.customers.create({ +// // data: { +// // user_id: user.id, +// // invoice_id, +// // }, +// // }); +// // }); +// // } -// findAll(): Promise { -// return this.prisma.customers.findMany({ -// include: { user: true }, -// }) -// } +// // findAll(): Promise { +// // return this.prisma.customers.findMany({ +// // include: { user: true }, +// // }) +// // } -// async findOne(id:number): Promise { -// const customer = await this.prisma.customers.findUnique({ -// where: { id }, -// include: { user: true }, -// }); -// if(!customer) throw new NotFoundException(`Customer #${id} not found`); -// return customer; -// } +// // async findOne(id:number): Promise { +// // const customer = await this.prisma.customers.findUnique({ +// // where: { id }, +// // include: { user: true }, +// // }); +// // if(!customer) throw new NotFoundException(`Customer #${id} not found`); +// // return customer; +// // } -// async update(id: number,dto: UpdateCustomerDto): Promise { -// const customer = await this.findOne(id); +// // async update(id: number,dto: UpdateCustomerDto): Promise { +// // const customer = await this.findOne(id); -// const { -// first_name, -// last_name, -// email, -// phone_number, -// residence, -// invoice_id, -// } = dto; +// // const { +// // first_name, +// // last_name, +// // email, +// // phone_number, +// // residence, +// // invoice_id, +// // } = dto; -// return this.prisma.$transaction(async (transaction) => { -// await transaction.users.update({ -// where: { id: customer.user_id }, -// data: { -// ...(first_name !== undefined && { first_name }), -// ...(last_name !== undefined && { last_name }), -// ...(email !== undefined && { email }), -// ...(phone_number !== undefined && { phone_number }), -// ...(residence !== undefined && { residence }), -// }, -// }); +// // return this.prisma.$transaction(async (transaction) => { +// // await transaction.users.update({ +// // where: { id: customer.user_id }, +// // data: { +// // ...(first_name !== undefined && { first_name }), +// // ...(last_name !== undefined && { last_name }), +// // ...(email !== undefined && { email }), +// // ...(phone_number !== undefined && { phone_number }), +// // ...(residence !== undefined && { residence }), +// // }, +// // }); -// return transaction.customers.update({ -// where: { id }, -// data: { -// ...(invoice_id !== undefined && { invoice_id }), -// }, -// }); -// }); +// // return transaction.customers.update({ +// // where: { id }, +// // data: { +// // ...(invoice_id !== undefined && { invoice_id }), +// // }, +// // }); +// // }); +// // } + +// // async remove(id: number): Promise { +// // await this.findOne(id); +// // return this.prisma.customers.delete({ where: { id }}); +// // } // } - -// async remove(id: number): Promise { -// await this.findOne(id); -// return this.prisma.customers.delete({ where: { id }}); -// } -} diff --git a/src/modules/employees/dtos/create-employee.dto.ts b/src/modules/employees/dtos/create-employee.dto.ts index 89279ef..4fbbaaa 100644 --- a/src/modules/employees/dtos/create-employee.dto.ts +++ b/src/modules/employees/dtos/create-employee.dto.ts @@ -1,118 +1,118 @@ -import { - Allow, - IsBoolean, - IsDateString, - IsEmail, - IsInt, - IsNotEmpty, - IsOptional, - IsPositive, - IsString, - IsUUID, -} from 'class-validator'; -import { Type } from 'class-transformer'; -import { ApiProperty } from '@nestjs/swagger'; +// import { +// Allow, +// IsBoolean, +// IsDateString, +// IsEmail, +// IsInt, +// IsNotEmpty, +// IsOptional, +// IsPositive, +// IsString, +// IsUUID, +// } from 'class-validator'; +// import { Type } from 'class-transformer'; +// import { ApiProperty } from '@nestjs/swagger'; -export class CreateEmployeeDto { - @ApiProperty({ - example: 1, - description: 'Unique ID of an employee(primary-key, auto-incremented)', - }) - @Allow() - id: number; +// export class CreateEmployeeDto { +// @ApiProperty({ +// example: 1, +// description: 'Unique ID of an employee(primary-key, auto-incremented)', +// }) +// @Allow() +// id: number; - @ApiProperty({ - example: '0e6e2e1f-b157-4c7c-ae3f-999b3e4f914d', - description: 'UUID of the user linked to that employee', - }) - @IsUUID() - @IsOptional() - user_id?: string; +// @ApiProperty({ +// example: '0e6e2e1f-b157-4c7c-ae3f-999b3e4f914d', +// description: 'UUID of the user linked to that employee', +// }) +// @IsUUID() +// @IsOptional() +// user_id?: string; - @ApiProperty({ - example: 'Frodo', - description: 'Employee`s first name', - }) - @IsString() - @IsNotEmpty() - first_name: string; +// @ApiProperty({ +// example: 'Frodo', +// description: 'Employee`s first name', +// }) +// @IsString() +// @IsNotEmpty() +// first_name: string; - @ApiProperty({ - example: 'Baggins', - description: 'Employee`s last name', - }) - @IsString() - @IsNotEmpty() - last_name: string; +// @ApiProperty({ +// example: 'Baggins', +// description: 'Employee`s last name', +// }) +// @IsString() +// @IsNotEmpty() +// last_name: string; - @ApiProperty({ - example: 'i_cant_do_this_sam@targointernet.com', - description: 'Employee`s email', - }) - @IsEmail() - @IsOptional() - email: string; +// @ApiProperty({ +// example: 'i_cant_do_this_sam@targointernet.com', +// description: 'Employee`s email', +// }) +// @IsEmail() +// @IsOptional() +// email: string; - @IsOptional() - @IsBoolean() - is_supervisor: boolean; +// @IsOptional() +// @IsBoolean() +// is_supervisor: boolean; - @ApiProperty({ - example: '82538437464', - description: 'Employee`s phone number', - }) - @IsString() - phone_number: string; +// @ApiProperty({ +// example: '82538437464', +// description: 'Employee`s phone number', +// }) +// @IsString() +// phone_number: string; - @ApiProperty({ - example: '1 Bagshot Row, Hobbiton, The Shire, Middle-earth', - description: 'Employee`s residence', - required: false, - }) - @IsString() - @IsOptional() - residence?: string; +// @ApiProperty({ +// example: '1 Bagshot Row, Hobbiton, The Shire, Middle-earth', +// description: 'Employee`s residence', +// required: false, +// }) +// @IsString() +// @IsOptional() +// residence?: string; - @ApiProperty({ - example: 7464, - description: 'external ID for the pay system', - }) - @IsInt() - @IsPositive() - @Type(() => Number) - external_payroll_id: number; +// @ApiProperty({ +// example: 7464, +// description: 'external ID for the pay system', +// }) +// @IsInt() +// @IsPositive() +// @Type(() => Number) +// external_payroll_id: number; - @ApiProperty({ - example: 335567447, - description: 'Employee`s company code', - }) - @IsInt() - @IsPositive() - @Type(() => Number) - company_code: number; +// @ApiProperty({ +// example: 335567447, +// description: 'Employee`s company code', +// }) +// @IsInt() +// @IsPositive() +// @Type(() => Number) +// company_code: number; - @ApiProperty({ - example:'technicient', - description: 'employee`s job title', - }) - @IsString() - @IsOptional() - job_title: string; +// @ApiProperty({ +// example:'technicient', +// description: 'employee`s job title', +// }) +// @IsString() +// @IsOptional() +// job_title: string; - @ApiProperty({ - example: '23/09/3018', - description: 'Employee`s first working day', - }) - @IsDateString() - first_work_day: string; +// @ApiProperty({ +// example: '23/09/3018', +// description: 'Employee`s first working day', +// }) +// @IsDateString() +// first_work_day: string; - @ApiProperty({ - example: '25/03/3019', - description: 'Employee`s last working day', - required: false, - }) - @IsDateString() - @IsOptional() - last_work_day?: string; -} +// @ApiProperty({ +// example: '25/03/3019', +// description: 'Employee`s last working day', +// required: false, +// }) +// @IsDateString() +// @IsOptional() +// last_work_day?: string; +// } diff --git a/src/modules/employees/dtos/list-employee.dto.ts b/src/modules/employees/dtos/list-employee.dto.ts index 39abf03..6adbe3f 100644 --- a/src/modules/employees/dtos/list-employee.dto.ts +++ b/src/modules/employees/dtos/list-employee.dto.ts @@ -1,8 +1,8 @@ -export class EmployeeListItemDto { - first_name: string; - last_name: string; - email: string; - supervisor_full_name: string | null; - company_name: number | null; - job_title: string | null; -} \ No newline at end of file +// export class EmployeeListItemDto { +// first_name: string; +// last_name: string; +// email: string; +// supervisor_full_name: string | null; +// company_name: number | null; +// job_title: string | null; +// } \ No newline at end of file diff --git a/src/modules/employees/dtos/profil-employee.dto.ts b/src/modules/employees/dtos/profil-employee.dto.ts index c6836cf..adbf38e 100644 --- a/src/modules/employees/dtos/profil-employee.dto.ts +++ b/src/modules/employees/dtos/profil-employee.dto.ts @@ -1,13 +1,13 @@ -export class EmployeeProfileItemDto { - first_name: string; - last_name: string; - employee_full_name: string; - supervisor_full_name: string | null; - company_name: number | null; - job_title: string | null; - email: string | null; - phone_number: string; - first_work_day: string; - last_work_day?: string | null; - residence: string | null; -} \ No newline at end of file +// export class EmployeeProfileItemDto { +// first_name: string; +// last_name: string; +// employee_full_name: string; +// supervisor_full_name: string | null; +// company_name: number | null; +// job_title: string | null; +// email: string | null; +// phone_number: string; +// first_work_day: string; +// last_work_day?: string | null; +// residence: string | null; +// } \ No newline at end of file diff --git a/src/modules/employees/dtos/update-employee.dto.ts b/src/modules/employees/dtos/update-employee.dto.ts index 334a01a..1efbbfd 100644 --- a/src/modules/employees/dtos/update-employee.dto.ts +++ b/src/modules/employees/dtos/update-employee.dto.ts @@ -1,22 +1,22 @@ -import { ApiProperty, PartialType } from '@nestjs/swagger'; -import { CreateEmployeeDto } from './create-employee.dto'; -import { IsDateString, IsOptional, Max } from 'class-validator'; +// import { ApiProperty, PartialType } from '@nestjs/swagger'; +// import { CreateEmployeeDto } from './create-employee.dto'; +// import { IsDateString, IsOptional, Max } from 'class-validator'; -export class UpdateEmployeeDto extends PartialType(CreateEmployeeDto) { - @ApiProperty({ required: false, type: Date, description: 'New hire date or undefined' }) - @IsDateString() - @IsOptional() - first_work_day?: string; +// export class UpdateEmployeeDto extends PartialType(CreateEmployeeDto) { +// @ApiProperty({ required: false, type: Date, description: 'New hire date or undefined' }) +// @IsDateString() +// @IsOptional() +// first_work_day?: string; - @ApiProperty({ required: false, type: Date, description: 'Termination date (null to restore)' }) - @IsDateString() - @IsOptional() - last_work_day?: string; +// @ApiProperty({ required: false, type: Date, description: 'Termination date (null to restore)' }) +// @IsDateString() +// @IsOptional() +// last_work_day?: string; - @ApiProperty({ required: false, type: Number, description: 'Supervisor ID' }) - @IsOptional() - supervisor_id?: number; +// @ApiProperty({ required: false, type: Number, description: 'Supervisor ID' }) +// @IsOptional() +// supervisor_id?: number; - @IsOptional() - phone_number: string; -} +// @IsOptional() +// phone_number: string; +// } diff --git a/src/modules/employees/services/employees.service.ts b/src/modules/employees/services/employees.service.ts index 3627476..b44bf7d 100644 --- a/src/modules/employees/services/employees.service.ts +++ b/src/modules/employees/services/employees.service.ts @@ -1,230 +1,230 @@ -import { Injectable, NotFoundException } from '@nestjs/common'; -import { PrismaService } from 'src/prisma/prisma.service'; -import { EmployeeListItemDto } from '../dtos/list-employee.dto'; -import { EmployeeProfileItemDto } from '../dtos/profil-employee.dto'; +// import { Injectable, NotFoundException } from '@nestjs/common'; +// import { PrismaService } from 'src/prisma/prisma.service'; +// import { EmployeeListItemDto } from '../dtos/list-employee.dto'; +// import { EmployeeProfileItemDto } from '../dtos/profil-employee.dto'; -@Injectable() -export class EmployeesService { - constructor(private readonly prisma: PrismaService) { } +// @Injectable() +// export class EmployeesService { +// constructor(private readonly prisma: PrismaService) { } - findListEmployees(): Promise { - return this.prisma.employees.findMany({ - select: { - user: { - select: { - first_name: true, - last_name: true, - email: true, - }, - }, - supervisor: { - select: { - user: { - select: { - first_name: true, - last_name: true, - }, - }, - }, - }, - job_title: true, - company_code: true, - } - }).then(rows => rows.map(r => ({ - first_name: r.user.first_name, - last_name: r.user.last_name, - email: r.user.email, - company_name: r.company_code, - job_title: r.job_title, - employee_full_name: `${r.user.first_name} ${r.user.last_name}`, - supervisor_full_name: r.supervisor ? `${r.supervisor.user.first_name} ${r.supervisor.user.last_name}` : null, - })), - ); - } +// findListEmployees(): Promise { +// return this.prisma.employees.findMany({ +// select: { +// user: { +// select: { +// first_name: true, +// last_name: true, +// email: true, +// }, +// }, +// supervisor: { +// select: { +// user: { +// select: { +// first_name: true, +// last_name: true, +// }, +// }, +// }, +// }, +// job_title: true, +// company_code: true, +// } +// }).then(rows => rows.map(r => ({ +// first_name: r.user.first_name, +// last_name: r.user.last_name, +// email: r.user.email, +// company_name: r.company_code, +// job_title: r.job_title, +// employee_full_name: `${r.user.first_name} ${r.user.last_name}`, +// supervisor_full_name: r.supervisor ? `${r.supervisor.user.first_name} ${r.supervisor.user.last_name}` : null, +// })), +// ); +// } - async findOneProfile(email: string): Promise { - const emp = await this.prisma.employees.findFirst({ - where: { user: { email } }, - select: { - user: { - select: { - first_name: true, - last_name: true, - email: true, - phone_number: true, - residence: true, - }, - }, - supervisor: { - select: { - user: { - select: { - first_name: true, - last_name: true, - }, - }, - }, - }, - job_title: true, - company_code: true, - first_work_day: true, - last_work_day: true, - } - }); - if (!emp) throw new NotFoundException(`Employee with email ${email} not found`); +// async findOneProfile(email: string): Promise { +// const emp = await this.prisma.employees.findFirst({ +// where: { user: { email } }, +// select: { +// user: { +// select: { +// first_name: true, +// last_name: true, +// email: true, +// phone_number: true, +// residence: true, +// }, +// }, +// supervisor: { +// select: { +// user: { +// select: { +// first_name: true, +// last_name: true, +// }, +// }, +// }, +// }, +// job_title: true, +// company_code: true, +// first_work_day: true, +// last_work_day: true, +// } +// }); +// if (!emp) throw new NotFoundException(`Employee with email ${email} not found`); - return { - first_name: emp.user.first_name, - last_name: emp.user.last_name, - email: emp.user.email, - residence: emp.user.residence, - phone_number: emp.user.phone_number, - company_name: emp.company_code, - job_title: emp.job_title, - employee_full_name: `${emp.user.first_name} ${emp.user.last_name}`, - first_work_day: emp.first_work_day.toISOString().slice(0, 10), - last_work_day: emp.last_work_day ? emp.last_work_day.toISOString().slice(0, 10) : null, - supervisor_full_name: emp.supervisor ? `${emp.supervisor.user.first_name}, ${emp.supervisor.user.last_name}` : null, - }; - } +// return { +// first_name: emp.user.first_name, +// last_name: emp.user.last_name, +// email: emp.user.email, +// residence: emp.user.residence, +// phone_number: emp.user.phone_number, +// company_name: emp.company_code, +// job_title: emp.job_title, +// employee_full_name: `${emp.user.first_name} ${emp.user.last_name}`, +// first_work_day: emp.first_work_day.toISOString().slice(0, 10), +// last_work_day: emp.last_work_day ? emp.last_work_day.toISOString().slice(0, 10) : null, +// supervisor_full_name: emp.supervisor ? `${emp.supervisor.user.first_name}, ${emp.supervisor.user.last_name}` : null, +// }; +// } - //_____________________________________________________________________________________________ - // Deprecated or unused methods - //_____________________________________________________________________________________________ +// //_____________________________________________________________________________________________ +// // Deprecated or unused methods +// //_____________________________________________________________________________________________ - // async create(dto: CreateEmployeeDto): Promise { - // const { - // first_name, - // last_name, - // email, - // phone_number, - // residence, - // external_payroll_id, - // company_code, - // job_title, - // first_work_day, - // last_work_day, - // is_supervisor, - // } = dto; +// // async create(dto: CreateEmployeeDto): Promise { +// // const { +// // first_name, +// // last_name, +// // email, +// // phone_number, +// // residence, +// // external_payroll_id, +// // company_code, +// // job_title, +// // first_work_day, +// // last_work_day, +// // is_supervisor, +// // } = dto; - // return this.prisma.$transaction(async (transaction) => { - // const user: Users = await transaction.users.create({ - // data: { - // first_name, - // last_name, - // email, - // phone_number, - // residence, - // }, - // }); - // return transaction.employees.create({ - // data: { - // user_id: user.id, - // external_payroll_id, - // company_code, - // job_title, - // first_work_day, - // last_work_day, - // is_supervisor, - // }, - // }); - // }); - // } +// // return this.prisma.$transaction(async (transaction) => { +// // const user: Users = await transaction.users.create({ +// // data: { +// // first_name, +// // last_name, +// // email, +// // phone_number, +// // residence, +// // }, +// // }); +// // return transaction.employees.create({ +// // data: { +// // user_id: user.id, +// // external_payroll_id, +// // company_code, +// // job_title, +// // first_work_day, +// // last_work_day, +// // is_supervisor, +// // }, +// // }); +// // }); +// // } - // findAll(): Promise { - // return this.prisma.employees.findMany({ - // include: { user: true }, - // }); - // } +// // findAll(): Promise { +// // return this.prisma.employees.findMany({ +// // include: { user: true }, +// // }); +// // } - // async findOne(email: string): Promise { - // const emp = await this.prisma.employees.findFirst({ - // where: { user: { email } }, - // include: { user: true }, - // }); +// // async findOne(email: string): Promise { +// // const emp = await this.prisma.employees.findFirst({ +// // where: { user: { email } }, +// // include: { user: true }, +// // }); - // //add search for archived employees - // if (!emp) { - // throw new NotFoundException(`Employee with email: ${email} not found`); - // } - // return emp; - // } +// // //add search for archived employees +// // if (!emp) { +// // throw new NotFoundException(`Employee with email: ${email} not found`); +// // } +// // return emp; +// // } - // async update( - // email: string, - // dto: UpdateEmployeeDto, - // ): Promise { - // const emp = await this.findOne(email); +// // async update( +// // email: string, +// // dto: UpdateEmployeeDto, +// // ): Promise { +// // const emp = await this.findOne(email); - // const { - // first_name, - // last_name, - // phone_number, - // residence, - // external_payroll_id, - // company_code, - // job_title, - // first_work_day, - // last_work_day, - // is_supervisor, - // email: new_email, - // } = dto; +// // const { +// // first_name, +// // last_name, +// // phone_number, +// // residence, +// // external_payroll_id, +// // company_code, +// // job_title, +// // first_work_day, +// // last_work_day, +// // is_supervisor, +// // email: new_email, +// // } = dto; - // return this.prisma.$transaction(async (transaction) => { - // if( - // first_name !== undefined || - // last_name !== undefined || - // new_email !== undefined || - // phone_number !== undefined || - // residence !== undefined - // ){ - // await transaction.users.update({ - // where: { id: emp.user_id }, - // data: { - // ...(first_name !== undefined && { first_name }), - // ...(last_name !== undefined && { last_name }), - // ...(email !== undefined && { email }), - // ...(phone_number !== undefined && { phone_number }), - // ...(residence !== undefined && { residence }), - // }, - // }); - // } +// // return this.prisma.$transaction(async (transaction) => { +// // if( +// // first_name !== undefined || +// // last_name !== undefined || +// // new_email !== undefined || +// // phone_number !== undefined || +// // residence !== undefined +// // ){ +// // await transaction.users.update({ +// // where: { id: emp.user_id }, +// // data: { +// // ...(first_name !== undefined && { first_name }), +// // ...(last_name !== undefined && { last_name }), +// // ...(email !== undefined && { email }), +// // ...(phone_number !== undefined && { phone_number }), +// // ...(residence !== undefined && { residence }), +// // }, +// // }); +// // } - // const updated = await transaction.employees.update({ - // where: { id: emp.id }, - // data: { - // ...(external_payroll_id !== undefined && { external_payroll_id }), - // ...(company_code !== undefined && { company_code }), - // ...(first_work_day !== undefined && { first_work_day }), - // ...(last_work_day !== undefined && { last_work_day }), - // ...(job_title !== undefined && { job_title }), - // ...(is_supervisor !== undefined && { is_supervisor }), - // }, - // }); - // return updated; - // }); - // } +// // const updated = await transaction.employees.update({ +// // where: { id: emp.id }, +// // data: { +// // ...(external_payroll_id !== undefined && { external_payroll_id }), +// // ...(company_code !== undefined && { company_code }), +// // ...(first_work_day !== undefined && { first_work_day }), +// // ...(last_work_day !== undefined && { last_work_day }), +// // ...(job_title !== undefined && { job_title }), +// // ...(is_supervisor !== undefined && { is_supervisor }), +// // }, +// // }); +// // return updated; +// // }); +// // } - // async remove(email: string): Promise { +// // async remove(email: string): Promise { - // const emp = await this.findOne(email); +// // const emp = await this.findOne(email); - // return this.prisma.$transaction(async (transaction) => { - // await transaction.employees.updateMany({ - // where: { supervisor_id: emp.id }, - // data: { supervisor_id: null }, - // }); - // const deleted_employee = await transaction.employees.delete({ - // where: {id: emp.id }, - // }); - // await transaction.users.delete({ - // where: { id: emp.user_id }, - // }); - // return deleted_employee; - // }); - // } +// // return this.prisma.$transaction(async (transaction) => { +// // await transaction.employees.updateMany({ +// // where: { supervisor_id: emp.id }, +// // data: { supervisor_id: null }, +// // }); +// // const deleted_employee = await transaction.employees.delete({ +// // where: {id: emp.id }, +// // }); +// // await transaction.users.delete({ +// // where: { id: emp.user_id }, +// // }); +// // return deleted_employee; +// // }); +// // } -} \ No newline at end of file +// } \ No newline at end of file diff --git a/src/modules/employees/utils/employee.utils.ts b/src/modules/employees/utils/employee.utils.ts index 3534f3d..04f2540 100644 --- a/src/modules/employees/utils/employee.utils.ts +++ b/src/modules/employees/utils/employee.utils.ts @@ -1,9 +1,9 @@ -export function toDateOrNull(v?: string | null): Date | null { - if (!v) return null; - const day = new Date(v); - return isNaN(day.getTime()) ? null : day; -} -export function toDateOrUndefined(v?: string | null): Date | undefined { - const day = toDateOrNull(v ?? undefined); - return day === null ? undefined : day; -} \ No newline at end of file +// export function toDateOrNull(v?: string | null): Date | null { +// if (!v) return null; +// const day = new Date(v); +// return isNaN(day.getTime()) ? null : day; +// } +// export function toDateOrUndefined(v?: string | null): Date | undefined { +// const day = toDateOrNull(v ?? undefined); +// return day === null ? undefined : day; +// } \ No newline at end of file