clean(shifts): cleaning
This commit is contained in:
parent
c2203f77cb
commit
457757a066
|
|
@ -52,7 +52,7 @@ export class ShiftsUpsertService {
|
|||
select: timesheet_select,
|
||||
});
|
||||
if (!timesheet) {
|
||||
return { index, error: new NotFoundException(`Timesheet not found`)};
|
||||
return { index, error: new NotFoundException(`Timesheet not found`) };
|
||||
}
|
||||
|
||||
return {
|
||||
|
|
@ -136,7 +136,7 @@ export class ShiftsUpsertService {
|
|||
const day_date = new Date(day);
|
||||
const rows = await tx.shifts.findMany({
|
||||
where: { timesheet_id, date: day_date },
|
||||
select: { start_time: true, end_time: true },
|
||||
select: { start_time: true, end_time: true, id: true },
|
||||
});
|
||||
existing_map.set(
|
||||
key,
|
||||
|
|
@ -153,7 +153,7 @@ export class ShiftsUpsertService {
|
|||
const day_key = new Date(normed.date.getFullYear(), normed.date.getMonth(), normed.date.getDate()).getTime();
|
||||
const map_key = `${timesheet_id}|${day_key}`;
|
||||
let existing = existing_map.get(map_key);
|
||||
if(!existing) {
|
||||
if (!existing) {
|
||||
existing = [];
|
||||
existing_map.set(map_key, existing);
|
||||
}
|
||||
|
|
@ -189,8 +189,7 @@ export class ShiftsUpsertService {
|
|||
|
||||
const normalizeHHmm = (value: Date) => toHHmmFromString(toStringFromHHmm(value));
|
||||
|
||||
for (const { timesheet_id, day, key } of timesheet_keys) {
|
||||
const day_date = new Date(day);
|
||||
for (const { key } of timesheet_keys) {
|
||||
existing.push({
|
||||
start_time: normalizeHHmm(row.start_time),
|
||||
end_time: normalizeHHmm(row.end_time)
|
||||
|
|
@ -204,8 +203,7 @@ export class ShiftsUpsertService {
|
|||
);
|
||||
}
|
||||
|
||||
|
||||
const {type: bank_type} = await this.typeResolver.findTypeByBankCodeId(row.bank_code_id);
|
||||
const { type: bank_type } = await this.typeResolver.findTypeByBankCodeId(row.bank_code_id);
|
||||
const summary = await this.overtime.getWeekOvertimeSummary(timesheet_id, normed.date, tx);
|
||||
|
||||
const shift: GetShiftDto = {
|
||||
|
|
@ -279,7 +277,7 @@ export class ShiftsUpsertService {
|
|||
}
|
||||
}
|
||||
|
||||
const planned_updates = updates.map( update => {
|
||||
const planned_updates = updates.map(update => {
|
||||
const exist_shift = regroup_id.get(update.id)!;
|
||||
const date_string = update.dto.date ?? toStringFromDate(exist_shift.date);
|
||||
const start_string = update.dto.start_time ?? toStringFromHHmm(exist_shift.start_time);
|
||||
|
|
@ -421,7 +419,7 @@ export class ShiftsUpsertService {
|
|||
//_________________________________________________________________
|
||||
//converts all string hours and date to Date and HHmm formats
|
||||
private normalizeShiftDto = async (dto: ShiftDto): Promise<Normalized> => {
|
||||
const { id: bank_code_id} = await this.typeResolver.findBankCodeIDByType(dto.type);
|
||||
const { id: bank_code_id } = await this.typeResolver.findBankCodeIDByType(dto.type);
|
||||
const date = toDateFromString(dto.date);
|
||||
const start_time = toHHmmFromString(dto.start_time);
|
||||
const end_time = toHHmmFromString(dto.end_time);
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user