860 lines
30 KiB
Vue
860 lines
30 KiB
Vue
<script setup>
|
|
|
|
import dayjs from "dayjs";
|
|
import {filter} from "vuedraggable/dist/vuedraggable.common.js";
|
|
|
|
|
|
|
|
defineShortcuts({
|
|
'backspace': () => {
|
|
router.push("/banking")
|
|
}
|
|
})
|
|
|
|
const dataStore = useDataStore()
|
|
const profileStore = useProfileStore()
|
|
const route = useRoute()
|
|
const router = useRouter()
|
|
const mode = ref(route.params.mode || "show")
|
|
|
|
const itemInfo = ref({statementallocations:[]})
|
|
const oldItemInfo = ref({})
|
|
|
|
const openDocuments = ref([])
|
|
const allocatedDocuments = ref([])
|
|
const openIncomingInvoices = ref([])
|
|
const allocatedIncomingInvoices = ref([])
|
|
|
|
const customers = ref([])
|
|
const vendors = ref([])
|
|
|
|
const createddocuments = ref([])
|
|
const incominginvoices = ref([])
|
|
const accounts = ref([])
|
|
const ownaccounts = ref([])
|
|
|
|
const loading = ref(true)
|
|
const setup = async () => {
|
|
loading.value = true
|
|
if(route.params.id) {
|
|
itemInfo.value = await useEntities("bankstatements").selectSingle(route.params.id,"*, statementallocations(*, cd_id(*), ii_id(*))", undefined, undefined, true)
|
|
}
|
|
if(itemInfo.value) oldItemInfo.value = JSON.parse(JSON.stringify(itemInfo.value))
|
|
|
|
manualAllocationSum.value = calculateOpenSum.value
|
|
|
|
createddocuments.value = (await useEntities("createddocuments").select("*, statementallocations(*), customer(id,name)"))
|
|
const documents = createddocuments.value.filter(i => i.type === "invoices" ||i.type === "advanceInvoices")
|
|
incominginvoices.value = (await useEntities("incominginvoices").select("*, statementallocations(*), vendor(id,name)")).filter(i => i.state === "Gebucht")
|
|
|
|
accounts.value = (await useEntities("accounts").selectSpecial("*","number",true))
|
|
ownaccounts.value = (await useEntities("ownaccounts").select())
|
|
customers.value = (await useEntities("customers").select())
|
|
vendors.value = (await useEntities("vendors").select())
|
|
|
|
openDocuments.value = documents.filter(i => i.statementallocations.reduce((n,{amount}) => n + amount, 0).toFixed(2) !== useSum().getCreatedDocumentSum(i,createddocuments.value).toFixed(2))
|
|
openDocuments.value = openDocuments.value.map(i => {
|
|
|
|
return {
|
|
...i,
|
|
docTotal: useSum().getCreatedDocumentSum(i,createddocuments.value),
|
|
statementTotal: Number(i.statementallocations.reduce((n,{amount}) => n + amount, 0)),
|
|
openSum: (useSum().getCreatedDocumentSum(i,createddocuments.value) - Number(i.statementallocations.reduce((n,{amount}) => n + amount, 0))).toFixed(2)
|
|
}
|
|
})
|
|
|
|
console.log(openDocuments.value)
|
|
|
|
allocatedDocuments.value = documents.filter(i => i.statementallocations.find(x => x.bankstatement === itemInfo.value.id))
|
|
allocatedIncomingInvoices.value = incominginvoices.value.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))
|
|
//console.log(openIncomingInvoices.value)
|
|
|
|
// return incominginvoices.value.filter(i => bankstatements.value.filter(x => x.assignments.find(y => y.type === 'incomingInvoice' && y.id === i.id)).length === 0)
|
|
|
|
|
|
loading.value = false
|
|
|
|
}
|
|
|
|
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 getInvoiceSum = (invoice, onlyOpenSum) => {
|
|
console.log(invoice)
|
|
let sum = 0
|
|
invoice.accounts.forEach(account => {
|
|
sum += account.amountTax
|
|
sum += account.amountNet
|
|
})
|
|
console.log(sum)
|
|
|
|
if(onlyOpenSum) sum = sum + Number(invoice.statementallocations.reduce((n,{amount}) => n + amount, 0))
|
|
|
|
if(invoice.expense) {
|
|
return (sum * -1).toFixed(2)
|
|
} else {
|
|
return sum.toFixed(2)
|
|
}
|
|
}
|
|
|
|
const calculateOpenSum = computed(() => {
|
|
let startingAmount = 0
|
|
|
|
itemInfo.value.statementallocations.forEach(item => {
|
|
startingAmount += item.amount
|
|
})
|
|
|
|
return (itemInfo.value.amount - 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)
|
|
}
|
|
|
|
|
|
}
|
|
|
|
const showAccountSelection = ref(false)
|
|
const accountToSave = ref("")
|
|
const ownAccountToSave = ref("")
|
|
const customerAccountToSave = ref("")
|
|
const vendorAccountToSave = ref("")
|
|
|
|
const selectAccount = (id) => {
|
|
accountToSave.value = id
|
|
showAccountSelection.value = false
|
|
}
|
|
|
|
|
|
const manualAllocationSum = ref(itemInfo.value.amount || 0)
|
|
const allocationDescription = ref("")
|
|
const showMoreWithoutRecipe = ref(false)
|
|
const showMoreText = ref(false)
|
|
|
|
const saveAllocation = async (allocation) => {
|
|
//TODO: BACKEND CHANGE SAVE/REMOVE
|
|
console.log(allocation)
|
|
|
|
const res = await useNuxtApp().$api("/api/banking/statements",{
|
|
method: "POST",
|
|
body: {
|
|
data: allocation
|
|
}
|
|
})
|
|
|
|
if(res) {
|
|
await setup()
|
|
accountToSave.value = null
|
|
vendorAccountToSave.value = null
|
|
customerAccountToSave.value = null
|
|
ownAccountToSave.value = null
|
|
allocationDescription.value = null
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
const removeAllocation = async (allocationId) => {
|
|
const res = await useNuxtApp().$api(`/api/banking/statements/${allocationId}`,{
|
|
method: "DELETE"
|
|
})
|
|
|
|
await setup()
|
|
}
|
|
|
|
const searchString = ref("")
|
|
const filteredDocuments = computed(() => {
|
|
|
|
|
|
return useSearch(searchString.value, openDocuments.value.filter(i => i.state === "Gebucht"))
|
|
|
|
})
|
|
|
|
const filteredIncomingInvoices = computed(() => {
|
|
|
|
|
|
return useSearch(searchString.value, openIncomingInvoices.value.filter(i => i.state === "Gebucht"))
|
|
|
|
})
|
|
|
|
|
|
setup()
|
|
|
|
|
|
const archiveStatement = async () => {
|
|
|
|
let temp = itemInfo.value
|
|
delete temp.statementallocations
|
|
|
|
await useEntities("bankstatements").archive(temp.id)
|
|
}
|
|
|
|
</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.back()/*router.push(`/standardEntity/${type}`)*/"
|
|
>
|
|
Zurück
|
|
</UButton>
|
|
<UButton
|
|
icon="i-heroicons-chevron-left"
|
|
variant="outline"
|
|
@click="router.push(`/banking`)"
|
|
>
|
|
Kontobewegungen
|
|
</UButton>
|
|
</template>
|
|
<template #center>
|
|
<h1
|
|
:class="['text-xl','font-medium']"
|
|
>Kontobewegung bearbeiten</h1>
|
|
</template>
|
|
<template #badge v-if="itemInfo">
|
|
<UBadge
|
|
v-if="itemInfo.incomingInvoice || itemInfo.createdDocument"
|
|
>
|
|
Gebucht
|
|
</UBadge>
|
|
<UBadge
|
|
v-else
|
|
color="red"
|
|
>
|
|
Offen
|
|
</UBadge>
|
|
</template>
|
|
<template #right>
|
|
<ArchiveButton
|
|
color="rose"
|
|
variant="outline"
|
|
type="bankstatements"
|
|
@confirmed="archiveStatement"
|
|
/>
|
|
</template>
|
|
</UDashboardNavbar>
|
|
|
|
<UDashboardPanelContent
|
|
class="flex flex-row workingContainer"
|
|
v-if="!loading"
|
|
>
|
|
<div
|
|
class="mx-auto w-2/5"
|
|
>
|
|
<div class="px-2">
|
|
<UCard
|
|
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 text-nowrap">{{displayCurrency(itemInfo.amount)}}</span>
|
|
<span v-else-if="itemInfo.amount < 0" class="text-rose-600 font-semibold text-nowrap">{{displayCurrency(itemInfo.amount)}}</span>
|
|
<span v-else>{{displayCurrency(itemInfo.amount)}}</span>
|
|
</div>
|
|
</template>
|
|
|
|
<UAlert
|
|
v-if="itemInfo.archived"
|
|
color="rose"
|
|
variant="outline"
|
|
:title="`Kontobewegung archiviert`"
|
|
icon="i-heroicons-archive-box"
|
|
class="mb-5"
|
|
/>
|
|
|
|
<table class="w-full" v-if="itemInfo.id">
|
|
<tbody>
|
|
<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 text-right">
|
|
<td>
|
|
<span class="font-semibold">Partner:</span>
|
|
</td>
|
|
<td>
|
|
<span v-if="itemInfo.debName">{{itemInfo.debName}}</span>
|
|
<span v-else-if="itemInfo.credName">{{itemInfo.credName}}</span>
|
|
<span v-else>-</span>
|
|
|
|
</td>
|
|
</tr>
|
|
<tr class="flex-row flex justify-between">
|
|
<td>
|
|
<span class="font-semibold">Partner IBAN:</span>
|
|
</td>
|
|
<td>
|
|
<span v-if="itemInfo.debIban">{{separateIBAN(itemInfo.debIban)}}</span>
|
|
<span v-else-if="itemInfo.credIban">{{separateIBAN(itemInfo.credIban)}}</span>
|
|
<span v-else>-</span>
|
|
</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 colspan="2">
|
|
<span class="font-semibold">Buchungen:</span>
|
|
</td>
|
|
</tr>
|
|
<tr
|
|
class="flex-row flex justify-between mb-3"
|
|
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.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>
|
|
<span v-else-if="item.account">
|
|
Buchungskonto: {{accounts.find(i => i.id === item.account).number}} {{accounts.find(i => i.id === item.account).label}}
|
|
</span>
|
|
</td>
|
|
<td>
|
|
<UButton
|
|
variant="outline"
|
|
icon="i-heroicons-arrow-right-end-on-rectangle"
|
|
@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>-->
|
|
<tr class="flex-row flex justify-between">
|
|
<td colspan="2">
|
|
<span class="font-semibold">Beschreibung:</span>
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<td colspan="2">
|
|
<UButton
|
|
class="mt-3"
|
|
@click="showMoreText = !showMoreText"
|
|
variant="outline"
|
|
>{{ showMoreText ? "Weniger anzeigen" : "Mehr anzeigen" }}</UButton>
|
|
|
|
|
|
|
|
<p>{{showMoreText ? itemInfo.text : itemInfo.text.substring(0,200)}}</p>
|
|
</td>
|
|
</tr>
|
|
</tbody>
|
|
|
|
</table>
|
|
|
|
</UCard>
|
|
|
|
<UAlert
|
|
class="mb-3 mt-3"
|
|
:color="calculateOpenSum != 0 ? 'rose' : 'primary'"
|
|
variant="outline"
|
|
:title="calculateOpenSum != 0 ? `${displayCurrency(Math.abs(calculateOpenSum))} von ${displayCurrency(Math.abs(itemInfo.amount))} nicht zugewiesen` : 'Kontobewegung vollständig zugewiesen'"
|
|
>
|
|
<template #description>
|
|
<UProgress
|
|
:value="Math.abs(itemInfo.amount) - Math.abs(calculateOpenSum)"
|
|
:max="Math.abs(itemInfo.amount)"
|
|
:color="calculateOpenSum != 0 ? 'rose' : 'primary'"
|
|
/>
|
|
</template>
|
|
</UAlert>
|
|
</div>
|
|
|
|
|
|
<div class="scrollList mt-3 px-2 pb-3" style="height: 35vh">
|
|
<UDivider>Vorhandene Buchungen<UBadge v-if="itemInfo.statementallocations.length > 0" variant="outline" class="ml-2">{{itemInfo.statementallocations.length}}</UBadge></UDivider>
|
|
|
|
<UCard
|
|
class="mt-5"
|
|
v-for="item in itemInfo.statementallocations.filter(i => i.account)"
|
|
>
|
|
<template #header>
|
|
<div class="flex flex-row justify-between">
|
|
<span>{{accounts.find(i => i.id === item.account).number}} - {{accounts.find(i => i.id === item.account).label}}</span>
|
|
<span class="font-semibold text-nowrap">{{displayCurrency(item.amount)}}</span>
|
|
</div>
|
|
</template>
|
|
<p class="font-bold">Beschreibung:</p>
|
|
<p>{{item.description}}</p>
|
|
<UButton
|
|
icon="i-heroicons-x-mark"
|
|
variant="outline"
|
|
color="rose"
|
|
class="mr-3 mt-3"
|
|
@click="removeAllocation(item.id)"
|
|
/>
|
|
</UCard>
|
|
<UCard
|
|
class="mt-5"
|
|
v-for="item in itemInfo.statementallocations.filter(i => i.ownaccount)"
|
|
>
|
|
<template #header>
|
|
<div class="flex flex-row justify-between">
|
|
<span>{{ownaccounts.find(i => i.id === item.ownaccount).number}} - {{ownaccounts.find(i => i.id === item.ownaccount).name}}</span>
|
|
<span class="font-semibold text-nowrap">{{displayCurrency(item.amount)}}</span>
|
|
</div>
|
|
</template>
|
|
<p class="font-bold">Beschreibung:</p>
|
|
<p>{{item.description}}</p>
|
|
<UButton
|
|
icon="i-heroicons-x-mark"
|
|
variant="outline"
|
|
color="rose"
|
|
class="mr-3 mt-3"
|
|
@click="removeAllocation(item.id)"
|
|
/>
|
|
</UCard>
|
|
<UCard
|
|
class="mt-5"
|
|
v-for="item in itemInfo.statementallocations.filter(i => i.customer)"
|
|
>
|
|
<template #header>
|
|
<div class="flex flex-row justify-between">
|
|
<span>{{customers.find(i => i.id === item.customer).customerNumber}} - {{customers.find(i => i.id === item.customer).name}}</span>
|
|
<span class="font-semibold text-nowrap">{{displayCurrency(item.amount)}}</span>
|
|
</div>
|
|
</template>
|
|
<p class="font-bold">Beschreibung:</p>
|
|
<p>{{item.description}}</p>
|
|
<UButton
|
|
icon="i-heroicons-x-mark"
|
|
variant="outline"
|
|
color="rose"
|
|
class="mr-3 mt-3"
|
|
@click="removeAllocation(item.id)"
|
|
/>
|
|
</UCard>
|
|
<UCard
|
|
class="mt-5"
|
|
v-for="item in itemInfo.statementallocations.filter(i => i.vendor)"
|
|
>
|
|
<template #header>
|
|
<div class="flex flex-row justify-between">
|
|
<span>{{vendors.find(i => i.id === item.vendor).vendorNumber}} - {{vendors.find(i => i.id === item.vendor).name}}</span>
|
|
<span class="font-semibold text-nowrap">{{displayCurrency(item.amount)}}</span>
|
|
</div>
|
|
</template>
|
|
<p class="font-bold">Beschreibung:</p>
|
|
<p>{{item.description}}</p>
|
|
<UButton
|
|
icon="i-heroicons-x-mark"
|
|
variant="outline"
|
|
color="rose"
|
|
class="mr-3 mt-3"
|
|
@click="removeAllocation(item.id)"
|
|
/>
|
|
</UCard>
|
|
<UCard
|
|
class="mt-5"
|
|
v-for="item in itemInfo.statementallocations.filter(i => i.incominginvoice)"
|
|
>
|
|
<template #header>
|
|
<div class="flex flex-row justify-between">
|
|
<span> {{incominginvoices.find(i => i.id === item.incominginvoice).reference}} - {{incominginvoices.find(i => i.id === item.incominginvoice).vendor?.name}}</span>
|
|
<span class="font-semibold text-nowrap">{{displayCurrency(item.amount)}}</span>
|
|
</div>
|
|
</template>
|
|
<p class="font-bold">Beschreibung:</p>
|
|
<p>{{item.description}}</p>
|
|
<UButton
|
|
icon="i-heroicons-x-mark"
|
|
variant="outline"
|
|
color="rose"
|
|
class="mr-3 mt-3"
|
|
@click="removeAllocation(item.id)"
|
|
/>
|
|
</UCard>
|
|
<UCard
|
|
class="mt-5"
|
|
v-for="item in itemInfo.statementallocations.filter(i => i.createddocument)"
|
|
>
|
|
<template #header>
|
|
<div class="flex flex-row justify-between">
|
|
<span v-if="customers.find(i => i.id === createddocuments.find(i => i.id === item.createddocument).customer?.id)">{{createddocuments.find(i => i.id === item.createddocument).documentNumber}} - {{createddocuments.find(i => i.id === item.createddocument).customer?.name}}</span>
|
|
<span class="font-semibold text-nowrap">{{displayCurrency(item.amount)}}</span>
|
|
</div>
|
|
</template>
|
|
<p class="font-bold">Beschreibung:</p>
|
|
<p>{{item.description}}</p>
|
|
<UButton
|
|
icon="i-heroicons-x-mark"
|
|
variant="outline"
|
|
color="rose"
|
|
class="mr-3 mt-3"
|
|
@click="removeAllocation(item.id)"
|
|
/>
|
|
</UCard>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="w-2/5 mx-auto">
|
|
<div class="px-2">
|
|
<UDivider class="mt-3">Buchungsdaten</UDivider>
|
|
<UFormGroup
|
|
label="Summe:"
|
|
>
|
|
<UInput
|
|
v-model="manualAllocationSum"
|
|
type="number"
|
|
step="0.01"
|
|
>
|
|
<template #trailing>
|
|
<span class="text-gray-500 dark:text-gray-400 text-xs">EUR</span>
|
|
</template>
|
|
</UInput>
|
|
</UFormGroup>
|
|
<UFormGroup
|
|
label="Beschreibung:"
|
|
class="mt-3"
|
|
>
|
|
<UTextarea
|
|
v-model="allocationDescription"
|
|
rows="3"
|
|
/>
|
|
</UFormGroup>
|
|
|
|
|
|
<UDivider class="my-3">Ohne Beleg buchen</UDivider>
|
|
|
|
<UFormGroup
|
|
label="Buchungskonten"
|
|
class="mt-3"
|
|
>
|
|
<InputGroup class="mt-3 w-full">
|
|
<USelectMenu
|
|
class="w-full"
|
|
:options="accounts"
|
|
value-attribute="id"
|
|
option-attribute="label"
|
|
:ui-menu="{ width: 'min-w-max' }"
|
|
v-model="accountToSave"
|
|
searchable
|
|
:search-attributes="['number','label']"
|
|
>
|
|
<template #label>
|
|
<span v-if="accountToSave">{{accounts.find(i => i.id === accountToSave).number}} - {{accounts.find(i => i.id === accountToSave).label}}</span>
|
|
<span v-else>Kein Konto ausgewählt</span>
|
|
</template>
|
|
<template #option="{option}">
|
|
{{option.number}} - {{option.label}}
|
|
</template>
|
|
</USelectMenu>
|
|
<UButton
|
|
@click="showAccountSelection = true"
|
|
icon="i-heroicons-magnifying-glass"
|
|
variant="outline"
|
|
/>
|
|
<UButton
|
|
variant="outline"
|
|
icon="i-heroicons-check"
|
|
:disabled="!accountToSave"
|
|
@click="saveAllocation({bankstatement: itemInfo.id, amount: manualAllocationSum, account: accountToSave, description: allocationDescription })"
|
|
/>
|
|
<UButton
|
|
@click="accountToSave = ''"
|
|
icon="i-heroicons-x-mark"
|
|
variant="outline"
|
|
color="rose"
|
|
/>
|
|
</InputGroup>
|
|
<UModal
|
|
v-model="showAccountSelection"
|
|
>
|
|
<UCard>
|
|
<template #header>
|
|
<div class="flex items-center justify-between">
|
|
<h3 class="text-base font-semibold leading-6 text-gray-900 dark:text-white">
|
|
Konto auswählen
|
|
</h3>
|
|
<UButton color="gray" variant="ghost" icon="i-heroicons-x-mark-20-solid" class="-my-1" @click="showAccountSelection = false" />
|
|
</div>
|
|
</template>
|
|
<UButton
|
|
v-for="selectableAccount in accounts"
|
|
variant="outline"
|
|
class="m-3"
|
|
@click="selectAccount(selectableAccount.id)"
|
|
>
|
|
{{selectableAccount.label}}
|
|
</UButton>
|
|
</UCard>
|
|
|
|
</UModal>
|
|
</UFormGroup>
|
|
<UButton
|
|
class="mt-3"
|
|
@click="showMoreWithoutRecipe = !showMoreWithoutRecipe"
|
|
variant="outline"
|
|
>{{ showMoreWithoutRecipe ? "Weniger anzeigen" : "Mehr anzeigen" }}</UButton>
|
|
<UFormGroup
|
|
v-if="showMoreWithoutRecipe"
|
|
label="zusätzliche Buchungskonten"
|
|
class="mt-3"
|
|
>
|
|
<InputGroup class="w-full">
|
|
<USelectMenu
|
|
class="w-full"
|
|
:options="ownaccounts"
|
|
value-attribute="id"
|
|
option-attribute="label"
|
|
:ui-menu="{ width: 'min-w-max' }"
|
|
v-model="ownAccountToSave"
|
|
searchable
|
|
:search-attributes="['number','label']"
|
|
>
|
|
<template #label>
|
|
<span v-if="ownAccountToSave">{{ownaccounts.find(i => i.id === ownAccountToSave).number}} - {{ownaccounts.find(i => i.id === ownAccountToSave).name}}</span>
|
|
<span v-else>Kein Konto ausgewählt</span>
|
|
</template>
|
|
<template #option="{option}">
|
|
{{option.number}} - {{option.name}}
|
|
</template>
|
|
</USelectMenu>
|
|
<UButton
|
|
variant="outline"
|
|
icon="i-heroicons-check"
|
|
:disabled="!ownAccountToSave"
|
|
@click="saveAllocation({bankstatement: itemInfo.id, amount: manualAllocationSum, ownaccount: ownAccountToSave, description: allocationDescription })"
|
|
/>
|
|
<UButton
|
|
@click="accountToSave = ''"
|
|
icon="i-heroicons-x-mark"
|
|
variant="outline"
|
|
color="rose"
|
|
/>
|
|
</InputGroup>
|
|
</UFormGroup>
|
|
<UFormGroup
|
|
v-if="showMoreWithoutRecipe"
|
|
label="Kunden"
|
|
class="mt-3"
|
|
>
|
|
<InputGroup class="w-full">
|
|
<USelectMenu
|
|
class="w-full"
|
|
:options="customers"
|
|
value-attribute="id"
|
|
option-attribute="label"
|
|
:ui-menu="{ width: 'min-w-max' }"
|
|
v-model="customerAccountToSave"
|
|
searchable
|
|
:search-attributes="['number','name']"
|
|
>
|
|
<template #label>
|
|
<span v-if="customerAccountToSave">{{customers.find(i => i.id === customerAccountToSave).customerNumber}} - {{customers.find(i => i.id === customerAccountToSave).name}}</span>
|
|
<span v-else>Kein Konto ausgewählt</span>
|
|
</template>
|
|
<template #option="{option}">
|
|
{{option.customerNumber}} - {{option.name}}
|
|
</template>
|
|
</USelectMenu>
|
|
<UButton
|
|
variant="outline"
|
|
icon="i-heroicons-check"
|
|
:disabled="!customerAccountToSave"
|
|
@click="saveAllocation({bankstatement: itemInfo.id, amount: manualAllocationSum, customer: customerAccountToSave, description: allocationDescription })"
|
|
/>
|
|
<UButton
|
|
@click="customerAccountToSave = ''"
|
|
icon="i-heroicons-x-mark"
|
|
variant="outline"
|
|
color="rose"
|
|
/>
|
|
</InputGroup>
|
|
</UFormGroup>
|
|
<UFormGroup
|
|
v-if="showMoreWithoutRecipe"
|
|
label="Lieferanten"
|
|
class="mt-3"
|
|
>
|
|
<InputGroup class="w-full">
|
|
<USelectMenu
|
|
class="w-full"
|
|
:options="vendors"
|
|
value-attribute="id"
|
|
option-attribute="label"
|
|
:ui-menu="{ width: 'min-w-max' }"
|
|
v-model="vendorAccountToSave"
|
|
searchable
|
|
:search-attributes="['number','name']"
|
|
>
|
|
<template #label>
|
|
<span v-if="vendorAccountToSave">{{vendors.find(i => i.id === vendorAccountToSave).vendorNumber}} - {{vendors.find(i => i.id === vendorAccountToSave).name}}</span>
|
|
<span v-else>Kein Konto ausgewählt</span>
|
|
</template>
|
|
<template #option="{option}">
|
|
{{option.vendorNumber}} - {{option.name}}
|
|
</template>
|
|
</USelectMenu>
|
|
<UButton
|
|
variant="outline"
|
|
icon="i-heroicons-check"
|
|
:disabled="!vendorAccountToSave"
|
|
@click="saveAllocation({bankstatement: itemInfo.id, amount: manualAllocationSum, vendor: vendorAccountToSave, description: allocationDescription })"
|
|
/>
|
|
<UButton
|
|
@click="vendorAccountToSave = ''"
|
|
icon="i-heroicons-x-mark"
|
|
variant="outline"
|
|
color="rose"
|
|
/>
|
|
</InputGroup>
|
|
</UFormGroup>
|
|
|
|
<UDivider
|
|
class="my-3"
|
|
>
|
|
Auf Beleg buchen
|
|
</UDivider>
|
|
<InputGroup
|
|
class="mt-3 w-full"
|
|
>
|
|
<UInput
|
|
id="searchinput"
|
|
v-model="searchString"
|
|
icon="i-heroicons-funnel"
|
|
autocomplete="off"
|
|
placeholder="Suche..."
|
|
class="hidden lg:block w-full mr-1"
|
|
@keydown.esc="$event.target.blur()"
|
|
>
|
|
<template #trailing>
|
|
<UKbd value="/" />
|
|
</template>
|
|
</UInput>
|
|
<UButton
|
|
variant="outline"
|
|
icon="i-heroicons-x-mark"
|
|
color="rose"
|
|
@click="searchString = ''"
|
|
/>
|
|
</InputGroup>
|
|
</div>
|
|
|
|
<div class="scrollList mt-3 px-2" style="height: 40vh;">
|
|
|
|
<UCard
|
|
class="mt-5"
|
|
v-for="document in filteredDocuments"
|
|
>
|
|
<template #header>
|
|
<div class="flex flex-row justify-between">
|
|
<span>{{document.customer ? document.customer.name : ""}} - {{document.documentNumber}}</span>
|
|
<span class="font-semibold text-primary-500 text-nowrap">{{displayCurrency(document.openSum)}}</span>
|
|
</div>
|
|
</template>
|
|
<UButton
|
|
icon="i-heroicons-check"
|
|
variant="outline"
|
|
class="mr-3"
|
|
v-if="!itemInfo.statementallocations.find(i => i.createddocument === document.id)"
|
|
@click="saveAllocation({createddocument: document.id, bankstatement: itemInfo.id, amount: Number(Number(document.openSum) < manualAllocationSum ? document.openSum : manualAllocationSum), description: allocationDescription})"
|
|
/>
|
|
|
|
<UButton
|
|
variant="outline"
|
|
icon="i-heroicons-arrow-right-end-on-rectangle"
|
|
@click="router.push(`/createDocument/show/${document.id}`)"
|
|
/>
|
|
</UCard>
|
|
|
|
<UCard
|
|
class="mt-5"
|
|
v-for="item in filteredIncomingInvoices"
|
|
>
|
|
<template #header>
|
|
<div class="flex flex-row justify-between">
|
|
<span>{{item.vendor ? item.vendor.name : ''}} - {{item.reference}}</span>
|
|
<span class="font-semibold text-rose-600 text-nowrap">{{displayCurrency(getInvoiceSum(item,true))}}</span>
|
|
</div>
|
|
</template>
|
|
<UButton
|
|
icon="i-heroicons-check"
|
|
variant="outline"
|
|
class="mr-3"
|
|
v-if="!itemInfo.statementallocations.find(i => i.incominginvoice === item.id)"
|
|
@click="saveAllocation({incominginvoice: item.id, bankstatement: itemInfo.id, amount: Number(Math.abs(getInvoiceSum(item,true)) > Math.abs(manualAllocationSum) ? manualAllocationSum : getInvoiceSum(item,true)), description: allocationDescription})"
|
|
/>
|
|
<UButton
|
|
variant="outline"
|
|
icon="i-heroicons-arrow-right-end-on-rectangle"
|
|
@click="router.push(`/incominginvoices/show/${item.id}`)"
|
|
/>
|
|
|
|
</UCard>
|
|
</div>
|
|
</div>
|
|
|
|
</UDashboardPanelContent>
|
|
</template>
|
|
|
|
<style scoped>
|
|
.workingContainer {
|
|
height: 90vh;
|
|
overflow-y: hidden;
|
|
}
|
|
|
|
</style> |