This commit is contained in:
2024-06-02 21:39:26 +02:00
parent 4cd4a9c7c4
commit e139eb771c
9 changed files with 498 additions and 439 deletions

View File

@@ -312,7 +312,7 @@ let links = computed(() => {
... dataStore.ownTenant.features.vehicles ? [{ ... dataStore.ownTenant.features.vehicles ? [{
label: "Fahrzeuge", label: "Fahrzeuge",
to: "/vehicles", to: "/vehicles",
icon: "i-heroicons-truck" icon: "i-heroicons-truck",
}] : [], }] : [],
{ {
label: "Stammdaten", label: "Stammdaten",
@@ -476,7 +476,7 @@ const footerLinks = [/*{
<UDashboardSearchButton label="Suche..."/> <UDashboardSearchButton label="Suche..."/>
</template> </template>
<UDashboardSidebarLinks :links="links" > <UDashboardSidebarLinks :links="links">
</UDashboardSidebarLinks> </UDashboardSidebarLinks>
@@ -540,5 +540,7 @@ const footerLinks = [/*{
</template> </template>
<style scoped> <style scoped>
.testclass {
color: red;
}
</style> </style>

View File

@@ -1,3 +1,116 @@
<script setup>
import dayjs from "dayjs";
definePageMeta({
middleware: "auth"
})
defineShortcuts({
'/': () => {
//console.log(searchinput)
//searchinput.value.focus()
document.getElementById("searchinput").focus()
},
'escape': () => {
//console.log(searchinput)
//searchinput.value.focus()
showStatementModal.value = false
}
})
const dataStore = useDataStore()
const router = useRouter()
const supabase = useSupabaseClient()
const bankstatements = ref([])
const setupPage = async () => {
bankstatements.value = (await supabase.from("bankstatements").select("*, statementallocations(*)").eq('tenant', dataStore.currentTenant).order("date", {ascending:false})).data
}
const selectedStatement = ref(null)
const showStatementModal = ref(false)
const templateColumns = [
{
key: "account",
label: "Konto",
sortable: true
},{
key: "valueDate",
label: "Valuta",
sortable: true
},
{
key: "amount",
label: "Betrag",
sortable: true
},
{
key: "openAmount",
label: "Offener Betrag",
sortable: true
},
{
key: "partner",
label: "Name",
sortable: true
},
{
key: "text",
label: "Beschreibung",
sortable: true
}
]
const selectedColumns = ref(templateColumns)
const columns = computed(() => templateColumns.filter((column) => selectedColumns.value.includes(column)))
const searchString = ref('')
const filterAccount = ref(dataStore.bankAccounts || [])
const showOnlyNotAssigned = ref(true)
const displayCurrency = (value, currency = "€") => {
return `${Number(value).toFixed(2).replace(".",",")} ${currency}`
}
const getDocumentSum = (doc) => {
let sum = 0
doc.rows.forEach(row => {
if(row.mode === "normal" || row.mode === "service" || row.mode === "free") {
sum += row.quantity * row.price * (1 - row.discountPercent / 100) * (1 + row.taxPercent / 100)
}
})
return sum
}
const calculateOpenSum = (statement) => {
let startingAmount = statement.amount || 0
statement.statementallocations.forEach(item => {
if(item.cd_id) {
startingAmount = startingAmount - item.amount
} else if(item.ii_id) {
startingAmount = Number(startingAmount) + item.amount
}
})
return startingAmount.toFixed(2)
}
const filteredRows = computed(() => {
return useSearch(searchString.value, bankstatements.value.filter(i => filterAccount.value.find(x => x.id === i.account) && (showOnlyNotAssigned.value ? Number(calculateOpenSum(i)) !== 0 : true)))
})
setupPage()
</script>
<template> <template>
<UDashboardNavbar title="Bankbuchungen"> <UDashboardNavbar title="Bankbuchungen">
<template #right> <template #right>
@@ -161,104 +274,7 @@
</UModal> </UModal>
</template> </template>
<script setup>
import dayjs from "dayjs";
definePageMeta({
middleware: "auth"
})
defineShortcuts({
'/': () => {
//console.log(searchinput)
//searchinput.value.focus()
document.getElementById("searchinput").focus()
},
'escape': () => {
//console.log(searchinput)
//searchinput.value.focus()
showStatementModal.value = false
}
})
const dataStore = useDataStore()
const router = useRouter()
const selectedStatement = ref(null)
const showStatementModal = ref(false)
const templateColumns = [
{
key: "account",
label: "Konto",
sortable: true
},{
key: "valueDate",
label: "Valuta",
sortable: true
},
{
key: "amount",
label: "Betrag",
sortable: true
},
{
key: "openAmount",
label: "Offener Betrag",
sortable: true
},
{
key: "partner",
label: "Name",
sortable: true
},
{
key: "text",
label: "Beschreibung",
sortable: true
}
]
const selectedColumns = ref(templateColumns)
const columns = computed(() => templateColumns.filter((column) => selectedColumns.value.includes(column)))
const searchString = ref('')
const filterAccount = ref(dataStore.bankAccounts || [])
const showOnlyNotAssigned = ref(true)
const displayCurrency = (value, currency = "€") => {
return `${Number(value).toFixed(2).replace(".",",")} ${currency}`
}
const getDocumentSum = (doc) => {
let sum = 0
doc.rows.forEach(row => {
if(row.mode === "normal" || row.mode === "service" || row.mode === "free") {
sum += row.quantity * row.price * (1 - row.discountPercent / 100) * (1 + row.taxPercent / 100)
}
})
return sum
}
const calculateOpenSum = (statement) => {
let startingAmount = statement.amount
statement.assignments.forEach(item => {
if(item.type === "createdDocument") {
let doc = dataStore.getCreatedDocumentById(item.id)
startingAmount = startingAmount - getDocumentSum(doc)
}
})
return startingAmount.toFixed(2)
}
const filteredRows = computed(() => {
return useSearch(searchString.value, dataStore.bankstatements.filter(i => filterAccount.value.find(x => x.id === i.account) && (showOnlyNotAssigned.value ? Number(calculateOpenSum(i)) !== 0 : true)))
})
</script>
<style scoped> <style scoped>

View File

@@ -16,16 +16,26 @@ const dataStore = useDataStore()
const route = useRoute() const route = useRoute()
const router = useRouter() const router = useRouter()
const mode = ref(route.params.mode || "show") const mode = ref(route.params.mode || "show")
const supabase = useSupabaseClient()
const itemInfo = ref({}) const itemInfo = ref({statementallocations:[]})
const oldItemInfo = ref({}) const oldItemInfo = ref({})
const setup = () => { const openDocuments = ref([])
const setup = async () => {
if(route.params.id) { if(route.params.id) {
itemInfo.value = dataStore.bankstatements.find(i => i.id === Number(route.params.id)) itemInfo.value = (await supabase.from("bankstatements").select("*, statementallocations(*)").eq("id",route.params.id).single()).data //dataStore.bankstatements.find(i => i.id === Number(route.params.id))
} }
if(itemInfo.value) oldItemInfo.value = JSON.parse(JSON.stringify(itemInfo.value)) if(itemInfo.value) oldItemInfo.value = JSON.parse(JSON.stringify(itemInfo.value))
openDocuments.value = (await supabase.from("createddocuments").select("*, statementallocations(*)")).data.filter(i => i.statementallocations.length === 0 || i.statementallocations.find(x => x.bs_id === itemInfo.value.id))
let allocations = (await supabase.from("createddocuments").select(`*, statementallocations(*)`).eq("id",50)).data
} }
const displayCurrency = (value, currency = "€") => { const displayCurrency = (value, currency = "€") => {
@@ -57,18 +67,29 @@ const getInvoiceSum = (invoice) => {
} }
const calculateOpenSum = computed(() => { const calculateOpenSum = computed(() => {
let startingAmount = itemInfo.value.amount let startingAmount = itemInfo.value.amount || 0
itemInfo.value.assignments.forEach(item => { itemInfo.value.statementallocations.forEach(item => {
if(item.type === "createdDocument") { if(item.cd_id) {
let doc = dataStore.getCreatedDocumentById(item.id) startingAmount = startingAmount - item.amount
startingAmount = startingAmount - getDocumentSum(doc) } else if(item.ii_id) {
startingAmount = Number(startingAmount) + item.amount
} }
}) })
return startingAmount.toFixed(2) return startingAmount.toFixed(2)
}) })
const saveAllocations = async () => {
let allocationsToBeSaved = itemInfo.value.statementallocations.filter(i => !i.id)
for await (let i of allocationsToBeSaved) {
await dataStore.createNewItem("statementallocations", i)
}
}
setup() setup()
@@ -89,13 +110,13 @@ setup()
</template> </template>
<template #center> <template #center>
<h1 <h1
:class="['text-xl','font-medium', ... itemInfo.incomingInvoice || itemInfo.createdDocument ? ['text-primary-500'] : ['text-rose-600']]" :class="['text-xl','font-medium', Number(calculateOpenSum) === 0 ? ['text-primary-500'] : ['text-rose-600']]"
>Kontobewegung bearbeiten</h1> >Kontobewegung bearbeiten</h1>
</template> </template>
<template #right> <template #right>
<UButton <UButton
v-if="mode === 'edit'" v-if="mode === 'edit'"
@click="dataStore.updateItem('bankstatements',itemInfo,oldItemInfo)" @click="saveAllocations"
> >
Speichern Speichern
</UButton> </UButton>
@@ -160,11 +181,11 @@ setup()
<span v-if="itemInfo.amount > 0" class="text-primary-500 font-semibold">{{itemInfo.amount.toFixed(2).replace(".",",")}} {{itemInfo.currency}}</span> <span v-if="itemInfo.amount > 0" class="text-primary-500 font-semibold">{{itemInfo.amount.toFixed(2).replace(".",",")}} {{itemInfo.currency}}</span>
<span v-else-if="itemInfo.amount < 0" class="text-rose-600 font-semibold">{{itemInfo.amount.toFixed(2).replace(".",",")}} {{itemInfo.currency}}</span> <span v-else-if="itemInfo.amount < 0" class="text-rose-600 font-semibold">{{itemInfo.amount.toFixed(2).replace(".",",")}} {{itemInfo.currency}}</span>
<span v-else>{{itemInfo.amount.toFixed(2).replace(".",",")}} {{itemInfo.currency}}</span> <span v-else>{{(itemInfo.amount || 0).toFixed(2).replace(".",",")}} {{itemInfo.currency}}</span>
</div> </div>
</template> </template>
<table class="w-full"> <table class="w-full" v-if="itemInfo.id">
<tr class="flex-row flex justify-between"> <tr class="flex-row flex justify-between">
<td> <td>
<span class="font-semibold">Buchungsdatum:</span> <span class="font-semibold">Buchungsdatum:</span>
@@ -207,26 +228,36 @@ setup()
</tr> </tr>
<tr class="flex-row flex justify-between"> <tr class="flex-row flex justify-between">
<td colspan="2"> <td colspan="2">
<span class="font-semibold">Verknüpftes Dokument:</span> <span class="font-semibold">Verknüpfte Dokumente:</span>
</td> </td>
</tr> </tr>
<tr <tr
class="flex-row flex justify-between mb-3" class="flex-row flex justify-between mb-3"
v-for="item in itemInfo.assignments" v-for="item in itemInfo.statementallocations"
> >
<td> <td>
<!-- <span v-if="itemInfo.createdDocument"><nuxt-link :to="`/createDocument/show/${itemInfo.createdDocument}`">{{dataStore.createddocuments.find(i => i.id === itemInfo.createdDocument).documentNumber}}</nuxt-link></span> <!-- <span v-if="itemInfo.createdDocument"><nuxt-link :to="`/createDocument/show/${itemInfo.createdDocument}`">{{dataStore.createddocuments.find(i => i.id === itemInfo.createdDocument).documentNumber}}</nuxt-link></span>
<span v-else-if="itemInfo.incomingInvoice"><nuxt-link :to="`/incominInvoices/show/${itemInfo.incomingInvoice}`">{{dataStore.getIncomingInvoiceById(itemInfo.incomingInvoice).reference}}</nuxt-link></span>--> <span v-else-if="itemInfo.incomingInvoice"><nuxt-link :to="`/incominInvoices/show/${itemInfo.incomingInvoice}`">{{dataStore.getIncomingInvoiceById(itemInfo.incomingInvoice).reference}}</nuxt-link></span>-->
<span v-if="item.type === 'createdDocument'"> <span v-if="item.cd_id">
{{dataStore.getCreatedDocumentById(item.id).documentNumber}} {{dataStore.getCreatedDocumentById(item.cd_id).documentNumber}}
</span>
<span v-else-if="item.ii_id">
{{dataStore.getVendorById(dataStore.getIncomingInvoiceById(item.ii_id).vendor).name}} - {{dataStore.getIncomingInvoiceById(item.ii_id).reference}}
</span> </span>
</td> </td>
<td> <td>
<UButton <UButton
variant="outline" variant="outline"
icon="i-heroicons-arrow-right-end-on-rectangle" icon="i-heroicons-arrow-right-end-on-rectangle"
@click="router.push(`/createDocument/show/${item.id}`)" @click="router.push(`/createDocument/show/${item.cd_id}`)"
v-if="item.cd_id"
/>
<UButton
variant="outline"
icon="i-heroicons-arrow-right-end-on-rectangle"
@click="router.push(`/incominginvoices/show/${item.ii_id}`)"
v-else-if="item.ii_id"
/> />
</td> </td>
</tr> </tr>
@@ -253,15 +284,13 @@ setup()
class="w-2/5 mx-auto" class="w-2/5 mx-auto"
v-if="itemInfo.amount > 0 " v-if="itemInfo.amount > 0 "
> >
<UDivider <UDivider>
label="Test"
>
<span>Offene Summe: {{displayCurrency(calculateOpenSum)}}</span> <span>Offene Summe: {{displayCurrency(calculateOpenSum)}}</span>
</UDivider> </UDivider>
<UCard <UCard
class="mt-5" class="mt-5"
:ui="{ring: itemInfo.assignments.find(i => i.id === document.id) ? 'ring-primary-500' : 'ring-gray-200 dark:ring-gray-800'}" :ui="{ring: itemInfo.statementallocations.find(i => i.cd_id === document.id) ? 'ring-primary-500' : 'ring-gray-200 dark:ring-gray-800'}"
v-for="document in dataStore.getOpenDocuments()" v-for="document in openDocuments"
> >
<template #header> <template #header>
<div class="flex flex-row justify-between"> <div class="flex flex-row justify-between">
@@ -273,57 +302,68 @@ setup()
icon="i-heroicons-check" icon="i-heroicons-check"
variant="outline" variant="outline"
class="mr-3" class="mr-3"
v-if="!itemInfo.assignments.find(i => i.id === document.id)" v-if="!itemInfo.statementallocations.find(i => i.cd_id === document.id)"
@click="itemInfo.assignments.push({type: 'createdDocument',id: document.id})" @click="itemInfo.statementallocations.push({cd_id: document.id, bs_id: itemInfo.id, amount: Number(getDocumentSum(document))})"
/> />
<UButton <UButton
icon="i-heroicons-x-mark" icon="i-heroicons-x-mark"
variant="outline" variant="outline"
color="rose" color="rose"
v-if="itemInfo.assignments.find(i => i.id === document.id)" class="mr-3"
@click="itemInfo.assignments = itemInfo.assignments.filter(i => i.id !== document.id)" v-if="itemInfo.statementallocations.find(i => i.cd_id === document.id)"
@click="itemInfo.statementallocations = itemInfo.statementallocations.filter(i => i.cd_id !== document.id)"
/>
<UButton
variant="outline"
icon="i-heroicons-arrow-right-end-on-rectangle"
@click="router.push(`/createDocument/show/${document.id}`)"
/> />
</UCard> </UCard>
</div> </div>
<div
class="w-2/5 mx-auto"
v-if="itemInfo.amount < 0 "
<UCard
class="w-4/5 mx-auto mt-5"
v-else-if="itemInfo.amount < 0 && !itemInfo.incomingInvoice"
v-for="invoice in dataStore.getOpenIncomingInvoices()"
> >
<template #header> <UDivider>
<div class="flex flex-row justify-between"> <span>Offene Summe: {{displayCurrency(calculateOpenSum)}}</span>
<span>{{dataStore.getVendorById(invoice.vendor).name}} - {{invoice.reference}}</span> </UDivider>
<span class="font-semibold text-rose-600">-{{displayCurrency(getInvoiceSum(invoice))}}</span> <UCard
</div> class="mt-5"
</template> :ui="{ring: itemInfo.assignments.find(i => i.id === invoice.id) ? 'ring-primary-500' : 'ring-gray-200 dark:ring-gray-800'}"
<table class="w-full"> v-for="invoice in dataStore.getOpenIncomingInvoices()"
<tr class="flex flex-row justify-between"> >
<td><span class="font-semibold">Belegdatum:</span></td> <template #header>
<td>{{dayjs(invoice.date).format("DD.MM.YYYY")}}</td> <div class="flex flex-row justify-between">
</tr> <span>{{dataStore.getVendorById(invoice.vendor).name}} - {{invoice.reference}}</span>
<tr class="flex flex-row justify-between"> <span class="font-semibold text-rose-600">-{{displayCurrency(getInvoiceSum(invoice))}}</span>
<td><span class="font-semibold">Fälligkeitsdatum:</span></td> </div>
<td>{{dayjs(invoice.dueDate).format("DD.MM.YYYY")}}</td> </template>
</tr> <UButton
<tr class="flex flex-row justify-between"> icon="i-heroicons-check"
<td colspan="2"><span class="font-semibold">Beschreibung:</span></td> variant="outline"
</tr> class="mr-3"
<tr class="flex flex-row justify-between"> v-if="!itemInfo.assignments.find(i => i.id === invoice.id)"
<td colspan="2">{{invoice.description}}</td> @click="itemInfo.assignments.push({type: 'incomingInvoice',id: invoice.id})"
</tr> />
</table> <UButton
</UCard> icon="i-heroicons-x-mark"
variant="outline"
color="rose"
class="mr-3"
v-if="itemInfo.assignments.find(i => i.id === invoice.id)"
@click="itemInfo.assignments = itemInfo.assignments.filter(i => i.id !== invoice.id)"
/>
<UButton
variant="outline"
icon="i-heroicons-arrow-right-end-on-rectangle"
@click="router.push(`/incominginvoices/show/${invoice.id}`)"
/>
</UCard>
</div>
</UDashboardPanelContent> </UDashboardPanelContent>
</template> </template>
<style scoped> <style scoped>

View File

@@ -482,6 +482,7 @@ setupPage()
</UButton> </UButton>
<UButton <UButton
@click="closeDocument" @click="closeDocument"
v-if="itemInfo.id"
> >
Fertigstellen Fertigstellen
</UButton> </UButton>

View File

@@ -106,7 +106,7 @@
<span :class="dayjs(row.dueDate).diff(dayjs()) <= 0 ? ['text-rose-500'] : '' ">{{row.dueDate ? dayjs(row.dueDate).format("DD.MM.YY") : ''}}</span> <span :class="dayjs(row.dueDate).diff(dayjs()) <= 0 ? ['text-rose-500'] : '' ">{{row.dueDate ? dayjs(row.dueDate).format("DD.MM.YY") : ''}}</span>
</template> </template>
<template #paid-data="{row}"> <template #paid-data="{row}">
<span v-if="dataStore.bankstatements.find(x => x.assignments.find(y => y.id === row.id))" class="text-primary-500">Bezahlt</span> <span v-if="dataStore.bankstatements.find(x => x.assignments.find(y => y.type === 'createdDocument' && y.id === row.id))" class="text-primary-500">Bezahlt</span>
<span v-else :class="dayjs(row.dueDate).diff(dayjs()) <= 0 ? ['text-rose-500'] : ['text-cyan-500'] ">Offen</span> <span v-else :class="dayjs(row.dueDate).diff(dayjs()) <= 0 ? ['text-rose-500'] : ['text-cyan-500'] ">Offen</span>
<!-- {{dataStore.bankstatements.find(x => x.assignments.find(y => y.id === row.id)) ? true : false}}--> <!-- {{dataStore.bankstatements.find(x => x.assignments.find(y => y.id === row.id)) ? true : false}}-->
</template> </template>

View File

@@ -186,7 +186,6 @@ setupPage()
:render-headline="true" :render-headline="true"
/> />
</UCard> </UCard>
</div> </div>
</div> </div>
@@ -194,15 +193,8 @@ setupPage()
<UCard class="mt-5" v-else> <UCard class="mt-5" v-else>
<div v-if="item.label === 'Informationen'" class="flex">
<div v-if="item.label === 'Projekte'">
</div>
<div v-else-if="item.label === 'Projekte'">
<Toolbar> <Toolbar>
<UButton <UButton
@click="router.push(`/projects/create?customer=${currentItem.id}`)" @click="router.push(`/projects/create?customer=${currentItem.id}`)"

View File

@@ -187,294 +187,296 @@ setupPage()
</UButton> </UButton>
</template> </template>
</UDashboardNavbar> </UDashboardNavbar>
<div v-if="!itemInfo.document"> <UDashboardPanelContent>
<!-- <div v-if="availableDocuments.length === 0" class="w-1/2 mx-auto text-center"> <div v-if="!itemInfo.document">
<p class="text-2xl mt-5">Keine Dokumente zur Auswahl vefügbar</p> <!-- <div v-if="availableDocuments.length === 0" class="w-1/2 mx-auto text-center">
<UButton <p class="text-2xl mt-5">Keine Dokumente zur Auswahl vefügbar</p>
@click="router.push(`/documents`)" <UButton
class="mt-5" @click="router.push(`/documents`)"
variant="outline" class="mt-5"
> variant="outline"
Zu den Dokumenten >
</UButton> Zu den Dokumenten
</div>--> </UButton>
</div>-->
<DocumentList <DocumentList
:documents="availableDocuments" :documents="availableDocuments"
:return-document-id="true" :return-document-id="true"
@selectDocument="(documentId) => itemInfo.document = documentId" @selectDocument="(documentId) => itemInfo.document = documentId"
/> />
</div> </div>
<div <div
v-else v-else
class="flex justify-between mt-5" class="flex justify-between mt-5"
> >
<object <object
v-if="currentDocument ? currentDocument.url : false" v-if="currentDocument ? currentDocument.url : false"
:data="currentDocument.url + '#toolbar=0&navpanes=0&scrollbar=0&statusbar=0&messages=0&scrollbar=0'" :data="currentDocument.url + '#toolbar=0&navpanes=0&scrollbar=0&statusbar=0&messages=0&scrollbar=0'"
type="application/pdf" type="application/pdf"
class="mx-5 documentPreview w-full" class="mx-5 documentPreview w-full"
/> />
<div class="w-3/5 mx-5"> <div class="w-3/5 mx-5">
<div v-if="mode === 'show'"> <div v-if="mode === 'show'">
<div class="truncate mb-5"> <div class="truncate mb-5">
<p>Status: {{itemInfo.state}}</p> <p>Status: {{itemInfo.state}}</p>
<p>Datum: {{dayjs(itemInfo.date).format('DD.MM.YYYY')}}</p> <p>Datum: {{dayjs(itemInfo.date).format('DD.MM.YYYY')}}</p>
<p>Fälligkeitsdatum: {{dayjs(itemInfo.dueDate).format('DD.MM.YYYY')}}</p> <p>Fälligkeitsdatum: {{dayjs(itemInfo.dueDate).format('DD.MM.YYYY')}}</p>
<p>Lieferant: <nuxt-link :to="`/vendors/show/${itemInfo.vendor}`">{{dataStore.getVendorById(itemInfo.vendor).name}}</nuxt-link></p> <p>Lieferant: <nuxt-link :to="`/vendors/show/${itemInfo.vendor}`">{{dataStore.getVendorById(itemInfo.vendor).name}}</nuxt-link></p>
<p>Bezahlt: {{itemInfo.paid}}</p> <p>Bezahlt: {{itemInfo.paid}}</p>
<p>Beschreibung: {{itemInfo.description}}</p> <p>Beschreibung: {{itemInfo.description}}</p>
<!-- TODO: Buchungszeilen darstellen --> <!-- TODO: Buchungszeilen darstellen -->
</div>
<HistoryDisplay
type="incomingInvoice"
v-if="itemInfo"
:element-id="itemInfo.id"
:render-headline="true"
/>
</div> </div>
<HistoryDisplay <div v-else class=" scrollContainer">
type="incomingInvoice" <InputGroup class="mb-3">
v-if="itemInfo"
:element-id="itemInfo.id"
:render-headline="true"
/>
</div>
<div v-else class=" scrollContainer">
<InputGroup class="mb-3">
<UButton
:variant="itemInfo.expense ? 'solid' : 'outline'"
@click="itemInfo.expense = true"
>
Ausgabe
</UButton>
<UButton
:variant="!itemInfo.expense ? 'solid' : 'outline'"
@click="itemInfo.expense = false"
>
Einnahme
</UButton>
</InputGroup>
<UFormGroup label="Lieferant:" required>
<InputGroup>
<USelectMenu
v-model="itemInfo.vendor"
:options="dataStore.vendors"
option-attribute="name"
value-attribute="id"
searchable
:search-attributes="['name','vendorNumber']"
class="flex-auto"
>
<template #label>
{{dataStore.vendors.find(vendor => vendor.id === itemInfo.vendor) ? dataStore.vendors.find(vendor => vendor.id === itemInfo.vendor).name : 'Lieferant auswählen'}}
</template>
</USelectMenu>
<UButton <UButton
@click="router.push('/vendors/create')" :variant="itemInfo.expense ? 'solid' : 'outline'"
@click="itemInfo.expense = true"
> >
+ Lieferant Ausgabe
</UButton>
<UButton
:variant="!itemInfo.expense ? 'solid' : 'outline'"
@click="itemInfo.expense = false"
>
Einnahme
</UButton> </UButton>
</InputGroup> </InputGroup>
<UFormGroup label="Lieferant:" required>
</UFormGroup> <InputGroup>
<UFormGroup
class="mt-3"
label="Rechnungsreferenz:"
required
>
<UInput
v-model="itemInfo.reference"
/>
</UFormGroup>
<InputGroup class="mt-3" gap="2">
<UFormGroup label="Rechnungsdatum:" required>
<UPopover :popper="{ placement: 'bottom-start' }">
<UButton icon="i-heroicons-calendar-days-20-solid" :label="itemInfo.date ? dayjs(itemInfo.date).format('DD.MM.YYYY') : 'Datum auswählen'" />
<template #panel="{ close }">
<LazyDatePicker v-model="itemInfo.date" @close="close" />
</template>
</UPopover>
</UFormGroup>
<UFormGroup label="Fälligkeitsdatum:" required>
<UPopover :popper="{ placement: 'bottom-start' }">
<UButton icon="i-heroicons-calendar-days-20-solid" :label="itemInfo.dueDate ? dayjs(itemInfo.dueDate).format('DD.MM.YYYY') : 'Datum auswählen'" />
<template #panel="{ close }">
<LazyDatePicker v-model="itemInfo.dueDate" @close="close" />
</template>
</UPopover>
</UFormGroup>
</InputGroup>
<UFormGroup label="Beschreibung:" required>
<UTextarea
v-model="itemInfo.description"
/>
</UFormGroup>
<InputGroup class="my-3">
Brutto
<UToggle
v-model="useNetMode"
@update:model-value="itemInfo.accounts = [{account: null,amountNet: null,amountTax: null,taxType: '19'}]"
/>
Netto
</InputGroup>
<table v-if="itemInfo.accounts.length > 1">
<tr>
<td>Gesamt exkl. Steuer: </td>
<td class="text-right">{{totalCalculated.totalNet.toFixed(2)}} </td>
</tr>
<tr>
<td>19% Steuer: </td>
<td class="text-right">{{totalCalculated.totalAmount19Tax.toFixed(2)}} </td>
</tr>
<tr>
<td>Gesamt inkl. Steuer: </td>
<td class="text-right">{{totalCalculated.totalGross.toFixed(2)}} </td>
</tr>
</table>
<div
class="my-3"
v-for="(item,index) in itemInfo.accounts"
>
<UFormGroup
label="Kategorie"
class=" mb-3"
>
<USelectMenu
:options="dataStore.accounts"
option-attribute="label"
value-attribute="id"
searchable
:search-attributes="['label']"
searchable-placeholder="Suche..."
v-model="item.account"
>
<template #label>
{{dataStore.accounts.find(account => account.id === item.account) ? dataStore.accounts.find(account => account.id === item.account).label : "Keine Kategorie ausgewählt" }}
</template>
</USelectMenu>
</UFormGroup>
<UFormGroup
label="Kostenstelle"
class=" mb-3"
>
<USelectMenu
:options="dataStore.getCostCentresComposed"
option-attribute="label"
value-attribute="id"
searchable
:search-attributes="['label']"
searchable-placeholder="Suche..."
v-model="item.costCentre"
>
<template #label>
{{dataStore.getCostCentresComposed.find(account => account.id === item.costCentre) ? dataStore.getCostCentresComposed.find(account => account.id === item.costCentre).label : "Keine Kostenstelle ausgewählt" }}
</template>
</USelectMenu>
</UFormGroup>
<InputGroup>
<UFormGroup
label="Umsatzsteuer"
class="w-32"
:help="`Betrag: ${item.amountTax ? String(item.amountTax).replace('.',',') : '0,00'} €`"
>
<USelectMenu <USelectMenu
:options="taxOptions" v-model="itemInfo.vendor"
v-model="item.taxType" :options="dataStore.vendors"
value-attribute="key" option-attribute="name"
option-attribute="label" value-attribute="id"
@change="item.amountTax = Number(((item.amountNet ? item.amountNet : 0) * (Number(taxOptions.find(i => i.key === item.taxType).percentage)/100)).toFixed(2))" searchable
:search-attributes="['name','vendorNumber']"
class="flex-auto"
> >
<template #label> <template #label>
<span class="truncate">{{taxOptions.find(i => i.key === item.taxType) ? taxOptions.find(i => i.key === item.taxType).label : ""}}</span> {{dataStore.vendors.find(vendor => vendor.id === itemInfo.vendor) ? dataStore.vendors.find(vendor => vendor.id === itemInfo.vendor).name : 'Lieferant auswählen'}}
</template> </template>
</USelectMenu> </USelectMenu>
</UFormGroup> <UButton
<UFormGroup @click="router.push('/vendors/create')"
v-if="useNetMode"
label="Gesamtbetrag exkl. Steuer in EUR"
class="flex-auto"
:help="item.taxType !== null ? `Betrag inkl. Steuern: ${String(Number(item.amountNet + item.amountTax).toFixed(2)).replace('.',',')} €` : 'Zuerst Steuertyp festlegen' "
>
<UInput
type="number"
step="0.01"
v-model="item.amountNet"
:disabled="item.taxType === null"
@keyup="item.amountTax = Number((item.amountNet * (Number(item.taxType)/100)).toFixed(2))"
> >
<template #trailing> + Lieferant
<span class="text-gray-500 dark:text-gray-400 text-xs">EUR</span> </UButton>
</InputGroup>
</UFormGroup>
<UFormGroup
class="mt-3"
label="Rechnungsreferenz:"
required
>
<UInput
v-model="itemInfo.reference"
/>
</UFormGroup>
<InputGroup class="mt-3" gap="2">
<UFormGroup label="Rechnungsdatum:" required>
<UPopover :popper="{ placement: 'bottom-start' }">
<UButton icon="i-heroicons-calendar-days-20-solid" :label="itemInfo.date ? dayjs(itemInfo.date).format('DD.MM.YYYY') : 'Datum auswählen'" />
<template #panel="{ close }">
<LazyDatePicker v-model="itemInfo.date" @close="close" />
</template> </template>
</UInput> </UPopover>
</UFormGroup> </UFormGroup>
<UFormGroup
v-else
label="Gesamtbetrag inkl. Steuer in EUR"
class="flex-auto"
:help="item.taxType !== null ? `Betrag exkl. Steuern: ${item.amountNet ? String(item.amountNet.toFixed(2)).replace('.',',') : '0,00'} €` : 'Zuerst Steuertyp festlegen' "
> <UFormGroup label="Fälligkeitsdatum:" required>
<UInput <UPopover :popper="{ placement: 'bottom-start' }">
type="number" <UButton icon="i-heroicons-calendar-days-20-solid" :label="itemInfo.dueDate ? dayjs(itemInfo.dueDate).format('DD.MM.YYYY') : 'Datum auswählen'" />
step="0.01"
:disabled="item.taxType === null" <template #panel="{ close }">
v-model="item.amountGross" <LazyDatePicker v-model="itemInfo.dueDate" @close="close" />
@keyup="item.amountNet = Number((item.amountGross / (1 + Number(item.taxType)/100)).toFixed(2)),
item.amountTax = Number((item.amountGross - item.amountNet).toFixed(2))"
>
<template #trailing>
<span class="text-gray-500 dark:text-gray-400 text-xs">EUR</span>
</template> </template>
</UInput> </UPopover>
</UFormGroup> </UFormGroup>
{{item}}
</InputGroup> </InputGroup>
<UButton
class="mt-3" <UFormGroup label="Beschreibung:" required>
@click="itemInfo.accounts = [...itemInfo.accounts.slice(0,index+1),{account:null, amountNet: null, amountTax:null, taxType: '19'} , ...itemInfo.accounts.slice(index+1)]" <UTextarea
v-model="itemInfo.description"
/>
</UFormGroup>
<InputGroup class="my-3">
Brutto
<UToggle
v-model="useNetMode"
@update:model-value="itemInfo.accounts = [{account: null,amountNet: null,amountTax: null,taxType: '19'}]"
/>
Netto
</InputGroup>
<table v-if="itemInfo.accounts.length > 1">
<tr>
<td>Gesamt exkl. Steuer: </td>
<td class="text-right">{{totalCalculated.totalNet.toFixed(2)}} </td>
</tr>
<tr>
<td>19% Steuer: </td>
<td class="text-right">{{totalCalculated.totalAmount19Tax.toFixed(2)}} </td>
</tr>
<tr>
<td>Gesamt inkl. Steuer: </td>
<td class="text-right">{{totalCalculated.totalGross.toFixed(2)}} </td>
</tr>
</table>
<div
class="my-3"
v-for="(item,index) in itemInfo.accounts"
> >
Position hinzufügen
</UButton> <UFormGroup
<UButton label="Kategorie"
v-if="index !== 0" class=" mb-3"
class="mt-3" >
variant="ghost" <USelectMenu
color="rose" :options="dataStore.accounts"
@click="itemInfo.accounts = itemInfo.accounts.filter((account,itemIndex) => itemIndex !== index)" option-attribute="label"
> value-attribute="id"
Position entfernen searchable
</UButton> :search-attributes="['label']"
searchable-placeholder="Suche..."
v-model="item.account"
>
<template #label>
{{dataStore.accounts.find(account => account.id === item.account) ? dataStore.accounts.find(account => account.id === item.account).label : "Keine Kategorie ausgewählt" }}
</template>
</USelectMenu>
</UFormGroup>
<UFormGroup
label="Kostenstelle"
class=" mb-3"
>
<USelectMenu
:options="dataStore.getCostCentresComposed"
option-attribute="label"
value-attribute="id"
searchable
:search-attributes="['label']"
searchable-placeholder="Suche..."
v-model="item.costCentre"
>
<template #label>
{{dataStore.getCostCentresComposed.find(account => account.id === item.costCentre) ? dataStore.getCostCentresComposed.find(account => account.id === item.costCentre).label : "Keine Kostenstelle ausgewählt" }}
</template>
</USelectMenu>
</UFormGroup>
<InputGroup>
<UFormGroup
label="Umsatzsteuer"
class="w-32"
:help="`Betrag: ${item.amountTax ? String(item.amountTax).replace('.',',') : '0,00'} €`"
>
<USelectMenu
:options="taxOptions"
v-model="item.taxType"
value-attribute="key"
option-attribute="label"
@change="item.amountTax = Number(((item.amountNet ? item.amountNet : 0) * (Number(taxOptions.find(i => i.key === item.taxType).percentage)/100)).toFixed(2))"
>
<template #label>
<span class="truncate">{{taxOptions.find(i => i.key === item.taxType) ? taxOptions.find(i => i.key === item.taxType).label : ""}}</span>
</template>
</USelectMenu>
</UFormGroup>
<UFormGroup
v-if="useNetMode"
label="Gesamtbetrag exkl. Steuer in EUR"
class="flex-auto"
:help="item.taxType !== null ? `Betrag inkl. Steuern: ${String(Number(item.amountNet + item.amountTax).toFixed(2)).replace('.',',')} €` : 'Zuerst Steuertyp festlegen' "
>
<UInput
type="number"
step="0.01"
v-model="item.amountNet"
:disabled="item.taxType === null"
@keyup="item.amountTax = Number((item.amountNet * (Number(item.taxType)/100)).toFixed(2))"
>
<template #trailing>
<span class="text-gray-500 dark:text-gray-400 text-xs">EUR</span>
</template>
</UInput>
</UFormGroup>
<UFormGroup
v-else
label="Gesamtbetrag inkl. Steuer in EUR"
class="flex-auto"
:help="item.taxType !== null ? `Betrag exkl. Steuern: ${item.amountNet ? String(item.amountNet.toFixed(2)).replace('.',',') : '0,00'} €` : 'Zuerst Steuertyp festlegen' "
>
<UInput
type="number"
step="0.01"
:disabled="item.taxType === null"
v-model="item.amountGross"
@keyup="item.amountNet = Number((item.amountGross / (1 + Number(item.taxType)/100)).toFixed(2)),
item.amountTax = Number((item.amountGross - item.amountNet).toFixed(2))"
>
<template #trailing>
<span class="text-gray-500 dark:text-gray-400 text-xs">EUR</span>
</template>
</UInput>
</UFormGroup>
</InputGroup>
<UButton
class="mt-3"
@click="itemInfo.accounts = [...itemInfo.accounts.slice(0,index+1),{account:null, amountNet: null, amountTax:null, taxType: '19'} , ...itemInfo.accounts.slice(index+1)]"
>
Position hinzufügen
</UButton>
<UButton
v-if="index !== 0"
class="mt-3"
variant="ghost"
color="rose"
@click="itemInfo.accounts = itemInfo.accounts.filter((account,itemIndex) => itemIndex !== index)"
>
Position entfernen
</UButton>
</div>
</div> </div>
</div> </div>
</div> </div>
</div> </UDashboardPanelContent>

View File

@@ -120,7 +120,7 @@ const filteredRows = computed(() => {
{{dayjs(row.dueDate).format("DD.MM.YYYY")}} {{dayjs(row.dueDate).format("DD.MM.YYYY")}}
</template> </template>
<template #paid-data="{row}"> <template #paid-data="{row}">
<span v-if="row.paid" class="text-primary-500">Bezahlt</span> <span v-if="dataStore.bankstatements.find(x => x.assignments.find(y => y.type === 'incomingInvoice' && y.id === row.id))" class="text-primary-500">Bezahlt</span>
<span v-else class="text-rose-600">Offen</span> <span v-else class="text-rose-600">Offen</span>
</template> </template>
</UTable> </UTable>

View File

@@ -130,6 +130,10 @@ export const useDataStore = defineStore('data', () => {
label: "Kontobewegungen", label: "Kontobewegungen",
labelSingle: "Kontobewegung", labelSingle: "Kontobewegung",
historyItemHolder: "bankStatement", historyItemHolder: "bankStatement",
},
statementallocations: {
label: "Bankzuweisungen",
labelSingle: "Bankzuweisung"
} }
} }
@@ -809,7 +813,7 @@ export const useDataStore = defineStore('data', () => {
} else if (supabaseData) { } else if (supabaseData) {
console.log(supabaseData) console.log(supabaseData)
await generateHistoryItems(dataType, supabaseData[0]) await generateHistoryItems(dataType, supabaseData[0])
await eval( dataType + '.value.push(' + JSON.stringify(...supabaseData) + ')') //await eval( dataType + '.value.push(' + JSON.stringify(...supabaseData) + ')')
toast.add({title: `${dataTypes[dataType].labelSingle} hinzugefügt`}) toast.add({title: `${dataTypes[dataType].labelSingle} hinzugefügt`})
if(dataTypes[dataType].redirect) await router.push(`/${dataType}/show/${supabaseData[0].id}`) if(dataTypes[dataType].redirect) await router.push(`/${dataType}/show/${supabaseData[0].id}`)
return supabaseData return supabaseData
@@ -1526,12 +1530,12 @@ export const useDataStore = defineStore('data', () => {
return workingtimes.value.find(item => item.id === itemId) return workingtimes.value.find(item => item.id === itemId)
}) })
const getOpenDocuments = computed(() => (itemId) => { /*const getOpenDocuments = computed(() => (itemId) => {
let items = createddocuments.value.filter(i => i.type === "invoices" || i.type === "advanceInvoices") let items = createddocuments.value.filter(i => i.type === "invoices" || i.type === "advanceInvoices")
items = items.filter(i => bankstatements.value.filter(x => x.assignments.find(y => y.id === i.id)).length === 0) items = items.filter(i => bankstatements.value.filter(x => x.assignments.find(y => y.type === 'createdDocument' && y.id === i.id)).length === 0)
/*let finalItems = [] /!*let finalItems = []
items.forEach(item => { items.forEach(item => {
if(bankstatements.value.filter(i => i.assignments.find(x => x.id === item.id))){ if(bankstatements.value.filter(i => i.assignments.find(x => x.id === item.id))){
finalItems.push(item) finalItems.push(item)
@@ -1539,16 +1543,18 @@ export const useDataStore = defineStore('data', () => {
}) })
return finalItems*/ return finalItems*!/
return items return items
//return createddocuments.value.filter(i => (i.type === "invoices" || i.type === "advanceInvoices") && !bankstatements.value.some(x => x.amount -)) //return createddocuments.value.filter(i => (i.type === "invoices" || i.type === "advanceInvoices") && !bankstatements.value.some(x => x.amount -))
}) })*/
const getOpenIncomingInvoices = computed(() => (itemId) => { const getOpenIncomingInvoices = computed(() => (itemId) => {
return incominginvoices.value.filter(i => !i.paid) return incominginvoices.value.filter(i => bankstatements.value.filter(x => x.assignments.find(y => y.type === 'incomingInvoice' && y.id === i.id)).length === 0)
//return incominginvoices.value.filter(i => !i.paid)
}) })
@@ -1726,7 +1732,7 @@ export const useDataStore = defineStore('data', () => {
getBankAccountById, getBankAccountById,
getEventById, getEventById,
getWorkingTimeById, getWorkingTimeById,
getOpenDocuments, //getOpenDocuments,
getOpenIncomingInvoices getOpenIncomingInvoices
} }