clean(shifts): clean module of unused features
This commit is contained in:
parent
efc06b8857
commit
eb166dbc46
|
|
@ -1,6 +1,5 @@
|
||||||
import { BadRequestException, Body, Controller, Delete, Param, Patch, Post, Req } from "@nestjs/common";
|
import { BadRequestException, Body, Controller, Delete, Param, Patch, Post, Req } from "@nestjs/common";
|
||||||
import { ShiftDto } from "src/time-and-attendance/time-tracker/shifts/dtos/shift-create.dto";
|
import { ShiftDto } from "src/time-and-attendance/time-tracker/shifts/dtos/shift-create.dto";
|
||||||
import { UpdateShiftDto } from "src/time-and-attendance/time-tracker/shifts/dtos/shift-update.dto";
|
|
||||||
import { ShiftsUpsertService } from "src/time-and-attendance/time-tracker/shifts/services/shifts-upsert.service";
|
import { ShiftsUpsertService } from "src/time-and-attendance/time-tracker/shifts/services/shifts-upsert.service";
|
||||||
import { CreateShiftResult, UpdateShiftResult } from "src/time-and-attendance/utils/type.utils";
|
import { CreateShiftResult, UpdateShiftResult } from "src/time-and-attendance/utils/type.utils";
|
||||||
import { RolesAllowed } from "src/common/decorators/roles.decorators";
|
import { RolesAllowed } from "src/common/decorators/roles.decorators";
|
||||||
|
|
|
||||||
|
|
@ -1,11 +0,0 @@
|
||||||
import { PartialType, OmitType } from "@nestjs/swagger";
|
|
||||||
import { IsInt } from "class-validator";
|
|
||||||
import { ShiftDto } from "src/time-and-attendance/time-tracker/shifts/dtos/shift-create.dto";
|
|
||||||
|
|
||||||
export class UpdateShiftDto extends PartialType(
|
|
||||||
// allows update using ShiftDto and preventing OmitType variables to be modified
|
|
||||||
OmitType(ShiftDto, ['is_approved', 'timesheet_id'] as const),
|
|
||||||
) {
|
|
||||||
@IsInt()
|
|
||||||
shift_id!: number;
|
|
||||||
}
|
|
||||||
|
|
@ -8,7 +8,6 @@ import { PrismaService } from "src/prisma/prisma.service";
|
||||||
import { GetShiftDto } from "src/time-and-attendance/time-tracker/shifts/dtos/shift-get.dto";
|
import { GetShiftDto } from "src/time-and-attendance/time-tracker/shifts/dtos/shift-get.dto";
|
||||||
import { ShiftEntity } from "src/time-and-attendance/time-tracker/shifts/dtos/shift-payload.dto";
|
import { ShiftEntity } from "src/time-and-attendance/time-tracker/shifts/dtos/shift-payload.dto";
|
||||||
import { ShiftDto } from "src/time-and-attendance/time-tracker/shifts/dtos/shift-create.dto";
|
import { ShiftDto } from "src/time-and-attendance/time-tracker/shifts/dtos/shift-create.dto";
|
||||||
import { response } from "express";
|
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class ShiftsUpsertService {
|
export class ShiftsUpsertService {
|
||||||
|
|
@ -226,7 +225,7 @@ export class ShiftsUpsertService {
|
||||||
is_approved: false,
|
is_approved: false,
|
||||||
comment: row.comment ?? undefined,
|
comment: row.comment ?? undefined,
|
||||||
};
|
};
|
||||||
results[index] = { ok: true, data: { shift } };
|
results[index] = { ok: true, data: shift };
|
||||||
}
|
}
|
||||||
|
|
||||||
return results;
|
return results;
|
||||||
|
|
@ -341,19 +340,18 @@ export class ShiftsUpsertService {
|
||||||
{ start: planned.normed.start_time, end: planned.normed.end_time, date: planned.normed.date })
|
{ start: planned.normed.start_time, end: planned.normed.end_time, date: planned.normed.date })
|
||||||
);
|
);
|
||||||
if (conflict) {
|
if (conflict) {
|
||||||
return updates.map(exist =>
|
return updates.map(exist => exist.id === planned.exist_shift.id
|
||||||
exist.id === planned.exist_shift.id
|
? ({
|
||||||
? ({
|
ok: false, id: exist.id, error: {
|
||||||
ok: false, id: exist.id, error: {
|
error_code: 'SHIFT_OVERLAP',
|
||||||
error_code: 'SHIFT_OVERLAP',
|
conflicts: {
|
||||||
conflicts: {
|
start_time: toStringFromHHmm(conflict.start),
|
||||||
start_time: toStringFromHHmm(conflict.start),
|
end_time: toStringFromHHmm(conflict.end),
|
||||||
end_time: toStringFromHHmm(conflict.end),
|
date: toStringFromDate(conflict.date),
|
||||||
date: toStringFromDate(conflict.date),
|
},
|
||||||
},
|
}
|
||||||
}
|
} as UpdateShiftResult)
|
||||||
} as UpdateShiftResult)
|
: ({ ok: false, id: exist.id, error: new BadRequestException('Batch aborted due to overlap in another update') })
|
||||||
: ({ ok: false, id: exist.id, error: new BadRequestException('Batch aborted due to overlap in another update') })
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -424,7 +422,7 @@ export class ShiftsUpsertService {
|
||||||
comment: row.comment ?? undefined,
|
comment: row.comment ?? undefined,
|
||||||
};
|
};
|
||||||
|
|
||||||
results.push({ ok: true, id: planned.exist_shift.id, data: { shift: dto } });
|
results.push({ ok: true, id: planned.exist_shift.id, data: dto });
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
throw new BadRequestException('INVALID_SHIFT');
|
throw new BadRequestException('INVALID_SHIFT');
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,14 +1,11 @@
|
||||||
|
|
||||||
import { BusinessLogicsModule } from 'src/time-and-attendance/domains/business-logics.module';
|
|
||||||
import { Module } from '@nestjs/common';
|
import { Module } from '@nestjs/common';
|
||||||
import { ShiftController } from 'src/time-and-attendance/time-tracker/shifts/controllers/shift.controller';
|
import { ShiftController } from 'src/time-and-attendance/time-tracker/shifts/controllers/shift.controller';
|
||||||
import { ShiftsGetService } from 'src/time-and-attendance/time-tracker/shifts/services/shifts-get.service';
|
|
||||||
import { ShiftsUpsertService } from 'src/time-and-attendance/time-tracker/shifts/services/shifts-upsert.service';
|
import { ShiftsUpsertService } from 'src/time-and-attendance/time-tracker/shifts/services/shifts-upsert.service';
|
||||||
|
|
||||||
@Module({
|
@Module({
|
||||||
imports: [ BusinessLogicsModule ],
|
|
||||||
controllers: [ShiftController],
|
controllers: [ShiftController],
|
||||||
providers: [ ShiftsGetService, ShiftsUpsertService ],
|
providers: [ ShiftsUpsertService ],
|
||||||
exports: [ ShiftsUpsertService ],
|
exports: [ ShiftsUpsertService ],
|
||||||
})
|
})
|
||||||
export class ShiftsModule {}
|
export class ShiftsModule {}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,4 @@
|
||||||
import { Prisma } from "@prisma/client";
|
import { Prisma } from "@prisma/client";
|
||||||
import { dmmfToRuntimeDataModel } from "@prisma/client/runtime/library";
|
|
||||||
|
|
||||||
export const expense_select = {
|
export const expense_select = {
|
||||||
id: true,
|
id: true,
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,6 @@ import { updateExpenseDto } from "src/time-and-attendance/expenses/dtos/expense-
|
||||||
import { SchedulePresetsDto } from "src/time-and-attendance/time-tracker/schedule-presets/dtos/create-schedule-presets.dto";
|
import { SchedulePresetsDto } from "src/time-and-attendance/time-tracker/schedule-presets/dtos/create-schedule-presets.dto";
|
||||||
import { GetShiftDto } from "src/time-and-attendance/time-tracker/shifts/dtos/shift-get.dto";
|
import { GetShiftDto } from "src/time-and-attendance/time-tracker/shifts/dtos/shift-get.dto";
|
||||||
import { ShiftEntity } from "src/time-and-attendance/time-tracker/shifts/dtos/shift-payload.dto";
|
import { ShiftEntity } from "src/time-and-attendance/time-tracker/shifts/dtos/shift-payload.dto";
|
||||||
import { UpdateShiftDto } from "src/time-and-attendance/time-tracker/shifts/dtos/shift-update.dto";
|
|
||||||
import { leaveRequestsSelect } from "src/time-and-attendance/utils/selects.utils";
|
import { leaveRequestsSelect } from "src/time-and-attendance/utils/selects.utils";
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -26,24 +25,15 @@ export type TotalExpenses = {
|
||||||
};
|
};
|
||||||
|
|
||||||
export type Normalized = { date: Date; start_time: Date; end_time: Date; bank_code_id: number};
|
export type Normalized = { date: Date; start_time: Date; end_time: Date; bank_code_id: number};
|
||||||
|
export type CreateShiftResult = { ok: true; data: GetShiftDto } | { ok: false; error: any };
|
||||||
export type ShiftWithOvertimeDto = {
|
export type UpdateShiftResult = { ok: true; id: number; data: GetShiftDto } | { ok: false; id: number; error: any };
|
||||||
shift: GetShiftDto;
|
|
||||||
// overtime: WeekOvertimeSummary;
|
|
||||||
};
|
|
||||||
|
|
||||||
export type CreateShiftResult = { ok: true; data: ShiftWithOvertimeDto } | { ok: false; error: any };
|
|
||||||
export type UpdateShiftChanges = Omit<UpdateShiftDto, 'shift_id'>;
|
|
||||||
export type UpdateShiftPayload = { shift_id: number; dto: UpdateShiftChanges };
|
|
||||||
export type UpdateShiftResult = { ok: true; id: number; data: ShiftWithOvertimeDto } | { ok: false; id: number; error: any };
|
|
||||||
export type DeleteShiftResult = { ok: true; id: number; overtime: WeekOvertimeSummary } | { ok: false; id: number; error: any };
|
|
||||||
|
|
||||||
export type DeletePresetResult = { ok: true; id: number; } | { ok: false; id: number; error: any };
|
export type DeletePresetResult = { ok: true; id: number; } | { ok: false; id: number; error: any };
|
||||||
export type CreatePresetResult = { ok: true; } | { ok: false; error: any };
|
export type CreatePresetResult = { ok: true; } | { ok: false; error: any };
|
||||||
export type UpdatePresetResult = { ok: true; id: number; data: SchedulePresetsDto } | { ok: false; id: number; error: any };
|
export type UpdatePresetResult = { ok: true; id: number; data: SchedulePresetsDto } | { ok: false; id: number; error: any };
|
||||||
|
|
||||||
export type NormalizedExpense = { date: Date; comment: string; supervisor_comment?: string; };
|
|
||||||
|
|
||||||
|
export type NormalizedExpense = { date: Date; comment: string; supervisor_comment?: string; };
|
||||||
export type CreateExpenseResult = { ok: true; data: GetExpenseDto } | { ok: false; error: any };
|
export type CreateExpenseResult = { ok: true; data: GetExpenseDto } | { ok: false; error: any };
|
||||||
export type UpdateExpensePayload = { id: number; dto: updateExpenseDto };
|
export type UpdateExpensePayload = { id: number; dto: updateExpenseDto };
|
||||||
export type UpdateExpenseResult = { ok: true; id: number; data: GetExpenseDto } | { ok: false; id: number; error: any };
|
export type UpdateExpenseResult = { ok: true; id: number; data: GetExpenseDto } | { ok: false; id: number; error: any };
|
||||||
|
|
@ -52,7 +42,6 @@ export type DeleteExpenseResult = { ok: true; id: number; } | { ok: false; id: n
|
||||||
|
|
||||||
|
|
||||||
export type NormedOk = { index: number; dto: ShiftEntity; normed: Normalized, timesheet_id: number };
|
export type NormedOk = { index: number; dto: ShiftEntity; normed: Normalized, timesheet_id: number };
|
||||||
export type NormedErr = { index: number; error: any };
|
|
||||||
|
|
||||||
|
|
||||||
export type ShiftResponse = {
|
export type ShiftResponse = {
|
||||||
|
|
@ -79,8 +68,6 @@ export type ApplyResult = {
|
||||||
|
|
||||||
export type LeaveRequestRow = Prisma.LeaveRequestsGetPayload<{ select: typeof leaveRequestsSelect}>;
|
export type LeaveRequestRow = Prisma.LeaveRequestsGetPayload<{ select: typeof leaveRequestsSelect}>;
|
||||||
|
|
||||||
export type UpsertAction = 'create' | 'update' | 'delete';
|
|
||||||
|
|
||||||
export type Tx = Prisma.TransactionClient | PrismaClient;
|
export type Tx = Prisma.TransactionClient | PrismaClient;
|
||||||
|
|
||||||
export type WeekOvertimeSummary = {
|
export type WeekOvertimeSummary = {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user