From 3e2265cbacc1abcd774577640e9413443b323cfb Mon Sep 17 00:00:00 2001 From: Matthieu Haineault Date: Thu, 23 Oct 2025 14:23:53 -0400 Subject: [PATCH 1/5] BREAKING CHANGE(Time&Attendance): prep to split into APIs. setup structure for timesheet related modules --- .../domains}/business-logics.module.ts | 0 .../domains}/services/after-hours.service.ts | 0 .../domains}/services/holiday.service.ts | 0 .../domains}/services/mileage.service.ts | 0 .../domains}/services/overtime.service.ts | 0 .../domains}/services/sick-leave.service.ts | 0 .../domains}/services/vacation.service.ts | 0 .../controllers/leave-requests.controller.ts | 0 .../dtos/leave-request-view.dto.ts | 0 .../dtos/upsert-leave-request.dto.ts | 0 .../leave-requests/leave-requests.module.ts | 0 .../mappers/leave-requests-archive.mapper.ts | 0 .../mappers/leave-requests.mapper.ts | 0 .../holiday-leave-requests.service.ts | 0 .../services/leave-request.service.ts | 0 .../services/sick-leave-requests.service.ts | 0 .../vacation-leave-requests.service.ts | 0 .../utils/leave-request.transform.ts | 0 .../utils/leave-request.util.ts | 0 .../utils/leave-requests-archive.select.ts | 0 .../utils/leave-requests.select.ts | 0 .../controllers/pay-periods.controller.ts | 0 .../dtos/bulk-crew-approval.dto.ts | 0 .../pay-period}/dtos/bundle-pay-period.dto.ts | 0 .../dtos/overview-employee-period.dto.ts | 0 .../dtos/overview-pay-period.dto.ts | 0 .../pay-period}/dtos/pay-period.dto.ts | 0 .../pay-period}/mappers/pay-periods.mapper.ts | 0 .../modules/pay-period}/pay-periods.module.ts | 4 ++-- .../services/pay-periods-command.service.ts | 0 .../services/pay-periods-query.service.ts | 0 .../pay-period}/utils/pay-year.util.ts | 0 .../shared/constants/date-time.constant.ts | 0 .../shared/constants/regex.constant.ts | 0 .../shared/constants/utils.constant.ts | 0 .../shared/helpers/date-time.helpers.ts | 0 .../shared/interfaces/shifts.interface.ts | 0 .../modules/shared/selects/expenses.select.ts | 0 .../shared/selects/pay-periods.select.ts | 0 .../modules/shared/selects/shifts.select.ts | 0 .../modules/shared/shared.module.ts | 0 .../shared/types/upsert-actions.types.ts | 0 .../utils/resolve-bank-type-id.utils.ts | 0 .../shared/utils/resolve-email-id.utils.ts | 0 .../shared/utils/resolve-full-name.utils.ts | 0 .../shared/utils/resolve-shifts-id.utils.ts | 0 .../shared/utils/resolve-timesheet.utils.ts | 2 +- .../controller/schedule-presets.controller.ts | 2 +- .../dtos/create-schedule-preset-shifts.dto.ts | 0 .../dtos/create-schedule-presets.dto.ts | 0 .../mappers/schedule-presets.mappers.ts | 0 .../schedule-presets.module.ts | 0 .../schedule-presets-apply.service.ts | 2 +- .../schedule-presets-command.service.ts | 6 ++--- .../schedule-presets-query.service.ts | 2 +- .../types/schedule-presets.types.ts | 0 .../shifts/controllers/shift.controller.ts | 0 .../shifts/dtos/get-shift.dto.ts | 0 .../time-tracker}/shifts/dtos/shift.dto.ts | 0 .../shifts/dtos/update-shift.dto.ts | 0 .../helpers/shifts-date-time-helpers.ts | 0 .../services/shifts-archival.service.ts | 0 .../shifts/services/shifts-get.service.ts | 0 .../shifts/services/shifts-upsert.service.ts | 0 .../time-tracker}/shifts/shifts.module.ts | 4 ++-- .../get-shift-overview.dto.ts | 0 .../shifts-command.service.ts | 0 .../shifts-overview-row.interface.ts | 0 .../shifts-query.service.ts | 0 .../shifts-upsert.types.ts | 0 .../shifts.controller.ts | 0 .../~misc_deprecated-files/shifts.helpers.ts | 0 .../~misc_deprecated-files/shifts.utils.ts | 0 .../upsert-shift.dto.ts | 0 .../controllers/timesheet.controller.ts | 2 +- .../timesheets/dtos/timesheet.dto.ts | 0 .../helpers/timesheets-date-time-helpers.ts | 0 .../services/timesheet-approval.service.ts | 0 .../services/timesheet-archive.service.ts | 0 .../timesheet-get-overview.service.ts | 0 .../timesheets/timesheets.module.ts | 23 +++++++++++++++++++ .../create-timesheet.dto.ts | 0 .../search-timesheet.dto.ts | 0 .../timesheet-period.dto.ts | 0 .../timesheet.helpers.ts | 0 .../timesheet.mappers.ts | 0 .../timesheet.selectors.ts | 0 .../~misc_deprecated-files/timesheet.types.ts | 0 .../~misc_deprecated-files/timesheet.utils.ts | 0 .../timesheets-command.service.ts | 0 .../timesheets-query.service.ts | 0 .../timesheets.controller.ts | 0 src/app.module.ts | 6 ++--- .../controllers/shifts-archive.controller.ts | 2 +- .../timesheets-archive.controller.ts | 2 +- .../archival/services/archival.service.ts | 4 ++-- src/modules/employees/employees.module.ts | 2 +- src/modules/exports/csv-exports.module.ts | 2 +- src/modules/preferences/preferences.module.ts | 2 +- .../services/preferences.service.ts | 2 +- src/modules/timesheets/timesheets.module.ts | 10 ++++---- 101 files changed, 51 insertions(+), 28 deletions(-) rename src/{modules/business-logics => Time_And_Attendance/domains}/business-logics.module.ts (100%) rename src/{modules/business-logics => Time_And_Attendance/domains}/services/after-hours.service.ts (100%) rename src/{modules/business-logics => Time_And_Attendance/domains}/services/holiday.service.ts (100%) rename src/{modules/business-logics => Time_And_Attendance/domains}/services/mileage.service.ts (100%) rename src/{modules/business-logics => Time_And_Attendance/domains}/services/overtime.service.ts (100%) rename src/{modules/business-logics => Time_And_Attendance/domains}/services/sick-leave.service.ts (100%) rename src/{modules/business-logics => Time_And_Attendance/domains}/services/vacation.service.ts (100%) rename src/{ => Time_And_Attendance}/modules/leave-requests/controllers/leave-requests.controller.ts (100%) rename src/{ => Time_And_Attendance}/modules/leave-requests/dtos/leave-request-view.dto.ts (100%) rename src/{ => Time_And_Attendance}/modules/leave-requests/dtos/upsert-leave-request.dto.ts (100%) rename src/{ => Time_And_Attendance}/modules/leave-requests/leave-requests.module.ts (100%) rename src/{ => Time_And_Attendance}/modules/leave-requests/mappers/leave-requests-archive.mapper.ts (100%) rename src/{ => Time_And_Attendance}/modules/leave-requests/mappers/leave-requests.mapper.ts (100%) rename src/{ => Time_And_Attendance}/modules/leave-requests/services/holiday-leave-requests.service.ts (100%) rename src/{ => Time_And_Attendance}/modules/leave-requests/services/leave-request.service.ts (100%) rename src/{ => Time_And_Attendance}/modules/leave-requests/services/sick-leave-requests.service.ts (100%) rename src/{ => Time_And_Attendance}/modules/leave-requests/services/vacation-leave-requests.service.ts (100%) rename src/{ => Time_And_Attendance}/modules/leave-requests/utils/leave-request.transform.ts (100%) rename src/{ => Time_And_Attendance}/modules/leave-requests/utils/leave-request.util.ts (100%) rename src/{ => Time_And_Attendance}/modules/leave-requests/utils/leave-requests-archive.select.ts (100%) rename src/{ => Time_And_Attendance}/modules/leave-requests/utils/leave-requests.select.ts (100%) rename src/{modules/pay-periods => Time_And_Attendance/modules/pay-period}/controllers/pay-periods.controller.ts (100%) rename src/{modules/pay-periods => Time_And_Attendance/modules/pay-period}/dtos/bulk-crew-approval.dto.ts (100%) rename src/{modules/pay-periods => Time_And_Attendance/modules/pay-period}/dtos/bundle-pay-period.dto.ts (100%) rename src/{modules/pay-periods => Time_And_Attendance/modules/pay-period}/dtos/overview-employee-period.dto.ts (100%) rename src/{modules/pay-periods => Time_And_Attendance/modules/pay-period}/dtos/overview-pay-period.dto.ts (100%) rename src/{modules/pay-periods => Time_And_Attendance/modules/pay-period}/dtos/pay-period.dto.ts (100%) rename src/{modules/pay-periods => Time_And_Attendance/modules/pay-period}/mappers/pay-periods.mapper.ts (100%) rename src/{modules/pay-periods => Time_And_Attendance/modules/pay-period}/pay-periods.module.ts (78%) rename src/{modules/pay-periods => Time_And_Attendance/modules/pay-period}/services/pay-periods-command.service.ts (100%) rename src/{modules/pay-periods => Time_And_Attendance/modules/pay-period}/services/pay-periods-query.service.ts (100%) rename src/{modules/pay-periods => Time_And_Attendance/modules/pay-period}/utils/pay-year.util.ts (100%) rename src/{ => Time_And_Attendance}/modules/shared/constants/date-time.constant.ts (100%) rename src/{ => Time_And_Attendance}/modules/shared/constants/regex.constant.ts (100%) rename src/{ => Time_And_Attendance}/modules/shared/constants/utils.constant.ts (100%) rename src/{ => Time_And_Attendance}/modules/shared/helpers/date-time.helpers.ts (100%) rename src/{ => Time_And_Attendance}/modules/shared/interfaces/shifts.interface.ts (100%) rename src/{ => Time_And_Attendance}/modules/shared/selects/expenses.select.ts (100%) rename src/{ => Time_And_Attendance}/modules/shared/selects/pay-periods.select.ts (100%) rename src/{ => Time_And_Attendance}/modules/shared/selects/shifts.select.ts (100%) rename src/{ => Time_And_Attendance}/modules/shared/shared.module.ts (100%) rename src/{ => Time_And_Attendance}/modules/shared/types/upsert-actions.types.ts (100%) rename src/{ => Time_And_Attendance}/modules/shared/utils/resolve-bank-type-id.utils.ts (100%) rename src/{ => Time_And_Attendance}/modules/shared/utils/resolve-email-id.utils.ts (100%) rename src/{ => Time_And_Attendance}/modules/shared/utils/resolve-full-name.utils.ts (100%) rename src/{ => Time_And_Attendance}/modules/shared/utils/resolve-shifts-id.utils.ts (100%) rename src/{ => Time_And_Attendance}/modules/shared/utils/resolve-timesheet.utils.ts (89%) rename src/{modules => Time_And_Attendance/modules/time-tracker}/schedule-presets/controller/schedule-presets.controller.ts (94%) rename src/{modules => Time_And_Attendance/modules/time-tracker}/schedule-presets/dtos/create-schedule-preset-shifts.dto.ts (100%) rename src/{modules => Time_And_Attendance/modules/time-tracker}/schedule-presets/dtos/create-schedule-presets.dto.ts (100%) rename src/{modules => Time_And_Attendance/modules/time-tracker}/schedule-presets/mappers/schedule-presets.mappers.ts (100%) rename src/{modules => Time_And_Attendance/modules/time-tracker}/schedule-presets/schedule-presets.module.ts (100%) rename src/{modules => Time_And_Attendance/modules/time-tracker}/schedule-presets/services/schedule-presets-apply.service.ts (98%) rename src/{modules => Time_And_Attendance/modules/time-tracker}/schedule-presets/services/schedule-presets-command.service.ts (96%) rename src/{modules => Time_And_Attendance/modules/time-tracker}/schedule-presets/services/schedule-presets-query.service.ts (95%) rename src/{modules => Time_And_Attendance/modules/time-tracker}/schedule-presets/types/schedule-presets.types.ts (100%) rename src/{modules => Time_And_Attendance/modules/time-tracker}/shifts/controllers/shift.controller.ts (100%) rename src/{modules => Time_And_Attendance/modules/time-tracker}/shifts/dtos/get-shift.dto.ts (100%) rename src/{modules => Time_And_Attendance/modules/time-tracker}/shifts/dtos/shift.dto.ts (100%) rename src/{modules => Time_And_Attendance/modules/time-tracker}/shifts/dtos/update-shift.dto.ts (100%) rename src/{modules => Time_And_Attendance/modules/time-tracker}/shifts/helpers/shifts-date-time-helpers.ts (100%) rename src/{modules => Time_And_Attendance/modules/time-tracker}/shifts/services/shifts-archival.service.ts (100%) rename src/{modules => Time_And_Attendance/modules/time-tracker}/shifts/services/shifts-get.service.ts (100%) rename src/{modules => Time_And_Attendance/modules/time-tracker}/shifts/services/shifts-upsert.service.ts (100%) rename src/{modules => Time_And_Attendance/modules/time-tracker}/shifts/shifts.module.ts (82%) rename src/{modules => Time_And_Attendance/modules/time-tracker}/shifts/~misc_deprecated-files/get-shift-overview.dto.ts (100%) rename src/{modules => Time_And_Attendance/modules/time-tracker}/shifts/~misc_deprecated-files/shifts-command.service.ts (100%) rename src/{modules => Time_And_Attendance/modules/time-tracker}/shifts/~misc_deprecated-files/shifts-overview-row.interface.ts (100%) rename src/{modules => Time_And_Attendance/modules/time-tracker}/shifts/~misc_deprecated-files/shifts-query.service.ts (100%) rename src/{modules => Time_And_Attendance/modules/time-tracker}/shifts/~misc_deprecated-files/shifts-upsert.types.ts (100%) rename src/{modules => Time_And_Attendance/modules/time-tracker}/shifts/~misc_deprecated-files/shifts.controller.ts (100%) rename src/{modules => Time_And_Attendance/modules/time-tracker}/shifts/~misc_deprecated-files/shifts.helpers.ts (100%) rename src/{modules => Time_And_Attendance/modules/time-tracker}/shifts/~misc_deprecated-files/shifts.utils.ts (100%) rename src/{modules => Time_And_Attendance/modules/time-tracker}/shifts/~misc_deprecated-files/upsert-shift.dto.ts (100%) rename src/{modules => Time_And_Attendance/modules/time-tracker}/timesheets/controllers/timesheet.controller.ts (91%) rename src/{modules => Time_And_Attendance/modules/time-tracker}/timesheets/dtos/timesheet.dto.ts (100%) rename src/{modules => Time_And_Attendance/modules/time-tracker}/timesheets/helpers/timesheets-date-time-helpers.ts (100%) rename src/{modules => Time_And_Attendance/modules/time-tracker}/timesheets/services/timesheet-approval.service.ts (100%) rename src/{modules => Time_And_Attendance/modules/time-tracker}/timesheets/services/timesheet-archive.service.ts (100%) rename src/{modules => Time_And_Attendance/modules/time-tracker}/timesheets/services/timesheet-get-overview.service.ts (100%) create mode 100644 src/Time_And_Attendance/modules/time-tracker/timesheets/timesheets.module.ts rename src/{modules => Time_And_Attendance/modules/time-tracker}/timesheets/~misc_deprecated-files/create-timesheet.dto.ts (100%) rename src/{modules => Time_And_Attendance/modules/time-tracker}/timesheets/~misc_deprecated-files/search-timesheet.dto.ts (100%) rename src/{modules => Time_And_Attendance/modules/time-tracker}/timesheets/~misc_deprecated-files/timesheet-period.dto.ts (100%) rename src/{modules => Time_And_Attendance/modules/time-tracker}/timesheets/~misc_deprecated-files/timesheet.helpers.ts (100%) rename src/{modules => Time_And_Attendance/modules/time-tracker}/timesheets/~misc_deprecated-files/timesheet.mappers.ts (100%) rename src/{modules => Time_And_Attendance/modules/time-tracker}/timesheets/~misc_deprecated-files/timesheet.selectors.ts (100%) rename src/{modules => Time_And_Attendance/modules/time-tracker}/timesheets/~misc_deprecated-files/timesheet.types.ts (100%) rename src/{modules => Time_And_Attendance/modules/time-tracker}/timesheets/~misc_deprecated-files/timesheet.utils.ts (100%) rename src/{modules => Time_And_Attendance/modules/time-tracker}/timesheets/~misc_deprecated-files/timesheets-command.service.ts (100%) rename src/{modules => Time_And_Attendance/modules/time-tracker}/timesheets/~misc_deprecated-files/timesheets-query.service.ts (100%) rename src/{modules => Time_And_Attendance/modules/time-tracker}/timesheets/~misc_deprecated-files/timesheets.controller.ts (100%) diff --git a/src/modules/business-logics/business-logics.module.ts b/src/Time_And_Attendance/domains/business-logics.module.ts similarity index 100% rename from src/modules/business-logics/business-logics.module.ts rename to src/Time_And_Attendance/domains/business-logics.module.ts diff --git a/src/modules/business-logics/services/after-hours.service.ts b/src/Time_And_Attendance/domains/services/after-hours.service.ts similarity index 100% rename from src/modules/business-logics/services/after-hours.service.ts rename to src/Time_And_Attendance/domains/services/after-hours.service.ts diff --git a/src/modules/business-logics/services/holiday.service.ts b/src/Time_And_Attendance/domains/services/holiday.service.ts similarity index 100% rename from src/modules/business-logics/services/holiday.service.ts rename to src/Time_And_Attendance/domains/services/holiday.service.ts diff --git a/src/modules/business-logics/services/mileage.service.ts b/src/Time_And_Attendance/domains/services/mileage.service.ts similarity index 100% rename from src/modules/business-logics/services/mileage.service.ts rename to src/Time_And_Attendance/domains/services/mileage.service.ts diff --git a/src/modules/business-logics/services/overtime.service.ts b/src/Time_And_Attendance/domains/services/overtime.service.ts similarity index 100% rename from src/modules/business-logics/services/overtime.service.ts rename to src/Time_And_Attendance/domains/services/overtime.service.ts diff --git a/src/modules/business-logics/services/sick-leave.service.ts b/src/Time_And_Attendance/domains/services/sick-leave.service.ts similarity index 100% rename from src/modules/business-logics/services/sick-leave.service.ts rename to src/Time_And_Attendance/domains/services/sick-leave.service.ts diff --git a/src/modules/business-logics/services/vacation.service.ts b/src/Time_And_Attendance/domains/services/vacation.service.ts similarity index 100% rename from src/modules/business-logics/services/vacation.service.ts rename to src/Time_And_Attendance/domains/services/vacation.service.ts diff --git a/src/modules/leave-requests/controllers/leave-requests.controller.ts b/src/Time_And_Attendance/modules/leave-requests/controllers/leave-requests.controller.ts similarity index 100% rename from src/modules/leave-requests/controllers/leave-requests.controller.ts rename to src/Time_And_Attendance/modules/leave-requests/controllers/leave-requests.controller.ts diff --git a/src/modules/leave-requests/dtos/leave-request-view.dto.ts b/src/Time_And_Attendance/modules/leave-requests/dtos/leave-request-view.dto.ts similarity index 100% rename from src/modules/leave-requests/dtos/leave-request-view.dto.ts rename to src/Time_And_Attendance/modules/leave-requests/dtos/leave-request-view.dto.ts diff --git a/src/modules/leave-requests/dtos/upsert-leave-request.dto.ts b/src/Time_And_Attendance/modules/leave-requests/dtos/upsert-leave-request.dto.ts similarity index 100% rename from src/modules/leave-requests/dtos/upsert-leave-request.dto.ts rename to src/Time_And_Attendance/modules/leave-requests/dtos/upsert-leave-request.dto.ts diff --git a/src/modules/leave-requests/leave-requests.module.ts b/src/Time_And_Attendance/modules/leave-requests/leave-requests.module.ts similarity index 100% rename from src/modules/leave-requests/leave-requests.module.ts rename to src/Time_And_Attendance/modules/leave-requests/leave-requests.module.ts diff --git a/src/modules/leave-requests/mappers/leave-requests-archive.mapper.ts b/src/Time_And_Attendance/modules/leave-requests/mappers/leave-requests-archive.mapper.ts similarity index 100% rename from src/modules/leave-requests/mappers/leave-requests-archive.mapper.ts rename to src/Time_And_Attendance/modules/leave-requests/mappers/leave-requests-archive.mapper.ts diff --git a/src/modules/leave-requests/mappers/leave-requests.mapper.ts b/src/Time_And_Attendance/modules/leave-requests/mappers/leave-requests.mapper.ts similarity index 100% rename from src/modules/leave-requests/mappers/leave-requests.mapper.ts rename to src/Time_And_Attendance/modules/leave-requests/mappers/leave-requests.mapper.ts diff --git a/src/modules/leave-requests/services/holiday-leave-requests.service.ts b/src/Time_And_Attendance/modules/leave-requests/services/holiday-leave-requests.service.ts similarity index 100% rename from src/modules/leave-requests/services/holiday-leave-requests.service.ts rename to src/Time_And_Attendance/modules/leave-requests/services/holiday-leave-requests.service.ts diff --git a/src/modules/leave-requests/services/leave-request.service.ts b/src/Time_And_Attendance/modules/leave-requests/services/leave-request.service.ts similarity index 100% rename from src/modules/leave-requests/services/leave-request.service.ts rename to src/Time_And_Attendance/modules/leave-requests/services/leave-request.service.ts diff --git a/src/modules/leave-requests/services/sick-leave-requests.service.ts b/src/Time_And_Attendance/modules/leave-requests/services/sick-leave-requests.service.ts similarity index 100% rename from src/modules/leave-requests/services/sick-leave-requests.service.ts rename to src/Time_And_Attendance/modules/leave-requests/services/sick-leave-requests.service.ts diff --git a/src/modules/leave-requests/services/vacation-leave-requests.service.ts b/src/Time_And_Attendance/modules/leave-requests/services/vacation-leave-requests.service.ts similarity index 100% rename from src/modules/leave-requests/services/vacation-leave-requests.service.ts rename to src/Time_And_Attendance/modules/leave-requests/services/vacation-leave-requests.service.ts diff --git a/src/modules/leave-requests/utils/leave-request.transform.ts b/src/Time_And_Attendance/modules/leave-requests/utils/leave-request.transform.ts similarity index 100% rename from src/modules/leave-requests/utils/leave-request.transform.ts rename to src/Time_And_Attendance/modules/leave-requests/utils/leave-request.transform.ts diff --git a/src/modules/leave-requests/utils/leave-request.util.ts b/src/Time_And_Attendance/modules/leave-requests/utils/leave-request.util.ts similarity index 100% rename from src/modules/leave-requests/utils/leave-request.util.ts rename to src/Time_And_Attendance/modules/leave-requests/utils/leave-request.util.ts diff --git a/src/modules/leave-requests/utils/leave-requests-archive.select.ts b/src/Time_And_Attendance/modules/leave-requests/utils/leave-requests-archive.select.ts similarity index 100% rename from src/modules/leave-requests/utils/leave-requests-archive.select.ts rename to src/Time_And_Attendance/modules/leave-requests/utils/leave-requests-archive.select.ts diff --git a/src/modules/leave-requests/utils/leave-requests.select.ts b/src/Time_And_Attendance/modules/leave-requests/utils/leave-requests.select.ts similarity index 100% rename from src/modules/leave-requests/utils/leave-requests.select.ts rename to src/Time_And_Attendance/modules/leave-requests/utils/leave-requests.select.ts diff --git a/src/modules/pay-periods/controllers/pay-periods.controller.ts b/src/Time_And_Attendance/modules/pay-period/controllers/pay-periods.controller.ts similarity index 100% rename from src/modules/pay-periods/controllers/pay-periods.controller.ts rename to src/Time_And_Attendance/modules/pay-period/controllers/pay-periods.controller.ts diff --git a/src/modules/pay-periods/dtos/bulk-crew-approval.dto.ts b/src/Time_And_Attendance/modules/pay-period/dtos/bulk-crew-approval.dto.ts similarity index 100% rename from src/modules/pay-periods/dtos/bulk-crew-approval.dto.ts rename to src/Time_And_Attendance/modules/pay-period/dtos/bulk-crew-approval.dto.ts diff --git a/src/modules/pay-periods/dtos/bundle-pay-period.dto.ts b/src/Time_And_Attendance/modules/pay-period/dtos/bundle-pay-period.dto.ts similarity index 100% rename from src/modules/pay-periods/dtos/bundle-pay-period.dto.ts rename to src/Time_And_Attendance/modules/pay-period/dtos/bundle-pay-period.dto.ts diff --git a/src/modules/pay-periods/dtos/overview-employee-period.dto.ts b/src/Time_And_Attendance/modules/pay-period/dtos/overview-employee-period.dto.ts similarity index 100% rename from src/modules/pay-periods/dtos/overview-employee-period.dto.ts rename to src/Time_And_Attendance/modules/pay-period/dtos/overview-employee-period.dto.ts diff --git a/src/modules/pay-periods/dtos/overview-pay-period.dto.ts b/src/Time_And_Attendance/modules/pay-period/dtos/overview-pay-period.dto.ts similarity index 100% rename from src/modules/pay-periods/dtos/overview-pay-period.dto.ts rename to src/Time_And_Attendance/modules/pay-period/dtos/overview-pay-period.dto.ts diff --git a/src/modules/pay-periods/dtos/pay-period.dto.ts b/src/Time_And_Attendance/modules/pay-period/dtos/pay-period.dto.ts similarity index 100% rename from src/modules/pay-periods/dtos/pay-period.dto.ts rename to src/Time_And_Attendance/modules/pay-period/dtos/pay-period.dto.ts diff --git a/src/modules/pay-periods/mappers/pay-periods.mapper.ts b/src/Time_And_Attendance/modules/pay-period/mappers/pay-periods.mapper.ts similarity index 100% rename from src/modules/pay-periods/mappers/pay-periods.mapper.ts rename to src/Time_And_Attendance/modules/pay-period/mappers/pay-periods.mapper.ts diff --git a/src/modules/pay-periods/pay-periods.module.ts b/src/Time_And_Attendance/modules/pay-period/pay-periods.module.ts similarity index 78% rename from src/modules/pay-periods/pay-periods.module.ts rename to src/Time_And_Attendance/modules/pay-period/pay-periods.module.ts index c614179..fabd257 100644 --- a/src/modules/pay-periods/pay-periods.module.ts +++ b/src/Time_And_Attendance/modules/pay-period/pay-periods.module.ts @@ -2,10 +2,10 @@ 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 "../timesheets/timesheets.module"; +import { TimesheetsModule } from "../time-tracker/timesheets/timesheets.module"; import { SharedModule } from "../shared/shared.module"; import { PrismaService } from "src/prisma/prisma.service"; -import { BusinessLogicsModule } from "../business-logics/business-logics.module"; +import { BusinessLogicsModule } from "../../../modules/business-logics/business-logics.module"; @Module({ imports: [PrismaModule, TimesheetsModule, SharedModule, BusinessLogicsModule], diff --git a/src/modules/pay-periods/services/pay-periods-command.service.ts b/src/Time_And_Attendance/modules/pay-period/services/pay-periods-command.service.ts similarity index 100% rename from src/modules/pay-periods/services/pay-periods-command.service.ts rename to src/Time_And_Attendance/modules/pay-period/services/pay-periods-command.service.ts diff --git a/src/modules/pay-periods/services/pay-periods-query.service.ts b/src/Time_And_Attendance/modules/pay-period/services/pay-periods-query.service.ts similarity index 100% rename from src/modules/pay-periods/services/pay-periods-query.service.ts rename to src/Time_And_Attendance/modules/pay-period/services/pay-periods-query.service.ts diff --git a/src/modules/pay-periods/utils/pay-year.util.ts b/src/Time_And_Attendance/modules/pay-period/utils/pay-year.util.ts similarity index 100% rename from src/modules/pay-periods/utils/pay-year.util.ts rename to src/Time_And_Attendance/modules/pay-period/utils/pay-year.util.ts diff --git a/src/modules/shared/constants/date-time.constant.ts b/src/Time_And_Attendance/modules/shared/constants/date-time.constant.ts similarity index 100% rename from src/modules/shared/constants/date-time.constant.ts rename to src/Time_And_Attendance/modules/shared/constants/date-time.constant.ts diff --git a/src/modules/shared/constants/regex.constant.ts b/src/Time_And_Attendance/modules/shared/constants/regex.constant.ts similarity index 100% rename from src/modules/shared/constants/regex.constant.ts rename to src/Time_And_Attendance/modules/shared/constants/regex.constant.ts diff --git a/src/modules/shared/constants/utils.constant.ts b/src/Time_And_Attendance/modules/shared/constants/utils.constant.ts similarity index 100% rename from src/modules/shared/constants/utils.constant.ts rename to src/Time_And_Attendance/modules/shared/constants/utils.constant.ts diff --git a/src/modules/shared/helpers/date-time.helpers.ts b/src/Time_And_Attendance/modules/shared/helpers/date-time.helpers.ts similarity index 100% rename from src/modules/shared/helpers/date-time.helpers.ts rename to src/Time_And_Attendance/modules/shared/helpers/date-time.helpers.ts diff --git a/src/modules/shared/interfaces/shifts.interface.ts b/src/Time_And_Attendance/modules/shared/interfaces/shifts.interface.ts similarity index 100% rename from src/modules/shared/interfaces/shifts.interface.ts rename to src/Time_And_Attendance/modules/shared/interfaces/shifts.interface.ts diff --git a/src/modules/shared/selects/expenses.select.ts b/src/Time_And_Attendance/modules/shared/selects/expenses.select.ts similarity index 100% rename from src/modules/shared/selects/expenses.select.ts rename to src/Time_And_Attendance/modules/shared/selects/expenses.select.ts diff --git a/src/modules/shared/selects/pay-periods.select.ts b/src/Time_And_Attendance/modules/shared/selects/pay-periods.select.ts similarity index 100% rename from src/modules/shared/selects/pay-periods.select.ts rename to src/Time_And_Attendance/modules/shared/selects/pay-periods.select.ts diff --git a/src/modules/shared/selects/shifts.select.ts b/src/Time_And_Attendance/modules/shared/selects/shifts.select.ts similarity index 100% rename from src/modules/shared/selects/shifts.select.ts rename to src/Time_And_Attendance/modules/shared/selects/shifts.select.ts diff --git a/src/modules/shared/shared.module.ts b/src/Time_And_Attendance/modules/shared/shared.module.ts similarity index 100% rename from src/modules/shared/shared.module.ts rename to src/Time_And_Attendance/modules/shared/shared.module.ts diff --git a/src/modules/shared/types/upsert-actions.types.ts b/src/Time_And_Attendance/modules/shared/types/upsert-actions.types.ts similarity index 100% rename from src/modules/shared/types/upsert-actions.types.ts rename to src/Time_And_Attendance/modules/shared/types/upsert-actions.types.ts diff --git a/src/modules/shared/utils/resolve-bank-type-id.utils.ts b/src/Time_And_Attendance/modules/shared/utils/resolve-bank-type-id.utils.ts similarity index 100% rename from src/modules/shared/utils/resolve-bank-type-id.utils.ts rename to src/Time_And_Attendance/modules/shared/utils/resolve-bank-type-id.utils.ts diff --git a/src/modules/shared/utils/resolve-email-id.utils.ts b/src/Time_And_Attendance/modules/shared/utils/resolve-email-id.utils.ts similarity index 100% rename from src/modules/shared/utils/resolve-email-id.utils.ts rename to src/Time_And_Attendance/modules/shared/utils/resolve-email-id.utils.ts diff --git a/src/modules/shared/utils/resolve-full-name.utils.ts b/src/Time_And_Attendance/modules/shared/utils/resolve-full-name.utils.ts similarity index 100% rename from src/modules/shared/utils/resolve-full-name.utils.ts rename to src/Time_And_Attendance/modules/shared/utils/resolve-full-name.utils.ts diff --git a/src/modules/shared/utils/resolve-shifts-id.utils.ts b/src/Time_And_Attendance/modules/shared/utils/resolve-shifts-id.utils.ts similarity index 100% rename from src/modules/shared/utils/resolve-shifts-id.utils.ts rename to src/Time_And_Attendance/modules/shared/utils/resolve-shifts-id.utils.ts diff --git a/src/modules/shared/utils/resolve-timesheet.utils.ts b/src/Time_And_Attendance/modules/shared/utils/resolve-timesheet.utils.ts similarity index 89% rename from src/modules/shared/utils/resolve-timesheet.utils.ts rename to src/Time_And_Attendance/modules/shared/utils/resolve-timesheet.utils.ts index 61f4ce6..2c5e515 100644 --- a/src/modules/shared/utils/resolve-timesheet.utils.ts +++ b/src/Time_And_Attendance/modules/shared/utils/resolve-timesheet.utils.ts @@ -1,6 +1,6 @@ import { Injectable, NotFoundException } from "@nestjs/common"; import { Prisma, PrismaClient } from "@prisma/client"; -import { weekStartSunday } from "src/modules/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"; diff --git a/src/modules/schedule-presets/controller/schedule-presets.controller.ts b/src/Time_And_Attendance/modules/time-tracker/schedule-presets/controller/schedule-presets.controller.ts similarity index 94% rename from src/modules/schedule-presets/controller/schedule-presets.controller.ts rename to src/Time_And_Attendance/modules/time-tracker/schedule-presets/controller/schedule-presets.controller.ts index b031c67..0efb934 100644 --- a/src/modules/schedule-presets/controller/schedule-presets.controller.ts +++ b/src/Time_And_Attendance/modules/time-tracker/schedule-presets/controller/schedule-presets.controller.ts @@ -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/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') diff --git a/src/modules/schedule-presets/dtos/create-schedule-preset-shifts.dto.ts b/src/Time_And_Attendance/modules/time-tracker/schedule-presets/dtos/create-schedule-preset-shifts.dto.ts similarity index 100% rename from src/modules/schedule-presets/dtos/create-schedule-preset-shifts.dto.ts rename to src/Time_And_Attendance/modules/time-tracker/schedule-presets/dtos/create-schedule-preset-shifts.dto.ts diff --git a/src/modules/schedule-presets/dtos/create-schedule-presets.dto.ts b/src/Time_And_Attendance/modules/time-tracker/schedule-presets/dtos/create-schedule-presets.dto.ts similarity index 100% rename from src/modules/schedule-presets/dtos/create-schedule-presets.dto.ts rename to src/Time_And_Attendance/modules/time-tracker/schedule-presets/dtos/create-schedule-presets.dto.ts diff --git a/src/modules/schedule-presets/mappers/schedule-presets.mappers.ts b/src/Time_And_Attendance/modules/time-tracker/schedule-presets/mappers/schedule-presets.mappers.ts similarity index 100% rename from src/modules/schedule-presets/mappers/schedule-presets.mappers.ts rename to src/Time_And_Attendance/modules/time-tracker/schedule-presets/mappers/schedule-presets.mappers.ts diff --git a/src/modules/schedule-presets/schedule-presets.module.ts b/src/Time_And_Attendance/modules/time-tracker/schedule-presets/schedule-presets.module.ts similarity index 100% rename from src/modules/schedule-presets/schedule-presets.module.ts rename to src/Time_And_Attendance/modules/time-tracker/schedule-presets/schedule-presets.module.ts diff --git a/src/modules/schedule-presets/services/schedule-presets-apply.service.ts b/src/Time_And_Attendance/modules/time-tracker/schedule-presets/services/schedule-presets-apply.service.ts similarity index 98% rename from src/modules/schedule-presets/services/schedule-presets-apply.service.ts rename to src/Time_And_Attendance/modules/time-tracker/schedule-presets/services/schedule-presets-apply.service.ts index fa2bce1..e2e8dbf 100644 --- a/src/modules/schedule-presets/services/schedule-presets-apply.service.ts +++ b/src/Time_And_Attendance/modules/time-tracker/schedule-presets/services/schedule-presets-apply.service.ts @@ -1,5 +1,5 @@ import { BadRequestException, ConflictException, Injectable, NotFoundException } from "@nestjs/common"; -import { EmailToIdResolver } from "src/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"; diff --git a/src/modules/schedule-presets/services/schedule-presets-command.service.ts b/src/Time_And_Attendance/modules/time-tracker/schedule-presets/services/schedule-presets-command.service.ts similarity index 96% rename from src/modules/schedule-presets/services/schedule-presets-command.service.ts rename to src/Time_And_Attendance/modules/time-tracker/schedule-presets/services/schedule-presets-command.service.ts index 0c2a8bb..5c1cb2c 100644 --- a/src/modules/schedule-presets/services/schedule-presets-command.service.ts +++ b/src/Time_And_Attendance/modules/time-tracker/schedule-presets/services/schedule-presets-command.service.ts @@ -1,7 +1,7 @@ import { BadRequestException, ConflictException, Injectable, NotFoundException } from "@nestjs/common"; -import { BankCodesResolver } from "src/modules/shared/utils/resolve-bank-type-id.utils"; -import { EmailToIdResolver } from "src/modules/shared/utils/resolve-email-id.utils"; -import { UpsertAction } from "src/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"; diff --git a/src/modules/schedule-presets/services/schedule-presets-query.service.ts b/src/Time_And_Attendance/modules/time-tracker/schedule-presets/services/schedule-presets-query.service.ts similarity index 95% rename from src/modules/schedule-presets/services/schedule-presets-query.service.ts rename to src/Time_And_Attendance/modules/time-tracker/schedule-presets/services/schedule-presets-query.service.ts index 7ccb0f0..7b87cef 100644 --- a/src/modules/schedule-presets/services/schedule-presets-query.service.ts +++ b/src/Time_And_Attendance/modules/time-tracker/schedule-presets/services/schedule-presets-query.service.ts @@ -1,5 +1,5 @@ import { Injectable, NotFoundException } from "@nestjs/common"; -import { EmailToIdResolver } from "src/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"; diff --git a/src/modules/schedule-presets/types/schedule-presets.types.ts b/src/Time_And_Attendance/modules/time-tracker/schedule-presets/types/schedule-presets.types.ts similarity index 100% rename from src/modules/schedule-presets/types/schedule-presets.types.ts rename to src/Time_And_Attendance/modules/time-tracker/schedule-presets/types/schedule-presets.types.ts diff --git a/src/modules/shifts/controllers/shift.controller.ts b/src/Time_And_Attendance/modules/time-tracker/shifts/controllers/shift.controller.ts similarity index 100% rename from src/modules/shifts/controllers/shift.controller.ts rename to src/Time_And_Attendance/modules/time-tracker/shifts/controllers/shift.controller.ts diff --git a/src/modules/shifts/dtos/get-shift.dto.ts b/src/Time_And_Attendance/modules/time-tracker/shifts/dtos/get-shift.dto.ts similarity index 100% rename from src/modules/shifts/dtos/get-shift.dto.ts rename to src/Time_And_Attendance/modules/time-tracker/shifts/dtos/get-shift.dto.ts diff --git a/src/modules/shifts/dtos/shift.dto.ts b/src/Time_And_Attendance/modules/time-tracker/shifts/dtos/shift.dto.ts similarity index 100% rename from src/modules/shifts/dtos/shift.dto.ts rename to src/Time_And_Attendance/modules/time-tracker/shifts/dtos/shift.dto.ts diff --git a/src/modules/shifts/dtos/update-shift.dto.ts b/src/Time_And_Attendance/modules/time-tracker/shifts/dtos/update-shift.dto.ts similarity index 100% rename from src/modules/shifts/dtos/update-shift.dto.ts rename to src/Time_And_Attendance/modules/time-tracker/shifts/dtos/update-shift.dto.ts diff --git a/src/modules/shifts/helpers/shifts-date-time-helpers.ts b/src/Time_And_Attendance/modules/time-tracker/shifts/helpers/shifts-date-time-helpers.ts similarity index 100% rename from src/modules/shifts/helpers/shifts-date-time-helpers.ts rename to src/Time_And_Attendance/modules/time-tracker/shifts/helpers/shifts-date-time-helpers.ts diff --git a/src/modules/shifts/services/shifts-archival.service.ts b/src/Time_And_Attendance/modules/time-tracker/shifts/services/shifts-archival.service.ts similarity index 100% rename from src/modules/shifts/services/shifts-archival.service.ts rename to src/Time_And_Attendance/modules/time-tracker/shifts/services/shifts-archival.service.ts diff --git a/src/modules/shifts/services/shifts-get.service.ts b/src/Time_And_Attendance/modules/time-tracker/shifts/services/shifts-get.service.ts similarity index 100% rename from src/modules/shifts/services/shifts-get.service.ts rename to src/Time_And_Attendance/modules/time-tracker/shifts/services/shifts-get.service.ts diff --git a/src/modules/shifts/services/shifts-upsert.service.ts b/src/Time_And_Attendance/modules/time-tracker/shifts/services/shifts-upsert.service.ts similarity index 100% rename from src/modules/shifts/services/shifts-upsert.service.ts rename to src/Time_And_Attendance/modules/time-tracker/shifts/services/shifts-upsert.service.ts diff --git a/src/modules/shifts/shifts.module.ts b/src/Time_And_Attendance/modules/time-tracker/shifts/shifts.module.ts similarity index 82% rename from src/modules/shifts/shifts.module.ts rename to src/Time_And_Attendance/modules/time-tracker/shifts/shifts.module.ts index 4c20e0d..5d33c35 100644 --- a/src/modules/shifts/shifts.module.ts +++ b/src/Time_And_Attendance/modules/time-tracker/shifts/shifts.module.ts @@ -1,10 +1,10 @@ import { ShiftsArchivalService } from './services/shifts-archival.service'; import { BusinessLogicsModule } from 'src/modules/business-logics/business-logics.module'; -import { NotificationsModule } from '../notifications/notifications.module'; +import { NotificationsModule } from '../../../../modules/notifications/notifications.module'; import { ShiftsUpsertService } from './services/shifts-upsert.service'; import { ShiftsGetService } from './services/shifts-get.service'; import { ShiftController } from './controllers/shift.controller'; -import { SharedModule } from '../shared/shared.module'; +import { SharedModule } from '../../shared/shared.module'; import { Module } from '@nestjs/common'; @Module({ diff --git a/src/modules/shifts/~misc_deprecated-files/get-shift-overview.dto.ts b/src/Time_And_Attendance/modules/time-tracker/shifts/~misc_deprecated-files/get-shift-overview.dto.ts similarity index 100% rename from src/modules/shifts/~misc_deprecated-files/get-shift-overview.dto.ts rename to src/Time_And_Attendance/modules/time-tracker/shifts/~misc_deprecated-files/get-shift-overview.dto.ts diff --git a/src/modules/shifts/~misc_deprecated-files/shifts-command.service.ts b/src/Time_And_Attendance/modules/time-tracker/shifts/~misc_deprecated-files/shifts-command.service.ts similarity index 100% rename from src/modules/shifts/~misc_deprecated-files/shifts-command.service.ts rename to src/Time_And_Attendance/modules/time-tracker/shifts/~misc_deprecated-files/shifts-command.service.ts diff --git a/src/modules/shifts/~misc_deprecated-files/shifts-overview-row.interface.ts b/src/Time_And_Attendance/modules/time-tracker/shifts/~misc_deprecated-files/shifts-overview-row.interface.ts similarity index 100% rename from src/modules/shifts/~misc_deprecated-files/shifts-overview-row.interface.ts rename to src/Time_And_Attendance/modules/time-tracker/shifts/~misc_deprecated-files/shifts-overview-row.interface.ts diff --git a/src/modules/shifts/~misc_deprecated-files/shifts-query.service.ts b/src/Time_And_Attendance/modules/time-tracker/shifts/~misc_deprecated-files/shifts-query.service.ts similarity index 100% rename from src/modules/shifts/~misc_deprecated-files/shifts-query.service.ts rename to src/Time_And_Attendance/modules/time-tracker/shifts/~misc_deprecated-files/shifts-query.service.ts diff --git a/src/modules/shifts/~misc_deprecated-files/shifts-upsert.types.ts b/src/Time_And_Attendance/modules/time-tracker/shifts/~misc_deprecated-files/shifts-upsert.types.ts similarity index 100% rename from src/modules/shifts/~misc_deprecated-files/shifts-upsert.types.ts rename to src/Time_And_Attendance/modules/time-tracker/shifts/~misc_deprecated-files/shifts-upsert.types.ts diff --git a/src/modules/shifts/~misc_deprecated-files/shifts.controller.ts b/src/Time_And_Attendance/modules/time-tracker/shifts/~misc_deprecated-files/shifts.controller.ts similarity index 100% rename from src/modules/shifts/~misc_deprecated-files/shifts.controller.ts rename to src/Time_And_Attendance/modules/time-tracker/shifts/~misc_deprecated-files/shifts.controller.ts diff --git a/src/modules/shifts/~misc_deprecated-files/shifts.helpers.ts b/src/Time_And_Attendance/modules/time-tracker/shifts/~misc_deprecated-files/shifts.helpers.ts similarity index 100% rename from src/modules/shifts/~misc_deprecated-files/shifts.helpers.ts rename to src/Time_And_Attendance/modules/time-tracker/shifts/~misc_deprecated-files/shifts.helpers.ts diff --git a/src/modules/shifts/~misc_deprecated-files/shifts.utils.ts b/src/Time_And_Attendance/modules/time-tracker/shifts/~misc_deprecated-files/shifts.utils.ts similarity index 100% rename from src/modules/shifts/~misc_deprecated-files/shifts.utils.ts rename to src/Time_And_Attendance/modules/time-tracker/shifts/~misc_deprecated-files/shifts.utils.ts diff --git a/src/modules/shifts/~misc_deprecated-files/upsert-shift.dto.ts b/src/Time_And_Attendance/modules/time-tracker/shifts/~misc_deprecated-files/upsert-shift.dto.ts similarity index 100% rename from src/modules/shifts/~misc_deprecated-files/upsert-shift.dto.ts rename to src/Time_And_Attendance/modules/time-tracker/shifts/~misc_deprecated-files/upsert-shift.dto.ts diff --git a/src/modules/timesheets/controllers/timesheet.controller.ts b/src/Time_And_Attendance/modules/time-tracker/timesheets/controllers/timesheet.controller.ts similarity index 91% rename from src/modules/timesheets/controllers/timesheet.controller.ts rename to src/Time_And_Attendance/modules/time-tracker/timesheets/controllers/timesheet.controller.ts index 1efb2fe..61eef3a 100644 --- a/src/modules/timesheets/controllers/timesheet.controller.ts +++ b/src/Time_And_Attendance/modules/time-tracker/timesheets/controllers/timesheet.controller.ts @@ -1,4 +1,4 @@ -import { EmailToIdResolver } from "src/modules/shared/utils/resolve-email-id.utils"; +import { EmailToIdResolver } from "src/Time_And_Attendance/modules/shared/utils/resolve-email-id.utils"; import { GetTimesheetsOverviewService } from "../services/timesheet-get-overview.service"; import { BadRequestException, Controller, Get, Query} from "@nestjs/common"; diff --git a/src/modules/timesheets/dtos/timesheet.dto.ts b/src/Time_And_Attendance/modules/time-tracker/timesheets/dtos/timesheet.dto.ts similarity index 100% rename from src/modules/timesheets/dtos/timesheet.dto.ts rename to src/Time_And_Attendance/modules/time-tracker/timesheets/dtos/timesheet.dto.ts diff --git a/src/modules/timesheets/helpers/timesheets-date-time-helpers.ts b/src/Time_And_Attendance/modules/time-tracker/timesheets/helpers/timesheets-date-time-helpers.ts similarity index 100% rename from src/modules/timesheets/helpers/timesheets-date-time-helpers.ts rename to src/Time_And_Attendance/modules/time-tracker/timesheets/helpers/timesheets-date-time-helpers.ts diff --git a/src/modules/timesheets/services/timesheet-approval.service.ts b/src/Time_And_Attendance/modules/time-tracker/timesheets/services/timesheet-approval.service.ts similarity index 100% rename from src/modules/timesheets/services/timesheet-approval.service.ts rename to src/Time_And_Attendance/modules/time-tracker/timesheets/services/timesheet-approval.service.ts diff --git a/src/modules/timesheets/services/timesheet-archive.service.ts b/src/Time_And_Attendance/modules/time-tracker/timesheets/services/timesheet-archive.service.ts similarity index 100% rename from src/modules/timesheets/services/timesheet-archive.service.ts rename to src/Time_And_Attendance/modules/time-tracker/timesheets/services/timesheet-archive.service.ts diff --git a/src/modules/timesheets/services/timesheet-get-overview.service.ts b/src/Time_And_Attendance/modules/time-tracker/timesheets/services/timesheet-get-overview.service.ts similarity index 100% rename from src/modules/timesheets/services/timesheet-get-overview.service.ts rename to src/Time_And_Attendance/modules/time-tracker/timesheets/services/timesheet-get-overview.service.ts diff --git a/src/Time_And_Attendance/modules/time-tracker/timesheets/timesheets.module.ts b/src/Time_And_Attendance/modules/time-tracker/timesheets/timesheets.module.ts new file mode 100644 index 0000000..001fb19 --- /dev/null +++ b/src/Time_And_Attendance/modules/time-tracker/timesheets/timesheets.module.ts @@ -0,0 +1,23 @@ +import { GetTimesheetsOverviewService } from './services/timesheet-get-overview.service'; +import { TimesheetArchiveService } from './services/timesheet-archive.service'; +import { BusinessLogicsModule } from 'src/modules/business-logics/business-logics.module'; +import { TimesheetController } from './controllers/timesheet.controller'; +import { SharedModule } from '../../shared/shared.module'; +import { ShiftsModule } from '../shifts/shifts.module'; +import { Module } from '@nestjs/common'; + +@Module({ + imports: [ + BusinessLogicsModule, + SharedModule, + ShiftsModule, + ], + controllers: [TimesheetController], + providers: [ + TimesheetArchiveService, + GetTimesheetsOverviewService, + SharedModule, + ], + exports: [], +}) +export class TimesheetsModule {} diff --git a/src/modules/timesheets/~misc_deprecated-files/create-timesheet.dto.ts b/src/Time_And_Attendance/modules/time-tracker/timesheets/~misc_deprecated-files/create-timesheet.dto.ts similarity index 100% rename from src/modules/timesheets/~misc_deprecated-files/create-timesheet.dto.ts rename to src/Time_And_Attendance/modules/time-tracker/timesheets/~misc_deprecated-files/create-timesheet.dto.ts diff --git a/src/modules/timesheets/~misc_deprecated-files/search-timesheet.dto.ts b/src/Time_And_Attendance/modules/time-tracker/timesheets/~misc_deprecated-files/search-timesheet.dto.ts similarity index 100% rename from src/modules/timesheets/~misc_deprecated-files/search-timesheet.dto.ts rename to src/Time_And_Attendance/modules/time-tracker/timesheets/~misc_deprecated-files/search-timesheet.dto.ts diff --git a/src/modules/timesheets/~misc_deprecated-files/timesheet-period.dto.ts b/src/Time_And_Attendance/modules/time-tracker/timesheets/~misc_deprecated-files/timesheet-period.dto.ts similarity index 100% rename from src/modules/timesheets/~misc_deprecated-files/timesheet-period.dto.ts rename to src/Time_And_Attendance/modules/time-tracker/timesheets/~misc_deprecated-files/timesheet-period.dto.ts diff --git a/src/modules/timesheets/~misc_deprecated-files/timesheet.helpers.ts b/src/Time_And_Attendance/modules/time-tracker/timesheets/~misc_deprecated-files/timesheet.helpers.ts similarity index 100% rename from src/modules/timesheets/~misc_deprecated-files/timesheet.helpers.ts rename to src/Time_And_Attendance/modules/time-tracker/timesheets/~misc_deprecated-files/timesheet.helpers.ts diff --git a/src/modules/timesheets/~misc_deprecated-files/timesheet.mappers.ts b/src/Time_And_Attendance/modules/time-tracker/timesheets/~misc_deprecated-files/timesheet.mappers.ts similarity index 100% rename from src/modules/timesheets/~misc_deprecated-files/timesheet.mappers.ts rename to src/Time_And_Attendance/modules/time-tracker/timesheets/~misc_deprecated-files/timesheet.mappers.ts diff --git a/src/modules/timesheets/~misc_deprecated-files/timesheet.selectors.ts b/src/Time_And_Attendance/modules/time-tracker/timesheets/~misc_deprecated-files/timesheet.selectors.ts similarity index 100% rename from src/modules/timesheets/~misc_deprecated-files/timesheet.selectors.ts rename to src/Time_And_Attendance/modules/time-tracker/timesheets/~misc_deprecated-files/timesheet.selectors.ts diff --git a/src/modules/timesheets/~misc_deprecated-files/timesheet.types.ts b/src/Time_And_Attendance/modules/time-tracker/timesheets/~misc_deprecated-files/timesheet.types.ts similarity index 100% rename from src/modules/timesheets/~misc_deprecated-files/timesheet.types.ts rename to src/Time_And_Attendance/modules/time-tracker/timesheets/~misc_deprecated-files/timesheet.types.ts diff --git a/src/modules/timesheets/~misc_deprecated-files/timesheet.utils.ts b/src/Time_And_Attendance/modules/time-tracker/timesheets/~misc_deprecated-files/timesheet.utils.ts similarity index 100% rename from src/modules/timesheets/~misc_deprecated-files/timesheet.utils.ts rename to src/Time_And_Attendance/modules/time-tracker/timesheets/~misc_deprecated-files/timesheet.utils.ts diff --git a/src/modules/timesheets/~misc_deprecated-files/timesheets-command.service.ts b/src/Time_And_Attendance/modules/time-tracker/timesheets/~misc_deprecated-files/timesheets-command.service.ts similarity index 100% rename from src/modules/timesheets/~misc_deprecated-files/timesheets-command.service.ts rename to src/Time_And_Attendance/modules/time-tracker/timesheets/~misc_deprecated-files/timesheets-command.service.ts diff --git a/src/modules/timesheets/~misc_deprecated-files/timesheets-query.service.ts b/src/Time_And_Attendance/modules/time-tracker/timesheets/~misc_deprecated-files/timesheets-query.service.ts similarity index 100% rename from src/modules/timesheets/~misc_deprecated-files/timesheets-query.service.ts rename to src/Time_And_Attendance/modules/time-tracker/timesheets/~misc_deprecated-files/timesheets-query.service.ts diff --git a/src/modules/timesheets/~misc_deprecated-files/timesheets.controller.ts b/src/Time_And_Attendance/modules/time-tracker/timesheets/~misc_deprecated-files/timesheets.controller.ts similarity index 100% rename from src/modules/timesheets/~misc_deprecated-files/timesheets.controller.ts rename to src/Time_And_Attendance/modules/time-tracker/timesheets/~misc_deprecated-files/timesheets.controller.ts diff --git a/src/app.module.ts b/src/app.module.ts index 4179229..60c2767 100644 --- a/src/app.module.ts +++ b/src/app.module.ts @@ -18,15 +18,15 @@ import { OvertimeService } from './modules/business-logics/services/overtime.se import { PreferencesModule } from './modules/preferences/preferences.module'; import { PrismaModule } from './prisma/prisma.module'; import { ScheduleModule } from '@nestjs/schedule'; -import { ShiftsModule } from './modules/shifts/shifts.module'; -import { TimesheetsModule } from './modules/timesheets/timesheets.module'; +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 './modules/pay-periods/pay-periods.module'; +import { PayperiodsModule } from './Time_And_Attendance/modules/pay-period/pay-periods.module'; @Module({ imports: [ diff --git a/src/modules/archival/controllers/shifts-archive.controller.ts b/src/modules/archival/controllers/shifts-archive.controller.ts index e8f92f2..463ea4a 100644 --- a/src/modules/archival/controllers/shifts-archive.controller.ts +++ b/src/modules/archival/controllers/shifts-archive.controller.ts @@ -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/modules/shifts/services/shifts-archival.service"; +import { ShiftsArchivalService } from "src/Time_And_Attendance/modules/time-tracker/shifts/services/shifts-archival.service"; @ApiTags('Shift Archives') // @UseGuards() diff --git a/src/modules/archival/controllers/timesheets-archive.controller.ts b/src/modules/archival/controllers/timesheets-archive.controller.ts index 7505b66..9be0116 100644 --- a/src/modules/archival/controllers/timesheets-archive.controller.ts +++ b/src/modules/archival/controllers/timesheets-archive.controller.ts @@ -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/modules/timesheets/services/timesheet-archive.service"; +import { TimesheetArchiveService } from "src/Time_And_Attendance/modules/time-tracker/timesheets/services/timesheet-archive.service"; @ApiTags('Timesheet Archives') // @UseGuards() diff --git a/src/modules/archival/services/archival.service.ts b/src/modules/archival/services/archival.service.ts index 66be2d0..898ab51 100644 --- a/src/modules/archival/services/archival.service.ts +++ b/src/modules/archival/services/archival.service.ts @@ -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/modules/shifts/services/shifts-archival.service"; -import { TimesheetArchiveService } from "src/modules/timesheets/services/timesheet-archive.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 { diff --git a/src/modules/employees/employees.module.ts b/src/modules/employees/employees.module.ts index 0f0be93..2fd40ee 100644 --- a/src/modules/employees/employees.module.ts +++ b/src/modules/employees/employees.module.ts @@ -2,7 +2,7 @@ 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 '../shared/shared.module'; +import { SharedModule } from '../../Time_And_Attendance/modules/shared/shared.module'; @Module({ imports: [SharedModule], diff --git a/src/modules/exports/csv-exports.module.ts b/src/modules/exports/csv-exports.module.ts index e034c9e..0c9f00b 100644 --- a/src/modules/exports/csv-exports.module.ts +++ b/src/modules/exports/csv-exports.module.ts @@ -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 "../shared/shared.module"; +import { SharedModule } from "../../Time_And_Attendance/modules/shared/shared.module"; @Module({ providers:[CsvExportService, SharedModule], diff --git a/src/modules/preferences/preferences.module.ts b/src/modules/preferences/preferences.module.ts index 4fe0227..59031ba 100644 --- a/src/modules/preferences/preferences.module.ts +++ b/src/modules/preferences/preferences.module.ts @@ -1,7 +1,7 @@ import { Module } from "@nestjs/common"; import { PreferencesController } from "./controllers/preferences.controller"; import { PreferencesService } from "./services/preferences.service"; -import { SharedModule } from "../shared/shared.module"; +import { SharedModule } from "../../Time_And_Attendance/modules/shared/shared.module"; @Module({ imports: [SharedModule], diff --git a/src/modules/preferences/services/preferences.service.ts b/src/modules/preferences/services/preferences.service.ts index 6e4f169..2677573 100644 --- a/src/modules/preferences/services/preferences.service.ts +++ b/src/modules/preferences/services/preferences.service.ts @@ -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/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 { diff --git a/src/modules/timesheets/timesheets.module.ts b/src/modules/timesheets/timesheets.module.ts index be44043..e1c997e 100644 --- a/src/modules/timesheets/timesheets.module.ts +++ b/src/modules/timesheets/timesheets.module.ts @@ -1,9 +1,9 @@ -import { GetTimesheetsOverviewService } from './services/timesheet-get-overview.service'; -import { TimesheetArchiveService } from './services/timesheet-archive.service'; +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 './controllers/timesheet.controller'; -import { SharedModule } from '../shared/shared.module'; -import { ShiftsModule } from '../shifts/shifts.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({ From 062b9b4640e1c07e54498109f66847d5bb0c2116 Mon Sep 17 00:00:00 2001 From: Matthieu Haineault Date: Fri, 24 Oct 2025 16:15:54 -0400 Subject: [PATCH 2/5] refactor(expenses): major refactor of the CRUDs methods sing sessions data --- package-lock.json | 136 +++++++------- package.json | 4 +- prisma/schema.prisma | 62 +------ .../controllers/expense.controller.ts | 27 ++- src/modules/expenses/dtos/expense.dto.ts | 4 +- src/modules/expenses/dtos/get-expense.dto.ts | 3 +- src/modules/expenses/expenses.module.ts | 34 ++-- .../helpers/expenses-date-time-helpers.ts | 4 +- .../services/expense-upsert.service.ts | 174 ++++++++++++++++-- .../shifts/controllers/shift.controller.ts | 12 +- .../shifts/services/shifts-upsert.service.ts | 16 +- 11 files changed, 277 insertions(+), 199 deletions(-) diff --git a/package-lock.json b/package-lock.json index 1180132..b3363fc 100644 --- a/package-lock.json +++ b/package-lock.json @@ -17,7 +17,7 @@ "@nestjs/platform-express": "^11.1.6", "@nestjs/schedule": "^6.0.0", "@nestjs/swagger": "^11.2.0", - "@prisma/client": "^6.17.1", + "@prisma/client": "^6.18.0", "bullmq": "^5.58.0", "class-transformer": "^0.5.1", "class-validator": "^0.14.2", @@ -54,7 +54,7 @@ "globals": "^16.0.0", "jest": "^29.7.0", "prettier": "^3.4.2", - "prisma": "^6.17.1", + "prisma": "^6.18.0", "source-map-support": "^0.5.21", "supertest": "^7.0.0", "ts-jest": "^29.2.5", @@ -3268,13 +3268,13 @@ } }, "node_modules/@nestjs/common": { - "version": "11.1.6", - "resolved": "https://registry.npmjs.org/@nestjs/common/-/common-11.1.6.tgz", - "integrity": "sha512-krKwLLcFmeuKDqngG2N/RuZHCs2ycsKcxWIDgcm7i1lf3sQ0iG03ci+DsP/r3FcT/eJDFsIHnKtNta2LIi7PzQ==", + "version": "11.1.7", + "resolved": "https://registry.npmjs.org/@nestjs/common/-/common-11.1.7.tgz", + "integrity": "sha512-lwlObwGgIlpXSXYOTpfzdCepUyWomz6bv9qzGzzvpgspUxkj0Uz0fUJcvD44V8Ps7QhKW3lZBoYbXrH25UZrbA==", "dependencies": { "file-type": "21.0.0", "iterare": "1.2.1", - "load-esm": "1.0.2", + "load-esm": "1.0.3", "tslib": "2.8.1", "uid": "2.0.2" }, @@ -3312,15 +3312,15 @@ } }, "node_modules/@nestjs/core": { - "version": "11.1.6", - "resolved": "https://registry.npmjs.org/@nestjs/core/-/core-11.1.6.tgz", - "integrity": "sha512-siWX7UDgErisW18VTeJA+x+/tpNZrJewjTBsRPF3JVxuWRuAB1kRoiJcxHgln8Lb5UY9NdvklITR84DUEXD0Cg==", + "version": "11.1.7", + "resolved": "https://registry.npmjs.org/@nestjs/core/-/core-11.1.7.tgz", + "integrity": "sha512-TyXFOwjhHv/goSgJ8i20K78jwTM0iSpk9GBcC2h3mf4MxNy+znI8m7nWjfoACjTkb89cTwDQetfTHtSfGLLaiA==", "hasInstallScript": true, "dependencies": { "@nuxt/opencollective": "0.4.1", "fast-safe-stringify": "2.1.1", "iterare": "1.2.1", - "path-to-regexp": "8.2.0", + "path-to-regexp": "8.3.0", "tslib": "2.8.1", "uid": "2.0.2" }, @@ -3392,14 +3392,14 @@ } }, "node_modules/@nestjs/platform-express": { - "version": "11.1.6", - "resolved": "https://registry.npmjs.org/@nestjs/platform-express/-/platform-express-11.1.6.tgz", - "integrity": "sha512-HErwPmKnk+loTq8qzu1up+k7FC6Kqa8x6lJ4cDw77KnTxLzsCaPt+jBvOq6UfICmfqcqCCf3dKXg+aObQp+kIQ==", + "version": "11.1.7", + "resolved": "https://registry.npmjs.org/@nestjs/platform-express/-/platform-express-11.1.7.tgz", + "integrity": "sha512-5T+GLdvTiGPKB4/P4PM9ftKUKNHJy8ThEFhZA3vQnXVL7Vf0rDr07TfVTySVu+XTh85m1lpFVuyFM6u6wLNsRA==", "dependencies": { "cors": "2.8.5", "express": "5.1.0", "multer": "2.0.2", - "path-to-regexp": "8.2.0", + "path-to-regexp": "8.3.0", "tslib": "2.8.1" }, "funding": { @@ -3547,19 +3547,10 @@ } } }, - "node_modules/@nestjs/swagger/node_modules/path-to-regexp": { - "version": "8.3.0", - "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-8.3.0.tgz", - "integrity": "sha512-7jdwVIRtsP8MYpdXSwOS0YdD0Du+qOoF/AEPIt88PcCFrZCzx41oxku1jD88hZBwbNUIEfpqvuhjFaMAqMTWnA==", - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/express" - } - }, "node_modules/@nestjs/testing": { - "version": "11.1.6", - "resolved": "https://registry.npmjs.org/@nestjs/testing/-/testing-11.1.6.tgz", - "integrity": "sha512-srYzzDNxGvVCe1j0SpTS9/ix75PKt6Sn6iMaH1rpJ6nj2g8vwNrhK0CoJJXvpCYgrnI+2WES2pprYnq8rAMYHA==", + "version": "11.1.7", + "resolved": "https://registry.npmjs.org/@nestjs/testing/-/testing-11.1.7.tgz", + "integrity": "sha512-QbtrgSlc3QVo6RHNxTTlyhaiobLLy8kvhOlgWHsoXRknybuRs7vZg4k5mo3ye6pITGeT3CrWIRpZjUsh5Wps5Q==", "dev": true, "dependencies": { "tslib": "2.8.1" @@ -3667,9 +3658,9 @@ } }, "node_modules/@prisma/client": { - "version": "6.17.1", - "resolved": "https://registry.npmjs.org/@prisma/client/-/client-6.17.1.tgz", - "integrity": "sha512-zL58jbLzYamjnNnmNA51IOZdbk5ci03KviXCuB0Tydc9btH2kDWsi1pQm2VecviRTM7jGia0OPPkgpGnT3nKvw==", + "version": "6.18.0", + "resolved": "https://registry.npmjs.org/@prisma/client/-/client-6.18.0.tgz", + "integrity": "sha512-jnL2I9gDnPnw4A+4h5SuNn8Gc+1mL1Z79U/3I9eE2gbxJG1oSA+62ByPW4xkeDgwE0fqMzzpAZ7IHxYnLZ4iQA==", "hasInstallScript": true, "engines": { "node": ">=18.18" @@ -3688,60 +3679,60 @@ } }, "node_modules/@prisma/config": { - "version": "6.17.1", - "resolved": "https://registry.npmjs.org/@prisma/config/-/config-6.17.1.tgz", - "integrity": "sha512-fs8wY6DsvOCzuiyWVckrVs1LOcbY4LZNz8ki4uUIQ28jCCzojTGqdLhN2Jl5lDnC1yI8/gNIKpsWDM8pLhOdwA==", + "version": "6.18.0", + "resolved": "https://registry.npmjs.org/@prisma/config/-/config-6.18.0.tgz", + "integrity": "sha512-rgFzspCpwsE+q3OF/xkp0fI2SJ3PfNe9LLMmuSVbAZ4nN66WfBiKqJKo/hLz3ysxiPQZf8h1SMf2ilqPMeWATQ==", "devOptional": true, "dependencies": { "c12": "3.1.0", "deepmerge-ts": "7.1.5", - "effect": "3.16.12", + "effect": "3.18.4", "empathic": "2.0.0" } }, "node_modules/@prisma/debug": { - "version": "6.17.1", - "resolved": "https://registry.npmjs.org/@prisma/debug/-/debug-6.17.1.tgz", - "integrity": "sha512-Vf7Tt5Wh9XcndpbmeotuqOMLWPTjEKCsgojxXP2oxE1/xYe7PtnP76hsouG9vis6fctX+TxgmwxTuYi/+xc7dQ==", + "version": "6.18.0", + "resolved": "https://registry.npmjs.org/@prisma/debug/-/debug-6.18.0.tgz", + "integrity": "sha512-PMVPMmxPj0ps1VY75DIrT430MoOyQx9hmm174k6cmLZpcI95rAPXOQ+pp8ANQkJtNyLVDxnxVJ0QLbrm/ViBcg==", "devOptional": true }, "node_modules/@prisma/engines": { - "version": "6.17.1", - "resolved": "https://registry.npmjs.org/@prisma/engines/-/engines-6.17.1.tgz", - "integrity": "sha512-D95Ik3GYZkqZ8lSR4EyFOJ/tR33FcYRP8kK61o+WMsyD10UfJwd7+YielflHfKwiGodcqKqoraWw8ElAgMDbPw==", + "version": "6.18.0", + "resolved": "https://registry.npmjs.org/@prisma/engines/-/engines-6.18.0.tgz", + "integrity": "sha512-i5RzjGF/ex6AFgqEe2o1IW8iIxJGYVQJVRau13kHPYEL1Ck8Zvwuzamqed/1iIljs5C7L+Opiz5TzSsUebkriA==", "devOptional": true, "hasInstallScript": true, "dependencies": { - "@prisma/debug": "6.17.1", - "@prisma/engines-version": "6.17.1-1.272a37d34178c2894197e17273bf937f25acdeac", - "@prisma/fetch-engine": "6.17.1", - "@prisma/get-platform": "6.17.1" + "@prisma/debug": "6.18.0", + "@prisma/engines-version": "6.18.0-8.34b5a692b7bd79939a9a2c3ef97d816e749cda2f", + "@prisma/fetch-engine": "6.18.0", + "@prisma/get-platform": "6.18.0" } }, "node_modules/@prisma/engines-version": { - "version": "6.17.1-1.272a37d34178c2894197e17273bf937f25acdeac", - "resolved": "https://registry.npmjs.org/@prisma/engines-version/-/engines-version-6.17.1-1.272a37d34178c2894197e17273bf937f25acdeac.tgz", - "integrity": "sha512-17140E3huOuD9lMdJ9+SF/juOf3WR3sTJMVyyenzqUPbuH+89nPhSWcrY+Mf7tmSs6HvaO+7S+HkELinn6bhdg==", + "version": "6.18.0-8.34b5a692b7bd79939a9a2c3ef97d816e749cda2f", + "resolved": "https://registry.npmjs.org/@prisma/engines-version/-/engines-version-6.18.0-8.34b5a692b7bd79939a9a2c3ef97d816e749cda2f.tgz", + "integrity": "sha512-T7Af4QsJQnSgWN1zBbX+Cha5t4qjHRxoeoWpK4JugJzG/ipmmDMY5S+O0N1ET6sCBNVkf6lz+Y+ZNO9+wFU8pQ==", "devOptional": true }, "node_modules/@prisma/fetch-engine": { - "version": "6.17.1", - "resolved": "https://registry.npmjs.org/@prisma/fetch-engine/-/fetch-engine-6.17.1.tgz", - "integrity": "sha512-AYZiHOs184qkDMiTeshyJCtyL4yERkjfTkJiSJdYuSfc24m94lTNL5+GFinZ6vVz+ktX4NJzHKn1zIFzGTWrWg==", + "version": "6.18.0", + "resolved": "https://registry.npmjs.org/@prisma/fetch-engine/-/fetch-engine-6.18.0.tgz", + "integrity": "sha512-TdaBvTtBwP3IoqVYoGIYpD4mWlk0pJpjTJjir/xLeNWlwog7Sl3bD2J0jJ8+5+q/6RBg+acb9drsv5W6lqae7A==", "devOptional": true, "dependencies": { - "@prisma/debug": "6.17.1", - "@prisma/engines-version": "6.17.1-1.272a37d34178c2894197e17273bf937f25acdeac", - "@prisma/get-platform": "6.17.1" + "@prisma/debug": "6.18.0", + "@prisma/engines-version": "6.18.0-8.34b5a692b7bd79939a9a2c3ef97d816e749cda2f", + "@prisma/get-platform": "6.18.0" } }, "node_modules/@prisma/get-platform": { - "version": "6.17.1", - "resolved": "https://registry.npmjs.org/@prisma/get-platform/-/get-platform-6.17.1.tgz", - "integrity": "sha512-AKEn6fsfz0r482S5KRDFlIGEaq9wLNcgalD1adL+fPcFFblIKs1sD81kY/utrHdqKuVC6E1XSRpegDK3ZLL4Qg==", + "version": "6.18.0", + "resolved": "https://registry.npmjs.org/@prisma/get-platform/-/get-platform-6.18.0.tgz", + "integrity": "sha512-uXNJCJGhxTCXo2B25Ta91Rk1/Nmlqg9p7G9GKh8TPhxvAyXCvMNQoogj4JLEUy+3ku8g59cpyQIKFhqY2xO2bg==", "devOptional": true, "dependencies": { - "@prisma/debug": "6.17.1" + "@prisma/debug": "6.18.0" } }, "node_modules/@scarf/scarf": { @@ -6953,9 +6944,9 @@ "integrity": "sha512-WMwm9LhRUo+WUaRN+vRuETqG89IgZphVSNkdFgeb6sS/E4OrDIN7t48CAewSHXc6C8lefD8KKfr5vY61brQlow==" }, "node_modules/effect": { - "version": "3.16.12", - "resolved": "https://registry.npmjs.org/effect/-/effect-3.16.12.tgz", - "integrity": "sha512-N39iBk0K71F9nb442TLbTkjl24FLUzuvx2i1I2RsEAQsdAdUTuUoW0vlfUXgkMTUOnYqKnWcFfqw4hK4Pw27hg==", + "version": "3.18.4", + "resolved": "https://registry.npmjs.org/effect/-/effect-3.18.4.tgz", + "integrity": "sha512-b1LXQJLe9D11wfnOKAk3PKxuqYshQ0Heez+y5pnkd3jLj1yx9QhM72zZ9uUrOQyNvrs2GZZd/3maL0ZV18YuDA==", "devOptional": true, "dependencies": { "@standard-schema/spec": "^1.0.0", @@ -9542,9 +9533,9 @@ "dev": true }, "node_modules/load-esm": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/load-esm/-/load-esm-1.0.2.tgz", - "integrity": "sha512-nVAvWk/jeyrWyXEAs84mpQCYccxRqgKY4OznLuJhJCa0XsPSfdOIr2zvBZEj3IHEHbX97jjscKRRV539bW0Gpw==", + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/load-esm/-/load-esm-1.0.3.tgz", + "integrity": "sha512-v5xlu8eHD1+6r8EHTg6hfmO97LN8ugKtiXcy5e6oN72iD2r6u0RPfLl6fxM+7Wnh2ZRq15o0russMst44WauPA==", "funding": [ { "type": "github", @@ -10468,11 +10459,12 @@ } }, "node_modules/path-to-regexp": { - "version": "8.2.0", - "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-8.2.0.tgz", - "integrity": "sha512-TdrF7fW9Rphjq4RjrW0Kp2AW0Ahwu9sRGTkS6bvDi0SCwZlEZYmcfDbEsTz8RVk0EHIS/Vd1bv3JhG+1xZuAyQ==", - "engines": { - "node": ">=16" + "version": "8.3.0", + "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-8.3.0.tgz", + "integrity": "sha512-7jdwVIRtsP8MYpdXSwOS0YdD0Du+qOoF/AEPIt88PcCFrZCzx41oxku1jD88hZBwbNUIEfpqvuhjFaMAqMTWnA==", + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" } }, "node_modules/path-type": { @@ -10703,14 +10695,14 @@ } }, "node_modules/prisma": { - "version": "6.17.1", - "resolved": "https://registry.npmjs.org/prisma/-/prisma-6.17.1.tgz", - "integrity": "sha512-ac6h0sM1Tg3zu8NInY+qhP/S9KhENVaw9n1BrGKQVFu05JT5yT5Qqqmb8tMRIE3ZXvVj4xcRA5yfrsy4X7Yy5g==", + "version": "6.18.0", + "resolved": "https://registry.npmjs.org/prisma/-/prisma-6.18.0.tgz", + "integrity": "sha512-bXWy3vTk8mnRmT+SLyZBQoC2vtV9Z8u7OHvEu+aULYxwiop/CPiFZ+F56KsNRNf35jw+8wcu8pmLsjxpBxAO9g==", "devOptional": true, "hasInstallScript": true, "dependencies": { - "@prisma/config": "6.17.1", - "@prisma/engines": "6.17.1" + "@prisma/config": "6.18.0", + "@prisma/engines": "6.18.0" }, "bin": { "prisma": "build/index.js" diff --git a/package.json b/package.json index c8db806..589f94f 100644 --- a/package.json +++ b/package.json @@ -49,7 +49,7 @@ "@nestjs/platform-express": "^11.1.6", "@nestjs/schedule": "^6.0.0", "@nestjs/swagger": "^11.2.0", - "@prisma/client": "^6.17.1", + "@prisma/client": "^6.18.0", "bullmq": "^5.58.0", "class-transformer": "^0.5.1", "class-validator": "^0.14.2", @@ -86,7 +86,7 @@ "globals": "^16.0.0", "jest": "^29.7.0", "prettier": "^3.4.2", - "prisma": "^6.17.1", + "prisma": "^6.18.0", "source-map-support": "^0.5.21", "supertest": "^7.0.0", "ts-jest": "^29.2.5", diff --git a/prisma/schema.prisma b/prisma/schema.prisma index 1d62fbd..60503eb 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -24,10 +24,7 @@ model Users { role Roles @default(GUEST) employee Employees? @relation("UserEmployee") - customer Customers? @relation("UserCustomer") oauth_sessions OAuthSessions[] @relation("UserOAuthSessions") - employees_archive EmployeesArchive[] @relation("UsersToEmployeesToArchive") - customer_archive CustomersArchive[] @relation("UserToCustomersToArchive") preferences Preferences? @relation("UserPreferences") @@map("users") @@ -49,61 +46,13 @@ model Employees { crew Employees[] @relation("EmployeeSupervisor") - archive EmployeesArchive[] @relation("EmployeeToArchive") timesheet Timesheets[] @relation("TimesheetEmployee") leave_request LeaveRequests[] @relation("LeaveRequestEmployee") - supervisor_archive EmployeesArchive[] @relation("EmployeeSupervisorToArchive") schedule_presets SchedulePresets[] @relation("SchedulePreset") @@map("employees") } -model EmployeesArchive { - id Int @id @default(autoincrement()) - employee Employees @relation("EmployeeToArchive", fields: [employee_id], references: [id]) - employee_id Int - user_id String @db.Uuid - user Users @relation("UsersToEmployeesToArchive", fields: [user_id], references: [id]) - supervisor Employees? @relation("EmployeeSupervisorToArchive", fields: [supervisor_id], references: [id]) - supervisor_id Int? - - archived_at DateTime @default(now()) - first_name String - last_name String - job_title String? - is_supervisor Boolean - external_payroll_id Int - company_code Int - first_work_day DateTime @db.Date - last_work_day DateTime @db.Date - - @@map("employees_archive") -} - -model Customers { - id Int @id @default(autoincrement()) - user Users @relation("UserCustomer", fields: [user_id], references: [id]) - user_id String @unique @db.Uuid - invoice_id Int? @unique - - archive CustomersArchive[] @relation("CustomerToArchive") - - @@map("customers") -} - -model CustomersArchive { - id Int @id @default(autoincrement()) - customer Customers @relation("CustomerToArchive", fields: [customer_id], references: [id]) - customer_id Int - user Users @relation("UserToCustomersToArchive", fields: [user_id], references: [id]) - user_id String @db.Uuid - - archived_at DateTime @default(now()) - invoice_id Int? @unique - - @@map("customers_archive") -} - model LeaveRequests { id Int @id @default(autoincrement()) employee Employees @relation("LeaveRequestEmployee", fields: [employee_id], references: [id]) @@ -216,13 +165,6 @@ model SchedulePresetShifts { @@map("schedule_preset_shifts") } - - - - - - - model Shifts { id Int @id @default(autoincrement()) timesheet Timesheets @relation("ShiftTimesheet", fields: [timesheet_id], references: [id]) @@ -283,7 +225,7 @@ model Expenses { attachment Int? date DateTime @db.Date - amount Decimal @db.Money + amount Decimal? @db.Decimal(12,2) mileage Decimal? @db.Decimal(12,2) comment String supervisor_comment String? @@ -305,7 +247,7 @@ model ExpensesArchive { archived_at DateTime @default(now()) bank_code_id Int date DateTime @db.Date - amount Decimal? @db.Money + amount Decimal? @db.Decimal(12,2) mileage Decimal? @db.Decimal(12,2) comment String? is_approved Boolean diff --git a/src/modules/expenses/controllers/expense.controller.ts b/src/modules/expenses/controllers/expense.controller.ts index bb37634..e5e5f56 100644 --- a/src/modules/expenses/controllers/expense.controller.ts +++ b/src/modules/expenses/controllers/expense.controller.ts @@ -1,7 +1,8 @@ -import { Body, Controller, Param, ParseIntPipe, Post } from "@nestjs/common"; +import { Body, Controller, Delete, Get, Param, ParseIntPipe, Patch, Post } from "@nestjs/common"; import { PrismaService } from "src/prisma/prisma.service"; import { ExpenseDto } from "../dtos/expense.dto"; -import { CreateResult, ExpenseUpsertService } from "../services/expense-upsert.service"; +import { CreateResult, ExpenseUpsertService, UpdateResult } from "../services/expense-upsert.service"; +import { updateExpenseDto } from "src/modules/expenses/dtos/update-expense.dto"; @Controller('expense') @@ -11,11 +12,21 @@ export class ExpenseController { private readonly upsert_service: ExpenseUpsertService, ){} + @Post(':timesheet_id') + create( + @Param('timesheet_id', ParseIntPipe) timesheet_id: number, + @Body() dto: ExpenseDto): Promise{ + return this.upsert_service.createExpense(timesheet_id, dto); + } - // @Post(':timesheet_id') - // create( - // @Param('timesheet_id', ParseIntPipe) timesheet_id: number, - // @Body() dto: ExpenseDto): Promise{ - // return this.upsert_service.createExpense(timesheet_id, dto); - // } + @Patch() + update( + @Body() body: { update :{ id: number; dto: updateExpenseDto }}): Promise{ + return this.upsert_service.updateExpense(body.update); + } + + @Delete(':expense_id') + remove(@Param('expense_id') expense_id: number) { + return this.upsert_service.deleteExpense(expense_id); + } } \ No newline at end of file diff --git a/src/modules/expenses/dtos/expense.dto.ts b/src/modules/expenses/dtos/expense.dto.ts index 51cc174..7e037e8 100644 --- a/src/modules/expenses/dtos/expense.dto.ts +++ b/src/modules/expenses/dtos/expense.dto.ts @@ -3,9 +3,9 @@ import { IsBoolean, IsInt, IsOptional, IsString, MaxLength } from "class-validat export class ExpenseDto { @IsInt() bank_code_id!: number; @IsInt() timesheet_id!: number; - @IsString() @IsOptional() attachment?: string; + @IsInt() @IsOptional() attachment?: number; - @IsString() date!: string; + @IsString() date!: string; @IsInt() @IsOptional() amount?: number; @IsInt() @IsOptional() mileage?: number; @IsString() @MaxLength(280) comment!: string; diff --git a/src/modules/expenses/dtos/get-expense.dto.ts b/src/modules/expenses/dtos/get-expense.dto.ts index 6c3056e..773a1a7 100644 --- a/src/modules/expenses/dtos/get-expense.dto.ts +++ b/src/modules/expenses/dtos/get-expense.dto.ts @@ -1,7 +1,8 @@ export class GetExpenseDto { + id: number; timesheet_id: number; bank_code_id: number; - attachment?: string; + attachment?: number; date: string; comment: string; mileage?: number; diff --git a/src/modules/expenses/expenses.module.ts b/src/modules/expenses/expenses.module.ts index 490ec9e..85f62cb 100644 --- a/src/modules/expenses/expenses.module.ts +++ b/src/modules/expenses/expenses.module.ts @@ -1,23 +1,15 @@ -// import { ExpensesController } from "./controllers/expenses.controller"; -// import { Module } from "@nestjs/common"; -// import { ExpensesQueryService } from "./services/expenses-query.service"; -// import { BusinessLogicsModule } from "src/modules/business-logics/business-logics.module"; -// import { ExpensesCommandService } from "./services/expenses-command.service"; -// import { ExpensesArchivalService } from "./services/expenses-archival.service"; -// import { SharedModule } from "../shared/shared.module"; +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: [ExpensesController], -// providers: [ -// ExpensesQueryService, -// ExpensesArchivalService, -// ExpensesCommandService, -// ], -// exports: [ -// ExpensesQueryService, -// ExpensesArchivalService, -// ], -// }) +@Module({ + imports: [ BusinessLogicsModule, SharedModule ], + controllers: [ ExpenseController ], + providers: [ ExpenseUpsertService, ExpensesArchivalService ], + exports: [ ExpensesArchivalService ], +}) -// export class ExpensesModule {} \ No newline at end of file +export class ExpensesModule {} \ No newline at end of file diff --git a/src/modules/expenses/helpers/expenses-date-time-helpers.ts b/src/modules/expenses/helpers/expenses-date-time-helpers.ts index ce14e69..ef81852 100644 --- a/src/modules/expenses/helpers/expenses-date-time-helpers.ts +++ b/src/modules/expenses/helpers/expenses-date-time-helpers.ts @@ -1,3 +1,5 @@ export const toDateFromString = (ymd: string): Date => { return new Date(`${ymd}T00:00:00:000Z`); -} \ No newline at end of file +} +export const toStringFromDate = (date: Date) => + date.toISOString().slice(0,10); \ No newline at end of file diff --git a/src/modules/expenses/services/expense-upsert.service.ts b/src/modules/expenses/services/expense-upsert.service.ts index 5e47a1e..d2a332c 100644 --- a/src/modules/expenses/services/expense-upsert.service.ts +++ b/src/modules/expenses/services/expense-upsert.service.ts @@ -1,41 +1,171 @@ -import { Injectable } from "@nestjs/common"; -import { PrismaService } from "src/prisma/prisma.service"; -import { GetExpenseDto } from "../dtos/get-expense.dto"; +import { toDateFromString, toStringFromDate } from "../helpers/expenses-date-time-helpers"; +import { Injectable, NotFoundException } from "@nestjs/common"; import { updateExpenseDto } from "../dtos/update-expense.dto"; +import { GetExpenseDto } from "../dtos/get-expense.dto"; +import { PrismaService } from "src/prisma/prisma.service"; import { ExpenseDto } from "../dtos/expense.dto"; -import { toDateFromString } from "../helpers/expenses-date-time-helpers"; -type Normalized = { date: Date; comment: string; supervisor_comment: string; }; +type Normalized = { date: Date; comment: string; supervisor_comment?: string; }; -export type CreateResult = { ok: true; data: GetExpenseDto } | { ok: false; error: any }; +export type CreateResult = { ok: true; data: GetExpenseDto } | { ok: false; error: any }; export type UpdatePayload = { id: number; dto: updateExpenseDto }; -export type UpdateResult = { ok: true; id: number; data: GetExpenseDto } | { ok: false; id: number; error: any }; -export type DeleteResult = { ok: true; id: number; } | { ok: false; id: number; error: any }; - -type NormedOk = { dto: GetExpenseDto; normed: Normalized }; -type NormedErr = { error: any }; +export type UpdateResult = { ok: true; id: number; data: GetExpenseDto } | { ok: false; id: number; error: any }; +export type DeleteResult = { ok: true; id: number; } | { ok: false; id: number; error: any }; @Injectable() export class ExpenseUpsertService { - constructor(private readonly prisma: PrismaService){} + constructor(private readonly prisma: PrismaService) { } //_________________________________________________________________ // CREATE //_________________________________________________________________ - //normalized frontend data to match DB - async createExpense(timesheet_id: number, dto: ExpenseDto){ - const normed_expense = this.normalizeExpenseDto(dto) - + async createExpense(timesheet_id: number, dto: ExpenseDto): Promise { + try { + //normalize strings and dates + const normed_expense = this.normalizeExpenseDto(dto); + //parse numbers + const parsed_amount = this.parseOptionalNumber(dto.amount, "amount"); + const parsed_mileage = this.parseOptionalNumber(dto.mileage, "mileage"); + const parsed_attachment = this.parseOptionalNumber(dto.attachment, "attachment"); + + //create a new expense + const expense = await this.prisma.expenses.create({ + data: { + timesheet_id, + bank_code_id: dto.bank_code_id, + attachment: parsed_attachment, + date: normed_expense.date, + amount: parsed_amount, + mileage: parsed_mileage, + comment: normed_expense.comment, + supervisor_comment: normed_expense.supervisor_comment, + is_approved: dto.is_approved, + }, + //return the newly created expense with id + select: { + id: true, + timesheet_id: true, + bank_code_id: true, + attachment: true, + date: true, + amount: true, + mileage: true, + comment: true, + supervisor_comment: true, + is_approved: true, + }, + }); + + //build an object to return to the frontend to display + const created: GetExpenseDto = { + id: expense.id, + timesheet_id: expense.timesheet_id, + bank_code_id: expense.bank_code_id, + attachment: expense.attachment ?? undefined, + date: toStringFromDate(expense.date), + amount: expense.amount?.toNumber(), + mileage: expense.mileage?.toNumber(), + comment: expense.comment, + supervisor_comment: expense.supervisor_comment ?? undefined, + is_approved: expense.is_approved, + }; + return { ok: true, data: created } + + } catch (error) { + return { ok: false, error: error } + } + } + + //_________________________________________________________________ + // UPDATE + //_________________________________________________________________ + async updateExpense({id, dto}: UpdatePayload): Promise { + try { + //checks for modifications + const data: Record = {}; + if (dto.date !== undefined) data.date = toDateFromString(dto.date); + if (dto.comment !== undefined) data.comment = this.truncate280(dto.comment); + if (dto.attachment !== undefined) data.attachment = this.parseOptionalNumber(dto.attachment, "attachment"); + if (dto.amount !== undefined) data.amount = this.parseOptionalNumber(dto.amount, "amount"); + if (dto.mileage !== undefined) data.mileage = this.parseOptionalNumber(dto.mileage, "mileage"); + if (dto.bank_code_id !== undefined) data.bank_code_id = dto.bank_code_id; + if (dto.supervisor_comment !== undefined) { + data.supervisor_comment = dto.supervisor_comment?.trim() + ? this.truncate280(dto.supervisor_comment.trim()) + : null; + } + //return an error if no fields needs an update + if(!Object.keys(data).length) { + return { ok: false, id, error: new Error("Nothing to update")}; + } + + const expense = await this.prisma.expenses.update({ + where: { id }, + data, + select: { + id: true, + timesheet_id: true, + bank_code_id: true, + attachment: true, + date: true, + amount: true, + mileage: true, + comment: true, + supervisor_comment: true, + is_approved: true, + }, + }); + + const updated: GetExpenseDto = { + id: expense.id, + timesheet_id: expense.timesheet_id, + bank_code_id: expense.bank_code_id, + attachment: expense.attachment ?? undefined, + date: toStringFromDate(expense.date), + amount: expense.amount?.toNumber(), + mileage: expense.mileage?.toNumber(), + comment: expense.comment, + supervisor_comment: expense.supervisor_comment ?? undefined, + is_approved: expense.is_approved, + }; + return { ok: true, id: expense.id, data: updated }; + } catch (error) { + return { ok: false, id: id, error: error} + } + } + //_________________________________________________________________ + // DELETE + //_________________________________________________________________ + async deleteExpense(expense_id: number): Promise { + try { + await this.prisma.$transaction(async (tx) => { + const expense = await tx.expenses.findUnique({ + where: { id: expense_id }, + select: { id: true }, + }); + if(!expense) throw new NotFoundException(`Expense with id: ${expense_id} not found`); + + await tx.expenses.delete({ where: { id: expense_id }}); + return { success: true }; + }); + return { ok: true, id: expense_id }; + } catch (error) { + return { ok: false, id: expense_id, error }; + } } //_________________________________________________________________ // LOCAL HELPERS //_________________________________________________________________ + //makes sure that comments are the right length the date is of Date type private normalizeExpenseDto(dto: ExpenseDto): Normalized { - const date = toDateFromString(dto.date); + const date = toDateFromString(dto.date); const comment = this.truncate280(dto.comment); - const supervisor_comment = this.truncate280(dto.supervisor_comment? dto.supervisor_comment : ''); + const supervisor_comment = + dto.supervisor_comment && dto.supervisor_comment.trim() + ? this.truncate280(dto.supervisor_comment.trim()) + : undefined; return { date, comment, supervisor_comment }; } @@ -43,4 +173,12 @@ export class ExpenseUpsertService { private truncate280 = (input: string): string => { return input.length > 280 ? input.slice(0, 280) : input; } + + //makes sure that the type of data of numeric values is valid + private parseOptionalNumber = (value: unknown, field: string) => { + if (value == null) return undefined; + const parsed = Number(value); + if (Number.isNaN(parsed)) throw new Error(`Invalid value : ${value} for ${field}`); + return parsed; + }; } \ No newline at end of file diff --git a/src/modules/shifts/controllers/shift.controller.ts b/src/modules/shifts/controllers/shift.controller.ts index bffa9cb..b35766d 100644 --- a/src/modules/shifts/controllers/shift.controller.ts +++ b/src/modules/shifts/controllers/shift.controller.ts @@ -12,12 +12,12 @@ export class ShiftController { private readonly get_service: ShiftsGetService ){} - @Get() - async getShiftsByIds( - @Query("shift_ids") shift_ids: string) { - const parsed = shift_ids.split(/,\s*/).map(value => Number(value)).filter(Number.isFinite); - return this.get_service.getShiftByShiftId(parsed); - } + // @Get() + // async getShiftsByIds( + // @Query("shift_ids") shift_ids: string) { + // const parsed = shift_ids.split(/,\s*/).map(value => Number(value)).filter(Number.isFinite); + // return this.get_service.getShiftByShiftId(parsed); + // } @Post(':timesheet_id') createBatch( diff --git a/src/modules/shifts/services/shifts-upsert.service.ts b/src/modules/shifts/services/shifts-upsert.service.ts index e63380b..cc0e790 100644 --- a/src/modules/shifts/services/shifts-upsert.service.ts +++ b/src/modules/shifts/services/shifts-upsert.service.ts @@ -336,20 +336,20 @@ export class ShiftsUpsertService { //finds shifts using shit_ids //recalc overtime shifts after delete //blocs deletion if approved - async deleteShift(shift_id: number) { - return await this.prisma.$transaction(async (tx) =>{ + async deleteShift(shift_id: number) { + return await this.prisma.$transaction(async (tx) => { const shift = await tx.shifts.findUnique({ - where: { id: shift_id }, + where: { id: shift_id }, select: { id: true, date: true, timesheet_id: true }, }); - if(!shift) throw new NotFoundException(`Shift with id #${shift_id} not found`); + if (!shift) throw new NotFoundException(`Shift with id #${shift_id} not found`); await tx.shifts.delete({ where: { id: shift_id } }); - const summary = await this.overtime.getWeekOvertimeSummary( shift.timesheet_id, shift.date, tx); - return { - success: true, - overtime: summary + const summary = await this.overtime.getWeekOvertimeSummary(shift.timesheet_id, shift.date, tx); + return { + success: true, + overtime: summary }; }); } From 1289aed720c7421d57112effa2de1faf3802c6eb Mon Sep 17 00:00:00 2001 From: Matthieu Haineault Date: Fri, 24 Oct 2025 16:38:18 -0400 Subject: [PATCH 3/5] reafactor(time-and-attendance): organized files and folders and centralize module files --- docs/swagger/swagger-spec.json | 505 +++++------------- prisma/mock-seeds-scripts/04-customers.ts | 46 +- .../05-employees-archive.ts | 76 +-- .../06-customers-archive.ts | 56 +- .../08-leave-requests-archive.ts | 148 ++--- .../mock-seeds-scripts/11-shifts-archive.ts | 122 ++--- .../mock-seeds-scripts/13-expenses-archive.ts | 108 ++-- src/app.module.ts | 27 +- .../employees/employees.module.ts | 13 + .../employees-archive.controller.ts | 58 +- .../expenses-archive.controller.ts | 2 +- .../controllers/shifts-archive.controller.ts | 2 +- .../timesheets-archive.controller.ts | 2 +- .../archival/services/archival.service.ts | 6 +- .../controllers/customers.controller.ts | 122 ++--- src/modules/customers/customers.module.ts | 16 +- .../controllers/employees.controller.ts | 178 +++--- src/modules/employees/employees.module.ts | 23 +- .../services/employees-archival.service.ts | 308 +++++------ src/modules/expenses/expenses.module.ts | 15 - src/modules/exports/csv-exports.module.ts | 2 +- src/modules/preferences/preferences.module.ts | 2 +- .../services/preferences.service.ts | 2 +- src/modules/timesheets/timesheets.module.ts | 23 - .../domains/business-logics.module.ts | 0 .../domains/services/after-hours.service.ts | 0 .../domains/services/holiday.service.ts | 0 .../domains/services/mileage.service.ts | 0 .../domains/services/overtime.service.ts | 0 .../domains/services/sick-leave.service.ts | 0 .../domains/services/vacation.service.ts | 0 .../controllers/expense.controller.ts | 2 +- .../modules/expenses/dtos/expense.dto.ts | 0 .../modules/expenses/dtos/get-expense.dto.ts | 0 .../expenses/dtos/update-expense.dto.ts | 0 .../modules/expenses/expenses.module.ts | 15 + .../helpers/expenses-date-time-helpers.ts | 0 .../services/expense-upsert.service.ts | 0 .../services/expenses-archival.service.ts | 0 .../create-expense.dto.ts | 0 .../expenses-command.service.ts | 0 .../expenses-query.service.ts | 0 .../expenses.controller.ts | 0 .../expenses.types.interfaces.ts | 0 .../~misc_deprecated-files/expenses.utils.ts | 0 .../search-expense.dto.ts | 0 .../update-expense.dto.ts | 0 .../upsert-expense.dto.ts | 0 .../controllers/leave-requests.controller.ts | 0 .../dtos/leave-request-view.dto.ts | 0 .../dtos/upsert-leave-request.dto.ts | 0 .../leave-requests/leave-requests.module.ts | 0 .../mappers/leave-requests-archive.mapper.ts | 0 .../mappers/leave-requests.mapper.ts | 0 .../holiday-leave-requests.service.ts | 0 .../services/leave-request.service.ts | 0 .../services/sick-leave-requests.service.ts | 0 .../vacation-leave-requests.service.ts | 0 .../utils/leave-request.transform.ts | 0 .../utils/leave-request.util.ts | 0 .../utils/leave-requests-archive.select.ts | 0 .../utils/leave-requests.select.ts | 0 .../controllers/pay-periods.controller.ts | 0 .../pay-period/dtos/bulk-crew-approval.dto.ts | 0 .../pay-period/dtos/bundle-pay-period.dto.ts | 0 .../dtos/overview-employee-period.dto.ts | 0 .../dtos/overview-pay-period.dto.ts | 0 .../modules/pay-period/dtos/pay-period.dto.ts | 0 .../pay-period/mappers/pay-periods.mapper.ts | 0 .../modules/pay-period/pay-periods.module.ts | 13 +- .../services/pay-periods-command.service.ts | 0 .../services/pay-periods-query.service.ts | 0 .../modules/pay-period/utils/pay-year.util.ts | 0 .../shared/constants/date-time.constant.ts | 0 .../shared/constants/regex.constant.ts | 0 .../shared/constants/utils.constant.ts | 0 .../shared/helpers/date-time.helpers.ts | 0 .../shared/interfaces/shifts.interface.ts | 0 .../modules/shared/selects/expenses.select.ts | 0 .../shared/selects/pay-periods.select.ts | 0 .../modules/shared/selects/shifts.select.ts | 0 .../modules/shared/shared.module.ts | 0 .../shared/types/upsert-actions.types.ts | 0 .../utils/resolve-bank-type-id.utils.ts | 0 .../shared/utils/resolve-email-id.utils.ts | 0 .../shared/utils/resolve-full-name.utils.ts | 0 .../shared/utils/resolve-shifts-id.utils.ts | 0 .../shared/utils/resolve-timesheet.utils.ts | 2 +- .../controller/schedule-presets.controller.ts | 2 +- .../dtos/create-schedule-preset-shifts.dto.ts | 0 .../dtos/create-schedule-presets.dto.ts | 0 .../mappers/schedule-presets.mappers.ts | 0 .../schedule-presets.module.ts | 2 +- .../schedule-presets-apply.service.ts | 2 +- .../schedule-presets-command.service.ts | 6 +- .../schedule-presets-query.service.ts | 2 +- .../types/schedule-presets.types.ts | 0 .../shifts/controllers/shift.controller.ts | 0 .../time-tracker/shifts/dtos/get-shift.dto.ts | 0 .../time-tracker/shifts/dtos/shift.dto.ts | 0 .../shifts/dtos/update-shift.dto.ts | 0 .../helpers/shifts-date-time-helpers.ts | 0 .../services/shifts-archival.service.ts | 0 .../shifts/services/shifts-get.service.ts | 0 .../shifts/services/shifts-upsert.service.ts | 2 +- .../time-tracker/shifts/shifts.module.ts | 2 +- .../get-shift-overview.dto.ts | 0 .../shifts-command.service.ts | 0 .../shifts-overview-row.interface.ts | 0 .../shifts-query.service.ts | 0 .../shifts-upsert.types.ts | 0 .../shifts.controller.ts | 0 .../~misc_deprecated-files/shifts.helpers.ts | 0 .../~misc_deprecated-files/shifts.utils.ts | 0 .../upsert-shift.dto.ts | 0 .../controllers/timesheet.controller.ts | 2 +- .../timesheets/dtos/timesheet.dto.ts | 0 .../helpers/timesheets-date-time-helpers.ts | 0 .../services/timesheet-approval.service.ts | 0 .../services/timesheet-archive.service.ts | 0 .../timesheet-get-overview.service.ts | 0 .../timesheets/timesheets.module.ts | 8 +- .../create-timesheet.dto.ts | 0 .../search-timesheet.dto.ts | 0 .../timesheet-period.dto.ts | 0 .../timesheet.helpers.ts | 0 .../timesheet.mappers.ts | 0 .../timesheet.selectors.ts | 0 .../~misc_deprecated-files/timesheet.types.ts | 0 .../~misc_deprecated-files/timesheet.utils.ts | 0 .../timesheets-command.service.ts | 0 .../timesheets-query.service.ts | 0 .../timesheets.controller.ts | 0 .../time-and-attendance.module.ts | 42 ++ 134 files changed, 880 insertions(+), 1084 deletions(-) create mode 100644 src/identity-and-account/employees/employees.module.ts delete mode 100644 src/modules/expenses/expenses.module.ts delete mode 100644 src/modules/timesheets/timesheets.module.ts rename src/{Time_And_Attendance => time-and-attendance}/domains/business-logics.module.ts (100%) rename src/{Time_And_Attendance => time-and-attendance}/domains/services/after-hours.service.ts (100%) rename src/{Time_And_Attendance => time-and-attendance}/domains/services/holiday.service.ts (100%) rename src/{Time_And_Attendance => time-and-attendance}/domains/services/mileage.service.ts (100%) rename src/{Time_And_Attendance => time-and-attendance}/domains/services/overtime.service.ts (100%) rename src/{Time_And_Attendance => time-and-attendance}/domains/services/sick-leave.service.ts (100%) rename src/{Time_And_Attendance => time-and-attendance}/domains/services/vacation.service.ts (100%) rename src/{ => time-and-attendance}/modules/expenses/controllers/expense.controller.ts (91%) rename src/{ => time-and-attendance}/modules/expenses/dtos/expense.dto.ts (100%) rename src/{ => time-and-attendance}/modules/expenses/dtos/get-expense.dto.ts (100%) rename src/{ => time-and-attendance}/modules/expenses/dtos/update-expense.dto.ts (100%) create mode 100644 src/time-and-attendance/modules/expenses/expenses.module.ts rename src/{ => time-and-attendance}/modules/expenses/helpers/expenses-date-time-helpers.ts (100%) rename src/{ => time-and-attendance}/modules/expenses/services/expense-upsert.service.ts (100%) rename src/{ => time-and-attendance}/modules/expenses/services/expenses-archival.service.ts (100%) rename src/{ => time-and-attendance}/modules/expenses/~misc_deprecated-files/create-expense.dto.ts (100%) rename src/{ => time-and-attendance}/modules/expenses/~misc_deprecated-files/expenses-command.service.ts (100%) rename src/{ => time-and-attendance}/modules/expenses/~misc_deprecated-files/expenses-query.service.ts (100%) rename src/{ => time-and-attendance}/modules/expenses/~misc_deprecated-files/expenses.controller.ts (100%) rename src/{ => time-and-attendance}/modules/expenses/~misc_deprecated-files/expenses.types.interfaces.ts (100%) rename src/{ => time-and-attendance}/modules/expenses/~misc_deprecated-files/expenses.utils.ts (100%) rename src/{ => time-and-attendance}/modules/expenses/~misc_deprecated-files/search-expense.dto.ts (100%) rename src/{ => time-and-attendance}/modules/expenses/~misc_deprecated-files/update-expense.dto.ts (100%) rename src/{ => time-and-attendance}/modules/expenses/~misc_deprecated-files/upsert-expense.dto.ts (100%) rename src/{Time_And_Attendance => time-and-attendance}/modules/leave-requests/controllers/leave-requests.controller.ts (100%) rename src/{Time_And_Attendance => time-and-attendance}/modules/leave-requests/dtos/leave-request-view.dto.ts (100%) rename src/{Time_And_Attendance => time-and-attendance}/modules/leave-requests/dtos/upsert-leave-request.dto.ts (100%) rename src/{Time_And_Attendance => time-and-attendance}/modules/leave-requests/leave-requests.module.ts (100%) rename src/{Time_And_Attendance => time-and-attendance}/modules/leave-requests/mappers/leave-requests-archive.mapper.ts (100%) rename src/{Time_And_Attendance => time-and-attendance}/modules/leave-requests/mappers/leave-requests.mapper.ts (100%) rename src/{Time_And_Attendance => time-and-attendance}/modules/leave-requests/services/holiday-leave-requests.service.ts (100%) rename src/{Time_And_Attendance => time-and-attendance}/modules/leave-requests/services/leave-request.service.ts (100%) rename src/{Time_And_Attendance => time-and-attendance}/modules/leave-requests/services/sick-leave-requests.service.ts (100%) rename src/{Time_And_Attendance => time-and-attendance}/modules/leave-requests/services/vacation-leave-requests.service.ts (100%) rename src/{Time_And_Attendance => time-and-attendance}/modules/leave-requests/utils/leave-request.transform.ts (100%) rename src/{Time_And_Attendance => time-and-attendance}/modules/leave-requests/utils/leave-request.util.ts (100%) rename src/{Time_And_Attendance => time-and-attendance}/modules/leave-requests/utils/leave-requests-archive.select.ts (100%) rename src/{Time_And_Attendance => time-and-attendance}/modules/leave-requests/utils/leave-requests.select.ts (100%) rename src/{Time_And_Attendance => time-and-attendance}/modules/pay-period/controllers/pay-periods.controller.ts (100%) rename src/{Time_And_Attendance => time-and-attendance}/modules/pay-period/dtos/bulk-crew-approval.dto.ts (100%) rename src/{Time_And_Attendance => time-and-attendance}/modules/pay-period/dtos/bundle-pay-period.dto.ts (100%) rename src/{Time_And_Attendance => time-and-attendance}/modules/pay-period/dtos/overview-employee-period.dto.ts (100%) rename src/{Time_And_Attendance => time-and-attendance}/modules/pay-period/dtos/overview-pay-period.dto.ts (100%) rename src/{Time_And_Attendance => time-and-attendance}/modules/pay-period/dtos/pay-period.dto.ts (100%) rename src/{Time_And_Attendance => time-and-attendance}/modules/pay-period/mappers/pay-periods.mapper.ts (100%) rename src/{Time_And_Attendance => time-and-attendance}/modules/pay-period/pay-periods.module.ts (68%) rename src/{Time_And_Attendance => time-and-attendance}/modules/pay-period/services/pay-periods-command.service.ts (100%) rename src/{Time_And_Attendance => time-and-attendance}/modules/pay-period/services/pay-periods-query.service.ts (100%) rename src/{Time_And_Attendance => time-and-attendance}/modules/pay-period/utils/pay-year.util.ts (100%) rename src/{Time_And_Attendance => time-and-attendance}/modules/shared/constants/date-time.constant.ts (100%) rename src/{Time_And_Attendance => time-and-attendance}/modules/shared/constants/regex.constant.ts (100%) rename src/{Time_And_Attendance => time-and-attendance}/modules/shared/constants/utils.constant.ts (100%) rename src/{Time_And_Attendance => time-and-attendance}/modules/shared/helpers/date-time.helpers.ts (100%) rename src/{Time_And_Attendance => time-and-attendance}/modules/shared/interfaces/shifts.interface.ts (100%) rename src/{Time_And_Attendance => time-and-attendance}/modules/shared/selects/expenses.select.ts (100%) rename src/{Time_And_Attendance => time-and-attendance}/modules/shared/selects/pay-periods.select.ts (100%) rename src/{Time_And_Attendance => time-and-attendance}/modules/shared/selects/shifts.select.ts (100%) rename src/{Time_And_Attendance => time-and-attendance}/modules/shared/shared.module.ts (100%) rename src/{Time_And_Attendance => time-and-attendance}/modules/shared/types/upsert-actions.types.ts (100%) rename src/{Time_And_Attendance => time-and-attendance}/modules/shared/utils/resolve-bank-type-id.utils.ts (100%) rename src/{Time_And_Attendance => time-and-attendance}/modules/shared/utils/resolve-email-id.utils.ts (100%) rename src/{Time_And_Attendance => time-and-attendance}/modules/shared/utils/resolve-full-name.utils.ts (100%) rename src/{Time_And_Attendance => time-and-attendance}/modules/shared/utils/resolve-shifts-id.utils.ts (100%) rename src/{Time_And_Attendance => time-and-attendance}/modules/shared/utils/resolve-timesheet.utils.ts (94%) rename src/{Time_And_Attendance => time-and-attendance}/modules/time-tracker/schedule-presets/controller/schedule-presets.controller.ts (96%) rename src/{Time_And_Attendance => time-and-attendance}/modules/time-tracker/schedule-presets/dtos/create-schedule-preset-shifts.dto.ts (100%) rename src/{Time_And_Attendance => time-and-attendance}/modules/time-tracker/schedule-presets/dtos/create-schedule-presets.dto.ts (100%) rename src/{Time_And_Attendance => time-and-attendance}/modules/time-tracker/schedule-presets/mappers/schedule-presets.mappers.ts (100%) rename src/{Time_And_Attendance => time-and-attendance}/modules/time-tracker/schedule-presets/schedule-presets.module.ts (91%) rename src/{Time_And_Attendance => time-and-attendance}/modules/time-tracker/schedule-presets/services/schedule-presets-apply.service.ts (98%) rename src/{Time_And_Attendance => time-and-attendance}/modules/time-tracker/schedule-presets/services/schedule-presets-command.service.ts (98%) rename src/{Time_And_Attendance => time-and-attendance}/modules/time-tracker/schedule-presets/services/schedule-presets-query.service.ts (96%) rename src/{Time_And_Attendance => time-and-attendance}/modules/time-tracker/schedule-presets/types/schedule-presets.types.ts (100%) rename src/{Time_And_Attendance => time-and-attendance}/modules/time-tracker/shifts/controllers/shift.controller.ts (100%) rename src/{Time_And_Attendance => time-and-attendance}/modules/time-tracker/shifts/dtos/get-shift.dto.ts (100%) rename src/{Time_And_Attendance => time-and-attendance}/modules/time-tracker/shifts/dtos/shift.dto.ts (100%) rename src/{Time_And_Attendance => time-and-attendance}/modules/time-tracker/shifts/dtos/update-shift.dto.ts (100%) rename src/{Time_And_Attendance => time-and-attendance}/modules/time-tracker/shifts/helpers/shifts-date-time-helpers.ts (100%) rename src/{Time_And_Attendance => time-and-attendance}/modules/time-tracker/shifts/services/shifts-archival.service.ts (100%) rename src/{Time_And_Attendance => time-and-attendance}/modules/time-tracker/shifts/services/shifts-get.service.ts (100%) rename src/{Time_And_Attendance => time-and-attendance}/modules/time-tracker/shifts/services/shifts-upsert.service.ts (99%) rename src/{Time_And_Attendance => time-and-attendance}/modules/time-tracker/shifts/shifts.module.ts (89%) rename src/{Time_And_Attendance => time-and-attendance}/modules/time-tracker/shifts/~misc_deprecated-files/get-shift-overview.dto.ts (100%) rename src/{Time_And_Attendance => time-and-attendance}/modules/time-tracker/shifts/~misc_deprecated-files/shifts-command.service.ts (100%) rename src/{Time_And_Attendance => time-and-attendance}/modules/time-tracker/shifts/~misc_deprecated-files/shifts-overview-row.interface.ts (100%) rename src/{Time_And_Attendance => time-and-attendance}/modules/time-tracker/shifts/~misc_deprecated-files/shifts-query.service.ts (100%) rename src/{Time_And_Attendance => time-and-attendance}/modules/time-tracker/shifts/~misc_deprecated-files/shifts-upsert.types.ts (100%) rename src/{Time_And_Attendance => time-and-attendance}/modules/time-tracker/shifts/~misc_deprecated-files/shifts.controller.ts (100%) rename src/{Time_And_Attendance => time-and-attendance}/modules/time-tracker/shifts/~misc_deprecated-files/shifts.helpers.ts (100%) rename src/{Time_And_Attendance => time-and-attendance}/modules/time-tracker/shifts/~misc_deprecated-files/shifts.utils.ts (100%) rename src/{Time_And_Attendance => time-and-attendance}/modules/time-tracker/shifts/~misc_deprecated-files/upsert-shift.dto.ts (100%) rename src/{Time_And_Attendance => time-and-attendance}/modules/time-tracker/timesheets/controllers/timesheet.controller.ts (94%) rename src/{Time_And_Attendance => time-and-attendance}/modules/time-tracker/timesheets/dtos/timesheet.dto.ts (100%) rename src/{Time_And_Attendance => time-and-attendance}/modules/time-tracker/timesheets/helpers/timesheets-date-time-helpers.ts (100%) rename src/{Time_And_Attendance => time-and-attendance}/modules/time-tracker/timesheets/services/timesheet-approval.service.ts (100%) rename src/{Time_And_Attendance => time-and-attendance}/modules/time-tracker/timesheets/services/timesheet-archive.service.ts (100%) rename src/{Time_And_Attendance => time-and-attendance}/modules/time-tracker/timesheets/services/timesheet-get-overview.service.ts (100%) rename src/{Time_And_Attendance => time-and-attendance}/modules/time-tracker/timesheets/timesheets.module.ts (70%) rename src/{Time_And_Attendance => time-and-attendance}/modules/time-tracker/timesheets/~misc_deprecated-files/create-timesheet.dto.ts (100%) rename src/{Time_And_Attendance => time-and-attendance}/modules/time-tracker/timesheets/~misc_deprecated-files/search-timesheet.dto.ts (100%) rename src/{Time_And_Attendance => time-and-attendance}/modules/time-tracker/timesheets/~misc_deprecated-files/timesheet-period.dto.ts (100%) rename src/{Time_And_Attendance => time-and-attendance}/modules/time-tracker/timesheets/~misc_deprecated-files/timesheet.helpers.ts (100%) rename src/{Time_And_Attendance => time-and-attendance}/modules/time-tracker/timesheets/~misc_deprecated-files/timesheet.mappers.ts (100%) rename src/{Time_And_Attendance => time-and-attendance}/modules/time-tracker/timesheets/~misc_deprecated-files/timesheet.selectors.ts (100%) rename src/{Time_And_Attendance => time-and-attendance}/modules/time-tracker/timesheets/~misc_deprecated-files/timesheet.types.ts (100%) rename src/{Time_And_Attendance => time-and-attendance}/modules/time-tracker/timesheets/~misc_deprecated-files/timesheet.utils.ts (100%) rename src/{Time_And_Attendance => time-and-attendance}/modules/time-tracker/timesheets/~misc_deprecated-files/timesheets-command.service.ts (100%) rename src/{Time_And_Attendance => time-and-attendance}/modules/time-tracker/timesheets/~misc_deprecated-files/timesheets-query.service.ts (100%) rename src/{Time_And_Attendance => time-and-attendance}/modules/time-tracker/timesheets/~misc_deprecated-files/timesheets.controller.ts (100%) create mode 100644 src/time-and-attendance/time-and-attendance.module.ts diff --git a/docs/swagger/swagger-spec.json b/docs/swagger/swagger-spec.json index 15ab59d..0462102 100644 --- a/docs/swagger/swagger-spec.json +++ b/docs/swagger/swagger-spec.json @@ -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": {} } } } diff --git a/prisma/mock-seeds-scripts/04-customers.ts b/prisma/mock-seeds-scripts/04-customers.ts index aaa63b6..b8319cf 100644 --- a/prisma/mock-seeds-scripts/04-customers.ts +++ b/prisma/mock-seeds-scripts/04-customers.ts @@ -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()); diff --git a/prisma/mock-seeds-scripts/05-employees-archive.ts b/prisma/mock-seeds-scripts/05-employees-archive.ts index 1687b23..b352a7f 100644 --- a/prisma/mock-seeds-scripts/05-employees-archive.ts +++ b/prisma/mock-seeds-scripts/05-employees-archive.ts @@ -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()); diff --git a/prisma/mock-seeds-scripts/06-customers-archive.ts b/prisma/mock-seeds-scripts/06-customers-archive.ts index 31a7d01..0c2a382 100644 --- a/prisma/mock-seeds-scripts/06-customers-archive.ts +++ b/prisma/mock-seeds-scripts/06-customers-archive.ts @@ -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()); diff --git a/prisma/mock-seeds-scripts/08-leave-requests-archive.ts b/prisma/mock-seeds-scripts/08-leave-requests-archive.ts index 45b1d43..0170635 100644 --- a/prisma/mock-seeds-scripts/08-leave-requests-archive.ts +++ b/prisma/mock-seeds-scripts/08-leave-requests-archive.ts @@ -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� (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. Excute 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� trouv�. Ex�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'). Vrifie 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� 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()); \ No newline at end of file +// main().finally(() => prisma.$disconnect()); \ No newline at end of file diff --git a/prisma/mock-seeds-scripts/11-shifts-archive.ts b/prisma/mock-seeds-scripts/11-shifts-archive.ts index 1c3f5e8..4259359 100644 --- a/prisma/mock-seeds-scripts/11-shifts-archive.ts +++ b/prisma/mock-seeds-scripts/11-shifts-archive.ts @@ -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()); diff --git a/prisma/mock-seeds-scripts/13-expenses-archive.ts b/prisma/mock-seeds-scripts/13-expenses-archive.ts index d8e35a2..c56520e 100644 --- a/prisma/mock-seeds-scripts/13-expenses-archive.ts +++ b/prisma/mock-seeds-scripts/13-expenses-archive.ts @@ -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()); diff --git a/src/app.module.ts b/src/app.module.ts index 60c2767..901f74e 100644 --- a/src/app.module.ts +++ b/src/app.module.ts @@ -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 diff --git a/src/identity-and-account/employees/employees.module.ts b/src/identity-and-account/employees/employees.module.ts new file mode 100644 index 0000000..7ce6f04 --- /dev/null +++ b/src/identity-and-account/employees/employees.module.ts @@ -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 {} diff --git a/src/modules/archival/controllers/employees-archive.controller.ts b/src/modules/archival/controllers/employees-archive.controller.ts index 375a351..776c6fa 100644 --- a/src/modules/archival/controllers/employees-archive.controller.ts +++ b/src/modules/archival/controllers/employees-archive.controller.ts @@ -1,33 +1,33 @@ -import { Controller, Get, NotFoundException, Param, ParseIntPipe, UseGuards } from "@nestjs/common"; -import { ApiOperation, ApiResponse, ApiTags } from "@nestjs/swagger"; -import { RolesAllowed } from "src/common/decorators/roles.decorators"; -import { 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 { - 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 { +// 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 { - 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 { +// try{ +// return await this.employeesArchiveService.findOneArchived(id); +// }catch { +// throw new NotFoundException(`Archived employee #${id} not found`); +// } +// } -} \ No newline at end of file +// } \ No newline at end of file diff --git a/src/modules/archival/controllers/expenses-archive.controller.ts b/src/modules/archival/controllers/expenses-archive.controller.ts index e6bd935..f256b82 100644 --- a/src/modules/archival/controllers/expenses-archive.controller.ts +++ b/src/modules/archival/controllers/expenses-archive.controller.ts @@ -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() diff --git a/src/modules/archival/controllers/shifts-archive.controller.ts b/src/modules/archival/controllers/shifts-archive.controller.ts index 463ea4a..7c88288 100644 --- a/src/modules/archival/controllers/shifts-archive.controller.ts +++ b/src/modules/archival/controllers/shifts-archive.controller.ts @@ -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() diff --git a/src/modules/archival/controllers/timesheets-archive.controller.ts b/src/modules/archival/controllers/timesheets-archive.controller.ts index 9be0116..3a8f0a2 100644 --- a/src/modules/archival/controllers/timesheets-archive.controller.ts +++ b/src/modules/archival/controllers/timesheets-archive.controller.ts @@ -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() diff --git a/src/modules/archival/services/archival.service.ts b/src/modules/archival/services/archival.service.ts index 898ab51..ded45eb 100644 --- a/src/modules/archival/services/archival.service.ts +++ b/src/modules/archival/services/archival.service.ts @@ -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 { diff --git a/src/modules/customers/controllers/customers.controller.ts b/src/modules/customers/controllers/customers.controller.ts index 713ebde..c066342 100644 --- a/src/modules/customers/controllers/customers.controller.ts +++ b/src/modules/customers/controllers/customers.controller.ts @@ -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 { - // 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 { +// // 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 { - // 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 { +// // 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 { - // 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 { +// // 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 { - // 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 { +// // 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{ - // 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{ +// // return this.customersService.remove(id); +// // } +// } diff --git a/src/modules/customers/customers.module.ts b/src/modules/customers/customers.module.ts index c9e3f9d..cccb363 100644 --- a/src/modules/customers/customers.module.ts +++ b/src/modules/customers/customers.module.ts @@ -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 {} \ No newline at end of file +// @Module({ +// controllers:[CustomersController], +// providers:[CustomersService], +// }) +// export class CustomersModule {} \ No newline at end of file diff --git a/src/modules/employees/controllers/employees.controller.ts b/src/modules/employees/controllers/employees.controller.ts index e647547..4828d91 100644 --- a/src/modules/employees/controllers/employees.controller.ts +++ b/src/modules/employees/controllers/employees.controller.ts @@ -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 { - 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 { +// 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 { - // 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 { - // 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 { +// // 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 { +// // 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 { - // 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 { +// // 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 { - 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 { +// 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 { - // 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 { +// // return this.employeesService.remove(email); +// // } -} +// } diff --git a/src/modules/employees/employees.module.ts b/src/modules/employees/employees.module.ts index 2fd40ee..676f4b0 100644 --- a/src/modules/employees/employees.module.ts +++ b/src/modules/employees/employees.module.ts @@ -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 {} diff --git a/src/modules/employees/services/employees-archival.service.ts b/src/modules/employees/services/employees-archival.service.ts index b13fa74..6046e94 100644 --- a/src/modules/employees/services/employees-archival.service.ts +++ b/src/modules/employees/services/employees-archival.service.ts @@ -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 { - // 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 { +// // 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 { - 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 { +// 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 { - // 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 { +// // 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 { - return this.prisma.employeesArchive.findMany(); - } +// //fetches all archived employees +// async findAllArchived(): Promise { +// return this.prisma.employeesArchive.findMany(); +// } - //fetches an archived employee - async findOneArchived(id: number): Promise { - return this.prisma.employeesArchive.findUniqueOrThrow({ where: { id } }); - } +// //fetches an archived employee +// async findOneArchived(id: number): Promise { +// return this.prisma.employeesArchive.findUniqueOrThrow({ where: { id } }); +// } -} +// } diff --git a/src/modules/expenses/expenses.module.ts b/src/modules/expenses/expenses.module.ts deleted file mode 100644 index 85f62cb..0000000 --- a/src/modules/expenses/expenses.module.ts +++ /dev/null @@ -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 {} \ No newline at end of file diff --git a/src/modules/exports/csv-exports.module.ts b/src/modules/exports/csv-exports.module.ts index 0c9f00b..fa0c7f1 100644 --- a/src/modules/exports/csv-exports.module.ts +++ b/src/modules/exports/csv-exports.module.ts @@ -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], diff --git a/src/modules/preferences/preferences.module.ts b/src/modules/preferences/preferences.module.ts index 59031ba..65deb82 100644 --- a/src/modules/preferences/preferences.module.ts +++ b/src/modules/preferences/preferences.module.ts @@ -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], diff --git a/src/modules/preferences/services/preferences.service.ts b/src/modules/preferences/services/preferences.service.ts index 2677573..2ff02ac 100644 --- a/src/modules/preferences/services/preferences.service.ts +++ b/src/modules/preferences/services/preferences.service.ts @@ -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 { diff --git a/src/modules/timesheets/timesheets.module.ts b/src/modules/timesheets/timesheets.module.ts deleted file mode 100644 index e1c997e..0000000 --- a/src/modules/timesheets/timesheets.module.ts +++ /dev/null @@ -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 {} diff --git a/src/Time_And_Attendance/domains/business-logics.module.ts b/src/time-and-attendance/domains/business-logics.module.ts similarity index 100% rename from src/Time_And_Attendance/domains/business-logics.module.ts rename to src/time-and-attendance/domains/business-logics.module.ts diff --git a/src/Time_And_Attendance/domains/services/after-hours.service.ts b/src/time-and-attendance/domains/services/after-hours.service.ts similarity index 100% rename from src/Time_And_Attendance/domains/services/after-hours.service.ts rename to src/time-and-attendance/domains/services/after-hours.service.ts diff --git a/src/Time_And_Attendance/domains/services/holiday.service.ts b/src/time-and-attendance/domains/services/holiday.service.ts similarity index 100% rename from src/Time_And_Attendance/domains/services/holiday.service.ts rename to src/time-and-attendance/domains/services/holiday.service.ts diff --git a/src/Time_And_Attendance/domains/services/mileage.service.ts b/src/time-and-attendance/domains/services/mileage.service.ts similarity index 100% rename from src/Time_And_Attendance/domains/services/mileage.service.ts rename to src/time-and-attendance/domains/services/mileage.service.ts diff --git a/src/Time_And_Attendance/domains/services/overtime.service.ts b/src/time-and-attendance/domains/services/overtime.service.ts similarity index 100% rename from src/Time_And_Attendance/domains/services/overtime.service.ts rename to src/time-and-attendance/domains/services/overtime.service.ts diff --git a/src/Time_And_Attendance/domains/services/sick-leave.service.ts b/src/time-and-attendance/domains/services/sick-leave.service.ts similarity index 100% rename from src/Time_And_Attendance/domains/services/sick-leave.service.ts rename to src/time-and-attendance/domains/services/sick-leave.service.ts diff --git a/src/Time_And_Attendance/domains/services/vacation.service.ts b/src/time-and-attendance/domains/services/vacation.service.ts similarity index 100% rename from src/Time_And_Attendance/domains/services/vacation.service.ts rename to src/time-and-attendance/domains/services/vacation.service.ts diff --git a/src/modules/expenses/controllers/expense.controller.ts b/src/time-and-attendance/modules/expenses/controllers/expense.controller.ts similarity index 91% rename from src/modules/expenses/controllers/expense.controller.ts rename to src/time-and-attendance/modules/expenses/controllers/expense.controller.ts index e5e5f56..b7a3736 100644 --- a/src/modules/expenses/controllers/expense.controller.ts +++ b/src/time-and-attendance/modules/expenses/controllers/expense.controller.ts @@ -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') diff --git a/src/modules/expenses/dtos/expense.dto.ts b/src/time-and-attendance/modules/expenses/dtos/expense.dto.ts similarity index 100% rename from src/modules/expenses/dtos/expense.dto.ts rename to src/time-and-attendance/modules/expenses/dtos/expense.dto.ts diff --git a/src/modules/expenses/dtos/get-expense.dto.ts b/src/time-and-attendance/modules/expenses/dtos/get-expense.dto.ts similarity index 100% rename from src/modules/expenses/dtos/get-expense.dto.ts rename to src/time-and-attendance/modules/expenses/dtos/get-expense.dto.ts diff --git a/src/modules/expenses/dtos/update-expense.dto.ts b/src/time-and-attendance/modules/expenses/dtos/update-expense.dto.ts similarity index 100% rename from src/modules/expenses/dtos/update-expense.dto.ts rename to src/time-and-attendance/modules/expenses/dtos/update-expense.dto.ts diff --git a/src/time-and-attendance/modules/expenses/expenses.module.ts b/src/time-and-attendance/modules/expenses/expenses.module.ts new file mode 100644 index 0000000..923ce3e --- /dev/null +++ b/src/time-and-attendance/modules/expenses/expenses.module.ts @@ -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 {} \ No newline at end of file diff --git a/src/modules/expenses/helpers/expenses-date-time-helpers.ts b/src/time-and-attendance/modules/expenses/helpers/expenses-date-time-helpers.ts similarity index 100% rename from src/modules/expenses/helpers/expenses-date-time-helpers.ts rename to src/time-and-attendance/modules/expenses/helpers/expenses-date-time-helpers.ts diff --git a/src/modules/expenses/services/expense-upsert.service.ts b/src/time-and-attendance/modules/expenses/services/expense-upsert.service.ts similarity index 100% rename from src/modules/expenses/services/expense-upsert.service.ts rename to src/time-and-attendance/modules/expenses/services/expense-upsert.service.ts diff --git a/src/modules/expenses/services/expenses-archival.service.ts b/src/time-and-attendance/modules/expenses/services/expenses-archival.service.ts similarity index 100% rename from src/modules/expenses/services/expenses-archival.service.ts rename to src/time-and-attendance/modules/expenses/services/expenses-archival.service.ts diff --git a/src/modules/expenses/~misc_deprecated-files/create-expense.dto.ts b/src/time-and-attendance/modules/expenses/~misc_deprecated-files/create-expense.dto.ts similarity index 100% rename from src/modules/expenses/~misc_deprecated-files/create-expense.dto.ts rename to src/time-and-attendance/modules/expenses/~misc_deprecated-files/create-expense.dto.ts diff --git a/src/modules/expenses/~misc_deprecated-files/expenses-command.service.ts b/src/time-and-attendance/modules/expenses/~misc_deprecated-files/expenses-command.service.ts similarity index 100% rename from src/modules/expenses/~misc_deprecated-files/expenses-command.service.ts rename to src/time-and-attendance/modules/expenses/~misc_deprecated-files/expenses-command.service.ts diff --git a/src/modules/expenses/~misc_deprecated-files/expenses-query.service.ts b/src/time-and-attendance/modules/expenses/~misc_deprecated-files/expenses-query.service.ts similarity index 100% rename from src/modules/expenses/~misc_deprecated-files/expenses-query.service.ts rename to src/time-and-attendance/modules/expenses/~misc_deprecated-files/expenses-query.service.ts diff --git a/src/modules/expenses/~misc_deprecated-files/expenses.controller.ts b/src/time-and-attendance/modules/expenses/~misc_deprecated-files/expenses.controller.ts similarity index 100% rename from src/modules/expenses/~misc_deprecated-files/expenses.controller.ts rename to src/time-and-attendance/modules/expenses/~misc_deprecated-files/expenses.controller.ts diff --git a/src/modules/expenses/~misc_deprecated-files/expenses.types.interfaces.ts b/src/time-and-attendance/modules/expenses/~misc_deprecated-files/expenses.types.interfaces.ts similarity index 100% rename from src/modules/expenses/~misc_deprecated-files/expenses.types.interfaces.ts rename to src/time-and-attendance/modules/expenses/~misc_deprecated-files/expenses.types.interfaces.ts diff --git a/src/modules/expenses/~misc_deprecated-files/expenses.utils.ts b/src/time-and-attendance/modules/expenses/~misc_deprecated-files/expenses.utils.ts similarity index 100% rename from src/modules/expenses/~misc_deprecated-files/expenses.utils.ts rename to src/time-and-attendance/modules/expenses/~misc_deprecated-files/expenses.utils.ts diff --git a/src/modules/expenses/~misc_deprecated-files/search-expense.dto.ts b/src/time-and-attendance/modules/expenses/~misc_deprecated-files/search-expense.dto.ts similarity index 100% rename from src/modules/expenses/~misc_deprecated-files/search-expense.dto.ts rename to src/time-and-attendance/modules/expenses/~misc_deprecated-files/search-expense.dto.ts diff --git a/src/modules/expenses/~misc_deprecated-files/update-expense.dto.ts b/src/time-and-attendance/modules/expenses/~misc_deprecated-files/update-expense.dto.ts similarity index 100% rename from src/modules/expenses/~misc_deprecated-files/update-expense.dto.ts rename to src/time-and-attendance/modules/expenses/~misc_deprecated-files/update-expense.dto.ts diff --git a/src/modules/expenses/~misc_deprecated-files/upsert-expense.dto.ts b/src/time-and-attendance/modules/expenses/~misc_deprecated-files/upsert-expense.dto.ts similarity index 100% rename from src/modules/expenses/~misc_deprecated-files/upsert-expense.dto.ts rename to src/time-and-attendance/modules/expenses/~misc_deprecated-files/upsert-expense.dto.ts diff --git a/src/Time_And_Attendance/modules/leave-requests/controllers/leave-requests.controller.ts b/src/time-and-attendance/modules/leave-requests/controllers/leave-requests.controller.ts similarity index 100% rename from src/Time_And_Attendance/modules/leave-requests/controllers/leave-requests.controller.ts rename to src/time-and-attendance/modules/leave-requests/controllers/leave-requests.controller.ts diff --git a/src/Time_And_Attendance/modules/leave-requests/dtos/leave-request-view.dto.ts b/src/time-and-attendance/modules/leave-requests/dtos/leave-request-view.dto.ts similarity index 100% rename from src/Time_And_Attendance/modules/leave-requests/dtos/leave-request-view.dto.ts rename to src/time-and-attendance/modules/leave-requests/dtos/leave-request-view.dto.ts diff --git a/src/Time_And_Attendance/modules/leave-requests/dtos/upsert-leave-request.dto.ts b/src/time-and-attendance/modules/leave-requests/dtos/upsert-leave-request.dto.ts similarity index 100% rename from src/Time_And_Attendance/modules/leave-requests/dtos/upsert-leave-request.dto.ts rename to src/time-and-attendance/modules/leave-requests/dtos/upsert-leave-request.dto.ts diff --git a/src/Time_And_Attendance/modules/leave-requests/leave-requests.module.ts b/src/time-and-attendance/modules/leave-requests/leave-requests.module.ts similarity index 100% rename from src/Time_And_Attendance/modules/leave-requests/leave-requests.module.ts rename to src/time-and-attendance/modules/leave-requests/leave-requests.module.ts diff --git a/src/Time_And_Attendance/modules/leave-requests/mappers/leave-requests-archive.mapper.ts b/src/time-and-attendance/modules/leave-requests/mappers/leave-requests-archive.mapper.ts similarity index 100% rename from src/Time_And_Attendance/modules/leave-requests/mappers/leave-requests-archive.mapper.ts rename to src/time-and-attendance/modules/leave-requests/mappers/leave-requests-archive.mapper.ts diff --git a/src/Time_And_Attendance/modules/leave-requests/mappers/leave-requests.mapper.ts b/src/time-and-attendance/modules/leave-requests/mappers/leave-requests.mapper.ts similarity index 100% rename from src/Time_And_Attendance/modules/leave-requests/mappers/leave-requests.mapper.ts rename to src/time-and-attendance/modules/leave-requests/mappers/leave-requests.mapper.ts diff --git a/src/Time_And_Attendance/modules/leave-requests/services/holiday-leave-requests.service.ts b/src/time-and-attendance/modules/leave-requests/services/holiday-leave-requests.service.ts similarity index 100% rename from src/Time_And_Attendance/modules/leave-requests/services/holiday-leave-requests.service.ts rename to src/time-and-attendance/modules/leave-requests/services/holiday-leave-requests.service.ts diff --git a/src/Time_And_Attendance/modules/leave-requests/services/leave-request.service.ts b/src/time-and-attendance/modules/leave-requests/services/leave-request.service.ts similarity index 100% rename from src/Time_And_Attendance/modules/leave-requests/services/leave-request.service.ts rename to src/time-and-attendance/modules/leave-requests/services/leave-request.service.ts diff --git a/src/Time_And_Attendance/modules/leave-requests/services/sick-leave-requests.service.ts b/src/time-and-attendance/modules/leave-requests/services/sick-leave-requests.service.ts similarity index 100% rename from src/Time_And_Attendance/modules/leave-requests/services/sick-leave-requests.service.ts rename to src/time-and-attendance/modules/leave-requests/services/sick-leave-requests.service.ts diff --git a/src/Time_And_Attendance/modules/leave-requests/services/vacation-leave-requests.service.ts b/src/time-and-attendance/modules/leave-requests/services/vacation-leave-requests.service.ts similarity index 100% rename from src/Time_And_Attendance/modules/leave-requests/services/vacation-leave-requests.service.ts rename to src/time-and-attendance/modules/leave-requests/services/vacation-leave-requests.service.ts diff --git a/src/Time_And_Attendance/modules/leave-requests/utils/leave-request.transform.ts b/src/time-and-attendance/modules/leave-requests/utils/leave-request.transform.ts similarity index 100% rename from src/Time_And_Attendance/modules/leave-requests/utils/leave-request.transform.ts rename to src/time-and-attendance/modules/leave-requests/utils/leave-request.transform.ts diff --git a/src/Time_And_Attendance/modules/leave-requests/utils/leave-request.util.ts b/src/time-and-attendance/modules/leave-requests/utils/leave-request.util.ts similarity index 100% rename from src/Time_And_Attendance/modules/leave-requests/utils/leave-request.util.ts rename to src/time-and-attendance/modules/leave-requests/utils/leave-request.util.ts diff --git a/src/Time_And_Attendance/modules/leave-requests/utils/leave-requests-archive.select.ts b/src/time-and-attendance/modules/leave-requests/utils/leave-requests-archive.select.ts similarity index 100% rename from src/Time_And_Attendance/modules/leave-requests/utils/leave-requests-archive.select.ts rename to src/time-and-attendance/modules/leave-requests/utils/leave-requests-archive.select.ts diff --git a/src/Time_And_Attendance/modules/leave-requests/utils/leave-requests.select.ts b/src/time-and-attendance/modules/leave-requests/utils/leave-requests.select.ts similarity index 100% rename from src/Time_And_Attendance/modules/leave-requests/utils/leave-requests.select.ts rename to src/time-and-attendance/modules/leave-requests/utils/leave-requests.select.ts diff --git a/src/Time_And_Attendance/modules/pay-period/controllers/pay-periods.controller.ts b/src/time-and-attendance/modules/pay-period/controllers/pay-periods.controller.ts similarity index 100% rename from src/Time_And_Attendance/modules/pay-period/controllers/pay-periods.controller.ts rename to src/time-and-attendance/modules/pay-period/controllers/pay-periods.controller.ts diff --git a/src/Time_And_Attendance/modules/pay-period/dtos/bulk-crew-approval.dto.ts b/src/time-and-attendance/modules/pay-period/dtos/bulk-crew-approval.dto.ts similarity index 100% rename from src/Time_And_Attendance/modules/pay-period/dtos/bulk-crew-approval.dto.ts rename to src/time-and-attendance/modules/pay-period/dtos/bulk-crew-approval.dto.ts diff --git a/src/Time_And_Attendance/modules/pay-period/dtos/bundle-pay-period.dto.ts b/src/time-and-attendance/modules/pay-period/dtos/bundle-pay-period.dto.ts similarity index 100% rename from src/Time_And_Attendance/modules/pay-period/dtos/bundle-pay-period.dto.ts rename to src/time-and-attendance/modules/pay-period/dtos/bundle-pay-period.dto.ts diff --git a/src/Time_And_Attendance/modules/pay-period/dtos/overview-employee-period.dto.ts b/src/time-and-attendance/modules/pay-period/dtos/overview-employee-period.dto.ts similarity index 100% rename from src/Time_And_Attendance/modules/pay-period/dtos/overview-employee-period.dto.ts rename to src/time-and-attendance/modules/pay-period/dtos/overview-employee-period.dto.ts diff --git a/src/Time_And_Attendance/modules/pay-period/dtos/overview-pay-period.dto.ts b/src/time-and-attendance/modules/pay-period/dtos/overview-pay-period.dto.ts similarity index 100% rename from src/Time_And_Attendance/modules/pay-period/dtos/overview-pay-period.dto.ts rename to src/time-and-attendance/modules/pay-period/dtos/overview-pay-period.dto.ts diff --git a/src/Time_And_Attendance/modules/pay-period/dtos/pay-period.dto.ts b/src/time-and-attendance/modules/pay-period/dtos/pay-period.dto.ts similarity index 100% rename from src/Time_And_Attendance/modules/pay-period/dtos/pay-period.dto.ts rename to src/time-and-attendance/modules/pay-period/dtos/pay-period.dto.ts diff --git a/src/Time_And_Attendance/modules/pay-period/mappers/pay-periods.mapper.ts b/src/time-and-attendance/modules/pay-period/mappers/pay-periods.mapper.ts similarity index 100% rename from src/Time_And_Attendance/modules/pay-period/mappers/pay-periods.mapper.ts rename to src/time-and-attendance/modules/pay-period/mappers/pay-periods.mapper.ts diff --git a/src/Time_And_Attendance/modules/pay-period/pay-periods.module.ts b/src/time-and-attendance/modules/pay-period/pay-periods.module.ts similarity index 68% rename from src/Time_And_Attendance/modules/pay-period/pay-periods.module.ts rename to src/time-and-attendance/modules/pay-period/pay-periods.module.ts index fabd257..6e15221 100644 --- a/src/Time_And_Attendance/modules/pay-period/pay-periods.module.ts +++ b/src/time-and-attendance/modules/pay-period/pay-periods.module.ts @@ -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, diff --git a/src/Time_And_Attendance/modules/pay-period/services/pay-periods-command.service.ts b/src/time-and-attendance/modules/pay-period/services/pay-periods-command.service.ts similarity index 100% rename from src/Time_And_Attendance/modules/pay-period/services/pay-periods-command.service.ts rename to src/time-and-attendance/modules/pay-period/services/pay-periods-command.service.ts diff --git a/src/Time_And_Attendance/modules/pay-period/services/pay-periods-query.service.ts b/src/time-and-attendance/modules/pay-period/services/pay-periods-query.service.ts similarity index 100% rename from src/Time_And_Attendance/modules/pay-period/services/pay-periods-query.service.ts rename to src/time-and-attendance/modules/pay-period/services/pay-periods-query.service.ts diff --git a/src/Time_And_Attendance/modules/pay-period/utils/pay-year.util.ts b/src/time-and-attendance/modules/pay-period/utils/pay-year.util.ts similarity index 100% rename from src/Time_And_Attendance/modules/pay-period/utils/pay-year.util.ts rename to src/time-and-attendance/modules/pay-period/utils/pay-year.util.ts diff --git a/src/Time_And_Attendance/modules/shared/constants/date-time.constant.ts b/src/time-and-attendance/modules/shared/constants/date-time.constant.ts similarity index 100% rename from src/Time_And_Attendance/modules/shared/constants/date-time.constant.ts rename to src/time-and-attendance/modules/shared/constants/date-time.constant.ts diff --git a/src/Time_And_Attendance/modules/shared/constants/regex.constant.ts b/src/time-and-attendance/modules/shared/constants/regex.constant.ts similarity index 100% rename from src/Time_And_Attendance/modules/shared/constants/regex.constant.ts rename to src/time-and-attendance/modules/shared/constants/regex.constant.ts diff --git a/src/Time_And_Attendance/modules/shared/constants/utils.constant.ts b/src/time-and-attendance/modules/shared/constants/utils.constant.ts similarity index 100% rename from src/Time_And_Attendance/modules/shared/constants/utils.constant.ts rename to src/time-and-attendance/modules/shared/constants/utils.constant.ts diff --git a/src/Time_And_Attendance/modules/shared/helpers/date-time.helpers.ts b/src/time-and-attendance/modules/shared/helpers/date-time.helpers.ts similarity index 100% rename from src/Time_And_Attendance/modules/shared/helpers/date-time.helpers.ts rename to src/time-and-attendance/modules/shared/helpers/date-time.helpers.ts diff --git a/src/Time_And_Attendance/modules/shared/interfaces/shifts.interface.ts b/src/time-and-attendance/modules/shared/interfaces/shifts.interface.ts similarity index 100% rename from src/Time_And_Attendance/modules/shared/interfaces/shifts.interface.ts rename to src/time-and-attendance/modules/shared/interfaces/shifts.interface.ts diff --git a/src/Time_And_Attendance/modules/shared/selects/expenses.select.ts b/src/time-and-attendance/modules/shared/selects/expenses.select.ts similarity index 100% rename from src/Time_And_Attendance/modules/shared/selects/expenses.select.ts rename to src/time-and-attendance/modules/shared/selects/expenses.select.ts diff --git a/src/Time_And_Attendance/modules/shared/selects/pay-periods.select.ts b/src/time-and-attendance/modules/shared/selects/pay-periods.select.ts similarity index 100% rename from src/Time_And_Attendance/modules/shared/selects/pay-periods.select.ts rename to src/time-and-attendance/modules/shared/selects/pay-periods.select.ts diff --git a/src/Time_And_Attendance/modules/shared/selects/shifts.select.ts b/src/time-and-attendance/modules/shared/selects/shifts.select.ts similarity index 100% rename from src/Time_And_Attendance/modules/shared/selects/shifts.select.ts rename to src/time-and-attendance/modules/shared/selects/shifts.select.ts diff --git a/src/Time_And_Attendance/modules/shared/shared.module.ts b/src/time-and-attendance/modules/shared/shared.module.ts similarity index 100% rename from src/Time_And_Attendance/modules/shared/shared.module.ts rename to src/time-and-attendance/modules/shared/shared.module.ts diff --git a/src/Time_And_Attendance/modules/shared/types/upsert-actions.types.ts b/src/time-and-attendance/modules/shared/types/upsert-actions.types.ts similarity index 100% rename from src/Time_And_Attendance/modules/shared/types/upsert-actions.types.ts rename to src/time-and-attendance/modules/shared/types/upsert-actions.types.ts diff --git a/src/Time_And_Attendance/modules/shared/utils/resolve-bank-type-id.utils.ts b/src/time-and-attendance/modules/shared/utils/resolve-bank-type-id.utils.ts similarity index 100% rename from src/Time_And_Attendance/modules/shared/utils/resolve-bank-type-id.utils.ts rename to src/time-and-attendance/modules/shared/utils/resolve-bank-type-id.utils.ts diff --git a/src/Time_And_Attendance/modules/shared/utils/resolve-email-id.utils.ts b/src/time-and-attendance/modules/shared/utils/resolve-email-id.utils.ts similarity index 100% rename from src/Time_And_Attendance/modules/shared/utils/resolve-email-id.utils.ts rename to src/time-and-attendance/modules/shared/utils/resolve-email-id.utils.ts diff --git a/src/Time_And_Attendance/modules/shared/utils/resolve-full-name.utils.ts b/src/time-and-attendance/modules/shared/utils/resolve-full-name.utils.ts similarity index 100% rename from src/Time_And_Attendance/modules/shared/utils/resolve-full-name.utils.ts rename to src/time-and-attendance/modules/shared/utils/resolve-full-name.utils.ts diff --git a/src/Time_And_Attendance/modules/shared/utils/resolve-shifts-id.utils.ts b/src/time-and-attendance/modules/shared/utils/resolve-shifts-id.utils.ts similarity index 100% rename from src/Time_And_Attendance/modules/shared/utils/resolve-shifts-id.utils.ts rename to src/time-and-attendance/modules/shared/utils/resolve-shifts-id.utils.ts diff --git a/src/Time_And_Attendance/modules/shared/utils/resolve-timesheet.utils.ts b/src/time-and-attendance/modules/shared/utils/resolve-timesheet.utils.ts similarity index 94% rename from src/Time_And_Attendance/modules/shared/utils/resolve-timesheet.utils.ts rename to src/time-and-attendance/modules/shared/utils/resolve-timesheet.utils.ts index 2c5e515..11c89f2 100644 --- a/src/Time_And_Attendance/modules/shared/utils/resolve-timesheet.utils.ts +++ b/src/time-and-attendance/modules/shared/utils/resolve-timesheet.utils.ts @@ -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"; diff --git a/src/Time_And_Attendance/modules/time-tracker/schedule-presets/controller/schedule-presets.controller.ts b/src/time-and-attendance/modules/time-tracker/schedule-presets/controller/schedule-presets.controller.ts similarity index 96% rename from src/Time_And_Attendance/modules/time-tracker/schedule-presets/controller/schedule-presets.controller.ts rename to src/time-and-attendance/modules/time-tracker/schedule-presets/controller/schedule-presets.controller.ts index 0efb934..79a8976 100644 --- a/src/Time_And_Attendance/modules/time-tracker/schedule-presets/controller/schedule-presets.controller.ts +++ b/src/time-and-attendance/modules/time-tracker/schedule-presets/controller/schedule-presets.controller.ts @@ -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') diff --git a/src/Time_And_Attendance/modules/time-tracker/schedule-presets/dtos/create-schedule-preset-shifts.dto.ts b/src/time-and-attendance/modules/time-tracker/schedule-presets/dtos/create-schedule-preset-shifts.dto.ts similarity index 100% rename from src/Time_And_Attendance/modules/time-tracker/schedule-presets/dtos/create-schedule-preset-shifts.dto.ts rename to src/time-and-attendance/modules/time-tracker/schedule-presets/dtos/create-schedule-preset-shifts.dto.ts diff --git a/src/Time_And_Attendance/modules/time-tracker/schedule-presets/dtos/create-schedule-presets.dto.ts b/src/time-and-attendance/modules/time-tracker/schedule-presets/dtos/create-schedule-presets.dto.ts similarity index 100% rename from src/Time_And_Attendance/modules/time-tracker/schedule-presets/dtos/create-schedule-presets.dto.ts rename to src/time-and-attendance/modules/time-tracker/schedule-presets/dtos/create-schedule-presets.dto.ts diff --git a/src/Time_And_Attendance/modules/time-tracker/schedule-presets/mappers/schedule-presets.mappers.ts b/src/time-and-attendance/modules/time-tracker/schedule-presets/mappers/schedule-presets.mappers.ts similarity index 100% rename from src/Time_And_Attendance/modules/time-tracker/schedule-presets/mappers/schedule-presets.mappers.ts rename to src/time-and-attendance/modules/time-tracker/schedule-presets/mappers/schedule-presets.mappers.ts diff --git a/src/Time_And_Attendance/modules/time-tracker/schedule-presets/schedule-presets.module.ts b/src/time-and-attendance/modules/time-tracker/schedule-presets/schedule-presets.module.ts similarity index 91% rename from src/Time_And_Attendance/modules/time-tracker/schedule-presets/schedule-presets.module.ts rename to src/time-and-attendance/modules/time-tracker/schedule-presets/schedule-presets.module.ts index 2e25a6d..8194655 100644 --- a/src/Time_And_Attendance/modules/time-tracker/schedule-presets/schedule-presets.module.ts +++ b/src/time-and-attendance/modules/time-tracker/schedule-presets/schedule-presets.module.ts @@ -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], diff --git a/src/Time_And_Attendance/modules/time-tracker/schedule-presets/services/schedule-presets-apply.service.ts b/src/time-and-attendance/modules/time-tracker/schedule-presets/services/schedule-presets-apply.service.ts similarity index 98% rename from src/Time_And_Attendance/modules/time-tracker/schedule-presets/services/schedule-presets-apply.service.ts rename to src/time-and-attendance/modules/time-tracker/schedule-presets/services/schedule-presets-apply.service.ts index e2e8dbf..98bde74 100644 --- a/src/Time_And_Attendance/modules/time-tracker/schedule-presets/services/schedule-presets-apply.service.ts +++ b/src/time-and-attendance/modules/time-tracker/schedule-presets/services/schedule-presets-apply.service.ts @@ -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"; diff --git a/src/Time_And_Attendance/modules/time-tracker/schedule-presets/services/schedule-presets-command.service.ts b/src/time-and-attendance/modules/time-tracker/schedule-presets/services/schedule-presets-command.service.ts similarity index 98% rename from src/Time_And_Attendance/modules/time-tracker/schedule-presets/services/schedule-presets-command.service.ts rename to src/time-and-attendance/modules/time-tracker/schedule-presets/services/schedule-presets-command.service.ts index 5c1cb2c..3803004 100644 --- a/src/Time_And_Attendance/modules/time-tracker/schedule-presets/services/schedule-presets-command.service.ts +++ b/src/time-and-attendance/modules/time-tracker/schedule-presets/services/schedule-presets-command.service.ts @@ -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"; diff --git a/src/Time_And_Attendance/modules/time-tracker/schedule-presets/services/schedule-presets-query.service.ts b/src/time-and-attendance/modules/time-tracker/schedule-presets/services/schedule-presets-query.service.ts similarity index 96% rename from src/Time_And_Attendance/modules/time-tracker/schedule-presets/services/schedule-presets-query.service.ts rename to src/time-and-attendance/modules/time-tracker/schedule-presets/services/schedule-presets-query.service.ts index 7b87cef..e406151 100644 --- a/src/Time_And_Attendance/modules/time-tracker/schedule-presets/services/schedule-presets-query.service.ts +++ b/src/time-and-attendance/modules/time-tracker/schedule-presets/services/schedule-presets-query.service.ts @@ -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"; diff --git a/src/Time_And_Attendance/modules/time-tracker/schedule-presets/types/schedule-presets.types.ts b/src/time-and-attendance/modules/time-tracker/schedule-presets/types/schedule-presets.types.ts similarity index 100% rename from src/Time_And_Attendance/modules/time-tracker/schedule-presets/types/schedule-presets.types.ts rename to src/time-and-attendance/modules/time-tracker/schedule-presets/types/schedule-presets.types.ts diff --git a/src/Time_And_Attendance/modules/time-tracker/shifts/controllers/shift.controller.ts b/src/time-and-attendance/modules/time-tracker/shifts/controllers/shift.controller.ts similarity index 100% rename from src/Time_And_Attendance/modules/time-tracker/shifts/controllers/shift.controller.ts rename to src/time-and-attendance/modules/time-tracker/shifts/controllers/shift.controller.ts diff --git a/src/Time_And_Attendance/modules/time-tracker/shifts/dtos/get-shift.dto.ts b/src/time-and-attendance/modules/time-tracker/shifts/dtos/get-shift.dto.ts similarity index 100% rename from src/Time_And_Attendance/modules/time-tracker/shifts/dtos/get-shift.dto.ts rename to src/time-and-attendance/modules/time-tracker/shifts/dtos/get-shift.dto.ts diff --git a/src/Time_And_Attendance/modules/time-tracker/shifts/dtos/shift.dto.ts b/src/time-and-attendance/modules/time-tracker/shifts/dtos/shift.dto.ts similarity index 100% rename from src/Time_And_Attendance/modules/time-tracker/shifts/dtos/shift.dto.ts rename to src/time-and-attendance/modules/time-tracker/shifts/dtos/shift.dto.ts diff --git a/src/Time_And_Attendance/modules/time-tracker/shifts/dtos/update-shift.dto.ts b/src/time-and-attendance/modules/time-tracker/shifts/dtos/update-shift.dto.ts similarity index 100% rename from src/Time_And_Attendance/modules/time-tracker/shifts/dtos/update-shift.dto.ts rename to src/time-and-attendance/modules/time-tracker/shifts/dtos/update-shift.dto.ts diff --git a/src/Time_And_Attendance/modules/time-tracker/shifts/helpers/shifts-date-time-helpers.ts b/src/time-and-attendance/modules/time-tracker/shifts/helpers/shifts-date-time-helpers.ts similarity index 100% rename from src/Time_And_Attendance/modules/time-tracker/shifts/helpers/shifts-date-time-helpers.ts rename to src/time-and-attendance/modules/time-tracker/shifts/helpers/shifts-date-time-helpers.ts diff --git a/src/Time_And_Attendance/modules/time-tracker/shifts/services/shifts-archival.service.ts b/src/time-and-attendance/modules/time-tracker/shifts/services/shifts-archival.service.ts similarity index 100% rename from src/Time_And_Attendance/modules/time-tracker/shifts/services/shifts-archival.service.ts rename to src/time-and-attendance/modules/time-tracker/shifts/services/shifts-archival.service.ts diff --git a/src/Time_And_Attendance/modules/time-tracker/shifts/services/shifts-get.service.ts b/src/time-and-attendance/modules/time-tracker/shifts/services/shifts-get.service.ts similarity index 100% rename from src/Time_And_Attendance/modules/time-tracker/shifts/services/shifts-get.service.ts rename to src/time-and-attendance/modules/time-tracker/shifts/services/shifts-get.service.ts diff --git a/src/Time_And_Attendance/modules/time-tracker/shifts/services/shifts-upsert.service.ts b/src/time-and-attendance/modules/time-tracker/shifts/services/shifts-upsert.service.ts similarity index 99% rename from src/Time_And_Attendance/modules/time-tracker/shifts/services/shifts-upsert.service.ts rename to src/time-and-attendance/modules/time-tracker/shifts/services/shifts-upsert.service.ts index cc0e790..a7ec458 100644 --- a/src/Time_And_Attendance/modules/time-tracker/shifts/services/shifts-upsert.service.ts +++ b/src/time-and-attendance/modules/time-tracker/shifts/services/shifts-upsert.service.ts @@ -1,6 +1,6 @@ import { toDateFromString, toHHmmFromString, toStringFromDate, toStringFromHHmm } from "../helpers/shifts-date-time-helpers"; import { BadRequestException, ConflictException, Injectable, NotFoundException } from "@nestjs/common"; -import { OvertimeService, WeekOvertimeSummary } from "src/modules/business-logics/services/overtime.service"; +import { OvertimeService, WeekOvertimeSummary } from "src/time-and-attendance/domains/services/overtime.service"; import { updateShiftDto } from "../dtos/update-shift.dto"; import { PrismaService } from "src/prisma/prisma.service"; import { GetShiftDto } from "../dtos/get-shift.dto"; diff --git a/src/Time_And_Attendance/modules/time-tracker/shifts/shifts.module.ts b/src/time-and-attendance/modules/time-tracker/shifts/shifts.module.ts similarity index 89% rename from src/Time_And_Attendance/modules/time-tracker/shifts/shifts.module.ts rename to src/time-and-attendance/modules/time-tracker/shifts/shifts.module.ts index 5d33c35..00fe148 100644 --- a/src/Time_And_Attendance/modules/time-tracker/shifts/shifts.module.ts +++ b/src/time-and-attendance/modules/time-tracker/shifts/shifts.module.ts @@ -1,5 +1,5 @@ import { ShiftsArchivalService } from './services/shifts-archival.service'; -import { BusinessLogicsModule } from 'src/modules/business-logics/business-logics.module'; +import { BusinessLogicsModule } from 'src/time-and-attendance/domains/business-logics.module'; import { NotificationsModule } from '../../../../modules/notifications/notifications.module'; import { ShiftsUpsertService } from './services/shifts-upsert.service'; import { ShiftsGetService } from './services/shifts-get.service'; diff --git a/src/Time_And_Attendance/modules/time-tracker/shifts/~misc_deprecated-files/get-shift-overview.dto.ts b/src/time-and-attendance/modules/time-tracker/shifts/~misc_deprecated-files/get-shift-overview.dto.ts similarity index 100% rename from src/Time_And_Attendance/modules/time-tracker/shifts/~misc_deprecated-files/get-shift-overview.dto.ts rename to src/time-and-attendance/modules/time-tracker/shifts/~misc_deprecated-files/get-shift-overview.dto.ts diff --git a/src/Time_And_Attendance/modules/time-tracker/shifts/~misc_deprecated-files/shifts-command.service.ts b/src/time-and-attendance/modules/time-tracker/shifts/~misc_deprecated-files/shifts-command.service.ts similarity index 100% rename from src/Time_And_Attendance/modules/time-tracker/shifts/~misc_deprecated-files/shifts-command.service.ts rename to src/time-and-attendance/modules/time-tracker/shifts/~misc_deprecated-files/shifts-command.service.ts diff --git a/src/Time_And_Attendance/modules/time-tracker/shifts/~misc_deprecated-files/shifts-overview-row.interface.ts b/src/time-and-attendance/modules/time-tracker/shifts/~misc_deprecated-files/shifts-overview-row.interface.ts similarity index 100% rename from src/Time_And_Attendance/modules/time-tracker/shifts/~misc_deprecated-files/shifts-overview-row.interface.ts rename to src/time-and-attendance/modules/time-tracker/shifts/~misc_deprecated-files/shifts-overview-row.interface.ts diff --git a/src/Time_And_Attendance/modules/time-tracker/shifts/~misc_deprecated-files/shifts-query.service.ts b/src/time-and-attendance/modules/time-tracker/shifts/~misc_deprecated-files/shifts-query.service.ts similarity index 100% rename from src/Time_And_Attendance/modules/time-tracker/shifts/~misc_deprecated-files/shifts-query.service.ts rename to src/time-and-attendance/modules/time-tracker/shifts/~misc_deprecated-files/shifts-query.service.ts diff --git a/src/Time_And_Attendance/modules/time-tracker/shifts/~misc_deprecated-files/shifts-upsert.types.ts b/src/time-and-attendance/modules/time-tracker/shifts/~misc_deprecated-files/shifts-upsert.types.ts similarity index 100% rename from src/Time_And_Attendance/modules/time-tracker/shifts/~misc_deprecated-files/shifts-upsert.types.ts rename to src/time-and-attendance/modules/time-tracker/shifts/~misc_deprecated-files/shifts-upsert.types.ts diff --git a/src/Time_And_Attendance/modules/time-tracker/shifts/~misc_deprecated-files/shifts.controller.ts b/src/time-and-attendance/modules/time-tracker/shifts/~misc_deprecated-files/shifts.controller.ts similarity index 100% rename from src/Time_And_Attendance/modules/time-tracker/shifts/~misc_deprecated-files/shifts.controller.ts rename to src/time-and-attendance/modules/time-tracker/shifts/~misc_deprecated-files/shifts.controller.ts diff --git a/src/Time_And_Attendance/modules/time-tracker/shifts/~misc_deprecated-files/shifts.helpers.ts b/src/time-and-attendance/modules/time-tracker/shifts/~misc_deprecated-files/shifts.helpers.ts similarity index 100% rename from src/Time_And_Attendance/modules/time-tracker/shifts/~misc_deprecated-files/shifts.helpers.ts rename to src/time-and-attendance/modules/time-tracker/shifts/~misc_deprecated-files/shifts.helpers.ts diff --git a/src/Time_And_Attendance/modules/time-tracker/shifts/~misc_deprecated-files/shifts.utils.ts b/src/time-and-attendance/modules/time-tracker/shifts/~misc_deprecated-files/shifts.utils.ts similarity index 100% rename from src/Time_And_Attendance/modules/time-tracker/shifts/~misc_deprecated-files/shifts.utils.ts rename to src/time-and-attendance/modules/time-tracker/shifts/~misc_deprecated-files/shifts.utils.ts diff --git a/src/Time_And_Attendance/modules/time-tracker/shifts/~misc_deprecated-files/upsert-shift.dto.ts b/src/time-and-attendance/modules/time-tracker/shifts/~misc_deprecated-files/upsert-shift.dto.ts similarity index 100% rename from src/Time_And_Attendance/modules/time-tracker/shifts/~misc_deprecated-files/upsert-shift.dto.ts rename to src/time-and-attendance/modules/time-tracker/shifts/~misc_deprecated-files/upsert-shift.dto.ts diff --git a/src/Time_And_Attendance/modules/time-tracker/timesheets/controllers/timesheet.controller.ts b/src/time-and-attendance/modules/time-tracker/timesheets/controllers/timesheet.controller.ts similarity index 94% rename from src/Time_And_Attendance/modules/time-tracker/timesheets/controllers/timesheet.controller.ts rename to src/time-and-attendance/modules/time-tracker/timesheets/controllers/timesheet.controller.ts index 61eef3a..7eb7209 100644 --- a/src/Time_And_Attendance/modules/time-tracker/timesheets/controllers/timesheet.controller.ts +++ b/src/time-and-attendance/modules/time-tracker/timesheets/controllers/timesheet.controller.ts @@ -1,4 +1,4 @@ -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 { GetTimesheetsOverviewService } from "../services/timesheet-get-overview.service"; import { BadRequestException, Controller, Get, Query} from "@nestjs/common"; diff --git a/src/Time_And_Attendance/modules/time-tracker/timesheets/dtos/timesheet.dto.ts b/src/time-and-attendance/modules/time-tracker/timesheets/dtos/timesheet.dto.ts similarity index 100% rename from src/Time_And_Attendance/modules/time-tracker/timesheets/dtos/timesheet.dto.ts rename to src/time-and-attendance/modules/time-tracker/timesheets/dtos/timesheet.dto.ts diff --git a/src/Time_And_Attendance/modules/time-tracker/timesheets/helpers/timesheets-date-time-helpers.ts b/src/time-and-attendance/modules/time-tracker/timesheets/helpers/timesheets-date-time-helpers.ts similarity index 100% rename from src/Time_And_Attendance/modules/time-tracker/timesheets/helpers/timesheets-date-time-helpers.ts rename to src/time-and-attendance/modules/time-tracker/timesheets/helpers/timesheets-date-time-helpers.ts diff --git a/src/Time_And_Attendance/modules/time-tracker/timesheets/services/timesheet-approval.service.ts b/src/time-and-attendance/modules/time-tracker/timesheets/services/timesheet-approval.service.ts similarity index 100% rename from src/Time_And_Attendance/modules/time-tracker/timesheets/services/timesheet-approval.service.ts rename to src/time-and-attendance/modules/time-tracker/timesheets/services/timesheet-approval.service.ts diff --git a/src/Time_And_Attendance/modules/time-tracker/timesheets/services/timesheet-archive.service.ts b/src/time-and-attendance/modules/time-tracker/timesheets/services/timesheet-archive.service.ts similarity index 100% rename from src/Time_And_Attendance/modules/time-tracker/timesheets/services/timesheet-archive.service.ts rename to src/time-and-attendance/modules/time-tracker/timesheets/services/timesheet-archive.service.ts diff --git a/src/Time_And_Attendance/modules/time-tracker/timesheets/services/timesheet-get-overview.service.ts b/src/time-and-attendance/modules/time-tracker/timesheets/services/timesheet-get-overview.service.ts similarity index 100% rename from src/Time_And_Attendance/modules/time-tracker/timesheets/services/timesheet-get-overview.service.ts rename to src/time-and-attendance/modules/time-tracker/timesheets/services/timesheet-get-overview.service.ts diff --git a/src/Time_And_Attendance/modules/time-tracker/timesheets/timesheets.module.ts b/src/time-and-attendance/modules/time-tracker/timesheets/timesheets.module.ts similarity index 70% rename from src/Time_And_Attendance/modules/time-tracker/timesheets/timesheets.module.ts rename to src/time-and-attendance/modules/time-tracker/timesheets/timesheets.module.ts index 001fb19..930c70f 100644 --- a/src/Time_And_Attendance/modules/time-tracker/timesheets/timesheets.module.ts +++ b/src/time-and-attendance/modules/time-tracker/timesheets/timesheets.module.ts @@ -1,17 +1,11 @@ import { GetTimesheetsOverviewService } from './services/timesheet-get-overview.service'; import { TimesheetArchiveService } from './services/timesheet-archive.service'; -import { BusinessLogicsModule } from 'src/modules/business-logics/business-logics.module'; import { TimesheetController } from './controllers/timesheet.controller'; import { SharedModule } from '../../shared/shared.module'; -import { ShiftsModule } from '../shifts/shifts.module'; import { Module } from '@nestjs/common'; @Module({ - imports: [ - BusinessLogicsModule, - SharedModule, - ShiftsModule, - ], + imports: [], controllers: [TimesheetController], providers: [ TimesheetArchiveService, diff --git a/src/Time_And_Attendance/modules/time-tracker/timesheets/~misc_deprecated-files/create-timesheet.dto.ts b/src/time-and-attendance/modules/time-tracker/timesheets/~misc_deprecated-files/create-timesheet.dto.ts similarity index 100% rename from src/Time_And_Attendance/modules/time-tracker/timesheets/~misc_deprecated-files/create-timesheet.dto.ts rename to src/time-and-attendance/modules/time-tracker/timesheets/~misc_deprecated-files/create-timesheet.dto.ts diff --git a/src/Time_And_Attendance/modules/time-tracker/timesheets/~misc_deprecated-files/search-timesheet.dto.ts b/src/time-and-attendance/modules/time-tracker/timesheets/~misc_deprecated-files/search-timesheet.dto.ts similarity index 100% rename from src/Time_And_Attendance/modules/time-tracker/timesheets/~misc_deprecated-files/search-timesheet.dto.ts rename to src/time-and-attendance/modules/time-tracker/timesheets/~misc_deprecated-files/search-timesheet.dto.ts diff --git a/src/Time_And_Attendance/modules/time-tracker/timesheets/~misc_deprecated-files/timesheet-period.dto.ts b/src/time-and-attendance/modules/time-tracker/timesheets/~misc_deprecated-files/timesheet-period.dto.ts similarity index 100% rename from src/Time_And_Attendance/modules/time-tracker/timesheets/~misc_deprecated-files/timesheet-period.dto.ts rename to src/time-and-attendance/modules/time-tracker/timesheets/~misc_deprecated-files/timesheet-period.dto.ts diff --git a/src/Time_And_Attendance/modules/time-tracker/timesheets/~misc_deprecated-files/timesheet.helpers.ts b/src/time-and-attendance/modules/time-tracker/timesheets/~misc_deprecated-files/timesheet.helpers.ts similarity index 100% rename from src/Time_And_Attendance/modules/time-tracker/timesheets/~misc_deprecated-files/timesheet.helpers.ts rename to src/time-and-attendance/modules/time-tracker/timesheets/~misc_deprecated-files/timesheet.helpers.ts diff --git a/src/Time_And_Attendance/modules/time-tracker/timesheets/~misc_deprecated-files/timesheet.mappers.ts b/src/time-and-attendance/modules/time-tracker/timesheets/~misc_deprecated-files/timesheet.mappers.ts similarity index 100% rename from src/Time_And_Attendance/modules/time-tracker/timesheets/~misc_deprecated-files/timesheet.mappers.ts rename to src/time-and-attendance/modules/time-tracker/timesheets/~misc_deprecated-files/timesheet.mappers.ts diff --git a/src/Time_And_Attendance/modules/time-tracker/timesheets/~misc_deprecated-files/timesheet.selectors.ts b/src/time-and-attendance/modules/time-tracker/timesheets/~misc_deprecated-files/timesheet.selectors.ts similarity index 100% rename from src/Time_And_Attendance/modules/time-tracker/timesheets/~misc_deprecated-files/timesheet.selectors.ts rename to src/time-and-attendance/modules/time-tracker/timesheets/~misc_deprecated-files/timesheet.selectors.ts diff --git a/src/Time_And_Attendance/modules/time-tracker/timesheets/~misc_deprecated-files/timesheet.types.ts b/src/time-and-attendance/modules/time-tracker/timesheets/~misc_deprecated-files/timesheet.types.ts similarity index 100% rename from src/Time_And_Attendance/modules/time-tracker/timesheets/~misc_deprecated-files/timesheet.types.ts rename to src/time-and-attendance/modules/time-tracker/timesheets/~misc_deprecated-files/timesheet.types.ts diff --git a/src/Time_And_Attendance/modules/time-tracker/timesheets/~misc_deprecated-files/timesheet.utils.ts b/src/time-and-attendance/modules/time-tracker/timesheets/~misc_deprecated-files/timesheet.utils.ts similarity index 100% rename from src/Time_And_Attendance/modules/time-tracker/timesheets/~misc_deprecated-files/timesheet.utils.ts rename to src/time-and-attendance/modules/time-tracker/timesheets/~misc_deprecated-files/timesheet.utils.ts diff --git a/src/Time_And_Attendance/modules/time-tracker/timesheets/~misc_deprecated-files/timesheets-command.service.ts b/src/time-and-attendance/modules/time-tracker/timesheets/~misc_deprecated-files/timesheets-command.service.ts similarity index 100% rename from src/Time_And_Attendance/modules/time-tracker/timesheets/~misc_deprecated-files/timesheets-command.service.ts rename to src/time-and-attendance/modules/time-tracker/timesheets/~misc_deprecated-files/timesheets-command.service.ts diff --git a/src/Time_And_Attendance/modules/time-tracker/timesheets/~misc_deprecated-files/timesheets-query.service.ts b/src/time-and-attendance/modules/time-tracker/timesheets/~misc_deprecated-files/timesheets-query.service.ts similarity index 100% rename from src/Time_And_Attendance/modules/time-tracker/timesheets/~misc_deprecated-files/timesheets-query.service.ts rename to src/time-and-attendance/modules/time-tracker/timesheets/~misc_deprecated-files/timesheets-query.service.ts diff --git a/src/Time_And_Attendance/modules/time-tracker/timesheets/~misc_deprecated-files/timesheets.controller.ts b/src/time-and-attendance/modules/time-tracker/timesheets/~misc_deprecated-files/timesheets.controller.ts similarity index 100% rename from src/Time_And_Attendance/modules/time-tracker/timesheets/~misc_deprecated-files/timesheets.controller.ts rename to src/time-and-attendance/modules/time-tracker/timesheets/~misc_deprecated-files/timesheets.controller.ts diff --git a/src/time-and-attendance/time-and-attendance.module.ts b/src/time-and-attendance/time-and-attendance.module.ts new file mode 100644 index 0000000..ebcbd05 --- /dev/null +++ b/src/time-and-attendance/time-and-attendance.module.ts @@ -0,0 +1,42 @@ +import { Module } from "@nestjs/common"; +import { ExpensesArchiveController } from "src/modules/archival/controllers/expenses-archive.controller"; +import { BusinessLogicsModule } from "src/time-and-attendance/domains/business-logics.module"; +import { ExpenseController } from "src/time-and-attendance/modules/expenses/controllers/expense.controller"; +import { ExpenseUpsertService } from "src/time-and-attendance/modules/expenses/services/expense-upsert.service"; +import { ExpensesArchivalService } from "src/time-and-attendance/modules/expenses/services/expenses-archival.service"; +import { PayperiodsModule } from "src/time-and-attendance/modules/pay-period/pay-periods.module"; +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 { SchedulePresetsController } from "src/time-and-attendance/modules/time-tracker/schedule-presets/controller/schedule-presets.controller"; +import { SchedulePresetsCommandService } from "src/time-and-attendance/modules/time-tracker/schedule-presets/services/schedule-presets-command.service"; +import { SchedulePresetsQueryService } from "src/time-and-attendance/modules/time-tracker/schedule-presets/services/schedule-presets-query.service"; +import { ShiftController } from "src/time-and-attendance/modules/time-tracker/shifts/controllers/shift.controller"; +import { ShiftsGetService } from "src/time-and-attendance/modules/time-tracker/shifts/services/shifts-get.service"; +import { ShiftsUpsertService } from "src/time-and-attendance/modules/time-tracker/shifts/services/shifts-upsert.service"; +import { TimesheetController } from "src/time-and-attendance/modules/time-tracker/timesheets/controllers/timesheet.controller"; +import { GetTimesheetsOverviewService } from "src/time-and-attendance/modules/time-tracker/timesheets/services/timesheet-get-overview.service"; + +@Module({ + imports: [BusinessLogicsModule, PayperiodsModule], + controllers: [ + TimesheetController, + ShiftController, + SchedulePresetsController, + ExpenseController, + ExpensesArchiveController, + // LeaveRequestController, + + ], + providers: [ + GetTimesheetsOverviewService, + ShiftsGetService, + ShiftsUpsertService, + ExpenseUpsertService, + ExpensesArchivalService, + EmailToIdResolver, + SchedulePresetsCommandService, + BankCodesResolver, + SchedulePresetsQueryService, + ], + exports: [], +}) export class TimeAndAttendanceModule{}; \ No newline at end of file From 2712033451ae41958a24d98bb5e86a5d0dc75d64 Mon Sep 17 00:00:00 2001 From: Matthieu Haineault Date: Fri, 24 Oct 2025 16:47:30 -0400 Subject: [PATCH 4/5] refactor(cleaning): preparing other modules for refactoring --- prisma/schema.prisma | 72 +-- src/app.module.ts | 4 +- .../expenses-archive.controller.ts | 58 +-- .../leave-requests-archive.controller.ts | 12 +- .../controllers/shifts-archive.controller.ts | 58 +-- .../timesheets-archive.controller.ts | 58 +-- .../archival/services/archival.service.ts | 66 +-- .../controllers/attachments.controller.ts | 4 +- src/modules/bank-codes/bank-codes.module.ts | 18 +- .../controllers/bank-codes.controller.ts | 86 ++-- .../bank-codes/dtos/create-bank-code.dto.ts | 82 ++-- .../bank-codes/dtos/update-bank-code.dto.ts | 6 +- .../bank-codes/services/bank-codes.service.ts | 84 ++-- .../customers/dtos/create-customer.dto.ts | 142 +++--- .../customers/dtos/update-customer.dto.ts | 6 +- .../customers/services/customers.service.ts | 162 +++---- .../employees/dtos/create-employee.dto.ts | 208 ++++----- .../employees/dtos/list-employee.dto.ts | 16 +- .../employees/dtos/profil-employee.dto.ts | 26 +- .../employees/dtos/update-employee.dto.ts | 36 +- .../employees/services/employees.service.ts | 418 +++++++++--------- src/modules/employees/utils/employee.utils.ts | 18 +- 22 files changed, 819 insertions(+), 821 deletions(-) diff --git a/prisma/schema.prisma b/prisma/schema.prisma index 60503eb..fd3b522 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -14,48 +14,48 @@ datasource db { url = env("DATABASE_URL_DEV") } -model Users { - id String @id @default(dbgenerated("gen_random_uuid()")) @db.Uuid - first_name String - last_name String - email String @unique - phone_number String @unique - residence String? - role Roles @default(GUEST) +// model Users { +// id String @id @default(dbgenerated("gen_random_uuid()")) @db.Uuid +// first_name String +// last_name String +// email String @unique +// phone_number String @unique +// residence String? +// role Roles @default(GUEST) - employee Employees? @relation("UserEmployee") - oauth_sessions OAuthSessions[] @relation("UserOAuthSessions") - preferences Preferences? @relation("UserPreferences") +// employee Employees? @relation("UserEmployee") +// oauth_sessions OAuthSessions[] @relation("UserOAuthSessions") +// preferences Preferences? @relation("UserPreferences") - @@map("users") -} +// @@map("users") +// } -model Employees { - id Int @id @default(autoincrement()) - user Users @relation("UserEmployee", fields: [user_id], references: [id]) - user_id String @unique @db.Uuid - supervisor Employees? @relation("EmployeeSupervisor", fields: [supervisor_id], references: [id]) - supervisor_id Int? +// model Employees { +// id Int @id @default(autoincrement()) +// user Users @relation("UserEmployee", fields: [user_id], references: [id]) +// user_id String @unique @db.Uuid +// supervisor Employees? @relation("EmployeeSupervisor", fields: [supervisor_id], references: [id]) +// supervisor_id Int? - external_payroll_id Int - company_code Int - first_work_day DateTime @db.Date - last_work_day DateTime? @db.Date - job_title String? - is_supervisor Boolean @default(false) +// external_payroll_id Int +// company_code Int +// first_work_day DateTime @db.Date +// last_work_day DateTime? @db.Date +// job_title String? +// is_supervisor Boolean @default(false) - crew Employees[] @relation("EmployeeSupervisor") - timesheet Timesheets[] @relation("TimesheetEmployee") - leave_request LeaveRequests[] @relation("LeaveRequestEmployee") - schedule_presets SchedulePresets[] @relation("SchedulePreset") +// crew Employees[] @relation("EmployeeSupervisor") +// timesheet Timesheets[] @relation("TimesheetEmployee") +// leave_request LeaveRequests[] @relation("LeaveRequestEmployee") +// schedule_presets SchedulePresets[] @relation("SchedulePreset") - @@map("employees") -} +// @@map("employees") +// } model LeaveRequests { id Int @id @default(autoincrement()) - employee Employees @relation("LeaveRequestEmployee", fields: [employee_id], references: [id]) + // employee Employees @relation("LeaveRequestEmployee", fields: [employee_id], references: [id]) employee_id Int bank_code BankCodes @relation("LeaveRequestBankCodes", fields: [bank_code_id], references: [id]) bank_code_id Int @@ -107,7 +107,7 @@ view PayPeriods { model Timesheets { id Int @id @default(autoincrement()) - employee Employees @relation("TimesheetEmployee", fields: [employee_id], references: [id]) + // employee Employees @relation("TimesheetEmployee", fields: [employee_id], references: [id]) employee_id Int start_date DateTime @db.Date @@ -135,7 +135,7 @@ model TimesheetsArchive { model SchedulePresets { id Int @id @default(autoincrement()) - employee Employees @relation("SchedulePreset", fields: [employee_id], references: [id]) + // employee Employees @relation("SchedulePreset", fields: [employee_id], references: [id]) employee_id Int name String @@ -258,7 +258,7 @@ model ExpensesArchive { model OAuthSessions { id String @id @default(cuid()) - user Users @relation("UserOAuthSessions", fields: [user_id], references: [id]) + // user Users @relation("UserOAuthSessions", fields: [user_id], references: [id]) user_id String @db.Uuid application String access_token String @unique @@ -327,7 +327,7 @@ model AttachmentVariants { model Preferences { id Int @id @default(autoincrement()) - user Users @relation("UserPreferences", fields: [user_id], references: [id]) + // user Users @relation("UserPreferences", fields: [user_id], references: [id]) user_id String @unique @db.Uuid notifications Int @default(0) diff --git a/src/app.module.ts b/src/app.module.ts index 901f74e..4519929 100644 --- a/src/app.module.ts +++ b/src/app.module.ts @@ -3,7 +3,7 @@ import { AppController } from './app.controller'; import { AppService } from './app.service'; // import { ArchivalModule } from './modules/archival/archival.module'; import { AuthenticationModule } from './modules/authentication/auth.module'; -import { BankCodesModule } from './modules/bank-codes/bank-codes.module'; +// import { BankCodesModule } from './modules/bank-codes/bank-codes.module'; // import { CsvExportModule } from './modules/exports/csv-exports.module'; import { HealthModule } from './health/health.module'; import { HealthController } from './health/health.controller'; @@ -23,7 +23,7 @@ import { TimeAndAttendanceModule } from 'src/time-and-attendance/time-and-attend @Module({ imports: [ AuthenticationModule, - BankCodesModule, + // BankCodesModule, ConfigModule.forRoot({isGlobal: true}), // CsvExportModule, // CustomersModule, diff --git a/src/modules/archival/controllers/expenses-archive.controller.ts b/src/modules/archival/controllers/expenses-archive.controller.ts index f256b82..ecfd7b8 100644 --- a/src/modules/archival/controllers/expenses-archive.controller.ts +++ b/src/modules/archival/controllers/expenses-archive.controller.ts @@ -1,32 +1,32 @@ -import { UseGuards, Controller, Get, Param, ParseIntPipe, NotFoundException } from "@nestjs/common"; -import { ApiTags, ApiOperation, ApiResponse } from "@nestjs/swagger"; -import { ExpensesArchive,Roles as RoleEnum } from "@prisma/client"; -import { RolesAllowed } from "src/common/decorators/roles.decorators"; -import { ExpensesArchivalService } from "src/time-and-attendance/modules/expenses/services/expenses-archival.service"; +// import { UseGuards, Controller, Get, Param, ParseIntPipe, NotFoundException } from "@nestjs/common"; +// import { ApiTags, ApiOperation, ApiResponse } from "@nestjs/swagger"; +// import { ExpensesArchive,Roles as RoleEnum } from "@prisma/client"; +// import { RolesAllowed } from "src/common/decorators/roles.decorators"; +// import { ExpensesArchivalService } from "src/time-and-attendance/modules/expenses/services/expenses-archival.service"; -@ApiTags('Expense Archives') -// @UseGuards() -@Controller('archives/expenses') -export class ExpensesArchiveController { - constructor(private readonly expensesService: ExpensesArchivalService) {} +// @ApiTags('Expense Archives') +// // @UseGuards() +// @Controller('archives/expenses') +// export class ExpensesArchiveController { +// constructor(private readonly expensesService: ExpensesArchivalService) {} - @Get() - //@RolesAllowed(RoleEnum.ADMIN, RoleEnum.HR, RoleEnum.SUPERVISOR) - @ApiOperation({ summary: 'List of archived expenses'}) - @ApiResponse({ status: 200, description: 'List of archived expenses', isArray: true }) - async findAllArchived(): Promise { - return this.expensesService.findAllArchived(); - } +// @Get() +// //@RolesAllowed(RoleEnum.ADMIN, RoleEnum.HR, RoleEnum.SUPERVISOR) +// @ApiOperation({ summary: 'List of archived expenses'}) +// @ApiResponse({ status: 200, description: 'List of archived expenses', isArray: true }) +// async findAllArchived(): Promise { +// return this.expensesService.findAllArchived(); +// } - @Get() - //@RolesAllowed(RoleEnum.ADMIN, RoleEnum.HR, RoleEnum.SUPERVISOR) - @ApiOperation({ summary: 'Fetch expense in archives with its Id'}) - @ApiResponse({ status: 200, description: 'Archived expense found'}) - async findOneArchived(@Param('id', ParseIntPipe) id: number ): Promise { - try{ - return await this.expensesService.findOneArchived(id); - }catch { - throw new NotFoundException(`Archived expense #${id} not found`); - } - } -} \ No newline at end of file +// @Get() +// //@RolesAllowed(RoleEnum.ADMIN, RoleEnum.HR, RoleEnum.SUPERVISOR) +// @ApiOperation({ summary: 'Fetch expense in archives with its Id'}) +// @ApiResponse({ status: 200, description: 'Archived expense found'}) +// async findOneArchived(@Param('id', ParseIntPipe) id: number ): Promise { +// try{ +// return await this.expensesService.findOneArchived(id); +// }catch { +// throw new NotFoundException(`Archived expense #${id} not found`); +// } +// } +// } \ No newline at end of file diff --git a/src/modules/archival/controllers/leave-requests-archive.controller.ts b/src/modules/archival/controllers/leave-requests-archive.controller.ts index 1c5e4be..ec1b046 100644 --- a/src/modules/archival/controllers/leave-requests-archive.controller.ts +++ b/src/modules/archival/controllers/leave-requests-archive.controller.ts @@ -1,7 +1,7 @@ -import { Controller } from '@nestjs/common'; -import { ApiTags } from '@nestjs/swagger'; +// import { Controller } from '@nestjs/common'; +// import { ApiTags } from '@nestjs/swagger'; -@ApiTags('LeaveRequests Archives') -// @UseGuards() -@Controller('archives/leaveRequests') -export class LeaveRequestsArchiveController {} \ No newline at end of file +// @ApiTags('LeaveRequests Archives') +// // @UseGuards() +// @Controller('archives/leaveRequests') +// export class LeaveRequestsArchiveController {} \ No newline at end of file diff --git a/src/modules/archival/controllers/shifts-archive.controller.ts b/src/modules/archival/controllers/shifts-archive.controller.ts index 7c88288..f322fa1 100644 --- a/src/modules/archival/controllers/shifts-archive.controller.ts +++ b/src/modules/archival/controllers/shifts-archive.controller.ts @@ -1,32 +1,32 @@ -import { Get, Param, ParseIntPipe, NotFoundException, Controller, UseGuards } from "@nestjs/common"; -import { ApiOperation, ApiResponse, ApiTags } from "@nestjs/swagger"; -import { ShiftsArchive, Roles as RoleEnum } from "@prisma/client"; -import { RolesAllowed } from "src/common/decorators/roles.decorators"; -import { ShiftsArchivalService } from "src/time-and-attendance/modules/time-tracker/shifts/services/shifts-archival.service"; +// import { Get, Param, ParseIntPipe, NotFoundException, Controller, UseGuards } from "@nestjs/common"; +// import { ApiOperation, ApiResponse, ApiTags } from "@nestjs/swagger"; +// import { ShiftsArchive, Roles as RoleEnum } from "@prisma/client"; +// import { RolesAllowed } from "src/common/decorators/roles.decorators"; +// import { ShiftsArchivalService } from "src/time-and-attendance/modules/time-tracker/shifts/services/shifts-archival.service"; -@ApiTags('Shift Archives') -// @UseGuards() -@Controller('archives/shifts') -export class ShiftsArchiveController { - constructor(private readonly shiftsService: ShiftsArchivalService) {} +// @ApiTags('Shift Archives') +// // @UseGuards() +// @Controller('archives/shifts') +// export class ShiftsArchiveController { +// constructor(private readonly shiftsService: ShiftsArchivalService) {} - @Get() - //@RolesAllowed(RoleEnum.ADMIN, RoleEnum.HR, RoleEnum.SUPERVISOR) - @ApiOperation({ summary: 'List of archived shifts'}) - @ApiResponse({ status: 200, description: 'List of archived shifts', isArray: true }) - async findAllArchived(): Promise { - return this.shiftsService.findAllArchived(); - } +// @Get() +// //@RolesAllowed(RoleEnum.ADMIN, RoleEnum.HR, RoleEnum.SUPERVISOR) +// @ApiOperation({ summary: 'List of archived shifts'}) +// @ApiResponse({ status: 200, description: 'List of archived shifts', isArray: true }) +// async findAllArchived(): Promise { +// return this.shiftsService.findAllArchived(); +// } - @Get() - //@RolesAllowed(RoleEnum.ADMIN, RoleEnum.HR,RoleEnum.SUPERVISOR) - @ApiOperation({ summary: 'Fetch shift in archives with its Id'}) - @ApiResponse({ status: 200, description: 'Archived shift found'}) - async findOneArchived(@Param('id', ParseIntPipe) id: number ): Promise { - try{ - return await this.shiftsService.findOneArchived(id); - }catch { - throw new NotFoundException(`Archived shift #${id} not found`); - } - } -} \ No newline at end of file +// @Get() +// //@RolesAllowed(RoleEnum.ADMIN, RoleEnum.HR,RoleEnum.SUPERVISOR) +// @ApiOperation({ summary: 'Fetch shift in archives with its Id'}) +// @ApiResponse({ status: 200, description: 'Archived shift found'}) +// async findOneArchived(@Param('id', ParseIntPipe) id: number ): Promise { +// try{ +// return await this.shiftsService.findOneArchived(id); +// }catch { +// throw new NotFoundException(`Archived shift #${id} not found`); +// } +// } +// } \ No newline at end of file diff --git a/src/modules/archival/controllers/timesheets-archive.controller.ts b/src/modules/archival/controllers/timesheets-archive.controller.ts index 3a8f0a2..888dc3c 100644 --- a/src/modules/archival/controllers/timesheets-archive.controller.ts +++ b/src/modules/archival/controllers/timesheets-archive.controller.ts @@ -1,33 +1,33 @@ -import { Controller, Get, NotFoundException, Param, ParseIntPipe, UseGuards } from "@nestjs/common"; -import { ApiOperation, ApiResponse, ApiTags } from "@nestjs/swagger"; -import { RolesAllowed } from "src/common/decorators/roles.decorators"; -import { TimesheetsArchive, Roles as RoleEnum } from '@prisma/client'; -import { TimesheetArchiveService } from "src/time-and-attendance/modules/time-tracker/timesheets/services/timesheet-archive.service"; +// import { Controller, Get, NotFoundException, Param, ParseIntPipe, UseGuards } from "@nestjs/common"; +// import { ApiOperation, ApiResponse, ApiTags } from "@nestjs/swagger"; +// import { RolesAllowed } from "src/common/decorators/roles.decorators"; +// import { TimesheetsArchive, Roles as RoleEnum } from '@prisma/client'; +// import { TimesheetArchiveService } from "src/time-and-attendance/modules/time-tracker/timesheets/services/timesheet-archive.service"; -@ApiTags('Timesheet Archives') -// @UseGuards() -@Controller('archives/timesheets') -export class TimesheetsArchiveController { - constructor(private readonly timesheetsService: TimesheetArchiveService) {} +// @ApiTags('Timesheet Archives') +// // @UseGuards() +// @Controller('archives/timesheets') +// export class TimesheetsArchiveController { +// constructor(private readonly timesheetsService: TimesheetArchiveService) {} - @Get() - //@RolesAllowed(RoleEnum.ADMIN, RoleEnum.HR, RoleEnum.SUPERVISOR) - @ApiOperation({ summary: 'List of archived timesheets'}) - @ApiResponse({ status: 200, description: 'List of archived timesheets', isArray: true }) - async findAllArchived(): Promise { - return this.timesheetsService.findAllArchived(); - } +// @Get() +// //@RolesAllowed(RoleEnum.ADMIN, RoleEnum.HR, RoleEnum.SUPERVISOR) +// @ApiOperation({ summary: 'List of archived timesheets'}) +// @ApiResponse({ status: 200, description: 'List of archived timesheets', isArray: true }) +// async findAllArchived(): Promise { +// return this.timesheetsService.findAllArchived(); +// } - @Get() - //@RolesAllowed(RoleEnum.ADMIN, RoleEnum.HR, RoleEnum.SUPERVISOR) - @ApiOperation({ summary: 'Fetch timesheet in archives with its Id'}) - @ApiResponse({ status: 200, description: 'Archived timesheet found'}) - async findOneArchived(@Param('id', ParseIntPipe) id: number ): Promise { - try{ - return await this.timesheetsService.findOneArchived(id); - }catch { - throw new NotFoundException(`Archived timesheet #${id} not found`); - } - } +// @Get() +// //@RolesAllowed(RoleEnum.ADMIN, RoleEnum.HR, RoleEnum.SUPERVISOR) +// @ApiOperation({ summary: 'Fetch timesheet in archives with its Id'}) +// @ApiResponse({ status: 200, description: 'Archived timesheet found'}) +// async findOneArchived(@Param('id', ParseIntPipe) id: number ): Promise { +// try{ +// return await this.timesheetsService.findOneArchived(id); +// }catch { +// throw new NotFoundException(`Archived timesheet #${id} not found`); +// } +// } -} \ No newline at end of file +// } \ No newline at end of file diff --git a/src/modules/archival/services/archival.service.ts b/src/modules/archival/services/archival.service.ts index ded45eb..bed4191 100644 --- a/src/modules/archival/services/archival.service.ts +++ b/src/modules/archival/services/archival.service.ts @@ -1,38 +1,38 @@ -import { Injectable, Logger } from "@nestjs/common"; -import { Cron } from "@nestjs/schedule"; -import { ExpensesArchivalService } from "src/time-and-attendance/modules/expenses/services/expenses-archival.service"; -import { ShiftsArchivalService } from "src/time-and-attendance/modules/time-tracker/shifts/services/shifts-archival.service"; -import { TimesheetArchiveService } from "src/time-and-attendance/modules/time-tracker/timesheets/services/timesheet-archive.service"; +// import { Injectable, Logger } from "@nestjs/common"; +// import { Cron } from "@nestjs/schedule"; +// import { ExpensesArchivalService } from "src/time-and-attendance/modules/expenses/services/expenses-archival.service"; +// import { ShiftsArchivalService } from "src/time-and-attendance/modules/time-tracker/shifts/services/shifts-archival.service"; +// import { TimesheetArchiveService } from "src/time-and-attendance/modules/time-tracker/timesheets/services/timesheet-archive.service"; -@Injectable() -export class ArchivalService { - private readonly logger = new Logger(ArchivalService.name); +// @Injectable() +// export class ArchivalService { +// private readonly logger = new Logger(ArchivalService.name); - constructor( - private readonly timesheetsService: TimesheetArchiveService, - private readonly expensesService: ExpensesArchivalService, - private readonly shiftsService: ShiftsArchivalService, - ) {} +// constructor( +// private readonly timesheetsService: TimesheetArchiveService, +// private readonly expensesService: ExpensesArchivalService, +// private readonly shiftsService: ShiftsArchivalService, +// ) {} - @Cron('0 0 3 * * 1', {timeZone:'America/Toronto'}) // chaque premier lundi du mois à 03h00 - async handleMonthlyArchival() { - const today = new Date(); - const dayOfMonth = today.getDate(); +// @Cron('0 0 3 * * 1', {timeZone:'America/Toronto'}) // chaque premier lundi du mois à 03h00 +// async handleMonthlyArchival() { +// const today = new Date(); +// const dayOfMonth = today.getDate(); - if (dayOfMonth > 7) { - this.logger.warn('Archive {awaiting 1st monday of the month for archivation process}') - return; - } +// if (dayOfMonth > 7) { +// this.logger.warn('Archive {awaiting 1st monday of the month for archivation process}') +// return; +// } - this.logger.log('monthly archivation in process'); - try { - await this.timesheetsService.archiveOld(); - await this.expensesService.archiveOld(); - await this.shiftsService.archiveOld(); - // await this.leaveRequestsService.archiveExpired(); - this.logger.log('archivation process done'); - } catch (err) { - this.logger.error('an error occured during archivation process ', err); - } - } -} \ No newline at end of file +// this.logger.log('monthly archivation in process'); +// try { +// await this.timesheetsService.archiveOld(); +// await this.expensesService.archiveOld(); +// await this.shiftsService.archiveOld(); +// // await this.leaveRequestsService.archiveExpired(); +// this.logger.log('archivation process done'); +// } catch (err) { +// this.logger.error('an error occured during archivation process ', err); +// } +// } +// } \ No newline at end of file diff --git a/src/modules/attachments/controllers/attachments.controller.ts b/src/modules/attachments/controllers/attachments.controller.ts index 3a75d6a..4999771 100644 --- a/src/modules/attachments/controllers/attachments.controller.ts +++ b/src/modules/attachments/controllers/attachments.controller.ts @@ -4,9 +4,7 @@ import { Controller,NotFoundException, UseInterceptors, Post, Get, Param, Res, UploadedFile, BadRequestException, UnsupportedMediaTypeException, Body, Delete, Query, - DefaultValuePipe, - ParseIntPipe - } from "@nestjs/common"; +} from "@nestjs/common"; import { maxUploadBytes, allowedMimes } from "../config/upload.config"; import { memoryStorage } from 'multer'; import { fileTypeFromBuffer, fileTypeFromFile } from "file-type"; diff --git a/src/modules/bank-codes/bank-codes.module.ts b/src/modules/bank-codes/bank-codes.module.ts index 80ec6e3..816c440 100644 --- a/src/modules/bank-codes/bank-codes.module.ts +++ b/src/modules/bank-codes/bank-codes.module.ts @@ -1,11 +1,11 @@ -import { Module } from "@nestjs/common"; -import { PrismaService } from "src/prisma/prisma.service"; -import { BankCodesControllers } from "./controllers/bank-codes.controller"; -import { BankCodesService } from "./services/bank-codes.service"; +// import { Module } from "@nestjs/common"; +// import { PrismaService } from "src/prisma/prisma.service"; +// import { BankCodesControllers } from "./controllers/bank-codes.controller"; +// import { BankCodesService } from "./services/bank-codes.service"; -@Module({ - controllers: [BankCodesControllers], - providers: [BankCodesService, PrismaService], -}) +// @Module({ +// controllers: [BankCodesControllers], +// providers: [BankCodesService, PrismaService], +// }) -export class BankCodesModule {} \ No newline at end of file +// export class BankCodesModule {} \ No newline at end of file diff --git a/src/modules/bank-codes/controllers/bank-codes.controller.ts b/src/modules/bank-codes/controllers/bank-codes.controller.ts index 678336c..4588bbf 100644 --- a/src/modules/bank-codes/controllers/bank-codes.controller.ts +++ b/src/modules/bank-codes/controllers/bank-codes.controller.ts @@ -1,49 +1,49 @@ -import { Body, Controller, Delete, Get, Param, ParseIntPipe, Patch, Post } from "@nestjs/common"; -import { BankCodesService } from "../services/bank-codes.service"; -import { CreateBankCodeDto } from "../dtos/create-bank-code.dto"; -import { UpdateBankCodeDto } from "../dtos/update-bank-code.dto"; -import { ApiBadRequestResponse, ApiNotFoundResponse, ApiOperation, ApiResponse } from "@nestjs/swagger"; +// import { Body, Controller, Delete, Get, Param, ParseIntPipe, Patch, Post } from "@nestjs/common"; +// import { BankCodesService } from "../services/bank-codes.service"; +// import { CreateBankCodeDto } from "../dtos/create-bank-code.dto"; +// import { UpdateBankCodeDto } from "../dtos/update-bank-code.dto"; +// import { ApiBadRequestResponse, ApiNotFoundResponse, ApiOperation, ApiResponse } from "@nestjs/swagger"; -@Controller('bank-codes') -export class BankCodesControllers { - constructor(private readonly bankCodesService: BankCodesService) {} - //_____________________________________________________________________________________________ - // Deprecated or unused methods - //_____________________________________________________________________________________________ +// @Controller('bank-codes') +// export class BankCodesControllers { +// constructor(private readonly bankCodesService: BankCodesService) {} +// //_____________________________________________________________________________________________ +// // Deprecated or unused methods +// //_____________________________________________________________________________________________ - // @Post() - // @ApiOperation({ summary: 'Create a new bank code' }) - // @ApiResponse({ status: 201, description: 'Bank code successfully created.' }) - // @ApiBadRequestResponse({ description: 'Invalid input data.' }) - // create(@Body() dto: CreateBankCodeDto) { - // return this.bankCodesService.create(dto); - // } +// // @Post() +// // @ApiOperation({ summary: 'Create a new bank code' }) +// // @ApiResponse({ status: 201, description: 'Bank code successfully created.' }) +// // @ApiBadRequestResponse({ description: 'Invalid input data.' }) +// // create(@Body() dto: CreateBankCodeDto) { +// // return this.bankCodesService.create(dto); +// // } - // @Get() - // @ApiOperation({ summary: 'Retrieve all bank codes' }) - // @ApiResponse({ status: 200, description: 'List of bank codes.' }) - // findAll() { - // return this.bankCodesService.findAll(); - // } +// // @Get() +// // @ApiOperation({ summary: 'Retrieve all bank codes' }) +// // @ApiResponse({ status: 200, description: 'List of bank codes.' }) +// // findAll() { +// // return this.bankCodesService.findAll(); +// // } - // @Get(':id') - // @ApiOperation({ summary: 'Retrieve a bank code by its ID' }) - // @ApiNotFoundResponse({ description: 'Bank code not found.' }) - // findOne(@Param('id', ParseIntPipe) id: number){ - // return this.bankCodesService.findOne(id); - // } +// // @Get(':id') +// // @ApiOperation({ summary: 'Retrieve a bank code by its ID' }) +// // @ApiNotFoundResponse({ description: 'Bank code not found.' }) +// // findOne(@Param('id', ParseIntPipe) id: number){ +// // return this.bankCodesService.findOne(id); +// // } - // @Patch(':id') - // @ApiOperation({ summary: 'Update an existing bank code' }) - // @ApiNotFoundResponse({ description: 'Bank code not found.' }) - // update(@Param('id', ParseIntPipe) id: number, @Body() dto: UpdateBankCodeDto) { - // return this.bankCodesService.update(id, dto) - // } +// // @Patch(':id') +// // @ApiOperation({ summary: 'Update an existing bank code' }) +// // @ApiNotFoundResponse({ description: 'Bank code not found.' }) +// // update(@Param('id', ParseIntPipe) id: number, @Body() dto: UpdateBankCodeDto) { +// // return this.bankCodesService.update(id, dto) +// // } - // @Delete(':id') - // @ApiOperation({ summary: 'Delete a bank code' }) - // @ApiNotFoundResponse({ description: 'Bank code not found.' }) - // remove(@Param('id', ParseIntPipe) id: number) { - // return this.bankCodesService.remove(id); - // } -} \ No newline at end of file +// // @Delete(':id') +// // @ApiOperation({ summary: 'Delete a bank code' }) +// // @ApiNotFoundResponse({ description: 'Bank code not found.' }) +// // remove(@Param('id', ParseIntPipe) id: number) { +// // return this.bankCodesService.remove(id); +// // } +// } \ No newline at end of file diff --git a/src/modules/bank-codes/dtos/create-bank-code.dto.ts b/src/modules/bank-codes/dtos/create-bank-code.dto.ts index f2bec7b..a08020a 100644 --- a/src/modules/bank-codes/dtos/create-bank-code.dto.ts +++ b/src/modules/bank-codes/dtos/create-bank-code.dto.ts @@ -1,46 +1,46 @@ -import { ApiProperty } from "@nestjs/swagger"; -import { Type } from "class-transformer"; -import { Allow, IsNotEmpty, IsNumber, IsString } from "class-validator"; +// import { ApiProperty } from "@nestjs/swagger"; +// import { Type } from "class-transformer"; +// import { Allow, IsNotEmpty, IsNumber, IsString } from "class-validator"; -export class CreateBankCodeDto { - @ApiProperty({ - example: 1, - description: 'Unique ID of a bank-code (auto-generated)', - readOnly: true, - }) - @Allow() - id: number; +// export class CreateBankCodeDto { +// @ApiProperty({ +// example: 1, +// description: 'Unique ID of a bank-code (auto-generated)', +// readOnly: true, +// }) +// @Allow() +// id: number; - @ApiProperty({ - example: 'regular, vacation, emergency, sick, parental, etc', - description: 'Type of codes', - }) - @IsString() - @IsNotEmpty() - type: string; +// @ApiProperty({ +// example: 'regular, vacation, emergency, sick, parental, etc', +// description: 'Type of codes', +// }) +// @IsString() +// @IsNotEmpty() +// type: string; - @ApiProperty({ - example: 'shift, expense, leave', - description: 'categorie of the related code', - }) - @IsString() - @IsNotEmpty() - categorie: string; +// @ApiProperty({ +// example: 'shift, expense, leave', +// description: 'categorie of the related code', +// }) +// @IsString() +// @IsNotEmpty() +// categorie: string; - @ApiProperty({ - example: '0, 0.72, 1, 1.5, 2', - description: 'modifier number to apply to salary', - }) - @Type(()=> Number) - @IsNumber() - @IsNotEmpty() - modifier: number; +// @ApiProperty({ +// example: '0, 0.72, 1, 1.5, 2', +// description: 'modifier number to apply to salary', +// }) +// @Type(()=> Number) +// @IsNumber() +// @IsNotEmpty() +// modifier: number; - @ApiProperty({ - example: 'G1, G345, G501, G43, G700', - description: 'codes given by the bank', - }) - @IsString() - @IsNotEmpty() - bank_code: string; -} \ No newline at end of file +// @ApiProperty({ +// example: 'G1, G345, G501, G43, G700', +// description: 'codes given by the bank', +// }) +// @IsString() +// @IsNotEmpty() +// bank_code: string; +// } \ No newline at end of file diff --git a/src/modules/bank-codes/dtos/update-bank-code.dto.ts b/src/modules/bank-codes/dtos/update-bank-code.dto.ts index 4033484..884e544 100644 --- a/src/modules/bank-codes/dtos/update-bank-code.dto.ts +++ b/src/modules/bank-codes/dtos/update-bank-code.dto.ts @@ -1,4 +1,4 @@ -import { PartialType } from "@nestjs/swagger"; -import { CreateBankCodeDto } from "./create-bank-code.dto"; +// import { PartialType } from "@nestjs/swagger"; +// import { CreateBankCodeDto } from "./create-bank-code.dto"; -export class UpdateBankCodeDto extends PartialType(CreateBankCodeDto) {} \ No newline at end of file +// export class UpdateBankCodeDto extends PartialType(CreateBankCodeDto) {} \ No newline at end of file diff --git a/src/modules/bank-codes/services/bank-codes.service.ts b/src/modules/bank-codes/services/bank-codes.service.ts index 5e1549a..fbb8745 100644 --- a/src/modules/bank-codes/services/bank-codes.service.ts +++ b/src/modules/bank-codes/services/bank-codes.service.ts @@ -1,51 +1,51 @@ -import { Injectable, NotFoundException } from "@nestjs/common"; -import { PrismaService } from "src/prisma/prisma.service"; -import { CreateBankCodeDto } from "../dtos/create-bank-code.dto"; -import { BankCodes } from "@prisma/client"; -import { UpdateBankCodeDto } from "../dtos/update-bank-code.dto"; +// import { Injectable, NotFoundException } from "@nestjs/common"; +// import { PrismaService } from "src/prisma/prisma.service"; +// import { CreateBankCodeDto } from "../dtos/create-bank-code.dto"; +// import { BankCodes } from "@prisma/client"; +// import { UpdateBankCodeDto } from "../dtos/update-bank-code.dto"; -@Injectable() -export class BankCodesService { - constructor(private readonly prisma: PrismaService) {} +// @Injectable() +// export class BankCodesService { +// constructor(private readonly prisma: PrismaService) {} - async create(dto: CreateBankCodeDto): Promise{ - return this.prisma.bankCodes.create({ - data: { - type: dto.type, - categorie: dto.categorie, - modifier: dto.modifier, - bank_code: dto.bank_code, - }, - }); - } +// async create(dto: CreateBankCodeDto): Promise{ +// return this.prisma.bankCodes.create({ +// data: { +// type: dto.type, +// categorie: dto.categorie, +// modifier: dto.modifier, +// bank_code: dto.bank_code, +// }, +// }); +// } - findAll() { - return this.prisma.bankCodes.findMany(); - } +// findAll() { +// return this.prisma.bankCodes.findMany(); +// } - async findOne(id: number) { - const bankCode = await this.prisma.bankCodes.findUnique({ where: {id} }); +// async findOne(id: number) { +// const bankCode = await this.prisma.bankCodes.findUnique({ where: {id} }); - if(!bankCode) throw new NotFoundException(`Bank Code #${id} not found`); +// if(!bankCode) throw new NotFoundException(`Bank Code #${id} not found`); - return bankCode; - } +// return bankCode; +// } - async update(id:number, dto: UpdateBankCodeDto) { - return await this.prisma.bankCodes.update({ - where: { id }, - data: { - type: dto.type, - categorie: dto.categorie, - modifier: dto.modifier as any, - bank_code: dto.bank_code, - }, - }); - } +// async update(id:number, dto: UpdateBankCodeDto) { +// return await this.prisma.bankCodes.update({ +// where: { id }, +// data: { +// type: dto.type, +// categorie: dto.categorie, +// modifier: dto.modifier as any, +// bank_code: dto.bank_code, +// }, +// }); +// } - async remove(id: number) { - await this.findOne(id); - return this.prisma.bankCodes.delete({ where: {id} }); - } +// async remove(id: number) { +// await this.findOne(id); +// return this.prisma.bankCodes.delete({ where: {id} }); +// } -} \ No newline at end of file +// } \ No newline at end of file diff --git a/src/modules/customers/dtos/create-customer.dto.ts b/src/modules/customers/dtos/create-customer.dto.ts index 8382f20..8a136ac 100644 --- a/src/modules/customers/dtos/create-customer.dto.ts +++ b/src/modules/customers/dtos/create-customer.dto.ts @@ -1,79 +1,79 @@ -import { ApiProperty } from "@nestjs/swagger"; -import { Type } from "class-transformer"; -import { - Allow, - IsEmail, - IsInt, - IsNotEmpty, - IsOptional, - IsPositive, - IsString, - IsUUID, -} from "class-validator"; +// import { ApiProperty } from "@nestjs/swagger"; +// import { Type } from "class-transformer"; +// import { +// Allow, +// IsEmail, +// IsInt, +// IsNotEmpty, +// IsOptional, +// IsPositive, +// IsString, +// IsUUID, +// } from "class-validator"; -export class CreateCustomerDto { - @ApiProperty({ - example: 1, - description: 'Unique ID of a customer(primary-key, auto-incremented)', - }) - @Allow() - id?: number; +// export class CreateCustomerDto { +// @ApiProperty({ +// example: 1, +// description: 'Unique ID of a customer(primary-key, auto-incremented)', +// }) +// @Allow() +// id?: number; - @ApiProperty({ - example: '0e6e2e1f-b157-4c7c-ae3f-999b3e4f914d', - description: 'UUID of the user linked to that customer', - }) - @IsUUID() - @IsOptional() - user_id?: string; +// @ApiProperty({ +// example: '0e6e2e1f-b157-4c7c-ae3f-999b3e4f914d', +// description: 'UUID of the user linked to that customer', +// }) +// @IsUUID() +// @IsOptional() +// user_id?: string; - @ApiProperty({ - example: 'Gandalf', - description: 'Customer`s first name', - }) - @IsString() - @IsNotEmpty() - first_name: string; +// @ApiProperty({ +// example: 'Gandalf', +// description: 'Customer`s first name', +// }) +// @IsString() +// @IsNotEmpty() +// first_name: string; - @ApiProperty({ - example: 'TheGray', - description: 'Customer`s last name', - }) - @IsString() - @IsNotEmpty() - last_name: string; +// @ApiProperty({ +// example: 'TheGray', +// description: 'Customer`s last name', +// }) +// @IsString() +// @IsNotEmpty() +// last_name: string; - @ApiProperty({ - example: 'you_shall_not_pass@middleEarth.com', - description: 'Customer`s email', - }) - @IsEmail() - @IsOptional() - email: string; +// @ApiProperty({ +// example: 'you_shall_not_pass@middleEarth.com', +// description: 'Customer`s email', +// }) +// @IsEmail() +// @IsOptional() +// email: string; - @ApiProperty({ - example: '8436637464', - description: 'Customer`s phone number', - }) - @IsString() - phone_number: string; +// @ApiProperty({ +// example: '8436637464', +// description: 'Customer`s phone number', +// }) +// @IsString() +// phone_number: string; - @ApiProperty({ - example: '1 Ringbearer`s way, Mount Doom city, ME, T1R 1N6 ', - description: 'Customer`s residence', - required: false, - }) - @IsString() - @IsOptional() - residence?: string; +// @ApiProperty({ +// example: '1 Ringbearer`s way, Mount Doom city, ME, T1R 1N6 ', +// description: 'Customer`s residence', +// required: false, +// }) +// @IsString() +// @IsOptional() +// residence?: string; - @ApiProperty({ - example: '4263253', - description: 'Customer`s invoice number', - required: false, - }) - @Type(() => Number) - @IsInt() - @IsNotEmpty() - invoice_id: number; -} \ No newline at end of file +// @ApiProperty({ +// example: '4263253', +// description: 'Customer`s invoice number', +// required: false, +// }) +// @Type(() => Number) +// @IsInt() +// @IsNotEmpty() +// invoice_id: number; +// } \ No newline at end of file diff --git a/src/modules/customers/dtos/update-customer.dto.ts b/src/modules/customers/dtos/update-customer.dto.ts index fc1ba39..2f52413 100644 --- a/src/modules/customers/dtos/update-customer.dto.ts +++ b/src/modules/customers/dtos/update-customer.dto.ts @@ -1,4 +1,4 @@ -import { PartialType } from "@nestjs/swagger"; -import { CreateCustomerDto } from "./create-customer.dto"; +// import { PartialType } from "@nestjs/swagger"; +// import { CreateCustomerDto } from "./create-customer.dto"; -export class UpdateCustomerDto extends PartialType(CreateCustomerDto) {} \ No newline at end of file +// export class UpdateCustomerDto extends PartialType(CreateCustomerDto) {} \ No newline at end of file diff --git a/src/modules/customers/services/customers.service.ts b/src/modules/customers/services/customers.service.ts index b0b68c8..2662250 100644 --- a/src/modules/customers/services/customers.service.ts +++ b/src/modules/customers/services/customers.service.ts @@ -1,93 +1,93 @@ -import { Injectable } from '@nestjs/common'; +// import { Injectable } from '@nestjs/common'; -@Injectable() -export class CustomersService { +// @Injectable() +// export class CustomersService { -//_____________________________________________________________________________________________ -// Deprecated or unused methods -//_____________________________________________________________________________________________ +// //_____________________________________________________________________________________________ +// // Deprecated or unused methods +// //_____________________________________________________________________________________________ -// constructor(private readonly prisma: PrismaService) {} +// // constructor(private readonly prisma: PrismaService) {} -// async create(dto: CreateCustomerDto): Promise { -// const { -// first_name, -// last_name, -// email, -// phone_number, -// residence, -// invoice_id, -// } = dto; +// // async create(dto: CreateCustomerDto): Promise { +// // const { +// // first_name, +// // last_name, +// // email, +// // phone_number, +// // residence, +// // invoice_id, +// // } = dto; -// return this.prisma.$transaction(async (transaction) => { -// const user: Users = await transaction.users.create({ -// data: { -// first_name, -// last_name, -// email, -// phone_number, -// residence, -// }, -// }); -// return transaction.customers.create({ -// data: { -// user_id: user.id, -// invoice_id, -// }, -// }); -// }); -// } +// // return this.prisma.$transaction(async (transaction) => { +// // const user: Users = await transaction.users.create({ +// // data: { +// // first_name, +// // last_name, +// // email, +// // phone_number, +// // residence, +// // }, +// // }); +// // return transaction.customers.create({ +// // data: { +// // user_id: user.id, +// // invoice_id, +// // }, +// // }); +// // }); +// // } -// findAll(): Promise { -// return this.prisma.customers.findMany({ -// include: { user: true }, -// }) -// } +// // findAll(): Promise { +// // return this.prisma.customers.findMany({ +// // include: { user: true }, +// // }) +// // } -// async findOne(id:number): Promise { -// const customer = await this.prisma.customers.findUnique({ -// where: { id }, -// include: { user: true }, -// }); -// if(!customer) throw new NotFoundException(`Customer #${id} not found`); -// return customer; -// } +// // async findOne(id:number): Promise { +// // const customer = await this.prisma.customers.findUnique({ +// // where: { id }, +// // include: { user: true }, +// // }); +// // if(!customer) throw new NotFoundException(`Customer #${id} not found`); +// // return customer; +// // } -// async update(id: number,dto: UpdateCustomerDto): Promise { -// const customer = await this.findOne(id); +// // async update(id: number,dto: UpdateCustomerDto): Promise { +// // const customer = await this.findOne(id); -// const { -// first_name, -// last_name, -// email, -// phone_number, -// residence, -// invoice_id, -// } = dto; +// // const { +// // first_name, +// // last_name, +// // email, +// // phone_number, +// // residence, +// // invoice_id, +// // } = dto; -// return this.prisma.$transaction(async (transaction) => { -// await transaction.users.update({ -// where: { id: customer.user_id }, -// data: { -// ...(first_name !== undefined && { first_name }), -// ...(last_name !== undefined && { last_name }), -// ...(email !== undefined && { email }), -// ...(phone_number !== undefined && { phone_number }), -// ...(residence !== undefined && { residence }), -// }, -// }); +// // return this.prisma.$transaction(async (transaction) => { +// // await transaction.users.update({ +// // where: { id: customer.user_id }, +// // data: { +// // ...(first_name !== undefined && { first_name }), +// // ...(last_name !== undefined && { last_name }), +// // ...(email !== undefined && { email }), +// // ...(phone_number !== undefined && { phone_number }), +// // ...(residence !== undefined && { residence }), +// // }, +// // }); -// return transaction.customers.update({ -// where: { id }, -// data: { -// ...(invoice_id !== undefined && { invoice_id }), -// }, -// }); -// }); +// // return transaction.customers.update({ +// // where: { id }, +// // data: { +// // ...(invoice_id !== undefined && { invoice_id }), +// // }, +// // }); +// // }); +// // } + +// // async remove(id: number): Promise { +// // await this.findOne(id); +// // return this.prisma.customers.delete({ where: { id }}); +// // } // } - -// async remove(id: number): Promise { -// await this.findOne(id); -// return this.prisma.customers.delete({ where: { id }}); -// } -} diff --git a/src/modules/employees/dtos/create-employee.dto.ts b/src/modules/employees/dtos/create-employee.dto.ts index 89279ef..4fbbaaa 100644 --- a/src/modules/employees/dtos/create-employee.dto.ts +++ b/src/modules/employees/dtos/create-employee.dto.ts @@ -1,118 +1,118 @@ -import { - Allow, - IsBoolean, - IsDateString, - IsEmail, - IsInt, - IsNotEmpty, - IsOptional, - IsPositive, - IsString, - IsUUID, -} from 'class-validator'; -import { Type } from 'class-transformer'; -import { ApiProperty } from '@nestjs/swagger'; +// import { +// Allow, +// IsBoolean, +// IsDateString, +// IsEmail, +// IsInt, +// IsNotEmpty, +// IsOptional, +// IsPositive, +// IsString, +// IsUUID, +// } from 'class-validator'; +// import { Type } from 'class-transformer'; +// import { ApiProperty } from '@nestjs/swagger'; -export class CreateEmployeeDto { - @ApiProperty({ - example: 1, - description: 'Unique ID of an employee(primary-key, auto-incremented)', - }) - @Allow() - id: number; +// export class CreateEmployeeDto { +// @ApiProperty({ +// example: 1, +// description: 'Unique ID of an employee(primary-key, auto-incremented)', +// }) +// @Allow() +// id: number; - @ApiProperty({ - example: '0e6e2e1f-b157-4c7c-ae3f-999b3e4f914d', - description: 'UUID of the user linked to that employee', - }) - @IsUUID() - @IsOptional() - user_id?: string; +// @ApiProperty({ +// example: '0e6e2e1f-b157-4c7c-ae3f-999b3e4f914d', +// description: 'UUID of the user linked to that employee', +// }) +// @IsUUID() +// @IsOptional() +// user_id?: string; - @ApiProperty({ - example: 'Frodo', - description: 'Employee`s first name', - }) - @IsString() - @IsNotEmpty() - first_name: string; +// @ApiProperty({ +// example: 'Frodo', +// description: 'Employee`s first name', +// }) +// @IsString() +// @IsNotEmpty() +// first_name: string; - @ApiProperty({ - example: 'Baggins', - description: 'Employee`s last name', - }) - @IsString() - @IsNotEmpty() - last_name: string; +// @ApiProperty({ +// example: 'Baggins', +// description: 'Employee`s last name', +// }) +// @IsString() +// @IsNotEmpty() +// last_name: string; - @ApiProperty({ - example: 'i_cant_do_this_sam@targointernet.com', - description: 'Employee`s email', - }) - @IsEmail() - @IsOptional() - email: string; +// @ApiProperty({ +// example: 'i_cant_do_this_sam@targointernet.com', +// description: 'Employee`s email', +// }) +// @IsEmail() +// @IsOptional() +// email: string; - @IsOptional() - @IsBoolean() - is_supervisor: boolean; +// @IsOptional() +// @IsBoolean() +// is_supervisor: boolean; - @ApiProperty({ - example: '82538437464', - description: 'Employee`s phone number', - }) - @IsString() - phone_number: string; +// @ApiProperty({ +// example: '82538437464', +// description: 'Employee`s phone number', +// }) +// @IsString() +// phone_number: string; - @ApiProperty({ - example: '1 Bagshot Row, Hobbiton, The Shire, Middle-earth', - description: 'Employee`s residence', - required: false, - }) - @IsString() - @IsOptional() - residence?: string; +// @ApiProperty({ +// example: '1 Bagshot Row, Hobbiton, The Shire, Middle-earth', +// description: 'Employee`s residence', +// required: false, +// }) +// @IsString() +// @IsOptional() +// residence?: string; - @ApiProperty({ - example: 7464, - description: 'external ID for the pay system', - }) - @IsInt() - @IsPositive() - @Type(() => Number) - external_payroll_id: number; +// @ApiProperty({ +// example: 7464, +// description: 'external ID for the pay system', +// }) +// @IsInt() +// @IsPositive() +// @Type(() => Number) +// external_payroll_id: number; - @ApiProperty({ - example: 335567447, - description: 'Employee`s company code', - }) - @IsInt() - @IsPositive() - @Type(() => Number) - company_code: number; +// @ApiProperty({ +// example: 335567447, +// description: 'Employee`s company code', +// }) +// @IsInt() +// @IsPositive() +// @Type(() => Number) +// company_code: number; - @ApiProperty({ - example:'technicient', - description: 'employee`s job title', - }) - @IsString() - @IsOptional() - job_title: string; +// @ApiProperty({ +// example:'technicient', +// description: 'employee`s job title', +// }) +// @IsString() +// @IsOptional() +// job_title: string; - @ApiProperty({ - example: '23/09/3018', - description: 'Employee`s first working day', - }) - @IsDateString() - first_work_day: string; +// @ApiProperty({ +// example: '23/09/3018', +// description: 'Employee`s first working day', +// }) +// @IsDateString() +// first_work_day: string; - @ApiProperty({ - example: '25/03/3019', - description: 'Employee`s last working day', - required: false, - }) - @IsDateString() - @IsOptional() - last_work_day?: string; -} +// @ApiProperty({ +// example: '25/03/3019', +// description: 'Employee`s last working day', +// required: false, +// }) +// @IsDateString() +// @IsOptional() +// last_work_day?: string; +// } diff --git a/src/modules/employees/dtos/list-employee.dto.ts b/src/modules/employees/dtos/list-employee.dto.ts index 39abf03..6adbe3f 100644 --- a/src/modules/employees/dtos/list-employee.dto.ts +++ b/src/modules/employees/dtos/list-employee.dto.ts @@ -1,8 +1,8 @@ -export class EmployeeListItemDto { - first_name: string; - last_name: string; - email: string; - supervisor_full_name: string | null; - company_name: number | null; - job_title: string | null; -} \ No newline at end of file +// export class EmployeeListItemDto { +// first_name: string; +// last_name: string; +// email: string; +// supervisor_full_name: string | null; +// company_name: number | null; +// job_title: string | null; +// } \ No newline at end of file diff --git a/src/modules/employees/dtos/profil-employee.dto.ts b/src/modules/employees/dtos/profil-employee.dto.ts index c6836cf..adbf38e 100644 --- a/src/modules/employees/dtos/profil-employee.dto.ts +++ b/src/modules/employees/dtos/profil-employee.dto.ts @@ -1,13 +1,13 @@ -export class EmployeeProfileItemDto { - first_name: string; - last_name: string; - employee_full_name: string; - supervisor_full_name: string | null; - company_name: number | null; - job_title: string | null; - email: string | null; - phone_number: string; - first_work_day: string; - last_work_day?: string | null; - residence: string | null; -} \ No newline at end of file +// export class EmployeeProfileItemDto { +// first_name: string; +// last_name: string; +// employee_full_name: string; +// supervisor_full_name: string | null; +// company_name: number | null; +// job_title: string | null; +// email: string | null; +// phone_number: string; +// first_work_day: string; +// last_work_day?: string | null; +// residence: string | null; +// } \ No newline at end of file diff --git a/src/modules/employees/dtos/update-employee.dto.ts b/src/modules/employees/dtos/update-employee.dto.ts index 334a01a..1efbbfd 100644 --- a/src/modules/employees/dtos/update-employee.dto.ts +++ b/src/modules/employees/dtos/update-employee.dto.ts @@ -1,22 +1,22 @@ -import { ApiProperty, PartialType } from '@nestjs/swagger'; -import { CreateEmployeeDto } from './create-employee.dto'; -import { IsDateString, IsOptional, Max } from 'class-validator'; +// import { ApiProperty, PartialType } from '@nestjs/swagger'; +// import { CreateEmployeeDto } from './create-employee.dto'; +// import { IsDateString, IsOptional, Max } from 'class-validator'; -export class UpdateEmployeeDto extends PartialType(CreateEmployeeDto) { - @ApiProperty({ required: false, type: Date, description: 'New hire date or undefined' }) - @IsDateString() - @IsOptional() - first_work_day?: string; +// export class UpdateEmployeeDto extends PartialType(CreateEmployeeDto) { +// @ApiProperty({ required: false, type: Date, description: 'New hire date or undefined' }) +// @IsDateString() +// @IsOptional() +// first_work_day?: string; - @ApiProperty({ required: false, type: Date, description: 'Termination date (null to restore)' }) - @IsDateString() - @IsOptional() - last_work_day?: string; +// @ApiProperty({ required: false, type: Date, description: 'Termination date (null to restore)' }) +// @IsDateString() +// @IsOptional() +// last_work_day?: string; - @ApiProperty({ required: false, type: Number, description: 'Supervisor ID' }) - @IsOptional() - supervisor_id?: number; +// @ApiProperty({ required: false, type: Number, description: 'Supervisor ID' }) +// @IsOptional() +// supervisor_id?: number; - @IsOptional() - phone_number: string; -} +// @IsOptional() +// phone_number: string; +// } diff --git a/src/modules/employees/services/employees.service.ts b/src/modules/employees/services/employees.service.ts index 3627476..b44bf7d 100644 --- a/src/modules/employees/services/employees.service.ts +++ b/src/modules/employees/services/employees.service.ts @@ -1,230 +1,230 @@ -import { Injectable, NotFoundException } from '@nestjs/common'; -import { PrismaService } from 'src/prisma/prisma.service'; -import { EmployeeListItemDto } from '../dtos/list-employee.dto'; -import { EmployeeProfileItemDto } from '../dtos/profil-employee.dto'; +// import { Injectable, NotFoundException } from '@nestjs/common'; +// import { PrismaService } from 'src/prisma/prisma.service'; +// import { EmployeeListItemDto } from '../dtos/list-employee.dto'; +// import { EmployeeProfileItemDto } from '../dtos/profil-employee.dto'; -@Injectable() -export class EmployeesService { - constructor(private readonly prisma: PrismaService) { } +// @Injectable() +// export class EmployeesService { +// constructor(private readonly prisma: PrismaService) { } - findListEmployees(): Promise { - return this.prisma.employees.findMany({ - select: { - user: { - select: { - first_name: true, - last_name: true, - email: true, - }, - }, - supervisor: { - select: { - user: { - select: { - first_name: true, - last_name: true, - }, - }, - }, - }, - job_title: true, - company_code: true, - } - }).then(rows => rows.map(r => ({ - first_name: r.user.first_name, - last_name: r.user.last_name, - email: r.user.email, - company_name: r.company_code, - job_title: r.job_title, - employee_full_name: `${r.user.first_name} ${r.user.last_name}`, - supervisor_full_name: r.supervisor ? `${r.supervisor.user.first_name} ${r.supervisor.user.last_name}` : null, - })), - ); - } +// findListEmployees(): Promise { +// return this.prisma.employees.findMany({ +// select: { +// user: { +// select: { +// first_name: true, +// last_name: true, +// email: true, +// }, +// }, +// supervisor: { +// select: { +// user: { +// select: { +// first_name: true, +// last_name: true, +// }, +// }, +// }, +// }, +// job_title: true, +// company_code: true, +// } +// }).then(rows => rows.map(r => ({ +// first_name: r.user.first_name, +// last_name: r.user.last_name, +// email: r.user.email, +// company_name: r.company_code, +// job_title: r.job_title, +// employee_full_name: `${r.user.first_name} ${r.user.last_name}`, +// supervisor_full_name: r.supervisor ? `${r.supervisor.user.first_name} ${r.supervisor.user.last_name}` : null, +// })), +// ); +// } - async findOneProfile(email: string): Promise { - const emp = await this.prisma.employees.findFirst({ - where: { user: { email } }, - select: { - user: { - select: { - first_name: true, - last_name: true, - email: true, - phone_number: true, - residence: true, - }, - }, - supervisor: { - select: { - user: { - select: { - first_name: true, - last_name: true, - }, - }, - }, - }, - job_title: true, - company_code: true, - first_work_day: true, - last_work_day: true, - } - }); - if (!emp) throw new NotFoundException(`Employee with email ${email} not found`); +// async findOneProfile(email: string): Promise { +// const emp = await this.prisma.employees.findFirst({ +// where: { user: { email } }, +// select: { +// user: { +// select: { +// first_name: true, +// last_name: true, +// email: true, +// phone_number: true, +// residence: true, +// }, +// }, +// supervisor: { +// select: { +// user: { +// select: { +// first_name: true, +// last_name: true, +// }, +// }, +// }, +// }, +// job_title: true, +// company_code: true, +// first_work_day: true, +// last_work_day: true, +// } +// }); +// if (!emp) throw new NotFoundException(`Employee with email ${email} not found`); - return { - first_name: emp.user.first_name, - last_name: emp.user.last_name, - email: emp.user.email, - residence: emp.user.residence, - phone_number: emp.user.phone_number, - company_name: emp.company_code, - job_title: emp.job_title, - employee_full_name: `${emp.user.first_name} ${emp.user.last_name}`, - first_work_day: emp.first_work_day.toISOString().slice(0, 10), - last_work_day: emp.last_work_day ? emp.last_work_day.toISOString().slice(0, 10) : null, - supervisor_full_name: emp.supervisor ? `${emp.supervisor.user.first_name}, ${emp.supervisor.user.last_name}` : null, - }; - } +// return { +// first_name: emp.user.first_name, +// last_name: emp.user.last_name, +// email: emp.user.email, +// residence: emp.user.residence, +// phone_number: emp.user.phone_number, +// company_name: emp.company_code, +// job_title: emp.job_title, +// employee_full_name: `${emp.user.first_name} ${emp.user.last_name}`, +// first_work_day: emp.first_work_day.toISOString().slice(0, 10), +// last_work_day: emp.last_work_day ? emp.last_work_day.toISOString().slice(0, 10) : null, +// supervisor_full_name: emp.supervisor ? `${emp.supervisor.user.first_name}, ${emp.supervisor.user.last_name}` : null, +// }; +// } - //_____________________________________________________________________________________________ - // Deprecated or unused methods - //_____________________________________________________________________________________________ +// //_____________________________________________________________________________________________ +// // Deprecated or unused methods +// //_____________________________________________________________________________________________ - // async create(dto: CreateEmployeeDto): Promise { - // const { - // first_name, - // last_name, - // email, - // phone_number, - // residence, - // external_payroll_id, - // company_code, - // job_title, - // first_work_day, - // last_work_day, - // is_supervisor, - // } = dto; +// // async create(dto: CreateEmployeeDto): Promise { +// // const { +// // first_name, +// // last_name, +// // email, +// // phone_number, +// // residence, +// // external_payroll_id, +// // company_code, +// // job_title, +// // first_work_day, +// // last_work_day, +// // is_supervisor, +// // } = dto; - // return this.prisma.$transaction(async (transaction) => { - // const user: Users = await transaction.users.create({ - // data: { - // first_name, - // last_name, - // email, - // phone_number, - // residence, - // }, - // }); - // return transaction.employees.create({ - // data: { - // user_id: user.id, - // external_payroll_id, - // company_code, - // job_title, - // first_work_day, - // last_work_day, - // is_supervisor, - // }, - // }); - // }); - // } +// // return this.prisma.$transaction(async (transaction) => { +// // const user: Users = await transaction.users.create({ +// // data: { +// // first_name, +// // last_name, +// // email, +// // phone_number, +// // residence, +// // }, +// // }); +// // return transaction.employees.create({ +// // data: { +// // user_id: user.id, +// // external_payroll_id, +// // company_code, +// // job_title, +// // first_work_day, +// // last_work_day, +// // is_supervisor, +// // }, +// // }); +// // }); +// // } - // findAll(): Promise { - // return this.prisma.employees.findMany({ - // include: { user: true }, - // }); - // } +// // findAll(): Promise { +// // return this.prisma.employees.findMany({ +// // include: { user: true }, +// // }); +// // } - // async findOne(email: string): Promise { - // const emp = await this.prisma.employees.findFirst({ - // where: { user: { email } }, - // include: { user: true }, - // }); +// // async findOne(email: string): Promise { +// // const emp = await this.prisma.employees.findFirst({ +// // where: { user: { email } }, +// // include: { user: true }, +// // }); - // //add search for archived employees - // if (!emp) { - // throw new NotFoundException(`Employee with email: ${email} not found`); - // } - // return emp; - // } +// // //add search for archived employees +// // if (!emp) { +// // throw new NotFoundException(`Employee with email: ${email} not found`); +// // } +// // return emp; +// // } - // async update( - // email: string, - // dto: UpdateEmployeeDto, - // ): Promise { - // const emp = await this.findOne(email); +// // async update( +// // email: string, +// // dto: UpdateEmployeeDto, +// // ): Promise { +// // const emp = await this.findOne(email); - // const { - // first_name, - // last_name, - // phone_number, - // residence, - // external_payroll_id, - // company_code, - // job_title, - // first_work_day, - // last_work_day, - // is_supervisor, - // email: new_email, - // } = dto; +// // const { +// // first_name, +// // last_name, +// // phone_number, +// // residence, +// // external_payroll_id, +// // company_code, +// // job_title, +// // first_work_day, +// // last_work_day, +// // is_supervisor, +// // email: new_email, +// // } = dto; - // return this.prisma.$transaction(async (transaction) => { - // if( - // first_name !== undefined || - // last_name !== undefined || - // new_email !== undefined || - // phone_number !== undefined || - // residence !== undefined - // ){ - // await transaction.users.update({ - // where: { id: emp.user_id }, - // data: { - // ...(first_name !== undefined && { first_name }), - // ...(last_name !== undefined && { last_name }), - // ...(email !== undefined && { email }), - // ...(phone_number !== undefined && { phone_number }), - // ...(residence !== undefined && { residence }), - // }, - // }); - // } +// // return this.prisma.$transaction(async (transaction) => { +// // if( +// // first_name !== undefined || +// // last_name !== undefined || +// // new_email !== undefined || +// // phone_number !== undefined || +// // residence !== undefined +// // ){ +// // await transaction.users.update({ +// // where: { id: emp.user_id }, +// // data: { +// // ...(first_name !== undefined && { first_name }), +// // ...(last_name !== undefined && { last_name }), +// // ...(email !== undefined && { email }), +// // ...(phone_number !== undefined && { phone_number }), +// // ...(residence !== undefined && { residence }), +// // }, +// // }); +// // } - // const updated = await transaction.employees.update({ - // where: { id: emp.id }, - // data: { - // ...(external_payroll_id !== undefined && { external_payroll_id }), - // ...(company_code !== undefined && { company_code }), - // ...(first_work_day !== undefined && { first_work_day }), - // ...(last_work_day !== undefined && { last_work_day }), - // ...(job_title !== undefined && { job_title }), - // ...(is_supervisor !== undefined && { is_supervisor }), - // }, - // }); - // return updated; - // }); - // } +// // const updated = await transaction.employees.update({ +// // where: { id: emp.id }, +// // data: { +// // ...(external_payroll_id !== undefined && { external_payroll_id }), +// // ...(company_code !== undefined && { company_code }), +// // ...(first_work_day !== undefined && { first_work_day }), +// // ...(last_work_day !== undefined && { last_work_day }), +// // ...(job_title !== undefined && { job_title }), +// // ...(is_supervisor !== undefined && { is_supervisor }), +// // }, +// // }); +// // return updated; +// // }); +// // } - // async remove(email: string): Promise { +// // async remove(email: string): Promise { - // const emp = await this.findOne(email); +// // const emp = await this.findOne(email); - // return this.prisma.$transaction(async (transaction) => { - // await transaction.employees.updateMany({ - // where: { supervisor_id: emp.id }, - // data: { supervisor_id: null }, - // }); - // const deleted_employee = await transaction.employees.delete({ - // where: {id: emp.id }, - // }); - // await transaction.users.delete({ - // where: { id: emp.user_id }, - // }); - // return deleted_employee; - // }); - // } +// // return this.prisma.$transaction(async (transaction) => { +// // await transaction.employees.updateMany({ +// // where: { supervisor_id: emp.id }, +// // data: { supervisor_id: null }, +// // }); +// // const deleted_employee = await transaction.employees.delete({ +// // where: {id: emp.id }, +// // }); +// // await transaction.users.delete({ +// // where: { id: emp.user_id }, +// // }); +// // return deleted_employee; +// // }); +// // } -} \ No newline at end of file +// } \ No newline at end of file diff --git a/src/modules/employees/utils/employee.utils.ts b/src/modules/employees/utils/employee.utils.ts index 3534f3d..04f2540 100644 --- a/src/modules/employees/utils/employee.utils.ts +++ b/src/modules/employees/utils/employee.utils.ts @@ -1,9 +1,9 @@ -export function toDateOrNull(v?: string | null): Date | null { - if (!v) return null; - const day = new Date(v); - return isNaN(day.getTime()) ? null : day; -} -export function toDateOrUndefined(v?: string | null): Date | undefined { - const day = toDateOrNull(v ?? undefined); - return day === null ? undefined : day; -} \ No newline at end of file +// export function toDateOrNull(v?: string | null): Date | null { +// if (!v) return null; +// const day = new Date(v); +// return isNaN(day.getTime()) ? null : day; +// } +// export function toDateOrUndefined(v?: string | null): Date | undefined { +// const day = toDateOrNull(v ?? undefined); +// return day === null ? undefined : day; +// } \ No newline at end of file From 6c44bb5ad2aebf8dbd9e48c024d2a8d3ffd82c81 Mon Sep 17 00:00:00 2001 From: Matthieu Haineault Date: Mon, 27 Oct 2025 09:50:22 -0400 Subject: [PATCH 5/5] refactor(modules): moved some module to change the structure to domain oriented --- docs/swagger/swagger-spec.json | 24 - src/app.module.ts | 8 +- .../authentication/auth.module.ts | 0 .../controllers/auth.controller.ts | 52 +- .../guards/authentik-auth.guard.ts | 22 +- .../serializers/express-session.serializer.ts | 0 .../services/authentik-auth.service.ts | 28 +- .../strategies/authentik.strategy.ts | 126 ++--- .../controllers/employees.controller.ts | 0 .../employees/dtos/create-employee.dto.ts | 0 .../employees/dtos/list-employee.dto.ts | 0 .../employees/dtos/profil-employee.dto.ts | 0 .../employees/dtos/update-employee.dto.ts | 0 .../employees/employees.module.ts | 5 +- .../services/employees-archival.service.ts | 0 .../employees/services/employees.service.ts | 0 .../employees/utils/employee.utils.ts | 0 .../controllers/oauth-sessions.controller.ts | 0 .../dtos/create-oauth-session.dto.ts | 0 .../dtos/update-oauth-session.dto.ts | 0 .../oauth-sessions/oauth-sessions.module.ts | 0 .../services/oauth-sessions.service.ts | 0 .../controllers/preferences.controller.ts | 0 .../preferences/dtos/preferences.dto.ts | 0 .../preferences/preferences.module.ts | 0 .../services/preferences.service.ts | 0 .../users-management/dtos/user.dto.ts | 0 .../services/abstract-user.service.ts | 0 .../services/users.service.ts | 0 .../users-management/users.module.ts | 0 .../controllers/customers.controller.ts | 68 --- src/modules/customers/customers.module.ts | 10 - .../customers/dtos/create-customer.dto.ts | 79 ---- .../customers/dtos/update-customer.dto.ts | 4 - .../customers/services/customers.service.ts | 93 ---- src/modules/employees/employees.module.ts | 12 - .../controllers/leave-requests.controller.ts | 48 +- .../leave-requests/leave-requests.module.ts | 55 +-- .../holiday-leave-requests.service.ts | 134 +++--- .../services/leave-request.service.ts | 447 +++++++++--------- .../services/sick-leave-requests.service.ts | 175 +++---- .../vacation-leave-requests.service.ts | 168 +++---- .../utils/leave-request.util.ts | 186 ++++---- .../time-and-attendance.module.ts | 27 +- 44 files changed, 739 insertions(+), 1032 deletions(-) rename src/{modules => identity-and-account}/authentication/auth.module.ts (100%) rename src/{modules => identity-and-account}/authentication/controllers/auth.controller.ts (96%) rename src/{modules => identity-and-account}/authentication/guards/authentik-auth.guard.ts (97%) rename src/{modules => identity-and-account}/authentication/serializers/express-session.serializer.ts (100%) rename src/{modules => identity-and-account}/authentication/services/authentik-auth.service.ts (75%) rename src/{modules => identity-and-account}/authentication/strategies/authentik.strategy.ts (97%) rename src/{modules => identity-and-account}/employees/controllers/employees.controller.ts (100%) rename src/{modules => identity-and-account}/employees/dtos/create-employee.dto.ts (100%) rename src/{modules => identity-and-account}/employees/dtos/list-employee.dto.ts (100%) rename src/{modules => identity-and-account}/employees/dtos/profil-employee.dto.ts (100%) rename src/{modules => identity-and-account}/employees/dtos/update-employee.dto.ts (100%) rename src/{modules => identity-and-account}/employees/services/employees-archival.service.ts (100%) rename src/{modules => identity-and-account}/employees/services/employees.service.ts (100%) rename src/{modules => identity-and-account}/employees/utils/employee.utils.ts (100%) rename src/{modules => identity-and-account}/oauth-sessions/controllers/oauth-sessions.controller.ts (100%) rename src/{modules => identity-and-account}/oauth-sessions/dtos/create-oauth-session.dto.ts (100%) rename src/{modules => identity-and-account}/oauth-sessions/dtos/update-oauth-session.dto.ts (100%) rename src/{modules => identity-and-account}/oauth-sessions/oauth-sessions.module.ts (100%) rename src/{modules => identity-and-account}/oauth-sessions/services/oauth-sessions.service.ts (100%) rename src/{modules => identity-and-account}/preferences/controllers/preferences.controller.ts (100%) rename src/{modules => identity-and-account}/preferences/dtos/preferences.dto.ts (100%) rename src/{modules => identity-and-account}/preferences/preferences.module.ts (100%) rename src/{modules => identity-and-account}/preferences/services/preferences.service.ts (100%) rename src/{modules => identity-and-account}/users-management/dtos/user.dto.ts (100%) rename src/{modules => identity-and-account}/users-management/services/abstract-user.service.ts (100%) rename src/{modules => identity-and-account}/users-management/services/users.service.ts (100%) rename src/{modules => identity-and-account}/users-management/users.module.ts (100%) delete mode 100644 src/modules/customers/controllers/customers.controller.ts delete mode 100644 src/modules/customers/customers.module.ts delete mode 100644 src/modules/customers/dtos/create-customer.dto.ts delete mode 100644 src/modules/customers/dtos/update-customer.dto.ts delete mode 100644 src/modules/customers/services/customers.service.ts delete mode 100644 src/modules/employees/employees.module.ts diff --git a/docs/swagger/swagger-spec.json b/docs/swagger/swagger-spec.json index 0462102..85ce3df 100644 --- a/docs/swagger/swagger-spec.json +++ b/docs/swagger/swagger-spec.json @@ -828,30 +828,6 @@ "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": { diff --git a/src/app.module.ts b/src/app.module.ts index 4519929..c8035c4 100644 --- a/src/app.module.ts +++ b/src/app.module.ts @@ -2,17 +2,17 @@ import { BadRequestException, Module, ValidationPipe } from '@nestjs/common'; import { AppController } from './app.controller'; import { AppService } from './app.service'; // import { ArchivalModule } from './modules/archival/archival.module'; -import { AuthenticationModule } from './modules/authentication/auth.module'; +import { AuthenticationModule } from './identity-and-account/authentication/auth.module'; // import { BankCodesModule } from './modules/bank-codes/bank-codes.module'; // import { CsvExportModule } from './modules/exports/csv-exports.module'; import { HealthModule } from './health/health.module'; import { HealthController } from './health/health.controller'; import { NotificationsModule } from './modules/notifications/notifications.module'; -import { OauthSessionsModule } from './modules/oauth-sessions/oauth-sessions.module'; -import { PreferencesModule } from './modules/preferences/preferences.module'; +import { OauthSessionsModule } from './identity-and-account/oauth-sessions/oauth-sessions.module'; +import { PreferencesModule } from './identity-and-account/preferences/preferences.module'; import { PrismaModule } from './prisma/prisma.module'; import { ScheduleModule } from '@nestjs/schedule'; -import { UsersModule } from './modules/users-management/users.module'; +import { UsersModule } from './identity-and-account/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'; diff --git a/src/modules/authentication/auth.module.ts b/src/identity-and-account/authentication/auth.module.ts similarity index 100% rename from src/modules/authentication/auth.module.ts rename to src/identity-and-account/authentication/auth.module.ts diff --git a/src/modules/authentication/controllers/auth.controller.ts b/src/identity-and-account/authentication/controllers/auth.controller.ts similarity index 96% rename from src/modules/authentication/controllers/auth.controller.ts rename to src/identity-and-account/authentication/controllers/auth.controller.ts index 248c4d1..15255f1 100644 --- a/src/modules/authentication/controllers/auth.controller.ts +++ b/src/identity-and-account/authentication/controllers/auth.controller.ts @@ -1,26 +1,26 @@ -import { Controller, Get, Req, Res, UnauthorizedException, UseGuards } from '@nestjs/common'; -import { OIDCLoginGuard } from '../guards/authentik-auth.guard'; -import { Request, Response } from 'express'; - -@Controller('auth') -export class AuthController { - - @UseGuards(OIDCLoginGuard) - @Get('/v1/login') - login() { } - - @Get('/callback') - @UseGuards(OIDCLoginGuard) - loginCallback(@Req() req: Request, @Res() res: Response) { - res.redirect('http://localhost:9000/#/login-success'); - } - - @Get('/me') - getProfile(@Req() req: Request) { - if (!req.user) { - throw new UnauthorizedException('Not logged in'); - } - return req.user; - } - -} +import { Controller, Get, Req, Res, UnauthorizedException, UseGuards } from '@nestjs/common'; +import { OIDCLoginGuard } from '../guards/authentik-auth.guard'; +import { Request, Response } from 'express'; + +@Controller('auth') +export class AuthController { + + @UseGuards(OIDCLoginGuard) + @Get('/v1/login') + login() { } + + @Get('/callback') + @UseGuards(OIDCLoginGuard) + loginCallback(@Req() req: Request, @Res() res: Response) { + res.redirect('http://localhost:9000/#/login-success'); + } + + @Get('/me') + getProfile(@Req() req: Request) { + if (!req.user) { + throw new UnauthorizedException('Not logged in'); + } + return req.user; + } + +} diff --git a/src/modules/authentication/guards/authentik-auth.guard.ts b/src/identity-and-account/authentication/guards/authentik-auth.guard.ts similarity index 97% rename from src/modules/authentication/guards/authentik-auth.guard.ts rename to src/identity-and-account/authentication/guards/authentik-auth.guard.ts index df9208c..ff4f44d 100644 --- a/src/modules/authentication/guards/authentik-auth.guard.ts +++ b/src/identity-and-account/authentication/guards/authentik-auth.guard.ts @@ -1,12 +1,12 @@ -import { ExecutionContext, Injectable } from '@nestjs/common'; -import { AuthGuard } from '@nestjs/passport'; - -@Injectable() -export class OIDCLoginGuard extends AuthGuard('openidconnect') { - async canActivate(context: ExecutionContext) { - const result = (await super.canActivate(context)) as boolean; - const request = context.switchToHttp().getRequest(); - await super.logIn(request); - return result; - } +import { ExecutionContext, Injectable } from '@nestjs/common'; +import { AuthGuard } from '@nestjs/passport'; + +@Injectable() +export class OIDCLoginGuard extends AuthGuard('openidconnect') { + async canActivate(context: ExecutionContext) { + const result = (await super.canActivate(context)) as boolean; + const request = context.switchToHttp().getRequest(); + await super.logIn(request); + return result; + } } \ No newline at end of file diff --git a/src/modules/authentication/serializers/express-session.serializer.ts b/src/identity-and-account/authentication/serializers/express-session.serializer.ts similarity index 100% rename from src/modules/authentication/serializers/express-session.serializer.ts rename to src/identity-and-account/authentication/serializers/express-session.serializer.ts diff --git a/src/modules/authentication/services/authentik-auth.service.ts b/src/identity-and-account/authentication/services/authentik-auth.service.ts similarity index 75% rename from src/modules/authentication/services/authentik-auth.service.ts rename to src/identity-and-account/authentication/services/authentik-auth.service.ts index 9d6514c..974a1eb 100644 --- a/src/modules/authentication/services/authentik-auth.service.ts +++ b/src/identity-and-account/authentication/services/authentik-auth.service.ts @@ -1,14 +1,14 @@ - -import { Injectable } from '@nestjs/common'; -import { UsersService } from 'src/modules/users-management/services/users.service'; - -@Injectable() -export class AuthentikAuthService { - constructor(private usersService: UsersService) {} - - async validateUser(user_email: string): Promise { - const user = await this.usersService.findOneByEmail(user_email); - - return user; - } -} + +import { Injectable } from '@nestjs/common'; +import { UsersService } from 'src/identity-and-account/users-management/services/users.service'; + +@Injectable() +export class AuthentikAuthService { + constructor(private usersService: UsersService) {} + + async validateUser(user_email: string): Promise { + const user = await this.usersService.findOneByEmail(user_email); + + return user; + } +} diff --git a/src/modules/authentication/strategies/authentik.strategy.ts b/src/identity-and-account/authentication/strategies/authentik.strategy.ts similarity index 97% rename from src/modules/authentication/strategies/authentik.strategy.ts rename to src/identity-and-account/authentication/strategies/authentik.strategy.ts index 98602c5..6609356 100644 --- a/src/modules/authentication/strategies/authentik.strategy.ts +++ b/src/identity-and-account/authentication/strategies/authentik.strategy.ts @@ -1,63 +1,63 @@ - -import { Strategy as OIDCStrategy, Profile, VerifyCallback } from 'passport-openidconnect'; -import { PassportStrategy } from '@nestjs/passport'; -import { Injectable } from '@nestjs/common'; -import { AuthentikAuthService } from '../services/authentik-auth.service'; -import { ValidationError } from 'class-validator'; - -export interface AuthentikPayload { - iss: string; // Issuer - sub: string; // Subject (user ID) - aud: string; // Audience (client ID) - exp: number; // Expiration time (Unix) - iat: number; // Issued at time (Unix) - auth_time: number; // Time of authentication (Unix) - acr?: string; // Auth Context Class Reference - amr?: string[]; // Auth Method References (e.g., ['pwd']) - email: string; - email_verified: boolean; - name?: string; - given_name?: string; - preferred_username?: string; - nickname?: string; - groups?: string[]; -} - -@Injectable() -export class AuthentikStrategy extends PassportStrategy(OIDCStrategy, 'openidconnect', 8) { - constructor(private authentikAuthService: AuthentikAuthService) { - super({ - issuer: process.env.AUTHENTIK_ISSUER || "ISSUER_MISSING", - clientID: process.env.AUTHENTIK_CLIENT_ID || 'CLIENT_ID_MISSING', - clientSecret: process.env.AUTHENTIK_CLIENT_SECRET || 'CLIENT_SECRET_MISSING', - callbackURL: process.env.AUTHENTIK_CALLBACK_URL || 'CALLBACK_URL_MISSING', - authorizationURL: process.env.AUTHENTIK_AUTH_URL || 'AUTH_URL_MISSING', - tokenURL: process.env.AUTHENTIK_TOKEN_URL || 'TOKEN_URL_MISSING', - userInfoURL: process.env.AUTHENTIK_USERINFO_URL || 'USERINFO_URL_MISSING', - scope: ['openid', 'email', 'profile', 'offline_access'], - },); - } - - async validate( - _issuer: string, - profile: Profile, - _context: any, - _idToken: string, - _accessToken: string, - _refreshToken: string, - _params: any, - cb: VerifyCallback, - ): Promise { - try { - const email = profile.emails?.[0]?.value; - if (!email) return cb(new Error('Missing email in OIDC profile'), false); - - const user = await this.authentikAuthService.validateUser(email); - if (!user) return cb(new Error('User not found'), false); - - return cb(null, user); - } catch (err) { - return cb(err, false); - } - } -} + +import { Strategy as OIDCStrategy, Profile, VerifyCallback } from 'passport-openidconnect'; +import { PassportStrategy } from '@nestjs/passport'; +import { Injectable } from '@nestjs/common'; +import { AuthentikAuthService } from '../services/authentik-auth.service'; +import { ValidationError } from 'class-validator'; + +export interface AuthentikPayload { + iss: string; // Issuer + sub: string; // Subject (user ID) + aud: string; // Audience (client ID) + exp: number; // Expiration time (Unix) + iat: number; // Issued at time (Unix) + auth_time: number; // Time of authentication (Unix) + acr?: string; // Auth Context Class Reference + amr?: string[]; // Auth Method References (e.g., ['pwd']) + email: string; + email_verified: boolean; + name?: string; + given_name?: string; + preferred_username?: string; + nickname?: string; + groups?: string[]; +} + +@Injectable() +export class AuthentikStrategy extends PassportStrategy(OIDCStrategy, 'openidconnect', 8) { + constructor(private authentikAuthService: AuthentikAuthService) { + super({ + issuer: process.env.AUTHENTIK_ISSUER || "ISSUER_MISSING", + clientID: process.env.AUTHENTIK_CLIENT_ID || 'CLIENT_ID_MISSING', + clientSecret: process.env.AUTHENTIK_CLIENT_SECRET || 'CLIENT_SECRET_MISSING', + callbackURL: process.env.AUTHENTIK_CALLBACK_URL || 'CALLBACK_URL_MISSING', + authorizationURL: process.env.AUTHENTIK_AUTH_URL || 'AUTH_URL_MISSING', + tokenURL: process.env.AUTHENTIK_TOKEN_URL || 'TOKEN_URL_MISSING', + userInfoURL: process.env.AUTHENTIK_USERINFO_URL || 'USERINFO_URL_MISSING', + scope: ['openid', 'email', 'profile', 'offline_access'], + },); + } + + async validate( + _issuer: string, + profile: Profile, + _context: any, + _idToken: string, + _accessToken: string, + _refreshToken: string, + _params: any, + cb: VerifyCallback, + ): Promise { + try { + const email = profile.emails?.[0]?.value; + if (!email) return cb(new Error('Missing email in OIDC profile'), false); + + const user = await this.authentikAuthService.validateUser(email); + if (!user) return cb(new Error('User not found'), false); + + return cb(null, user); + } catch (err) { + return cb(err, false); + } + } +} diff --git a/src/modules/employees/controllers/employees.controller.ts b/src/identity-and-account/employees/controllers/employees.controller.ts similarity index 100% rename from src/modules/employees/controllers/employees.controller.ts rename to src/identity-and-account/employees/controllers/employees.controller.ts diff --git a/src/modules/employees/dtos/create-employee.dto.ts b/src/identity-and-account/employees/dtos/create-employee.dto.ts similarity index 100% rename from src/modules/employees/dtos/create-employee.dto.ts rename to src/identity-and-account/employees/dtos/create-employee.dto.ts diff --git a/src/modules/employees/dtos/list-employee.dto.ts b/src/identity-and-account/employees/dtos/list-employee.dto.ts similarity index 100% rename from src/modules/employees/dtos/list-employee.dto.ts rename to src/identity-and-account/employees/dtos/list-employee.dto.ts diff --git a/src/modules/employees/dtos/profil-employee.dto.ts b/src/identity-and-account/employees/dtos/profil-employee.dto.ts similarity index 100% rename from src/modules/employees/dtos/profil-employee.dto.ts rename to src/identity-and-account/employees/dtos/profil-employee.dto.ts diff --git a/src/modules/employees/dtos/update-employee.dto.ts b/src/identity-and-account/employees/dtos/update-employee.dto.ts similarity index 100% rename from src/modules/employees/dtos/update-employee.dto.ts rename to src/identity-and-account/employees/dtos/update-employee.dto.ts diff --git a/src/identity-and-account/employees/employees.module.ts b/src/identity-and-account/employees/employees.module.ts index 7ce6f04..676f4b0 100644 --- a/src/identity-and-account/employees/employees.module.ts +++ b/src/identity-and-account/employees/employees.module.ts @@ -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'; // @Module({ // imports: [SharedModule], // controllers: [EmployeesController], -// providers: [EmployeesService, EmployeesArchivalService], -// exports: [EmployeesService, EmployeesArchivalService], +// providers: [EmployeesService], +// exports: [EmployeesService ], // }) // export class EmployeesModule {} diff --git a/src/modules/employees/services/employees-archival.service.ts b/src/identity-and-account/employees/services/employees-archival.service.ts similarity index 100% rename from src/modules/employees/services/employees-archival.service.ts rename to src/identity-and-account/employees/services/employees-archival.service.ts diff --git a/src/modules/employees/services/employees.service.ts b/src/identity-and-account/employees/services/employees.service.ts similarity index 100% rename from src/modules/employees/services/employees.service.ts rename to src/identity-and-account/employees/services/employees.service.ts diff --git a/src/modules/employees/utils/employee.utils.ts b/src/identity-and-account/employees/utils/employee.utils.ts similarity index 100% rename from src/modules/employees/utils/employee.utils.ts rename to src/identity-and-account/employees/utils/employee.utils.ts diff --git a/src/modules/oauth-sessions/controllers/oauth-sessions.controller.ts b/src/identity-and-account/oauth-sessions/controllers/oauth-sessions.controller.ts similarity index 100% rename from src/modules/oauth-sessions/controllers/oauth-sessions.controller.ts rename to src/identity-and-account/oauth-sessions/controllers/oauth-sessions.controller.ts diff --git a/src/modules/oauth-sessions/dtos/create-oauth-session.dto.ts b/src/identity-and-account/oauth-sessions/dtos/create-oauth-session.dto.ts similarity index 100% rename from src/modules/oauth-sessions/dtos/create-oauth-session.dto.ts rename to src/identity-and-account/oauth-sessions/dtos/create-oauth-session.dto.ts diff --git a/src/modules/oauth-sessions/dtos/update-oauth-session.dto.ts b/src/identity-and-account/oauth-sessions/dtos/update-oauth-session.dto.ts similarity index 100% rename from src/modules/oauth-sessions/dtos/update-oauth-session.dto.ts rename to src/identity-and-account/oauth-sessions/dtos/update-oauth-session.dto.ts diff --git a/src/modules/oauth-sessions/oauth-sessions.module.ts b/src/identity-and-account/oauth-sessions/oauth-sessions.module.ts similarity index 100% rename from src/modules/oauth-sessions/oauth-sessions.module.ts rename to src/identity-and-account/oauth-sessions/oauth-sessions.module.ts diff --git a/src/modules/oauth-sessions/services/oauth-sessions.service.ts b/src/identity-and-account/oauth-sessions/services/oauth-sessions.service.ts similarity index 100% rename from src/modules/oauth-sessions/services/oauth-sessions.service.ts rename to src/identity-and-account/oauth-sessions/services/oauth-sessions.service.ts diff --git a/src/modules/preferences/controllers/preferences.controller.ts b/src/identity-and-account/preferences/controllers/preferences.controller.ts similarity index 100% rename from src/modules/preferences/controllers/preferences.controller.ts rename to src/identity-and-account/preferences/controllers/preferences.controller.ts diff --git a/src/modules/preferences/dtos/preferences.dto.ts b/src/identity-and-account/preferences/dtos/preferences.dto.ts similarity index 100% rename from src/modules/preferences/dtos/preferences.dto.ts rename to src/identity-and-account/preferences/dtos/preferences.dto.ts diff --git a/src/modules/preferences/preferences.module.ts b/src/identity-and-account/preferences/preferences.module.ts similarity index 100% rename from src/modules/preferences/preferences.module.ts rename to src/identity-and-account/preferences/preferences.module.ts diff --git a/src/modules/preferences/services/preferences.service.ts b/src/identity-and-account/preferences/services/preferences.service.ts similarity index 100% rename from src/modules/preferences/services/preferences.service.ts rename to src/identity-and-account/preferences/services/preferences.service.ts diff --git a/src/modules/users-management/dtos/user.dto.ts b/src/identity-and-account/users-management/dtos/user.dto.ts similarity index 100% rename from src/modules/users-management/dtos/user.dto.ts rename to src/identity-and-account/users-management/dtos/user.dto.ts diff --git a/src/modules/users-management/services/abstract-user.service.ts b/src/identity-and-account/users-management/services/abstract-user.service.ts similarity index 100% rename from src/modules/users-management/services/abstract-user.service.ts rename to src/identity-and-account/users-management/services/abstract-user.service.ts diff --git a/src/modules/users-management/services/users.service.ts b/src/identity-and-account/users-management/services/users.service.ts similarity index 100% rename from src/modules/users-management/services/users.service.ts rename to src/identity-and-account/users-management/services/users.service.ts diff --git a/src/modules/users-management/users.module.ts b/src/identity-and-account/users-management/users.module.ts similarity index 100% rename from src/modules/users-management/users.module.ts rename to src/identity-and-account/users-management/users.module.ts diff --git a/src/modules/customers/controllers/customers.controller.ts b/src/modules/customers/controllers/customers.controller.ts deleted file mode 100644 index c066342..0000000 --- a/src/modules/customers/controllers/customers.controller.ts +++ /dev/null @@ -1,68 +0,0 @@ -// 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) {} - -// //_____________________________________________________________________________________________ -// // 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 { -// // 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 { -// // 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 { -// // 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 { -// // 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{ -// // return this.customersService.remove(id); -// // } -// } diff --git a/src/modules/customers/customers.module.ts b/src/modules/customers/customers.module.ts deleted file mode 100644 index cccb363..0000000 --- a/src/modules/customers/customers.module.ts +++ /dev/null @@ -1,10 +0,0 @@ - -// 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 {} \ No newline at end of file diff --git a/src/modules/customers/dtos/create-customer.dto.ts b/src/modules/customers/dtos/create-customer.dto.ts deleted file mode 100644 index 8a136ac..0000000 --- a/src/modules/customers/dtos/create-customer.dto.ts +++ /dev/null @@ -1,79 +0,0 @@ -// import { ApiProperty } from "@nestjs/swagger"; -// import { Type } from "class-transformer"; -// import { -// Allow, -// IsEmail, -// IsInt, -// IsNotEmpty, -// IsOptional, -// IsPositive, -// IsString, -// IsUUID, -// } from "class-validator"; - -// export class CreateCustomerDto { -// @ApiProperty({ -// example: 1, -// description: 'Unique ID of a customer(primary-key, auto-incremented)', -// }) -// @Allow() -// id?: number; - -// @ApiProperty({ -// example: '0e6e2e1f-b157-4c7c-ae3f-999b3e4f914d', -// description: 'UUID of the user linked to that customer', -// }) -// @IsUUID() -// @IsOptional() -// user_id?: string; - -// @ApiProperty({ -// example: 'Gandalf', -// description: 'Customer`s first name', -// }) -// @IsString() -// @IsNotEmpty() -// first_name: string; - -// @ApiProperty({ -// example: 'TheGray', -// description: 'Customer`s last name', -// }) -// @IsString() -// @IsNotEmpty() -// last_name: string; - -// @ApiProperty({ -// example: 'you_shall_not_pass@middleEarth.com', -// description: 'Customer`s email', -// }) -// @IsEmail() -// @IsOptional() -// email: string; - -// @ApiProperty({ -// example: '8436637464', -// description: 'Customer`s phone number', -// }) -// @IsString() -// phone_number: string; - -// @ApiProperty({ -// example: '1 Ringbearer`s way, Mount Doom city, ME, T1R 1N6 ', -// description: 'Customer`s residence', -// required: false, -// }) -// @IsString() -// @IsOptional() -// residence?: string; - -// @ApiProperty({ -// example: '4263253', -// description: 'Customer`s invoice number', -// required: false, -// }) -// @Type(() => Number) -// @IsInt() -// @IsNotEmpty() -// invoice_id: number; -// } \ No newline at end of file diff --git a/src/modules/customers/dtos/update-customer.dto.ts b/src/modules/customers/dtos/update-customer.dto.ts deleted file mode 100644 index 2f52413..0000000 --- a/src/modules/customers/dtos/update-customer.dto.ts +++ /dev/null @@ -1,4 +0,0 @@ -// import { PartialType } from "@nestjs/swagger"; -// import { CreateCustomerDto } from "./create-customer.dto"; - -// export class UpdateCustomerDto extends PartialType(CreateCustomerDto) {} \ No newline at end of file diff --git a/src/modules/customers/services/customers.service.ts b/src/modules/customers/services/customers.service.ts deleted file mode 100644 index 2662250..0000000 --- a/src/modules/customers/services/customers.service.ts +++ /dev/null @@ -1,93 +0,0 @@ -// import { Injectable } from '@nestjs/common'; - -// @Injectable() -// export class CustomersService { - -// //_____________________________________________________________________________________________ -// // Deprecated or unused methods -// //_____________________________________________________________________________________________ - -// // constructor(private readonly prisma: PrismaService) {} - -// // async create(dto: CreateCustomerDto): Promise { -// // const { -// // first_name, -// // last_name, -// // email, -// // phone_number, -// // residence, -// // invoice_id, -// // } = dto; - -// // return this.prisma.$transaction(async (transaction) => { -// // const user: Users = await transaction.users.create({ -// // data: { -// // first_name, -// // last_name, -// // email, -// // phone_number, -// // residence, -// // }, -// // }); -// // return transaction.customers.create({ -// // data: { -// // user_id: user.id, -// // invoice_id, -// // }, -// // }); -// // }); -// // } - -// // findAll(): Promise { -// // return this.prisma.customers.findMany({ -// // include: { user: true }, -// // }) -// // } - -// // async findOne(id:number): Promise { -// // const customer = await this.prisma.customers.findUnique({ -// // where: { id }, -// // include: { user: true }, -// // }); -// // if(!customer) throw new NotFoundException(`Customer #${id} not found`); -// // return customer; -// // } - -// // async update(id: number,dto: UpdateCustomerDto): Promise { -// // const customer = await this.findOne(id); - -// // const { -// // first_name, -// // last_name, -// // email, -// // phone_number, -// // residence, -// // invoice_id, -// // } = dto; - -// // return this.prisma.$transaction(async (transaction) => { -// // await transaction.users.update({ -// // where: { id: customer.user_id }, -// // data: { -// // ...(first_name !== undefined && { first_name }), -// // ...(last_name !== undefined && { last_name }), -// // ...(email !== undefined && { email }), -// // ...(phone_number !== undefined && { phone_number }), -// // ...(residence !== undefined && { residence }), -// // }, -// // }); - -// // return transaction.customers.update({ -// // where: { id }, -// // data: { -// // ...(invoice_id !== undefined && { invoice_id }), -// // }, -// // }); -// // }); -// // } - -// // async remove(id: number): Promise { -// // await this.findOne(id); -// // return this.prisma.customers.delete({ where: { id }}); -// // } -// } diff --git a/src/modules/employees/employees.module.ts b/src/modules/employees/employees.module.ts deleted file mode 100644 index 676f4b0..0000000 --- a/src/modules/employees/employees.module.ts +++ /dev/null @@ -1,12 +0,0 @@ -// 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], -// exports: [EmployeesService ], -// }) -// export class EmployeesModule {} diff --git a/src/time-and-attendance/modules/leave-requests/controllers/leave-requests.controller.ts b/src/time-and-attendance/modules/leave-requests/controllers/leave-requests.controller.ts index 7ecce7e..fc934ff 100644 --- a/src/time-and-attendance/modules/leave-requests/controllers/leave-requests.controller.ts +++ b/src/time-and-attendance/modules/leave-requests/controllers/leave-requests.controller.ts @@ -1,30 +1,30 @@ -// import { Body, Controller, Post } from "@nestjs/common"; -// import { ApiBearerAuth, ApiTags } from "@nestjs/swagger"; -// import { LeaveRequestsService } from "../services/leave-request.service"; -// import { UpsertLeaveRequestDto } from "../dtos/upsert-leave-request.dto"; -// import { LeaveTypes } from "@prisma/client"; +import { Body, Controller, Post } from "@nestjs/common"; +import { ApiBearerAuth, ApiTags } from "@nestjs/swagger"; +import { LeaveRequestsService } from "../services/leave-request.service"; +import { UpsertLeaveRequestDto } from "../dtos/upsert-leave-request.dto"; +import { LeaveTypes } from "@prisma/client"; -// @ApiTags('Leave Requests') -// @ApiBearerAuth('access-token') -// // @UseGuards() -// @Controller('leave-requests') -// export class LeaveRequestController { -// constructor(private readonly leave_service: LeaveRequestsService){} +@ApiTags('Leave Requests') +@ApiBearerAuth('access-token') +// @UseGuards() +@Controller('leave-requests') +export class LeaveRequestController { + constructor(private readonly leave_service: LeaveRequestsService){} -// @Post('upsert') -// async upsertLeaveRequest(@Body() dto: UpsertLeaveRequestDto) { -// const { action, leave_requests } = await this.leave_service.handle(dto); -// return { action, leave_requests }; -// }q + @Post('upsert') + async upsertLeaveRequest(@Body() dto: UpsertLeaveRequestDto) { + const { action, leave_requests } = await this.leave_service.handle(dto); + return { action, leave_requests }; + }q -// //TODO: -// /* -// @Get('archive') -// findAllArchived(){...} + //TODO: + /* + @Get('archive') + findAllArchived(){...} -// @Get('archive/:id') -// findOneArchived(id){...} -// */ + @Get('archive/:id') + findOneArchived(id){...} + */ -// } +} diff --git a/src/time-and-attendance/modules/leave-requests/leave-requests.module.ts b/src/time-and-attendance/modules/leave-requests/leave-requests.module.ts index 03ad546..954f07a 100644 --- a/src/time-and-attendance/modules/leave-requests/leave-requests.module.ts +++ b/src/time-and-attendance/modules/leave-requests/leave-requests.module.ts @@ -1,29 +1,30 @@ -// import { PrismaService } from "src/prisma/prisma.service"; -// import { LeaveRequestController } from "./controllers/leave-requests.controller"; -// import { HolidayLeaveRequestsService } from "./services/holiday-leave-requests.service"; -// import { Module } from "@nestjs/common"; -// import { BusinessLogicsModule } from "src/modules/business-logics/business-logics.module"; -// import { VacationLeaveRequestsService } from "./services/vacation-leave-requests.service"; -// import { SickLeaveRequestsService } from "./services/sick-leave-requests.service"; -// import { LeaveRequestsService } from "./services/leave-request.service"; -// import { ShiftsModule } from "../shifts/shifts.module"; -// import { LeaveRequestsUtils } from "./utils/leave-request.util"; -// import { SharedModule } from "../shared/shared.module"; +import { Module } from "@nestjs/common"; +import { PrismaService } from "src/prisma/prisma.service"; +import { BusinessLogicsModule } from "src/time-and-attendance/domains/business-logics.module"; +import { HolidayService } from "src/time-and-attendance/domains/services/holiday.service"; +import { SickLeaveService } from "src/time-and-attendance/domains/services/sick-leave.service"; +import { VacationService } from "src/time-and-attendance/domains/services/vacation.service"; +import { LeaveRequestController } from "src/time-and-attendance/modules/leave-requests/controllers/leave-requests.controller"; +import { LeaveRequestsService } from "src/time-and-attendance/modules/leave-requests/services/leave-request.service"; +import { LeaveRequestsUtils } from "src/time-and-attendance/modules/leave-requests/utils/leave-request.util"; +import { SharedModule } from "src/time-and-attendance/modules/shared/shared.module"; +import { ShiftsModule } from "src/time-and-attendance/modules/time-tracker/shifts/shifts.module"; -// @Module({ -// imports: [BusinessLogicsModule, ShiftsModule, SharedModule], -// controllers: [LeaveRequestController], -// providers: [ -// VacationLeaveRequestsService, -// SickLeaveRequestsService, -// HolidayLeaveRequestsService, -// LeaveRequestsService, -// PrismaService, -// LeaveRequestsUtils, -// ], -// exports: [ -// LeaveRequestsService, -// ], -// }) -// export class LeaveRequestsModule {} \ No newline at end of file +@Module({ + imports: [BusinessLogicsModule, ShiftsModule, SharedModule], + controllers: [LeaveRequestController], + providers: [ + VacationService, + SickLeaveService, + HolidayService, + LeaveRequestsService, + PrismaService, + LeaveRequestsUtils, + ], + exports: [ + LeaveRequestsService, + ], +}) + +export class LeaveRequestsModule {} \ No newline at end of file diff --git a/src/time-and-attendance/modules/leave-requests/services/holiday-leave-requests.service.ts b/src/time-and-attendance/modules/leave-requests/services/holiday-leave-requests.service.ts index ecfa8cc..43f4716 100644 --- a/src/time-and-attendance/modules/leave-requests/services/holiday-leave-requests.service.ts +++ b/src/time-and-attendance/modules/leave-requests/services/holiday-leave-requests.service.ts @@ -1,78 +1,78 @@ -// import { UpsertLeaveRequestDto, UpsertResult } from '../dtos/upsert-leave-request.dto'; -// import { LeaveRequestViewDto } from '../dtos/leave-request-view.dto'; -// import { BadRequestException, Injectable, NotFoundException } from '@nestjs/common'; -// import { LeaveApprovalStatus, LeaveTypes } from '@prisma/client'; -// import { HolidayService } from 'src/modules/business-logics/services/holiday.service'; -// import { PrismaService } from 'src/prisma/prisma.service'; -// import { mapRowToView } from '../mappers/leave-requests.mapper'; -// import { leaveRequestsSelect } from '../utils/leave-requests.select'; -// import { LeaveRequestsUtils} from '../utils/leave-request.util'; -// import { normalizeDates, toDateOnly } from 'src/modules/shared/helpers/date-time.helpers'; -// import { BankCodesResolver } from 'src/modules/shared/utils/resolve-bank-type-id.utils'; -// import { EmailToIdResolver } from 'src/modules/shared/utils/resolve-email-id.utils'; +import { Injectable, NotFoundException, BadRequestException } from "@nestjs/common"; +import { LeaveTypes, LeaveApprovalStatus } from "@prisma/client"; +import { PrismaService } from "src/prisma/prisma.service"; +import { HolidayService } from "src/time-and-attendance/domains/services/holiday.service"; +import { LeaveRequestViewDto } from "src/time-and-attendance/modules/leave-requests/dtos/leave-request-view.dto"; +import { UpsertLeaveRequestDto, UpsertResult } from "src/time-and-attendance/modules/leave-requests/dtos/upsert-leave-request.dto"; +import { mapRowToView } from "src/time-and-attendance/modules/leave-requests/mappers/leave-requests.mapper"; +import { LeaveRequestsUtils } from "src/time-and-attendance/modules/leave-requests/utils/leave-request.util"; +import { leaveRequestsSelect } from "src/time-and-attendance/modules/leave-requests/utils/leave-requests.select"; +import { normalizeDates, toDateOnly } from "src/time-and-attendance/modules/shared/helpers/date-time.helpers"; +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"; -// @Injectable() -// export class HolidayLeaveRequestsService { -// constructor( -// private readonly prisma: PrismaService, -// private readonly holidayService: HolidayService, -// private readonly leaveUtils: LeaveRequestsUtils, -// private readonly emailResolver: EmailToIdResolver, -// private readonly typeResolver: BankCodesResolver, -// ) {} +@Injectable() +export class HolidayLeaveRequestsService { + constructor( + private readonly prisma: PrismaService, + private readonly holidayService: HolidayService, + private readonly leaveUtils: LeaveRequestsUtils, + private readonly emailResolver: EmailToIdResolver, + private readonly typeResolver: BankCodesResolver, + ) {} -// async create(dto: UpsertLeaveRequestDto): Promise { -// const email = dto.email.trim(); -// const employee_id = await this.emailResolver.findIdByEmail(email); -// const bank_code = await this.typeResolver.findByType(LeaveTypes.HOLIDAY); -// if(!bank_code) throw new NotFoundException(`bank_code not found`); -// const dates = normalizeDates(dto.dates); -// if (!dates.length) throw new BadRequestException('Dates array must not be empty'); + async create(dto: UpsertLeaveRequestDto): Promise { + const email = dto.email.trim(); + const employee_id = await this.emailResolver.findIdByEmail(email); + const bank_code = await this.typeResolver.findByType(LeaveTypes.HOLIDAY); + if(!bank_code) throw new NotFoundException(`bank_code not found`); + const dates = normalizeDates(dto.dates); + if (!dates.length) throw new BadRequestException('Dates array must not be empty'); -// const created: LeaveRequestViewDto[] = []; + const created: LeaveRequestViewDto[] = []; -// for (const iso_date of dates) { -// const date = toDateOnly(iso_date); + for (const iso_date of dates) { + const date = toDateOnly(iso_date); -// const existing = await this.prisma.leaveRequests.findUnique({ -// where: { -// leave_per_employee_date: { -// employee_id: employee_id, -// leave_type: LeaveTypes.HOLIDAY, -// date, -// }, -// }, -// select: { id: true }, -// }); -// if (existing) { -// throw new BadRequestException(`Holiday request already exists for ${iso_date}`); -// } + const existing = await this.prisma.leaveRequests.findUnique({ + where: { + leave_per_employee_date: { + employee_id: employee_id, + leave_type: LeaveTypes.HOLIDAY, + date, + }, + }, + select: { id: true }, + }); + if (existing) { + throw new BadRequestException(`Holiday request already exists for ${iso_date}`); + } -// const payable = await this.holidayService.calculateHolidayPay(email, date, bank_code.modifier); -// const row = await this.prisma.leaveRequests.create({ -// data: { -// employee_id: employee_id, -// bank_code_id: bank_code.id, -// leave_type: LeaveTypes.HOLIDAY, -// date, -// comment: dto.comment ?? '', -// requested_hours: dto.requested_hours ?? 8, -// payable_hours: payable, -// approval_status: dto.approval_status ?? LeaveApprovalStatus.PENDING, -// }, -// select: leaveRequestsSelect, -// }); + const payable = await this.holidayService.calculateHolidayPay(email, date, bank_code.modifier); + const row = await this.prisma.leaveRequests.create({ + data: { + employee_id: employee_id, + bank_code_id: bank_code.id, + leave_type: LeaveTypes.HOLIDAY, + date, + comment: dto.comment ?? '', + requested_hours: dto.requested_hours ?? 8, + payable_hours: payable, + approval_status: dto.approval_status ?? LeaveApprovalStatus.PENDING, + }, + select: leaveRequestsSelect, + }); -// const hours = Number(row.payable_hours ?? row.requested_hours ?? 0); -// if (row.approval_status === LeaveApprovalStatus.APPROVED) { -// await this.leaveUtils.syncShift(email, employee_id, iso_date, hours,LeaveTypes.HOLIDAY, row.comment); -// } + const hours = Number(row.payable_hours ?? row.requested_hours ?? 0); + if (row.approval_status === LeaveApprovalStatus.APPROVED) { + await this.leaveUtils.syncShift(email, employee_id, iso_date, hours,LeaveTypes.HOLIDAY, row.comment); + } -// created.push({ ...mapRowToView(row), action: 'create' }); -// } + created.push({ ...mapRowToView(row), action: 'create' }); + } -// return { action: 'create', leave_requests: created }; -// } -// } + return { action: 'create', leave_requests: created }; + } +} diff --git a/src/time-and-attendance/modules/leave-requests/services/leave-request.service.ts b/src/time-and-attendance/modules/leave-requests/services/leave-request.service.ts index 7b0c82e..8b44ac0 100644 --- a/src/time-and-attendance/modules/leave-requests/services/leave-request.service.ts +++ b/src/time-and-attendance/modules/leave-requests/services/leave-request.service.ts @@ -1,248 +1,243 @@ -// import { BadRequestException, Injectable, NotFoundException } from "@nestjs/common"; -// import { LeaveApprovalStatus, LeaveTypes } from "@prisma/client"; -// import { roundToQuarterHour } from "src/common/utils/date-utils"; -// import { UpsertLeaveRequestDto, UpsertResult } from "../dtos/upsert-leave-request.dto"; -// import { LeaveRequestViewDto } from "../dtos/leave-request-view.dto"; -// import { mapRowToView } from "../mappers/leave-requests.mapper"; -// import { leaveRequestsSelect } from "../utils/leave-requests.select"; -// import { HolidayLeaveRequestsService } from "./holiday-leave-requests.service"; -// import { SickLeaveRequestsService } from "./sick-leave-requests.service"; -// import { VacationLeaveRequestsService } from "./vacation-leave-requests.service"; -// import { HolidayService } from "src/modules/business-logics/services/holiday.service"; -// import { SickLeaveService } from "src/modules/business-logics/services/sick-leave.service"; -// import { VacationService } from "src/modules/business-logics/services/vacation.service"; -// import { PrismaService } from "src/prisma/prisma.service"; -// import { LeaveRequestsUtils } from "../utils/leave-request.util"; -// import { normalizeDates, toDateOnly, toISODateKey } from "src/modules/shared/helpers/date-time.helpers"; -// import { EmailToIdResolver } from "src/modules/shared/utils/resolve-email-id.utils"; -// import { BankCodesResolver } from "src/modules/shared/utils/resolve-bank-type-id.utils"; +import { BadRequestException, Injectable, NotFoundException } from "@nestjs/common"; +import { LeaveApprovalStatus, LeaveTypes } from "@prisma/client"; +import { roundToQuarterHour } from "src/common/utils/date-utils"; +import { UpsertLeaveRequestDto, UpsertResult } from "../dtos/upsert-leave-request.dto"; +import { LeaveRequestViewDto } from "../dtos/leave-request-view.dto"; +import { mapRowToView } from "../mappers/leave-requests.mapper"; +import { leaveRequestsSelect } from "../utils/leave-requests.select"; +import { PrismaService } from "src/prisma/prisma.service"; +import { HolidayService } from "src/time-and-attendance/domains/services/holiday.service"; +import { SickLeaveService } from "src/time-and-attendance/domains/services/sick-leave.service"; +import { VacationService } from "src/time-and-attendance/domains/services/vacation.service"; +import { normalizeDates, toDateOnly, toISODateKey } from "src/time-and-attendance/modules/shared/helpers/date-time.helpers"; +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 { LeaveRequestsUtils } from "src/time-and-attendance/modules/leave-requests/utils/leave-request.util"; +@Injectable() +export class LeaveRequestsService { + constructor( + private readonly prisma: PrismaService, + private readonly holidayService: HolidayService, + private readonly sickLogic: SickLeaveService, + private readonly sickLeaveService: SickLeaveService, + private readonly vacationService: VacationService, + private readonly vacationLogic: VacationService, + private readonly leaveUtils: LeaveRequestsUtils, + private readonly emailResolver: EmailToIdResolver, + private readonly typeResolver: BankCodesResolver, + ) {} -// @Injectable() -// export class LeaveRequestsService { -// constructor( -// private readonly prisma: PrismaService, -// private readonly holidayLeaveService: HolidayLeaveRequestsService, -// private readonly holidayService: HolidayService, -// private readonly sickLogic: SickLeaveService, -// private readonly sickLeaveService: SickLeaveRequestsService, -// private readonly vacationLeaveService: VacationLeaveRequestsService, -// private readonly vacationLogic: VacationService, -// private readonly leaveUtils: LeaveRequestsUtils, -// private readonly emailResolver: EmailToIdResolver, -// private readonly typeResolver: BankCodesResolver, -// ) {} + // handle distribution to the right service according to the selected type and action + async handle(dto: UpsertLeaveRequestDto): Promise { + switch (dto.type) { + case LeaveTypes.HOLIDAY: + if( dto.action === 'create'){ + // return this.holidayService.create(dto); + } else if (dto.action === 'update') { + return this.update(dto, LeaveTypes.HOLIDAY); + } else if (dto.action === 'delete'){ + return this.delete(dto, LeaveTypes.HOLIDAY); + } + case LeaveTypes.VACATION: + if( dto.action === 'create'){ + // return this.vacationService.create(dto); + } else if (dto.action === 'update') { + return this.update(dto, LeaveTypes.VACATION); + } else if (dto.action === 'delete'){ + return this.delete(dto, LeaveTypes.VACATION); + } + case LeaveTypes.SICK: + if( dto.action === 'create'){ + // return this.sickLeaveService.create(dto); + } else if (dto.action === 'update') { + return this.update(dto, LeaveTypes.SICK); + } else if (dto.action === 'delete'){ + return this.delete(dto, LeaveTypes.SICK); + } + default: + throw new BadRequestException(`Unsupported leave type: ${dto.type} or action: ${dto.action}`); + } + } -// //handle distribution to the right service according to the selected type and action -// async handle(dto: UpsertLeaveRequestDto): Promise { -// switch (dto.type) { -// case LeaveTypes.HOLIDAY: -// if( dto.action === 'create'){ -// return this.holidayLeaveService.create(dto); -// } else if (dto.action === 'update') { -// return this.update(dto, LeaveTypes.HOLIDAY); -// } else if (dto.action === 'delete'){ -// return this.delete(dto, LeaveTypes.HOLIDAY); -// } -// case LeaveTypes.VACATION: -// if( dto.action === 'create'){ -// return this.vacationLeaveService.create(dto); -// } else if (dto.action === 'update') { -// return this.update(dto, LeaveTypes.VACATION); -// } else if (dto.action === 'delete'){ -// return this.delete(dto, LeaveTypes.VACATION); -// } -// case LeaveTypes.SICK: -// if( dto.action === 'create'){ -// return this.sickLeaveService.create(dto); -// } else if (dto.action === 'update') { -// return this.update(dto, LeaveTypes.SICK); -// } else if (dto.action === 'delete'){ -// return this.delete(dto, LeaveTypes.SICK); -// } -// default: -// throw new BadRequestException(`Unsupported leave type: ${dto.type} or action: ${dto.action}`); -// } -// } + async delete(dto: UpsertLeaveRequestDto, type: LeaveTypes): Promise { + const email = dto.email.trim(); + const dates = normalizeDates(dto.dates); + const employee_id = await this.emailResolver.findIdByEmail(email); + if (!dates.length) throw new BadRequestException("Dates array must not be empty"); -// async delete(dto: UpsertLeaveRequestDto, type: LeaveTypes): Promise { -// const email = dto.email.trim(); -// const dates = normalizeDates(dto.dates); -// const employee_id = await this.emailResolver.findIdByEmail(email); -// if (!dates.length) throw new BadRequestException("Dates array must not be empty"); + const rows = await this.prisma.leaveRequests.findMany({ + where: { + employee_id: employee_id, + leave_type: type, + date: { in: dates.map((d) => toDateOnly(d)) }, + }, + select: leaveRequestsSelect, + }); -// const rows = await this.prisma.leaveRequests.findMany({ -// where: { -// employee_id: employee_id, -// leave_type: type, -// date: { in: dates.map((d) => toDateOnly(d)) }, -// }, -// select: leaveRequestsSelect, -// }); + if (rows.length !== dates.length) { + const missing = dates.filter((isoDate) => !rows.some((row) => toISODateKey(row.date) === isoDate)); + throw new NotFoundException(`No Leave request found for: ${missing.join(", ")}`); + } -// if (rows.length !== dates.length) { -// const missing = dates.filter((isoDate) => !rows.some((row) => toISODateKey(row.date) === isoDate)); -// throw new NotFoundException(`No Leave request found for: ${missing.join(", ")}`); -// } + for (const row of rows) { + if (row.approval_status === LeaveApprovalStatus.APPROVED) { + const iso = toISODateKey(row.date); + await this.leaveUtils.removeShift(email, employee_id, iso, type); + } + } -// for (const row of rows) { -// if (row.approval_status === LeaveApprovalStatus.APPROVED) { -// const iso = toISODateKey(row.date); -// await this.leaveUtils.removeShift(email, employee_id, iso, type); -// } -// } + await this.prisma.leaveRequests.deleteMany({ + where: { id: { in: rows.map((row) => row.id) } }, + }); -// await this.prisma.leaveRequests.deleteMany({ -// where: { id: { in: rows.map((row) => row.id) } }, -// }); + const deleted = rows.map((row) => ({ ...mapRowToView(row), action: "delete" as const })); + return { action: "delete", leave_requests: deleted }; + } -// const deleted = rows.map((row) => ({ ...mapRowToView(row), action: "delete" as const })); -// return { action: "delete", leave_requests: deleted }; -// } + async update(dto: UpsertLeaveRequestDto, type: LeaveTypes): Promise { + const email = dto.email.trim(); + const employee_id = await this.emailResolver.findIdByEmail(email); + const bank_code = await this.typeResolver.findByType(type); + if(!bank_code) throw new NotFoundException(`bank_code not found`); + const modifier = Number(bank_code.modifier ?? 1); + const dates = normalizeDates(dto.dates); + if (!dates.length) { + throw new BadRequestException("Dates array must not be empty"); + } -// async update(dto: UpsertLeaveRequestDto, type: LeaveTypes): Promise { -// const email = dto.email.trim(); -// const employee_id = await this.emailResolver.findIdByEmail(email); -// const bank_code = await this.typeResolver.findByType(type); -// if(!bank_code) throw new NotFoundException(`bank_code not found`); -// const modifier = Number(bank_code.modifier ?? 1); -// const dates = normalizeDates(dto.dates); -// if (!dates.length) { -// throw new BadRequestException("Dates array must not be empty"); -// } + const entries = await Promise.all( + dates.map(async (iso_date) => { + const date = toDateOnly(iso_date); + const existing = await this.prisma.leaveRequests.findUnique({ + where: { + leave_per_employee_date: { + employee_id: employee_id, + leave_type: type, + date, + }, + }, + select: leaveRequestsSelect, + }); + if (!existing) throw new NotFoundException(`No Leave request found for ${iso_date}`); + return { iso_date, date, existing }; + }), + ); -// const entries = await Promise.all( -// dates.map(async (iso_date) => { -// const date = toDateOnly(iso_date); -// const existing = await this.prisma.leaveRequests.findUnique({ -// where: { -// leave_per_employee_date: { -// employee_id: employee_id, -// leave_type: type, -// date, -// }, -// }, -// select: leaveRequestsSelect, -// }); -// if (!existing) throw new NotFoundException(`No Leave request found for ${iso_date}`); -// return { iso_date, date, existing }; -// }), -// ); + const updated: LeaveRequestViewDto[] = []; -// const updated: LeaveRequestViewDto[] = []; + if (type === LeaveTypes.SICK) { + const firstExisting = entries[0].existing; + const fallbackRequested = + firstExisting.requested_hours !== null && firstExisting.requested_hours !== undefined + ? Number(firstExisting.requested_hours) + : 8; + const requested_hours_per_day = dto.requested_hours ?? fallbackRequested; + const reference_date = entries.reduce( + (latest, entry) => (entry.date > latest ? entry.date : latest), + entries[0].date, + ); + const total_payable_hours = await this.sickLogic.calculateSickLeavePay( + employee_id, + reference_date, + entries.length, + requested_hours_per_day, + modifier, + ); + let remaining_payable_hours = roundToQuarterHour(Math.max(0, total_payable_hours)); + const daily_payable_cap = roundToQuarterHour(requested_hours_per_day * modifier); -// if (type === LeaveTypes.SICK) { -// const firstExisting = entries[0].existing; -// const fallbackRequested = -// firstExisting.requested_hours !== null && firstExisting.requested_hours !== undefined -// ? Number(firstExisting.requested_hours) -// : 8; -// const requested_hours_per_day = dto.requested_hours ?? fallbackRequested; -// const reference_date = entries.reduce( -// (latest, entry) => (entry.date > latest ? entry.date : latest), -// entries[0].date, -// ); -// const total_payable_hours = await this.sickLogic.calculateSickLeavePay( -// employee_id, -// reference_date, -// entries.length, -// requested_hours_per_day, -// modifier, -// ); -// let remaining_payable_hours = roundToQuarterHour(Math.max(0, total_payable_hours)); -// const daily_payable_cap = roundToQuarterHour(requested_hours_per_day * modifier); + for (const { iso_date, existing } of entries) { + const previous_status = existing.approval_status; + const payable = Math.min(remaining_payable_hours, daily_payable_cap); + const payable_rounded = roundToQuarterHour(Math.max(0, payable)); + remaining_payable_hours = roundToQuarterHour( + Math.max(0, remaining_payable_hours - payable_rounded), + ); -// for (const { iso_date, existing } of entries) { -// const previous_status = existing.approval_status; -// const payable = Math.min(remaining_payable_hours, daily_payable_cap); -// const payable_rounded = roundToQuarterHour(Math.max(0, payable)); -// remaining_payable_hours = roundToQuarterHour( -// Math.max(0, remaining_payable_hours - payable_rounded), -// ); + const row = await this.prisma.leaveRequests.update({ + where: { id: existing.id }, + data: { + comment: dto.comment ?? existing.comment, + requested_hours: requested_hours_per_day, + payable_hours: payable_rounded, + bank_code_id: bank_code.id, + approval_status: dto.approval_status ?? existing.approval_status, + }, + select: leaveRequestsSelect, + }); -// const row = await this.prisma.leaveRequests.update({ -// where: { id: existing.id }, -// data: { -// comment: dto.comment ?? existing.comment, -// requested_hours: requested_hours_per_day, -// payable_hours: payable_rounded, -// bank_code_id: bank_code.id, -// approval_status: dto.approval_status ?? existing.approval_status, -// }, -// select: leaveRequestsSelect, -// }); + const was_approved = previous_status === LeaveApprovalStatus.APPROVED; + const is_approved = row.approval_status === LeaveApprovalStatus.APPROVED; + const hours = Number(row.payable_hours ?? row.requested_hours ?? 0); -// const was_approved = previous_status === LeaveApprovalStatus.APPROVED; -// const is_approved = row.approval_status === LeaveApprovalStatus.APPROVED; -// const hours = Number(row.payable_hours ?? row.requested_hours ?? 0); + if (!was_approved && is_approved) { + await this.leaveUtils.syncShift(email, employee_id, iso_date, hours, type, row.comment); + } else if (was_approved && !is_approved) { + await this.leaveUtils.removeShift(email, employee_id, iso_date, type); + } else if (was_approved && is_approved) { + await this.leaveUtils.syncShift(email, employee_id, iso_date, hours, type, row.comment); + } + updated.push({ ...mapRowToView(row), action: "update" }); + } + return { action: "update", leave_requests: updated }; + } -// if (!was_approved && is_approved) { -// await this.leaveUtils.syncShift(email, employee_id, iso_date, hours, type, row.comment); -// } else if (was_approved && !is_approved) { -// await this.leaveUtils.removeShift(email, employee_id, iso_date, type); -// } else if (was_approved && is_approved) { -// await this.leaveUtils.syncShift(email, employee_id, iso_date, hours, type, row.comment); -// } -// updated.push({ ...mapRowToView(row), action: "update" }); -// } -// return { action: "update", leave_requests: updated }; -// } + for (const { iso_date, date, existing } of entries) { + const previous_status = existing.approval_status; + const fallbackRequested = + existing.requested_hours !== null && existing.requested_hours !== undefined + ? Number(existing.requested_hours) + : 8; + const requested_hours = dto.requested_hours ?? fallbackRequested; -// for (const { iso_date, date, existing } of entries) { -// const previous_status = existing.approval_status; -// const fallbackRequested = -// existing.requested_hours !== null && existing.requested_hours !== undefined -// ? Number(existing.requested_hours) -// : 8; -// const requested_hours = dto.requested_hours ?? fallbackRequested; + let payable: number; + switch (type) { + case LeaveTypes.HOLIDAY: + payable = await this.holidayService.calculateHolidayPay(email, date, modifier); + break; + case LeaveTypes.VACATION: { + const days_requested = requested_hours / 8; + payable = await this.vacationLogic.calculateVacationPay( + employee_id, + date, + Math.max(0, days_requested), + modifier, + ); + break; + } + default: + payable = existing.payable_hours !== null && existing.payable_hours !== undefined + ? Number(existing.payable_hours) + : requested_hours; + } -// let payable: number; -// switch (type) { -// case LeaveTypes.HOLIDAY: -// payable = await this.holidayService.calculateHolidayPay(email, date, modifier); -// break; -// case LeaveTypes.VACATION: { -// const days_requested = requested_hours / 8; -// payable = await this.vacationLogic.calculateVacationPay( -// employee_id, -// date, -// Math.max(0, days_requested), -// modifier, -// ); -// break; -// } -// default: -// payable = existing.payable_hours !== null && existing.payable_hours !== undefined -// ? Number(existing.payable_hours) -// : requested_hours; -// } + const row = await this.prisma.leaveRequests.update({ + where: { id: existing.id }, + data: { + requested_hours, + comment: dto.comment ?? existing.comment, + payable_hours: payable, + bank_code_id: bank_code.id, + approval_status: dto.approval_status ?? existing.approval_status, + }, + select: leaveRequestsSelect, + }); -// const row = await this.prisma.leaveRequests.update({ -// where: { id: existing.id }, -// data: { -// requested_hours, -// comment: dto.comment ?? existing.comment, -// payable_hours: payable, -// bank_code_id: bank_code.id, -// approval_status: dto.approval_status ?? existing.approval_status, -// }, -// select: leaveRequestsSelect, -// }); + const was_approved = previous_status === LeaveApprovalStatus.APPROVED; + const is_approved = row.approval_status === LeaveApprovalStatus.APPROVED; + const hours = Number(row.payable_hours ?? row.requested_hours ?? 0); -// const was_approved = previous_status === LeaveApprovalStatus.APPROVED; -// const is_approved = row.approval_status === LeaveApprovalStatus.APPROVED; -// const hours = Number(row.payable_hours ?? row.requested_hours ?? 0); - -// if (!was_approved && is_approved) { -// await this.leaveUtils.syncShift(email, employee_id, iso_date, hours, type, row.comment); -// } else if (was_approved && !is_approved) { -// await this.leaveUtils.removeShift(email, employee_id, iso_date, type); -// } else if (was_approved && is_approved) { -// await this.leaveUtils.syncShift(email, employee_id, iso_date, hours, type, row.comment); -// } -// updated.push({ ...mapRowToView(row), action: "update" }); -// } -// return { action: "update", leave_requests: updated }; -// } -// } + if (!was_approved && is_approved) { + await this.leaveUtils.syncShift(email, employee_id, iso_date, hours, type, row.comment); + } else if (was_approved && !is_approved) { + await this.leaveUtils.removeShift(email, employee_id, iso_date, type); + } else if (was_approved && is_approved) { + await this.leaveUtils.syncShift(email, employee_id, iso_date, hours, type, row.comment); + } + updated.push({ ...mapRowToView(row), action: "update" }); + } + return { action: "update", leave_requests: updated }; + } +} diff --git a/src/time-and-attendance/modules/leave-requests/services/sick-leave-requests.service.ts b/src/time-and-attendance/modules/leave-requests/services/sick-leave-requests.service.ts index a4554b1..145a283 100644 --- a/src/time-and-attendance/modules/leave-requests/services/sick-leave-requests.service.ts +++ b/src/time-and-attendance/modules/leave-requests/services/sick-leave-requests.service.ts @@ -1,98 +1,99 @@ -// import { UpsertLeaveRequestDto, UpsertResult } from "../dtos/upsert-leave-request.dto"; -// import { LeaveRequestViewDto } from "../dtos/leave-request-view.dto"; -// import { BadRequestException, Injectable, NotFoundException } from "@nestjs/common"; -// import { LeaveApprovalStatus, LeaveTypes } from "@prisma/client"; -// import { leaveRequestsSelect } from "../utils/leave-requests.select"; -// import { mapRowToView } from "../mappers/leave-requests.mapper"; -// import { PrismaService } from "src/prisma/prisma.service"; -// import { SickLeaveService } from "src/modules/business-logics/services/sick-leave.service"; -// import { roundToQuarterHour } from "src/common/utils/date-utils"; -// import { LeaveRequestsUtils } from "../utils/leave-request.util"; -// import { normalizeDates, toDateOnly } from "src/modules/shared/helpers/date-time.helpers"; -// import { EmailToIdResolver } from "src/modules/shared/utils/resolve-email-id.utils"; -// import { BankCodesResolver } from "src/modules/shared/utils/resolve-bank-type-id.utils"; +import { Injectable, NotFoundException, BadRequestException } from "@nestjs/common"; +import { LeaveTypes, LeaveApprovalStatus } from "@prisma/client"; +import { roundToQuarterHour } from "src/common/utils/date-utils"; +import { PrismaService } from "src/prisma/prisma.service"; +import { SickLeaveService } from "src/time-and-attendance/domains/services/sick-leave.service"; +import { LeaveRequestViewDto } from "src/time-and-attendance/modules/leave-requests/dtos/leave-request-view.dto"; +import { UpsertLeaveRequestDto, UpsertResult } from "src/time-and-attendance/modules/leave-requests/dtos/upsert-leave-request.dto"; +import { mapRowToView } from "src/time-and-attendance/modules/leave-requests/mappers/leave-requests.mapper"; +import { LeaveRequestsUtils } from "src/time-and-attendance/modules/leave-requests/utils/leave-request.util"; +import { leaveRequestsSelect } from "src/time-and-attendance/modules/leave-requests/utils/leave-requests.select"; +import { normalizeDates, toDateOnly } from "src/time-and-attendance/modules/shared/helpers/date-time.helpers"; +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"; -// @Injectable() -// export class SickLeaveRequestsService { -// constructor( -// private readonly prisma: PrismaService, -// private readonly sickService: SickLeaveService, -// private readonly leaveUtils: LeaveRequestsUtils, -// private readonly emailResolver: EmailToIdResolver, -// private readonly typeResolver: BankCodesResolver, -// ) {} -// async create(dto: UpsertLeaveRequestDto): Promise { -// const email = dto.email.trim(); -// const employee_id = await this.emailResolver.findIdByEmail(email); -// const bank_code = await this.typeResolver.findByType(LeaveTypes.SICK); -// if(!bank_code) throw new NotFoundException(`bank_code not found`); +@Injectable() +export class SickLeaveRequestsService { + constructor( + private readonly prisma: PrismaService, + private readonly sickService: SickLeaveService, + private readonly leaveUtils: LeaveRequestsUtils, + private readonly emailResolver: EmailToIdResolver, + private readonly typeResolver: BankCodesResolver, + ) {} + + async create(dto: UpsertLeaveRequestDto): Promise { + const email = dto.email.trim(); + const employee_id = await this.emailResolver.findIdByEmail(email); + const bank_code = await this.typeResolver.findByType(LeaveTypes.SICK); + if(!bank_code) throw new NotFoundException(`bank_code not found`); -// const modifier = bank_code.modifier ?? 1; -// const dates = normalizeDates(dto.dates); -// if (!dates.length) throw new BadRequestException("Dates array must not be empty"); -// const requested_hours_per_day = dto.requested_hours ?? 8; + const modifier = bank_code.modifier ?? 1; + const dates = normalizeDates(dto.dates); + if (!dates.length) throw new BadRequestException("Dates array must not be empty"); + const requested_hours_per_day = dto.requested_hours ?? 8; -// const entries = dates.map((iso) => ({ iso, date: toDateOnly(iso) })); -// const reference_date = entries.reduce( -// (latest, entry) => (entry.date > latest ? entry.date : latest), -// entries[0].date, -// ); -// const total_payable_hours = await this.sickService.calculateSickLeavePay( -// employee_id, -// reference_date, -// entries.length, -// requested_hours_per_day, -// modifier, -// ); -// let remaining_payable_hours = roundToQuarterHour(Math.max(0, total_payable_hours)); -// const daily_payable_cap = roundToQuarterHour(requested_hours_per_day * modifier); + const entries = dates.map((iso) => ({ iso, date: toDateOnly(iso) })); + const reference_date = entries.reduce( + (latest, entry) => (entry.date > latest ? entry.date : latest), + entries[0].date, + ); + const total_payable_hours = await this.sickService.calculateSickLeavePay( + employee_id, + reference_date, + entries.length, + requested_hours_per_day, + modifier, + ); + let remaining_payable_hours = roundToQuarterHour(Math.max(0, total_payable_hours)); + const daily_payable_cap = roundToQuarterHour(requested_hours_per_day * modifier); -// const created: LeaveRequestViewDto[] = []; + const created: LeaveRequestViewDto[] = []; -// for (const { iso, date } of entries) { -// const existing = await this.prisma.leaveRequests.findUnique({ -// where: { -// leave_per_employee_date: { -// employee_id: employee_id, -// leave_type: LeaveTypes.SICK, -// date, -// }, -// }, -// select: { id: true }, -// }); -// if (existing) { -// throw new BadRequestException(`Sick request already exists for ${iso}`); -// } + for (const { iso, date } of entries) { + const existing = await this.prisma.leaveRequests.findUnique({ + where: { + leave_per_employee_date: { + employee_id: employee_id, + leave_type: LeaveTypes.SICK, + date, + }, + }, + select: { id: true }, + }); + if (existing) { + throw new BadRequestException(`Sick request already exists for ${iso}`); + } -// const payable = Math.min(remaining_payable_hours, daily_payable_cap); -// const payable_rounded = roundToQuarterHour(Math.max(0, payable)); -// remaining_payable_hours = roundToQuarterHour( -// Math.max(0, remaining_payable_hours - payable_rounded), -// ); + const payable = Math.min(remaining_payable_hours, daily_payable_cap); + const payable_rounded = roundToQuarterHour(Math.max(0, payable)); + remaining_payable_hours = roundToQuarterHour( + Math.max(0, remaining_payable_hours - payable_rounded), + ); -// const row = await this.prisma.leaveRequests.create({ -// data: { -// employee_id: employee_id, -// bank_code_id: bank_code.id, -// leave_type: LeaveTypes.SICK, -// comment: dto.comment ?? "", -// requested_hours: requested_hours_per_day, -// payable_hours: payable_rounded, -// approval_status: dto.approval_status ?? LeaveApprovalStatus.PENDING, -// date, -// }, -// select: leaveRequestsSelect, -// }); + const row = await this.prisma.leaveRequests.create({ + data: { + employee_id: employee_id, + bank_code_id: bank_code.id, + leave_type: LeaveTypes.SICK, + comment: dto.comment ?? "", + requested_hours: requested_hours_per_day, + payable_hours: payable_rounded, + approval_status: dto.approval_status ?? LeaveApprovalStatus.PENDING, + date, + }, + select: leaveRequestsSelect, + }); -// const hours = Number(row.payable_hours ?? row.requested_hours ?? 0); -// if (row.approval_status === LeaveApprovalStatus.APPROVED) { -// await this.leaveUtils.syncShift(email, employee_id, iso, hours,LeaveTypes.SICK, row.comment); -// } + const hours = Number(row.payable_hours ?? row.requested_hours ?? 0); + if (row.approval_status === LeaveApprovalStatus.APPROVED) { + // await this.leaveUtils.syncShift(email, employee_id, iso, hours,LeaveTypes.SICK, row.comment); + } -// created.push({ ...mapRowToView(row), action: "create" }); -// } + created.push({ ...mapRowToView(row), action: "create" }); + } -// return { action: "create", leave_requests: created }; -// } -// } + return { action: "create", leave_requests: created }; + } +} diff --git a/src/time-and-attendance/modules/leave-requests/services/vacation-leave-requests.service.ts b/src/time-and-attendance/modules/leave-requests/services/vacation-leave-requests.service.ts index 34223f5..652feff 100644 --- a/src/time-and-attendance/modules/leave-requests/services/vacation-leave-requests.service.ts +++ b/src/time-and-attendance/modules/leave-requests/services/vacation-leave-requests.service.ts @@ -1,93 +1,93 @@ - -// import { UpsertLeaveRequestDto, UpsertResult } from "../dtos/upsert-leave-request.dto"; -// import { LeaveRequestViewDto } from "../dtos/leave-request-view.dto"; -// import { BadRequestException, Injectable, NotFoundException } from "@nestjs/common"; -// import { LeaveApprovalStatus, LeaveTypes } from "@prisma/client"; -// import { VacationService } from "src/modules/business-logics/services/vacation.service"; -// import { PrismaService } from "src/prisma/prisma.service"; -// import { mapRowToView } from "../mappers/leave-requests.mapper"; -// import { leaveRequestsSelect } from "../utils/leave-requests.select"; -// import { roundToQuarterHour } from "src/common/utils/date-utils"; -// import { LeaveRequestsUtils } from "../utils/leave-request.util"; -// import { normalizeDates, toDateOnly } from "src/modules/shared/helpers/date-time.helpers"; -// import { EmailToIdResolver } from "src/modules/shared/utils/resolve-email-id.utils"; -// import { BankCodesResolver } from "src/modules/shared/utils/resolve-bank-type-id.utils"; +import { Injectable, NotFoundException, BadRequestException } from "@nestjs/common"; +import { LeaveTypes, LeaveApprovalStatus } from "@prisma/client"; +import { roundToQuarterHour } from "src/common/utils/date-utils"; +import { PrismaService } from "src/prisma/prisma.service"; +import { VacationService } from "src/time-and-attendance/domains/services/vacation.service"; +import { LeaveRequestViewDto } from "src/time-and-attendance/modules/leave-requests/dtos/leave-request-view.dto"; +import { UpsertLeaveRequestDto, UpsertResult } from "src/time-and-attendance/modules/leave-requests/dtos/upsert-leave-request.dto"; +import { mapRowToView } from "src/time-and-attendance/modules/leave-requests/mappers/leave-requests.mapper"; +import { LeaveRequestsUtils } from "src/time-and-attendance/modules/leave-requests/utils/leave-request.util"; +import { leaveRequestsSelect } from "src/time-and-attendance/modules/leave-requests/utils/leave-requests.select"; +import { normalizeDates, toDateOnly } from "src/time-and-attendance/modules/shared/helpers/date-time.helpers"; +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"; -// @Injectable() -// export class VacationLeaveRequestsService { -// constructor( -// private readonly prisma: PrismaService, -// private readonly vacationService: VacationService, -// private readonly leaveUtils: LeaveRequestsUtils, -// private readonly emailResolver: EmailToIdResolver, -// private readonly typeResolver: BankCodesResolver, -// ) {} -// async create(dto: UpsertLeaveRequestDto): Promise { -// const email = dto.email.trim(); -// const employee_id = await this.emailResolver.findIdByEmail(email); -// const bank_code = await this.typeResolver.findByType(LeaveTypes.VACATION); -// if(!bank_code) throw new NotFoundException(`bank_code not found`); +@Injectable() +export class VacationLeaveRequestsService { + constructor( + private readonly prisma: PrismaService, + private readonly vacationService: VacationService, + private readonly leaveUtils: LeaveRequestsUtils, + private readonly emailResolver: EmailToIdResolver, + private readonly typeResolver: BankCodesResolver, + ) {} + + async create(dto: UpsertLeaveRequestDto): Promise { + const email = dto.email.trim(); + const employee_id = await this.emailResolver.findIdByEmail(email); + const bank_code = await this.typeResolver.findByType(LeaveTypes.VACATION); + if(!bank_code) throw new NotFoundException(`bank_code not found`); -// const modifier = bank_code.modifier ?? 1; -// const dates = normalizeDates(dto.dates); -// const requested_hours_per_day = dto.requested_hours ?? 8; -// if (!dates.length) throw new BadRequestException("Dates array must not be empty"); + const modifier = bank_code.modifier ?? 1; + const dates = normalizeDates(dto.dates); + const requested_hours_per_day = dto.requested_hours ?? 8; + if (!dates.length) throw new BadRequestException("Dates array must not be empty"); -// const entries = dates -// .map((iso) => ({ iso, date: toDateOnly(iso) })) -// .sort((a, b) => a.date.getTime() - b.date.getTime()); -// const start_date = entries[0].date; -// const total_payable_hours = await this.vacationService.calculateVacationPay( -// employee_id, -// start_date, -// entries.length, -// modifier, -// ); -// let remaining_payable_hours = roundToQuarterHour(Math.max(0, total_payable_hours)); -// const daily_payable_cap = roundToQuarterHour(requested_hours_per_day * modifier); + const entries = dates + .map((iso) => ({ iso, date: toDateOnly(iso) })) + .sort((a, b) => a.date.getTime() - b.date.getTime()); + const start_date = entries[0].date; + const total_payable_hours = await this.vacationService.calculateVacationPay( + employee_id, + start_date, + entries.length, + modifier, + ); + let remaining_payable_hours = roundToQuarterHour(Math.max(0, total_payable_hours)); + const daily_payable_cap = roundToQuarterHour(requested_hours_per_day * modifier); -// const created: LeaveRequestViewDto[] = []; + const created: LeaveRequestViewDto[] = []; -// for (const { iso, date } of entries) { -// const existing = await this.prisma.leaveRequests.findUnique({ -// where: { -// leave_per_employee_date: { -// employee_id: employee_id, -// leave_type: LeaveTypes.VACATION, -// date, -// }, -// }, -// select: { id: true }, -// }); -// if (existing) throw new BadRequestException(`Vacation request already exists for ${iso}`); + for (const { iso, date } of entries) { + const existing = await this.prisma.leaveRequests.findUnique({ + where: { + leave_per_employee_date: { + employee_id: employee_id, + leave_type: LeaveTypes.VACATION, + date, + }, + }, + select: { id: true }, + }); + if (existing) throw new BadRequestException(`Vacation request already exists for ${iso}`); -// const payable = Math.min(remaining_payable_hours, daily_payable_cap); -// const payable_rounded = roundToQuarterHour(Math.max(0, payable)); -// remaining_payable_hours = roundToQuarterHour( -// Math.max(0, remaining_payable_hours - payable_rounded), -// ); + const payable = Math.min(remaining_payable_hours, daily_payable_cap); + const payable_rounded = roundToQuarterHour(Math.max(0, payable)); + remaining_payable_hours = roundToQuarterHour( + Math.max(0, remaining_payable_hours - payable_rounded), + ); -// const row = await this.prisma.leaveRequests.create({ -// data: { -// employee_id: employee_id, -// bank_code_id: bank_code.id, -// payable_hours: payable_rounded, -// requested_hours: requested_hours_per_day, -// leave_type: LeaveTypes.VACATION, -// comment: dto.comment ?? "", -// approval_status: dto.approval_status ?? LeaveApprovalStatus.PENDING, -// date, -// }, -// select: leaveRequestsSelect, -// }); + const row = await this.prisma.leaveRequests.create({ + data: { + employee_id: employee_id, + bank_code_id: bank_code.id, + payable_hours: payable_rounded, + requested_hours: requested_hours_per_day, + leave_type: LeaveTypes.VACATION, + comment: dto.comment ?? "", + approval_status: dto.approval_status ?? LeaveApprovalStatus.PENDING, + date, + }, + select: leaveRequestsSelect, + }); -// const hours = Number(row.payable_hours ?? row.requested_hours ?? 0); -// if (row.approval_status === LeaveApprovalStatus.APPROVED) { -// await this.leaveUtils.syncShift(email, employee_id, iso, hours, LeaveTypes.VACATION, row.comment); -// } -// created.push({ ...mapRowToView(row), action: "create" }); -// } -// return { action: "create", leave_requests: created }; -// } -// } + const hours = Number(row.payable_hours ?? row.requested_hours ?? 0); + if (row.approval_status === LeaveApprovalStatus.APPROVED) { + // await this.leaveUtils.syncShift(email, employee_id, iso, hours, LeaveTypes.VACATION, row.comment); + } + created.push({ ...mapRowToView(row), action: "create" }); + } + return { action: "create", leave_requests: created }; + } +} diff --git a/src/time-and-attendance/modules/leave-requests/utils/leave-request.util.ts b/src/time-and-attendance/modules/leave-requests/utils/leave-request.util.ts index d01ccf2..3b40236 100644 --- a/src/time-and-attendance/modules/leave-requests/utils/leave-request.util.ts +++ b/src/time-and-attendance/modules/leave-requests/utils/leave-request.util.ts @@ -1,104 +1,106 @@ -// import { hhmmFromLocal, toDateOnly, toStringFromDate } from "src/modules/shared/helpers/date-time.helpers"; -// import { BadRequestException, Injectable } from "@nestjs/common"; -// import { PrismaService } from "src/prisma/prisma.service"; -// import { LeaveTypes } from "@prisma/client"; -// import { UpsertAction } from "src/modules/shared/types/upsert-actions.types"; -// @Injectable() -// export class LeaveRequestsUtils { -// constructor( -// private readonly prisma: PrismaService, -// private readonly shiftsCommand: ShiftsCommandService, -// ){} +import { BadRequestException, Injectable } from "@nestjs/common"; +import { PrismaService } from "src/prisma/prisma.service"; +import { LeaveTypes } from "@prisma/client"; +import { toDateOnly, toStringFromDate, hhmmFromLocal } from "src/time-and-attendance/modules/shared/helpers/date-time.helpers"; +import { UpsertAction } from "src/time-and-attendance/modules/shared/types/upsert-actions.types"; +import { ShiftsUpsertService } from "src/time-and-attendance/modules/time-tracker/shifts/services/shifts-upsert.service"; -// async syncShift( -// email: string, -// employee_id: number, -// date: string, -// hours: number, -// type: LeaveTypes, -// comment?: string, -// ) { -// if (hours <= 0) return; +@Injectable() +export class LeaveRequestsUtils { + constructor( + private readonly prisma: PrismaService, + private readonly shiftsService: ShiftsUpsertService, + ){} -// const duration_minutes = Math.round(hours * 60); -// if (duration_minutes > 8 * 60) { -// throw new BadRequestException("Amount of hours cannot exceed 8 hours per day."); -// } -// const date_only = toDateOnly(date); -// const yyyy_mm_dd = toStringFromDate(date_only); + async syncShift( + email: string, + employee_id: number, + date: string, + hours: number, + type: LeaveTypes, + comment?: string, + ) { + if (hours <= 0) return; + + const duration_minutes = Math.round(hours * 60); + if (duration_minutes > 8 * 60) { + throw new BadRequestException("Amount of hours cannot exceed 8 hours per day."); + } + const date_only = toDateOnly(date); + const yyyy_mm_dd = toStringFromDate(date_only); -// const start_minutes = 8 * 60; -// const end_minutes = start_minutes + duration_minutes; -// const toHHmm = (total: number) => -// `${String(Math.floor(total / 60)).padStart(2, "0")}:${String(total % 60).padStart(2, "0")}`; + const start_minutes = 8 * 60; + const end_minutes = start_minutes + duration_minutes; + const toHHmm = (total: number) => + `${String(Math.floor(total / 60)).padStart(2, "0")}:${String(total % 60).padStart(2, "0")}`; -// const existing = await this.prisma.shifts.findFirst({ -// where: { -// date: date_only, -// bank_code: { type }, -// timesheet: { employee_id: employee_id }, -// }, -// include: { bank_code: true }, -// }); + const existing = await this.prisma.shifts.findFirst({ + where: { + date: date_only, + bank_code: { type }, + timesheet: { employee_id: employee_id }, + }, + include: { bank_code: true }, + }); -// const action: UpsertAction = existing ? 'update' : 'create'; + const action: UpsertAction = existing ? 'update' : 'create'; -// await this.shiftsCommand.upsertShifts(email, action, { -// old_shift: existing -// ? { -// date: yyyy_mm_dd, -// start_time: existing.start_time.toISOString().slice(11, 16), -// end_time: existing.end_time.toISOString().slice(11, 16), -// type: existing.bank_code?.type ?? type, -// is_remote: existing.is_remote, -// is_approved:existing.is_approved, -// comment: existing.comment ?? undefined, -// } -// : undefined, -// new_shift: { -// date: yyyy_mm_dd, -// start_time: toHHmm(start_minutes), -// end_time: toHHmm(end_minutes), -// is_remote: existing?.is_remote ?? false, -// is_approved:existing?.is_approved ?? false, -// comment: comment ?? existing?.comment ?? "", -// type: type, -// }, -// }); -// } + // await this.shiftsService.upsertShifts(email, action, { + // old_shift: existing + // ? { + // date: yyyy_mm_dd, + // start_time: existing.start_time.toISOString().slice(11, 16), + // end_time: existing.end_time.toISOString().slice(11, 16), + // type: existing.bank_code?.type ?? type, + // is_remote: existing.is_remote, + // is_approved:existing.is_approved, + // comment: existing.comment ?? undefined, + // } + // : undefined, + // new_shift: { + // date: yyyy_mm_dd, + // start_time: toHHmm(start_minutes), + // end_time: toHHmm(end_minutes), + // is_remote: existing?.is_remote ?? false, + // is_approved:existing?.is_approved ?? false, + // comment: comment ?? existing?.comment ?? "", + // type: type, + // }, + // }); + } -// async removeShift( -// email: string, -// employee_id: number, -// iso_date: string, -// type: LeaveTypes, -// ) { -// const date_only = toDateOnly(iso_date); -// const yyyy_mm_dd = toStringFromDate(date_only); -// const existing = await this.prisma.shifts.findFirst({ -// where: { -// date: date_only, -// bank_code: { type }, -// timesheet: { employee_id: employee_id }, -// }, -// include: { bank_code: true }, -// }); -// if (!existing) return; + async removeShift( + email: string, + employee_id: number, + iso_date: string, + type: LeaveTypes, + ) { + const date_only = toDateOnly(iso_date); + const yyyy_mm_dd = toStringFromDate(date_only); + const existing = await this.prisma.shifts.findFirst({ + where: { + date: date_only, + bank_code: { type }, + timesheet: { employee_id: employee_id }, + }, + include: { bank_code: true }, + }); + if (!existing) return; -// await this.shiftsCommand.upsertShifts(email, 'delete', { -// old_shift: { -// date: yyyy_mm_dd, -// start_time: hhmmFromLocal(existing.start_time), -// end_time: hhmmFromLocal(existing.end_time), -// type: existing.bank_code?.type ?? type, -// is_remote: existing.is_remote, -// is_approved:existing.is_approved, -// comment: existing.comment ?? undefined, -// }, -// }); -// } + // await this.shiftsService.upsertShifts(email, 'delete', { + // old_shift: { + // date: yyyy_mm_dd, + // start_time: hhmmFromLocal(existing.start_time), + // end_time: hhmmFromLocal(existing.end_time), + // type: existing.bank_code?.type ?? type, + // is_remote: existing.is_remote, + // is_approved:existing.is_approved, + // comment: existing.comment ?? undefined, + // }, + // }); + } -// } +} diff --git a/src/time-and-attendance/time-and-attendance.module.ts b/src/time-and-attendance/time-and-attendance.module.ts index ebcbd05..e3eff36 100644 --- a/src/time-and-attendance/time-and-attendance.module.ts +++ b/src/time-and-attendance/time-and-attendance.module.ts @@ -1,20 +1,20 @@ -import { Module } from "@nestjs/common"; -import { ExpensesArchiveController } from "src/modules/archival/controllers/expenses-archive.controller"; -import { BusinessLogicsModule } from "src/time-and-attendance/domains/business-logics.module"; -import { ExpenseController } from "src/time-and-attendance/modules/expenses/controllers/expense.controller"; -import { ExpenseUpsertService } from "src/time-and-attendance/modules/expenses/services/expense-upsert.service"; -import { ExpensesArchivalService } from "src/time-and-attendance/modules/expenses/services/expenses-archival.service"; -import { PayperiodsModule } from "src/time-and-attendance/modules/pay-period/pay-periods.module"; -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 { SchedulePresetsController } from "src/time-and-attendance/modules/time-tracker/schedule-presets/controller/schedule-presets.controller"; import { SchedulePresetsCommandService } from "src/time-and-attendance/modules/time-tracker/schedule-presets/services/schedule-presets-command.service"; +import { GetTimesheetsOverviewService } from "src/time-and-attendance/modules/time-tracker/timesheets/services/timesheet-get-overview.service"; import { SchedulePresetsQueryService } from "src/time-and-attendance/modules/time-tracker/schedule-presets/services/schedule-presets-query.service"; -import { ShiftController } from "src/time-and-attendance/modules/time-tracker/shifts/controllers/shift.controller"; -import { ShiftsGetService } from "src/time-and-attendance/modules/time-tracker/shifts/services/shifts-get.service"; +import { SchedulePresetsController } from "src/time-and-attendance/modules/time-tracker/schedule-presets/controller/schedule-presets.controller"; +import { ExpensesArchivalService } from "src/time-and-attendance/modules/expenses/services/expenses-archival.service"; +// import { LeaveRequestController } from "src/time-and-attendance/modules/leave-requests/controllers/leave-requests.controller"; +import { BusinessLogicsModule } from "src/time-and-attendance/domains/business-logics.module"; +import { ExpenseUpsertService } from "src/time-and-attendance/modules/expenses/services/expense-upsert.service"; import { ShiftsUpsertService } from "src/time-and-attendance/modules/time-tracker/shifts/services/shifts-upsert.service"; import { TimesheetController } from "src/time-and-attendance/modules/time-tracker/timesheets/controllers/timesheet.controller"; -import { GetTimesheetsOverviewService } from "src/time-and-attendance/modules/time-tracker/timesheets/services/timesheet-get-overview.service"; +import { ExpenseController } from "src/time-and-attendance/modules/expenses/controllers/expense.controller"; +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 { PayperiodsModule } from "src/time-and-attendance/modules/pay-period/pay-periods.module"; +import { ShiftsGetService } from "src/time-and-attendance/modules/time-tracker/shifts/services/shifts-get.service"; +import { ShiftController } from "src/time-and-attendance/modules/time-tracker/shifts/controllers/shift.controller"; +import { Module } from "@nestjs/common"; @Module({ imports: [BusinessLogicsModule, PayperiodsModule], @@ -23,7 +23,6 @@ import { GetTimesheetsOverviewService } from "src/time-and-attendance/modules/ti ShiftController, SchedulePresetsController, ExpenseController, - ExpensesArchiveController, // LeaveRequestController, ],