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": {
|
||||
"get": {
|
||||
"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": {
|
||||
"get": {
|
||||
"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}": {
|
||||
"post": {
|
||||
"operationId": "ShiftController_createBatch",
|
||||
|
|
@ -759,6 +621,20 @@
|
|||
]
|
||||
}
|
||||
},
|
||||
"/shift": {
|
||||
"patch": {
|
||||
"operationId": "ShiftController_updateBatch",
|
||||
"parameters": [],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": ""
|
||||
}
|
||||
},
|
||||
"tags": [
|
||||
"Shift"
|
||||
]
|
||||
}
|
||||
},
|
||||
"/shift/{shift_id}": {
|
||||
"delete": {
|
||||
"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}": {
|
||||
"put": {
|
||||
"operationId": "SchedulePresetsController_upsert",
|
||||
|
|
@ -915,6 +758,100 @@
|
|||
"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": {
|
||||
|
|
@ -974,162 +911,6 @@
|
|||
}
|
||||
},
|
||||
"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": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
|
|
@ -1407,6 +1188,10 @@
|
|||
"SchedulePresetsDto": {
|
||||
"type": "object",
|
||||
"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() {
|
||||
const customerUsers = await prisma.users.findMany({
|
||||
where: { role: Roles.CUSTOMER },
|
||||
orderBy: { email: 'asc' },
|
||||
});
|
||||
// async function main() {
|
||||
// const customerUsers = await prisma.users.findMany({
|
||||
// where: { role: Roles.CUSTOMER },
|
||||
// orderBy: { email: 'asc' },
|
||||
// });
|
||||
|
||||
let i = 0;
|
||||
for (const u of customerUsers) {
|
||||
await prisma.customers.upsert({
|
||||
where: { user_id: u.id },
|
||||
update: {},
|
||||
create: {
|
||||
user_id: u.id,
|
||||
invoice_id: i % 2 === 0 ? 100000 + i : null, // 1 sur 2 a un invoice_id
|
||||
},
|
||||
});
|
||||
i++;
|
||||
}
|
||||
// let i = 0;
|
||||
// for (const u of customerUsers) {
|
||||
// await prisma.customers.upsert({
|
||||
// where: { user_id: u.id },
|
||||
// update: {},
|
||||
// create: {
|
||||
// user_id: u.id,
|
||||
// invoice_id: i % 2 === 0 ? 100000 + i : null, // 1 sur 2 a un invoice_id
|
||||
// },
|
||||
// });
|
||||
// i++;
|
||||
// }
|
||||
|
||||
const total = await prisma.customers.count();
|
||||
console.log(`✓ Customers: ${total} rows`);
|
||||
}
|
||||
// const total = await prisma.customers.count();
|
||||
// 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') {
|
||||
console.log("⏭ Seed leave-requests ignoré (SKIP_LEAVE_REQUESTS=true)");
|
||||
process.exit(0);
|
||||
}
|
||||
// if (process.env.SKIP_LEAVE_REQUESTS === 'true') {
|
||||
// console.log("⏭ Seed leave-requests ignoré (SKIP_LEAVE_REQUESTS=true)");
|
||||
// process.exit(0);
|
||||
// }
|
||||
|
||||
const prisma = new PrismaClient();
|
||||
// const prisma = new PrismaClient();
|
||||
|
||||
function daysAgo(n: number) {
|
||||
const d = new Date();
|
||||
d.setDate(d.getDate() - n);
|
||||
d.setHours(0,0,0,0);
|
||||
return d;
|
||||
}
|
||||
// function daysAgo(n: number) {
|
||||
// const d = new Date();
|
||||
// d.setDate(d.getDate() - n);
|
||||
// d.setHours(0,0,0,0);
|
||||
// return d;
|
||||
// }
|
||||
|
||||
async function main() {
|
||||
const employees = await prisma.employees.findMany({
|
||||
include: { user: true },
|
||||
take: 10, // archive 10
|
||||
});
|
||||
// async function main() {
|
||||
// const employees = await prisma.employees.findMany({
|
||||
// include: { user: true },
|
||||
// take: 10, // archive 10
|
||||
// });
|
||||
|
||||
for (const e of employees) {
|
||||
await prisma.employeesArchive.create({
|
||||
data: {
|
||||
employee_id: e.id,
|
||||
user_id: e.user_id,
|
||||
first_name: e.user.first_name,
|
||||
last_name: e.user.last_name,
|
||||
external_payroll_id: e.external_payroll_id,
|
||||
company_code: e.company_code,
|
||||
first_work_day: e.first_work_day,
|
||||
last_work_day: daysAgo(30),
|
||||
supervisor_id: e.supervisor_id ?? null,
|
||||
job_title: e.job_title,
|
||||
is_supervisor: e.is_supervisor,
|
||||
},
|
||||
});
|
||||
}
|
||||
// for (const e of employees) {
|
||||
// await prisma.employeesArchive.create({
|
||||
// data: {
|
||||
// employee_id: e.id,
|
||||
// user_id: e.user_id,
|
||||
// first_name: e.user.first_name,
|
||||
// last_name: e.user.last_name,
|
||||
// external_payroll_id: e.external_payroll_id,
|
||||
// company_code: e.company_code,
|
||||
// first_work_day: e.first_work_day,
|
||||
// last_work_day: daysAgo(30),
|
||||
// supervisor_id: e.supervisor_id ?? null,
|
||||
// job_title: e.job_title,
|
||||
// is_supervisor: e.is_supervisor,
|
||||
// },
|
||||
// });
|
||||
// }
|
||||
|
||||
const total = await prisma.employeesArchive.count();
|
||||
console.log(`✓ EmployeesArchive: ${total} rows (added 10)`);
|
||||
}
|
||||
// const total = await prisma.employeesArchive.count();
|
||||
// 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
|
||||
import { PrismaClient } from '@prisma/client';
|
||||
// // prisma/mock-seeds-scripts/06-customers-archive.ts
|
||||
// import { PrismaClient } from '@prisma/client';
|
||||
|
||||
if (process.env.SKIP_LEAVE_REQUESTS === 'true') {
|
||||
console.log("⏭ Seed leave-requests ignoré (SKIP_LEAVE_REQUESTS=true)");
|
||||
process.exit(0);
|
||||
}
|
||||
// if (process.env.SKIP_LEAVE_REQUESTS === 'true') {
|
||||
// console.log("⏭ Seed leave-requests ignoré (SKIP_LEAVE_REQUESTS=true)");
|
||||
// process.exit(0);
|
||||
// }
|
||||
|
||||
const prisma = new PrismaClient();
|
||||
// const prisma = new PrismaClient();
|
||||
|
||||
async function main() {
|
||||
const customers = await prisma.customers.findMany({
|
||||
orderBy: { id: 'asc' },
|
||||
take: 5,
|
||||
});
|
||||
// async function main() {
|
||||
// const customers = await prisma.customers.findMany({
|
||||
// orderBy: { id: 'asc' },
|
||||
// take: 5,
|
||||
// });
|
||||
|
||||
for (const c of customers) {
|
||||
const invoiceId = 200000 + c.id; // déterministe, stable entre runs
|
||||
// for (const c of customers) {
|
||||
// const invoiceId = 200000 + c.id; // déterministe, stable entre runs
|
||||
|
||||
await prisma.customersArchive.upsert({
|
||||
where: { invoice_id: invoiceId }, // invoice_id est unique
|
||||
update: {}, // idempotent
|
||||
create: {
|
||||
customer_id: c.id,
|
||||
user_id: c.user_id,
|
||||
invoice_id: invoiceId,
|
||||
},
|
||||
});
|
||||
}
|
||||
// await prisma.customersArchive.upsert({
|
||||
// where: { invoice_id: invoiceId }, // invoice_id est unique
|
||||
// update: {}, // idempotent
|
||||
// create: {
|
||||
// customer_id: c.id,
|
||||
// user_id: c.user_id,
|
||||
// invoice_id: invoiceId,
|
||||
// },
|
||||
// });
|
||||
// }
|
||||
|
||||
const total = await prisma.customersArchive.count();
|
||||
console.log(`✓ CustomersArchive upserted for ${customers.length} customers (total=${total})`);
|
||||
}
|
||||
// const total = await prisma.customersArchive.count();
|
||||
// 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') {
|
||||
console.log('?? Seed leave-requests ignoré (SKIP_LEAVE_REQUESTS=true)');
|
||||
process.exit(0);
|
||||
}
|
||||
// if (process.env.SKIP_LEAVE_REQUESTS === 'true') {
|
||||
// console.log('?? Seed leave-requests ignor<6F> (SKIP_LEAVE_REQUESTS=true)');
|
||||
// process.exit(0);
|
||||
// }
|
||||
|
||||
const prisma = new PrismaClient();
|
||||
// const prisma = new PrismaClient();
|
||||
|
||||
function daysAgo(n: number) {
|
||||
const d = new Date();
|
||||
d.setUTCDate(d.getUTCDate() - n);
|
||||
d.setUTCHours(0, 0, 0, 0);
|
||||
return d;
|
||||
}
|
||||
// function daysAgo(n: number) {
|
||||
// const d = new Date();
|
||||
// d.setUTCDate(d.getUTCDate() - n);
|
||||
// d.setUTCHours(0, 0, 0, 0);
|
||||
// return d;
|
||||
// }
|
||||
|
||||
async function main() {
|
||||
const employees = await prisma.employees.findMany({ select: { id: true } });
|
||||
if (!employees.length) {
|
||||
throw new Error('Aucun employé trouvé. Exécute le seed employees avant celui-ci.');
|
||||
}
|
||||
// async function main() {
|
||||
// const employees = await prisma.employees.findMany({ select: { id: true } });
|
||||
// if (!employees.length) {
|
||||
// throw new Error('Aucun employ<6F> trouv<75>. Ex<45>cute le seed employees avant celui-ci.');
|
||||
// }
|
||||
|
||||
const leaveCodes = await prisma.bankCodes.findMany({
|
||||
where: { type: { in: ['SICK', 'VACATION', 'HOLIDAY'] } },
|
||||
select: { id: true, type: true },
|
||||
});
|
||||
if (!leaveCodes.length) {
|
||||
throw new Error("Aucun bank code trouvé avec type in ('SICK','VACATION','HOLIDAY'). Vérifie ta table bank_codes.");
|
||||
}
|
||||
// const leaveCodes = await prisma.bankCodes.findMany({
|
||||
// where: { type: { in: ['SICK', 'VACATION', 'HOLIDAY'] } },
|
||||
// select: { id: true, type: true },
|
||||
// });
|
||||
// if (!leaveCodes.length) {
|
||||
// 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 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 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 COUNT = 12;
|
||||
for (let i = 0; i < COUNT; i++) {
|
||||
const emp = employees[i % employees.length];
|
||||
const leaveCode = leaveCodes[Math.floor(Math.random() * leaveCodes.length)];
|
||||
// const COUNT = 12;
|
||||
// for (let i = 0; i < COUNT; i++) {
|
||||
// const emp = employees[i % employees.length];
|
||||
// const leaveCode = leaveCodes[Math.floor(Math.random() * leaveCodes.length)];
|
||||
|
||||
const date = daysAgo(120 - i * 3);
|
||||
const status = statuses[(i + 2) % statuses.length];
|
||||
const requestedHours = 4 + (i % 5); // 4 ? 8 h
|
||||
const payableHours = status === LeaveApprovalStatus.APPROVED ? Math.min(requestedHours, 8) : null;
|
||||
// const date = daysAgo(120 - i * 3);
|
||||
// const status = statuses[(i + 2) % statuses.length];
|
||||
// const requestedHours = 4 + (i % 5); // 4 ? 8 h
|
||||
// const payableHours = status === LeaveApprovalStatus.APPROVED ? Math.min(requestedHours, 8) : null;
|
||||
|
||||
const lr = await prisma.leaveRequests.create({
|
||||
data: {
|
||||
employee_id: emp.id,
|
||||
bank_code_id: leaveCode.id,
|
||||
leave_type: leaveCode.type as LeaveTypes,
|
||||
date,
|
||||
comment: `Past leave #${i + 1} (${leaveCode.type})`,
|
||||
approval_status: status,
|
||||
requested_hours: requestedHours,
|
||||
payable_hours: payableHours,
|
||||
},
|
||||
});
|
||||
// const lr = await prisma.leaveRequests.create({
|
||||
// data: {
|
||||
// employee_id: emp.id,
|
||||
// bank_code_id: leaveCode.id,
|
||||
// leave_type: leaveCode.type as LeaveTypes,
|
||||
// date,
|
||||
// comment: `Past leave #${i + 1} (${leaveCode.type})`,
|
||||
// approval_status: status,
|
||||
// requested_hours: requestedHours,
|
||||
// payable_hours: payableHours,
|
||||
// },
|
||||
// });
|
||||
|
||||
created.push({
|
||||
id: lr.id,
|
||||
employee_id: lr.employee_id,
|
||||
leave_type: lr.leave_type,
|
||||
date: lr.date,
|
||||
comment: lr.comment,
|
||||
approval_status: lr.approval_status,
|
||||
requested_hours: requestedHours,
|
||||
payable_hours: payableHours,
|
||||
});
|
||||
}
|
||||
// created.push({
|
||||
// id: lr.id,
|
||||
// employee_id: lr.employee_id,
|
||||
// leave_type: lr.leave_type,
|
||||
// date: lr.date,
|
||||
// comment: lr.comment,
|
||||
// approval_status: lr.approval_status,
|
||||
// requested_hours: requestedHours,
|
||||
// payable_hours: payableHours,
|
||||
// });
|
||||
// }
|
||||
|
||||
for (const lr of created) {
|
||||
await prisma.leaveRequestsArchive.create({
|
||||
data: {
|
||||
leave_request_id: lr.id,
|
||||
employee_id: lr.employee_id,
|
||||
leave_type: lr.leave_type,
|
||||
date: lr.date,
|
||||
comment: lr.comment,
|
||||
approval_status: lr.approval_status,
|
||||
requested_hours: lr.requested_hours,
|
||||
payable_hours: lr.payable_hours,
|
||||
},
|
||||
});
|
||||
}
|
||||
// for (const lr of created) {
|
||||
// await prisma.leaveRequestsArchive.create({
|
||||
// data: {
|
||||
// leave_request_id: lr.id,
|
||||
// employee_id: lr.employee_id,
|
||||
// leave_type: lr.leave_type,
|
||||
// date: lr.date,
|
||||
// comment: lr.comment,
|
||||
// approval_status: lr.approval_status,
|
||||
// requested_hours: lr.requested_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') {
|
||||
console.log("⏭ Seed leave-requests ignoré (SKIP_LEAVE_REQUESTS=true)");
|
||||
process.exit(0);
|
||||
}
|
||||
// if (process.env.SKIP_LEAVE_REQUESTS === 'true') {
|
||||
// console.log("⏭ Seed leave-requests ignoré (SKIP_LEAVE_REQUESTS=true)");
|
||||
// process.exit(0);
|
||||
// }
|
||||
|
||||
const prisma = new PrismaClient();
|
||||
// const prisma = new PrismaClient();
|
||||
|
||||
function timeAt(h:number,m:number) {
|
||||
return new Date(Date.UTC(1970,0,1,h,m,0));
|
||||
}
|
||||
function daysAgo(n:number) {
|
||||
const d = new Date();
|
||||
d.setUTCDate(d.getUTCDate() - n);
|
||||
d.setUTCHours(0,0,0,0);
|
||||
return d;
|
||||
}
|
||||
// function timeAt(h:number,m:number) {
|
||||
// return new Date(Date.UTC(1970,0,1,h,m,0));
|
||||
// }
|
||||
// function daysAgo(n:number) {
|
||||
// const d = new Date();
|
||||
// d.setUTCDate(d.getUTCDate() - n);
|
||||
// d.setUTCHours(0,0,0,0);
|
||||
// return d;
|
||||
// }
|
||||
|
||||
async function main() {
|
||||
const bankCodes = await prisma.bankCodes.findMany({ where: { categorie: 'SHIFT' }, select: { id: true } });
|
||||
const employees = await prisma.employees.findMany({ select: { id: true } });
|
||||
// async function main() {
|
||||
// const bankCodes = await prisma.bankCodes.findMany({ where: { categorie: 'SHIFT' }, select: { id: true } });
|
||||
// const employees = await prisma.employees.findMany({ select: { id: true } });
|
||||
|
||||
for (const e of employees) {
|
||||
const tss = await prisma.timesheets.findMany({ where: { employee_id: e.id }, select: { id: true } });
|
||||
if (!tss.length) continue;
|
||||
// for (const e of employees) {
|
||||
// const tss = await prisma.timesheets.findMany({ where: { employee_id: e.id }, select: { id: true } });
|
||||
// if (!tss.length) continue;
|
||||
|
||||
const createdShiftIds: number[] = [];
|
||||
for (let i = 0; i < 8; i++) {
|
||||
const ts = tss[i % tss.length];
|
||||
const bc = bankCodes[i % bankCodes.length];
|
||||
const date = daysAgo(200 + i); // bien dans le passé
|
||||
const startH = 7 + (i % 4); // 7..10
|
||||
const endH = startH + 8; // 15..18
|
||||
// const createdShiftIds: number[] = [];
|
||||
// for (let i = 0; i < 8; i++) {
|
||||
// const ts = tss[i % tss.length];
|
||||
// const bc = bankCodes[i % bankCodes.length];
|
||||
// const date = daysAgo(200 + i); // bien dans le passé
|
||||
// const startH = 7 + (i % 4); // 7..10
|
||||
// const endH = startH + 8; // 15..18
|
||||
|
||||
const sh = await prisma.shifts.create({
|
||||
data: {
|
||||
timesheet_id: ts.id,
|
||||
bank_code_id: bc.id,
|
||||
comment: `Archived-era shift ${i + 1} for emp ${e.id}`,
|
||||
date,
|
||||
start_time: timeAt(startH, 0),
|
||||
end_time: timeAt(endH, 0),
|
||||
is_approved: true,
|
||||
},
|
||||
});
|
||||
createdShiftIds.push(sh.id);
|
||||
}
|
||||
// const sh = await prisma.shifts.create({
|
||||
// data: {
|
||||
// timesheet_id: ts.id,
|
||||
// bank_code_id: bc.id,
|
||||
// comment: `Archived-era shift ${i + 1} for emp ${e.id}`,
|
||||
// date,
|
||||
// start_time: timeAt(startH, 0),
|
||||
// end_time: timeAt(endH, 0),
|
||||
// is_approved: true,
|
||||
// },
|
||||
// });
|
||||
// createdShiftIds.push(sh.id);
|
||||
// }
|
||||
|
||||
for (const sid of createdShiftIds) {
|
||||
const s = await prisma.shifts.findUnique({ where: { id: sid } });
|
||||
if (!s) continue;
|
||||
await prisma.shiftsArchive.create({
|
||||
data: {
|
||||
shift_id: s.id,
|
||||
timesheet_id: s.timesheet_id,
|
||||
bank_code_id: s.bank_code_id,
|
||||
comment: s.comment,
|
||||
date: s.date,
|
||||
start_time: s.start_time,
|
||||
end_time: s.end_time,
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
// for (const sid of createdShiftIds) {
|
||||
// const s = await prisma.shifts.findUnique({ where: { id: sid } });
|
||||
// if (!s) continue;
|
||||
// await prisma.shiftsArchive.create({
|
||||
// data: {
|
||||
// shift_id: s.id,
|
||||
// timesheet_id: s.timesheet_id,
|
||||
// bank_code_id: s.bank_code_id,
|
||||
// comment: s.comment,
|
||||
// date: s.date,
|
||||
// start_time: s.start_time,
|
||||
// end_time: s.end_time,
|
||||
// },
|
||||
// });
|
||||
// }
|
||||
// }
|
||||
|
||||
const total = await prisma.shiftsArchive.count();
|
||||
console.log(`✓ ShiftsArchive: ${total} rows total`);
|
||||
}
|
||||
// const total = await prisma.shiftsArchive.count();
|
||||
// console.log(`✓ ShiftsArchive: ${total} rows total`);
|
||||
// }
|
||||
|
||||
main().finally(() => prisma.$disconnect());
|
||||
// main().finally(() => prisma.$disconnect());
|
||||
|
|
|
|||
|
|
@ -1,65 +1,65 @@
|
|||
// 13-expenses-archive.ts
|
||||
import { PrismaClient, Expenses } from '@prisma/client';
|
||||
// // 13-expenses-archive.ts
|
||||
// import { PrismaClient, Expenses } from '@prisma/client';
|
||||
|
||||
if (process.env.SKIP_LEAVE_REQUESTS === 'true') {
|
||||
console.log("⏭ Seed leave-requests ignoré (SKIP_LEAVE_REQUESTS=true)");
|
||||
process.exit(0);
|
||||
}
|
||||
// if (process.env.SKIP_LEAVE_REQUESTS === 'true') {
|
||||
// console.log("⏭ Seed leave-requests ignoré (SKIP_LEAVE_REQUESTS=true)");
|
||||
// process.exit(0);
|
||||
// }
|
||||
|
||||
const prisma = new PrismaClient();
|
||||
// const prisma = new PrismaClient();
|
||||
|
||||
function daysAgo(n:number) {
|
||||
const d = new Date();
|
||||
d.setUTCDate(d.getUTCDate() - n);
|
||||
d.setUTCHours(0,0,0,0);
|
||||
return d;
|
||||
}
|
||||
// function daysAgo(n:number) {
|
||||
// const d = new Date();
|
||||
// d.setUTCDate(d.getUTCDate() - n);
|
||||
// d.setUTCHours(0,0,0,0);
|
||||
// return d;
|
||||
// }
|
||||
|
||||
async function main() {
|
||||
const expenseCodes = await prisma.bankCodes.findMany({ where: { categorie: 'EXPENSE' }, select: { id: true } });
|
||||
const timesheets = await prisma.timesheets.findMany({ select: { id: true } });
|
||||
// async function main() {
|
||||
// const expenseCodes = await prisma.bankCodes.findMany({ where: { categorie: 'EXPENSE' }, select: { id: true } });
|
||||
// const timesheets = await prisma.timesheets.findMany({ select: { id: true } });
|
||||
|
||||
// ✅ typer pour éviter never[]
|
||||
const created: Expenses[] = [];
|
||||
// // ✅ typer pour éviter never[]
|
||||
// const created: Expenses[] = [];
|
||||
|
||||
for (let i = 0; i < 4; i++) {
|
||||
const ts = timesheets[i % timesheets.length];
|
||||
const bc = expenseCodes[i % expenseCodes.length];
|
||||
// for (let i = 0; i < 4; i++) {
|
||||
// const ts = timesheets[i % timesheets.length];
|
||||
// const bc = expenseCodes[i % expenseCodes.length];
|
||||
|
||||
const exp = await prisma.expenses.create({
|
||||
data: {
|
||||
timesheet_id: ts.id,
|
||||
bank_code_id: bc.id,
|
||||
date: daysAgo(60 + i),
|
||||
amount: (20 + i * 3.5).toFixed(2), // ok: Decimal accepte string
|
||||
attachment: null,
|
||||
comment: `Old expense #${i + 1}`,
|
||||
is_approved: true,
|
||||
supervisor_comment: null,
|
||||
},
|
||||
});
|
||||
// const exp = await prisma.expenses.create({
|
||||
// data: {
|
||||
// timesheet_id: ts.id,
|
||||
// bank_code_id: bc.id,
|
||||
// date: daysAgo(60 + i),
|
||||
// amount: (20 + i * 3.5).toFixed(2), // ok: Decimal accepte string
|
||||
// attachment: null,
|
||||
// comment: `Old expense #${i + 1}`,
|
||||
// is_approved: true,
|
||||
// supervisor_comment: null,
|
||||
// },
|
||||
// });
|
||||
|
||||
created.push(exp);
|
||||
}
|
||||
// created.push(exp);
|
||||
// }
|
||||
|
||||
for (const e of created) {
|
||||
await prisma.expensesArchive.create({
|
||||
data: {
|
||||
expense_id: e.id,
|
||||
timesheet_id: e.timesheet_id,
|
||||
bank_code_id: e.bank_code_id,
|
||||
date: e.date,
|
||||
amount: e.amount,
|
||||
attachment: e.attachment,
|
||||
comment: e.comment,
|
||||
is_approved: e.is_approved,
|
||||
supervisor_comment: e.supervisor_comment,
|
||||
},
|
||||
});
|
||||
}
|
||||
// for (const e of created) {
|
||||
// await prisma.expensesArchive.create({
|
||||
// data: {
|
||||
// expense_id: e.id,
|
||||
// timesheet_id: e.timesheet_id,
|
||||
// bank_code_id: e.bank_code_id,
|
||||
// date: e.date,
|
||||
// amount: e.amount,
|
||||
// attachment: e.attachment,
|
||||
// comment: e.comment,
|
||||
// is_approved: e.is_approved,
|
||||
// supervisor_comment: e.supervisor_comment,
|
||||
// },
|
||||
// });
|
||||
// }
|
||||
|
||||
const total = await prisma.expensesArchive.count();
|
||||
console.log(`✓ ExpensesArchive: ${total} total rows (added ${created.length})`);
|
||||
}
|
||||
// const total = await prisma.expensesArchive.count();
|
||||
// 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 { AuthenticationModule } from './modules/authentication/auth.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 { 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 { HealthController } from './health/health.controller';
|
||||
// import { LeaveRequestsModule } from './modules/leave-requests/leave-requests.module';
|
||||
import { NotificationsModule } from './modules/notifications/notifications.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 { PrismaModule } from './prisma/prisma.module';
|
||||
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 { ConfigModule } from '@nestjs/config';
|
||||
import { APP_FILTER, APP_PIPE } from '@nestjs/core';
|
||||
import { HttpExceptionFilter } from './common/filters/http-exception.filter';
|
||||
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({
|
||||
imports: [
|
||||
// ArchivalModule,
|
||||
AuthenticationModule,
|
||||
BankCodesModule,
|
||||
BusinessLogicsModule,
|
||||
ConfigModule.forRoot({isGlobal: true}),
|
||||
// CsvExportModule,
|
||||
CustomersModule,
|
||||
EmployeesModule,
|
||||
// ExpensesModule,
|
||||
// CustomersModule,
|
||||
// EmployeesModule,
|
||||
HealthModule,
|
||||
// LeaveRequestsModule,
|
||||
NotificationsModule,
|
||||
OauthSessionsModule,
|
||||
PayperiodsModule,
|
||||
PreferencesModule,
|
||||
PrismaModule,
|
||||
ScheduleModule.forRoot(), //cronjobs
|
||||
SchedulePresetsModule,
|
||||
ShiftsModule,
|
||||
TimesheetsModule,
|
||||
// ShiftsModule,
|
||||
TimeAndAttendanceModule,
|
||||
// TimesheetsModule,
|
||||
UsersModule,
|
||||
],
|
||||
controllers: [AppController, HealthController],
|
||||
providers: [
|
||||
AppService,
|
||||
OvertimeService,
|
||||
{
|
||||
provide: APP_FILTER,
|
||||
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 { ApiOperation, ApiResponse, ApiTags } from "@nestjs/swagger";
|
||||
import { RolesAllowed } from "src/common/decorators/roles.decorators";
|
||||
import { EmployeesArchive, Roles as RoleEnum } from '@prisma/client';
|
||||
import { EmployeesArchivalService } from "src/modules/employees/services/employees-archival.service";
|
||||
// import { Controller, Get, NotFoundException, Param, ParseIntPipe, UseGuards } from "@nestjs/common";
|
||||
// import { ApiOperation, ApiResponse, ApiTags } from "@nestjs/swagger";
|
||||
// import { RolesAllowed } from "src/common/decorators/roles.decorators";
|
||||
// import { EmployeesArchive, Roles as RoleEnum } from '@prisma/client';
|
||||
// import { EmployeesArchivalService } from "src/modules/employees/services/employees-archival.service";
|
||||
|
||||
@ApiTags('Employee Archives')
|
||||
// @UseGuards()
|
||||
@Controller('archives/employees')
|
||||
export class EmployeesArchiveController {
|
||||
constructor(private readonly employeesArchiveService: EmployeesArchivalService) {}
|
||||
// @ApiTags('Employee Archives')
|
||||
// // @UseGuards()
|
||||
// @Controller('archives/employees')
|
||||
// export class EmployeesArchiveController {
|
||||
// constructor(private readonly employeesArchiveService: EmployeesArchivalService) {}
|
||||
|
||||
@Get()
|
||||
//@RolesAllowed(RoleEnum.ADMIN, RoleEnum.HR, RoleEnum.SUPERVISOR)
|
||||
@ApiOperation({ summary: 'List of archived employees'})
|
||||
@ApiResponse({ status: 200, description: 'List of archived employees', isArray: true })
|
||||
async findAllArchived(): Promise<EmployeesArchive[]> {
|
||||
return this.employeesArchiveService.findAllArchived();
|
||||
}
|
||||
// @Get()
|
||||
// //@RolesAllowed(RoleEnum.ADMIN, RoleEnum.HR, RoleEnum.SUPERVISOR)
|
||||
// @ApiOperation({ summary: 'List of archived employees'})
|
||||
// @ApiResponse({ status: 200, description: 'List of archived employees', isArray: true })
|
||||
// async findAllArchived(): Promise<EmployeesArchive[]> {
|
||||
// return this.employeesArchiveService.findAllArchived();
|
||||
// }
|
||||
|
||||
@Get()
|
||||
//@RolesAllowed(RoleEnum.ADMIN, RoleEnum.HR,RoleEnum.SUPERVISOR)
|
||||
@ApiOperation({ summary: 'Fetch employee in archives with its Id'})
|
||||
@ApiResponse({ status: 200, description: 'Archived employee found'})
|
||||
async findOneArchived(@Param('id', ParseIntPipe) id: number ): Promise<EmployeesArchive> {
|
||||
try{
|
||||
return await this.employeesArchiveService.findOneArchived(id);
|
||||
}catch {
|
||||
throw new NotFoundException(`Archived employee #${id} not found`);
|
||||
}
|
||||
}
|
||||
// @Get()
|
||||
// //@RolesAllowed(RoleEnum.ADMIN, RoleEnum.HR,RoleEnum.SUPERVISOR)
|
||||
// @ApiOperation({ summary: 'Fetch employee in archives with its Id'})
|
||||
// @ApiResponse({ status: 200, description: 'Archived employee found'})
|
||||
// async findOneArchived(@Param('id', ParseIntPipe) id: number ): Promise<EmployeesArchive> {
|
||||
// try{
|
||||
// return await this.employeesArchiveService.findOneArchived(id);
|
||||
// }catch {
|
||||
// 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 { ExpensesArchive,Roles as RoleEnum } from "@prisma/client";
|
||||
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')
|
||||
// @UseGuards()
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ import { Get, Param, ParseIntPipe, NotFoundException, Controller, UseGuards } fr
|
|||
import { ApiOperation, ApiResponse, ApiTags } from "@nestjs/swagger";
|
||||
import { ShiftsArchive, Roles as RoleEnum } from "@prisma/client";
|
||||
import { RolesAllowed } from "src/common/decorators/roles.decorators";
|
||||
import { ShiftsArchivalService } from "src/Time_And_Attendance/modules/time-tracker/shifts/services/shifts-archival.service";
|
||||
import { ShiftsArchivalService } from "src/time-and-attendance/modules/time-tracker/shifts/services/shifts-archival.service";
|
||||
|
||||
@ApiTags('Shift Archives')
|
||||
// @UseGuards()
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ import { Controller, Get, NotFoundException, Param, ParseIntPipe, UseGuards } fr
|
|||
import { ApiOperation, ApiResponse, ApiTags } from "@nestjs/swagger";
|
||||
import { RolesAllowed } from "src/common/decorators/roles.decorators";
|
||||
import { TimesheetsArchive, Roles as RoleEnum } from '@prisma/client';
|
||||
import { TimesheetArchiveService } from "src/Time_And_Attendance/modules/time-tracker/timesheets/services/timesheet-archive.service";
|
||||
import { TimesheetArchiveService } from "src/time-and-attendance/modules/time-tracker/timesheets/services/timesheet-archive.service";
|
||||
|
||||
@ApiTags('Timesheet Archives')
|
||||
// @UseGuards()
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
import { Injectable, Logger } from "@nestjs/common";
|
||||
import { Cron } from "@nestjs/schedule";
|
||||
import { ExpensesArchivalService } from "src/modules/expenses/services/expenses-archival.service";
|
||||
import { ShiftsArchivalService } from "src/Time_And_Attendance/modules/time-tracker/shifts/services/shifts-archival.service";
|
||||
import { TimesheetArchiveService } from "src/Time_And_Attendance/modules/time-tracker/timesheets/services/timesheet-archive.service";
|
||||
import { ExpensesArchivalService } from "src/time-and-attendance/modules/expenses/services/expenses-archival.service";
|
||||
import { ShiftsArchivalService } from "src/time-and-attendance/modules/time-tracker/shifts/services/shifts-archival.service";
|
||||
import { TimesheetArchiveService } from "src/time-and-attendance/modules/time-tracker/timesheets/services/timesheet-archive.service";
|
||||
|
||||
@Injectable()
|
||||
export class ArchivalService {
|
||||
|
|
|
|||
|
|
@ -1,68 +1,68 @@
|
|||
import { Body, Controller, Delete, Get, Param, ParseIntPipe, Patch, Post, UseGuards } from '@nestjs/common';
|
||||
import { CustomersService } from '../services/customers.service';
|
||||
import { Customers } from '@prisma/client';
|
||||
import { CreateCustomerDto } from '../dtos/create-customer.dto';
|
||||
import { UpdateCustomerDto } from '../dtos/update-customer.dto';
|
||||
import { RolesAllowed } from "src/common/decorators/roles.decorators";
|
||||
import { Roles as RoleEnum } from '.prisma/client';
|
||||
import { ApiBearerAuth, ApiOperation, ApiResponse, ApiTags } from '@nestjs/swagger';
|
||||
// import { Body, Controller, Delete, Get, Param, ParseIntPipe, Patch, Post, UseGuards } from '@nestjs/common';
|
||||
// import { CustomersService } from '../services/customers.service';
|
||||
// import { Customers } from '@prisma/client';
|
||||
// import { CreateCustomerDto } from '../dtos/create-customer.dto';
|
||||
// import { UpdateCustomerDto } from '../dtos/update-customer.dto';
|
||||
// import { RolesAllowed } from "src/common/decorators/roles.decorators";
|
||||
// import { Roles as RoleEnum } from '.prisma/client';
|
||||
// import { ApiBearerAuth, ApiOperation, ApiResponse, ApiTags } from '@nestjs/swagger';
|
||||
|
||||
@ApiTags('Customers')
|
||||
@ApiBearerAuth('access-token')
|
||||
// @UseGuards()
|
||||
@Controller('customers')
|
||||
export class CustomersController {
|
||||
constructor(private readonly customersService: CustomersService) {}
|
||||
// @ApiTags('Customers')
|
||||
// @ApiBearerAuth('access-token')
|
||||
// // @UseGuards()
|
||||
// @Controller('customers')
|
||||
// export class CustomersController {
|
||||
// constructor(private readonly customersService: CustomersService) {}
|
||||
|
||||
//_____________________________________________________________________________________________
|
||||
// Deprecated or unused methods
|
||||
//_____________________________________________________________________________________________
|
||||
// //_____________________________________________________________________________________________
|
||||
// // Deprecated or unused methods
|
||||
// //_____________________________________________________________________________________________
|
||||
|
||||
// @Post()
|
||||
// //@RolesAllowed(RoleEnum.ACCOUNTING, RoleEnum.ADMIN, RoleEnum.EMPLOYEE, RoleEnum.SUPERVISOR)
|
||||
// @ApiOperation({ summary: 'Create customer' })
|
||||
// @ApiResponse({ status: 201, description: 'Customer created', type: CreateCustomerDto })
|
||||
// @ApiResponse({ status: 400, description: 'Invalid task or invalid data' })
|
||||
// create(@Body() dto: CreateCustomerDto): Promise<Customers> {
|
||||
// return this.customersService.create(dto);
|
||||
// }
|
||||
// // @Post()
|
||||
// // //@RolesAllowed(RoleEnum.ACCOUNTING, RoleEnum.ADMIN, RoleEnum.EMPLOYEE, RoleEnum.SUPERVISOR)
|
||||
// // @ApiOperation({ summary: 'Create customer' })
|
||||
// // @ApiResponse({ status: 201, description: 'Customer created', type: CreateCustomerDto })
|
||||
// // @ApiResponse({ status: 400, description: 'Invalid task or invalid data' })
|
||||
// // create(@Body() dto: CreateCustomerDto): Promise<Customers> {
|
||||
// // return this.customersService.create(dto);
|
||||
// // }
|
||||
|
||||
// @Get()
|
||||
// //@RolesAllowed(RoleEnum.ACCOUNTING, RoleEnum.ADMIN, RoleEnum.EMPLOYEE, RoleEnum.HR, RoleEnum.SUPERVISOR)
|
||||
// @ApiOperation({ summary: 'Find all customers' })
|
||||
// @ApiResponse({ status: 201, description: 'List of customers found', type: CreateCustomerDto, isArray: true })
|
||||
// @ApiResponse({ status: 400, description: 'List of customers not found' })
|
||||
// findAll(): Promise<Customers[]> {
|
||||
// return this.customersService.findAll();
|
||||
// }
|
||||
// // @Get()
|
||||
// // //@RolesAllowed(RoleEnum.ACCOUNTING, RoleEnum.ADMIN, RoleEnum.EMPLOYEE, RoleEnum.HR, RoleEnum.SUPERVISOR)
|
||||
// // @ApiOperation({ summary: 'Find all customers' })
|
||||
// // @ApiResponse({ status: 201, description: 'List of customers found', type: CreateCustomerDto, isArray: true })
|
||||
// // @ApiResponse({ status: 400, description: 'List of customers not found' })
|
||||
// // findAll(): Promise<Customers[]> {
|
||||
// // return this.customersService.findAll();
|
||||
// // }
|
||||
|
||||
// @Get(':id')
|
||||
// //@RolesAllowed(RoleEnum.ACCOUNTING, RoleEnum.ADMIN, RoleEnum.EMPLOYEE, RoleEnum.HR, RoleEnum.SUPERVISOR)
|
||||
// @ApiOperation({ summary: 'Find customer' })
|
||||
// @ApiResponse({ status: 201, description: 'Customer found', type: CreateCustomerDto })
|
||||
// @ApiResponse({ status: 400, description: 'Customer not found' })
|
||||
// findOne(@Param('id', ParseIntPipe) id: number): Promise<Customers> {
|
||||
// return this.customersService.findOne(id);
|
||||
// }
|
||||
// // @Get(':id')
|
||||
// // //@RolesAllowed(RoleEnum.ACCOUNTING, RoleEnum.ADMIN, RoleEnum.EMPLOYEE, RoleEnum.HR, RoleEnum.SUPERVISOR)
|
||||
// // @ApiOperation({ summary: 'Find customer' })
|
||||
// // @ApiResponse({ status: 201, description: 'Customer found', type: CreateCustomerDto })
|
||||
// // @ApiResponse({ status: 400, description: 'Customer not found' })
|
||||
// // findOne(@Param('id', ParseIntPipe) id: number): Promise<Customers> {
|
||||
// // return this.customersService.findOne(id);
|
||||
// // }
|
||||
|
||||
// @Patch(':id')
|
||||
// //@RolesAllowed(RoleEnum.ACCOUNTING, RoleEnum.ADMIN, RoleEnum.EMPLOYEE,RoleEnum.SUPERVISOR)
|
||||
// @ApiOperation({ summary: 'Update customer' })
|
||||
// @ApiResponse({ status: 201, description: 'Customer updated', type: CreateCustomerDto })
|
||||
// @ApiResponse({ status: 400, description: 'Customer not found' })
|
||||
// update(
|
||||
// @Param('id', ParseIntPipe) id: number,
|
||||
// @Body() dto: UpdateCustomerDto,
|
||||
// ): Promise<Customers> {
|
||||
// return this.customersService.update(id, dto);
|
||||
// }
|
||||
// // @Patch(':id')
|
||||
// // //@RolesAllowed(RoleEnum.ACCOUNTING, RoleEnum.ADMIN, RoleEnum.EMPLOYEE,RoleEnum.SUPERVISOR)
|
||||
// // @ApiOperation({ summary: 'Update customer' })
|
||||
// // @ApiResponse({ status: 201, description: 'Customer updated', type: CreateCustomerDto })
|
||||
// // @ApiResponse({ status: 400, description: 'Customer not found' })
|
||||
// // update(
|
||||
// // @Param('id', ParseIntPipe) id: number,
|
||||
// // @Body() dto: UpdateCustomerDto,
|
||||
// // ): Promise<Customers> {
|
||||
// // return this.customersService.update(id, dto);
|
||||
// // }
|
||||
|
||||
// @Delete(':id')
|
||||
// //@RolesAllowed(RoleEnum.ACCOUNTING, RoleEnum.ADMIN, RoleEnum.SUPERVISOR)
|
||||
// @ApiOperation({ summary: 'Delete customer' })
|
||||
// @ApiResponse({ status: 201, description: 'Customer deleted', type: CreateCustomerDto })
|
||||
// @ApiResponse({ status: 400, description: 'Customer not found' })
|
||||
// remove(@Param('id', ParseIntPipe) id: number): Promise<Customers>{
|
||||
// return this.customersService.remove(id);
|
||||
// }
|
||||
}
|
||||
// // @Delete(':id')
|
||||
// // //@RolesAllowed(RoleEnum.ACCOUNTING, RoleEnum.ADMIN, RoleEnum.SUPERVISOR)
|
||||
// // @ApiOperation({ summary: 'Delete customer' })
|
||||
// // @ApiResponse({ status: 201, description: 'Customer deleted', type: CreateCustomerDto })
|
||||
// // @ApiResponse({ status: 400, description: 'Customer not found' })
|
||||
// // remove(@Param('id', ParseIntPipe) id: number): Promise<Customers>{
|
||||
// // return this.customersService.remove(id);
|
||||
// // }
|
||||
// }
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
|
||||
import { Module } from '@nestjs/common';
|
||||
import { CustomersController } from './controllers/customers.controller';
|
||||
import { CustomersService } from './services/customers.service';
|
||||
// import { Module } from '@nestjs/common';
|
||||
// import { CustomersController } from './controllers/customers.controller';
|
||||
// import { CustomersService } from './services/customers.service';
|
||||
|
||||
@Module({
|
||||
controllers:[CustomersController],
|
||||
providers:[CustomersService],
|
||||
})
|
||||
export class CustomersModule {}
|
||||
// @Module({
|
||||
// controllers:[CustomersController],
|
||||
// providers:[CustomersService],
|
||||
// })
|
||||
// export class CustomersModule {}
|
||||
|
|
@ -1,99 +1,99 @@
|
|||
import { Body,Controller,Get,NotFoundException,Param,Patch } from '@nestjs/common';
|
||||
import { EmployeesService } from '../services/employees.service';
|
||||
import { CreateEmployeeDto } from '../dtos/create-employee.dto';
|
||||
import { UpdateEmployeeDto } from '../dtos/update-employee.dto';
|
||||
import { RolesAllowed } from '../../../common/decorators/roles.decorators';
|
||||
import { ApiBearerAuth, ApiOperation, ApiParam, ApiResponse, ApiTags } from '@nestjs/swagger';
|
||||
import { EmployeeListItemDto } from '../dtos/list-employee.dto';
|
||||
import { EmployeesArchivalService } from '../services/employees-archival.service';
|
||||
import { EmployeeProfileItemDto } from 'src/modules/employees/dtos/profil-employee.dto';
|
||||
// import { Body,Controller,Get,NotFoundException,Param,Patch } from '@nestjs/common';
|
||||
// import { EmployeesService } from '../services/employees.service';
|
||||
// import { CreateEmployeeDto } from '../dtos/create-employee.dto';
|
||||
// import { UpdateEmployeeDto } from '../dtos/update-employee.dto';
|
||||
// import { RolesAllowed } from '../../../common/decorators/roles.decorators';
|
||||
// import { ApiBearerAuth, ApiOperation, ApiParam, ApiResponse, ApiTags } from '@nestjs/swagger';
|
||||
// import { EmployeeListItemDto } from '../dtos/list-employee.dto';
|
||||
// import { EmployeesArchivalService } from '../services/employees-archival.service';
|
||||
// import { EmployeeProfileItemDto } from 'src/modules/employees/dtos/profil-employee.dto';
|
||||
|
||||
@ApiTags('Employees')
|
||||
@ApiBearerAuth('access-token')
|
||||
// @UseGuards()
|
||||
@Controller('employees')
|
||||
export class EmployeesController {
|
||||
constructor(
|
||||
private readonly employeesService: EmployeesService,
|
||||
private readonly archiveService: EmployeesArchivalService,
|
||||
) {}
|
||||
// @ApiTags('Employees')
|
||||
// @ApiBearerAuth('access-token')
|
||||
// // @UseGuards()
|
||||
// @Controller('employees')
|
||||
// export class EmployeesController {
|
||||
// constructor(
|
||||
// private readonly employeesService: EmployeesService,
|
||||
// private readonly archiveService: EmployeesArchivalService,
|
||||
// ) {}
|
||||
|
||||
@Get('employee-list')
|
||||
//@RolesAllowed(RoleEnum.ADMIN, RoleEnum.HR, RoleEnum.SUPERVISOR, RoleEnum.ACCOUNTING)
|
||||
@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: 400, description: 'List of employees with scoped info not found' })
|
||||
findListEmployees(): Promise<EmployeeListItemDto[]> {
|
||||
return this.employeesService.findListEmployees();
|
||||
}
|
||||
// @Get('employee-list')
|
||||
// //@RolesAllowed(RoleEnum.ADMIN, RoleEnum.HR, RoleEnum.SUPERVISOR, RoleEnum.ACCOUNTING)
|
||||
// @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: 400, description: 'List of employees with scoped info not found' })
|
||||
// findListEmployees(): Promise<EmployeeListItemDto[]> {
|
||||
// return this.employeesService.findListEmployees();
|
||||
// }
|
||||
|
||||
@Patch(':email')
|
||||
//@RolesAllowed(RoleEnum.ADMIN, RoleEnum.HR, RoleEnum.SUPERVISOR)
|
||||
@ApiBearerAuth('access-token')
|
||||
@ApiOperation({ summary: 'Update, archive or restore an employee' })
|
||||
@ApiParam({ name: 'email', type: Number, description: 'Email of the employee' })
|
||||
@ApiResponse({ status: 200, description: 'Employee updated or restored', type: CreateEmployeeDto })
|
||||
@ApiResponse({ status: 202, description: 'Employee archived successfully', type: CreateEmployeeDto })
|
||||
@ApiResponse({ status: 404, description: 'Employee not found in active or archive' })
|
||||
async updateOrArchiveOrRestore(@Param('email') email: string, @Body() dto: UpdateEmployeeDto,) {
|
||||
// if last_work_day is set => archive the employee
|
||||
// else if employee is archived and first_work_day or last_work_day = null => restore
|
||||
//otherwise => standard update
|
||||
const result = await this.archiveService.patchEmployee(email, dto);
|
||||
if(!result) {
|
||||
throw new NotFoundException(`Employee with email: ${ email } is not found in active or archive.`)
|
||||
}
|
||||
return result;
|
||||
}
|
||||
// @Patch(':email')
|
||||
// //@RolesAllowed(RoleEnum.ADMIN, RoleEnum.HR, RoleEnum.SUPERVISOR)
|
||||
// @ApiBearerAuth('access-token')
|
||||
// @ApiOperation({ summary: 'Update, archive or restore an employee' })
|
||||
// @ApiParam({ name: 'email', type: Number, description: 'Email of the employee' })
|
||||
// @ApiResponse({ status: 200, description: 'Employee updated or restored', type: CreateEmployeeDto })
|
||||
// @ApiResponse({ status: 202, description: 'Employee archived successfully', type: CreateEmployeeDto })
|
||||
// @ApiResponse({ status: 404, description: 'Employee not found in active or archive' })
|
||||
// async updateOrArchiveOrRestore(@Param('email') email: string, @Body() dto: UpdateEmployeeDto,) {
|
||||
// // if last_work_day is set => archive the employee
|
||||
// // else if employee is archived and first_work_day or last_work_day = null => restore
|
||||
// //otherwise => standard update
|
||||
// const result = await this.archiveService.patchEmployee(email, dto);
|
||||
// if(!result) {
|
||||
// throw new NotFoundException(`Employee with email: ${ email } is not found in active or archive.`)
|
||||
// }
|
||||
// return result;
|
||||
// }
|
||||
|
||||
//_____________________________________________________________________________________________
|
||||
// Deprecated or unused methods
|
||||
//_____________________________________________________________________________________________
|
||||
// //_____________________________________________________________________________________________
|
||||
// // Deprecated or unused methods
|
||||
// //_____________________________________________________________________________________________
|
||||
|
||||
// @Post()
|
||||
// //@RolesAllowed(RoleEnum.ADMIN, RoleEnum.HR, RoleEnum.SUPERVISOR)
|
||||
// @ApiOperation({summary: 'Create employee' })
|
||||
// @ApiResponse({ status: 201, description: 'Employee created', type: CreateEmployeeDto })
|
||||
// @ApiResponse({ status: 400, description: 'Incomplete task or invalid data' })
|
||||
// create(@Body() dto: CreateEmployeeDto): Promise<Employees> {
|
||||
// return this.employeesService.create(dto);
|
||||
// }
|
||||
// @Get()
|
||||
// //@RolesAllowed(RoleEnum.ADMIN, RoleEnum.HR, RoleEnum.SUPERVISOR, RoleEnum.ACCOUNTING)
|
||||
// @ApiOperation({summary: 'Find all employees' })
|
||||
// @ApiResponse({ status: 200, description: 'List of employees found', type: CreateEmployeeDto, isArray: true })
|
||||
// @ApiResponse({ status: 400, description: 'List of employees not found' })
|
||||
// findAll(): Promise<Employees[]> {
|
||||
// return this.employeesService.findAll();
|
||||
// }
|
||||
// // @Post()
|
||||
// // //@RolesAllowed(RoleEnum.ADMIN, RoleEnum.HR, RoleEnum.SUPERVISOR)
|
||||
// // @ApiOperation({summary: 'Create employee' })
|
||||
// // @ApiResponse({ status: 201, description: 'Employee created', type: CreateEmployeeDto })
|
||||
// // @ApiResponse({ status: 400, description: 'Incomplete task or invalid data' })
|
||||
// // create(@Body() dto: CreateEmployeeDto): Promise<Employees> {
|
||||
// // return this.employeesService.create(dto);
|
||||
// // }
|
||||
// // @Get()
|
||||
// // //@RolesAllowed(RoleEnum.ADMIN, RoleEnum.HR, RoleEnum.SUPERVISOR, RoleEnum.ACCOUNTING)
|
||||
// // @ApiOperation({summary: 'Find all employees' })
|
||||
// // @ApiResponse({ status: 200, description: 'List of employees found', type: CreateEmployeeDto, isArray: true })
|
||||
// // @ApiResponse({ status: 400, description: 'List of employees not found' })
|
||||
// // findAll(): Promise<Employees[]> {
|
||||
// // return this.employeesService.findAll();
|
||||
// // }
|
||||
|
||||
|
||||
// @Get(':email')
|
||||
// //@RolesAllowed(RoleEnum.ADMIN, RoleEnum.HR, RoleEnum.SUPERVISOR,RoleEnum.ACCOUNTING )
|
||||
// @ApiOperation({summary: 'Find employee' })
|
||||
// @ApiResponse({ status: 200, description: 'Employee found', type: CreateEmployeeDto })
|
||||
// @ApiResponse({ status: 400, description: 'Employee not found' })
|
||||
// findOne(@Param('email', ParseIntPipe) email: string): Promise<Employees> {
|
||||
// return this.employeesService.findOne(email);
|
||||
// }
|
||||
// // @Get(':email')
|
||||
// // //@RolesAllowed(RoleEnum.ADMIN, RoleEnum.HR, RoleEnum.SUPERVISOR,RoleEnum.ACCOUNTING )
|
||||
// // @ApiOperation({summary: 'Find employee' })
|
||||
// // @ApiResponse({ status: 200, description: 'Employee found', type: CreateEmployeeDto })
|
||||
// // @ApiResponse({ status: 400, description: 'Employee not found' })
|
||||
// // findOne(@Param('email', ParseIntPipe) email: string): Promise<Employees> {
|
||||
// // return this.employeesService.findOne(email);
|
||||
// // }
|
||||
|
||||
@Get('profile/:email')
|
||||
@ApiOperation({summary: 'Find employee profile' })
|
||||
@ApiParam({ name: 'email', type: String, description: 'Identifier of the employee' })
|
||||
@ApiResponse({ status: 200, description: 'Employee profile found', type: EmployeeProfileItemDto })
|
||||
@ApiResponse({ status: 400, description: 'Employee profile not found' })
|
||||
findOneProfile(@Param('email') email: string): Promise<EmployeeProfileItemDto> {
|
||||
return this.employeesService.findOneProfile(email);
|
||||
}
|
||||
// @Get('profile/:email')
|
||||
// @ApiOperation({summary: 'Find employee profile' })
|
||||
// @ApiParam({ name: 'email', type: String, description: 'Identifier of the employee' })
|
||||
// @ApiResponse({ status: 200, description: 'Employee profile found', type: EmployeeProfileItemDto })
|
||||
// @ApiResponse({ status: 400, description: 'Employee profile not found' })
|
||||
// findOneProfile(@Param('email') email: string): Promise<EmployeeProfileItemDto> {
|
||||
// return this.employeesService.findOneProfile(email);
|
||||
// }
|
||||
|
||||
// @Delete(':email')
|
||||
// //@RolesAllowed(RoleEnum.ADMIN, RoleEnum.HR, RoleEnum.SUPERVISOR )
|
||||
// @ApiOperation({summary: 'Delete employee' })
|
||||
// @ApiParam({ name: 'email', type: Number, description: 'Email of the employee to delete' })
|
||||
// @ApiResponse({ status: 204, description: 'Employee deleted' })
|
||||
// @ApiResponse({ status: 404, description: 'Employee not found' })
|
||||
// remove(@Param('email', ParseIntPipe) email: string): Promise<Employees> {
|
||||
// return this.employeesService.remove(email);
|
||||
// }
|
||||
// // @Delete(':email')
|
||||
// // //@RolesAllowed(RoleEnum.ADMIN, RoleEnum.HR, RoleEnum.SUPERVISOR )
|
||||
// // @ApiOperation({summary: 'Delete employee' })
|
||||
// // @ApiParam({ name: 'email', type: Number, description: 'Email of the employee to delete' })
|
||||
// // @ApiResponse({ status: 204, description: 'Employee deleted' })
|
||||
// // @ApiResponse({ status: 404, description: 'Employee not found' })
|
||||
// // remove(@Param('email', ParseIntPipe) email: string): Promise<Employees> {
|
||||
// // return this.employeesService.remove(email);
|
||||
// // }
|
||||
|
||||
}
|
||||
// }
|
||||
|
|
|
|||
|
|
@ -1,13 +1,12 @@
|
|||
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';
|
||||
// import { Module } from '@nestjs/common';
|
||||
// import { EmployeesController } from './controllers/employees.controller';
|
||||
// import { EmployeesService } from './services/employees.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 {}
|
||||
// @Module({
|
||||
// imports: [SharedModule],
|
||||
// controllers: [EmployeesController],
|
||||
// providers: [EmployeesService],
|
||||
// exports: [EmployeesService ],
|
||||
// })
|
||||
// export class EmployeesModule {}
|
||||
|
|
|
|||
|
|
@ -1,173 +1,173 @@
|
|||
import { Injectable } from "@nestjs/common";
|
||||
import { Employees, EmployeesArchive, Users } from "@prisma/client";
|
||||
import { PrismaService } from "src/prisma/prisma.service";
|
||||
import { UpdateEmployeeDto } from "../dtos/update-employee.dto";
|
||||
import { toDateOrUndefined, toDateOrNull } from "../utils/employee.utils";
|
||||
// import { Injectable } from "@nestjs/common";
|
||||
// import { Employees, EmployeesArchive, Users } from "@prisma/client";
|
||||
// import { PrismaService } from "src/prisma/prisma.service";
|
||||
// import { UpdateEmployeeDto } from "../dtos/update-employee.dto";
|
||||
// import { toDateOrUndefined, toDateOrNull } from "../utils/employee.utils";
|
||||
|
||||
@Injectable()
|
||||
export class EmployeesArchivalService {
|
||||
constructor(private readonly prisma: PrismaService) { }
|
||||
// @Injectable()
|
||||
// export class EmployeesArchivalService {
|
||||
// constructor(private readonly prisma: PrismaService) { }
|
||||
|
||||
async patchEmployee(email: string, dto: UpdateEmployeeDto): Promise<Employees | EmployeesArchive | null> {
|
||||
// 1) Tenter sur employés actifs
|
||||
const active = await this.prisma.employees.findFirst({
|
||||
where: { user: { email } },
|
||||
include: { user: true },
|
||||
});
|
||||
// async patchEmployee(email: string, dto: UpdateEmployeeDto): Promise<Employees | EmployeesArchive | null> {
|
||||
// // 1) Tenter sur employés actifs
|
||||
// const active = await this.prisma.employees.findFirst({
|
||||
// where: { user: { email } },
|
||||
// include: { user: true },
|
||||
// });
|
||||
|
||||
if (active) {
|
||||
// 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) {
|
||||
return this.archiveOnTermination(active, dto);
|
||||
}
|
||||
// if (active) {
|
||||
// // 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) {
|
||||
// return this.archiveOnTermination(active, dto);
|
||||
// }
|
||||
|
||||
// Sinon, update standard (split Users/Employees)
|
||||
const {
|
||||
first_name,
|
||||
last_name,
|
||||
email: new_email,
|
||||
phone_number,
|
||||
residence,
|
||||
external_payroll_id,
|
||||
company_code,
|
||||
job_title,
|
||||
first_work_day,
|
||||
last_work_day,
|
||||
supervisor_id,
|
||||
is_supervisor,
|
||||
} = dto as any;
|
||||
// // Sinon, update standard (split Users/Employees)
|
||||
// const {
|
||||
// first_name,
|
||||
// last_name,
|
||||
// email: new_email,
|
||||
// phone_number,
|
||||
// residence,
|
||||
// external_payroll_id,
|
||||
// company_code,
|
||||
// job_title,
|
||||
// first_work_day,
|
||||
// last_work_day,
|
||||
// supervisor_id,
|
||||
// is_supervisor,
|
||||
// } = dto as any;
|
||||
|
||||
const first_work_d = toDateOrUndefined(first_work_day);
|
||||
const last_work_d = Object.prototype.hasOwnProperty('last_work_day')
|
||||
? toDateOrNull(last_work_day ?? null)
|
||||
: undefined;
|
||||
// const first_work_d = toDateOrUndefined(first_work_day);
|
||||
// const last_work_d = Object.prototype.hasOwnProperty('last_work_day')
|
||||
// ? toDateOrNull(last_work_day ?? null)
|
||||
// : undefined;
|
||||
|
||||
await this.prisma.$transaction(async (transaction) => {
|
||||
if (
|
||||
first_name !== undefined ||
|
||||
last_name !== undefined ||
|
||||
new_email !== undefined ||
|
||||
phone_number !== undefined ||
|
||||
residence !== undefined
|
||||
) {
|
||||
await transaction.users.update({
|
||||
where: { id: active.user_id },
|
||||
data: {
|
||||
...(first_name !== undefined ? { first_name } : {}),
|
||||
...(last_name !== undefined ? { last_name } : {}),
|
||||
...(email !== undefined ? { email: new_email } : {}),
|
||||
...(phone_number !== undefined ? { phone_number } : {}),
|
||||
...(residence !== undefined ? { residence } : {}),
|
||||
},
|
||||
});
|
||||
// await this.prisma.$transaction(async (transaction) => {
|
||||
// if (
|
||||
// first_name !== undefined ||
|
||||
// last_name !== undefined ||
|
||||
// new_email !== undefined ||
|
||||
// phone_number !== undefined ||
|
||||
// residence !== undefined
|
||||
// ) {
|
||||
// await transaction.users.update({
|
||||
// where: { id: active.user_id },
|
||||
// data: {
|
||||
// ...(first_name !== undefined ? { first_name } : {}),
|
||||
// ...(last_name !== undefined ? { last_name } : {}),
|
||||
// ...(email !== undefined ? { email: new_email } : {}),
|
||||
// ...(phone_number !== undefined ? { phone_number } : {}),
|
||||
// ...(residence !== undefined ? { residence } : {}),
|
||||
// },
|
||||
// });
|
||||
|
||||
}
|
||||
// }
|
||||
|
||||
const updated = await transaction.employees.update({
|
||||
where: { id: active.id },
|
||||
data: {
|
||||
...(external_payroll_id !== undefined ? { external_payroll_id } : {}),
|
||||
...(company_code !== undefined ? { company_code } : {}),
|
||||
...(job_title !== undefined ? { job_title } : {}),
|
||||
...(first_work_d !== undefined ? { first_work_day: first_work_d } : {}),
|
||||
...(last_work_d !== undefined ? { last_work_day: last_work_d } : {}),
|
||||
...(is_supervisor !== undefined ? { is_supervisor } : {}),
|
||||
...(supervisor_id !== undefined ? { supervisor_id } : {}),
|
||||
},
|
||||
include: { user: true },
|
||||
});
|
||||
// const updated = await transaction.employees.update({
|
||||
// where: { id: active.id },
|
||||
// data: {
|
||||
// ...(external_payroll_id !== undefined ? { external_payroll_id } : {}),
|
||||
// ...(company_code !== undefined ? { company_code } : {}),
|
||||
// ...(job_title !== undefined ? { job_title } : {}),
|
||||
// ...(first_work_d !== undefined ? { first_work_day: first_work_d } : {}),
|
||||
// ...(last_work_d !== undefined ? { last_work_day: last_work_d } : {}),
|
||||
// ...(is_supervisor !== undefined ? { is_supervisor } : {}),
|
||||
// ...(supervisor_id !== undefined ? { supervisor_id } : {}),
|
||||
// },
|
||||
// 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 } });
|
||||
if (!user) return null;
|
||||
// 2) Pas trouvé en actifs → regarder en archive (pour restauration)
|
||||
const archived = await this.prisma.employeesArchive.findFirst({
|
||||
where: { user_id: user.id },
|
||||
include: { user: true },
|
||||
});
|
||||
// const user = await this.prisma.users.findUnique({ where: { email } });
|
||||
// if (!user) return null;
|
||||
// // 2) Pas trouvé en actifs → regarder en archive (pour restauration)
|
||||
// const archived = await this.prisma.employeesArchive.findFirst({
|
||||
// where: { user_id: user.id },
|
||||
// include: { user: true },
|
||||
// });
|
||||
|
||||
if (archived) {
|
||||
// Condition de restauration : last_work_day === null ou first_work_day fourni
|
||||
const restore = dto.last_work_day === null || dto.first_work_day != null;
|
||||
if (restore) {
|
||||
return this.restoreEmployee(archived, dto);
|
||||
}
|
||||
}
|
||||
// 3) Ni actif, ni archivé → 404 dans le controller
|
||||
return null;
|
||||
}
|
||||
// if (archived) {
|
||||
// // Condition de restauration : last_work_day === null ou first_work_day fourni
|
||||
// const restore = dto.last_work_day === null || dto.first_work_day != null;
|
||||
// if (restore) {
|
||||
// return this.restoreEmployee(archived, dto);
|
||||
// }
|
||||
// }
|
||||
// // 3) Ni actif, ni archivé → 404 dans le controller
|
||||
// return null;
|
||||
// }
|
||||
|
||||
//transfers the employee to archive and then delete from employees table
|
||||
private async archiveOnTermination(active: Employees & { user: Users }, dto: UpdateEmployeeDto): Promise<EmployeesArchive> {
|
||||
const last_work_d = toDateOrNull(dto.last_work_day!);
|
||||
if (!last_work_d) throw new Error('invalide last_work_day for archive');
|
||||
return this.prisma.$transaction(async transaction => {
|
||||
//detach crew from supervisor if employee is a supervisor
|
||||
await transaction.employees.updateMany({
|
||||
where: { supervisor_id: active.id },
|
||||
data: { supervisor_id: null },
|
||||
})
|
||||
const archived = await transaction.employeesArchive.create({
|
||||
data: {
|
||||
employee_id: active.id,
|
||||
user_id: active.user_id,
|
||||
first_name: active.user.first_name,
|
||||
last_name: active.user.last_name,
|
||||
company_code: active.company_code,
|
||||
job_title: active.job_title,
|
||||
first_work_day: active.first_work_day,
|
||||
last_work_day: last_work_d,
|
||||
supervisor_id: active.supervisor_id ?? null,
|
||||
is_supervisor: active.is_supervisor,
|
||||
external_payroll_id: active.external_payroll_id,
|
||||
},
|
||||
include: { user: true }
|
||||
});
|
||||
//delete from employees table
|
||||
await transaction.employees.delete({ where: { id: active.id } });
|
||||
//return archived employee
|
||||
return archived
|
||||
});
|
||||
}
|
||||
// //transfers the employee to archive and then delete from employees table
|
||||
// private async archiveOnTermination(active: Employees & { user: Users }, dto: UpdateEmployeeDto): Promise<EmployeesArchive> {
|
||||
// const last_work_d = toDateOrNull(dto.last_work_day!);
|
||||
// if (!last_work_d) throw new Error('invalide last_work_day for archive');
|
||||
// return this.prisma.$transaction(async transaction => {
|
||||
// //detach crew from supervisor if employee is a supervisor
|
||||
// await transaction.employees.updateMany({
|
||||
// where: { supervisor_id: active.id },
|
||||
// data: { supervisor_id: null },
|
||||
// })
|
||||
// const archived = await transaction.employeesArchive.create({
|
||||
// data: {
|
||||
// employee_id: active.id,
|
||||
// user_id: active.user_id,
|
||||
// first_name: active.user.first_name,
|
||||
// last_name: active.user.last_name,
|
||||
// company_code: active.company_code,
|
||||
// job_title: active.job_title,
|
||||
// first_work_day: active.first_work_day,
|
||||
// last_work_day: last_work_d,
|
||||
// supervisor_id: active.supervisor_id ?? null,
|
||||
// is_supervisor: active.is_supervisor,
|
||||
// external_payroll_id: active.external_payroll_id,
|
||||
// },
|
||||
// include: { user: true }
|
||||
// });
|
||||
// //delete from employees table
|
||||
// await transaction.employees.delete({ where: { id: active.id } });
|
||||
// //return archived employee
|
||||
// return archived
|
||||
// });
|
||||
// }
|
||||
|
||||
//transfers the employee from archive to the employees table
|
||||
private async restoreEmployee(archived: EmployeesArchive & { user: Users }, dto: UpdateEmployeeDto): Promise<Employees> {
|
||||
// const first_work_d = toDateOrUndefined(dto.first_work_day);
|
||||
return this.prisma.$transaction(async transaction => {
|
||||
//restores the archived employee into the employees table
|
||||
const restored = await transaction.employees.create({
|
||||
data: {
|
||||
user_id: archived.user_id,
|
||||
company_code: archived.company_code,
|
||||
job_title: archived.job_title,
|
||||
first_work_day: archived.first_work_day,
|
||||
last_work_day: null,
|
||||
is_supervisor: archived.is_supervisor ?? false,
|
||||
external_payroll_id: archived.external_payroll_id,
|
||||
},
|
||||
});
|
||||
//deleting archived entry by id
|
||||
await transaction.employeesArchive.delete({ where: { id: archived.id } });
|
||||
// //transfers the employee from archive to the employees table
|
||||
// private async restoreEmployee(archived: EmployeesArchive & { user: Users }, dto: UpdateEmployeeDto): Promise<Employees> {
|
||||
// // const first_work_d = toDateOrUndefined(dto.first_work_day);
|
||||
// return this.prisma.$transaction(async transaction => {
|
||||
// //restores the archived employee into the employees table
|
||||
// const restored = await transaction.employees.create({
|
||||
// data: {
|
||||
// user_id: archived.user_id,
|
||||
// company_code: archived.company_code,
|
||||
// job_title: archived.job_title,
|
||||
// first_work_day: archived.first_work_day,
|
||||
// last_work_day: null,
|
||||
// is_supervisor: archived.is_supervisor ?? false,
|
||||
// external_payroll_id: archived.external_payroll_id,
|
||||
// },
|
||||
// });
|
||||
// //deleting archived entry by id
|
||||
// await transaction.employeesArchive.delete({ where: { id: archived.id } });
|
||||
|
||||
//return restored employee
|
||||
return restored;
|
||||
});
|
||||
}
|
||||
// //return restored employee
|
||||
// return restored;
|
||||
// });
|
||||
// }
|
||||
|
||||
//fetches all archived employees
|
||||
async findAllArchived(): Promise<EmployeesArchive[]> {
|
||||
return this.prisma.employeesArchive.findMany();
|
||||
}
|
||||
// //fetches all archived employees
|
||||
// async findAllArchived(): Promise<EmployeesArchive[]> {
|
||||
// return this.prisma.employeesArchive.findMany();
|
||||
// }
|
||||
|
||||
//fetches an archived employee
|
||||
async findOneArchived(id: number): Promise<EmployeesArchive> {
|
||||
return this.prisma.employeesArchive.findUniqueOrThrow({ where: { id } });
|
||||
}
|
||||
// //fetches an archived employee
|
||||
// async findOneArchived(id: number): Promise<EmployeesArchive> {
|
||||
// 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 { CsvExportController } from "./controllers/csv-exports.controller";
|
||||
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({
|
||||
providers:[CsvExportService, SharedModule],
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import { Module } from "@nestjs/common";
|
||||
import { PreferencesController } from "./controllers/preferences.controller";
|
||||
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({
|
||||
imports: [SharedModule],
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ import { Injectable } from "@nestjs/common";
|
|||
import { Preferences } from "@prisma/client";
|
||||
import { PrismaService } from "src/prisma/prisma.service";
|
||||
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()
|
||||
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 { ExpenseDto } from "../dtos/expense.dto";
|
||||
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')
|
||||
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 { TimesheetsModule } from "../time-tracker/timesheets/timesheets.module";
|
||||
import { SharedModule } from "../shared/shared.module";
|
||||
import { BusinessLogicsModule } from "src/time-and-attendance/domains/business-logics.module";
|
||||
import { PayPeriodsController } from "./controllers/pay-periods.controller";
|
||||
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({
|
||||
imports: [PrismaModule, TimesheetsModule, SharedModule, BusinessLogicsModule],
|
||||
imports: [PrismaModule, SharedModule, BusinessLogicsModule],
|
||||
providers: [
|
||||
PayPeriodsQueryService,
|
||||
PrismaService,
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
import { Injectable, NotFoundException } from "@nestjs/common";
|
||||
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 { EmailToIdResolver } from "./resolve-email-id.utils";
|
||||
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
import { BadRequestException, Body, Controller, Get, NotFoundException, Param, Post, Put, Query } from "@nestjs/common";
|
||||
import { SchedulePresetsDto } from "../dtos/create-schedule-presets.dto";
|
||||
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";
|
||||
|
||||
@Controller('schedule-presets')
|
||||
|
|
@ -4,7 +4,7 @@ import { SchedulePresetsQueryService } from "./services/schedule-presets-query.s
|
|||
import { SchedulePresetsController } from "./controller/schedule-presets.controller";
|
||||
import { PrismaService } from "src/prisma/prisma.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({
|
||||
imports: [SharedModule],
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
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 { ApplyResult } from "../types/schedule-presets.types";
|
||||
import { Prisma, Weekday } from "@prisma/client";
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
import { BadRequestException, ConflictException, Injectable, NotFoundException } from "@nestjs/common";
|
||||
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 { UpsertAction } from "src/Time_And_Attendance/modules/shared/types/upsert-actions.types";
|
||||
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 { UpsertAction } from "src/time-and-attendance/modules/shared/types/upsert-actions.types";
|
||||
import { PrismaService } from "src/prisma/prisma.service";
|
||||
import { SchedulePresetsDto } from "../dtos/create-schedule-presets.dto";
|
||||
import { Prisma, Weekday } from "@prisma/client";
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
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 { PresetResponse, ShiftResponse } from "../types/schedule-presets.types";
|
||||
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