BETA for new DB
This commit is contained in:
@@ -16,9 +16,15 @@ const router = useRouter()
|
||||
const items = ref([])
|
||||
const dataLoaded = ref(false)
|
||||
|
||||
const statementallocations = ref([])
|
||||
const incominginvoices = ref([])
|
||||
|
||||
const setupPage = async () => {
|
||||
items.value = await useEntities("accounts").selectSpecial()
|
||||
|
||||
statementallocations.value = (await useEntities("statementallocations").select("*, bs_id(*)"))
|
||||
incominginvoices.value = (await useEntities("incominginvoices").select("*, vendor(*)"))
|
||||
|
||||
items.value = await Promise.all(items.value.map(async (i) => {
|
||||
let renderedAllocationsTemp = await renderedAllocations(i.id)
|
||||
let saldo = getSaldo(renderedAllocationsTemp)
|
||||
@@ -37,22 +43,22 @@ const setupPage = async () => {
|
||||
|
||||
const renderedAllocations = async (account) => {
|
||||
|
||||
let statementallocations = (await useEntities("statementallocations").select("*, bs_id(*)")).filter(i => i.account === account)
|
||||
let incominginvoices = (await useEntities("incominginvoices").select("*, vendor(*)")).filter(i => i.accounts.find(x => x.account === account))
|
||||
let statementallocationslocal = statementallocations.value.filter(i => i.account === account)
|
||||
let incominginvoiceslocal = incominginvoices.value.filter(i => i.accounts.find(x => x.account === account))
|
||||
|
||||
let tempstatementallocations = statementallocations.map(i => {
|
||||
let tempstatementallocations = statementallocationslocal.map(i => {
|
||||
return {
|
||||
...i,
|
||||
type: "statementallocation",
|
||||
date: i.bs_id.date,
|
||||
partner: i.bs_id ? (i.bs_id.debName ? i.bs_id.debName : (i.bs_id.credName ? i.bs_id.credName : '')) : ''
|
||||
date: i.bankstatement.date,
|
||||
partner: i.bankstatement ? (i.bankstatement.debName ? i.bankstatement.debName : (i.bankstatement.credName ? i.bankstatement.credName : '')) : ''
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
let incominginvoicesallocations = []
|
||||
|
||||
incominginvoices.forEach(i => {
|
||||
incominginvoiceslocal.forEach(i => {
|
||||
|
||||
incominginvoicesallocations.push(...i.accounts.filter(x => x.account === account).map(x => {
|
||||
return {
|
||||
|
||||
@@ -65,8 +65,8 @@ const setup = async () => {
|
||||
|
||||
console.log(openDocuments.value)
|
||||
|
||||
allocatedDocuments.value = documents.filter(i => i.statementallocations.find(x => x.bs_id === itemInfo.value.id))
|
||||
allocatedIncomingInvoices.value = incominginvoices.filter(i => i.statementallocations.find(x => x.bs_id === itemInfo.value.id))
|
||||
allocatedDocuments.value = documents.filter(i => i.statementallocations.find(x => x.bankstatement === itemInfo.value.id))
|
||||
allocatedIncomingInvoices.value = incominginvoices.filter(i => i.statementallocations.find(x => x.bankstatement === itemInfo.value.id))
|
||||
console.log(allocatedDocuments.value)
|
||||
console.log(allocatedIncomingInvoices.value)
|
||||
openIncomingInvoices.value = (await useEntities("incominginvoices").select("*, statementallocations(*), vendor(*)")).filter(i => !i.archived && i.statementallocations.reduce((n,{amount}) => n + amount, 0).toFixed(2) !== getInvoiceSum(i,false))
|
||||
@@ -611,7 +611,7 @@ const archiveStatement = async () => {
|
||||
variant="outline"
|
||||
icon="i-heroicons-check"
|
||||
:disabled="!accountToSave"
|
||||
@click="saveAllocation({bs_id: itemInfo.id, amount: manualAllocationSum, account: accountToSave, description: allocationDescription })"
|
||||
@click="saveAllocation({bankstatement: itemInfo.id, amount: manualAllocationSum, account: accountToSave, description: allocationDescription })"
|
||||
/>
|
||||
<UButton
|
||||
@click="accountToSave = ''"
|
||||
@@ -677,7 +677,7 @@ const archiveStatement = async () => {
|
||||
variant="outline"
|
||||
icon="i-heroicons-check"
|
||||
:disabled="!ownAccountToSave"
|
||||
@click="saveAllocation({bs_id: itemInfo.id, amount: manualAllocationSum, ownaccount: ownAccountToSave, description: allocationDescription })"
|
||||
@click="saveAllocation({bankstatement: itemInfo.id, amount: manualAllocationSum, ownaccount: ownAccountToSave, description: allocationDescription })"
|
||||
/>
|
||||
<UButton
|
||||
@click="accountToSave = ''"
|
||||
@@ -715,7 +715,7 @@ const archiveStatement = async () => {
|
||||
variant="outline"
|
||||
icon="i-heroicons-check"
|
||||
:disabled="!customerAccountToSave"
|
||||
@click="saveAllocation({bs_id: itemInfo.id, amount: manualAllocationSum, customer: customerAccountToSave, description: allocationDescription })"
|
||||
@click="saveAllocation({bankstatement: itemInfo.id, amount: manualAllocationSum, customer: customerAccountToSave, description: allocationDescription })"
|
||||
/>
|
||||
<UButton
|
||||
@click="customerAccountToSave = ''"
|
||||
@@ -753,7 +753,7 @@ const archiveStatement = async () => {
|
||||
variant="outline"
|
||||
icon="i-heroicons-check"
|
||||
:disabled="!vendorAccountToSave"
|
||||
@click="saveAllocation({bs_id: itemInfo.id, amount: manualAllocationSum, vendor: vendorAccountToSave, description: allocationDescription })"
|
||||
@click="saveAllocation({bankstatement: itemInfo.id, amount: manualAllocationSum, vendor: vendorAccountToSave, description: allocationDescription })"
|
||||
/>
|
||||
<UButton
|
||||
@click="vendorAccountToSave = ''"
|
||||
@@ -811,7 +811,7 @@ const archiveStatement = async () => {
|
||||
variant="outline"
|
||||
class="mr-3"
|
||||
v-if="!itemInfo.statementallocations.find(i => i.cd_id === document.id)"
|
||||
@click="saveAllocation({cd_id: document.id, bs_id: itemInfo.id, amount: Number(Number(document.openSum) < manualAllocationSum ? document.openSum : manualAllocationSum), description: allocationDescription})"
|
||||
@click="saveAllocation({cd_id: document.id, bankstatement: itemInfo.id, amount: Number(Number(document.openSum) < manualAllocationSum ? document.openSum : manualAllocationSum), description: allocationDescription})"
|
||||
/>
|
||||
|
||||
<UButton
|
||||
@@ -836,7 +836,7 @@ const archiveStatement = async () => {
|
||||
variant="outline"
|
||||
class="mr-3"
|
||||
v-if="!itemInfo.statementallocations.find(i => i.ii_id === item.id)"
|
||||
@click="saveAllocation({ii_id: item.id, bs_id: itemInfo.id, amount: Number(Math.abs(getInvoiceSum(item,true)) > Math.abs(manualAllocationSum) ? manualAllocationSum : getInvoiceSum(item,true)), description: allocationDescription})"
|
||||
@click="saveAllocation({ii_id: item.id, bankstatement: itemInfo.id, amount: Number(Math.abs(getInvoiceSum(item,true)) > Math.abs(manualAllocationSum) ? manualAllocationSum : getInvoiceSum(item,true)), description: allocationDescription})"
|
||||
/>
|
||||
<UButton
|
||||
variant="outline"
|
||||
|
||||
@@ -26,6 +26,23 @@ const selectedUser = ref(platformIsNative ? auth.user.id : null)
|
||||
|
||||
const canViewAll = computed(() => auth.permissions.includes('staff.time.read_all'))
|
||||
|
||||
const typeLabel = {
|
||||
work: "Arbeitszeit",
|
||||
vacation: "Urlaub",
|
||||
sick: "Krankheit",
|
||||
holiday: "Feiertag",
|
||||
other: "Sonstiges"
|
||||
}
|
||||
|
||||
const typeColor = {
|
||||
work: "gray",
|
||||
vacation: "yellow",
|
||||
sick: "rose",
|
||||
holiday: "blue",
|
||||
other: "gray"
|
||||
}
|
||||
|
||||
|
||||
async function loadUsers() {
|
||||
if (!canViewAll.value) return
|
||||
// Beispiel: User aus Supabase holen
|
||||
@@ -171,28 +188,65 @@ onMounted(async () => {
|
||||
{ key: 'started_at', label: 'Start' },
|
||||
{ key: 'stopped_at', label: 'Ende' },
|
||||
{ key: 'duration_minutes', label: 'Dauer' },
|
||||
{ key: 'user', label: 'Mitarbeiter' },
|
||||
{ key: 'type', label: 'Typ' },
|
||||
{ key: 'description', label: 'Beschreibung' },
|
||||
]"
|
||||
]"
|
||||
>
|
||||
<template #state-data="{ row }">
|
||||
<span v-if="row.state === 'approved'" class="text-primary-500">Genehmigt</span>
|
||||
<span v-else-if="row.state === 'submitted'" class="text-cyan-500">Eingereicht</span>
|
||||
<span v-else-if="row.state === 'draft'" class="text-red-500">Entwurf</span>
|
||||
</template>
|
||||
|
||||
<template #started_at-data="{ row }">
|
||||
{{ useNuxtApp().$dayjs(row.started_at).format("DD.MM.YY HH:mm") }}
|
||||
<template #type-data="{ row }">
|
||||
<UBadge :color="typeColor[row.type] || 'gray'">
|
||||
{{ typeLabel[row.type] || row.type }}
|
||||
</UBadge>
|
||||
</template>
|
||||
|
||||
<!-- START -->
|
||||
<template #started_at-data="{ row }">
|
||||
<!-- Urlaub / Krankheit → nur Tag -->
|
||||
<span v-if="row.type === 'vacation' || row.type === 'sick'">
|
||||
{{ useNuxtApp().$dayjs(row.started_at).format("DD.MM.YY") }}
|
||||
</span>
|
||||
|
||||
<!-- Arbeitszeit / andere → Datum + Uhrzeit -->
|
||||
<span v-else>
|
||||
{{ useNuxtApp().$dayjs(row.started_at).format("DD.MM.YY HH:mm") }}
|
||||
</span>
|
||||
</template>
|
||||
|
||||
|
||||
<!-- ENDE -->
|
||||
<template #stopped_at-data="{ row }">
|
||||
<span v-if="row.stopped_at">
|
||||
<span v-if="!row.stopped_at" class="text-primary-500 font-medium">
|
||||
läuft...
|
||||
</span>
|
||||
|
||||
<!-- Urlaub / Krankheit → nur Tag -->
|
||||
<span v-else-if="row.type === 'vacation' || row.type === 'sick'">
|
||||
{{ useNuxtApp().$dayjs(row.stopped_at).format("DD.MM.YY") }}
|
||||
</span>
|
||||
|
||||
<!-- Arbeitszeit / andere → Datum + Uhrzeit -->
|
||||
<span v-else>
|
||||
{{ useNuxtApp().$dayjs(row.stopped_at).format("DD.MM.YY HH:mm") }}
|
||||
</span>
|
||||
<span v-else class="text-primary-500 font-medium">läuft...</span>
|
||||
</template>
|
||||
|
||||
<template #duration_minutes-data="{ row }">
|
||||
{{ row.duration_minutes ? useFormatDuration(row.duration_minutes) : "-" }}
|
||||
|
||||
<!-- Urlaub / Krankheit → Tage anzeigen -->
|
||||
<span v-if="row.type === 'vacation' || row.type === 'sick'">
|
||||
<!-- {{ useFormatDurationDays(row.startet_at, row.stopped_at) }}-->--
|
||||
</span>
|
||||
|
||||
<!-- Arbeitszeit / andere → Minutenformat -->
|
||||
<span v-else>
|
||||
{{ row.duration_minutes ? useFormatDuration(row.duration_minutes) : "-" }}
|
||||
</span>
|
||||
|
||||
</template>
|
||||
|
||||
<template #actions-data="{ row }">
|
||||
@@ -218,6 +272,14 @@ onMounted(async () => {
|
||||
/>
|
||||
</UTooltip>
|
||||
</template>
|
||||
<template #user-data="{ row }">
|
||||
{{users.find(i => i.user_id === row.user_id) ? users.find(i => i.user_id === row.user_id).full_name : ""}}
|
||||
</template>
|
||||
<template #description-data="{ row }">
|
||||
<span v-if="row.type === 'vacation'">{{row.vacation_reason}}</span>
|
||||
<span v-else-if="row.type === 'sick'">{{row.sick_reason}}</span>
|
||||
<span v-else>{{row.description}}</span>
|
||||
</template>
|
||||
</UTable>
|
||||
</UDashboardPanelContent>
|
||||
</template>
|
||||
@@ -284,9 +346,16 @@ onMounted(async () => {
|
||||
@click="handleEdit(row)"
|
||||
>
|
||||
<div class="flex justify-between items-center">
|
||||
<p class="font-semibold">
|
||||
{{ row.description || 'Keine Beschreibung' }}
|
||||
</p>
|
||||
<div class="font-semibold flex items-center gap-2">
|
||||
<span>{{ row.description || 'Keine Beschreibung' }}</span>
|
||||
|
||||
<UBadge
|
||||
:color="typeColor[row.type]"
|
||||
class="text-xs"
|
||||
>
|
||||
{{ typeLabel[row.type] }}
|
||||
</UBadge>
|
||||
</div>
|
||||
|
||||
<UBadge
|
||||
:color="{
|
||||
@@ -359,5 +428,12 @@ onMounted(async () => {
|
||||
</template>
|
||||
|
||||
<!-- MODAL -->
|
||||
<StaffTimeEntryModal v-model="showModal" :entry="editEntry" @saved="load" />
|
||||
<StaffTimeEntryModal
|
||||
v-model="showModal"
|
||||
:entry="editEntry"
|
||||
@saved="load"
|
||||
:users="users"
|
||||
:can-select-user="canViewAll"
|
||||
:default-user-id="selectedUser"
|
||||
/>
|
||||
</template>
|
||||
|
||||
Reference in New Issue
Block a user