Many Changes
This commit is contained in:
@@ -1,138 +0,0 @@
|
||||
<script setup>
|
||||
import dayjs from "dayjs";
|
||||
|
||||
definePageMeta({
|
||||
middleware: "auth"
|
||||
})
|
||||
const dataStore = useDataStore()
|
||||
const route = useRoute()
|
||||
const supabase = useSupabaseClient()
|
||||
|
||||
|
||||
const searchString = ref("")
|
||||
const showAssigned = ref(false)
|
||||
const selectedAccount = ref(0)
|
||||
|
||||
const filteredRows = computed(() => {
|
||||
let statements = dataStore.bankStatements
|
||||
|
||||
if(!showAssigned.value) {
|
||||
statements = statements.filter(statement => !statement.customerInvoice || !statement.vendorInvoice)
|
||||
}
|
||||
|
||||
if(selectedAccount.value !== 0) {
|
||||
statements = statements.filter(statement => statement.account === selectedAccount.value)
|
||||
}
|
||||
|
||||
if(searchString.value.length > 0) {
|
||||
statements = statements.filter(item => {
|
||||
return Object.values(item).some((value) => {
|
||||
return String(value).toLowerCase().includes(searchString.value.toLowerCase())
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
return statements
|
||||
})
|
||||
|
||||
|
||||
|
||||
const showStatementSlideover = ref(false)
|
||||
const selectedStatement = ref({})
|
||||
|
||||
const selectStatement = (statement) => {
|
||||
selectedStatement.value = statement
|
||||
showStatementSlideover.value = true
|
||||
}
|
||||
|
||||
const statementColumns = [
|
||||
{
|
||||
key:"amount",
|
||||
label: "Betrag"
|
||||
},
|
||||
{
|
||||
key:"date",
|
||||
label: "Datum",
|
||||
sortable: true
|
||||
},
|
||||
{
|
||||
key: "credName",
|
||||
label: "Empfänger"
|
||||
},
|
||||
{
|
||||
key: "debName",
|
||||
label: "Sender"
|
||||
},
|
||||
{
|
||||
key: "text",
|
||||
label: "Verwendungszweck"
|
||||
},
|
||||
]
|
||||
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<USlideover
|
||||
v-model="showStatementSlideover"
|
||||
>
|
||||
<UCard class="flex flex-col flex-1" :ui="{ body: { base: 'flex-1' }, ring: '', divide: 'divide-y divide-gray-100 dark:divide-gray-800' }">
|
||||
|
||||
|
||||
|
||||
|
||||
<DevOnly>
|
||||
{{selectedStatement}}
|
||||
</DevOnly>
|
||||
</UCard>
|
||||
|
||||
</USlideover>
|
||||
|
||||
<InputGroup :gap="2">
|
||||
<UInput
|
||||
v-model="searchString"
|
||||
placeholder="Suche..."
|
||||
/>
|
||||
<USelectMenu
|
||||
:options="dataStore.bankAccounts.filter(account => account.used)"
|
||||
v-model="selectedAccount"
|
||||
option-attribute="iban"
|
||||
value-attribute="id"
|
||||
>
|
||||
<template #label>
|
||||
{{dataStore.bankAccounts.find(account => account.id === selectedAccount) ? dataStore.bankAccounts.find(account => account.id === selectedAccount).iban : "Kontoauswählen"}}
|
||||
</template>
|
||||
</USelectMenu>
|
||||
<UCheckbox
|
||||
v-model="showAssigned"
|
||||
label="Zugeordnete Anzeigen"
|
||||
/>
|
||||
</InputGroup>
|
||||
|
||||
<UTable
|
||||
:rows="filteredRows"
|
||||
:columns="statementColumns"
|
||||
@select="selectStatement"
|
||||
>
|
||||
<template #amount-data="{row}">
|
||||
<span
|
||||
v-if="row.amount >= 0"
|
||||
class="text-primary-500"
|
||||
>
|
||||
{{row.amount.toFixed(2) + " €"}}
|
||||
</span>
|
||||
<span
|
||||
v-if="row.amount < 0"
|
||||
class="text-rose-600"
|
||||
>
|
||||
{{row.amount.toFixed(2) + " €"}}
|
||||
</span>
|
||||
</template>
|
||||
<template #date-data="{row}">
|
||||
{{dayjs(row.date).format("DD.MM.YY")}}
|
||||
</template>
|
||||
</UTable>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
|
||||
</style>
|
||||
278
pages/banking/statements/[mode]/[[id]].vue
Normal file
278
pages/banking/statements/[mode]/[[id]].vue
Normal file
@@ -0,0 +1,278 @@
|
||||
<script setup>
|
||||
|
||||
import dayjs from "dayjs";
|
||||
|
||||
definePageMeta({
|
||||
middleware: "auth"
|
||||
})
|
||||
|
||||
defineShortcuts({
|
||||
'backspace': () => {
|
||||
router.push("/banking")
|
||||
}
|
||||
})
|
||||
|
||||
const dataStore = useDataStore()
|
||||
const route = useRoute()
|
||||
const router = useRouter()
|
||||
const mode = ref(route.params.mode || "show")
|
||||
|
||||
const itemInfo = ref({})
|
||||
const oldItemInfo = ref({})
|
||||
|
||||
const setup = () => {
|
||||
if(route.params.id) {
|
||||
itemInfo.value = dataStore.bankstatements.find(i => i.id === Number(route.params.id))
|
||||
}
|
||||
if(itemInfo.value) oldItemInfo.value = JSON.parse(JSON.stringify(itemInfo.value))
|
||||
|
||||
}
|
||||
|
||||
const displayCurrency = (value, currency = "€") => {
|
||||
return `${Number(value).toFixed(2).replace(".",",")} ${currency}`
|
||||
}
|
||||
|
||||
const separateIBAN = (input) => {
|
||||
const separates = input.match(/.{1,4}/g)
|
||||
return separates.join(" ")
|
||||
}
|
||||
|
||||
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 getInvoiceSum = (invoice) => {
|
||||
let sum = 0
|
||||
invoice.accounts.forEach(account => {
|
||||
sum += account.amountTax
|
||||
sum += account.amountNet
|
||||
})
|
||||
return sum
|
||||
}
|
||||
|
||||
setup()
|
||||
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<UDashboardNavbar
|
||||
:ui="{center: 'flex items-stretch gap-1.5 min-w-0'}"
|
||||
>
|
||||
<template #left>
|
||||
<UButton
|
||||
icon="i-heroicons-chevron-left"
|
||||
variant="outline"
|
||||
@click="router.push(`/banking`)"
|
||||
>
|
||||
Kontobewegungen
|
||||
</UButton>
|
||||
</template>
|
||||
<template #center>
|
||||
<h1
|
||||
:class="['text-xl','font-medium', ... itemInfo.incomingInvoice || itemInfo.createdDocument ? ['text-primary-500'] : ['text-rose-600']]"
|
||||
>Kontobewegung bearbeiten</h1>
|
||||
</template>
|
||||
<template #right>
|
||||
<UButton
|
||||
v-if="mode === 'edit'"
|
||||
@click="dataStore.updateItem('bankstatements',itemInfo,oldItemInfo)"
|
||||
>
|
||||
Speichern
|
||||
</UButton>
|
||||
<!--<UButton
|
||||
v-else-if="mode === 'create'"
|
||||
@click="dataStore.createNewItem('customers',itemInfo)"
|
||||
>
|
||||
Erstellen
|
||||
</UButton>
|
||||
<UButton
|
||||
@click="cancelEditorCreate"
|
||||
color="red"
|
||||
class="ml-2"
|
||||
v-if="mode === 'edit' || mode === 'create'"
|
||||
>
|
||||
Abbrechen
|
||||
</UButton>
|
||||
<UButton
|
||||
v-if="mode === 'show'"
|
||||
@click="editItem"
|
||||
>
|
||||
Bearbeiten
|
||||
</UButton>-->
|
||||
</template>
|
||||
<template #badge v-if="itemInfo">
|
||||
<UBadge
|
||||
v-if="itemInfo.incomingInvoice || itemInfo.createdDocument"
|
||||
>
|
||||
Gebucht
|
||||
</UBadge>
|
||||
<UBadge
|
||||
v-else
|
||||
color="red"
|
||||
>
|
||||
Offen
|
||||
</UBadge>
|
||||
</template>
|
||||
</UDashboardNavbar>
|
||||
|
||||
<UDashboardPanelContent>
|
||||
<UCard
|
||||
class="w-4/5 mx-auto mt-10"
|
||||
v-if="itemInfo"
|
||||
>
|
||||
<template #header>
|
||||
<div class="flex flex-row justify-between">
|
||||
<span
|
||||
v-if="itemInfo.amount > 0"
|
||||
class="text-base font-semibold leading-6 text-gray-900 dark:text-white"
|
||||
>
|
||||
{{itemInfo.debName}}
|
||||
</span>
|
||||
<span
|
||||
v-else-if="itemInfo.amount < 0"
|
||||
class="text-base font-semibold leading-6 text-gray-900 dark:text-white"
|
||||
>
|
||||
{{itemInfo.credName}}
|
||||
</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>{{itemInfo.amount.toFixed(2).replace(".",",")}} {{itemInfo.currency}}</span>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<table class="w-full">
|
||||
<tr class="flex-row flex justify-between">
|
||||
<td>
|
||||
<span class="font-semibold">Buchungsdatum:</span>
|
||||
</td>
|
||||
<td>
|
||||
{{dayjs(itemInfo.date).format("DD.MM.YYYY")}}
|
||||
</td>
|
||||
</tr>
|
||||
<tr class="flex-row flex justify-between">
|
||||
<td>
|
||||
<span class="font-semibold">Wertstellungsdatum:</span>
|
||||
</td>
|
||||
<td>
|
||||
{{dayjs(itemInfo.valueDate).format("DD.MM.YYYY")}}
|
||||
</td>
|
||||
</tr>
|
||||
<tr class="flex-row flex justify-between">
|
||||
<td>
|
||||
<span class="font-semibold">Partner:</span>
|
||||
</td>
|
||||
<td>
|
||||
{{itemInfo.amount > 0 ? itemInfo.debName : itemInfo.credName}}
|
||||
</td>
|
||||
</tr>
|
||||
<tr class="flex-row flex justify-between">
|
||||
<td>
|
||||
<span class="font-semibold">Partner IBAN:</span>
|
||||
</td>
|
||||
<td>
|
||||
{{itemInfo.amount > 0 ? separateIBAN(itemInfo.debIban) : separateIBAN(itemInfo.credIban)}}
|
||||
</td>
|
||||
</tr>
|
||||
<tr class="flex-row flex justify-between">
|
||||
<td>
|
||||
<span class="font-semibold">Konto:</span>
|
||||
</td>
|
||||
<td>
|
||||
{{dataStore.getBankAccountById(itemInfo.account) ? dataStore.getBankAccountById(itemInfo.account).name || separateIBAN(dataStore.getBankAccountById(itemInfo.account).iban) : ""}}
|
||||
</td>
|
||||
</tr>
|
||||
<tr class="flex-row flex justify-between">
|
||||
<td>
|
||||
<span class="font-semibold">Verknüpftes Dokument:</span>
|
||||
</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-else-if="itemInfo.incomingInvoice"><nuxt-link :to="`/incominInvoices/show/${itemInfo.incomingInvoice}`">{{dataStore.getIncomingInvoiceById(itemInfo.incomingInvoice).reference}}</nuxt-link></span>
|
||||
</td>
|
||||
</tr>
|
||||
<tr class="flex-row flex justify-between">
|
||||
<td colspan="2">
|
||||
<span class="font-semibold">Beschreibung:</span>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2">
|
||||
{{itemInfo.text}}
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</UCard>
|
||||
|
||||
<UDivider
|
||||
class="mt-5 w-4/5 mx-auto"
|
||||
v-if="!itemInfo.createdDocument && !itemInfo.incomingInvoice"
|
||||
/>
|
||||
|
||||
<UCard
|
||||
class="w-4/5 mx-auto mt-5"
|
||||
v-if="itemInfo.amount > 0 && !itemInfo.createdDocument"
|
||||
:ui="{ring: itemInfo.createdDocument === document.id ? 'ring-primary-500' : 'ring-gray-200 dark:ring-gray-800'}"
|
||||
v-for="document in dataStore.getOpenDocuments()"
|
||||
>
|
||||
<template #header>
|
||||
<div class="flex flex-row justify-between">
|
||||
<span>{{dataStore.getCustomerById(document.customer).name}} - {{document.documentNumber}}</span>
|
||||
<span class="font-semibold text-primary-500">{{displayCurrency(getDocumentSum(document))}}</span>
|
||||
</div>
|
||||
</template>
|
||||
<UButton
|
||||
icon="i-heroicons-check"
|
||||
variant="outline"
|
||||
v-if="Number(getDocumentSum(document)) === itemInfo.amount"
|
||||
@click="itemInfo.createdDocument = document.id"
|
||||
/>
|
||||
</UCard>
|
||||
|
||||
|
||||
|
||||
<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>
|
||||
<div class="flex flex-row justify-between">
|
||||
<span>{{dataStore.getVendorById(invoice.vendor).name}} - {{invoice.reference}}</span>
|
||||
<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>
|
||||
</UCard>
|
||||
</UDashboardPanelContent>
|
||||
|
||||
|
||||
|
||||
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
|
||||
</style>
|
||||
Reference in New Issue
Block a user