Fixed not included last day
This commit is contained in:
@@ -11,6 +11,9 @@ export async function generateTimesEvaluation(
|
|||||||
const startDate = server.dayjs(startDateInput)
|
const startDate = server.dayjs(startDateInput)
|
||||||
const endDate = server.dayjs(endDateInput)
|
const endDate = server.dayjs(endDateInput)
|
||||||
|
|
||||||
|
console.log(startDate.format("YYYY-MM-DD HH:mm:ss"));
|
||||||
|
console.log(endDate.format("YYYY-MM-DD HH:mm:ss"));
|
||||||
|
|
||||||
// 🧾 Profil laden (Arbeitszeiten + Bundesland)
|
// 🧾 Profil laden (Arbeitszeiten + Bundesland)
|
||||||
const { data: profile, error: profileError } = await server.supabase
|
const { data: profile, error: profileError } = await server.supabase
|
||||||
.from("auth_profiles")
|
.from("auth_profiles")
|
||||||
@@ -22,17 +25,24 @@ export async function generateTimesEvaluation(
|
|||||||
if (profileError || !profile) throw new Error("Profil konnte nicht geladen werden.")
|
if (profileError || !profile) throw new Error("Profil konnte nicht geladen werden.")
|
||||||
|
|
||||||
// 🕒 Arbeitszeiten abrufen
|
// 🕒 Arbeitszeiten abrufen
|
||||||
const { data: times, error: timeError } = await server.supabase
|
const { data: timesRaw, error: timeError } = await server.supabase
|
||||||
.from("staff_time_entries")
|
.from("staff_time_entries")
|
||||||
.select("*")
|
.select("*")
|
||||||
.eq("tenant_id", tenant_id)
|
.eq("tenant_id", tenant_id)
|
||||||
.eq("user_id", user_id)
|
.eq("user_id", user_id)
|
||||||
.gte("started_at", startDate.toISOString())
|
|
||||||
.lte("started_at", endDate.toISOString())
|
|
||||||
.order("started_at", { ascending: true })
|
.order("started_at", { ascending: true })
|
||||||
|
|
||||||
if (timeError) throw new Error("Fehler beim Laden der Arbeitszeiten: " + timeError.message)
|
if (timeError) throw new Error("Fehler beim Laden der Arbeitszeiten: " + timeError.message)
|
||||||
|
|
||||||
|
const isBetween = (spanStartDate,spanEndDate,startDate,endDate) => {
|
||||||
|
return server.dayjs(startDate).isBetween(spanStartDate, spanEndDate, "day", "[]") && server.dayjs(endDate).isBetween(spanStartDate, spanEndDate, "day", "[]")
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const times = timesRaw.filter(i => isBetween(startDate,endDate,i.started_at,i.stopped_at) )
|
||||||
|
|
||||||
|
console.log(times)
|
||||||
|
|
||||||
// 📅 Feiertage aus Tabelle für Bundesland + DE
|
// 📅 Feiertage aus Tabelle für Bundesland + DE
|
||||||
const { data: holidays, error: holidaysError } = await server.supabase
|
const { data: holidays, error: holidaysError } = await server.supabase
|
||||||
.from("holidays")
|
.from("holidays")
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ dayjs.extend(utc)
|
|||||||
dayjs.extend(timezone)
|
dayjs.extend(timezone)
|
||||||
dayjs.extend(isSameOrAfter)
|
dayjs.extend(isSameOrAfter)
|
||||||
dayjs.extend(isSameOrBefore)
|
dayjs.extend(isSameOrBefore)
|
||||||
|
dayjs.extend(isBetween)
|
||||||
dayjs.extend(isoWeek)
|
dayjs.extend(isoWeek)
|
||||||
dayjs.extend(localizedFormat)
|
dayjs.extend(localizedFormat)
|
||||||
dayjs.extend(customParseFormat)
|
dayjs.extend(customParseFormat)
|
||||||
|
|||||||
Reference in New Issue
Block a user