From cbb863ac27da3c8ab9a3f935ee11f8814be668fc Mon Sep 17 00:00:00 2001 From: Matthieu Haineault Date: Wed, 30 Jul 2025 14:44:58 -0400 Subject: [PATCH] fix(dto): small fix to leave-request dto to inlcude bank_code_id --- docs/swagger/swagger-spec.json | 812 +++--------------- src/app.module.ts | 6 +- src/modules/bank-codes/bank-codes.module.ts | 2 +- .../dtos/create-leave-requests.dto.ts | 4 + .../services/leave-request.service.ts | 2 + 5 files changed, 146 insertions(+), 680 deletions(-) diff --git a/docs/swagger/swagger-spec.json b/docs/swagger/swagger-spec.json index 62fbba4..be46095 100644 --- a/docs/swagger/swagger-spec.json +++ b/docs/swagger/swagger-spec.json @@ -29,6 +29,125 @@ ] } }, + "/bank-codes": { + "post": { + "operationId": "BankCodesControllers_create", + "parameters": [], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/CreateBankCodeDto" + } + } + } + }, + "responses": { + "201": { + "description": "Bank code successfully created." + }, + "400": { + "description": "Invalid input data." + } + }, + "summary": "Create a new bank code", + "tags": [ + "BankCodesControllers" + ] + }, + "get": { + "operationId": "BankCodesControllers_findAll", + "parameters": [], + "responses": { + "200": { + "description": "List of bank codes." + } + }, + "summary": "Retrieve all bank codes", + "tags": [ + "BankCodesControllers" + ] + } + }, + "/bank-codes/{id}": { + "get": { + "operationId": "BankCodesControllers_findOne", + "parameters": [ + { + "name": "id", + "required": true, + "in": "path", + "schema": { + "type": "number" + } + } + ], + "responses": { + "404": { + "description": "Bank code not found." + } + }, + "summary": "Retrieve a bank code by its ID", + "tags": [ + "BankCodesControllers" + ] + }, + "patch": { + "operationId": "BankCodesControllers_update", + "parameters": [ + { + "name": "id", + "required": true, + "in": "path", + "schema": { + "type": "number" + } + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/UpdateBankCodeDto" + } + } + } + }, + "responses": { + "404": { + "description": "Bank code not found." + } + }, + "summary": "Update an existing bank code", + "tags": [ + "BankCodesControllers" + ] + }, + "delete": { + "operationId": "BankCodesControllers_remove", + "parameters": [ + { + "name": "id", + "required": true, + "in": "path", + "schema": { + "type": "number" + } + } + ], + "responses": { + "404": { + "description": "Bank code not found." + } + }, + "summary": "Delete a bank code", + "tags": [ + "BankCodesControllers" + ] + } + }, "/archives/employees": { "get": { "operationId": "EmployeesArchiveController_findOneArchived", @@ -1515,394 +1634,6 @@ ] } }, - "/expense-codes": { - "post": { - "operationId": "ExpenseCodesController_create", - "parameters": [], - "requestBody": { - "required": true, - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/CreateExpenseCodeDto" - } - } - } - }, - "responses": { - "201": { - "description": "Expense code created", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/ExpenseCodesEntity" - } - } - } - }, - "400": { - "description": "Incomplete task or invalid data" - } - }, - "security": [ - { - "access-token": [] - } - ], - "summary": "Create expense code", - "tags": [ - "Expense Codes" - ] - }, - "get": { - "operationId": "ExpenseCodesController_findAll", - "parameters": [], - "responses": { - "201": { - "description": "List of expense codes found", - "content": { - "application/json": { - "schema": { - "type": "array", - "items": { - "$ref": "#/components/schemas/ExpenseCodesEntity" - } - } - } - } - }, - "400": { - "description": "List of expense codes not found" - } - }, - "security": [ - { - "access-token": [] - } - ], - "summary": "Find all expense codes", - "tags": [ - "Expense Codes" - ] - } - }, - "/expense-codes/{id}": { - "get": { - "operationId": "ExpenseCodesController_findOne", - "parameters": [ - { - "name": "id", - "required": true, - "in": "path", - "schema": { - "type": "number" - } - } - ], - "responses": { - "201": { - "description": "Expense code found", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/ExpenseCodesEntity" - } - } - } - }, - "400": { - "description": "Expense code not found" - } - }, - "security": [ - { - "access-token": [] - } - ], - "summary": "Find expense code", - "tags": [ - "Expense Codes" - ] - }, - "patch": { - "operationId": "ExpenseCodesController_update", - "parameters": [ - { - "name": "id", - "required": true, - "in": "path", - "schema": { - "type": "number" - } - } - ], - "requestBody": { - "required": true, - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/UpdateExpenseCodeDto" - } - } - } - }, - "responses": { - "201": { - "description": "Expense code updated", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/ExpenseCodesEntity" - } - } - } - }, - "400": { - "description": "Expense code not found" - } - }, - "security": [ - { - "access-token": [] - } - ], - "summary": "Update expense code", - "tags": [ - "Expense Codes" - ] - }, - "delete": { - "operationId": "ExpenseCodesController_remove", - "parameters": [ - { - "name": "id", - "required": true, - "in": "path", - "schema": { - "type": "number" - } - } - ], - "responses": { - "201": { - "description": "Expense code deleted", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/ExpenseCodesEntity" - } - } - } - }, - "400": { - "description": "Expense code not found" - } - }, - "security": [ - { - "access-token": [] - } - ], - "summary": "Delete expense code", - "tags": [ - "Expense Codes" - ] - } - }, - "/shift-codes": { - "post": { - "operationId": "ShiftCodesController_create", - "parameters": [], - "requestBody": { - "required": true, - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/CreateShiftCodeDto" - } - } - } - }, - "responses": { - "201": { - "description": "Shift code created", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/ShiftCodesEntity" - } - } - } - }, - "400": { - "description": "Incomplete task or invalid data" - } - }, - "security": [ - { - "access-token": [] - } - ], - "summary": "Create shift code", - "tags": [ - "Shift Codes" - ] - }, - "get": { - "operationId": "ShiftCodesController_findAll", - "parameters": [], - "responses": { - "201": { - "description": "List of shift codes found", - "content": { - "application/json": { - "schema": { - "type": "array", - "items": { - "$ref": "#/components/schemas/ShiftCodesEntity" - } - } - } - } - }, - "400": { - "description": "List of shift codes not found" - } - }, - "security": [ - { - "access-token": [] - } - ], - "summary": "Find all shift codes", - "tags": [ - "Shift Codes" - ] - } - }, - "/shift-codes/{id}": { - "get": { - "operationId": "ShiftCodesController_findOne", - "parameters": [ - { - "name": "id", - "required": true, - "in": "path", - "schema": { - "type": "number" - } - } - ], - "responses": { - "201": { - "description": "Shift code found", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/ShiftCodesEntity" - } - } - } - }, - "400": { - "description": "Shift code not found" - } - }, - "security": [ - { - "access-token": [] - } - ], - "summary": "Find shift code", - "tags": [ - "Shift Codes" - ] - }, - "patch": { - "operationId": "ShiftCodesController_update", - "parameters": [ - { - "name": "id", - "required": true, - "in": "path", - "schema": { - "type": "number" - } - } - ], - "requestBody": { - "required": true, - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/UpdateShiftCodeDto" - } - } - } - }, - "responses": { - "201": { - "description": "Shift code updated", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/ShiftCodesEntity" - } - } - } - }, - "400": { - "description": "Shift code not found" - } - }, - "security": [ - { - "access-token": [] - } - ], - "summary": "Update shift code", - "tags": [ - "Shift Codes" - ] - }, - "delete": { - "operationId": "ShiftCodesController_remove", - "parameters": [ - { - "name": "id", - "required": true, - "in": "path", - "schema": { - "type": "number" - } - } - ], - "responses": { - "201": { - "description": "Shift code deleted", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/ShiftCodesEntity" - } - } - } - }, - "400": { - "description": "Shift code not found" - } - }, - "security": [ - { - "access-token": [] - } - ], - "summary": "Delete shift code", - "tags": [ - "Shift Codes" - ] - } - }, "/auth/login": { "get": { "operationId": "AuthController_login", @@ -2119,6 +1850,14 @@ } }, "schemas": { + "CreateBankCodeDto": { + "type": "object", + "properties": {} + }, + "UpdateBankCodeDto": { + "type": "object", + "properties": {} + }, "CreateEmployeeDto": { "type": "object", "properties": { @@ -2341,53 +2080,7 @@ }, "CreateExpenseDto": { "type": "object", - "properties": { - "timesheet_id": { - "type": "number", - "example": "Th3F3110w5h1pX2024", - "description": "ID number for a set timesheet" - }, - "expense_code_id": { - "type": "number", - "example": "0n3R1n962Ru13xX", - "description": "ID number of an expense code (link with shift-codes)" - }, - "date": { - "format": "date-time", - "type": "string", - "example": "20/10/3018", - "description": "Date where the expense was made" - }, - "amount": { - "type": "number", - "example": "280 000 000,00", - "description": "Amount of the expense" - }, - "description": { - "type": "string", - "example": "Spent for mileage between A and B", - "description": "explain`s why the expense was made" - }, - "is_approved": { - "type": "boolean", - "example": "True or False or Pending or Denied or Cancelled or Escalated", - "description": "Expense`s approval status" - }, - "supervisor_comment": { - "type": "string", - "example": "Asked X to go there as an emergency response", - "description": "Supervisro`s justification for the spending of an employee" - } - }, - "required": [ - "timesheet_id", - "expense_code_id", - "date", - "amount", - "description", - "is_approved", - "supervisor_comment" - ] + "properties": {} }, "ExpenseEntity": { "type": "object", @@ -2402,10 +2095,10 @@ "example": 101, "description": "ID number for a set timesheet" }, - "expense": { + "bank_code_id": { "type": "number", "example": 7, - "description": "ID number of an expense code (link with expense-codes)" + "description": "ID number of an bank code (link with bank-codes)" }, "date": { "format": "date-time", @@ -2432,7 +2125,7 @@ "required": [ "id", "timesheet_id", - "expense", + "bank_code_id", "date", "is_approuved", "description", @@ -2441,90 +2134,11 @@ }, "UpdateExpenseDto": { "type": "object", - "properties": { - "timesheet_id": { - "type": "number", - "example": "Th3F3110w5h1pX2024", - "description": "ID number for a set timesheet" - }, - "expense_code_id": { - "type": "number", - "example": "0n3R1n962Ru13xX", - "description": "ID number of an expense code (link with shift-codes)" - }, - "date": { - "format": "date-time", - "type": "string", - "example": "20/10/3018", - "description": "Date where the expense was made" - }, - "amount": { - "type": "number", - "example": "280 000 000,00", - "description": "Amount of the expense" - }, - "description": { - "type": "string", - "example": "Spent for mileage between A and B", - "description": "explain`s why the expense was made" - }, - "is_approved": { - "type": "boolean", - "example": "True or False or Pending or Denied or Cancelled or Escalated", - "description": "Expense`s approval status" - }, - "supervisor_comment": { - "type": "string", - "example": "Asked X to go there as an emergency response", - "description": "Supervisro`s justification for the spending of an employee" - } - } + "properties": {} }, "CreateShiftDto": { "type": "object", - "properties": { - "timesheet_id": { - "type": "number", - "example": "Th3F3110w5h1pX2024", - "description": "ID number for a set timesheet" - }, - "shift_code_id": { - "type": "number", - "example": "0n3R1n962Ru13xX", - "description": "ID number of a shift code (link with shift-codes)" - }, - "date": { - "format": "date-time", - "type": "string", - "example": "20/10/3018", - "description": "Date where the shift takes place" - }, - "start_time": { - "format": "date-time", - "type": "string", - "example": "08:00", - "description": "Start time of the said shift" - }, - "end_time": { - "format": "date-time", - "type": "string", - "example": "17:00", - "description": "End time of the said shift" - }, - "description": { - "type": "string", - "example": "Called for an emergency at X` place", - "description": "justify the purpose of the shift" - } - }, - "required": [ - "timesheet_id", - "shift_code_id", - "date", - "start_time", - "end_time", - "description" - ] + "properties": {} }, "ShiftEntity": { "type": "object", @@ -2539,10 +2153,10 @@ "example": 101, "description": "ID number for a set timesheet" }, - "shift_code_id": { + "bank_code_id": { "type": "number", "example": 7, - "description": "ID number of a shift code (link with shift-codes)" + "description": "ID number of a shift code (link with bank-codes)" }, "date": { "format": "date-time", @@ -2566,7 +2180,7 @@ "required": [ "id", "timesheet_id", - "shift_code_id", + "bank_code_id", "date", "start_time", "end_time" @@ -2574,41 +2188,7 @@ }, "UpdateShiftsDto": { "type": "object", - "properties": { - "timesheet_id": { - "type": "number", - "example": "Th3F3110w5h1pX2024", - "description": "ID number for a set timesheet" - }, - "shift_code_id": { - "type": "number", - "example": "0n3R1n962Ru13xX", - "description": "ID number of a shift code (link with shift-codes)" - }, - "date": { - "format": "date-time", - "type": "string", - "example": "20/10/3018", - "description": "Date where the shift takes place" - }, - "start_time": { - "format": "date-time", - "type": "string", - "example": "08:00", - "description": "Start time of the said shift" - }, - "end_time": { - "format": "date-time", - "type": "string", - "example": "17:00", - "description": "End time of the said shift" - }, - "description": { - "type": "string", - "example": "Called for an emergency at X` place", - "description": "justify the purpose of the shift" - } - } + "properties": {} }, "CreateLeaveRequestsDto": { "type": "object", @@ -3051,124 +2631,6 @@ } } }, - "CreateExpenseCodeDto": { - "type": "object", - "properties": { - "expense_type": { - "type": "string", - "example": "mileage, overnight, etc...", - "description": "Type of expenses for an account perception" - }, - "bank_code": { - "type": "string", - "example": "G500, G501, etc...", - "description": "bank`s code related to the type of expense" - } - }, - "required": [ - "expense_type", - "bank_code" - ] - }, - "ExpenseCodesEntity": { - "type": "object", - "properties": { - "id": { - "type": "number", - "example": 1, - "description": "Unique ID of a expense-code (auto-generated)" - }, - "shift_type": { - "type": "string", - "example": "Mileage", - "description": "Type of expenses for an account perception" - }, - "bank_code": { - "type": "string", - "example": "G501", - "description": "bank`s code related to the type of expense" - } - }, - "required": [ - "id", - "shift_type", - "bank_code" - ] - }, - "UpdateExpenseCodeDto": { - "type": "object", - "properties": { - "expense_type": { - "type": "string", - "example": "mileage, overnight, etc...", - "description": "Type of expenses for an account perception" - }, - "bank_code": { - "type": "string", - "example": "G500, G501, etc...", - "description": "bank`s code related to the type of expense" - } - } - }, - "CreateShiftCodeDto": { - "type": "object", - "properties": { - "shift_type": { - "type": "string", - "example": "Regular or Night or Emergency, etc...", - "description": "Type of shifts for an account perception" - }, - "bank_code": { - "type": "string", - "example": "G1, G2, G3, etc...", - "description": "bank`s code related to the type of shift" - } - }, - "required": [ - "shift_type", - "bank_code" - ] - }, - "ShiftCodesEntity": { - "type": "object", - "properties": { - "id": { - "type": "number", - "example": 1, - "description": "Unique ID of a shift-code (auto-generated)" - }, - "shift_type": { - "type": "string", - "example": "Night", - "description": "Type of shifts for an account perception" - }, - "bank_code": { - "type": "string", - "example": "G2", - "description": "bank`s code related to the type of shift" - } - }, - "required": [ - "id", - "shift_type", - "bank_code" - ] - }, - "UpdateShiftCodeDto": { - "type": "object", - "properties": { - "shift_type": { - "type": "string", - "example": "Regular or Night or Emergency, etc...", - "description": "Type of shifts for an account perception" - }, - "bank_code": { - "type": "string", - "example": "G1, G2, G3, etc...", - "description": "bank`s code related to the type of shift" - } - } - }, "PayPeriodEntity": { "type": "object", "properties": { diff --git a/src/app.module.ts b/src/app.module.ts index e874e70..1a4c3a7 100644 --- a/src/app.module.ts +++ b/src/app.module.ts @@ -9,19 +9,19 @@ import { OauthAccessTokensModule } from './modules/oauth-access-tokens/oauth-acc import { CustomersModule } from './modules/customers/customers.module'; import { EmployeesModule } from './modules/employees/employees.module'; import { LeaveRequestsModule } from './modules/leave-requests/leave-requests.module'; -import { ShiftCodesModule } from './modules/shift-codes/shift-codes.module'; import { ShiftsModule } from './modules/shifts/shifts.module'; import { TimesheetsModule } from './modules/timesheets/timesheets.module'; import { AuthenticationModule } from './modules/authentication/auth.module'; import { ExpensesModule } from './modules/expenses/expenses.module'; -import { ExpenseCodesModule } from './modules/expense-codes/expense-codes.module'; import { PayperiodsModule } from './modules/pay-periods/pay-periods.module'; import { ScheduleModule } from '@nestjs/schedule'; import { ArchivalModule } from './modules/archival/archival.module'; +import { BankCodesModule } from './modules/bank-codes/bank-codes.module'; @Module({ imports: [ ScheduleModule.forRoot(), + BankCodesModule, ArchivalModule, PrismaModule, HealthModule, @@ -31,8 +31,6 @@ import { ArchivalModule } from './modules/archival/archival.module'; EmployeesModule, LeaveRequestsModule, ExpensesModule, - ExpenseCodesModule, - ShiftCodesModule, ShiftsModule, TimesheetsModule, AuthenticationModule, diff --git a/src/modules/bank-codes/bank-codes.module.ts b/src/modules/bank-codes/bank-codes.module.ts index a8c4ced..bda3b9b 100644 --- a/src/modules/bank-codes/bank-codes.module.ts +++ b/src/modules/bank-codes/bank-codes.module.ts @@ -9,4 +9,4 @@ import { BankCodesService } from "./services/bank-codes.services"; providers: [BankCodesService, PrismaService], }) -export class ShiftCodesModule {} \ No newline at end of file +export class BankCodesModule {} \ No newline at end of file diff --git a/src/modules/leave-requests/dtos/create-leave-requests.dto.ts b/src/modules/leave-requests/dtos/create-leave-requests.dto.ts index 703cf91..24cb91e 100644 --- a/src/modules/leave-requests/dtos/create-leave-requests.dto.ts +++ b/src/modules/leave-requests/dtos/create-leave-requests.dto.ts @@ -12,6 +12,10 @@ export class CreateLeaveRequestsDto { @IsInt() employee_id: number; + @Type(()=> Number) + @IsInt() + bank_code_id: number; + @ApiProperty({ example: 'Sick or Vacation or Unpaid or Bereavement or Parental or Legal', description: 'type of leave request for an accounting perception', diff --git a/src/modules/leave-requests/services/leave-request.service.ts b/src/modules/leave-requests/services/leave-request.service.ts index e8315a7..a8bfafe 100644 --- a/src/modules/leave-requests/services/leave-request.service.ts +++ b/src/modules/leave-requests/services/leave-request.service.ts @@ -11,6 +11,7 @@ export class LeaveRequestsService { async create(dto: CreateLeaveRequestsDto): Promise { const { employee_id, + bank_code_id, leave_type, start_date_time, end_date_time, @@ -21,6 +22,7 @@ export class LeaveRequestsService { return this.prisma.leaveRequests.create({ data: { employee_id, + bank_code_id, leave_type, start_date_time, end_date_time,