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 ? [{
label: "Fahrzeuge",
to: "/vehicles",
icon: "i-heroicons-truck"
icon: "i-heroicons-truck",
}] : [],
{
label: "Stammdaten",
@@ -540,5 +540,7 @@ const footerLinks = [/*{
</template>
<style scoped>
.testclass {
color: red;
}
</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>
<UDashboardNavbar title="Bankbuchungen">
<template #right>
@@ -161,104 +274,7 @@
</UModal>
</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>

View File

@@ -16,16 +16,26 @@ const dataStore = useDataStore()
const route = useRoute()
const router = useRouter()
const mode = ref(route.params.mode || "show")
const supabase = useSupabaseClient()
const itemInfo = ref({})
const itemInfo = ref({statementallocations:[]})
const oldItemInfo = ref({})
const setup = () => {
const openDocuments = ref([])
const setup = async () => {
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))
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 = "€") => {
@@ -57,18 +67,29 @@ const getInvoiceSum = (invoice) => {
}
const calculateOpenSum = computed(() => {
let startingAmount = itemInfo.value.amount
let startingAmount = itemInfo.value.amount || 0
itemInfo.value.assignments.forEach(item => {
if(item.type === "createdDocument") {
let doc = dataStore.getCreatedDocumentById(item.id)
startingAmount = startingAmount - getDocumentSum(doc)
itemInfo.value.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 saveAllocations = async () => {
let allocationsToBeSaved = itemInfo.value.statementallocations.filter(i => !i.id)
for await (let i of allocationsToBeSaved) {
await dataStore.createNewItem("statementallocations", i)
}
}
setup()
@@ -89,13 +110,13 @@ setup()
</template>
<template #center>
<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>
</template>
<template #right>
<UButton
v-if="mode === 'edit'"
@click="dataStore.updateItem('bankstatements',itemInfo,oldItemInfo)"
@click="saveAllocations"
>
Speichern
</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-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>
</template>
<table class="w-full">
<table class="w-full" v-if="itemInfo.id">
<tr class="flex-row flex justify-between">
<td>
<span class="font-semibold">Buchungsdatum:</span>
@@ -207,26 +228,36 @@ setup()
</tr>
<tr class="flex-row flex justify-between">
<td colspan="2">
<span class="font-semibold">Verknüpftes Dokument:</span>
<span class="font-semibold">Verknüpfte Dokumente:</span>
</td>
</tr>
<tr
class="flex-row flex justify-between mb-3"
v-for="item in itemInfo.assignments"
v-for="item in itemInfo.statementallocations"
>
<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-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'">
{{dataStore.getCreatedDocumentById(item.id).documentNumber}}
<span v-if="item.cd_id">
{{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>
</td>
<td>
<UButton
variant="outline"
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>
</tr>
@@ -253,15 +284,13 @@ setup()
class="w-2/5 mx-auto"
v-if="itemInfo.amount > 0 "
>
<UDivider
label="Test"
>
<UDivider>
<span>Offene Summe: {{displayCurrency(calculateOpenSum)}}</span>
</UDivider>
<UCard
class="mt-5"
:ui="{ring: itemInfo.assignments.find(i => i.id === document.id) ? 'ring-primary-500' : 'ring-gray-200 dark:ring-gray-800'}"
v-for="document in dataStore.getOpenDocuments()"
: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 openDocuments"
>
<template #header>
<div class="flex flex-row justify-between">
@@ -273,27 +302,36 @@ setup()
icon="i-heroicons-check"
variant="outline"
class="mr-3"
v-if="!itemInfo.assignments.find(i => i.id === document.id)"
@click="itemInfo.assignments.push({type: 'createdDocument',id: document.id})"
v-if="!itemInfo.statementallocations.find(i => i.cd_id === document.id)"
@click="itemInfo.statementallocations.push({cd_id: document.id, bs_id: itemInfo.id, amount: Number(getDocumentSum(document))})"
/>
<UButton
icon="i-heroicons-x-mark"
variant="outline"
color="rose"
v-if="itemInfo.assignments.find(i => i.id === document.id)"
@click="itemInfo.assignments = itemInfo.assignments.filter(i => i.id !== document.id)"
class="mr-3"
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>
</div>
<div
class="w-2/5 mx-auto"
v-if="itemInfo.amount < 0 "
>
<UDivider>
<span>Offene Summe: {{displayCurrency(calculateOpenSum)}}</span>
</UDivider>
<UCard
class="w-4/5 mx-auto mt-5"
v-else-if="itemInfo.amount < 0 && !itemInfo.incomingInvoice"
class="mt-5"
:ui="{ring: itemInfo.assignments.find(i => i.id === invoice.id) ? 'ring-primary-500' : 'ring-gray-200 dark:ring-gray-800'}"
v-for="invoice in dataStore.getOpenIncomingInvoices()"
>
<template #header>
@@ -302,28 +340,30 @@ setup()
<span class="font-semibold text-rose-600">-{{displayCurrency(getInvoiceSum(invoice))}}</span>
</div>
</template>
<table class="w-full">
<tr class="flex flex-row justify-between">
<td><span class="font-semibold">Belegdatum:</span></td>
<td>{{dayjs(invoice.date).format("DD.MM.YYYY")}}</td>
</tr>
<tr class="flex flex-row justify-between">
<td><span class="font-semibold">Fälligkeitsdatum:</span></td>
<td>{{dayjs(invoice.dueDate).format("DD.MM.YYYY")}}</td>
</tr>
<tr class="flex flex-row justify-between">
<td colspan="2"><span class="font-semibold">Beschreibung:</span></td>
</tr>
<tr class="flex flex-row justify-between">
<td colspan="2">{{invoice.description}}</td>
</tr>
</table>
<UButton
icon="i-heroicons-check"
variant="outline"
class="mr-3"
v-if="!itemInfo.assignments.find(i => i.id === invoice.id)"
@click="itemInfo.assignments.push({type: 'incomingInvoice',id: invoice.id})"
/>
<UButton
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>
</template>
<style scoped>

View File

@@ -482,6 +482,7 @@ setupPage()
</UButton>
<UButton
@click="closeDocument"
v-if="itemInfo.id"
>
Fertigstellen
</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>
</template>
<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>
<!-- {{dataStore.bankstatements.find(x => x.assignments.find(y => y.id === row.id)) ? true : false}}-->
</template>

View File

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

View File

@@ -187,6 +187,7 @@ setupPage()
</UButton>
</template>
</UDashboardNavbar>
<UDashboardPanelContent>
<div v-if="!itemInfo.document">
<!-- <div v-if="availableDocuments.length === 0" class="w-1/2 mx-auto text-center">
<p class="text-2xl mt-5">Keine Dokumente zur Auswahl vefügbar</p>
@@ -448,7 +449,6 @@ setupPage()
</UInput>
</UFormGroup>
{{item}}
</InputGroup>
@@ -475,6 +475,8 @@ setupPage()
</div>
</div>
</div>
</UDashboardPanelContent>

View File

@@ -120,7 +120,7 @@ const filteredRows = computed(() => {
{{dayjs(row.dueDate).format("DD.MM.YYYY")}}
</template>
<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>
</template>
</UTable>

View File

@@ -130,6 +130,10 @@ export const useDataStore = defineStore('data', () => {
label: "Kontobewegungen",
labelSingle: "Kontobewegung",
historyItemHolder: "bankStatement",
},
statementallocations: {
label: "Bankzuweisungen",
labelSingle: "Bankzuweisung"
}
}
@@ -809,7 +813,7 @@ export const useDataStore = defineStore('data', () => {
} else if (supabaseData) {
console.log(supabaseData)
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`})
if(dataTypes[dataType].redirect) await router.push(`/${dataType}/show/${supabaseData[0].id}`)
return supabaseData
@@ -1526,12 +1530,12 @@ export const useDataStore = defineStore('data', () => {
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")
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 => {
if(bankstatements.value.filter(i => i.assignments.find(x => x.id === item.id))){
finalItems.push(item)
@@ -1539,16 +1543,18 @@ export const useDataStore = defineStore('data', () => {
})
return finalItems*/
return finalItems*!/
return items
//return createddocuments.value.filter(i => (i.type === "invoices" || i.type === "advanceInvoices") && !bankstatements.value.some(x => x.amount -))
})
})*/
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,
getEventById,
getWorkingTimeById,
getOpenDocuments,
//getOpenDocuments,
getOpenIncomingInvoices
}