Merge branch 'main' of git.targo.ca:Targo/targo_backend
This commit is contained in:
commit
e72b63116c
|
|
@ -62,6 +62,7 @@ export class ShiftsUpdateDeleteService {
|
||||||
if (!timesheet.success) return { success: false, error: timesheet.error }
|
if (!timesheet.success) return { success: false, error: timesheet.error }
|
||||||
|
|
||||||
//finds original shift
|
//finds original shift
|
||||||
|
console.log('timesheet id found: ', timesheet.data.id);
|
||||||
const original = await this.prisma.shifts.findFirst({
|
const original = await this.prisma.shifts.findFirst({
|
||||||
where: { id: dto.id, timesheet_id: timesheet.data.id },
|
where: { id: dto.id, timesheet_id: timesheet.data.id },
|
||||||
select: shift_select,
|
select: shift_select,
|
||||||
|
|
@ -162,9 +163,14 @@ export class ShiftsUpdateDeleteService {
|
||||||
for (let j = i + 1; j < shifts.length; j++) {
|
for (let j = i + 1; j < shifts.length; j++) {
|
||||||
const shift_a = shifts[i];
|
const shift_a = shifts[i];
|
||||||
const shift_b = shifts[j];
|
const shift_b = shifts[j];
|
||||||
|
<<<<<<< HEAD
|
||||||
|
|
||||||
if (shift_a.date !== shift_b.date) continue;
|
if (shift_a.date !== shift_b.date) continue;
|
||||||
if (shift_a.id === shift_b.id) continue;
|
if (shift_a.id === shift_b.id) continue;
|
||||||
|
=======
|
||||||
|
|
||||||
|
if (shift_a.date !== shift_b.date || shift_a.id === shift_b.id) continue;
|
||||||
|
>>>>>>> 37b150d87c98746a3cb23bbe36ee9e364c6a613d
|
||||||
const has_overlap = overlaps(
|
const has_overlap = overlaps(
|
||||||
{ start: toHHmmFromString(shift_a.start_time), end: toHHmmFromString(shift_a.end_time) },
|
{ start: toHHmmFromString(shift_a.start_time), end: toHHmmFromString(shift_a.end_time) },
|
||||||
{ start: toHHmmFromString(shift_b.start_time), end: toHHmmFromString(shift_b.end_time) },
|
{ start: toHHmmFromString(shift_b.start_time), end: toHHmmFromString(shift_b.end_time) },
|
||||||
|
|
|
||||||
|
|
@ -3,11 +3,9 @@ import { ANCHOR_ISO, MS_PER_DAY, PERIODS_PER_YEAR, PERIOD_DAYS } from "src/time-
|
||||||
|
|
||||||
//ensures the week starts from sunday
|
//ensures the week starts from sunday
|
||||||
export function weekStartSunday(date_local: Date): Date {
|
export function weekStartSunday(date_local: Date): Date {
|
||||||
const start = new Date(Date.UTC(date_local.getFullYear(), date_local.getMonth(), date_local.getDate()));
|
const start_date = new Date();
|
||||||
const dow = start.getDay(); // 0 = dimanche
|
start_date.setDate(date_local.getDate() - date_local.getDay());
|
||||||
start.setDate(start.getDate() - dow);
|
return start_date;
|
||||||
start.setHours(0, 0, 0, 0);
|
|
||||||
return start;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//converts string to HHmm format
|
//converts string to HHmm format
|
||||||
|
|
|
||||||
|
|
@ -20,6 +20,7 @@ export class EmployeeTimesheetResolver {
|
||||||
const employee_id = await this.emailResolver.findIdByEmail(email);
|
const employee_id = await this.emailResolver.findIdByEmail(email);
|
||||||
if(!employee_id.success) return { success: false, error: employee_id.error}
|
if(!employee_id.success) return { success: false, error: employee_id.error}
|
||||||
const start_date = weekStartSunday(date);
|
const start_date = weekStartSunday(date);
|
||||||
|
console.log('start date: ', start_date);
|
||||||
const timesheet = await db.timesheets.findFirst({
|
const timesheet = await db.timesheets.findFirst({
|
||||||
where: { employee_id : employee_id.data, start_date: start_date },
|
where: { employee_id : employee_id.data, start_date: start_date },
|
||||||
select: { id: true },
|
select: { id: true },
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user