Compare commits
No commits in common. "9999dff6cea6217ad5bb997501c5bbbdd0070eb5" and "9143d1a79e25c4827f2f784297000951a3e5a09e" have entirely different histories.
9999dff6ce
...
9143d1a79e
4
.gitignore
vendored
4
.gitignore
vendored
|
|
@ -55,5 +55,9 @@ 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,11 +37,6 @@ export type userModuleAccess = Prisma.userModuleAccessModel
|
|||
*
|
||||
*/
|
||||
export type Employees = Prisma.EmployeesModel
|
||||
/**
|
||||
* Model Contracts
|
||||
*
|
||||
*/
|
||||
export type Contracts = Prisma.ContractsModel
|
||||
/**
|
||||
* Model LeaveRequests
|
||||
*
|
||||
|
|
|
|||
|
|
@ -57,11 +57,6 @@ export type userModuleAccess = Prisma.userModuleAccessModel
|
|||
*
|
||||
*/
|
||||
export type Employees = Prisma.EmployeesModel
|
||||
/**
|
||||
* Model Contracts
|
||||
*
|
||||
*/
|
||||
export type Contracts = Prisma.ContractsModel
|
||||
/**
|
||||
* Model LeaveRequests
|
||||
*
|
||||
|
|
|
|||
|
|
@ -314,33 +314,6 @@ 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>
|
||||
|
|
@ -459,6 +432,33 @@ 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,33 +743,6 @@ 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>
|
||||
|
|
@ -877,4 +850,31 @@ 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,7 +388,6 @@ export const ModelName = {
|
|||
Notifications: 'Notifications',
|
||||
userModuleAccess: 'userModuleAccess',
|
||||
Employees: 'Employees',
|
||||
Contracts: 'Contracts',
|
||||
LeaveRequests: 'LeaveRequests',
|
||||
LeaveRequestsArchive: 'LeaveRequestsArchive',
|
||||
Timesheets: 'Timesheets',
|
||||
|
|
@ -420,7 +419,7 @@ export type TypeMap<ExtArgs extends runtime.Types.Extensions.InternalArgs = runt
|
|||
omit: GlobalOmitOptions
|
||||
}
|
||||
meta: {
|
||||
modelProps: "users" | "notifications" | "userModuleAccess" | "employees" | "contracts" | "leaveRequests" | "leaveRequestsArchive" | "timesheets" | "timesheetsArchive" | "schedulePresets" | "schedulePresetShifts" | "shifts" | "shiftsArchive" | "bankCodes" | "expenses" | "expensesArchive" | "oAuthSessions" | "sessions" | "preferences" | "paidTimeOff" | "payPeriods"
|
||||
modelProps: "users" | "notifications" | "userModuleAccess" | "employees" | "leaveRequests" | "leaveRequestsArchive" | "timesheets" | "timesheetsArchive" | "schedulePresets" | "schedulePresetShifts" | "shifts" | "shiftsArchive" | "bankCodes" | "expenses" | "expensesArchive" | "oAuthSessions" | "sessions" | "preferences" | "paidTimeOff" | "payPeriods"
|
||||
txIsolationLevel: TransactionIsolationLevel
|
||||
}
|
||||
model: {
|
||||
|
|
@ -720,80 +719,6 @@ 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
|
||||
|
|
@ -2022,30 +1947,19 @@ 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',
|
||||
|
|
@ -2412,20 +2326,6 @@ 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'
|
||||
*/
|
||||
|
|
@ -2454,6 +2354,20 @@ 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'
|
||||
*/
|
||||
|
|
@ -2580,7 +2494,6 @@ 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,7 +55,6 @@ export const ModelName = {
|
|||
Notifications: 'Notifications',
|
||||
userModuleAccess: 'userModuleAccess',
|
||||
Employees: 'Employees',
|
||||
Contracts: 'Contracts',
|
||||
LeaveRequests: 'LeaveRequests',
|
||||
LeaveRequestsArchive: 'LeaveRequestsArchive',
|
||||
Timesheets: 'Timesheets',
|
||||
|
|
@ -139,30 +138,19 @@ 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,7 +12,6 @@ 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'
|
||||
|
|
|
|||
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,6 +431,14 @@ 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
|
||||
|
|
|
|||
|
|
@ -9,14 +9,13 @@ datasource db {
|
|||
}
|
||||
|
||||
model Users {
|
||||
id String @id @default(dbgenerated("gen_random_uuid()")) @db.Uuid
|
||||
first_name String
|
||||
last_name String
|
||||
email String @unique
|
||||
phone_number String
|
||||
residence String?
|
||||
role Roles @default(EMPLOYEE)
|
||||
|
||||
id String @id @default(dbgenerated("gen_random_uuid()")) @db.Uuid
|
||||
first_name String
|
||||
last_name String
|
||||
email String @unique
|
||||
phone_number String
|
||||
residence String?
|
||||
role Roles @default(EMPLOYEE)
|
||||
notifications Notifications? @relation("UserNotification")
|
||||
employee Employees? @relation("UserEmployee")
|
||||
oauth_sessions OAuthSessions[] @relation("UserOAuthSessions")
|
||||
|
|
@ -35,8 +34,7 @@ model Notifications {
|
|||
metadata Json @db.JsonB
|
||||
created_at DateTime @default(now())
|
||||
viewed_at DateTime?
|
||||
|
||||
user Users @relation("UserNotification", fields: [user_id], references: [id])
|
||||
user Users @relation("UserNotification", fields: [user_id], references: [id])
|
||||
|
||||
@@map("notifications")
|
||||
}
|
||||
|
|
@ -53,64 +51,48 @@ model userModuleAccess {
|
|||
chatbot Boolean @default(false)
|
||||
ticket Boolean @default(false)
|
||||
ticket_management Boolean @default(false)
|
||||
|
||||
user Users @relation("UserModuleAccess", fields: [user_id], references: [id])
|
||||
user Users @relation("UserModuleAccess", fields: [user_id], references: [id])
|
||||
|
||||
@@map("user_module_access")
|
||||
}
|
||||
|
||||
model Employees {
|
||||
id Int @id @default(autoincrement())
|
||||
user_id String @unique @db.Uuid
|
||||
external_payroll_id Int
|
||||
company_code Int
|
||||
first_work_day DateTime @db.Date
|
||||
last_work_day DateTime? @db.Date
|
||||
supervisor_id Int?
|
||||
job_title String?
|
||||
is_supervisor Boolean @default(false)
|
||||
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")
|
||||
user Users @relation("UserEmployee", fields: [user_id], references: [id])
|
||||
leave_request LeaveRequests[] @relation("LeaveRequestEmployee")
|
||||
timesheet Timesheets[] @relation("TimesheetEmployee")
|
||||
paid_time_off PaidTimeOff? @relation("EmployeePaidTimeOff")
|
||||
contracts Contracts? @relation("EmployeeContract")
|
||||
id Int @id @default(autoincrement())
|
||||
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")
|
||||
user Users @relation("UserEmployee", fields: [user_id], references: [id])
|
||||
leave_request LeaveRequests[] @relation("LeaveRequestEmployee")
|
||||
timesheet Timesheets[] @relation("TimesheetEmployee")
|
||||
paid_time_off PaidTimeOff? @relation("EmployeePaidTimeOff")
|
||||
|
||||
@@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())
|
||||
id Int @id @default(autoincrement())
|
||||
employee_id Int
|
||||
leave_type LeaveTypes
|
||||
comment String
|
||||
approval_status LeaveApprovalStatus @default(PENDING)
|
||||
approval_status LeaveApprovalStatus @default(PENDING)
|
||||
bank_code_id Int
|
||||
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")
|
||||
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")
|
||||
|
||||
@@unique([employee_id, leave_type, dates], name: "leave_per_employee_date")
|
||||
@@index([employee_id, dates])
|
||||
|
|
@ -128,24 +110,22 @@ 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])
|
||||
leave_request LeaveRequests @relation("LeaveRequestToArchive", fields: [leave_request_id], references: [id])
|
||||
|
||||
@@index([employee_id, date])
|
||||
@@map("leave_requests_archive")
|
||||
}
|
||||
|
||||
model Timesheets {
|
||||
id Int @id @default(autoincrement())
|
||||
id Int @id @default(autoincrement())
|
||||
employee_id Int
|
||||
is_approved Boolean @default(false)
|
||||
start_date DateTime @db.Date
|
||||
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])
|
||||
archive TimesheetsArchive[] @relation("TimesheetsToArchive")
|
||||
expense Expenses[] @relation("ExpensesTimesheet")
|
||||
shift Shifts[] @relation("ShiftTimesheet")
|
||||
employee Employees @relation("TimesheetEmployee", fields: [employee_id], references: [id])
|
||||
archive TimesheetsArchive[] @relation("TimesheetsToArchive")
|
||||
|
||||
// @@unique([employee_id, start_date], name: "employee_id_start_date")
|
||||
@@map("timesheets")
|
||||
|
|
|
|||
|
|
@ -1,16 +0,0 @@
|
|||
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);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,12 +0,0 @@
|
|||
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;
|
||||
}
|
||||
|
|
@ -1,12 +0,0 @@
|
|||
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 { }
|
||||
|
|
@ -1,43 +0,0 @@
|
|||
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,7 +2,6 @@ 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;
|
||||
|
|
@ -15,13 +14,13 @@ 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[];
|
||||
@IsInt() @IsOptional() preset_id?: number;
|
||||
@IsInt() @IsOptional() preset_id?: number;
|
||||
}
|
||||
|
||||
export class EmployeeDetailedUpsertDto {
|
||||
|
|
@ -35,13 +34,13 @@ 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[];
|
||||
@IsInt() @IsOptional() preset_id?: number;
|
||||
@IsInt() @IsOptional() preset_id?: number;
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -75,26 +74,9 @@ export type EmployeeWithDetails = Prisma.EmployeesGetPayload<{
|
|||
first_work_day: true,
|
||||
last_work_day: true,
|
||||
external_payroll_id: true,
|
||||
paid_time_off: {
|
||||
select: {
|
||||
id: true,
|
||||
employee_id: true,
|
||||
sick_hours: true,
|
||||
vacation_hours: true,
|
||||
banked_hours: true,
|
||||
last_updated: true,
|
||||
},
|
||||
},
|
||||
paid_time_off: 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,
|
||||
},
|
||||
},
|
||||
daily_expected_hours: true,
|
||||
schedule_preset_id: true,
|
||||
schedule_preset: { select: { id: true } }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -44,20 +44,13 @@ 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,16 +37,8 @@ export class EmployeesGetService {
|
|||
},
|
||||
},
|
||||
},
|
||||
contracts: {
|
||||
select: {
|
||||
daily_expected_hours: true,
|
||||
applicable_overtime: true,
|
||||
on_call_allocation: true,
|
||||
weekend_on_call_allocation: true,
|
||||
phone_allocation: true,
|
||||
},
|
||||
},
|
||||
is_supervisor: true,
|
||||
daily_expected_hours: true,
|
||||
job_title: true,
|
||||
company_code: true,
|
||||
external_payroll_id: true,
|
||||
|
|
@ -55,33 +47,23 @@ export class EmployeesGetService {
|
|||
schedule_preset_id: true,
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
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 ?? '',
|
||||
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,
|
||||
supervisor_full_name: `${r.supervisor?.user.first_name} ${r.supervisor?.user.last_name}`,
|
||||
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: employeeDetailedList };
|
||||
}).then(rows => rows.map(r => ({
|
||||
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,
|
||||
external_payroll_id: r.external_payroll_id,
|
||||
employee_full_name: `${r.user.first_name} ${r.user.last_name}`,
|
||||
is_supervisor: r.is_supervisor,
|
||||
supervisor_full_name: `${r.supervisor?.user.first_name} ${r.supervisor?.user.last_name}`,
|
||||
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 };
|
||||
};
|
||||
|
||||
async findOwnProfile(email: string): Promise<Result<Partial<EmployeeDetailedDto>, string>> {
|
||||
|
|
@ -107,11 +89,7 @@ export class EmployeesGetService {
|
|||
paid_time_off: true,
|
||||
is_supervisor: true,
|
||||
schedule_preset_id: true,
|
||||
contracts: {
|
||||
select: {
|
||||
daily_expected_hours: true,
|
||||
},
|
||||
},
|
||||
daily_expected_hours: true,
|
||||
supervisor: {
|
||||
select: {
|
||||
id: true, user: {
|
||||
|
|
@ -125,7 +103,6 @@ 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);
|
||||
|
||||
|
|
@ -136,9 +113,7 @@ 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,
|
||||
contract: {
|
||||
daily_expected_hours: existing_profile.contracts?.daily_expected_hours ?? 24,
|
||||
},
|
||||
daily_expected_hours: existing_profile.daily_expected_hours,
|
||||
job_title: existing_profile.job_title ?? '',
|
||||
external_payroll_id: existing_profile.external_payroll_id,
|
||||
paid_time_off: {
|
||||
|
|
@ -195,11 +170,6 @@ export class EmployeesGetService {
|
|||
},
|
||||
},
|
||||
},
|
||||
contracts: {
|
||||
select: {
|
||||
daily_expected_hours: true,
|
||||
}
|
||||
},
|
||||
job_title: true,
|
||||
company_code: true,
|
||||
first_work_day: true,
|
||||
|
|
@ -207,6 +177,7 @@ 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: {
|
||||
|
|
@ -225,36 +196,35 @@ export class EmployeesGetService {
|
|||
|
||||
const company_name = toStringFromCompanyCode(employee.company_code);
|
||||
|
||||
const detailed_employee: EmployeeDetailedDto = {
|
||||
first_name: employee.user.first_name,
|
||||
last_name: employee.user.last_name,
|
||||
email: employee.user.email,
|
||||
residence: employee.user.residence ?? '',
|
||||
phone_number: employee.user.phone_number,
|
||||
company_name: company_name,
|
||||
is_supervisor: employee.is_supervisor ?? false,
|
||||
job_title: employee.job_title ?? '',
|
||||
external_payroll_id: employee.external_payroll_id,
|
||||
paid_time_off: {
|
||||
id: employee.paid_time_off?.id ?? -1,
|
||||
employee_id: employee.paid_time_off?.employee_id ?? -1,
|
||||
sick_hours: employee.paid_time_off?.sick_hours.toNumber() ?? 0,
|
||||
vacation_hours: employee.paid_time_off?.vacation_hours.toNumber() ?? 0,
|
||||
banked_hours: employee.paid_time_off?.banked_hours.toNumber() ?? 0,
|
||||
last_updated: employee.paid_time_off?.last_updated?.toISOString() ?? null,
|
||||
return {
|
||||
success: true,
|
||||
data: {
|
||||
first_name: employee.user.first_name,
|
||||
last_name: employee.user.last_name,
|
||||
email: employee.user.email,
|
||||
residence: employee.user.residence ?? '',
|
||||
phone_number: employee.user.phone_number,
|
||||
company_name: company_name,
|
||||
is_supervisor: employee.is_supervisor ?? false,
|
||||
job_title: employee.job_title ?? '',
|
||||
external_payroll_id: employee.external_payroll_id,
|
||||
paid_time_off: {
|
||||
id: employee.paid_time_off?.id ?? -1,
|
||||
employee_id: employee.paid_time_off?.employee_id ?? -1,
|
||||
sick_hours: employee.paid_time_off?.sick_hours.toNumber() ?? 0,
|
||||
vacation_hours: employee.paid_time_off?.vacation_hours.toNumber() ?? 0,
|
||||
banked_hours: employee.paid_time_off?.banked_hours.toNumber() ?? 0,
|
||||
last_updated: employee.paid_time_off?.last_updated?.toISOString() ?? null,
|
||||
},
|
||||
employee_full_name: `${employee.user.first_name} ${employee.user.last_name}`,
|
||||
first_work_day: toStringFromDate(employee.first_work_day),
|
||||
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,
|
||||
},
|
||||
employee_full_name: `${employee.user.first_name} ${employee.user.last_name}`,
|
||||
first_work_day: toStringFromDate(employee.first_work_day),
|
||||
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,
|
||||
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,21 +98,13 @@ 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,
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -1 +0,0 @@
|
|||
GET http://localhost:3000/contracts/details/matthieuh@targointernet.com
|
||||
|
|
@ -1 +0,0 @@
|
|||
GET http://localhost:3000/employees/employee-list
|
||||
|
|
@ -17,8 +17,6 @@ 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: [
|
||||
|
|
@ -30,7 +28,6 @@ import { ContractService } from "src/identity-and-account/contract/services/cont
|
|||
],
|
||||
controllers: [
|
||||
EmployeesController,
|
||||
ContractController,
|
||||
PreferencesController,
|
||||
ModuleAccessController,
|
||||
HomePageController,
|
||||
|
|
@ -45,7 +42,6 @@ import { ContractService } from "src/identity-and-account/contract/services/cont
|
|||
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: process.env.SESSION_SECRET || 'dev-only-secret-change-in-production',
|
||||
secret: 'This is a super secret dev secret that you cant share with anyone',
|
||||
resave: false,
|
||||
saveUninitialized: false,
|
||||
rolling: true,
|
||||
|
|
@ -39,27 +39,9 @@ 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: true, // allow all origins in dev
|
||||
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'],
|
||||
credentials: true,
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ export class BankedHoursService {
|
|||
|
||||
try {
|
||||
const result = await this.prisma.$transaction(async (tx) => {
|
||||
const employee = await tx.employees.findUnique({
|
||||
const employee = await this.prisma.employees.findUnique({
|
||||
where: { id: employee_id },
|
||||
select: {
|
||||
id: true,
|
||||
|
|
|
|||
|
|
@ -30,16 +30,23 @@ export class HolidayService {
|
|||
holiday_date: Date
|
||||
): Promise<Result<number, string>> {
|
||||
try {
|
||||
const valid_codes = ['G1', 'G43', 'G48', 'G104', 'G105', 'G109', 'G140', 'G720'];
|
||||
const valid_codes = ['G1', 'G43', 'G140', 'G104', 'G105', 'G305', 'G700', '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 }
|
||||
where: {
|
||||
external_payroll_id,
|
||||
company_code,
|
||||
},
|
||||
select: {
|
||||
id: true,
|
||||
}
|
||||
});
|
||||
|
||||
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: {
|
||||
|
|
@ -54,7 +61,8 @@ 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: { increment: sick_hours },
|
||||
sick_hours,
|
||||
last_updated,
|
||||
}
|
||||
})
|
||||
|
|
@ -129,7 +129,7 @@ export class SickLeaveService {
|
|||
|
||||
try {
|
||||
const result = await this.prisma.$transaction(async (tx) => {
|
||||
const employee = await tx.employees.findUnique({
|
||||
const employee = await this.prisma.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 },
|
||||
where: { employee_id: employee_id, vacation_hours: { gte: asked_hours } },
|
||||
data: {
|
||||
vacation_hours: { decrement: asked_hours },
|
||||
last_updated: new Date(),
|
||||
|
|
|
|||
|
|
@ -1,7 +1,8 @@
|
|||
import { Body, Controller, Param, Post, StreamableFile } from "@nestjs/common";
|
||||
import { Body, Controller, Param, Post, Res, 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";
|
||||
|
||||
|
|
@ -19,6 +20,7 @@ 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);
|
||||
|
|
@ -26,6 +28,13 @@ 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,9 +3,6 @@ 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;
|
||||
|
|
@ -76,46 +73,26 @@ 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; }
|
||||
|
||||
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);
|
||||
// calculate overtime directly from consolidated regular hours
|
||||
const overtime_hours = Math.max(0, regular_hours.quantite_hre - 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 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;
|
||||
// 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;
|
||||
|
||||
for (const row of rows) {
|
||||
if (row === regular_hours) {
|
||||
// pushes the regular row with subtracted overtime hours, if enough hours 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 });
|
||||
if (remaining > 0) {
|
||||
result.push({ ...regular_hours, quantite_hre: remaining });
|
||||
}
|
||||
} else {
|
||||
// other rows are left unchanged
|
||||
|
|
@ -123,13 +100,11 @@ 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_regular + deducted_evening,
|
||||
});
|
||||
}
|
||||
result.push({
|
||||
...regular_hours,
|
||||
code: OVERTIME,
|
||||
quantite_hre: deducted,
|
||||
});
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ export class PaidTimeOffController {
|
|||
) { }
|
||||
|
||||
@Get('totals')
|
||||
@ModuleAccessAllowed('timesheets')
|
||||
@ModuleAccessAllowed('timesheets', 'timesheets_approval', 'employee_management')
|
||||
async getPaidTimeOffTotalsForOneEmployee(
|
||||
@Access('email') email: string,
|
||||
@Query('email') employee_email?: string,
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ export class GetOverviewService {
|
|||
) { }
|
||||
|
||||
async getOverviewByYearPeriod(
|
||||
pay_year: number,
|
||||
pay_year: number,
|
||||
period_no: number
|
||||
): Promise<Result<PayPeriodOverviewDto, string>> {
|
||||
const period = computePeriod(pay_year, period_no);
|
||||
|
|
@ -110,9 +110,9 @@ export class GetOverviewService {
|
|||
}
|
||||
|
||||
const ensure = (
|
||||
id: number,
|
||||
first_name: string,
|
||||
last_name: string,
|
||||
id: number,
|
||||
first_name: string,
|
||||
last_name: string,
|
||||
email: string
|
||||
) => {
|
||||
if (!by_employee.has(id)) {
|
||||
|
|
@ -146,7 +146,13 @@ export class GetOverviewService {
|
|||
|
||||
switch (type) {
|
||||
case "EVENING":
|
||||
record.other_hours.evening_hours += Math.min(hours, 8 - daily_hours);
|
||||
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;
|
||||
|
|
@ -163,16 +169,12 @@ export class GetOverviewService {
|
|||
record.total_hours += hours;
|
||||
total_weekly_hours += hours;
|
||||
break;
|
||||
case "VACATION":
|
||||
record.other_hours.vacation_hours += hours;
|
||||
total_weekly_hours += hours;
|
||||
case "VACATION": record.other_hours.vacation_hours += hours;
|
||||
break;
|
||||
case "REGULAR":
|
||||
if (total_weekly_hours + hours <= 40) {
|
||||
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);
|
||||
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);
|
||||
|
|
@ -190,9 +192,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);
|
||||
const mileage = Number(expense.mileage) / rate;
|
||||
if (type === "MILEAGE" && rate > 0) {
|
||||
record.mileage = Number((record.mileage += mileage).toFixed(2));
|
||||
record.mileage = Number((record.mileage += Math.round(mileage)).toFixed(2));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -211,7 +213,7 @@ export class GetOverviewService {
|
|||
|
||||
if (timesheets.length > 0)
|
||||
record.is_approved = timesheets.every(timesheet => timesheet.is_approved);
|
||||
|
||||
|
||||
record.is_active = is_active;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
|
||||
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";
|
||||
|
|
@ -15,9 +16,9 @@ export class GetTimesheetsOverviewService {
|
|||
) { }
|
||||
|
||||
async getTimesheetsForEmployeeByPeriod(
|
||||
email: string,
|
||||
pay_year: number,
|
||||
pay_period_no: number,
|
||||
email: string,
|
||||
pay_year: number,
|
||||
pay_period_no: number,
|
||||
employee_email?: string
|
||||
): Promise<Result<Timesheets, string>> {
|
||||
try {
|
||||
|
|
@ -55,28 +56,16 @@ export class GetTimesheetsOverviewService {
|
|||
//find user infos using the employee_id
|
||||
const employee = await this.prisma.employees.findUnique({
|
||||
where: { id: employee_id.data },
|
||||
select: { schedule_preset: true, user: true, id: true }
|
||||
select: { daily_expected_hours: true, schedule_preset: true, user: true },
|
||||
});
|
||||
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' };
|
||||
if (!employee) return { success: false, error: `EMPLOYEE_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' }
|
||||
|
|
@ -84,13 +73,7 @@ export class GetTimesheetsOverviewService {
|
|||
const data: Timesheets = {
|
||||
has_preset_schedule,
|
||||
employee_fullname,
|
||||
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),
|
||||
},
|
||||
daily_expected_hours: employee.daily_expected_hours,
|
||||
timesheets,
|
||||
}
|
||||
|
||||
|
|
@ -102,8 +85,8 @@ export class GetTimesheetsOverviewService {
|
|||
}
|
||||
|
||||
private async loadTimesheets(
|
||||
employee_id: number,
|
||||
period_start: Date,
|
||||
employee_id: number,
|
||||
period_start: Date,
|
||||
period_end: Date
|
||||
) {
|
||||
return this.prisma.timesheets.findMany({
|
||||
|
|
@ -118,7 +101,7 @@ export class GetTimesheetsOverviewService {
|
|||
}
|
||||
|
||||
private ensureTimesheet = async (
|
||||
employee_id: number,
|
||||
employee_id: number,
|
||||
start_date: Date | string
|
||||
) => {
|
||||
const start = toDateFromString(start_date);
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import { Type } from "class-transformer";
|
||||
import { IsArray, IsBoolean, IsDate, IsInt, IsOptional, IsString } from "class-validator";
|
||||
import { IsBoolean, IsDate, IsInt, IsOptional, IsString } from "class-validator";
|
||||
|
||||
export class TimesheetEntity {
|
||||
@IsInt() id: number;
|
||||
|
|
@ -11,19 +11,10 @@ export class TimesheetEntity {
|
|||
export class Timesheets {
|
||||
@IsBoolean() has_preset_schedule: boolean;
|
||||
@IsString() employee_fullname: string;
|
||||
@Type(() => Contract) contract: Contract;
|
||||
@Type(() => Number)
|
||||
@IsInt() daily_expected_hours: 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,7 +82,6 @@ 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