Changes in Times Evaluation

This commit is contained in:
2024-10-20 16:14:01 +02:00
parent a905b1f966
commit d3c2c8f642
5 changed files with 174 additions and 42 deletions

View File

@@ -102,32 +102,32 @@ export const useCreateWorkingTimesPdf = async (input,backgroundSourceBuffer) =>
y: getCoordinatesForPDFLib(20,70,pages[pageCounter -1]).y,
size: 10,
})
/*pages[pageCounter - 1].drawText(`Bestätigt: ${Math.floor(input.sumWorkingMinutesApproved/60)}:${String(input.sumWorkingMinutesApproved % 60).padStart(2,"0")} Std`,{
pages[pageCounter - 1].drawText(`Genehmigt: ${Math.floor(input.sumWorkingMinutesApproved/60)}:${String(input.sumWorkingMinutesApproved % 60).padStart(2,"0")} Std`,{
x: getCoordinatesForPDFLib(20,75,pages[pageCounter -1]).x,
y: getCoordinatesForPDFLib(20,75,pages[pageCounter -1]).y,
size: 10,
})
pages[pageCounter - 1].drawText(`Soll Stunden: ${input.monthlyWorkingHours} Std`,{
pages[pageCounter - 1].drawText(`Soll Stunden: ${Math.floor(input.monthlyWorkingMinutes/60)}:${String(input.monthlyWorkingMinutes % 60).padStart(2,"0")} Std`,{
x: getCoordinatesForPDFLib(20,80,pages[pageCounter -1]).x,
y: getCoordinatesForPDFLib(20,80,pages[pageCounter -1]).y,
size: 10,
})
pages[pageCounter - 1].drawText(`Abwesend: Std`,{
pages[pageCounter - 1].drawText(`Feiertagsausgleich: ${Math.floor(input.sumWorkingMinutesRecreationDays/60)}:${String(input.sumWorkingMinutesRecreationDays % 60).padStart(2,"0")} Std`,{
x: getCoordinatesForPDFLib(20,85,pages[pageCounter -1]).x,
y: getCoordinatesForPDFLib(20,85,pages[pageCounter -1]).y,
size: 10,
})
pages[pageCounter - 1].drawText(`Ausgleich: Std`,{
pages[pageCounter - 1].drawText(`Urlaubsausgleich: ${Math.floor(input.sumWorkingMinutesRecreationDays/60)}:${String(input.sumWorkingMinutesRecreationDays % 60).padStart(2,"0")} Std`,{
x: getCoordinatesForPDFLib(20,90,pages[pageCounter -1]).x,
y: getCoordinatesForPDFLib(20,90,pages[pageCounter -1]).y,
size: 10,
})
pages[pageCounter - 1].drawText(`Inoffizielles Saldo: ${input.saldoInOfficial} Std`,{
pages[pageCounter - 1].drawText(`Inoffizielles Saldo: ${Math.sign(input.saldoInOfficial) === 1 ? "" : "-"}${Math.floor(Math.abs(input.saldoInOfficial/60))}:${String(Math.abs(input.saldoInOfficial) % 60).padStart(2,"0")} Std`,{
x: getCoordinatesForPDFLib(20,95,pages[pageCounter -1]).x,
y: getCoordinatesForPDFLib(20,95,pages[pageCounter -1]).y,
size: 10,
})
pages[pageCounter - 1].drawText(`Saldo: ${input.saldo} Std`,{
pages[pageCounter - 1].drawText(`Saldo: ${Math.sign(input.saldo) === 1 ? "" : "-"}${Math.floor(Math.abs(input.saldo/60))}:${String(Math.abs(input.saldo) % 60).padStart(2,"0")} Std`,{
x: getCoordinatesForPDFLib(20,100,pages[pageCounter -1]).x,
y: getCoordinatesForPDFLib(20,100,pages[pageCounter -1]).y,
size: 10,
@@ -149,10 +149,10 @@ export const useCreateWorkingTimesPdf = async (input,backgroundSourceBuffer) =>
x: getCoordinatesForPDFLib(100,110,pages[pageCounter -1]).x,
y: getCoordinatesForPDFLib(100,110,pages[pageCounter -1]).y,
size: 10,
})*/
})
let rowHeight = 85
let rowHeight = 115
input.times.forEach(time => {
pages[pageCounter - 1].drawText(`${dayjs(time.startDate).format("HH:mm DD.MM.YY")}`,{

View File

@@ -12,7 +12,6 @@ const router = useRouter()
const toast = useToast()
const id = ref(route.params.id ? route.params.id : null )
let currentItem = ref(null)
//Working
const mode = ref(route.params.mode || "show")
@@ -37,20 +36,19 @@ const absenceReasons = [
//Functions
const setupPage = () => {
if(mode.value === "show" || mode.value === "edit"){
currentItem.value = dataStore.getAbsenceRequestById(Number(useRoute().params.id))
itemInfo.value = dataStore.getAbsenceRequestById(Number(useRoute().params.id))
}
if(mode.value === "edit") itemInfo.value = currentItem.value
}
const editItem = async () => {
router.push(`/employees/absenceRequests/edit/${currentItem.id}`)
router.push(`/absenceRequests/edit/${itemInfo.value.id}`)
setupPage()
}
const cancelEditorCreate = () => {
if(currentItem.value) {
router.push(`/absenceRequests/show/${currentItem.value.id}`)
if(itemInfo.value) {
router.push(`/absenceRequests/show/${itemInfo.value.id}`)
} else {
router.push(`/absenceRequests/`)
}
@@ -59,7 +57,7 @@ setupPage()
</script>
<template>
<UDashboardNavbar :title="currentItem ? currentItem.name : (mode === 'create' ? 'Abwesenheit erstellen' : 'Abwesenheit bearbeiten')">
<UDashboardNavbar :title="itemInfo ? itemInfo.name : (mode === 'create' ? 'Abwesenheit erstellen' : 'Abwesenheit bearbeiten')">
<template #right>
<UButton
v-if="mode === 'edit'"
@@ -88,42 +86,42 @@ setupPage()
Bearbeiten
</UButton>
</template>
<template #badge v-if="currentItem">
<template #badge v-if="itemInfo">
<UBadge
v-if="currentItem.approved === 'Offen'"
v-if="itemInfo.approved === 'Offen'"
color="blue"
>{{currentItem.approved}}</UBadge>
>{{itemInfo.approved}}</UBadge>
<UBadge
v-else-if="currentItem.approved === 'Genehmigt'"
v-else-if="itemInfo.approved === 'Genehmigt'"
color="primary"
>{{currentItem.approved}}</UBadge>
>{{itemInfo.approved}}</UBadge>
<UBadge
v-else-if="currentItem.approved === 'Abgelehnt'"
v-else-if="itemInfo.approved === 'Abgelehnt'"
color="rose"
>{{currentItem.approved}}</UBadge>
>{{itemInfo.approved}}</UBadge>
</template>
</UDashboardNavbar>
<UTabs
:items="[{label: 'Informationen'}, {label: 'Logbuch'}]"
v-if="currentItem && mode == 'show'"
v-if="itemInfo && mode == 'show'"
class="p-5"
>
<template #item="{item}">
<UCard class="mt-5">
<div v-if="item.label === 'Informationen'">
<div class="truncate">
<p>Mitarbeiter: {{dataStore.profiles.find(item => item.id === currentItem.user) ? dataStore.profiles.find(item => item.id === currentItem.user).fullName : ""}}</p>
<p>Start: {{dayjs(currentItem.start).format("DD.MM.YYYY")}}</p>
<p>Ende: {{dayjs(currentItem.end).format("DD.MM.YYYY")}}</p>
<p>Grund: {{currentItem.reason}}</p>
<p>Notizen: {{currentItem.notes}}</p>
<p>Mitarbeiter: {{dataStore.profiles.find(item => item.id === itemInfo.user) ? dataStore.profiles.find(item => item.id === itemInfo.user).fullName : ""}}</p>
<p>Start: {{dayjs(itemInfo.start).format("DD.MM.YYYY")}}</p>
<p>Ende: {{dayjs(itemInfo.end).format("DD.MM.YYYY")}}</p>
<p>Grund: {{itemInfo.reason}}</p>
<p>Notizen: {{itemInfo.notes}}</p>
</div>
</div>
<div v-else-if="item.label === 'Logbuch'">
<HistoryDisplay
type="absencerequest"
v-if="currentItem"
:element-id="currentItem.id"
v-if="itemInfo"
:element-id="itemInfo.id"
/>
</div>
</UCard>

View File

@@ -15,7 +15,9 @@ const router = useRouter()
const supabase = useSupabaseClient()
const toast = useToast()
const itemInfo = ref({})
const itemInfo = ref({
weeklyRegularWorkingHours: {}
})
const oldItemInfo = ref({})
const setupPage = () => {
if(route.params.id) itemInfo.value = dataStore.getProfileById(route.params.id)
@@ -290,12 +292,12 @@ const addToNewsletter = async () => {
<UDivider>Newsletter</UDivider>
<UButton
<!-- <UButton
@click="addToNewsletter"
variant="outline"
>
In Newsletter eintragen
</UButton>
</UButton>-->
</div>
<div v-if="item.label === 'Logbuch'">
@@ -432,6 +434,68 @@ const addToNewsletter = async () => {
/>
</UFormGroup>
</InputGroup>
<UDivider>Regelarbeitszeiten</UDivider>
<InputGroup class="w-full">
<UFormGroup
label="Montag"
class="flex-auto"
>
<UInput
v-model="itemInfo.weeklyRegularWorkingHours[1]"
type="number"
/>
</UFormGroup><UFormGroup
label="Dienstag"
class="flex-auto"
>
<UInput
v-model="itemInfo.weeklyRegularWorkingHours[2]"
type="number"
/>
</UFormGroup>
<UFormGroup
label="Mittwoch"
class="flex-auto"
>
<UInput
v-model="itemInfo.weeklyRegularWorkingHours[3]"
type="number"
/>
</UFormGroup>
<UFormGroup
label="Donnerstag"
class="flex-auto"
>
<UInput
v-model="itemInfo.weeklyRegularWorkingHours[4]"
type="number"
/>
</UFormGroup>
<UFormGroup
label="Freitag"
class="flex-auto"
>
<UInput
v-model="itemInfo.weeklyRegularWorkingHours[5]"
type="number"
/>
</UFormGroup>
<UFormGroup
label="Samstag"
class="flex-auto"
>
<UInput
v-model="itemInfo.weeklyRegularWorkingHours[6]"
type="number"
/>
</UFormGroup>
</InputGroup>
</div>
</UCard>
</template>

View File

@@ -39,6 +39,21 @@ setupPage()
<UDashboardNavbar
:title="mode === 'show' ? `Anwesenheit: ${itemInfo.profile}` : (itemInfo.id ? 'Anwesenheit bearbeiten' :'Anwesenheit erstellen')"
>
<template #left>
<UButton
icon="i-heroicons-chevron-left"
variant="outline"
@click="router.push(`/workingtimes`)"
>
Anwesenheiten
</UButton>
</template>
<template #center>
<h1
v-if="itemInfo"
class="text-xl font-medium"
>{{itemInfo.id ? 'Anwesenheite bearbeiten' : 'Anwesenheit erstellen'}}</h1>
</template>
<template #right>
<UButton
color="rose"
@@ -53,6 +68,12 @@ setupPage()
>
Speichern
</UButton>
<UButton
v-if="mode === 'edit' && itemInfo.id"
@click="dataStore.updateItem('workingtimes',{...itemInfo, approved: true})"
>
Genehmigen & Speichern
</UButton>
<UButton
v-else-if="mode === 'edit' && !itemInfo.id"
@click="dataStore.createNewItem('workingtimes',itemInfo)"

View File

@@ -23,13 +23,14 @@ const itemInfo = ref({})
const oldItemInfo = ref({})
const workingtimes = ref([])
const absencerequests = ref([])
const setupPage = async () => {
if(route.params.id) itemInfo.value = dataStore.getProfileById(route.params.id)
if(itemInfo.value.id) oldItemInfo.value = JSON.parse(JSON.stringify(itemInfo.value))
workingtimes.value = (await supabase.from("workingtimes").select().eq("profile",itemInfo.value.id).order("startDate",{ascending:false})).data
absencerequests.value = (await supabase.from("absencerequests").select().eq("user",itemInfo.value.id).order("start",{ascending: false})).data
}
const selectedPresetRange = ref("Dieser Monat")
@@ -77,7 +78,7 @@ const workingTimeInfo = computed(() => {
let weekFactor = 4.33
let monthlyWorkingHours = itemInfo.value.weeklyWorkingHours * weekFactor
let monthlyWorkingMinutes = itemInfo.value.weeklyWorkingHours * weekFactor * 60
//Eingreicht
@@ -96,15 +97,60 @@ const workingTimeInfo = computed(() => {
//console.log(times.filter(i => i.approved).length)
//console.log(sumWorkingMinutesApproved)
let recreationDays = ["2024-01-01","2024-05-01","2024-10-03","2024-10-31","2024-12-25","2024-12-26"]
//Feiertagsausgleich
let sumWorkingMinutesRecreationDays = 0
let sumRecreationDays = 0
recreationDays.filter(i => dayjs(i).isSameOrAfter(selectedStartDay.value) && dayjs(i).isSameOrBefore(selectedEndDay.value)).forEach(day => {
let compensationTime = itemInfo.value.weeklyRegularWorkingHours[dayjs(day).day()]
sumWorkingMinutesRecreationDays += compensationTime * 60
sumRecreationDays++
})
//Urlaubsausgleich
let sumWorkingMinutesVacationDays = 0
let sumVacationDays = 0
let dailyMinutes = (itemInfo.value.weeklyWorkingHours / 6 * 60).toFixed(2)
let isBetween = (date,start,end) => {
return dayjs(date).isSameOrAfter(start) && dayjs(date).isSameOrBefore(end)
}
absencerequests.value.filter(i => (dayjs(i.start).isBetween(dayjs(selectedStartDay.value),dayjs(selectedEndDay.value)) || dayjs(i.end).isBetween(dayjs(selectedStartDay.value),dayjs(selectedEndDay.value)) ) && i.reason === "Urlaub" && i.approved === "Genehmigt").forEach(absenceRequest => {
let durationInDays = 0
if(isBetween(absenceRequest.start,selectedStartDay.value,selectedEndDay.value) && isBetween(absenceRequest.end,selectedStartDay.value,selectedEndDay.value)) {
//Full in Range
durationInDays = dayjs(absenceRequest.end).diff(absenceRequest.start, "days") + 1
} else if(isBetween(absenceRequest.start,selectedStartDay.value,selectedEndDay.value) && !isBetween(absenceRequest.end,selectedStartDay.value,selectedEndDay.value)) {
//Start in Range
durationInDays = dayjs(selectedEndDay.value).diff(absenceRequest.start, "days") + 1
} else if(!isBetween(absenceRequest.start,selectedStartDay.value,selectedEndDay.value) && isBetween(absenceRequest.end,selectedStartDay.value,selectedEndDay.value)) {
//End in Range
durationInDays = dayjs(absenceRequest.end).diff(selectedStartDay.value, "days") + 1
}
sumVacationDays += durationInDays
sumWorkingMinutesVacationDays += dailyMinutes * durationInDays
})
//Saldo
let saldo = (sumWorkingMinutesApproved / 60).toFixed(2) - monthlyWorkingHours
let saldoInOfficial = (((sumWorkingMinutesApproved + sumWorkingMinutesEingereicht) / 60).toFixed(2) - monthlyWorkingHours).toFixed(2)
let saldo = (sumWorkingMinutesApproved + sumWorkingMinutesRecreationDays +sumWorkingMinutesVacationDays - monthlyWorkingMinutes).toFixed(2)
let saldoInOfficial = (sumWorkingMinutesApproved + sumWorkingMinutesEingereicht + sumWorkingMinutesRecreationDays + sumWorkingMinutesVacationDays - monthlyWorkingMinutes).toFixed(2)
return {
monthlyWorkingHours,
monthlyWorkingMinutes,
sumWorkingMinutesEingereicht,
sumWorkingMinutesApproved,
sumWorkingMinutesRecreationDays,
sumRecreationDays,
sumWorkingMinutesVacationDays,
sumVacationDays,
saldo,
saldoInOfficial,
times,
@@ -253,14 +299,17 @@ changeRange()
Zusammenfassung
</template>
<p>Eingreicht: {{Math.floor(workingTimeInfo.sumWorkingMinutesEingereicht/60)}}:{{String(workingTimeInfo.sumWorkingMinutesEingereicht % 60).padStart(2,"0")}} h</p>
<p>Bestätigt: {{Math.floor(workingTimeInfo.sumWorkingMinutesApproved/60)}}:{{String(workingTimeInfo.sumWorkingMinutesApproved % 60).padStart(2,"0")}} h</p>
<p>Soll Stunden: {{workingTimeInfo.monthlyWorkingHours}} h</p>
<p>Genehmigt: {{Math.floor(workingTimeInfo.sumWorkingMinutesApproved/60)}}:{{String(workingTimeInfo.sumWorkingMinutesApproved % 60).padStart(2,"0")}} h</p>
<p>Feiertagsausgleich: {{Math.floor(workingTimeInfo.sumWorkingMinutesRecreationDays/60)}}:{{String(workingTimeInfo.sumWorkingMinutesRecreationDays % 60).padStart(2,"0")}} h / {{workingTimeInfo.sumRecreationDays}} Tage</p>
<p>Urlaubsausgleich: {{Math.floor(workingTimeInfo.sumWorkingMinutesVacationDays/60)}}:{{String(workingTimeInfo.sumWorkingMinutesVacationDays % 60).padStart(2,"0")}} h / {{workingTimeInfo.sumVacationDays}} Tage</p>
<p>Soll Stunden: {{Math.floor(workingTimeInfo.monthlyWorkingMinutes/60)}}:{{String(workingTimeInfo.monthlyWorkingMinutes % 60).padStart(2,"0")}} h</p>
<!-- <p>Abwesend: </p>
<p>Ausgleich:</p>
-->
<p>Inoffizielles Saldo: {{workingTimeInfo.saldoInOfficial}} h</p>
<p>Saldo: {{workingTimeInfo.saldo}} h</p>
<p>Inoffizielles Saldo: {{Math.sign(workingTimeInfo.saldoInOfficial) === 1 ? "" : "-"}}{{Math.floor(Math.abs(workingTimeInfo.saldoInOfficial/60))}}:{{String(Math.abs(workingTimeInfo.saldoInOfficial) % 60).padStart(2,"0")}} h</p>
<p>Saldo: {{Math.sign(workingTimeInfo.saldo) === 1 ? "" : "-"}}{{Math.floor(Math.abs(workingTimeInfo.saldo/60))}}:{{String(Math.abs(workingTimeInfo.saldo) % 60).padStart(2,"0")}} h</p>
</UCard>
<div style="overflow-y: scroll; height: 45vh">