Compare commits
13 Commits
9143d1a79e
...
9999dff6ce
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9999dff6ce | ||
|
|
154c7063d8 | ||
|
|
3a65030764 | ||
|
|
a6d2a3b3cd | ||
|
|
d5e101804a | ||
|
|
a5bd7d54fe | ||
|
|
c47dcb1f2f | ||
|
|
10b51f5ae6 | ||
|
|
8fdc2baf21 | ||
|
|
9f0ce738c2 | ||
|
|
2b04c3151d | ||
|
|
b1069c0add | ||
|
|
d004fa9fa2 |
4
.gitignore
vendored
4
.gitignore
vendored
|
|
@ -55,9 +55,5 @@ pids
|
|||
# Diagnostic reports (https://nodejs.org/api/report.html)
|
||||
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
|
||||
|
||||
# Generated prisma folders (from -> npm run prisma:generated)
|
||||
prisma/mariadb/generated/prisma/client/mariadb/
|
||||
prisma/postgres/generated/prisma/client/postgres/
|
||||
prisma/prisma-legacy/generated/prisma/client/legacy/
|
||||
|
||||
!swagger-spec.json
|
||||
|
|
|
|||
|
|
@ -37,6 +37,11 @@ export type userModuleAccess = Prisma.userModuleAccessModel
|
|||
*
|
||||
*/
|
||||
export type Employees = Prisma.EmployeesModel
|
||||
/**
|
||||
* Model Contracts
|
||||
*
|
||||
*/
|
||||
export type Contracts = Prisma.ContractsModel
|
||||
/**
|
||||
* Model LeaveRequests
|
||||
*
|
||||
|
|
|
|||
|
|
@ -57,6 +57,11 @@ export type userModuleAccess = Prisma.userModuleAccessModel
|
|||
*
|
||||
*/
|
||||
export type Employees = Prisma.EmployeesModel
|
||||
/**
|
||||
* Model Contracts
|
||||
*
|
||||
*/
|
||||
export type Contracts = Prisma.ContractsModel
|
||||
/**
|
||||
* Model LeaveRequests
|
||||
*
|
||||
|
|
|
|||
|
|
@ -314,6 +314,33 @@ export type IntNullableWithAggregatesFilter<$PrismaModel = never> = {
|
|||
_max?: Prisma.NestedIntNullableFilter<$PrismaModel>
|
||||
}
|
||||
|
||||
export type DecimalFilter<$PrismaModel = never> = {
|
||||
equals?: runtime.Decimal | runtime.DecimalJsLike | number | string | Prisma.DecimalFieldRefInput<$PrismaModel>
|
||||
in?: runtime.Decimal[] | runtime.DecimalJsLike[] | number[] | string[] | Prisma.ListDecimalFieldRefInput<$PrismaModel>
|
||||
notIn?: runtime.Decimal[] | runtime.DecimalJsLike[] | number[] | string[] | Prisma.ListDecimalFieldRefInput<$PrismaModel>
|
||||
lt?: runtime.Decimal | runtime.DecimalJsLike | number | string | Prisma.DecimalFieldRefInput<$PrismaModel>
|
||||
lte?: runtime.Decimal | runtime.DecimalJsLike | number | string | Prisma.DecimalFieldRefInput<$PrismaModel>
|
||||
gt?: runtime.Decimal | runtime.DecimalJsLike | number | string | Prisma.DecimalFieldRefInput<$PrismaModel>
|
||||
gte?: runtime.Decimal | runtime.DecimalJsLike | number | string | Prisma.DecimalFieldRefInput<$PrismaModel>
|
||||
not?: Prisma.NestedDecimalFilter<$PrismaModel> | runtime.Decimal | runtime.DecimalJsLike | number | string
|
||||
}
|
||||
|
||||
export type DecimalWithAggregatesFilter<$PrismaModel = never> = {
|
||||
equals?: runtime.Decimal | runtime.DecimalJsLike | number | string | Prisma.DecimalFieldRefInput<$PrismaModel>
|
||||
in?: runtime.Decimal[] | runtime.DecimalJsLike[] | number[] | string[] | Prisma.ListDecimalFieldRefInput<$PrismaModel>
|
||||
notIn?: runtime.Decimal[] | runtime.DecimalJsLike[] | number[] | string[] | Prisma.ListDecimalFieldRefInput<$PrismaModel>
|
||||
lt?: runtime.Decimal | runtime.DecimalJsLike | number | string | Prisma.DecimalFieldRefInput<$PrismaModel>
|
||||
lte?: runtime.Decimal | runtime.DecimalJsLike | number | string | Prisma.DecimalFieldRefInput<$PrismaModel>
|
||||
gt?: runtime.Decimal | runtime.DecimalJsLike | number | string | Prisma.DecimalFieldRefInput<$PrismaModel>
|
||||
gte?: runtime.Decimal | runtime.DecimalJsLike | number | string | Prisma.DecimalFieldRefInput<$PrismaModel>
|
||||
not?: Prisma.NestedDecimalWithAggregatesFilter<$PrismaModel> | runtime.Decimal | runtime.DecimalJsLike | number | string
|
||||
_count?: Prisma.NestedIntFilter<$PrismaModel>
|
||||
_avg?: Prisma.NestedDecimalFilter<$PrismaModel>
|
||||
_sum?: Prisma.NestedDecimalFilter<$PrismaModel>
|
||||
_min?: Prisma.NestedDecimalFilter<$PrismaModel>
|
||||
_max?: Prisma.NestedDecimalFilter<$PrismaModel>
|
||||
}
|
||||
|
||||
export type EnumLeaveTypesFilter<$PrismaModel = never> = {
|
||||
equals?: $Enums.LeaveTypes | Prisma.EnumLeaveTypesFieldRefInput<$PrismaModel>
|
||||
in?: $Enums.LeaveTypes[] | Prisma.ListEnumLeaveTypesFieldRefInput<$PrismaModel>
|
||||
|
|
@ -432,33 +459,6 @@ export type BoolNullableWithAggregatesFilter<$PrismaModel = never> = {
|
|||
_max?: Prisma.NestedBoolNullableFilter<$PrismaModel>
|
||||
}
|
||||
|
||||
export type DecimalFilter<$PrismaModel = never> = {
|
||||
equals?: runtime.Decimal | runtime.DecimalJsLike | number | string | Prisma.DecimalFieldRefInput<$PrismaModel>
|
||||
in?: runtime.Decimal[] | runtime.DecimalJsLike[] | number[] | string[] | Prisma.ListDecimalFieldRefInput<$PrismaModel>
|
||||
notIn?: runtime.Decimal[] | runtime.DecimalJsLike[] | number[] | string[] | Prisma.ListDecimalFieldRefInput<$PrismaModel>
|
||||
lt?: runtime.Decimal | runtime.DecimalJsLike | number | string | Prisma.DecimalFieldRefInput<$PrismaModel>
|
||||
lte?: runtime.Decimal | runtime.DecimalJsLike | number | string | Prisma.DecimalFieldRefInput<$PrismaModel>
|
||||
gt?: runtime.Decimal | runtime.DecimalJsLike | number | string | Prisma.DecimalFieldRefInput<$PrismaModel>
|
||||
gte?: runtime.Decimal | runtime.DecimalJsLike | number | string | Prisma.DecimalFieldRefInput<$PrismaModel>
|
||||
not?: Prisma.NestedDecimalFilter<$PrismaModel> | runtime.Decimal | runtime.DecimalJsLike | number | string
|
||||
}
|
||||
|
||||
export type DecimalWithAggregatesFilter<$PrismaModel = never> = {
|
||||
equals?: runtime.Decimal | runtime.DecimalJsLike | number | string | Prisma.DecimalFieldRefInput<$PrismaModel>
|
||||
in?: runtime.Decimal[] | runtime.DecimalJsLike[] | number[] | string[] | Prisma.ListDecimalFieldRefInput<$PrismaModel>
|
||||
notIn?: runtime.Decimal[] | runtime.DecimalJsLike[] | number[] | string[] | Prisma.ListDecimalFieldRefInput<$PrismaModel>
|
||||
lt?: runtime.Decimal | runtime.DecimalJsLike | number | string | Prisma.DecimalFieldRefInput<$PrismaModel>
|
||||
lte?: runtime.Decimal | runtime.DecimalJsLike | number | string | Prisma.DecimalFieldRefInput<$PrismaModel>
|
||||
gt?: runtime.Decimal | runtime.DecimalJsLike | number | string | Prisma.DecimalFieldRefInput<$PrismaModel>
|
||||
gte?: runtime.Decimal | runtime.DecimalJsLike | number | string | Prisma.DecimalFieldRefInput<$PrismaModel>
|
||||
not?: Prisma.NestedDecimalWithAggregatesFilter<$PrismaModel> | runtime.Decimal | runtime.DecimalJsLike | number | string
|
||||
_count?: Prisma.NestedIntFilter<$PrismaModel>
|
||||
_avg?: Prisma.NestedDecimalFilter<$PrismaModel>
|
||||
_sum?: Prisma.NestedDecimalFilter<$PrismaModel>
|
||||
_min?: Prisma.NestedDecimalFilter<$PrismaModel>
|
||||
_max?: Prisma.NestedDecimalFilter<$PrismaModel>
|
||||
}
|
||||
|
||||
export type NestedUuidFilter<$PrismaModel = never> = {
|
||||
equals?: string | Prisma.StringFieldRefInput<$PrismaModel>
|
||||
in?: string[] | Prisma.ListStringFieldRefInput<$PrismaModel>
|
||||
|
|
@ -743,6 +743,33 @@ export type NestedFloatNullableFilter<$PrismaModel = never> = {
|
|||
not?: Prisma.NestedFloatNullableFilter<$PrismaModel> | number | null
|
||||
}
|
||||
|
||||
export type NestedDecimalFilter<$PrismaModel = never> = {
|
||||
equals?: runtime.Decimal | runtime.DecimalJsLike | number | string | Prisma.DecimalFieldRefInput<$PrismaModel>
|
||||
in?: runtime.Decimal[] | runtime.DecimalJsLike[] | number[] | string[] | Prisma.ListDecimalFieldRefInput<$PrismaModel>
|
||||
notIn?: runtime.Decimal[] | runtime.DecimalJsLike[] | number[] | string[] | Prisma.ListDecimalFieldRefInput<$PrismaModel>
|
||||
lt?: runtime.Decimal | runtime.DecimalJsLike | number | string | Prisma.DecimalFieldRefInput<$PrismaModel>
|
||||
lte?: runtime.Decimal | runtime.DecimalJsLike | number | string | Prisma.DecimalFieldRefInput<$PrismaModel>
|
||||
gt?: runtime.Decimal | runtime.DecimalJsLike | number | string | Prisma.DecimalFieldRefInput<$PrismaModel>
|
||||
gte?: runtime.Decimal | runtime.DecimalJsLike | number | string | Prisma.DecimalFieldRefInput<$PrismaModel>
|
||||
not?: Prisma.NestedDecimalFilter<$PrismaModel> | runtime.Decimal | runtime.DecimalJsLike | number | string
|
||||
}
|
||||
|
||||
export type NestedDecimalWithAggregatesFilter<$PrismaModel = never> = {
|
||||
equals?: runtime.Decimal | runtime.DecimalJsLike | number | string | Prisma.DecimalFieldRefInput<$PrismaModel>
|
||||
in?: runtime.Decimal[] | runtime.DecimalJsLike[] | number[] | string[] | Prisma.ListDecimalFieldRefInput<$PrismaModel>
|
||||
notIn?: runtime.Decimal[] | runtime.DecimalJsLike[] | number[] | string[] | Prisma.ListDecimalFieldRefInput<$PrismaModel>
|
||||
lt?: runtime.Decimal | runtime.DecimalJsLike | number | string | Prisma.DecimalFieldRefInput<$PrismaModel>
|
||||
lte?: runtime.Decimal | runtime.DecimalJsLike | number | string | Prisma.DecimalFieldRefInput<$PrismaModel>
|
||||
gt?: runtime.Decimal | runtime.DecimalJsLike | number | string | Prisma.DecimalFieldRefInput<$PrismaModel>
|
||||
gte?: runtime.Decimal | runtime.DecimalJsLike | number | string | Prisma.DecimalFieldRefInput<$PrismaModel>
|
||||
not?: Prisma.NestedDecimalWithAggregatesFilter<$PrismaModel> | runtime.Decimal | runtime.DecimalJsLike | number | string
|
||||
_count?: Prisma.NestedIntFilter<$PrismaModel>
|
||||
_avg?: Prisma.NestedDecimalFilter<$PrismaModel>
|
||||
_sum?: Prisma.NestedDecimalFilter<$PrismaModel>
|
||||
_min?: Prisma.NestedDecimalFilter<$PrismaModel>
|
||||
_max?: Prisma.NestedDecimalFilter<$PrismaModel>
|
||||
}
|
||||
|
||||
export type NestedEnumLeaveTypesFilter<$PrismaModel = never> = {
|
||||
equals?: $Enums.LeaveTypes | Prisma.EnumLeaveTypesFieldRefInput<$PrismaModel>
|
||||
in?: $Enums.LeaveTypes[] | Prisma.ListEnumLeaveTypesFieldRefInput<$PrismaModel>
|
||||
|
|
@ -850,31 +877,4 @@ export type NestedBoolNullableWithAggregatesFilter<$PrismaModel = never> = {
|
|||
_max?: Prisma.NestedBoolNullableFilter<$PrismaModel>
|
||||
}
|
||||
|
||||
export type NestedDecimalFilter<$PrismaModel = never> = {
|
||||
equals?: runtime.Decimal | runtime.DecimalJsLike | number | string | Prisma.DecimalFieldRefInput<$PrismaModel>
|
||||
in?: runtime.Decimal[] | runtime.DecimalJsLike[] | number[] | string[] | Prisma.ListDecimalFieldRefInput<$PrismaModel>
|
||||
notIn?: runtime.Decimal[] | runtime.DecimalJsLike[] | number[] | string[] | Prisma.ListDecimalFieldRefInput<$PrismaModel>
|
||||
lt?: runtime.Decimal | runtime.DecimalJsLike | number | string | Prisma.DecimalFieldRefInput<$PrismaModel>
|
||||
lte?: runtime.Decimal | runtime.DecimalJsLike | number | string | Prisma.DecimalFieldRefInput<$PrismaModel>
|
||||
gt?: runtime.Decimal | runtime.DecimalJsLike | number | string | Prisma.DecimalFieldRefInput<$PrismaModel>
|
||||
gte?: runtime.Decimal | runtime.DecimalJsLike | number | string | Prisma.DecimalFieldRefInput<$PrismaModel>
|
||||
not?: Prisma.NestedDecimalFilter<$PrismaModel> | runtime.Decimal | runtime.DecimalJsLike | number | string
|
||||
}
|
||||
|
||||
export type NestedDecimalWithAggregatesFilter<$PrismaModel = never> = {
|
||||
equals?: runtime.Decimal | runtime.DecimalJsLike | number | string | Prisma.DecimalFieldRefInput<$PrismaModel>
|
||||
in?: runtime.Decimal[] | runtime.DecimalJsLike[] | number[] | string[] | Prisma.ListDecimalFieldRefInput<$PrismaModel>
|
||||
notIn?: runtime.Decimal[] | runtime.DecimalJsLike[] | number[] | string[] | Prisma.ListDecimalFieldRefInput<$PrismaModel>
|
||||
lt?: runtime.Decimal | runtime.DecimalJsLike | number | string | Prisma.DecimalFieldRefInput<$PrismaModel>
|
||||
lte?: runtime.Decimal | runtime.DecimalJsLike | number | string | Prisma.DecimalFieldRefInput<$PrismaModel>
|
||||
gt?: runtime.Decimal | runtime.DecimalJsLike | number | string | Prisma.DecimalFieldRefInput<$PrismaModel>
|
||||
gte?: runtime.Decimal | runtime.DecimalJsLike | number | string | Prisma.DecimalFieldRefInput<$PrismaModel>
|
||||
not?: Prisma.NestedDecimalWithAggregatesFilter<$PrismaModel> | runtime.Decimal | runtime.DecimalJsLike | number | string
|
||||
_count?: Prisma.NestedIntFilter<$PrismaModel>
|
||||
_avg?: Prisma.NestedDecimalFilter<$PrismaModel>
|
||||
_sum?: Prisma.NestedDecimalFilter<$PrismaModel>
|
||||
_min?: Prisma.NestedDecimalFilter<$PrismaModel>
|
||||
_max?: Prisma.NestedDecimalFilter<$PrismaModel>
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
|
|
@ -388,6 +388,7 @@ export const ModelName = {
|
|||
Notifications: 'Notifications',
|
||||
userModuleAccess: 'userModuleAccess',
|
||||
Employees: 'Employees',
|
||||
Contracts: 'Contracts',
|
||||
LeaveRequests: 'LeaveRequests',
|
||||
LeaveRequestsArchive: 'LeaveRequestsArchive',
|
||||
Timesheets: 'Timesheets',
|
||||
|
|
@ -419,7 +420,7 @@ export type TypeMap<ExtArgs extends runtime.Types.Extensions.InternalArgs = runt
|
|||
omit: GlobalOmitOptions
|
||||
}
|
||||
meta: {
|
||||
modelProps: "users" | "notifications" | "userModuleAccess" | "employees" | "leaveRequests" | "leaveRequestsArchive" | "timesheets" | "timesheetsArchive" | "schedulePresets" | "schedulePresetShifts" | "shifts" | "shiftsArchive" | "bankCodes" | "expenses" | "expensesArchive" | "oAuthSessions" | "sessions" | "preferences" | "paidTimeOff" | "payPeriods"
|
||||
modelProps: "users" | "notifications" | "userModuleAccess" | "employees" | "contracts" | "leaveRequests" | "leaveRequestsArchive" | "timesheets" | "timesheetsArchive" | "schedulePresets" | "schedulePresetShifts" | "shifts" | "shiftsArchive" | "bankCodes" | "expenses" | "expensesArchive" | "oAuthSessions" | "sessions" | "preferences" | "paidTimeOff" | "payPeriods"
|
||||
txIsolationLevel: TransactionIsolationLevel
|
||||
}
|
||||
model: {
|
||||
|
|
@ -719,6 +720,80 @@ export type TypeMap<ExtArgs extends runtime.Types.Extensions.InternalArgs = runt
|
|||
}
|
||||
}
|
||||
}
|
||||
Contracts: {
|
||||
payload: Prisma.$ContractsPayload<ExtArgs>
|
||||
fields: Prisma.ContractsFieldRefs
|
||||
operations: {
|
||||
findUnique: {
|
||||
args: Prisma.ContractsFindUniqueArgs<ExtArgs>
|
||||
result: runtime.Types.Utils.PayloadToResult<Prisma.$ContractsPayload> | null
|
||||
}
|
||||
findUniqueOrThrow: {
|
||||
args: Prisma.ContractsFindUniqueOrThrowArgs<ExtArgs>
|
||||
result: runtime.Types.Utils.PayloadToResult<Prisma.$ContractsPayload>
|
||||
}
|
||||
findFirst: {
|
||||
args: Prisma.ContractsFindFirstArgs<ExtArgs>
|
||||
result: runtime.Types.Utils.PayloadToResult<Prisma.$ContractsPayload> | null
|
||||
}
|
||||
findFirstOrThrow: {
|
||||
args: Prisma.ContractsFindFirstOrThrowArgs<ExtArgs>
|
||||
result: runtime.Types.Utils.PayloadToResult<Prisma.$ContractsPayload>
|
||||
}
|
||||
findMany: {
|
||||
args: Prisma.ContractsFindManyArgs<ExtArgs>
|
||||
result: runtime.Types.Utils.PayloadToResult<Prisma.$ContractsPayload>[]
|
||||
}
|
||||
create: {
|
||||
args: Prisma.ContractsCreateArgs<ExtArgs>
|
||||
result: runtime.Types.Utils.PayloadToResult<Prisma.$ContractsPayload>
|
||||
}
|
||||
createMany: {
|
||||
args: Prisma.ContractsCreateManyArgs<ExtArgs>
|
||||
result: BatchPayload
|
||||
}
|
||||
createManyAndReturn: {
|
||||
args: Prisma.ContractsCreateManyAndReturnArgs<ExtArgs>
|
||||
result: runtime.Types.Utils.PayloadToResult<Prisma.$ContractsPayload>[]
|
||||
}
|
||||
delete: {
|
||||
args: Prisma.ContractsDeleteArgs<ExtArgs>
|
||||
result: runtime.Types.Utils.PayloadToResult<Prisma.$ContractsPayload>
|
||||
}
|
||||
update: {
|
||||
args: Prisma.ContractsUpdateArgs<ExtArgs>
|
||||
result: runtime.Types.Utils.PayloadToResult<Prisma.$ContractsPayload>
|
||||
}
|
||||
deleteMany: {
|
||||
args: Prisma.ContractsDeleteManyArgs<ExtArgs>
|
||||
result: BatchPayload
|
||||
}
|
||||
updateMany: {
|
||||
args: Prisma.ContractsUpdateManyArgs<ExtArgs>
|
||||
result: BatchPayload
|
||||
}
|
||||
updateManyAndReturn: {
|
||||
args: Prisma.ContractsUpdateManyAndReturnArgs<ExtArgs>
|
||||
result: runtime.Types.Utils.PayloadToResult<Prisma.$ContractsPayload>[]
|
||||
}
|
||||
upsert: {
|
||||
args: Prisma.ContractsUpsertArgs<ExtArgs>
|
||||
result: runtime.Types.Utils.PayloadToResult<Prisma.$ContractsPayload>
|
||||
}
|
||||
aggregate: {
|
||||
args: Prisma.ContractsAggregateArgs<ExtArgs>
|
||||
result: runtime.Types.Utils.Optional<Prisma.AggregateContracts>
|
||||
}
|
||||
groupBy: {
|
||||
args: Prisma.ContractsGroupByArgs<ExtArgs>
|
||||
result: runtime.Types.Utils.Optional<Prisma.ContractsGroupByOutputType>[]
|
||||
}
|
||||
count: {
|
||||
args: Prisma.ContractsCountArgs<ExtArgs>
|
||||
result: runtime.Types.Utils.Optional<Prisma.ContractsCountAggregateOutputType> | number
|
||||
}
|
||||
}
|
||||
}
|
||||
LeaveRequests: {
|
||||
payload: Prisma.$LeaveRequestsPayload<ExtArgs>
|
||||
fields: Prisma.LeaveRequestsFieldRefs
|
||||
|
|
@ -1947,19 +2022,30 @@ export const EmployeesScalarFieldEnum = {
|
|||
user_id: 'user_id',
|
||||
external_payroll_id: 'external_payroll_id',
|
||||
company_code: 'company_code',
|
||||
daily_expected_hours: 'daily_expected_hours',
|
||||
first_work_day: 'first_work_day',
|
||||
last_work_day: 'last_work_day',
|
||||
supervisor_id: 'supervisor_id',
|
||||
job_title: 'job_title',
|
||||
is_supervisor: 'is_supervisor',
|
||||
applicable_overtime: 'applicable_overtime',
|
||||
schedule_preset_id: 'schedule_preset_id'
|
||||
} as const
|
||||
|
||||
export type EmployeesScalarFieldEnum = (typeof EmployeesScalarFieldEnum)[keyof typeof EmployeesScalarFieldEnum]
|
||||
|
||||
|
||||
export const ContractsScalarFieldEnum = {
|
||||
id: 'id',
|
||||
employee_id: 'employee_id',
|
||||
daily_expected_hours: 'daily_expected_hours',
|
||||
applicable_overtime: 'applicable_overtime',
|
||||
phone_allocation: 'phone_allocation',
|
||||
on_call_allocation: 'on_call_allocation',
|
||||
weekend_on_call_allocation: 'weekend_on_call_allocation'
|
||||
} as const
|
||||
|
||||
export type ContractsScalarFieldEnum = (typeof ContractsScalarFieldEnum)[keyof typeof ContractsScalarFieldEnum]
|
||||
|
||||
|
||||
export const LeaveRequestsScalarFieldEnum = {
|
||||
id: 'id',
|
||||
employee_id: 'employee_id',
|
||||
|
|
@ -2326,6 +2412,20 @@ export type EnumApplicableOvertimeFieldRefInput<$PrismaModel> = FieldRefInputTyp
|
|||
|
||||
|
||||
|
||||
/**
|
||||
* Reference to a field of type 'Decimal'
|
||||
*/
|
||||
export type DecimalFieldRefInput<$PrismaModel> = FieldRefInputType<$PrismaModel, 'Decimal'>
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Reference to a field of type 'Decimal[]'
|
||||
*/
|
||||
export type ListDecimalFieldRefInput<$PrismaModel> = FieldRefInputType<$PrismaModel, 'Decimal[]'>
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Reference to a field of type 'LeaveTypes'
|
||||
*/
|
||||
|
|
@ -2354,20 +2454,6 @@ export type ListEnumLeaveApprovalStatusFieldRefInput<$PrismaModel> = FieldRefInp
|
|||
|
||||
|
||||
|
||||
/**
|
||||
* Reference to a field of type 'Decimal'
|
||||
*/
|
||||
export type DecimalFieldRefInput<$PrismaModel> = FieldRefInputType<$PrismaModel, 'Decimal'>
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Reference to a field of type 'Decimal[]'
|
||||
*/
|
||||
export type ListDecimalFieldRefInput<$PrismaModel> = FieldRefInputType<$PrismaModel, 'Decimal[]'>
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Reference to a field of type 'Weekday'
|
||||
*/
|
||||
|
|
@ -2494,6 +2580,7 @@ export type GlobalOmitConfig = {
|
|||
notifications?: Prisma.NotificationsOmit
|
||||
userModuleAccess?: Prisma.userModuleAccessOmit
|
||||
employees?: Prisma.EmployeesOmit
|
||||
contracts?: Prisma.ContractsOmit
|
||||
leaveRequests?: Prisma.LeaveRequestsOmit
|
||||
leaveRequestsArchive?: Prisma.LeaveRequestsArchiveOmit
|
||||
timesheets?: Prisma.TimesheetsOmit
|
||||
|
|
|
|||
|
|
@ -55,6 +55,7 @@ export const ModelName = {
|
|||
Notifications: 'Notifications',
|
||||
userModuleAccess: 'userModuleAccess',
|
||||
Employees: 'Employees',
|
||||
Contracts: 'Contracts',
|
||||
LeaveRequests: 'LeaveRequests',
|
||||
LeaveRequestsArchive: 'LeaveRequestsArchive',
|
||||
Timesheets: 'Timesheets',
|
||||
|
|
@ -138,19 +139,30 @@ export const EmployeesScalarFieldEnum = {
|
|||
user_id: 'user_id',
|
||||
external_payroll_id: 'external_payroll_id',
|
||||
company_code: 'company_code',
|
||||
daily_expected_hours: 'daily_expected_hours',
|
||||
first_work_day: 'first_work_day',
|
||||
last_work_day: 'last_work_day',
|
||||
supervisor_id: 'supervisor_id',
|
||||
job_title: 'job_title',
|
||||
is_supervisor: 'is_supervisor',
|
||||
applicable_overtime: 'applicable_overtime',
|
||||
schedule_preset_id: 'schedule_preset_id'
|
||||
} as const
|
||||
|
||||
export type EmployeesScalarFieldEnum = (typeof EmployeesScalarFieldEnum)[keyof typeof EmployeesScalarFieldEnum]
|
||||
|
||||
|
||||
export const ContractsScalarFieldEnum = {
|
||||
id: 'id',
|
||||
employee_id: 'employee_id',
|
||||
daily_expected_hours: 'daily_expected_hours',
|
||||
applicable_overtime: 'applicable_overtime',
|
||||
phone_allocation: 'phone_allocation',
|
||||
on_call_allocation: 'on_call_allocation',
|
||||
weekend_on_call_allocation: 'weekend_on_call_allocation'
|
||||
} as const
|
||||
|
||||
export type ContractsScalarFieldEnum = (typeof ContractsScalarFieldEnum)[keyof typeof ContractsScalarFieldEnum]
|
||||
|
||||
|
||||
export const LeaveRequestsScalarFieldEnum = {
|
||||
id: 'id',
|
||||
employee_id: 'employee_id',
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ export type * from './models/Users'
|
|||
export type * from './models/Notifications'
|
||||
export type * from './models/userModuleAccess'
|
||||
export type * from './models/Employees'
|
||||
export type * from './models/Contracts'
|
||||
export type * from './models/LeaveRequests'
|
||||
export type * from './models/LeaveRequestsArchive'
|
||||
export type * from './models/Timesheets'
|
||||
|
|
|
|||
1442
prisma/postgres/generated/prisma/client/postgres/models/Contracts.ts
Normal file
1442
prisma/postgres/generated/prisma/client/postgres/models/Contracts.ts
Normal file
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
|
@ -431,14 +431,6 @@ export type PaidTimeOffUncheckedUpdateOneWithoutEmployeeNestedInput = {
|
|||
update?: Prisma.XOR<Prisma.XOR<Prisma.PaidTimeOffUpdateToOneWithWhereWithoutEmployeeInput, Prisma.PaidTimeOffUpdateWithoutEmployeeInput>, Prisma.PaidTimeOffUncheckedUpdateWithoutEmployeeInput>
|
||||
}
|
||||
|
||||
export type DecimalFieldUpdateOperationsInput = {
|
||||
set?: runtime.Decimal | runtime.DecimalJsLike | number | string
|
||||
increment?: runtime.Decimal | runtime.DecimalJsLike | number | string
|
||||
decrement?: runtime.Decimal | runtime.DecimalJsLike | number | string
|
||||
multiply?: runtime.Decimal | runtime.DecimalJsLike | number | string
|
||||
divide?: runtime.Decimal | runtime.DecimalJsLike | number | string
|
||||
}
|
||||
|
||||
export type PaidTimeOffCreateWithoutEmployeeInput = {
|
||||
vacation_hours?: runtime.Decimal | runtime.DecimalJsLike | number | string
|
||||
banked_hours?: runtime.Decimal | runtime.DecimalJsLike | number | string
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ model Users {
|
|||
phone_number String
|
||||
residence String?
|
||||
role Roles @default(EMPLOYEE)
|
||||
|
||||
notifications Notifications? @relation("UserNotification")
|
||||
employee Employees? @relation("UserEmployee")
|
||||
oauth_sessions OAuthSessions[] @relation("UserOAuthSessions")
|
||||
|
|
@ -34,6 +35,7 @@ model Notifications {
|
|||
metadata Json @db.JsonB
|
||||
created_at DateTime @default(now())
|
||||
viewed_at DateTime?
|
||||
|
||||
user Users @relation("UserNotification", fields: [user_id], references: [id])
|
||||
|
||||
@@map("notifications")
|
||||
|
|
@ -51,6 +53,7 @@ model userModuleAccess {
|
|||
chatbot Boolean @default(false)
|
||||
ticket Boolean @default(false)
|
||||
ticket_management Boolean @default(false)
|
||||
|
||||
user Users @relation("UserModuleAccess", fields: [user_id], references: [id])
|
||||
|
||||
@@map("user_module_access")
|
||||
|
|
@ -61,14 +64,13 @@ model Employees {
|
|||
user_id String @unique @db.Uuid
|
||||
external_payroll_id Int
|
||||
company_code Int
|
||||
daily_expected_hours Int @default(24)
|
||||
first_work_day DateTime @db.Date
|
||||
last_work_day DateTime? @db.Date
|
||||
supervisor_id Int?
|
||||
job_title String?
|
||||
is_supervisor Boolean @default(false)
|
||||
applicable_overtime ApplicableOvertime[] @default([WEEKLY])
|
||||
schedule_preset_id Int?
|
||||
|
||||
schedule_preset SchedulePresets? @relation("EmployeesSchedulePreset", fields: [schedule_preset_id], references: [id])
|
||||
supervisor Employees? @relation("EmployeeSupervisor", fields: [supervisor_id], references: [id])
|
||||
crew Employees[] @relation("EmployeeSupervisor")
|
||||
|
|
@ -76,10 +78,25 @@ model Employees {
|
|||
leave_request LeaveRequests[] @relation("LeaveRequestEmployee")
|
||||
timesheet Timesheets[] @relation("TimesheetEmployee")
|
||||
paid_time_off PaidTimeOff? @relation("EmployeePaidTimeOff")
|
||||
contracts Contracts? @relation("EmployeeContract")
|
||||
|
||||
@@map("employees")
|
||||
}
|
||||
|
||||
model Contracts {
|
||||
id Int @id @default(autoincrement())
|
||||
employee_id Int @unique
|
||||
daily_expected_hours Int @default(24)
|
||||
applicable_overtime ApplicableOvertime[] @default([WEEKLY])
|
||||
phone_allocation Decimal @default(0.00) @db.Decimal(5, 2)
|
||||
on_call_allocation Decimal @default(0.00) @db.Decimal(5, 2)
|
||||
weekend_on_call_allocation Decimal @default(0.00) @db.Decimal(5, 2)
|
||||
|
||||
employee Employees @relation("EmployeeContract", fields: [employee_id], references: [id])
|
||||
|
||||
@@map("contracts")
|
||||
}
|
||||
|
||||
model LeaveRequests {
|
||||
id Int @id @default(autoincrement())
|
||||
employee_id Int
|
||||
|
|
@ -90,6 +107,7 @@ model LeaveRequests {
|
|||
payable_hours Decimal? @db.Decimal(5, 2)
|
||||
requested_hours Decimal? @db.Decimal(5, 2)
|
||||
dates DateTime[] @db.Date
|
||||
|
||||
bank_code BankCodes @relation("LeaveRequestBankCodes", fields: [bank_code_id], references: [id])
|
||||
employee Employees @relation("LeaveRequestEmployee", fields: [employee_id], references: [id])
|
||||
archive LeaveRequestsArchive? @relation("LeaveRequestToArchive")
|
||||
|
|
@ -110,6 +128,7 @@ model LeaveRequestsArchive {
|
|||
date DateTime @db.Date
|
||||
payable_hours Decimal? @db.Decimal(5, 2)
|
||||
requested_hours Decimal? @db.Decimal(5, 2)
|
||||
|
||||
leave_request LeaveRequests @relation("LeaveRequestToArchive", fields: [leave_request_id], references: [id])
|
||||
|
||||
@@index([employee_id, date])
|
||||
|
|
@ -122,6 +141,7 @@ model Timesheets {
|
|||
is_approved Boolean @default(false)
|
||||
start_date DateTime @db.Date
|
||||
// hours_to_bank Decimal? @db.Decimal(5, 2) //will need to be implemented in the future
|
||||
|
||||
expense Expenses[] @relation("ExpensesTimesheet")
|
||||
shift Shifts[] @relation("ShiftTimesheet")
|
||||
employee Employees @relation("TimesheetEmployee", fields: [employee_id], references: [id])
|
||||
|
|
|
|||
16
src/identity-and-account/contract/contract.controller.ts
Normal file
16
src/identity-and-account/contract/contract.controller.ts
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
import { Controller, Get, Param } from "@nestjs/common";
|
||||
// import { Access } from "src/common/decorators/module-access.decorators";
|
||||
import { ContractService } from "src/identity-and-account/contract/services/contract.service";
|
||||
|
||||
@Controller('contracts')
|
||||
export class ContractController {
|
||||
constructor(private readonly getService: ContractService) { }
|
||||
|
||||
|
||||
@Get('details/:email')
|
||||
async getContractDetailsByEmail(
|
||||
@Param('email') email: string
|
||||
) {
|
||||
return await this.getService.getContractDetailsByEmail(email);
|
||||
}
|
||||
}
|
||||
12
src/identity-and-account/contract/contract.dto.ts
Normal file
12
src/identity-and-account/contract/contract.dto.ts
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
import { Type } from "class-transformer";
|
||||
import { IsArray, IsInt, IsString } from "class-validator";
|
||||
import { ApplicableOvertime } from "prisma/postgres/generated/prisma/client/postgres/enums";
|
||||
|
||||
export class Contract {
|
||||
@IsInt() id: number;
|
||||
@IsInt() daily_expected_hours: number;
|
||||
@IsString() @IsArray() applicable_overtime: ApplicableOvertime[];
|
||||
@Type(() => Number) phone_allocation: number;
|
||||
@Type(() => Number) on_call_allocation: number;
|
||||
@Type(() => Number) weekend_on_call_allocation: number;
|
||||
}
|
||||
12
src/identity-and-account/contract/contract.module.ts
Normal file
12
src/identity-and-account/contract/contract.module.ts
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
import { Module } from "@nestjs/common";
|
||||
import { ContractController } from "src/identity-and-account/contract/contract.controller";
|
||||
import { ContractService } from "src/identity-and-account/contract/services/contract.service";
|
||||
|
||||
@Module({
|
||||
imports: [
|
||||
ContractService,
|
||||
],
|
||||
providers: [
|
||||
ContractController,
|
||||
]
|
||||
}) export class ContractModule { }
|
||||
|
|
@ -0,0 +1,43 @@
|
|||
import { Injectable } from "@nestjs/common";
|
||||
import { PrismaPostgresService } from "prisma/postgres/prisma-postgres.service";
|
||||
import { Result } from "src/common/errors/result-error.factory";
|
||||
import { EmailToIdResolver } from "src/common/mappers/email-id.mapper";
|
||||
import { Contract } from "src/identity-and-account/contract/contract.dto";
|
||||
|
||||
@Injectable()
|
||||
export class ContractService {
|
||||
|
||||
constructor(
|
||||
private readonly prisma: PrismaPostgresService,
|
||||
private readonly emailresolver: EmailToIdResolver,
|
||||
) { }
|
||||
|
||||
getContractDetailsByEmail = async (email: string): Promise<Result<Contract, string>> => {
|
||||
try {
|
||||
const employee = await this.emailresolver.findIdByEmail(email);
|
||||
if (!employee.success) return { success: false, error: 'EMPLOYEE_NOT_FOUND' };
|
||||
|
||||
const contract = await this.prisma.contracts.findUnique({
|
||||
where: { employee_id: employee.data },
|
||||
omit: { employee_id: true },
|
||||
});
|
||||
if (!contract) return { success: false, error: 'CONTRACT_NOT_FOUND' };
|
||||
|
||||
const contractDetails: Contract = {
|
||||
id: contract.id,
|
||||
daily_expected_hours: contract.daily_expected_hours,
|
||||
applicable_overtime: contract.applicable_overtime,
|
||||
on_call_allocation: Number(contract.on_call_allocation),
|
||||
weekend_on_call_allocation: Number(contract.weekend_on_call_allocation),
|
||||
phone_allocation: Number(contract.phone_allocation),
|
||||
};
|
||||
|
||||
return { success: true, data: contractDetails }
|
||||
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
return { success: false, error: 'CONTRACT_NOT_FOUND' };
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -2,6 +2,7 @@ import { IsArray, IsBoolean, IsDateString, IsEmail, IsInt, IsNotEmpty, IsOptiona
|
|||
import { Type } from 'class-transformer';
|
||||
import { PaidTimeOffDto } from 'src/time-and-attendance/paid-time-off/paid-time-off.dto';
|
||||
import { Prisma } from 'prisma/postgres/generated/prisma/client/postgres/client';
|
||||
import { Contract } from 'src/identity-and-account/contract/contract.dto';
|
||||
|
||||
export class EmployeeDetailedDto {
|
||||
@IsString() @IsNotEmpty() first_name: string;
|
||||
|
|
@ -14,9 +15,9 @@ export class EmployeeDetailedDto {
|
|||
@IsEmail() @IsOptional() email: string;
|
||||
@IsString() phone_number: string;
|
||||
@IsDateString() first_work_day: string;
|
||||
@IsInt() daily_expected_hours: number;
|
||||
@IsDateString() @IsOptional() last_work_day?: string | null;
|
||||
@IsString() @IsOptional() residence?: string;
|
||||
@IsInt() @Type(() => Contract) contract: Partial<Contract>;
|
||||
@IsOptional() @Type(() => PaidTimeOffDto) paid_time_off?: Partial<PaidTimeOffDto>;
|
||||
@IsInt() @IsPositive() @Type(() => Number) external_payroll_id: number;
|
||||
@IsArray() @IsString({ each: true }) user_module_access: string[];
|
||||
|
|
@ -34,9 +35,9 @@ export class EmployeeDetailedUpsertDto {
|
|||
@IsEmail() @IsOptional() email: string;
|
||||
@IsString() phone_number: string;
|
||||
@IsDateString() first_work_day: string;
|
||||
@IsInt() daily_expected_hours: number;
|
||||
@IsDateString() @IsOptional() last_work_day?: string | null;
|
||||
@IsString() @IsOptional() residence?: string;
|
||||
@IsInt() @Type(() => Contract) contract: Partial<Contract>;
|
||||
@IsOptional() @Type(() => PaidTimeOffDto) paid_time_off?: PaidTimeOffDto;
|
||||
@IsInt() @IsPositive() @Type(() => Number) external_payroll_id: number;
|
||||
@IsArray() @IsString({ each: true }) user_module_access: string[];
|
||||
|
|
@ -74,9 +75,26 @@ export type EmployeeWithDetails = Prisma.EmployeesGetPayload<{
|
|||
first_work_day: true,
|
||||
last_work_day: true,
|
||||
external_payroll_id: true,
|
||||
paid_time_off: true,
|
||||
paid_time_off: {
|
||||
select: {
|
||||
id: true,
|
||||
employee_id: true,
|
||||
sick_hours: true,
|
||||
vacation_hours: true,
|
||||
banked_hours: true,
|
||||
last_updated: true,
|
||||
},
|
||||
},
|
||||
is_supervisor: true,
|
||||
contracts: {
|
||||
select: {
|
||||
daily_expected_hours: true,
|
||||
applicable_overtime: true,
|
||||
weekend_on_call_allocation: true,
|
||||
on_call_allocation: true,
|
||||
phone_allocation: true,
|
||||
},
|
||||
},
|
||||
schedule_preset_id: true,
|
||||
schedule_preset: { select: { id: true } }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -44,13 +44,20 @@ export class EmployeesCreateService {
|
|||
data: {
|
||||
user_id: user.id,
|
||||
external_payroll_id: dto.external_payroll_id,
|
||||
daily_expected_hours: dto.daily_expected_hours,
|
||||
company_code: company_code,
|
||||
job_title: dto.job_title,
|
||||
first_work_day: first_work_day,
|
||||
is_supervisor: dto.is_supervisor,
|
||||
supervisor_id: supervisor_id,
|
||||
schedule_preset_id: dto.preset_id,
|
||||
contracts: {
|
||||
create: {
|
||||
daily_expected_hours: dto.contract.daily_expected_hours,
|
||||
phone_allocation: dto.contract.phone_allocation,
|
||||
on_call_allocation: dto.contract.on_call_allocation,
|
||||
weekend_on_call_allocation: dto.contract.weekend_on_call_allocation,
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -37,8 +37,16 @@ export class EmployeesGetService {
|
|||
},
|
||||
},
|
||||
},
|
||||
is_supervisor: true,
|
||||
contracts: {
|
||||
select: {
|
||||
daily_expected_hours: true,
|
||||
applicable_overtime: true,
|
||||
on_call_allocation: true,
|
||||
weekend_on_call_allocation: true,
|
||||
phone_allocation: true,
|
||||
},
|
||||
},
|
||||
is_supervisor: true,
|
||||
job_title: true,
|
||||
company_code: true,
|
||||
external_payroll_id: true,
|
||||
|
|
@ -47,14 +55,23 @@ export class EmployeesGetService {
|
|||
schedule_preset_id: true,
|
||||
|
||||
}
|
||||
}).then(rows => rows.map(r => ({
|
||||
});
|
||||
|
||||
const employeeDetailedList = employee_list.map(r => {
|
||||
return {
|
||||
first_name: r.user.first_name,
|
||||
last_name: r.user.last_name,
|
||||
email: r.user.email,
|
||||
phone_number: r.user.phone_number,
|
||||
company_name: toStringFromCompanyCode(r.company_code),
|
||||
job_title: r.job_title ?? '',
|
||||
daily_expected_hours: r.daily_expected_hours,
|
||||
contract: {
|
||||
daily_expected_hours: r.contracts?.daily_expected_hours ?? 24,
|
||||
applicable_overtime: r.contracts?.applicable_overtime ?? [],
|
||||
phone_allocation: Number(r.contracts?.phone_allocation),
|
||||
on_call_allocation: Number(r.contracts?.on_call_allocation),
|
||||
weekend_on_call_allocation: Number(r.contracts?.weekend_on_call_allocation),
|
||||
},
|
||||
external_payroll_id: r.external_payroll_id,
|
||||
employee_full_name: `${r.user.first_name} ${r.user.last_name}`,
|
||||
is_supervisor: r.is_supervisor,
|
||||
|
|
@ -62,8 +79,9 @@ export class EmployeesGetService {
|
|||
first_work_day: toStringFromDate(r.first_work_day),
|
||||
last_work_day: r.last_work_day ? toStringFromDate(r.last_work_day) : null,
|
||||
preset_id: r.schedule_preset_id ?? undefined,
|
||||
})));
|
||||
return { success: true, data: employee_list };
|
||||
}
|
||||
});
|
||||
return { success: true, data: employeeDetailedList };
|
||||
};
|
||||
|
||||
async findOwnProfile(email: string): Promise<Result<Partial<EmployeeDetailedDto>, string>> {
|
||||
|
|
@ -89,7 +107,11 @@ export class EmployeesGetService {
|
|||
paid_time_off: true,
|
||||
is_supervisor: true,
|
||||
schedule_preset_id: true,
|
||||
contracts: {
|
||||
select: {
|
||||
daily_expected_hours: true,
|
||||
},
|
||||
},
|
||||
supervisor: {
|
||||
select: {
|
||||
id: true, user: {
|
||||
|
|
@ -103,6 +125,7 @@ export class EmployeesGetService {
|
|||
},
|
||||
});
|
||||
if (!existing_profile) return { success: false, error: 'EMPLOYEE_NOT_FOUND' };
|
||||
if (!existing_profile.contracts) return { success: false, error: 'CONTRACT_NOT_FOUND' };
|
||||
|
||||
const company_name = toStringFromCompanyCode(existing_profile.company_code);
|
||||
|
||||
|
|
@ -113,7 +136,9 @@ export class EmployeesGetService {
|
|||
email: existing_profile.user.email,
|
||||
supervisor_full_name: `${existing_profile.supervisor?.user.first_name} ${existing_profile.supervisor?.user.last_name}`,
|
||||
company_name: company_name,
|
||||
daily_expected_hours: existing_profile.daily_expected_hours,
|
||||
contract: {
|
||||
daily_expected_hours: existing_profile.contracts?.daily_expected_hours ?? 24,
|
||||
},
|
||||
job_title: existing_profile.job_title ?? '',
|
||||
external_payroll_id: existing_profile.external_payroll_id,
|
||||
paid_time_off: {
|
||||
|
|
@ -170,6 +195,11 @@ export class EmployeesGetService {
|
|||
},
|
||||
},
|
||||
},
|
||||
contracts: {
|
||||
select: {
|
||||
daily_expected_hours: true,
|
||||
}
|
||||
},
|
||||
job_title: true,
|
||||
company_code: true,
|
||||
first_work_day: true,
|
||||
|
|
@ -177,7 +207,6 @@ export class EmployeesGetService {
|
|||
external_payroll_id: true,
|
||||
paid_time_off: true,
|
||||
is_supervisor: true,
|
||||
daily_expected_hours: true,
|
||||
schedule_preset_id: true,
|
||||
schedule_preset: {
|
||||
select: {
|
||||
|
|
@ -196,9 +225,7 @@ export class EmployeesGetService {
|
|||
|
||||
const company_name = toStringFromCompanyCode(employee.company_code);
|
||||
|
||||
return {
|
||||
success: true,
|
||||
data: {
|
||||
const detailed_employee: EmployeeDetailedDto = {
|
||||
first_name: employee.user.first_name,
|
||||
last_name: employee.user.last_name,
|
||||
email: employee.user.email,
|
||||
|
|
@ -221,10 +248,13 @@ export class EmployeesGetService {
|
|||
last_work_day: employee.last_work_day ? toStringFromDate(employee.last_work_day) : undefined,
|
||||
supervisor_full_name: employee.supervisor ? `${employee.supervisor?.user.first_name} ${employee.supervisor?.user.last_name}` : '',
|
||||
user_module_access: module_access_array,
|
||||
daily_expected_hours: employee.daily_expected_hours,
|
||||
preset_id: employee.schedule_preset_id ? employee.schedule_preset_id : undefined,
|
||||
contract: {
|
||||
daily_expected_hours: employee.contracts?.daily_expected_hours ?? 24,
|
||||
},
|
||||
};
|
||||
preset_id: employee.schedule_preset_id ? employee.schedule_preset_id : undefined,
|
||||
}
|
||||
|
||||
return { success: true, data: detailed_employee };
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -98,13 +98,21 @@ export class EmployeesUpdateService {
|
|||
data: {
|
||||
company_code: company_code,
|
||||
job_title: dto.job_title,
|
||||
daily_expected_hours: dto.daily_expected_hours,
|
||||
first_work_day: toDateFromString(dto.first_work_day),
|
||||
last_work_day: last_work_day,
|
||||
is_supervisor: dto.is_supervisor,
|
||||
supervisor_id: supervisor_id,
|
||||
schedule_preset_id: dto.preset_id,
|
||||
external_payroll_id: dto.external_payroll_id,
|
||||
contracts: {
|
||||
update: {
|
||||
applicable_overtime: dto.contract.applicable_overtime,
|
||||
daily_expected_hours: dto.contract.daily_expected_hours,
|
||||
on_call_allocation: dto.contract.on_call_allocation,
|
||||
weekend_on_call_allocation: dto.contract.weekend_on_call_allocation,
|
||||
phone_allocation: dto.contract.phone_allocation,
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1 @@
|
|||
GET http://localhost:3000/contracts/details/matthieuh@targointernet.com
|
||||
|
|
@ -0,0 +1 @@
|
|||
GET http://localhost:3000/employees/employee-list
|
||||
|
|
@ -17,6 +17,8 @@ import { EmployeesCreateService } from "src/identity-and-account/employees/servi
|
|||
import { EmployeesUpdateService } from "src/identity-and-account/employees/services/employees-update.service";
|
||||
import { HomePageController } from "src/identity-and-account/help/help-page.controller";
|
||||
import { HomePageService } from "src/identity-and-account/help/help-page.service";
|
||||
import { ContractController } from "src/identity-and-account/contract/contract.controller";
|
||||
import { ContractService } from "src/identity-and-account/contract/services/contract.service";
|
||||
|
||||
@Module({
|
||||
imports: [
|
||||
|
|
@ -28,6 +30,7 @@ import { HomePageService } from "src/identity-and-account/help/help-page.service
|
|||
],
|
||||
controllers: [
|
||||
EmployeesController,
|
||||
ContractController,
|
||||
PreferencesController,
|
||||
ModuleAccessController,
|
||||
HomePageController,
|
||||
|
|
@ -42,6 +45,7 @@ import { HomePageService } from "src/identity-and-account/help/help-page.service
|
|||
AccessUpdateService,
|
||||
AccessGetService,
|
||||
HomePageService,
|
||||
ContractService,
|
||||
],
|
||||
})
|
||||
export class IdentityAndAccountModule { };
|
||||
|
|
|
|||
22
src/main.ts
22
src/main.ts
|
|
@ -21,7 +21,7 @@ async function bootstrap() {
|
|||
|
||||
// Authentication and session
|
||||
app.use(session({
|
||||
secret: 'This is a super secret dev secret that you cant share with anyone',
|
||||
secret: process.env.SESSION_SECRET || 'dev-only-secret-change-in-production',
|
||||
resave: false,
|
||||
saveUninitialized: false,
|
||||
rolling: true,
|
||||
|
|
@ -39,9 +39,27 @@ async function bootstrap() {
|
|||
app.use(passport.initialize());
|
||||
app.use(passport.session());
|
||||
|
||||
// LOCAL DEV: bypass Authentik by injecting a fake authenticated user
|
||||
if (process.env.DEV_BYPASS_AUTH === 'true') {
|
||||
console.log('⚠ DEV_BYPASS_AUTH enabled — all requests authenticated as louis@targo.ca');
|
||||
app.use((req, _res, next) => {
|
||||
if (!req.user) {
|
||||
req.user = {
|
||||
first_name: 'Louis',
|
||||
last_name: 'Paul',
|
||||
email: 'louis@targo.ca',
|
||||
role: 'ADMIN',
|
||||
user_module_access: ['timesheets', 'timesheets_approval', 'employee_list', 'employee_management', 'personal_profile', 'dashboard'],
|
||||
};
|
||||
req.isAuthenticated = () => true;
|
||||
}
|
||||
next();
|
||||
});
|
||||
}
|
||||
|
||||
// Enable CORS
|
||||
app.enableCors({
|
||||
origin: ['http://10.100.251.2:9011', 'http://10.5.14.111:9012', 'http://10.100.251.2:9013', 'http://localhost:9000', 'https://app.targo.ca', 'https://portail.targo.ca', 'https://staging.app.targo.ca'],
|
||||
origin: true, // allow all origins in dev
|
||||
credentials: true,
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ export class BankedHoursService {
|
|||
|
||||
try {
|
||||
const result = await this.prisma.$transaction(async (tx) => {
|
||||
const employee = await this.prisma.employees.findUnique({
|
||||
const employee = await tx.employees.findUnique({
|
||||
where: { id: employee_id },
|
||||
select: {
|
||||
id: true,
|
||||
|
|
|
|||
|
|
@ -30,23 +30,16 @@ export class HolidayService {
|
|||
holiday_date: Date
|
||||
): Promise<Result<number, string>> {
|
||||
try {
|
||||
const valid_codes = ['G1', 'G43', 'G140', 'G104', 'G105', 'G305', 'G700', 'G720'];
|
||||
const valid_codes = ['G1', 'G43', 'G48', 'G104', 'G105', 'G109', 'G140', 'G720'];
|
||||
const holiday_week_start = getWeekStart(holiday_date);
|
||||
const window_start = new Date(holiday_week_start.getTime() - 4 * MS_PER_WEEK);
|
||||
const window_end = new Date(holiday_week_start.getTime() - 1);
|
||||
|
||||
const employee = await this.prisma.employees.findFirst({
|
||||
where: {
|
||||
external_payroll_id,
|
||||
company_code,
|
||||
},
|
||||
select: {
|
||||
id: true,
|
||||
}
|
||||
where: { external_payroll_id, company_code }
|
||||
});
|
||||
|
||||
if (!employee)
|
||||
return { success: false, error: 'EMPLOYEE_NOT_FOUND' };
|
||||
if (!employee) return { success: false, error: 'EMPLOYEE_NOT_FOUND' };
|
||||
|
||||
const shifts = await this.prisma.shifts.findMany({
|
||||
where: {
|
||||
|
|
@ -61,8 +54,7 @@ export class HolidayService {
|
|||
for (const shift of shifts) {
|
||||
const hours = computeHours(shift.start_time, shift.end_time);
|
||||
|
||||
if (hours <= 0)
|
||||
continue;
|
||||
if (hours <= 0) continue;
|
||||
|
||||
const shift_week_start = getWeekStart(shift.date);
|
||||
const key = shift_week_start.getTime();
|
||||
|
|
|
|||
|
|
@ -109,7 +109,7 @@ export class SickLeaveService {
|
|||
employee_id,
|
||||
},
|
||||
data: {
|
||||
sick_hours,
|
||||
sick_hours: { increment: sick_hours },
|
||||
last_updated,
|
||||
}
|
||||
})
|
||||
|
|
@ -129,7 +129,7 @@ export class SickLeaveService {
|
|||
|
||||
try {
|
||||
const result = await this.prisma.$transaction(async (tx) => {
|
||||
const employee = await this.prisma.employees.findUnique({
|
||||
const employee = await tx.employees.findUnique({
|
||||
where: { id: employee_id },
|
||||
select: {
|
||||
id: true,
|
||||
|
|
|
|||
|
|
@ -97,7 +97,7 @@ export class VacationService {
|
|||
} else {
|
||||
//update vacation_bank
|
||||
await tx.paidTimeOff.update({
|
||||
where: { employee_id: employee_id, vacation_hours: { gte: asked_hours } },
|
||||
where: { employee_id: employee_id },
|
||||
data: {
|
||||
vacation_hours: { decrement: asked_hours },
|
||||
last_updated: new Date(),
|
||||
|
|
|
|||
|
|
@ -1,8 +1,7 @@
|
|||
import { Body, Controller, Param, Post, Res, StreamableFile } from "@nestjs/common";
|
||||
import { Body, Controller, Param, Post, StreamableFile } from "@nestjs/common";
|
||||
import { CsvExportService } from "./services/csv-exports.service";
|
||||
import { ModuleAccessAllowed } from "src/common/decorators/modules-guard.decorators";
|
||||
import { Modules as ModulesEnum } from "prisma/postgres/generated/prisma/client/postgres/client";
|
||||
// import { Response } from "express";
|
||||
import { CsvGeneratorService } from "src/time-and-attendance/exports/services/csv-builder.service";
|
||||
import type { CsvFilters } from "src/time-and-attendance/exports/export-csv-options.dto";
|
||||
|
||||
|
|
@ -20,7 +19,6 @@ export class CsvExportController {
|
|||
@Param('year') year: number,
|
||||
@Param('period_no') period_no: number,
|
||||
@Body() filters: CsvFilters,
|
||||
// @Res() response: Response,
|
||||
) {
|
||||
const rows = await this.csvService.collectTransaction(year, period_no, filters);
|
||||
const buffer = this.generator.generateCsv(rows);
|
||||
|
|
@ -28,13 +26,6 @@ export class CsvExportController {
|
|||
return new StreamableFile(buffer, {
|
||||
type: 'text/csv',
|
||||
disposition: 'attachment; filename=export.csv'
|
||||
})
|
||||
|
||||
// response.set({
|
||||
// 'Content-Type': 'text/csv',
|
||||
// 'Content-Disposition': 'attachment; filename="export.csv"',
|
||||
// });
|
||||
|
||||
// response.send(blob);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
@ -3,6 +3,9 @@ import { HolidayService } from "src/time-and-attendance/domains/services/holiday
|
|||
import { CsvRow, InternalCsvRow } from "src/time-and-attendance/exports/export-csv-options.dto";
|
||||
|
||||
const REGULAR = 1;
|
||||
const EVENING = 140;
|
||||
const EMERGENCY = 48;
|
||||
const HOLIDAY = 104;
|
||||
const OVERTIME = 43;
|
||||
const VACATION = 109;
|
||||
const SICK = 105;
|
||||
|
|
@ -73,26 +76,46 @@ export const applyOvertimeRequalifications = (
|
|||
}
|
||||
|
||||
for (const [, rows] of grouped_rows) {
|
||||
const evening_hours = rows.find(r => r.code === EVENING);
|
||||
const emergency_hours = rows.find(r => r.code === EMERGENCY);
|
||||
const holiday_hours = rows.find(r => r.code === HOLIDAY);
|
||||
const regular_hours = rows.find(r => r.code === REGULAR);
|
||||
const vacation_hours = rows.find(r => r.code === VACATION);
|
||||
|
||||
// if no regular hours row, push as is
|
||||
if (!regular_hours?.quantite_hre) { result.push(...rows); continue; }
|
||||
|
||||
// calculate overtime directly from consolidated regular hours
|
||||
const overtime_hours = Math.max(0, regular_hours.quantite_hre - WEEKLY_LIMIT_HOURS);
|
||||
const total_hours = (
|
||||
regular_hours.quantite_hre
|
||||
+ (evening_hours?.quantite_hre ?? 0)
|
||||
+ (emergency_hours?.quantite_hre ?? 0)
|
||||
+ (holiday_hours?.quantite_hre ?? 0)
|
||||
+ (vacation_hours?.quantite_hre ?? 0)
|
||||
)
|
||||
// calculate overtime directly from consolidated hours
|
||||
const overtime_hours = Math.max(0, total_hours - WEEKLY_LIMIT_HOURS);
|
||||
|
||||
// if no overtime, push as is
|
||||
if (overtime_hours <= 0) { result.push(...rows); continue; }
|
||||
|
||||
// ensures that its not possible to deduct more hours than the amount of regular hours
|
||||
const deducted = Math.min(overtime_hours, regular_hours.quantite_hre);
|
||||
const remaining = regular_hours.quantite_hre - deducted;
|
||||
// ensures that its not possible to deduct more hours than the amount of regular or evening hours
|
||||
const deducted_regular = Math.min(overtime_hours, regular_hours.quantite_hre);
|
||||
const remaining_overtime = overtime_hours - deducted_regular;
|
||||
const deducted_evening = Math.min(remaining_overtime, evening_hours?.quantite_hre ?? 0);
|
||||
|
||||
const remaining_regular = (regular_hours.quantite_hre ?? 0) - deducted_regular;
|
||||
const remaining_evening = (evening_hours?.quantite_hre ?? 0) - deducted_evening;
|
||||
|
||||
for (const row of rows) {
|
||||
if (row === regular_hours) {
|
||||
// pushes the regular row with subtracted overtime hours, if enough hours remaining
|
||||
if (remaining > 0) {
|
||||
result.push({ ...regular_hours, quantite_hre: remaining });
|
||||
if (remaining_regular > 0) {
|
||||
result.push({ ...regular_hours, quantite_hre: remaining_regular });
|
||||
}
|
||||
} else if (row === evening_hours) {
|
||||
// pushes the evening row with subtracted overtime hours, if enough not enough regular hours remaining
|
||||
if (remaining_evening > 0) {
|
||||
result.push({ ...evening_hours, quantite_hre: remaining_evening });
|
||||
}
|
||||
} else {
|
||||
// other rows are left unchanged
|
||||
|
|
@ -100,12 +123,14 @@ export const applyOvertimeRequalifications = (
|
|||
}
|
||||
}
|
||||
//adds a new row with overtime hours deducted from the regular hours
|
||||
if (deducted_regular + deducted_evening > 0) {
|
||||
result.push({
|
||||
...regular_hours,
|
||||
code: OVERTIME,
|
||||
quantite_hre: deducted,
|
||||
quantite_hre: deducted_regular + deducted_evening,
|
||||
});
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ export class PaidTimeOffController {
|
|||
) { }
|
||||
|
||||
@Get('totals')
|
||||
@ModuleAccessAllowed('timesheets', 'timesheets_approval', 'employee_management')
|
||||
@ModuleAccessAllowed('timesheets')
|
||||
async getPaidTimeOffTotalsForOneEmployee(
|
||||
@Access('email') email: string,
|
||||
@Query('email') employee_email?: string,
|
||||
|
|
|
|||
|
|
@ -146,13 +146,7 @@ export class GetOverviewService {
|
|||
|
||||
switch (type) {
|
||||
case "EVENING":
|
||||
if (total_weekly_hours + hours <= 40) {
|
||||
record.other_hours.evening_hours += Math.min(hours, 8 - daily_hours);
|
||||
record.other_hours.overtime_hours += Math.max(daily_hours + hours - 8, 0);
|
||||
} else {
|
||||
record.other_hours.evening_hours += Math.max(40 - total_weekly_hours, 0);
|
||||
record.other_hours.overtime_hours += Math.min(total_weekly_hours + hours - 40, hours);
|
||||
}
|
||||
total_weekly_hours += hours;
|
||||
record.total_hours += hours;
|
||||
break;
|
||||
|
|
@ -169,12 +163,16 @@ export class GetOverviewService {
|
|||
record.total_hours += hours;
|
||||
total_weekly_hours += hours;
|
||||
break;
|
||||
case "VACATION": record.other_hours.vacation_hours += hours;
|
||||
case "VACATION":
|
||||
record.other_hours.vacation_hours += hours;
|
||||
total_weekly_hours += hours;
|
||||
break;
|
||||
case "REGULAR":
|
||||
if (total_weekly_hours + hours <= 40) {
|
||||
record.regular_hours += Math.min(hours, 8 - daily_hours);
|
||||
record.other_hours.overtime_hours += Math.max(daily_hours + hours - 8, 0);
|
||||
record.regular_hours += hours;
|
||||
// TODO: ADD DAILY OVERTIME CHECK HERE
|
||||
// record.regular_hours += Math.min(hours, 8 - daily_hours);
|
||||
// record.other_hours.overtime_hours += Math.max(daily_hours + hours - 8, 0);
|
||||
} else {
|
||||
record.regular_hours += Math.max(40 - total_weekly_hours, 0);
|
||||
record.other_hours.overtime_hours += Math.min(total_weekly_hours + hours - 40, hours);
|
||||
|
|
@ -192,9 +190,9 @@ export class GetOverviewService {
|
|||
record.expenses = Number((record.expenses + amount).toFixed(2));
|
||||
const type = (expense.bank_code?.type || "").toUpperCase();
|
||||
const rate = expense.bank_code?.modifier ?? 1;
|
||||
const mileage = Number(expense.mileage) / rate;
|
||||
const mileage = Number(expense.mileage);
|
||||
if (type === "MILEAGE" && rate > 0) {
|
||||
record.mileage = Number((record.mileage += Math.round(mileage)).toFixed(2));
|
||||
record.mileage = Number((record.mileage += mileage).toFixed(2));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
import { NUMBER_OF_TIMESHEETS_TO_RETURN } from "src/common/utils/constants.utils";
|
||||
import { Injectable } from "@nestjs/common";
|
||||
import { PrismaPostgresService } from "prisma/postgres/prisma-postgres.service";
|
||||
|
|
@ -56,16 +55,28 @@ export class GetTimesheetsOverviewService {
|
|||
//find user infos using the employee_id
|
||||
const employee = await this.prisma.employees.findUnique({
|
||||
where: { id: employee_id.data },
|
||||
select: { daily_expected_hours: true, schedule_preset: true, user: true },
|
||||
select: { schedule_preset: true, user: true, id: true }
|
||||
});
|
||||
if (!employee) return { success: false, error: `EMPLOYEE_NOT_FOUND` }
|
||||
if (!employee) return { success: false, error: `EMPLOYEE_NOT_FOUND` };
|
||||
if (!employee.user) return { success: false, error: 'USER_NOT_FOUND' };
|
||||
|
||||
const contractDetails = await this.prisma.contracts.findUnique({
|
||||
where: { employee_id: employee.id },
|
||||
select: {
|
||||
daily_expected_hours: true,
|
||||
applicable_overtime: true,
|
||||
phone_allocation: true,
|
||||
on_call_allocation: true,
|
||||
weekend_on_call_allocation: true,
|
||||
}
|
||||
});
|
||||
if (!contractDetails) return { success: false, error: 'CONTRACT_NOT_FOUND' };
|
||||
|
||||
//builds employee details
|
||||
const has_preset_schedule = employee.schedule_preset !== null;
|
||||
const user = employee.user;
|
||||
const employee_fullname = `${user.first_name} ${user.last_name}`.trim();
|
||||
|
||||
|
||||
//maps all timesheet's infos
|
||||
const timesheets = await Promise.all(rows.map((timesheet) => mapOneTimesheet(timesheet)));
|
||||
if (!timesheets) return { success: false, error: 'INVALID_TIMESHEET' }
|
||||
|
|
@ -73,7 +84,13 @@ export class GetTimesheetsOverviewService {
|
|||
const data: Timesheets = {
|
||||
has_preset_schedule,
|
||||
employee_fullname,
|
||||
daily_expected_hours: employee.daily_expected_hours,
|
||||
contract: {
|
||||
daily_expected_hours: contractDetails.daily_expected_hours,
|
||||
applicable_overtime: contractDetails.applicable_overtime,
|
||||
phone_allocation: Number(contractDetails.phone_allocation),
|
||||
on_call_allocation: Number(contractDetails.on_call_allocation),
|
||||
weekend_on_call_allocation: Number(contractDetails.weekend_on_call_allocation),
|
||||
},
|
||||
timesheets,
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import { Type } from "class-transformer";
|
||||
import { IsBoolean, IsDate, IsInt, IsOptional, IsString } from "class-validator";
|
||||
import { IsArray, IsBoolean, IsDate, IsInt, IsOptional, IsString } from "class-validator";
|
||||
|
||||
export class TimesheetEntity {
|
||||
@IsInt() id: number;
|
||||
|
|
@ -11,10 +11,19 @@ export class TimesheetEntity {
|
|||
export class Timesheets {
|
||||
@IsBoolean() has_preset_schedule: boolean;
|
||||
@IsString() employee_fullname: string;
|
||||
@IsInt() daily_expected_hours: number;
|
||||
@Type(() => Contract) contract: Contract;
|
||||
@Type(() => Number)
|
||||
@Type(() => Timesheet) timesheets: Timesheet[];
|
||||
}
|
||||
|
||||
export class Contract {
|
||||
@Type(() => Number) daily_expected_hours: number;
|
||||
@Type(() => Number) phone_allocation: number;
|
||||
@Type(() => Number) on_call_allocation: number;
|
||||
@Type(() => Number) weekend_on_call_allocation: number;
|
||||
@IsArray() @IsString() applicable_overtime: string[];
|
||||
}
|
||||
|
||||
export class Timesheet {
|
||||
@IsInt() timesheet_id: number;
|
||||
@IsBoolean() is_approved: boolean;
|
||||
|
|
|
|||
|
|
@ -82,6 +82,7 @@ export const mapOneTimesheet = (
|
|||
weekly_hours[subgroup] += hours;
|
||||
}
|
||||
|
||||
// TODO: ADD DAILY OVERTIME CHECK HERE
|
||||
// const dailyOvertimeOwed = Math.max(daily_hours.regular - timesheet.employee.daily_expected_hours, 0)
|
||||
// daily_hours.overtime = dailyOvertimeOwed;
|
||||
// daily_hours.regular -= dailyOvertimeOwed;
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user