Merge branch 'main' of git.targo.ca:Targo/targo_backend into dev/setup/attachment/MatthieuH

This commit is contained in:
Matthieu Haineault 2025-08-25 13:29:56 -04:00
commit a3c58fb0f5
6 changed files with 54 additions and 58 deletions

View File

@ -464,24 +464,36 @@
]
},
"get": {
"operationId": "TimesheetsController_findAll",
"parameters": [],
"responses": {
"201": {
"description": "List of timesheet found",
"content": {
"application/json": {
"schema": {
"type": "array",
"items": {
"$ref": "#/components/schemas/CreateTimesheetDto"
}
}
}
"operationId": "TimesheetsController_getPeriodByQuery",
"parameters": [
{
"name": "year",
"required": true,
"in": "query",
"schema": {
"type": "number"
}
},
"400": {
"description": "List of timesheets not found"
{
"name": "period_no",
"required": true,
"in": "query",
"schema": {
"type": "number"
}
},
{
"name": "email",
"required": true,
"in": "query",
"schema": {
"type": "string"
}
}
],
"responses": {
"200": {
"description": ""
}
},
"security": [
@ -489,7 +501,6 @@
"access-token": []
}
],
"summary": "Find all timesheets",
"tags": [
"Timesheets"
]
@ -618,7 +629,7 @@
]
}
},
"/timesheets/{id}/approval": {
"/timesheets/approval/{id}": {
"patch": {
"operationId": "TimesheetsController_approve",
"parameters": [
@ -840,7 +851,7 @@
]
}
},
"/Expenses/{id}/approval": {
"/Expenses/approval/{id}": {
"patch": {
"operationId": "ExpensesController_approve",
"parameters": [
@ -1062,7 +1073,7 @@
]
}
},
"/shifts/{id}/approval": {
"/shifts/approval/{id}": {
"patch": {
"operationId": "ShiftsController_approve",
"parameters": [
@ -1206,7 +1217,7 @@
"schema": {
"type": "array",
"items": {
"$ref": "#/components/schemas/CreateLeaveRequestsDto"
"$ref": "#/components/schemas/LeaveRequestViewDto"
}
}
}
@ -1246,7 +1257,7 @@
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/CreateLeaveRequestsDto"
"$ref": "#/components/schemas/LeaveRequestViewDto"
}
}
}
@ -1293,7 +1304,7 @@
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/CreateLeaveRequestsDto"
"$ref": "#/components/schemas/LeaveRequestViewDto"
}
}
}
@ -1350,7 +1361,7 @@
]
}
},
"/leave-requests/{id}/approval": {
"/leave-requests/approval/{id}": {
"patch": {
"operationId": "LeaveRequestController_updateApproval",
"parameters": [
@ -2646,16 +2657,6 @@
"CreateLeaveRequestsDto": {
"type": "object",
"properties": {
"id": {
"type": "number",
"example": 1,
"description": "Leave request`s unique id(auto-incremented)"
},
"employee_id": {
"type": "number",
"example": "4655867",
"description": "Employee`s id"
},
"bank_code_id": {
"type": "number",
"example": 7,
@ -2667,13 +2668,11 @@
"description": "type of leave request for an accounting perception"
},
"start_date_time": {
"format": "date-time",
"type": "string",
"example": "22/06/2463",
"description": "Leave request`s start date"
},
"end_date_time": {
"format": "date-time",
"type": "string",
"example": "25/03/3019",
"description": "Leave request`s end date"
@ -2690,8 +2689,6 @@
}
},
"required": [
"id",
"employee_id",
"bank_code_id",
"leave_type",
"start_date_time",
@ -2700,19 +2697,13 @@
"approval_status"
]
},
"LeaveRequestViewDto": {
"type": "object",
"properties": {}
},
"UpdateLeaveRequestsDto": {
"type": "object",
"properties": {
"id": {
"type": "number",
"example": 1,
"description": "Leave request`s unique id(auto-incremented)"
},
"employee_id": {
"type": "number",
"example": "4655867",
"description": "Employee`s id"
},
"bank_code_id": {
"type": "number",
"example": 7,
@ -2724,13 +2715,11 @@
"description": "type of leave request for an accounting perception"
},
"start_date_time": {
"format": "date-time",
"type": "string",
"example": "22/06/2463",
"description": "Leave request`s start date"
},
"end_date_time": {
"format": "date-time",
"type": "string",
"example": "25/03/3019",
"description": "Leave request`s end date"

View File

@ -65,7 +65,7 @@ export class ExpensesController {
return this.expensesService.remove(id);
}
@Patch(':id/approval')
@Patch('approval/:id')
//@RolesAllowed(RoleEnum.ACCOUNTING, RoleEnum.ADMIN, RoleEnum.HR, RoleEnum.SUPERVISOR)
async approve(@Param('id', ParseIntPipe) id: number, @Body('is_approved', ParseBoolPipe) isApproved: boolean) {
return this.expensesApprovalService.updateApproval(id, isApproved);

View File

@ -64,7 +64,7 @@ export class LeaveRequestController {
}
//remove emp_id and use email
@Patch(':id/approval')
@Patch('approval/:id')
updateApproval( @Param('id', ParseIntPipe) id: number,
@Body('is_approved', ParseBoolPipe) is_approved: boolean): Promise<LeaveRequestViewDto> {
const approvalStatus = is_approved ?

View File

@ -96,7 +96,14 @@ export class PayPeriodsQueryService {
const crew = await this.resolveCrew(supervisor.id, include_subtree); // [{ id, first_name, last_name }]
const crew_ids = crew.map(c => c.id);
// seed names map for employee without data
const seed_names = new Map<number, string>(crew.map(crew => [crew.id, `${crew.first_name} ${crew.last_name}`.trim()]));
const seed_names = new Map<number, { name: string; email: string }>(
crew.map(crew => [
crew.id,
{ name:`${crew.first_name} ${crew.last_name}`.trim(),
email: crew.email }
]
)
);
// 4) overview build
return this.buildOverview({
@ -112,7 +119,7 @@ export class PayPeriodsQueryService {
private async buildOverview(
period: { period_start: string | Date; period_end: string | Date; payday: string | Date;
period_no: number; pay_year: number; label: string; },
options?: { filtered_employee_ids?: number[]; seed_names?: Map<number, string> },
options?: { filtered_employee_ids?: number[]; seed_names?: Map<number, {name: string, email: string}>}
): Promise<PayPeriodOverviewDto> {
const toDateString = (d: Date) => d.toISOString().slice(0, 10);
const toMoney = (v: any) => (typeof v === "object" && "toNumber" in v ? v.toNumber() : (v as number));
@ -184,9 +191,9 @@ export class PayPeriodsQueryService {
// seed for employee without data
if (options?.seed_names) {
for (const [id, name] of options.seed_names.entries()) {
for (const [id, {name, email}] of options.seed_names.entries()) {
by_employee.set(id, {
email: '',
email,
employee_name: name,
regular_hours: 0,
evening_hours: 0,

View File

@ -67,7 +67,7 @@ export class ShiftsController {
return this.shiftsService.remove(id);
}
@Patch(':id/approval')
@Patch('approval/:id')
//@RolesAllowed(RoleEnum.ACCOUNTING, RoleEnum.ADMIN, RoleEnum.HR, RoleEnum.SUPERVISOR)
async approve(@Param('id', ParseIntPipe) id: number, @Body('is_approved', ParseBoolPipe) isApproved: boolean) {
return this.shiftsApprovalService.updateApproval(id, isApproved);

View File

@ -70,7 +70,7 @@ export class TimesheetsController {
return this.timesheetsQuery.remove(id);
}
@Patch(':id/approval')
@Patch('approval/:id')
//@RolesAllowed(RoleEnum.ACCOUNTING, RoleEnum.ADMIN, RoleEnum.HR, RoleEnum.SUPERVISOR)
async approve(@Param('id', ParseIntPipe) id: number, @Body('is_approved', ParseBoolPipe) isApproved: boolean) {
return this.timesheetsCommand.updateApproval(id, isApproved);