Changes in times and Dashboard

This commit is contained in:
2024-03-19 12:26:16 +01:00
parent edf1de189b
commit 66ee33cdde
6 changed files with 183 additions and 20 deletions

158
imports/specht/index.js Normal file
View File

@@ -0,0 +1,158 @@
const csv = require("csv-parser")
const fs = require("fs")
const path = require("path")
const {createClient} = require("@supabase/supabase-js")
const dayjs = require("dayjs")
const customParseFormat = require('dayjs/plugin/customParseFormat')
dayjs.extend(customParseFormat)
const supabase = createClient("https://uwppvcxflrcsibuzsbil.supabase.co","eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InV3cHB2Y3hmbHJjc2lidXpzYmlsIiwicm9sZSI6InNlcnZpY2Vfcm9sZSIsImlhdCI6MTcwMDkzODE5NCwiZXhwIjoyMDE2NTE0MTk0fQ.6hOkD1J8XBkVJUm-swv0ngLQ74xrEYr28EEbo0rUrts")
let rows = []
fs.createReadStream(path.join(__dirname, "./Zeiterfassung.csv"), "utf-8")
.pipe(csv({ separator: ";" }))
.on("data", (data) => rows.push(data))
.on("end", async function () {
console.log("finished");
console.log(rows)
let profiles = (await supabase.from("profiles").select()).data
let times = []
let absences = []
rows.forEach(row => {
let date = dayjs(row.Datum, "DD.MM.YY",true).format("YYYY-MM-DD")
let profileId = profiles.find(i => i.employeeNumber === row['Mitarbeiter']).id
if(row.Notiz === 'Krankheit' || row.Notiz === "Urlaub" || row.Notiz === "Berufsschule") {
absences.push({
user: profileId,
tenant: 11,
start: date,
end: date,
reason: row.Notiz,
approved: "Genehmigt"
})
} else {
if(row.Start_1 && row.Ende_1) {
times.push({
profile:profileId,
date: date,
start: row.Start_1 + ":00",
end: row.Ende_1 + ":00",
approved:true,
tenant: 11,
state: "Importiert",
notes: row.Notiz
})
}
if(row.Start_2&& row.Ende_2) {
times.push({
profile:profileId,
date: date,
start: row.Start_2 + ":00",
end: row.Ende_2 + ":00",
approved:true,
tenant: 11,
state: "Importiert",
notes: row.Notiz
})
}
if(row.Start_3 && row.Ende_3) {
times.push({
profile:profileId,
date: date,
start: row.Start_3 + ":00",
end: row.Ende_3 + ":00",
approved:true,
tenant: 11,
state: "Importiert",
notes: row.Notiz
})
}
if(row.Start_4 && row.Ende_4) {
times.push({
profile:profileId,
date: date,
start: row.Start_4 + ":00",
end: row.Ende_4 + ":00",
approved:true,
tenant: 11,
state: "Importiert",
notes: row.Notiz
})
}
}
})
console.log(times)
console.log(times.length)
/*let hours = 0
let datebefore = ""
let days = []
let daysum = 0
times.forEach(time => {
if(time.date !== datebefore) {
datebefore = time.date
daysum = 0
}
console.log(time.date)
console.log(time.start)
console.log(time.end)
hours += dayjs(time.end, "HH:mm:ss").diff(dayjs(time.start, "HH:mm:ss"), "minutes")
daysum += dayjs(time.end, "HH:mm:ss").diff(dayjs(time.start, "HH:mm:ss"), "minutes")
console.log(datebefore, daysum/60)
})
console.log(hours/60)*/
await supabase.from("absencerequests").insert(absences)
await supabase.from("workingtimes").insert(times)
/*projects = rows.map(i => {
let item = {
customer : Number(i.customer),
tenant: tenant,
name: i.Projektname,
notes: i.Anmerkungen + "\n" + i['Angaben zum Projekt']
}
return item
})
console.log(projects)
const {data:vendorsData,error: vendorsError} = await supabase.from("projects").insert(projects).select()
console.log(vendorsData)
console.log(vendorsError)*/
//console.log(rows)
})
.on("error", function (error) {
console.log(error.message);
});

