reafactor(time-and-attendance): organized files and folders and centralize module files
This commit is contained in:
parent
b69b9f30d8
commit
1289aed720
|
|
@ -71,142 +71,6 @@
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"/employees/employee-list": {
|
|
||||||
"get": {
|
|
||||||
"operationId": "EmployeesController_findListEmployees",
|
|
||||||
"parameters": [],
|
|
||||||
"responses": {
|
|
||||||
"200": {
|
|
||||||
"description": "List of employees with scoped info found",
|
|
||||||
"content": {
|
|
||||||
"application/json": {
|
|
||||||
"schema": {
|
|
||||||
"type": "array",
|
|
||||||
"items": {
|
|
||||||
"$ref": "#/components/schemas/EmployeeListItemDto"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"400": {
|
|
||||||
"description": "List of employees with scoped info not found"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"security": [
|
|
||||||
{
|
|
||||||
"access-token": []
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"summary": "Find all employees with scoped info",
|
|
||||||
"tags": [
|
|
||||||
"Employees"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"/employees/{email}": {
|
|
||||||
"patch": {
|
|
||||||
"operationId": "EmployeesController_updateOrArchiveOrRestore",
|
|
||||||
"parameters": [
|
|
||||||
{
|
|
||||||
"name": "email",
|
|
||||||
"required": true,
|
|
||||||
"in": "path",
|
|
||||||
"description": "Email of the employee",
|
|
||||||
"schema": {
|
|
||||||
"type": "number"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"requestBody": {
|
|
||||||
"required": true,
|
|
||||||
"content": {
|
|
||||||
"application/json": {
|
|
||||||
"schema": {
|
|
||||||
"$ref": "#/components/schemas/UpdateEmployeeDto"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"responses": {
|
|
||||||
"200": {
|
|
||||||
"description": "Employee updated or restored",
|
|
||||||
"content": {
|
|
||||||
"application/json": {
|
|
||||||
"schema": {
|
|
||||||
"$ref": "#/components/schemas/CreateEmployeeDto"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"202": {
|
|
||||||
"description": "Employee archived successfully",
|
|
||||||
"content": {
|
|
||||||
"application/json": {
|
|
||||||
"schema": {
|
|
||||||
"$ref": "#/components/schemas/CreateEmployeeDto"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"404": {
|
|
||||||
"description": "Employee not found in active or archive"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"security": [
|
|
||||||
{
|
|
||||||
"access-token": []
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"access-token": []
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"summary": "Update, archive or restore an employee",
|
|
||||||
"tags": [
|
|
||||||
"Employees"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"/employees/profile/{email}": {
|
|
||||||
"get": {
|
|
||||||
"operationId": "EmployeesController_findOneProfile",
|
|
||||||
"parameters": [
|
|
||||||
{
|
|
||||||
"name": "email",
|
|
||||||
"required": true,
|
|
||||||
"in": "path",
|
|
||||||
"description": "Identifier of the employee",
|
|
||||||
"schema": {
|
|
||||||
"type": "string"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"responses": {
|
|
||||||
"200": {
|
|
||||||
"description": "Employee profile found",
|
|
||||||
"content": {
|
|
||||||
"application/json": {
|
|
||||||
"schema": {
|
|
||||||
"$ref": "#/components/schemas/EmployeeProfileItemDto"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"400": {
|
|
||||||
"description": "Employee profile not found"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"security": [
|
|
||||||
{
|
|
||||||
"access-token": []
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"summary": "Find employee profile",
|
|
||||||
"tags": [
|
|
||||||
"Employees"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"/notifications/summary": {
|
"/notifications/summary": {
|
||||||
"get": {
|
"get": {
|
||||||
"operationId": "NotificationsController_summary",
|
"operationId": "NotificationsController_summary",
|
||||||
|
|
@ -649,6 +513,39 @@
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"/preferences/{email}": {
|
||||||
|
"patch": {
|
||||||
|
"operationId": "PreferencesController_updatePreferences",
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"name": "email",
|
||||||
|
"required": true,
|
||||||
|
"in": "path",
|
||||||
|
"schema": {
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"requestBody": {
|
||||||
|
"required": true,
|
||||||
|
"content": {
|
||||||
|
"application/json": {
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/components/schemas/PreferencesDto"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"responses": {
|
||||||
|
"200": {
|
||||||
|
"description": ""
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"tags": [
|
||||||
|
"Preferences"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
"/timesheets": {
|
"/timesheets": {
|
||||||
"get": {
|
"get": {
|
||||||
"operationId": "TimesheetController_getTimesheetByIds",
|
"operationId": "TimesheetController_getTimesheetByIds",
|
||||||
|
|
@ -688,41 +585,6 @@
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"/shift": {
|
|
||||||
"get": {
|
|
||||||
"operationId": "ShiftController_getShiftsByIds",
|
|
||||||
"parameters": [
|
|
||||||
{
|
|
||||||
"name": "shift_ids",
|
|
||||||
"required": true,
|
|
||||||
"in": "query",
|
|
||||||
"schema": {
|
|
||||||
"type": "string"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"responses": {
|
|
||||||
"200": {
|
|
||||||
"description": ""
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"tags": [
|
|
||||||
"Shift"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"patch": {
|
|
||||||
"operationId": "ShiftController_updateBatch",
|
|
||||||
"parameters": [],
|
|
||||||
"responses": {
|
|
||||||
"200": {
|
|
||||||
"description": ""
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"tags": [
|
|
||||||
"Shift"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"/shift/{timesheet_id}": {
|
"/shift/{timesheet_id}": {
|
||||||
"post": {
|
"post": {
|
||||||
"operationId": "ShiftController_createBatch",
|
"operationId": "ShiftController_createBatch",
|
||||||
|
|
@ -759,6 +621,20 @@
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"/shift": {
|
||||||
|
"patch": {
|
||||||
|
"operationId": "ShiftController_updateBatch",
|
||||||
|
"parameters": [],
|
||||||
|
"responses": {
|
||||||
|
"200": {
|
||||||
|
"description": ""
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"tags": [
|
||||||
|
"Shift"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
"/shift/{shift_id}": {
|
"/shift/{shift_id}": {
|
||||||
"delete": {
|
"delete": {
|
||||||
"operationId": "ShiftController_remove",
|
"operationId": "ShiftController_remove",
|
||||||
|
|
@ -782,39 +658,6 @@
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"/preferences/{email}": {
|
|
||||||
"patch": {
|
|
||||||
"operationId": "PreferencesController_updatePreferences",
|
|
||||||
"parameters": [
|
|
||||||
{
|
|
||||||
"name": "email",
|
|
||||||
"required": true,
|
|
||||||
"in": "path",
|
|
||||||
"schema": {
|
|
||||||
"type": "string"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"requestBody": {
|
|
||||||
"required": true,
|
|
||||||
"content": {
|
|
||||||
"application/json": {
|
|
||||||
"schema": {
|
|
||||||
"$ref": "#/components/schemas/PreferencesDto"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"responses": {
|
|
||||||
"200": {
|
|
||||||
"description": ""
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"tags": [
|
|
||||||
"Preferences"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"/schedule-presets/{email}": {
|
"/schedule-presets/{email}": {
|
||||||
"put": {
|
"put": {
|
||||||
"operationId": "SchedulePresetsController_upsert",
|
"operationId": "SchedulePresetsController_upsert",
|
||||||
|
|
@ -915,6 +758,100 @@
|
||||||
"SchedulePresets"
|
"SchedulePresets"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"/expense/{timesheet_id}": {
|
||||||
|
"post": {
|
||||||
|
"operationId": "ExpenseController_create",
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"name": "timesheet_id",
|
||||||
|
"required": true,
|
||||||
|
"in": "path",
|
||||||
|
"schema": {
|
||||||
|
"type": "number"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"requestBody": {
|
||||||
|
"required": true,
|
||||||
|
"content": {
|
||||||
|
"application/json": {
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/components/schemas/ExpenseDto"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"responses": {
|
||||||
|
"201": {
|
||||||
|
"description": ""
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"tags": [
|
||||||
|
"Expense"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"/expense": {
|
||||||
|
"patch": {
|
||||||
|
"operationId": "ExpenseController_update",
|
||||||
|
"parameters": [],
|
||||||
|
"responses": {
|
||||||
|
"200": {
|
||||||
|
"description": ""
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"tags": [
|
||||||
|
"Expense"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"/expense/{expense_id}": {
|
||||||
|
"delete": {
|
||||||
|
"operationId": "ExpenseController_remove",
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"name": "expense_id",
|
||||||
|
"required": true,
|
||||||
|
"in": "path",
|
||||||
|
"schema": {
|
||||||
|
"type": "number"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"responses": {
|
||||||
|
"200": {
|
||||||
|
"description": ""
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"tags": [
|
||||||
|
"Expense"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"/archives/expenses": {
|
||||||
|
"get": {
|
||||||
|
"operationId": "ExpensesArchiveController_findOneArchived",
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"name": "id",
|
||||||
|
"required": true,
|
||||||
|
"in": "path",
|
||||||
|
"schema": {
|
||||||
|
"type": "number"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"responses": {
|
||||||
|
"200": {
|
||||||
|
"description": "Archived expense found"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"summary": "Fetch expense in archives with its Id",
|
||||||
|
"tags": [
|
||||||
|
"Expense Archives"
|
||||||
|
]
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"info": {
|
"info": {
|
||||||
|
|
@ -974,162 +911,6 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"schemas": {
|
"schemas": {
|
||||||
"EmployeeListItemDto": {
|
|
||||||
"type": "object",
|
|
||||||
"properties": {}
|
|
||||||
},
|
|
||||||
"UpdateEmployeeDto": {
|
|
||||||
"type": "object",
|
|
||||||
"properties": {
|
|
||||||
"id": {
|
|
||||||
"type": "number",
|
|
||||||
"example": 1,
|
|
||||||
"description": "Unique ID of an employee(primary-key, auto-incremented)"
|
|
||||||
},
|
|
||||||
"user_id": {
|
|
||||||
"type": "string",
|
|
||||||
"example": "0e6e2e1f-b157-4c7c-ae3f-999b3e4f914d",
|
|
||||||
"description": "UUID of the user linked to that employee"
|
|
||||||
},
|
|
||||||
"first_name": {
|
|
||||||
"type": "string",
|
|
||||||
"example": "Frodo",
|
|
||||||
"description": "Employee`s first name"
|
|
||||||
},
|
|
||||||
"last_name": {
|
|
||||||
"type": "string",
|
|
||||||
"example": "Baggins",
|
|
||||||
"description": "Employee`s last name"
|
|
||||||
},
|
|
||||||
"email": {
|
|
||||||
"type": "string",
|
|
||||||
"example": "i_cant_do_this_sam@targointernet.com",
|
|
||||||
"description": "Employee`s email"
|
|
||||||
},
|
|
||||||
"phone_number": {
|
|
||||||
"type": "string",
|
|
||||||
"example": "82538437464",
|
|
||||||
"description": "Employee`s phone number"
|
|
||||||
},
|
|
||||||
"residence": {
|
|
||||||
"type": "string",
|
|
||||||
"example": "1 Bagshot Row, Hobbiton, The Shire, Middle-earth",
|
|
||||||
"description": "Employee`s residence"
|
|
||||||
},
|
|
||||||
"external_payroll_id": {
|
|
||||||
"type": "number",
|
|
||||||
"example": 7464,
|
|
||||||
"description": "external ID for the pay system"
|
|
||||||
},
|
|
||||||
"company_code": {
|
|
||||||
"type": "number",
|
|
||||||
"example": 335567447,
|
|
||||||
"description": "Employee`s company code"
|
|
||||||
},
|
|
||||||
"job_title": {
|
|
||||||
"type": "string",
|
|
||||||
"example": "technicient",
|
|
||||||
"description": "employee`s job title"
|
|
||||||
},
|
|
||||||
"first_work_day": {
|
|
||||||
"format": "date-time",
|
|
||||||
"type": "string",
|
|
||||||
"example": "23/09/3018",
|
|
||||||
"description": "New hire date or undefined"
|
|
||||||
},
|
|
||||||
"last_work_day": {
|
|
||||||
"format": "date-time",
|
|
||||||
"type": "string",
|
|
||||||
"example": "25/03/3019",
|
|
||||||
"description": "Termination date (null to restore)"
|
|
||||||
},
|
|
||||||
"supervisor_id": {
|
|
||||||
"type": "number",
|
|
||||||
"description": "Supervisor ID"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"CreateEmployeeDto": {
|
|
||||||
"type": "object",
|
|
||||||
"properties": {
|
|
||||||
"id": {
|
|
||||||
"type": "number",
|
|
||||||
"example": 1,
|
|
||||||
"description": "Unique ID of an employee(primary-key, auto-incremented)"
|
|
||||||
},
|
|
||||||
"user_id": {
|
|
||||||
"type": "string",
|
|
||||||
"example": "0e6e2e1f-b157-4c7c-ae3f-999b3e4f914d",
|
|
||||||
"description": "UUID of the user linked to that employee"
|
|
||||||
},
|
|
||||||
"first_name": {
|
|
||||||
"type": "string",
|
|
||||||
"example": "Frodo",
|
|
||||||
"description": "Employee`s first name"
|
|
||||||
},
|
|
||||||
"last_name": {
|
|
||||||
"type": "string",
|
|
||||||
"example": "Baggins",
|
|
||||||
"description": "Employee`s last name"
|
|
||||||
},
|
|
||||||
"email": {
|
|
||||||
"type": "string",
|
|
||||||
"example": "i_cant_do_this_sam@targointernet.com",
|
|
||||||
"description": "Employee`s email"
|
|
||||||
},
|
|
||||||
"phone_number": {
|
|
||||||
"type": "string",
|
|
||||||
"example": "82538437464",
|
|
||||||
"description": "Employee`s phone number"
|
|
||||||
},
|
|
||||||
"residence": {
|
|
||||||
"type": "string",
|
|
||||||
"example": "1 Bagshot Row, Hobbiton, The Shire, Middle-earth",
|
|
||||||
"description": "Employee`s residence"
|
|
||||||
},
|
|
||||||
"external_payroll_id": {
|
|
||||||
"type": "number",
|
|
||||||
"example": 7464,
|
|
||||||
"description": "external ID for the pay system"
|
|
||||||
},
|
|
||||||
"company_code": {
|
|
||||||
"type": "number",
|
|
||||||
"example": 335567447,
|
|
||||||
"description": "Employee`s company code"
|
|
||||||
},
|
|
||||||
"job_title": {
|
|
||||||
"type": "string",
|
|
||||||
"example": "technicient",
|
|
||||||
"description": "employee`s job title"
|
|
||||||
},
|
|
||||||
"first_work_day": {
|
|
||||||
"type": "string",
|
|
||||||
"example": "23/09/3018",
|
|
||||||
"description": "Employee`s first working day"
|
|
||||||
},
|
|
||||||
"last_work_day": {
|
|
||||||
"type": "string",
|
|
||||||
"example": "25/03/3019",
|
|
||||||
"description": "Employee`s last working day"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"required": [
|
|
||||||
"id",
|
|
||||||
"user_id",
|
|
||||||
"first_name",
|
|
||||||
"last_name",
|
|
||||||
"email",
|
|
||||||
"phone_number",
|
|
||||||
"external_payroll_id",
|
|
||||||
"company_code",
|
|
||||||
"job_title",
|
|
||||||
"first_work_day"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"EmployeeProfileItemDto": {
|
|
||||||
"type": "object",
|
|
||||||
"properties": {}
|
|
||||||
},
|
|
||||||
"CreateOauthSessionDto": {
|
"CreateOauthSessionDto": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
|
|
@ -1407,6 +1188,10 @@
|
||||||
"SchedulePresetsDto": {
|
"SchedulePresetsDto": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {}
|
"properties": {}
|
||||||
|
},
|
||||||
|
"ExpenseDto": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,28 +1,28 @@
|
||||||
import { PrismaClient, Roles } from '@prisma/client';
|
// import { PrismaClient, Roles } from '@prisma/client';
|
||||||
|
|
||||||
const prisma = new PrismaClient();
|
// const prisma = new PrismaClient();
|
||||||
|
|
||||||
async function main() {
|
// async function main() {
|
||||||
const customerUsers = await prisma.users.findMany({
|
// const customerUsers = await prisma.users.findMany({
|
||||||
where: { role: Roles.CUSTOMER },
|
// where: { role: Roles.CUSTOMER },
|
||||||
orderBy: { email: 'asc' },
|
// orderBy: { email: 'asc' },
|
||||||
});
|
// });
|
||||||
|
|
||||||
let i = 0;
|
// let i = 0;
|
||||||
for (const u of customerUsers) {
|
// for (const u of customerUsers) {
|
||||||
await prisma.customers.upsert({
|
// await prisma.customers.upsert({
|
||||||
where: { user_id: u.id },
|
// where: { user_id: u.id },
|
||||||
update: {},
|
// update: {},
|
||||||
create: {
|
// create: {
|
||||||
user_id: u.id,
|
// user_id: u.id,
|
||||||
invoice_id: i % 2 === 0 ? 100000 + i : null, // 1 sur 2 a un invoice_id
|
// invoice_id: i % 2 === 0 ? 100000 + i : null, // 1 sur 2 a un invoice_id
|
||||||
},
|
// },
|
||||||
});
|
// });
|
||||||
i++;
|
// i++;
|
||||||
}
|
// }
|
||||||
|
|
||||||
const total = await prisma.customers.count();
|
// const total = await prisma.customers.count();
|
||||||
console.log(`✓ Customers: ${total} rows`);
|
// console.log(`✓ Customers: ${total} rows`);
|
||||||
}
|
// }
|
||||||
|
|
||||||
main().finally(() => prisma.$disconnect());
|
// main().finally(() => prisma.$disconnect());
|
||||||
|
|
|
||||||
|
|
@ -1,45 +1,45 @@
|
||||||
import { PrismaClient } from '@prisma/client';
|
// import { PrismaClient } from '@prisma/client';
|
||||||
|
|
||||||
if (process.env.SKIP_LEAVE_REQUESTS === 'true') {
|
// if (process.env.SKIP_LEAVE_REQUESTS === 'true') {
|
||||||
console.log("⏭ Seed leave-requests ignoré (SKIP_LEAVE_REQUESTS=true)");
|
// console.log("⏭ Seed leave-requests ignoré (SKIP_LEAVE_REQUESTS=true)");
|
||||||
process.exit(0);
|
// process.exit(0);
|
||||||
}
|
// }
|
||||||
|
|
||||||
const prisma = new PrismaClient();
|
// const prisma = new PrismaClient();
|
||||||
|
|
||||||
function daysAgo(n: number) {
|
// function daysAgo(n: number) {
|
||||||
const d = new Date();
|
// const d = new Date();
|
||||||
d.setDate(d.getDate() - n);
|
// d.setDate(d.getDate() - n);
|
||||||
d.setHours(0,0,0,0);
|
// d.setHours(0,0,0,0);
|
||||||
return d;
|
// return d;
|
||||||
}
|
// }
|
||||||
|
|
||||||
async function main() {
|
// async function main() {
|
||||||
const employees = await prisma.employees.findMany({
|
// const employees = await prisma.employees.findMany({
|
||||||
include: { user: true },
|
// include: { user: true },
|
||||||
take: 10, // archive 10
|
// take: 10, // archive 10
|
||||||
});
|
// });
|
||||||
|
|
||||||
for (const e of employees) {
|
// for (const e of employees) {
|
||||||
await prisma.employeesArchive.create({
|
// await prisma.employeesArchive.create({
|
||||||
data: {
|
// data: {
|
||||||
employee_id: e.id,
|
// employee_id: e.id,
|
||||||
user_id: e.user_id,
|
// user_id: e.user_id,
|
||||||
first_name: e.user.first_name,
|
// first_name: e.user.first_name,
|
||||||
last_name: e.user.last_name,
|
// last_name: e.user.last_name,
|
||||||
external_payroll_id: e.external_payroll_id,
|
// external_payroll_id: e.external_payroll_id,
|
||||||
company_code: e.company_code,
|
// company_code: e.company_code,
|
||||||
first_work_day: e.first_work_day,
|
// first_work_day: e.first_work_day,
|
||||||
last_work_day: daysAgo(30),
|
// last_work_day: daysAgo(30),
|
||||||
supervisor_id: e.supervisor_id ?? null,
|
// supervisor_id: e.supervisor_id ?? null,
|
||||||
job_title: e.job_title,
|
// job_title: e.job_title,
|
||||||
is_supervisor: e.is_supervisor,
|
// is_supervisor: e.is_supervisor,
|
||||||
},
|
// },
|
||||||
});
|
// });
|
||||||
}
|
// }
|
||||||
|
|
||||||
const total = await prisma.employeesArchive.count();
|
// const total = await prisma.employeesArchive.count();
|
||||||
console.log(`✓ EmployeesArchive: ${total} rows (added 10)`);
|
// console.log(`✓ EmployeesArchive: ${total} rows (added 10)`);
|
||||||
}
|
// }
|
||||||
|
|
||||||
main().finally(() => prisma.$disconnect());
|
// main().finally(() => prisma.$disconnect());
|
||||||
|
|
|
||||||
|
|
@ -1,35 +1,35 @@
|
||||||
// prisma/mock-seeds-scripts/06-customers-archive.ts
|
// // prisma/mock-seeds-scripts/06-customers-archive.ts
|
||||||
import { PrismaClient } from '@prisma/client';
|
// import { PrismaClient } from '@prisma/client';
|
||||||
|
|
||||||
if (process.env.SKIP_LEAVE_REQUESTS === 'true') {
|
// if (process.env.SKIP_LEAVE_REQUESTS === 'true') {
|
||||||
console.log("⏭ Seed leave-requests ignoré (SKIP_LEAVE_REQUESTS=true)");
|
// console.log("⏭ Seed leave-requests ignoré (SKIP_LEAVE_REQUESTS=true)");
|
||||||
process.exit(0);
|
// process.exit(0);
|
||||||
}
|
// }
|
||||||
|
|
||||||
const prisma = new PrismaClient();
|
// const prisma = new PrismaClient();
|
||||||
|
|
||||||
async function main() {
|
// async function main() {
|
||||||
const customers = await prisma.customers.findMany({
|
// const customers = await prisma.customers.findMany({
|
||||||
orderBy: { id: 'asc' },
|
// orderBy: { id: 'asc' },
|
||||||
take: 5,
|
// take: 5,
|
||||||
});
|
// });
|
||||||
|
|
||||||
for (const c of customers) {
|
// for (const c of customers) {
|
||||||
const invoiceId = 200000 + c.id; // déterministe, stable entre runs
|
// const invoiceId = 200000 + c.id; // déterministe, stable entre runs
|
||||||
|
|
||||||
await prisma.customersArchive.upsert({
|
// await prisma.customersArchive.upsert({
|
||||||
where: { invoice_id: invoiceId }, // invoice_id est unique
|
// where: { invoice_id: invoiceId }, // invoice_id est unique
|
||||||
update: {}, // idempotent
|
// update: {}, // idempotent
|
||||||
create: {
|
// create: {
|
||||||
customer_id: c.id,
|
// customer_id: c.id,
|
||||||
user_id: c.user_id,
|
// user_id: c.user_id,
|
||||||
invoice_id: invoiceId,
|
// invoice_id: invoiceId,
|
||||||
},
|
// },
|
||||||
});
|
// });
|
||||||
}
|
// }
|
||||||
|
|
||||||
const total = await prisma.customersArchive.count();
|
// const total = await prisma.customersArchive.count();
|
||||||
console.log(`✓ CustomersArchive upserted for ${customers.length} customers (total=${total})`);
|
// console.log(`✓ CustomersArchive upserted for ${customers.length} customers (total=${total})`);
|
||||||
}
|
// }
|
||||||
|
|
||||||
main().finally(() => prisma.$disconnect());
|
// main().finally(() => prisma.$disconnect());
|
||||||
|
|
|
||||||
|
|
@ -1,87 +1,87 @@
|
||||||
import { PrismaClient, LeaveApprovalStatus, LeaveTypes } from '@prisma/client';
|
// import { PrismaClient, LeaveApprovalStatus, LeaveTypes } from '@prisma/client';
|
||||||
|
|
||||||
if (process.env.SKIP_LEAVE_REQUESTS === 'true') {
|
// if (process.env.SKIP_LEAVE_REQUESTS === 'true') {
|
||||||
console.log('?? Seed leave-requests ignoré (SKIP_LEAVE_REQUESTS=true)');
|
// console.log('?? Seed leave-requests ignor<6F> (SKIP_LEAVE_REQUESTS=true)');
|
||||||
process.exit(0);
|
// process.exit(0);
|
||||||
}
|
// }
|
||||||
|
|
||||||
const prisma = new PrismaClient();
|
// const prisma = new PrismaClient();
|
||||||
|
|
||||||
function daysAgo(n: number) {
|
// function daysAgo(n: number) {
|
||||||
const d = new Date();
|
// const d = new Date();
|
||||||
d.setUTCDate(d.getUTCDate() - n);
|
// d.setUTCDate(d.getUTCDate() - n);
|
||||||
d.setUTCHours(0, 0, 0, 0);
|
// d.setUTCHours(0, 0, 0, 0);
|
||||||
return d;
|
// return d;
|
||||||
}
|
// }
|
||||||
|
|
||||||
async function main() {
|
// async function main() {
|
||||||
const employees = await prisma.employees.findMany({ select: { id: true } });
|
// const employees = await prisma.employees.findMany({ select: { id: true } });
|
||||||
if (!employees.length) {
|
// if (!employees.length) {
|
||||||
throw new Error('Aucun employé trouvé. Exécute le seed employees avant celui-ci.');
|
// throw new Error('Aucun employ<6F> trouv<75>. Ex<45>cute le seed employees avant celui-ci.');
|
||||||
}
|
// }
|
||||||
|
|
||||||
const leaveCodes = await prisma.bankCodes.findMany({
|
// const leaveCodes = await prisma.bankCodes.findMany({
|
||||||
where: { type: { in: ['SICK', 'VACATION', 'HOLIDAY'] } },
|
// where: { type: { in: ['SICK', 'VACATION', 'HOLIDAY'] } },
|
||||||
select: { id: true, type: true },
|
// select: { id: true, type: true },
|
||||||
});
|
// });
|
||||||
if (!leaveCodes.length) {
|
// if (!leaveCodes.length) {
|
||||||
throw new Error("Aucun bank code trouvé avec type in ('SICK','VACATION','HOLIDAY'). Vérifie ta table bank_codes.");
|
// throw new Error("Aucun bank code trouv<75> avec type in ('SICK','VACATION','HOLIDAY'). V<>rifie ta table bank_codes.");
|
||||||
}
|
// }
|
||||||
|
|
||||||
const statuses = Object.values(LeaveApprovalStatus);
|
// const statuses = Object.values(LeaveApprovalStatus);
|
||||||
const created = [] as Array<{ id: number; employee_id: number; leave_type: LeaveTypes; date: Date; comment: string; approval_status: LeaveApprovalStatus; requested_hours: number; payable_hours: number | null }>;
|
// const created = [] as Array<{ id: number; employee_id: number; leave_type: LeaveTypes; date: Date; comment: string; approval_status: LeaveApprovalStatus; requested_hours: number; payable_hours: number | null }>;
|
||||||
|
|
||||||
const COUNT = 12;
|
// const COUNT = 12;
|
||||||
for (let i = 0; i < COUNT; i++) {
|
// for (let i = 0; i < COUNT; i++) {
|
||||||
const emp = employees[i % employees.length];
|
// const emp = employees[i % employees.length];
|
||||||
const leaveCode = leaveCodes[Math.floor(Math.random() * leaveCodes.length)];
|
// const leaveCode = leaveCodes[Math.floor(Math.random() * leaveCodes.length)];
|
||||||
|
|
||||||
const date = daysAgo(120 - i * 3);
|
// const date = daysAgo(120 - i * 3);
|
||||||
const status = statuses[(i + 2) % statuses.length];
|
// const status = statuses[(i + 2) % statuses.length];
|
||||||
const requestedHours = 4 + (i % 5); // 4 ? 8 h
|
// const requestedHours = 4 + (i % 5); // 4 ? 8 h
|
||||||
const payableHours = status === LeaveApprovalStatus.APPROVED ? Math.min(requestedHours, 8) : null;
|
// const payableHours = status === LeaveApprovalStatus.APPROVED ? Math.min(requestedHours, 8) : null;
|
||||||
|
|
||||||
const lr = await prisma.leaveRequests.create({
|
// const lr = await prisma.leaveRequests.create({
|
||||||
data: {
|
// data: {
|
||||||
employee_id: emp.id,
|
// employee_id: emp.id,
|
||||||
bank_code_id: leaveCode.id,
|
// bank_code_id: leaveCode.id,
|
||||||
leave_type: leaveCode.type as LeaveTypes,
|
// leave_type: leaveCode.type as LeaveTypes,
|
||||||
date,
|
// date,
|
||||||
comment: `Past leave #${i + 1} (${leaveCode.type})`,
|
// comment: `Past leave #${i + 1} (${leaveCode.type})`,
|
||||||
approval_status: status,
|
// approval_status: status,
|
||||||
requested_hours: requestedHours,
|
// requested_hours: requestedHours,
|
||||||
payable_hours: payableHours,
|
// payable_hours: payableHours,
|
||||||
},
|
// },
|
||||||
});
|
// });
|
||||||
|
|
||||||
created.push({
|
// created.push({
|
||||||
id: lr.id,
|
// id: lr.id,
|
||||||
employee_id: lr.employee_id,
|
// employee_id: lr.employee_id,
|
||||||
leave_type: lr.leave_type,
|
// leave_type: lr.leave_type,
|
||||||
date: lr.date,
|
// date: lr.date,
|
||||||
comment: lr.comment,
|
// comment: lr.comment,
|
||||||
approval_status: lr.approval_status,
|
// approval_status: lr.approval_status,
|
||||||
requested_hours: requestedHours,
|
// requested_hours: requestedHours,
|
||||||
payable_hours: payableHours,
|
// payable_hours: payableHours,
|
||||||
});
|
// });
|
||||||
}
|
// }
|
||||||
|
|
||||||
for (const lr of created) {
|
// for (const lr of created) {
|
||||||
await prisma.leaveRequestsArchive.create({
|
// await prisma.leaveRequestsArchive.create({
|
||||||
data: {
|
// data: {
|
||||||
leave_request_id: lr.id,
|
// leave_request_id: lr.id,
|
||||||
employee_id: lr.employee_id,
|
// employee_id: lr.employee_id,
|
||||||
leave_type: lr.leave_type,
|
// leave_type: lr.leave_type,
|
||||||
date: lr.date,
|
// date: lr.date,
|
||||||
comment: lr.comment,
|
// comment: lr.comment,
|
||||||
approval_status: lr.approval_status,
|
// approval_status: lr.approval_status,
|
||||||
requested_hours: lr.requested_hours,
|
// requested_hours: lr.requested_hours,
|
||||||
payable_hours: lr.payable_hours,
|
// payable_hours: lr.payable_hours,
|
||||||
},
|
// },
|
||||||
});
|
// });
|
||||||
}
|
// }
|
||||||
|
|
||||||
console.log(`? LeaveRequestsArchive: ${created.length} rows`);
|
// console.log(`? LeaveRequestsArchive: ${created.length} rows`);
|
||||||
}
|
// }
|
||||||
|
|
||||||
main().finally(() => prisma.$disconnect());
|
// main().finally(() => prisma.$disconnect());
|
||||||
|
|
@ -1,71 +1,71 @@
|
||||||
import { PrismaClient } from '@prisma/client';
|
// import { PrismaClient } from '@prisma/client';
|
||||||
|
|
||||||
if (process.env.SKIP_LEAVE_REQUESTS === 'true') {
|
// if (process.env.SKIP_LEAVE_REQUESTS === 'true') {
|
||||||
console.log("⏭ Seed leave-requests ignoré (SKIP_LEAVE_REQUESTS=true)");
|
// console.log("⏭ Seed leave-requests ignoré (SKIP_LEAVE_REQUESTS=true)");
|
||||||
process.exit(0);
|
// process.exit(0);
|
||||||
}
|
// }
|
||||||
|
|
||||||
const prisma = new PrismaClient();
|
// const prisma = new PrismaClient();
|
||||||
|
|
||||||
function timeAt(h:number,m:number) {
|
// function timeAt(h:number,m:number) {
|
||||||
return new Date(Date.UTC(1970,0,1,h,m,0));
|
// return new Date(Date.UTC(1970,0,1,h,m,0));
|
||||||
}
|
// }
|
||||||
function daysAgo(n:number) {
|
// function daysAgo(n:number) {
|
||||||
const d = new Date();
|
// const d = new Date();
|
||||||
d.setUTCDate(d.getUTCDate() - n);
|
// d.setUTCDate(d.getUTCDate() - n);
|
||||||
d.setUTCHours(0,0,0,0);
|
// d.setUTCHours(0,0,0,0);
|
||||||
return d;
|
// return d;
|
||||||
}
|
// }
|
||||||
|
|
||||||
async function main() {
|
// async function main() {
|
||||||
const bankCodes = await prisma.bankCodes.findMany({ where: { categorie: 'SHIFT' }, select: { id: true } });
|
// const bankCodes = await prisma.bankCodes.findMany({ where: { categorie: 'SHIFT' }, select: { id: true } });
|
||||||
const employees = await prisma.employees.findMany({ select: { id: true } });
|
// const employees = await prisma.employees.findMany({ select: { id: true } });
|
||||||
|
|
||||||
for (const e of employees) {
|
// for (const e of employees) {
|
||||||
const tss = await prisma.timesheets.findMany({ where: { employee_id: e.id }, select: { id: true } });
|
// const tss = await prisma.timesheets.findMany({ where: { employee_id: e.id }, select: { id: true } });
|
||||||
if (!tss.length) continue;
|
// if (!tss.length) continue;
|
||||||
|
|
||||||
const createdShiftIds: number[] = [];
|
// const createdShiftIds: number[] = [];
|
||||||
for (let i = 0; i < 8; i++) {
|
// for (let i = 0; i < 8; i++) {
|
||||||
const ts = tss[i % tss.length];
|
// const ts = tss[i % tss.length];
|
||||||
const bc = bankCodes[i % bankCodes.length];
|
// const bc = bankCodes[i % bankCodes.length];
|
||||||
const date = daysAgo(200 + i); // bien dans le passé
|
// const date = daysAgo(200 + i); // bien dans le passé
|
||||||
const startH = 7 + (i % 4); // 7..10
|
// const startH = 7 + (i % 4); // 7..10
|
||||||
const endH = startH + 8; // 15..18
|
// const endH = startH + 8; // 15..18
|
||||||
|
|
||||||
const sh = await prisma.shifts.create({
|
// const sh = await prisma.shifts.create({
|
||||||
data: {
|
// data: {
|
||||||
timesheet_id: ts.id,
|
// timesheet_id: ts.id,
|
||||||
bank_code_id: bc.id,
|
// bank_code_id: bc.id,
|
||||||
comment: `Archived-era shift ${i + 1} for emp ${e.id}`,
|
// comment: `Archived-era shift ${i + 1} for emp ${e.id}`,
|
||||||
date,
|
// date,
|
||||||
start_time: timeAt(startH, 0),
|
// start_time: timeAt(startH, 0),
|
||||||
end_time: timeAt(endH, 0),
|
// end_time: timeAt(endH, 0),
|
||||||
is_approved: true,
|
// is_approved: true,
|
||||||
},
|
// },
|
||||||
});
|
// });
|
||||||
createdShiftIds.push(sh.id);
|
// createdShiftIds.push(sh.id);
|
||||||
}
|
// }
|
||||||
|
|
||||||
for (const sid of createdShiftIds) {
|
// for (const sid of createdShiftIds) {
|
||||||
const s = await prisma.shifts.findUnique({ where: { id: sid } });
|
// const s = await prisma.shifts.findUnique({ where: { id: sid } });
|
||||||
if (!s) continue;
|
// if (!s) continue;
|
||||||
await prisma.shiftsArchive.create({
|
// await prisma.shiftsArchive.create({
|
||||||
data: {
|
// data: {
|
||||||
shift_id: s.id,
|
// shift_id: s.id,
|
||||||
timesheet_id: s.timesheet_id,
|
// timesheet_id: s.timesheet_id,
|
||||||
bank_code_id: s.bank_code_id,
|
// bank_code_id: s.bank_code_id,
|
||||||
comment: s.comment,
|
// comment: s.comment,
|
||||||
date: s.date,
|
// date: s.date,
|
||||||
start_time: s.start_time,
|
// start_time: s.start_time,
|
||||||
end_time: s.end_time,
|
// end_time: s.end_time,
|
||||||
},
|
// },
|
||||||
});
|
// });
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
const total = await prisma.shiftsArchive.count();
|
// const total = await prisma.shiftsArchive.count();
|
||||||
console.log(`✓ ShiftsArchive: ${total} rows total`);
|
// console.log(`✓ ShiftsArchive: ${total} rows total`);
|
||||||
}
|
// }
|
||||||
|
|
||||||
main().finally(() => prisma.$disconnect());
|
// main().finally(() => prisma.$disconnect());
|
||||||
|
|
|
||||||
|
|
@ -1,65 +1,65 @@
|
||||||
// 13-expenses-archive.ts
|
// // 13-expenses-archive.ts
|
||||||
import { PrismaClient, Expenses } from '@prisma/client';
|
// import { PrismaClient, Expenses } from '@prisma/client';
|
||||||
|
|
||||||
if (process.env.SKIP_LEAVE_REQUESTS === 'true') {
|
// if (process.env.SKIP_LEAVE_REQUESTS === 'true') {
|
||||||
console.log("⏭ Seed leave-requests ignoré (SKIP_LEAVE_REQUESTS=true)");
|
// console.log("⏭ Seed leave-requests ignoré (SKIP_LEAVE_REQUESTS=true)");
|
||||||
process.exit(0);
|
// process.exit(0);
|
||||||
}
|
// }
|
||||||
|
|
||||||
const prisma = new PrismaClient();
|
// const prisma = new PrismaClient();
|
||||||
|
|
||||||
function daysAgo(n:number) {
|
// function daysAgo(n:number) {
|
||||||
const d = new Date();
|
// const d = new Date();
|
||||||
d.setUTCDate(d.getUTCDate() - n);
|
// d.setUTCDate(d.getUTCDate() - n);
|
||||||
d.setUTCHours(0,0,0,0);
|
// d.setUTCHours(0,0,0,0);
|
||||||
return d;
|
// return d;
|
||||||
}
|
// }
|
||||||
|
|
||||||
async function main() {
|
// async function main() {
|
||||||
const expenseCodes = await prisma.bankCodes.findMany({ where: { categorie: 'EXPENSE' }, select: { id: true } });
|
// const expenseCodes = await prisma.bankCodes.findMany({ where: { categorie: 'EXPENSE' }, select: { id: true } });
|
||||||
const timesheets = await prisma.timesheets.findMany({ select: { id: true } });
|
// const timesheets = await prisma.timesheets.findMany({ select: { id: true } });
|
||||||
|
|
||||||
// ✅ typer pour éviter never[]
|
// // ✅ typer pour éviter never[]
|
||||||
const created: Expenses[] = [];
|
// const created: Expenses[] = [];
|
||||||
|
|
||||||
for (let i = 0; i < 4; i++) {
|
// for (let i = 0; i < 4; i++) {
|
||||||
const ts = timesheets[i % timesheets.length];
|
// const ts = timesheets[i % timesheets.length];
|
||||||
const bc = expenseCodes[i % expenseCodes.length];
|
// const bc = expenseCodes[i % expenseCodes.length];
|
||||||
|
|
||||||
const exp = await prisma.expenses.create({
|
// const exp = await prisma.expenses.create({
|
||||||
data: {
|
// data: {
|
||||||
timesheet_id: ts.id,
|
// timesheet_id: ts.id,
|
||||||
bank_code_id: bc.id,
|
// bank_code_id: bc.id,
|
||||||
date: daysAgo(60 + i),
|
// date: daysAgo(60 + i),
|
||||||
amount: (20 + i * 3.5).toFixed(2), // ok: Decimal accepte string
|
// amount: (20 + i * 3.5).toFixed(2), // ok: Decimal accepte string
|
||||||
attachment: null,
|
// attachment: null,
|
||||||
comment: `Old expense #${i + 1}`,
|
// comment: `Old expense #${i + 1}`,
|
||||||
is_approved: true,
|
// is_approved: true,
|
||||||
supervisor_comment: null,
|
// supervisor_comment: null,
|
||||||
},
|
// },
|
||||||
});
|
// });
|
||||||
|
|
||||||
created.push(exp);
|
// created.push(exp);
|
||||||
}
|
// }
|
||||||
|
|
||||||
for (const e of created) {
|
// for (const e of created) {
|
||||||
await prisma.expensesArchive.create({
|
// await prisma.expensesArchive.create({
|
||||||
data: {
|
// data: {
|
||||||
expense_id: e.id,
|
// expense_id: e.id,
|
||||||
timesheet_id: e.timesheet_id,
|
// timesheet_id: e.timesheet_id,
|
||||||
bank_code_id: e.bank_code_id,
|
// bank_code_id: e.bank_code_id,
|
||||||
date: e.date,
|
// date: e.date,
|
||||||
amount: e.amount,
|
// amount: e.amount,
|
||||||
attachment: e.attachment,
|
// attachment: e.attachment,
|
||||||
comment: e.comment,
|
// comment: e.comment,
|
||||||
is_approved: e.is_approved,
|
// is_approved: e.is_approved,
|
||||||
supervisor_comment: e.supervisor_comment,
|
// supervisor_comment: e.supervisor_comment,
|
||||||
},
|
// },
|
||||||
});
|
// });
|
||||||
}
|
// }
|
||||||
|
|
||||||
const total = await prisma.expensesArchive.count();
|
// const total = await prisma.expensesArchive.count();
|
||||||
console.log(`✓ ExpensesArchive: ${total} total rows (added ${created.length})`);
|
// console.log(`✓ ExpensesArchive: ${total} total rows (added ${created.length})`);
|
||||||
}
|
// }
|
||||||
|
|
||||||
main().finally(() => prisma.$disconnect());
|
// main().finally(() => prisma.$disconnect());
|
||||||
|
|
|
||||||
|
|
@ -4,58 +4,45 @@ import { AppService } from './app.service';
|
||||||
// import { ArchivalModule } from './modules/archival/archival.module';
|
// import { ArchivalModule } from './modules/archival/archival.module';
|
||||||
import { AuthenticationModule } from './modules/authentication/auth.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 { BusinessLogicsModule } from './modules/business-logics/business-logics.module';
|
|
||||||
// import { CsvExportModule } from './modules/exports/csv-exports.module';
|
// import { CsvExportModule } from './modules/exports/csv-exports.module';
|
||||||
import { CustomersModule } from './modules/customers/customers.module';
|
|
||||||
import { EmployeesModule } from './modules/employees/employees.module';
|
|
||||||
// import { ExpensesModule } from './modules/expenses/expenses.module';
|
|
||||||
import { HealthModule } from './health/health.module';
|
import { HealthModule } from './health/health.module';
|
||||||
import { HealthController } from './health/health.controller';
|
import { HealthController } from './health/health.controller';
|
||||||
// import { LeaveRequestsModule } from './modules/leave-requests/leave-requests.module';
|
|
||||||
import { NotificationsModule } from './modules/notifications/notifications.module';
|
import { NotificationsModule } from './modules/notifications/notifications.module';
|
||||||
import { OauthSessionsModule } from './modules/oauth-sessions/oauth-sessions.module';
|
import { OauthSessionsModule } from './modules/oauth-sessions/oauth-sessions.module';
|
||||||
import { OvertimeService } from './modules/business-logics/services/overtime.service';
|
|
||||||
import { PreferencesModule } from './modules/preferences/preferences.module';
|
import { PreferencesModule } from './modules/preferences/preferences.module';
|
||||||
import { PrismaModule } from './prisma/prisma.module';
|
import { PrismaModule } from './prisma/prisma.module';
|
||||||
import { ScheduleModule } from '@nestjs/schedule';
|
import { ScheduleModule } from '@nestjs/schedule';
|
||||||
import { ShiftsModule } from './Time_And_Attendance/modules/time-tracker/shifts/shifts.module';
|
|
||||||
import { TimesheetsModule } from './Time_And_Attendance/modules/time-tracker/timesheets/timesheets.module';
|
|
||||||
import { UsersModule } from './modules/users-management/users.module';
|
import { UsersModule } from './modules/users-management/users.module';
|
||||||
import { ConfigModule } from '@nestjs/config';
|
import { ConfigModule } from '@nestjs/config';
|
||||||
import { APP_FILTER, APP_PIPE } from '@nestjs/core';
|
import { APP_FILTER, APP_PIPE } from '@nestjs/core';
|
||||||
import { HttpExceptionFilter } from './common/filters/http-exception.filter';
|
import { HttpExceptionFilter } from './common/filters/http-exception.filter';
|
||||||
import { ValidationError } from 'class-validator';
|
import { ValidationError } from 'class-validator';
|
||||||
import { SchedulePresetsModule } from './modules/schedule-presets/schedule-presets.module';
|
import { PayperiodsModule } from './time-and-attendance/modules/pay-period/pay-periods.module';
|
||||||
import { PayperiodsModule } from './Time_And_Attendance/modules/pay-period/pay-periods.module';
|
import { TimeAndAttendanceModule } from 'src/time-and-attendance/time-and-attendance.module';
|
||||||
|
|
||||||
@Module({
|
@Module({
|
||||||
imports: [
|
imports: [
|
||||||
// ArchivalModule,
|
|
||||||
AuthenticationModule,
|
AuthenticationModule,
|
||||||
BankCodesModule,
|
BankCodesModule,
|
||||||
BusinessLogicsModule,
|
|
||||||
ConfigModule.forRoot({isGlobal: true}),
|
ConfigModule.forRoot({isGlobal: true}),
|
||||||
// CsvExportModule,
|
// CsvExportModule,
|
||||||
CustomersModule,
|
// CustomersModule,
|
||||||
EmployeesModule,
|
// EmployeesModule,
|
||||||
// ExpensesModule,
|
|
||||||
HealthModule,
|
HealthModule,
|
||||||
// LeaveRequestsModule,
|
|
||||||
NotificationsModule,
|
NotificationsModule,
|
||||||
OauthSessionsModule,
|
OauthSessionsModule,
|
||||||
PayperiodsModule,
|
PayperiodsModule,
|
||||||
PreferencesModule,
|
PreferencesModule,
|
||||||
PrismaModule,
|
PrismaModule,
|
||||||
ScheduleModule.forRoot(), //cronjobs
|
ScheduleModule.forRoot(), //cronjobs
|
||||||
SchedulePresetsModule,
|
// ShiftsModule,
|
||||||
ShiftsModule,
|
TimeAndAttendanceModule,
|
||||||
TimesheetsModule,
|
// TimesheetsModule,
|
||||||
UsersModule,
|
UsersModule,
|
||||||
],
|
],
|
||||||
controllers: [AppController, HealthController],
|
controllers: [AppController, HealthController],
|
||||||
providers: [
|
providers: [
|
||||||
AppService,
|
AppService,
|
||||||
OvertimeService,
|
|
||||||
{
|
{
|
||||||
provide: APP_FILTER,
|
provide: APP_FILTER,
|
||||||
useClass: HttpExceptionFilter
|
useClass: HttpExceptionFilter
|
||||||
|
|
|
||||||
13
src/identity-and-account/employees/employees.module.ts
Normal file
13
src/identity-and-account/employees/employees.module.ts
Normal file
|
|
@ -0,0 +1,13 @@
|
||||||
|
// import { Module } from '@nestjs/common';
|
||||||
|
// import { EmployeesController } from './controllers/employees.controller';
|
||||||
|
// import { EmployeesService } from './services/employees.service';
|
||||||
|
// import { EmployeesArchivalService } from './services/employees-archival.service';
|
||||||
|
// import { SharedModule } from '../../time-and-attendance/modules/shared/shared.module';
|
||||||
|
|
||||||
|
// @Module({
|
||||||
|
// imports: [SharedModule],
|
||||||
|
// controllers: [EmployeesController],
|
||||||
|
// providers: [EmployeesService, EmployeesArchivalService],
|
||||||
|
// exports: [EmployeesService, EmployeesArchivalService],
|
||||||
|
// })
|
||||||
|
// export class EmployeesModule {}
|
||||||
|
|
@ -1,33 +1,33 @@
|
||||||
import { Controller, Get, NotFoundException, Param, ParseIntPipe, UseGuards } from "@nestjs/common";
|
// import { Controller, Get, NotFoundException, Param, ParseIntPipe, UseGuards } from "@nestjs/common";
|
||||||
import { ApiOperation, ApiResponse, ApiTags } from "@nestjs/swagger";
|
// import { ApiOperation, ApiResponse, ApiTags } from "@nestjs/swagger";
|
||||||
import { RolesAllowed } from "src/common/decorators/roles.decorators";
|
// import { RolesAllowed } from "src/common/decorators/roles.decorators";
|
||||||
import { EmployeesArchive, Roles as RoleEnum } from '@prisma/client';
|
// import { EmployeesArchive, Roles as RoleEnum } from '@prisma/client';
|
||||||
import { EmployeesArchivalService } from "src/modules/employees/services/employees-archival.service";
|
// import { EmployeesArchivalService } from "src/modules/employees/services/employees-archival.service";
|
||||||
|
|
||||||
@ApiTags('Employee Archives')
|
// @ApiTags('Employee Archives')
|
||||||
// @UseGuards()
|
// // @UseGuards()
|
||||||
@Controller('archives/employees')
|
// @Controller('archives/employees')
|
||||||
export class EmployeesArchiveController {
|
// export class EmployeesArchiveController {
|
||||||
constructor(private readonly employeesArchiveService: EmployeesArchivalService) {}
|
// constructor(private readonly employeesArchiveService: EmployeesArchivalService) {}
|
||||||
|
|
||||||
@Get()
|
// @Get()
|
||||||
//@RolesAllowed(RoleEnum.ADMIN, RoleEnum.HR, RoleEnum.SUPERVISOR)
|
// //@RolesAllowed(RoleEnum.ADMIN, RoleEnum.HR, RoleEnum.SUPERVISOR)
|
||||||
@ApiOperation({ summary: 'List of archived employees'})
|
// @ApiOperation({ summary: 'List of archived employees'})
|
||||||
@ApiResponse({ status: 200, description: 'List of archived employees', isArray: true })
|
// @ApiResponse({ status: 200, description: 'List of archived employees', isArray: true })
|
||||||
async findAllArchived(): Promise<EmployeesArchive[]> {
|
// async findAllArchived(): Promise<EmployeesArchive[]> {
|
||||||
return this.employeesArchiveService.findAllArchived();
|
// return this.employeesArchiveService.findAllArchived();
|
||||||
}
|
// }
|
||||||
|
|
||||||
@Get()
|
// @Get()
|
||||||
//@RolesAllowed(RoleEnum.ADMIN, RoleEnum.HR,RoleEnum.SUPERVISOR)
|
// //@RolesAllowed(RoleEnum.ADMIN, RoleEnum.HR,RoleEnum.SUPERVISOR)
|
||||||
@ApiOperation({ summary: 'Fetch employee in archives with its Id'})
|
// @ApiOperation({ summary: 'Fetch employee in archives with its Id'})
|
||||||
@ApiResponse({ status: 200, description: 'Archived employee found'})
|
// @ApiResponse({ status: 200, description: 'Archived employee found'})
|
||||||
async findOneArchived(@Param('id', ParseIntPipe) id: number ): Promise<EmployeesArchive> {
|
// async findOneArchived(@Param('id', ParseIntPipe) id: number ): Promise<EmployeesArchive> {
|
||||||
try{
|
// try{
|
||||||
return await this.employeesArchiveService.findOneArchived(id);
|
// return await this.employeesArchiveService.findOneArchived(id);
|
||||||
}catch {
|
// }catch {
|
||||||
throw new NotFoundException(`Archived employee #${id} not found`);
|
// throw new NotFoundException(`Archived employee #${id} not found`);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
}
|
// }
|
||||||
|
|
@ -2,7 +2,7 @@ import { UseGuards, Controller, Get, Param, ParseIntPipe, NotFoundException } fr
|
||||||
import { ApiTags, ApiOperation, ApiResponse } from "@nestjs/swagger";
|
import { ApiTags, ApiOperation, ApiResponse } from "@nestjs/swagger";
|
||||||
import { ExpensesArchive,Roles as RoleEnum } from "@prisma/client";
|
import { ExpensesArchive,Roles as RoleEnum } from "@prisma/client";
|
||||||
import { RolesAllowed } from "src/common/decorators/roles.decorators";
|
import { RolesAllowed } from "src/common/decorators/roles.decorators";
|
||||||
import { ExpensesArchivalService } from "src/modules/expenses/services/expenses-archival.service";
|
import { ExpensesArchivalService } from "src/time-and-attendance/modules/expenses/services/expenses-archival.service";
|
||||||
|
|
||||||
@ApiTags('Expense Archives')
|
@ApiTags('Expense Archives')
|
||||||
// @UseGuards()
|
// @UseGuards()
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@ import { Get, Param, ParseIntPipe, NotFoundException, Controller, UseGuards } fr
|
||||||
import { ApiOperation, ApiResponse, ApiTags } from "@nestjs/swagger";
|
import { ApiOperation, ApiResponse, ApiTags } from "@nestjs/swagger";
|
||||||
import { ShiftsArchive, Roles as RoleEnum } from "@prisma/client";
|
import { ShiftsArchive, Roles as RoleEnum } from "@prisma/client";
|
||||||
import { RolesAllowed } from "src/common/decorators/roles.decorators";
|
import { RolesAllowed } from "src/common/decorators/roles.decorators";
|
||||||
import { ShiftsArchivalService } from "src/Time_And_Attendance/modules/time-tracker/shifts/services/shifts-archival.service";
|
import { ShiftsArchivalService } from "src/time-and-attendance/modules/time-tracker/shifts/services/shifts-archival.service";
|
||||||
|
|
||||||
@ApiTags('Shift Archives')
|
@ApiTags('Shift Archives')
|
||||||
// @UseGuards()
|
// @UseGuards()
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@ import { Controller, Get, NotFoundException, Param, ParseIntPipe, UseGuards } fr
|
||||||
import { ApiOperation, ApiResponse, ApiTags } from "@nestjs/swagger";
|
import { ApiOperation, ApiResponse, ApiTags } from "@nestjs/swagger";
|
||||||
import { RolesAllowed } from "src/common/decorators/roles.decorators";
|
import { RolesAllowed } from "src/common/decorators/roles.decorators";
|
||||||
import { TimesheetsArchive, Roles as RoleEnum } from '@prisma/client';
|
import { TimesheetsArchive, Roles as RoleEnum } from '@prisma/client';
|
||||||
import { TimesheetArchiveService } from "src/Time_And_Attendance/modules/time-tracker/timesheets/services/timesheet-archive.service";
|
import { TimesheetArchiveService } from "src/time-and-attendance/modules/time-tracker/timesheets/services/timesheet-archive.service";
|
||||||
|
|
||||||
@ApiTags('Timesheet Archives')
|
@ApiTags('Timesheet Archives')
|
||||||
// @UseGuards()
|
// @UseGuards()
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
import { Injectable, Logger } from "@nestjs/common";
|
import { Injectable, Logger } from "@nestjs/common";
|
||||||
import { Cron } from "@nestjs/schedule";
|
import { Cron } from "@nestjs/schedule";
|
||||||
import { ExpensesArchivalService } from "src/modules/expenses/services/expenses-archival.service";
|
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 { 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 { TimesheetArchiveService } from "src/time-and-attendance/modules/time-tracker/timesheets/services/timesheet-archive.service";
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class ArchivalService {
|
export class ArchivalService {
|
||||||
|
|
|
||||||
|
|
@ -1,68 +1,68 @@
|
||||||
import { Body, Controller, Delete, Get, Param, ParseIntPipe, Patch, Post, UseGuards } from '@nestjs/common';
|
// import { Body, Controller, Delete, Get, Param, ParseIntPipe, Patch, Post, UseGuards } from '@nestjs/common';
|
||||||
import { CustomersService } from '../services/customers.service';
|
// import { CustomersService } from '../services/customers.service';
|
||||||
import { Customers } from '@prisma/client';
|
// import { Customers } from '@prisma/client';
|
||||||
import { CreateCustomerDto } from '../dtos/create-customer.dto';
|
// import { CreateCustomerDto } from '../dtos/create-customer.dto';
|
||||||
import { UpdateCustomerDto } from '../dtos/update-customer.dto';
|
// import { UpdateCustomerDto } from '../dtos/update-customer.dto';
|
||||||
import { RolesAllowed } from "src/common/decorators/roles.decorators";
|
// import { RolesAllowed } from "src/common/decorators/roles.decorators";
|
||||||
import { Roles as RoleEnum } from '.prisma/client';
|
// import { Roles as RoleEnum } from '.prisma/client';
|
||||||
import { ApiBearerAuth, ApiOperation, ApiResponse, ApiTags } from '@nestjs/swagger';
|
// import { ApiBearerAuth, ApiOperation, ApiResponse, ApiTags } from '@nestjs/swagger';
|
||||||
|
|
||||||
@ApiTags('Customers')
|
// @ApiTags('Customers')
|
||||||
@ApiBearerAuth('access-token')
|
// @ApiBearerAuth('access-token')
|
||||||
// @UseGuards()
|
// // @UseGuards()
|
||||||
@Controller('customers')
|
// @Controller('customers')
|
||||||
export class CustomersController {
|
// export class CustomersController {
|
||||||
constructor(private readonly customersService: CustomersService) {}
|
// constructor(private readonly customersService: CustomersService) {}
|
||||||
|
|
||||||
//_____________________________________________________________________________________________
|
// //_____________________________________________________________________________________________
|
||||||
// Deprecated or unused methods
|
// // Deprecated or unused methods
|
||||||
//_____________________________________________________________________________________________
|
// //_____________________________________________________________________________________________
|
||||||
|
|
||||||
// @Post()
|
// // @Post()
|
||||||
// //@RolesAllowed(RoleEnum.ACCOUNTING, RoleEnum.ADMIN, RoleEnum.EMPLOYEE, RoleEnum.SUPERVISOR)
|
// // //@RolesAllowed(RoleEnum.ACCOUNTING, RoleEnum.ADMIN, RoleEnum.EMPLOYEE, RoleEnum.SUPERVISOR)
|
||||||
// @ApiOperation({ summary: 'Create customer' })
|
// // @ApiOperation({ summary: 'Create customer' })
|
||||||
// @ApiResponse({ status: 201, description: 'Customer created', type: CreateCustomerDto })
|
// // @ApiResponse({ status: 201, description: 'Customer created', type: CreateCustomerDto })
|
||||||
// @ApiResponse({ status: 400, description: 'Invalid task or invalid data' })
|
// // @ApiResponse({ status: 400, description: 'Invalid task or invalid data' })
|
||||||
// create(@Body() dto: CreateCustomerDto): Promise<Customers> {
|
// // create(@Body() dto: CreateCustomerDto): Promise<Customers> {
|
||||||
// return this.customersService.create(dto);
|
// // return this.customersService.create(dto);
|
||||||
// }
|
// // }
|
||||||
|
|
||||||
// @Get()
|
// // @Get()
|
||||||
// //@RolesAllowed(RoleEnum.ACCOUNTING, RoleEnum.ADMIN, RoleEnum.EMPLOYEE, RoleEnum.HR, RoleEnum.SUPERVISOR)
|
// // //@RolesAllowed(RoleEnum.ACCOUNTING, RoleEnum.ADMIN, RoleEnum.EMPLOYEE, RoleEnum.HR, RoleEnum.SUPERVISOR)
|
||||||
// @ApiOperation({ summary: 'Find all customers' })
|
// // @ApiOperation({ summary: 'Find all customers' })
|
||||||
// @ApiResponse({ status: 201, description: 'List of customers found', type: CreateCustomerDto, isArray: true })
|
// // @ApiResponse({ status: 201, description: 'List of customers found', type: CreateCustomerDto, isArray: true })
|
||||||
// @ApiResponse({ status: 400, description: 'List of customers not found' })
|
// // @ApiResponse({ status: 400, description: 'List of customers not found' })
|
||||||
// findAll(): Promise<Customers[]> {
|
// // findAll(): Promise<Customers[]> {
|
||||||
// return this.customersService.findAll();
|
// // return this.customersService.findAll();
|
||||||
// }
|
// // }
|
||||||
|
|
||||||
// @Get(':id')
|
// // @Get(':id')
|
||||||
// //@RolesAllowed(RoleEnum.ACCOUNTING, RoleEnum.ADMIN, RoleEnum.EMPLOYEE, RoleEnum.HR, RoleEnum.SUPERVISOR)
|
// // //@RolesAllowed(RoleEnum.ACCOUNTING, RoleEnum.ADMIN, RoleEnum.EMPLOYEE, RoleEnum.HR, RoleEnum.SUPERVISOR)
|
||||||
// @ApiOperation({ summary: 'Find customer' })
|
// // @ApiOperation({ summary: 'Find customer' })
|
||||||
// @ApiResponse({ status: 201, description: 'Customer found', type: CreateCustomerDto })
|
// // @ApiResponse({ status: 201, description: 'Customer found', type: CreateCustomerDto })
|
||||||
// @ApiResponse({ status: 400, description: 'Customer not found' })
|
// // @ApiResponse({ status: 400, description: 'Customer not found' })
|
||||||
// findOne(@Param('id', ParseIntPipe) id: number): Promise<Customers> {
|
// // findOne(@Param('id', ParseIntPipe) id: number): Promise<Customers> {
|
||||||
// return this.customersService.findOne(id);
|
// // return this.customersService.findOne(id);
|
||||||
// }
|
// // }
|
||||||
|
|
||||||
// @Patch(':id')
|
// // @Patch(':id')
|
||||||
// //@RolesAllowed(RoleEnum.ACCOUNTING, RoleEnum.ADMIN, RoleEnum.EMPLOYEE,RoleEnum.SUPERVISOR)
|
// // //@RolesAllowed(RoleEnum.ACCOUNTING, RoleEnum.ADMIN, RoleEnum.EMPLOYEE,RoleEnum.SUPERVISOR)
|
||||||
// @ApiOperation({ summary: 'Update customer' })
|
// // @ApiOperation({ summary: 'Update customer' })
|
||||||
// @ApiResponse({ status: 201, description: 'Customer updated', type: CreateCustomerDto })
|
// // @ApiResponse({ status: 201, description: 'Customer updated', type: CreateCustomerDto })
|
||||||
// @ApiResponse({ status: 400, description: 'Customer not found' })
|
// // @ApiResponse({ status: 400, description: 'Customer not found' })
|
||||||
// update(
|
// // update(
|
||||||
// @Param('id', ParseIntPipe) id: number,
|
// // @Param('id', ParseIntPipe) id: number,
|
||||||
// @Body() dto: UpdateCustomerDto,
|
// // @Body() dto: UpdateCustomerDto,
|
||||||
// ): Promise<Customers> {
|
// // ): Promise<Customers> {
|
||||||
// return this.customersService.update(id, dto);
|
// // return this.customersService.update(id, dto);
|
||||||
// }
|
// // }
|
||||||
|
|
||||||
// @Delete(':id')
|
// // @Delete(':id')
|
||||||
// //@RolesAllowed(RoleEnum.ACCOUNTING, RoleEnum.ADMIN, RoleEnum.SUPERVISOR)
|
// // //@RolesAllowed(RoleEnum.ACCOUNTING, RoleEnum.ADMIN, RoleEnum.SUPERVISOR)
|
||||||
// @ApiOperation({ summary: 'Delete customer' })
|
// // @ApiOperation({ summary: 'Delete customer' })
|
||||||
// @ApiResponse({ status: 201, description: 'Customer deleted', type: CreateCustomerDto })
|
// // @ApiResponse({ status: 201, description: 'Customer deleted', type: CreateCustomerDto })
|
||||||
// @ApiResponse({ status: 400, description: 'Customer not found' })
|
// // @ApiResponse({ status: 400, description: 'Customer not found' })
|
||||||
// remove(@Param('id', ParseIntPipe) id: number): Promise<Customers>{
|
// // remove(@Param('id', ParseIntPipe) id: number): Promise<Customers>{
|
||||||
// return this.customersService.remove(id);
|
// // return this.customersService.remove(id);
|
||||||
// }
|
// // }
|
||||||
}
|
// }
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,10 @@
|
||||||
|
|
||||||
import { Module } from '@nestjs/common';
|
// import { Module } from '@nestjs/common';
|
||||||
import { CustomersController } from './controllers/customers.controller';
|
// import { CustomersController } from './controllers/customers.controller';
|
||||||
import { CustomersService } from './services/customers.service';
|
// import { CustomersService } from './services/customers.service';
|
||||||
|
|
||||||
@Module({
|
// @Module({
|
||||||
controllers:[CustomersController],
|
// controllers:[CustomersController],
|
||||||
providers:[CustomersService],
|
// providers:[CustomersService],
|
||||||
})
|
// })
|
||||||
export class CustomersModule {}
|
// export class CustomersModule {}
|
||||||
|
|
@ -1,99 +1,99 @@
|
||||||
import { Body,Controller,Get,NotFoundException,Param,Patch } from '@nestjs/common';
|
// import { Body,Controller,Get,NotFoundException,Param,Patch } from '@nestjs/common';
|
||||||
import { EmployeesService } from '../services/employees.service';
|
// import { EmployeesService } from '../services/employees.service';
|
||||||
import { CreateEmployeeDto } from '../dtos/create-employee.dto';
|
// import { CreateEmployeeDto } from '../dtos/create-employee.dto';
|
||||||
import { UpdateEmployeeDto } from '../dtos/update-employee.dto';
|
// import { UpdateEmployeeDto } from '../dtos/update-employee.dto';
|
||||||
import { RolesAllowed } from '../../../common/decorators/roles.decorators';
|
// import { RolesAllowed } from '../../../common/decorators/roles.decorators';
|
||||||
import { ApiBearerAuth, ApiOperation, ApiParam, ApiResponse, ApiTags } from '@nestjs/swagger';
|
// import { ApiBearerAuth, ApiOperation, ApiParam, ApiResponse, ApiTags } from '@nestjs/swagger';
|
||||||
import { EmployeeListItemDto } from '../dtos/list-employee.dto';
|
// import { EmployeeListItemDto } from '../dtos/list-employee.dto';
|
||||||
import { EmployeesArchivalService } from '../services/employees-archival.service';
|
// import { EmployeesArchivalService } from '../services/employees-archival.service';
|
||||||
import { EmployeeProfileItemDto } from 'src/modules/employees/dtos/profil-employee.dto';
|
// import { EmployeeProfileItemDto } from 'src/modules/employees/dtos/profil-employee.dto';
|
||||||
|
|
||||||
@ApiTags('Employees')
|
// @ApiTags('Employees')
|
||||||
@ApiBearerAuth('access-token')
|
// @ApiBearerAuth('access-token')
|
||||||
// @UseGuards()
|
// // @UseGuards()
|
||||||
@Controller('employees')
|
// @Controller('employees')
|
||||||
export class EmployeesController {
|
// export class EmployeesController {
|
||||||
constructor(
|
// constructor(
|
||||||
private readonly employeesService: EmployeesService,
|
// private readonly employeesService: EmployeesService,
|
||||||
private readonly archiveService: EmployeesArchivalService,
|
// private readonly archiveService: EmployeesArchivalService,
|
||||||
) {}
|
// ) {}
|
||||||
|
|
||||||
@Get('employee-list')
|
// @Get('employee-list')
|
||||||
//@RolesAllowed(RoleEnum.ADMIN, RoleEnum.HR, RoleEnum.SUPERVISOR, RoleEnum.ACCOUNTING)
|
// //@RolesAllowed(RoleEnum.ADMIN, RoleEnum.HR, RoleEnum.SUPERVISOR, RoleEnum.ACCOUNTING)
|
||||||
@ApiOperation({summary: 'Find all employees with scoped info' })
|
// @ApiOperation({summary: 'Find all employees with scoped info' })
|
||||||
@ApiResponse({ status: 200, description: 'List of employees with scoped info found', type: EmployeeListItemDto, isArray: true })
|
// @ApiResponse({ status: 200, description: 'List of employees with scoped info found', type: EmployeeListItemDto, isArray: true })
|
||||||
@ApiResponse({ status: 400, description: 'List of employees with scoped info not found' })
|
// @ApiResponse({ status: 400, description: 'List of employees with scoped info not found' })
|
||||||
findListEmployees(): Promise<EmployeeListItemDto[]> {
|
// findListEmployees(): Promise<EmployeeListItemDto[]> {
|
||||||
return this.employeesService.findListEmployees();
|
// return this.employeesService.findListEmployees();
|
||||||
}
|
// }
|
||||||
|
|
||||||
@Patch(':email')
|
// @Patch(':email')
|
||||||
//@RolesAllowed(RoleEnum.ADMIN, RoleEnum.HR, RoleEnum.SUPERVISOR)
|
// //@RolesAllowed(RoleEnum.ADMIN, RoleEnum.HR, RoleEnum.SUPERVISOR)
|
||||||
@ApiBearerAuth('access-token')
|
// @ApiBearerAuth('access-token')
|
||||||
@ApiOperation({ summary: 'Update, archive or restore an employee' })
|
// @ApiOperation({ summary: 'Update, archive or restore an employee' })
|
||||||
@ApiParam({ name: 'email', type: Number, description: 'Email of the employee' })
|
// @ApiParam({ name: 'email', type: Number, description: 'Email of the employee' })
|
||||||
@ApiResponse({ status: 200, description: 'Employee updated or restored', type: CreateEmployeeDto })
|
// @ApiResponse({ status: 200, description: 'Employee updated or restored', type: CreateEmployeeDto })
|
||||||
@ApiResponse({ status: 202, description: 'Employee archived successfully', type: CreateEmployeeDto })
|
// @ApiResponse({ status: 202, description: 'Employee archived successfully', type: CreateEmployeeDto })
|
||||||
@ApiResponse({ status: 404, description: 'Employee not found in active or archive' })
|
// @ApiResponse({ status: 404, description: 'Employee not found in active or archive' })
|
||||||
async updateOrArchiveOrRestore(@Param('email') email: string, @Body() dto: UpdateEmployeeDto,) {
|
// async updateOrArchiveOrRestore(@Param('email') email: string, @Body() dto: UpdateEmployeeDto,) {
|
||||||
// if last_work_day is set => archive the employee
|
// // if last_work_day is set => archive the employee
|
||||||
// else if employee is archived and first_work_day or last_work_day = null => restore
|
// // else if employee is archived and first_work_day or last_work_day = null => restore
|
||||||
//otherwise => standard update
|
// //otherwise => standard update
|
||||||
const result = await this.archiveService.patchEmployee(email, dto);
|
// const result = await this.archiveService.patchEmployee(email, dto);
|
||||||
if(!result) {
|
// if(!result) {
|
||||||
throw new NotFoundException(`Employee with email: ${ email } is not found in active or archive.`)
|
// throw new NotFoundException(`Employee with email: ${ email } is not found in active or archive.`)
|
||||||
}
|
// }
|
||||||
return result;
|
// return result;
|
||||||
}
|
// }
|
||||||
|
|
||||||
//_____________________________________________________________________________________________
|
// //_____________________________________________________________________________________________
|
||||||
// Deprecated or unused methods
|
// // Deprecated or unused methods
|
||||||
//_____________________________________________________________________________________________
|
// //_____________________________________________________________________________________________
|
||||||
|
|
||||||
// @Post()
|
// // @Post()
|
||||||
// //@RolesAllowed(RoleEnum.ADMIN, RoleEnum.HR, RoleEnum.SUPERVISOR)
|
// // //@RolesAllowed(RoleEnum.ADMIN, RoleEnum.HR, RoleEnum.SUPERVISOR)
|
||||||
// @ApiOperation({summary: 'Create employee' })
|
// // @ApiOperation({summary: 'Create employee' })
|
||||||
// @ApiResponse({ status: 201, description: 'Employee created', type: CreateEmployeeDto })
|
// // @ApiResponse({ status: 201, description: 'Employee created', type: CreateEmployeeDto })
|
||||||
// @ApiResponse({ status: 400, description: 'Incomplete task or invalid data' })
|
// // @ApiResponse({ status: 400, description: 'Incomplete task or invalid data' })
|
||||||
// create(@Body() dto: CreateEmployeeDto): Promise<Employees> {
|
// // create(@Body() dto: CreateEmployeeDto): Promise<Employees> {
|
||||||
// return this.employeesService.create(dto);
|
// // return this.employeesService.create(dto);
|
||||||
// }
|
// // }
|
||||||
// @Get()
|
// // @Get()
|
||||||
// //@RolesAllowed(RoleEnum.ADMIN, RoleEnum.HR, RoleEnum.SUPERVISOR, RoleEnum.ACCOUNTING)
|
// // //@RolesAllowed(RoleEnum.ADMIN, RoleEnum.HR, RoleEnum.SUPERVISOR, RoleEnum.ACCOUNTING)
|
||||||
// @ApiOperation({summary: 'Find all employees' })
|
// // @ApiOperation({summary: 'Find all employees' })
|
||||||
// @ApiResponse({ status: 200, description: 'List of employees found', type: CreateEmployeeDto, isArray: true })
|
// // @ApiResponse({ status: 200, description: 'List of employees found', type: CreateEmployeeDto, isArray: true })
|
||||||
// @ApiResponse({ status: 400, description: 'List of employees not found' })
|
// // @ApiResponse({ status: 400, description: 'List of employees not found' })
|
||||||
// findAll(): Promise<Employees[]> {
|
// // findAll(): Promise<Employees[]> {
|
||||||
// return this.employeesService.findAll();
|
// // return this.employeesService.findAll();
|
||||||
// }
|
// // }
|
||||||
|
|
||||||
|
|
||||||
// @Get(':email')
|
// // @Get(':email')
|
||||||
// //@RolesAllowed(RoleEnum.ADMIN, RoleEnum.HR, RoleEnum.SUPERVISOR,RoleEnum.ACCOUNTING )
|
// // //@RolesAllowed(RoleEnum.ADMIN, RoleEnum.HR, RoleEnum.SUPERVISOR,RoleEnum.ACCOUNTING )
|
||||||
// @ApiOperation({summary: 'Find employee' })
|
// // @ApiOperation({summary: 'Find employee' })
|
||||||
// @ApiResponse({ status: 200, description: 'Employee found', type: CreateEmployeeDto })
|
// // @ApiResponse({ status: 200, description: 'Employee found', type: CreateEmployeeDto })
|
||||||
// @ApiResponse({ status: 400, description: 'Employee not found' })
|
// // @ApiResponse({ status: 400, description: 'Employee not found' })
|
||||||
// findOne(@Param('email', ParseIntPipe) email: string): Promise<Employees> {
|
// // findOne(@Param('email', ParseIntPipe) email: string): Promise<Employees> {
|
||||||
// return this.employeesService.findOne(email);
|
// // return this.employeesService.findOne(email);
|
||||||
// }
|
// // }
|
||||||
|
|
||||||
@Get('profile/:email')
|
// @Get('profile/:email')
|
||||||
@ApiOperation({summary: 'Find employee profile' })
|
// @ApiOperation({summary: 'Find employee profile' })
|
||||||
@ApiParam({ name: 'email', type: String, description: 'Identifier of the employee' })
|
// @ApiParam({ name: 'email', type: String, description: 'Identifier of the employee' })
|
||||||
@ApiResponse({ status: 200, description: 'Employee profile found', type: EmployeeProfileItemDto })
|
// @ApiResponse({ status: 200, description: 'Employee profile found', type: EmployeeProfileItemDto })
|
||||||
@ApiResponse({ status: 400, description: 'Employee profile not found' })
|
// @ApiResponse({ status: 400, description: 'Employee profile not found' })
|
||||||
findOneProfile(@Param('email') email: string): Promise<EmployeeProfileItemDto> {
|
// findOneProfile(@Param('email') email: string): Promise<EmployeeProfileItemDto> {
|
||||||
return this.employeesService.findOneProfile(email);
|
// return this.employeesService.findOneProfile(email);
|
||||||
}
|
// }
|
||||||
|
|
||||||
// @Delete(':email')
|
// // @Delete(':email')
|
||||||
// //@RolesAllowed(RoleEnum.ADMIN, RoleEnum.HR, RoleEnum.SUPERVISOR )
|
// // //@RolesAllowed(RoleEnum.ADMIN, RoleEnum.HR, RoleEnum.SUPERVISOR )
|
||||||
// @ApiOperation({summary: 'Delete employee' })
|
// // @ApiOperation({summary: 'Delete employee' })
|
||||||
// @ApiParam({ name: 'email', type: Number, description: 'Email of the employee to delete' })
|
// // @ApiParam({ name: 'email', type: Number, description: 'Email of the employee to delete' })
|
||||||
// @ApiResponse({ status: 204, description: 'Employee deleted' })
|
// // @ApiResponse({ status: 204, description: 'Employee deleted' })
|
||||||
// @ApiResponse({ status: 404, description: 'Employee not found' })
|
// // @ApiResponse({ status: 404, description: 'Employee not found' })
|
||||||
// remove(@Param('email', ParseIntPipe) email: string): Promise<Employees> {
|
// // remove(@Param('email', ParseIntPipe) email: string): Promise<Employees> {
|
||||||
// return this.employeesService.remove(email);
|
// // return this.employeesService.remove(email);
|
||||||
// }
|
// // }
|
||||||
|
|
||||||
}
|
// }
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,12 @@
|
||||||
import { Module } from '@nestjs/common';
|
// import { Module } from '@nestjs/common';
|
||||||
import { EmployeesController } from './controllers/employees.controller';
|
// import { EmployeesController } from './controllers/employees.controller';
|
||||||
import { EmployeesService } from './services/employees.service';
|
// import { EmployeesService } from './services/employees.service';
|
||||||
import { EmployeesArchivalService } from './services/employees-archival.service';
|
// import { SharedModule } from '../../time-and-attendance/modules/shared/shared.module';
|
||||||
import { SharedModule } from '../../Time_And_Attendance/modules/shared/shared.module';
|
|
||||||
|
|
||||||
@Module({
|
// @Module({
|
||||||
imports: [SharedModule],
|
// imports: [SharedModule],
|
||||||
controllers: [EmployeesController],
|
// controllers: [EmployeesController],
|
||||||
providers: [EmployeesService, EmployeesArchivalService],
|
// providers: [EmployeesService],
|
||||||
exports: [EmployeesService, EmployeesArchivalService],
|
// exports: [EmployeesService ],
|
||||||
})
|
// })
|
||||||
export class EmployeesModule {}
|
// export class EmployeesModule {}
|
||||||
|
|
|
||||||
|
|
@ -1,173 +1,173 @@
|
||||||
import { Injectable } from "@nestjs/common";
|
// import { Injectable } from "@nestjs/common";
|
||||||
import { Employees, EmployeesArchive, Users } from "@prisma/client";
|
// import { Employees, EmployeesArchive, Users } from "@prisma/client";
|
||||||
import { PrismaService } from "src/prisma/prisma.service";
|
// import { PrismaService } from "src/prisma/prisma.service";
|
||||||
import { UpdateEmployeeDto } from "../dtos/update-employee.dto";
|
// import { UpdateEmployeeDto } from "../dtos/update-employee.dto";
|
||||||
import { toDateOrUndefined, toDateOrNull } from "../utils/employee.utils";
|
// import { toDateOrUndefined, toDateOrNull } from "../utils/employee.utils";
|
||||||
|
|
||||||
@Injectable()
|
// @Injectable()
|
||||||
export class EmployeesArchivalService {
|
// export class EmployeesArchivalService {
|
||||||
constructor(private readonly prisma: PrismaService) { }
|
// constructor(private readonly prisma: PrismaService) { }
|
||||||
|
|
||||||
async patchEmployee(email: string, dto: UpdateEmployeeDto): Promise<Employees | EmployeesArchive | null> {
|
// async patchEmployee(email: string, dto: UpdateEmployeeDto): Promise<Employees | EmployeesArchive | null> {
|
||||||
// 1) Tenter sur employés actifs
|
// // 1) Tenter sur employés actifs
|
||||||
const active = await this.prisma.employees.findFirst({
|
// const active = await this.prisma.employees.findFirst({
|
||||||
where: { user: { email } },
|
// where: { user: { email } },
|
||||||
include: { user: true },
|
// include: { user: true },
|
||||||
});
|
// });
|
||||||
|
|
||||||
if (active) {
|
// if (active) {
|
||||||
// Archivage : si on reçoit un last_work_day défini et que l'employé n’est pas déjà terminé
|
// // Archivage : si on reçoit un last_work_day défini et que l'employé n’est pas déjà terminé
|
||||||
if (dto.last_work_day !== undefined && active.last_work_day == null && dto.last_work_day !== null) {
|
// if (dto.last_work_day !== undefined && active.last_work_day == null && dto.last_work_day !== null) {
|
||||||
return this.archiveOnTermination(active, dto);
|
// return this.archiveOnTermination(active, dto);
|
||||||
}
|
// }
|
||||||
|
|
||||||
// Sinon, update standard (split Users/Employees)
|
// // Sinon, update standard (split Users/Employees)
|
||||||
const {
|
// const {
|
||||||
first_name,
|
// first_name,
|
||||||
last_name,
|
// last_name,
|
||||||
email: new_email,
|
// email: new_email,
|
||||||
phone_number,
|
// phone_number,
|
||||||
residence,
|
// residence,
|
||||||
external_payroll_id,
|
// external_payroll_id,
|
||||||
company_code,
|
// company_code,
|
||||||
job_title,
|
// job_title,
|
||||||
first_work_day,
|
// first_work_day,
|
||||||
last_work_day,
|
// last_work_day,
|
||||||
supervisor_id,
|
// supervisor_id,
|
||||||
is_supervisor,
|
// is_supervisor,
|
||||||
} = dto as any;
|
// } = dto as any;
|
||||||
|
|
||||||
const first_work_d = toDateOrUndefined(first_work_day);
|
// const first_work_d = toDateOrUndefined(first_work_day);
|
||||||
const last_work_d = Object.prototype.hasOwnProperty('last_work_day')
|
// const last_work_d = Object.prototype.hasOwnProperty('last_work_day')
|
||||||
? toDateOrNull(last_work_day ?? null)
|
// ? toDateOrNull(last_work_day ?? null)
|
||||||
: undefined;
|
// : undefined;
|
||||||
|
|
||||||
await this.prisma.$transaction(async (transaction) => {
|
// await this.prisma.$transaction(async (transaction) => {
|
||||||
if (
|
// if (
|
||||||
first_name !== undefined ||
|
// first_name !== undefined ||
|
||||||
last_name !== undefined ||
|
// last_name !== undefined ||
|
||||||
new_email !== undefined ||
|
// new_email !== undefined ||
|
||||||
phone_number !== undefined ||
|
// phone_number !== undefined ||
|
||||||
residence !== undefined
|
// residence !== undefined
|
||||||
) {
|
// ) {
|
||||||
await transaction.users.update({
|
// await transaction.users.update({
|
||||||
where: { id: active.user_id },
|
// where: { id: active.user_id },
|
||||||
data: {
|
// data: {
|
||||||
...(first_name !== undefined ? { first_name } : {}),
|
// ...(first_name !== undefined ? { first_name } : {}),
|
||||||
...(last_name !== undefined ? { last_name } : {}),
|
// ...(last_name !== undefined ? { last_name } : {}),
|
||||||
...(email !== undefined ? { email: new_email } : {}),
|
// ...(email !== undefined ? { email: new_email } : {}),
|
||||||
...(phone_number !== undefined ? { phone_number } : {}),
|
// ...(phone_number !== undefined ? { phone_number } : {}),
|
||||||
...(residence !== undefined ? { residence } : {}),
|
// ...(residence !== undefined ? { residence } : {}),
|
||||||
},
|
// },
|
||||||
});
|
// });
|
||||||
|
|
||||||
}
|
// }
|
||||||
|
|
||||||
const updated = await transaction.employees.update({
|
// const updated = await transaction.employees.update({
|
||||||
where: { id: active.id },
|
// where: { id: active.id },
|
||||||
data: {
|
// data: {
|
||||||
...(external_payroll_id !== undefined ? { external_payroll_id } : {}),
|
// ...(external_payroll_id !== undefined ? { external_payroll_id } : {}),
|
||||||
...(company_code !== undefined ? { company_code } : {}),
|
// ...(company_code !== undefined ? { company_code } : {}),
|
||||||
...(job_title !== undefined ? { job_title } : {}),
|
// ...(job_title !== undefined ? { job_title } : {}),
|
||||||
...(first_work_d !== undefined ? { first_work_day: first_work_d } : {}),
|
// ...(first_work_d !== undefined ? { first_work_day: first_work_d } : {}),
|
||||||
...(last_work_d !== undefined ? { last_work_day: last_work_d } : {}),
|
// ...(last_work_d !== undefined ? { last_work_day: last_work_d } : {}),
|
||||||
...(is_supervisor !== undefined ? { is_supervisor } : {}),
|
// ...(is_supervisor !== undefined ? { is_supervisor } : {}),
|
||||||
...(supervisor_id !== undefined ? { supervisor_id } : {}),
|
// ...(supervisor_id !== undefined ? { supervisor_id } : {}),
|
||||||
},
|
// },
|
||||||
include: { user: true },
|
// include: { user: true },
|
||||||
});
|
// });
|
||||||
|
|
||||||
return updated;
|
// return updated;
|
||||||
});
|
// });
|
||||||
|
|
||||||
return this.prisma.employees.findFirst({ where: { user: { email } } });
|
// return this.prisma.employees.findFirst({ where: { user: { email } } });
|
||||||
}
|
// }
|
||||||
|
|
||||||
const user = await this.prisma.users.findUnique({ where: { email } });
|
// const user = await this.prisma.users.findUnique({ where: { email } });
|
||||||
if (!user) return null;
|
// if (!user) return null;
|
||||||
// 2) Pas trouvé en actifs → regarder en archive (pour restauration)
|
// // 2) Pas trouvé en actifs → regarder en archive (pour restauration)
|
||||||
const archived = await this.prisma.employeesArchive.findFirst({
|
// const archived = await this.prisma.employeesArchive.findFirst({
|
||||||
where: { user_id: user.id },
|
// where: { user_id: user.id },
|
||||||
include: { user: true },
|
// include: { user: true },
|
||||||
});
|
// });
|
||||||
|
|
||||||
if (archived) {
|
// if (archived) {
|
||||||
// Condition de restauration : last_work_day === null ou first_work_day fourni
|
// // Condition de restauration : last_work_day === null ou first_work_day fourni
|
||||||
const restore = dto.last_work_day === null || dto.first_work_day != null;
|
// const restore = dto.last_work_day === null || dto.first_work_day != null;
|
||||||
if (restore) {
|
// if (restore) {
|
||||||
return this.restoreEmployee(archived, dto);
|
// return this.restoreEmployee(archived, dto);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
// 3) Ni actif, ni archivé → 404 dans le controller
|
// // 3) Ni actif, ni archivé → 404 dans le controller
|
||||||
return null;
|
// return null;
|
||||||
}
|
// }
|
||||||
|
|
||||||
//transfers the employee to archive and then delete from employees table
|
// //transfers the employee to archive and then delete from employees table
|
||||||
private async archiveOnTermination(active: Employees & { user: Users }, dto: UpdateEmployeeDto): Promise<EmployeesArchive> {
|
// private async archiveOnTermination(active: Employees & { user: Users }, dto: UpdateEmployeeDto): Promise<EmployeesArchive> {
|
||||||
const last_work_d = toDateOrNull(dto.last_work_day!);
|
// const last_work_d = toDateOrNull(dto.last_work_day!);
|
||||||
if (!last_work_d) throw new Error('invalide last_work_day for archive');
|
// if (!last_work_d) throw new Error('invalide last_work_day for archive');
|
||||||
return this.prisma.$transaction(async transaction => {
|
// return this.prisma.$transaction(async transaction => {
|
||||||
//detach crew from supervisor if employee is a supervisor
|
// //detach crew from supervisor if employee is a supervisor
|
||||||
await transaction.employees.updateMany({
|
// await transaction.employees.updateMany({
|
||||||
where: { supervisor_id: active.id },
|
// where: { supervisor_id: active.id },
|
||||||
data: { supervisor_id: null },
|
// data: { supervisor_id: null },
|
||||||
})
|
// })
|
||||||
const archived = await transaction.employeesArchive.create({
|
// const archived = await transaction.employeesArchive.create({
|
||||||
data: {
|
// data: {
|
||||||
employee_id: active.id,
|
// employee_id: active.id,
|
||||||
user_id: active.user_id,
|
// user_id: active.user_id,
|
||||||
first_name: active.user.first_name,
|
// first_name: active.user.first_name,
|
||||||
last_name: active.user.last_name,
|
// last_name: active.user.last_name,
|
||||||
company_code: active.company_code,
|
// company_code: active.company_code,
|
||||||
job_title: active.job_title,
|
// job_title: active.job_title,
|
||||||
first_work_day: active.first_work_day,
|
// first_work_day: active.first_work_day,
|
||||||
last_work_day: last_work_d,
|
// last_work_day: last_work_d,
|
||||||
supervisor_id: active.supervisor_id ?? null,
|
// supervisor_id: active.supervisor_id ?? null,
|
||||||
is_supervisor: active.is_supervisor,
|
// is_supervisor: active.is_supervisor,
|
||||||
external_payroll_id: active.external_payroll_id,
|
// external_payroll_id: active.external_payroll_id,
|
||||||
},
|
// },
|
||||||
include: { user: true }
|
// include: { user: true }
|
||||||
});
|
// });
|
||||||
//delete from employees table
|
// //delete from employees table
|
||||||
await transaction.employees.delete({ where: { id: active.id } });
|
// await transaction.employees.delete({ where: { id: active.id } });
|
||||||
//return archived employee
|
// //return archived employee
|
||||||
return archived
|
// return archived
|
||||||
});
|
// });
|
||||||
}
|
// }
|
||||||
|
|
||||||
//transfers the employee from archive to the employees table
|
// //transfers the employee from archive to the employees table
|
||||||
private async restoreEmployee(archived: EmployeesArchive & { user: Users }, dto: UpdateEmployeeDto): Promise<Employees> {
|
// private async restoreEmployee(archived: EmployeesArchive & { user: Users }, dto: UpdateEmployeeDto): Promise<Employees> {
|
||||||
// const first_work_d = toDateOrUndefined(dto.first_work_day);
|
// // const first_work_d = toDateOrUndefined(dto.first_work_day);
|
||||||
return this.prisma.$transaction(async transaction => {
|
// return this.prisma.$transaction(async transaction => {
|
||||||
//restores the archived employee into the employees table
|
// //restores the archived employee into the employees table
|
||||||
const restored = await transaction.employees.create({
|
// const restored = await transaction.employees.create({
|
||||||
data: {
|
// data: {
|
||||||
user_id: archived.user_id,
|
// user_id: archived.user_id,
|
||||||
company_code: archived.company_code,
|
// company_code: archived.company_code,
|
||||||
job_title: archived.job_title,
|
// job_title: archived.job_title,
|
||||||
first_work_day: archived.first_work_day,
|
// first_work_day: archived.first_work_day,
|
||||||
last_work_day: null,
|
// last_work_day: null,
|
||||||
is_supervisor: archived.is_supervisor ?? false,
|
// is_supervisor: archived.is_supervisor ?? false,
|
||||||
external_payroll_id: archived.external_payroll_id,
|
// external_payroll_id: archived.external_payroll_id,
|
||||||
},
|
// },
|
||||||
});
|
// });
|
||||||
//deleting archived entry by id
|
// //deleting archived entry by id
|
||||||
await transaction.employeesArchive.delete({ where: { id: archived.id } });
|
// await transaction.employeesArchive.delete({ where: { id: archived.id } });
|
||||||
|
|
||||||
//return restored employee
|
// //return restored employee
|
||||||
return restored;
|
// return restored;
|
||||||
});
|
// });
|
||||||
}
|
// }
|
||||||
|
|
||||||
//fetches all archived employees
|
// //fetches all archived employees
|
||||||
async findAllArchived(): Promise<EmployeesArchive[]> {
|
// async findAllArchived(): Promise<EmployeesArchive[]> {
|
||||||
return this.prisma.employeesArchive.findMany();
|
// return this.prisma.employeesArchive.findMany();
|
||||||
}
|
// }
|
||||||
|
|
||||||
//fetches an archived employee
|
// //fetches an archived employee
|
||||||
async findOneArchived(id: number): Promise<EmployeesArchive> {
|
// async findOneArchived(id: number): Promise<EmployeesArchive> {
|
||||||
return this.prisma.employeesArchive.findUniqueOrThrow({ where: { id } });
|
// return this.prisma.employeesArchive.findUniqueOrThrow({ where: { id } });
|
||||||
}
|
// }
|
||||||
|
|
||||||
}
|
// }
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,15 +0,0 @@
|
||||||
import { ExpensesArchivalService } from "./services/expenses-archival.service";
|
|
||||||
import { BusinessLogicsModule } from "src/modules/business-logics/business-logics.module";
|
|
||||||
import { ExpenseUpsertService } from "src/modules/expenses/services/expense-upsert.service";
|
|
||||||
import { ExpenseController } from "src/modules/expenses/controllers/expense.controller";
|
|
||||||
import { SharedModule } from "../shared/shared.module";
|
|
||||||
import { Module } from "@nestjs/common";
|
|
||||||
|
|
||||||
@Module({
|
|
||||||
imports: [ BusinessLogicsModule, SharedModule ],
|
|
||||||
controllers: [ ExpenseController ],
|
|
||||||
providers: [ ExpenseUpsertService, ExpensesArchivalService ],
|
|
||||||
exports: [ ExpensesArchivalService ],
|
|
||||||
})
|
|
||||||
|
|
||||||
export class ExpensesModule {}
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
import { Module } from "@nestjs/common";
|
import { Module } from "@nestjs/common";
|
||||||
import { CsvExportController } from "./controllers/csv-exports.controller";
|
import { CsvExportController } from "./controllers/csv-exports.controller";
|
||||||
import { CsvExportService } from "./services/csv-exports.service";
|
import { CsvExportService } from "./services/csv-exports.service";
|
||||||
import { SharedModule } from "../../Time_And_Attendance/modules/shared/shared.module";
|
import { SharedModule } from "../../time-and-attendance/modules/shared/shared.module";
|
||||||
|
|
||||||
@Module({
|
@Module({
|
||||||
providers:[CsvExportService, SharedModule],
|
providers:[CsvExportService, SharedModule],
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
import { Module } from "@nestjs/common";
|
import { Module } from "@nestjs/common";
|
||||||
import { PreferencesController } from "./controllers/preferences.controller";
|
import { PreferencesController } from "./controllers/preferences.controller";
|
||||||
import { PreferencesService } from "./services/preferences.service";
|
import { PreferencesService } from "./services/preferences.service";
|
||||||
import { SharedModule } from "../../Time_And_Attendance/modules/shared/shared.module";
|
import { SharedModule } from "../../time-and-attendance/modules/shared/shared.module";
|
||||||
|
|
||||||
@Module({
|
@Module({
|
||||||
imports: [SharedModule],
|
imports: [SharedModule],
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@ import { Injectable } from "@nestjs/common";
|
||||||
import { Preferences } from "@prisma/client";
|
import { Preferences } from "@prisma/client";
|
||||||
import { PrismaService } from "src/prisma/prisma.service";
|
import { PrismaService } from "src/prisma/prisma.service";
|
||||||
import { PreferencesDto } from "../dtos/preferences.dto";
|
import { PreferencesDto } from "../dtos/preferences.dto";
|
||||||
import { EmailToIdResolver } from "src/Time_And_Attendance/modules/shared/utils/resolve-email-id.utils";
|
import { EmailToIdResolver } from "src/time-and-attendance/modules/shared/utils/resolve-email-id.utils";
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class PreferencesService {
|
export class PreferencesService {
|
||||||
|
|
|
||||||
|
|
@ -1,23 +0,0 @@
|
||||||
import { GetTimesheetsOverviewService } from '../../Time_And_Attendance/modules/time-tracker/timesheets/services/timesheet-get-overview.service';
|
|
||||||
import { TimesheetArchiveService } from '../../Time_And_Attendance/modules/time-tracker/timesheets/services/timesheet-archive.service';
|
|
||||||
import { BusinessLogicsModule } from 'src/modules/business-logics/business-logics.module';
|
|
||||||
import { TimesheetController } from '../../Time_And_Attendance/modules/time-tracker/timesheets/controllers/timesheet.controller';
|
|
||||||
import { SharedModule } from '../../Time_And_Attendance/modules/shared/shared.module';
|
|
||||||
import { ShiftsModule } from '../../Time_And_Attendance/modules/time-tracker/shifts/shifts.module';
|
|
||||||
import { Module } from '@nestjs/common';
|
|
||||||
|
|
||||||
@Module({
|
|
||||||
imports: [
|
|
||||||
BusinessLogicsModule,
|
|
||||||
SharedModule,
|
|
||||||
ShiftsModule,
|
|
||||||
],
|
|
||||||
controllers: [TimesheetController],
|
|
||||||
providers: [
|
|
||||||
TimesheetArchiveService,
|
|
||||||
GetTimesheetsOverviewService,
|
|
||||||
SharedModule,
|
|
||||||
],
|
|
||||||
exports: [],
|
|
||||||
})
|
|
||||||
export class TimesheetsModule {}
|
|
||||||
|
|
@ -2,7 +2,7 @@ import { Body, Controller, Delete, Get, Param, ParseIntPipe, Patch, Post } from
|
||||||
import { PrismaService } from "src/prisma/prisma.service";
|
import { PrismaService } from "src/prisma/prisma.service";
|
||||||
import { ExpenseDto } from "../dtos/expense.dto";
|
import { ExpenseDto } from "../dtos/expense.dto";
|
||||||
import { CreateResult, ExpenseUpsertService, UpdateResult } from "../services/expense-upsert.service";
|
import { CreateResult, ExpenseUpsertService, UpdateResult } from "../services/expense-upsert.service";
|
||||||
import { updateExpenseDto } from "src/modules/expenses/dtos/update-expense.dto";
|
import { updateExpenseDto } from "src/time-and-attendance/modules/expenses/dtos/update-expense.dto";
|
||||||
|
|
||||||
|
|
||||||
@Controller('expense')
|
@Controller('expense')
|
||||||
15
src/time-and-attendance/modules/expenses/expenses.module.ts
Normal file
15
src/time-and-attendance/modules/expenses/expenses.module.ts
Normal file
|
|
@ -0,0 +1,15 @@
|
||||||
|
import { ExpensesArchivalService } from "./services/expenses-archival.service";
|
||||||
|
import { ExpenseUpsertService } from "src/time-and-attendance/modules/expenses/services/expense-upsert.service";
|
||||||
|
import { ExpenseController } from "src/time-and-attendance/modules/expenses/controllers/expense.controller";
|
||||||
|
import { Module } from "@nestjs/common";
|
||||||
|
import { BusinessLogicsModule } from "src/time-and-attendance/domains/business-logics.module";
|
||||||
|
import { SharedModule } from "src/time-and-attendance/modules/shared/shared.module";
|
||||||
|
|
||||||
|
@Module({
|
||||||
|
imports: [ BusinessLogicsModule, SharedModule ],
|
||||||
|
controllers: [ ExpenseController ],
|
||||||
|
providers: [ ExpenseUpsertService, ExpensesArchivalService ],
|
||||||
|
exports: [ ExpensesArchivalService ],
|
||||||
|
})
|
||||||
|
|
||||||
|
export class ExpensesModule {}
|
||||||
|
|
@ -1,14 +1,13 @@
|
||||||
import { PrismaModule } from "src/prisma/prisma.module";
|
|
||||||
import { PayPeriodsController } from "./controllers/pay-periods.controller";
|
|
||||||
import { Module } from "@nestjs/common";
|
|
||||||
import { PayPeriodsQueryService } from "./services/pay-periods-query.service";
|
import { PayPeriodsQueryService } from "./services/pay-periods-query.service";
|
||||||
import { TimesheetsModule } from "../time-tracker/timesheets/timesheets.module";
|
import { BusinessLogicsModule } from "src/time-and-attendance/domains/business-logics.module";
|
||||||
import { SharedModule } from "../shared/shared.module";
|
import { PayPeriodsController } from "./controllers/pay-periods.controller";
|
||||||
import { PrismaService } from "src/prisma/prisma.service";
|
import { PrismaService } from "src/prisma/prisma.service";
|
||||||
import { BusinessLogicsModule } from "../../../modules/business-logics/business-logics.module";
|
import { PrismaModule } from "src/prisma/prisma.module";
|
||||||
|
import { SharedModule } from "../shared/shared.module";
|
||||||
|
import { Module } from "@nestjs/common";
|
||||||
|
|
||||||
@Module({
|
@Module({
|
||||||
imports: [PrismaModule, TimesheetsModule, SharedModule, BusinessLogicsModule],
|
imports: [PrismaModule, SharedModule, BusinessLogicsModule],
|
||||||
providers: [
|
providers: [
|
||||||
PayPeriodsQueryService,
|
PayPeriodsQueryService,
|
||||||
PrismaService,
|
PrismaService,
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
import { Injectable, NotFoundException } from "@nestjs/common";
|
import { Injectable, NotFoundException } from "@nestjs/common";
|
||||||
import { Prisma, PrismaClient } from "@prisma/client";
|
import { Prisma, PrismaClient } from "@prisma/client";
|
||||||
import { weekStartSunday } from "src/Time_And_Attendance/modules/time-tracker/shifts/helpers/shifts-date-time-helpers";
|
import { weekStartSunday } from "src/time-and-attendance/modules/time-tracker/shifts/helpers/shifts-date-time-helpers";
|
||||||
import { PrismaService } from "src/prisma/prisma.service";
|
import { PrismaService } from "src/prisma/prisma.service";
|
||||||
import { EmailToIdResolver } from "./resolve-email-id.utils";
|
import { EmailToIdResolver } from "./resolve-email-id.utils";
|
||||||
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
import { BadRequestException, Body, Controller, Get, NotFoundException, Param, Post, Put, Query } from "@nestjs/common";
|
import { BadRequestException, Body, Controller, Get, NotFoundException, Param, Post, Put, Query } from "@nestjs/common";
|
||||||
import { SchedulePresetsDto } from "../dtos/create-schedule-presets.dto";
|
import { SchedulePresetsDto } from "../dtos/create-schedule-presets.dto";
|
||||||
import { SchedulePresetsCommandService } from "../services/schedule-presets-command.service";
|
import { SchedulePresetsCommandService } from "../services/schedule-presets-command.service";
|
||||||
import { UpsertAction } from "src/Time_And_Attendance/modules/shared/types/upsert-actions.types";
|
import { UpsertAction } from "src/time-and-attendance/modules/shared/types/upsert-actions.types";
|
||||||
import { SchedulePresetsQueryService } from "../services/schedule-presets-query.service";
|
import { SchedulePresetsQueryService } from "../services/schedule-presets-query.service";
|
||||||
|
|
||||||
@Controller('schedule-presets')
|
@Controller('schedule-presets')
|
||||||
|
|
@ -4,7 +4,7 @@ import { SchedulePresetsQueryService } from "./services/schedule-presets-query.s
|
||||||
import { SchedulePresetsController } from "./controller/schedule-presets.controller";
|
import { SchedulePresetsController } from "./controller/schedule-presets.controller";
|
||||||
import { PrismaService } from "src/prisma/prisma.service";
|
import { PrismaService } from "src/prisma/prisma.service";
|
||||||
import { SchedulePresetsApplyService } from "./services/schedule-presets-apply.service";
|
import { SchedulePresetsApplyService } from "./services/schedule-presets-apply.service";
|
||||||
import { SharedModule } from "../shared/shared.module";
|
import { SharedModule } from "src/time-and-attendance/modules/shared/shared.module";
|
||||||
|
|
||||||
@Module({
|
@Module({
|
||||||
imports: [SharedModule],
|
imports: [SharedModule],
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
import { BadRequestException, ConflictException, Injectable, NotFoundException } from "@nestjs/common";
|
import { BadRequestException, ConflictException, Injectable, NotFoundException } from "@nestjs/common";
|
||||||
import { EmailToIdResolver } from "src/Time_And_Attendance/modules/shared/utils/resolve-email-id.utils";
|
import { EmailToIdResolver } from "src/time-and-attendance/modules/shared/utils/resolve-email-id.utils";
|
||||||
import { PrismaService } from "src/prisma/prisma.service";
|
import { PrismaService } from "src/prisma/prisma.service";
|
||||||
import { ApplyResult } from "../types/schedule-presets.types";
|
import { ApplyResult } from "../types/schedule-presets.types";
|
||||||
import { Prisma, Weekday } from "@prisma/client";
|
import { Prisma, Weekday } from "@prisma/client";
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
import { BadRequestException, ConflictException, Injectable, NotFoundException } from "@nestjs/common";
|
import { BadRequestException, ConflictException, Injectable, NotFoundException } from "@nestjs/common";
|
||||||
import { BankCodesResolver } from "src/Time_And_Attendance/modules/shared/utils/resolve-bank-type-id.utils";
|
import { BankCodesResolver } from "src/time-and-attendance/modules/shared/utils/resolve-bank-type-id.utils";
|
||||||
import { EmailToIdResolver } from "src/Time_And_Attendance/modules/shared/utils/resolve-email-id.utils";
|
import { EmailToIdResolver } from "src/time-and-attendance/modules/shared/utils/resolve-email-id.utils";
|
||||||
import { UpsertAction } from "src/Time_And_Attendance/modules/shared/types/upsert-actions.types";
|
import { UpsertAction } from "src/time-and-attendance/modules/shared/types/upsert-actions.types";
|
||||||
import { PrismaService } from "src/prisma/prisma.service";
|
import { PrismaService } from "src/prisma/prisma.service";
|
||||||
import { SchedulePresetsDto } from "../dtos/create-schedule-presets.dto";
|
import { SchedulePresetsDto } from "../dtos/create-schedule-presets.dto";
|
||||||
import { Prisma, Weekday } from "@prisma/client";
|
import { Prisma, Weekday } from "@prisma/client";
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
import { Injectable, NotFoundException } from "@nestjs/common";
|
import { Injectable, NotFoundException } from "@nestjs/common";
|
||||||
import { EmailToIdResolver } from "src/Time_And_Attendance/modules/shared/utils/resolve-email-id.utils";
|
import { EmailToIdResolver } from "src/time-and-attendance/modules/shared/utils/resolve-email-id.utils";
|
||||||
import { PrismaService } from "src/prisma/prisma.service";
|
import { PrismaService } from "src/prisma/prisma.service";
|
||||||
import { PresetResponse, ShiftResponse } from "../types/schedule-presets.types";
|
import { PresetResponse, ShiftResponse } from "../types/schedule-presets.types";
|
||||||
import { Prisma } from "@prisma/client";
|
import { Prisma } from "@prisma/client";
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user