View File

@@ -12,4 +12,4 @@ ENV NUXT_PORT=3000
EXPOSE 3000 EXPOSE 3000
ENTRYPOINT ["node", ".output/server/index.mjs"] ENTRYPOINT ["node", ".output/server/index.js"]

View File

@@ -28,15 +28,11 @@
</UDashboardToolbar>--> </UDashboardToolbar>-->
<UDashboardPanelContent> <UDashboardPanelContent>
<!-- ~/components/home/HomeChart.vue --> <UDashboardCard
<!-- <HomeChart :period="period" :range="range" /> >
<p v-for="time in dataStore.getStartedWorkingTimes()"><UIcon name="i-heroicons-check"/>{{dataStore.getProfileById(time.profile).fullName}}</p>
</UDashboardCard>
<div class="grid lg:grid-cols-2 lg:items-start gap-8 mt-8">
&lt;!&ndash; ~/components/home/HomeSales.vue &ndash;&gt;
<HomeSales />
&lt;!&ndash; ~/components/home/HomeCountries.vue &ndash;&gt;
<HomeCountries />
</div>-->
</UDashboardPanelContent> </UDashboardPanelContent>
</UDashboardPanel> </UDashboardPanel>
</UDashboardPage> </UDashboardPage>
@@ -47,6 +43,8 @@ definePageMeta({
middleware: "auth" middleware: "auth"
}) })
const dataStore = useDataStore()
const { isNotificationsSlideoverOpen } = useDashboard() const { isNotificationsSlideoverOpen } = useDashboard()
const items = [[{ const items = [[{
label: 'Aufgabe', label: 'Aufgabe',

View File

@@ -47,8 +47,8 @@ const changeRange = () => {
subtract = 1 subtract = 1
} }
selectedStartDay.value = dayjs().subtract(subtract,selector).startOf(selector).format("YYYY-MM-DD") selectedStartDay.value = dayjs().subtract(subtract,selector === "isoWeek" ? "week" : selector).startOf(selector).format("YYYY-MM-DD")
selectedEndDay.value = dayjs().subtract(subtract,selector).endOf(selector).format("YYYY-MM-DD") selectedEndDay.value = dayjs().subtract(subtract,selector === "isoWeek" ? "week" : selector).endOf(selector).format("YYYY-MM-DD")
} }
@@ -57,7 +57,7 @@ const workingTimeInfo = computed(() => {
let times = dataStore.getWorkingTimesByProfileId(itemInfo.value.id) let times = dataStore.getWorkingTimesByProfileId(itemInfo.value.id)
times = times.filter(i => dayjs(i.date).isBetween(selectedStartDay.value,selectedEndDay.value,'day') && i.end) times = times.filter(i => dayjs(i.date).isBetween(dayjs(selectedStartDay.value).subtract(1,"days"),selectedEndDay.value,'day') && i.end)
@@ -68,27 +68,24 @@ const workingTimeInfo = computed(() => {
//Eingreicht //Eingreicht
let sumWorkingMinutesEingereicht = 0 let sumWorkingMinutesEingereicht = 0
times.filter(i => !i.approved).forEach(time => { times.filter(i => !i.approved).forEach(time => {
console.log(time)
const minutes = dayjs(time.end, "HH:mm:ss").diff(dayjs(time.start, "HH:mm:ss"),'minutes') const minutes = dayjs(time.end, "HH:mm:ss").diff(dayjs(time.start, "HH:mm:ss"),'minutes')
console.log(minutes)
sumWorkingMinutesEingereicht = sumWorkingMinutesEingereicht + minutes sumWorkingMinutesEingereicht = sumWorkingMinutesEingereicht + minutes
}) })
//Bestätigt //Bestätigt
let sumWorkingMinutesApproved = 0 let sumWorkingMinutesApproved = 0
times.filter(i => i.approved).forEach(time => { times.filter(i => i.approved).forEach(time => {
const minutes = Math.floor(dayjs(time.end, "HH:mm:ss").diff(dayjs(time.start, "HH:mm:ss"),'minutes')) const minutes = dayjs(time.end, "HH:mm:ss").diff(dayjs(time.start, "HH:mm:ss"),'minutes')
sumWorkingMinutesApproved = sumWorkingMinutesApproved + minutes sumWorkingMinutesApproved = sumWorkingMinutesApproved + minutes
}) })
//console.log(times.filter(i => i.approved).length)
//console.log(sumWorkingMinutesApproved)
//Saldo //Saldo
let saldo = (sumWorkingMinutesApproved / 60).toFixed(2) - monthlyWorkingHours let saldo = (sumWorkingMinutesApproved / 60).toFixed(2) - monthlyWorkingHours
let saldoInOfficial = ((sumWorkingMinutesApproved + sumWorkingMinutesEingereicht) / 60).toFixed(2) - monthlyWorkingHours let saldoInOfficial = ((sumWorkingMinutesApproved + sumWorkingMinutesEingereicht) / 60).toFixed(2) - monthlyWorkingHours
return { return {
monthlyWorkingHours, monthlyWorkingHours,
sumWorkingMinutesEingereicht, sumWorkingMinutesEingereicht,
@@ -211,7 +208,6 @@ changeRange()
@change="changeRange" @change="changeRange"
/> />
</UFormGroup> </UFormGroup>
<UFormGroup label="Start:" > <UFormGroup label="Start:" >
<UPopover :popper="{ placement: 'bottom-start' }"> <UPopover :popper="{ placement: 'bottom-start' }">
<UButton <UButton
@@ -247,8 +243,11 @@ changeRange()
<p>Saldo: {{workingTimeInfo.saldo}} h</p> <p>Saldo: {{workingTimeInfo.saldo}} h</p>
</div> </div>
<UDivider class="my-3"/>
<UTable <UTable
:rows="dataStore.getWorkingTimesByProfileId(dataStore.activeProfile.id)" :rows="dataStore.getWorkingTimesByProfileId(itemInfo.id)"
class="h-80"
:columns="[ :columns="[
{ {
key: 'state', key: 'state',

View File

@@ -319,6 +319,9 @@ const setState = async (newState) => {
/> />
</template> </template>
</UPopover> </UPopover>
<UInput
/>
</UFormGroup> </UFormGroup>
<!-- <UFormGroup <!-- <UFormGroup
label="Start:" label="Start:"

View File

@@ -853,6 +853,10 @@ export const useDataStore = defineStore('data', () => {
return workingtimes.value.filter(i => i.profile === profileId) return workingtimes.value.filter(i => i.profile === profileId)
}) })
const getStartedWorkingTimes = computed(() => () => {
return workingtimes.value.filter(i => !i.end)
})
const getStockByProductId = computed(() => (productId) => { const getStockByProductId = computed(() => (productId) => {
let productMovements = movements.value.filter(movement => movement.productId === productId) let productMovements = movements.value.filter(movement => movement.productId === productId)
@@ -1254,6 +1258,7 @@ export const useDataStore = defineStore('data', () => {
getTextTemplatesByDocumentType, getTextTemplatesByDocumentType,
getCreatedDocumentsByProject, getCreatedDocumentsByProject,
getWorkingTimesByProfileId, getWorkingTimesByProfileId,
getStartedWorkingTimes,
getStockByProductId, getStockByProductId,
getIncomingInvoicesByVehicleId, getIncomingInvoicesByVehicleId,
getEventTypes, getEventTypes,