Compare commits

...

3 Commits

Author SHA1 Message Date
13936db100 Move expense options into advanced booking
All checks were successful
Build and Push Docker Images / build-backend (push) Successful in 24s
Build and Push Docker Images / build-frontend (push) Successful in 1m45s
Build and Push Docker Images / build-website (push) Successful in 27s
Build and Push Docker Images / build-central-services-api (push) Successful in 24s
Build and Push Docker Images / build-central-services-admin (push) Successful in 24s
Build and Push Docker Images / build-docs (push) Successful in 23s
2026-08-06 11:51:17 +02:00
78d56738e8 Clarify bank allocation action 2026-08-06 11:45:21 +02:00
c8a7f4f396 Speed up bank allocation updates 2026-08-06 11:42:19 +02:00

View File

@@ -39,26 +39,8 @@ 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)
console.log(itemInfo.value)
}
if (itemInfo.value) oldItemInfo.value = JSON.parse(JSON.stringify(itemInfo.value))
manualAllocationSum.value = calculateOpenSum.value
allocationDepreciationStartDate.value = dayjs(itemInfo.value?.date || new Date()).format("YYYY-MM-DD")
createddocuments.value = (await useEntities("createddocuments").select("*, statementallocations(*), customer(id,name)"))
const rebuildDocumentLists = () => {
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 => useSum().isOpenCreatedDocument(i, createddocuments.value))
openDocuments.value = openDocuments.value.map(i => {
@@ -72,8 +54,38 @@ const setup = async () => {
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))
openIncomingInvoices.value = incominginvoices.value.filter(i =>
!i.archived && i.statementallocations.reduce((n, {amount}) => n + amount, 0).toFixed(2) !== getInvoiceSum(i, false)
)
}
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))
const setup = async () => {
loading.value = true
const [statement, documentItems, invoiceItems, accountItems, ownAccountItems, customerItems, vendorItems] = await Promise.all([
route.params.id
? useEntities("bankstatements").selectSingle(route.params.id, "*, statementallocations(*, cd_id(*), ii_id(*))")
: Promise.resolve(itemInfo.value),
useEntities("createddocuments").select("*, statementallocations(*), customer(id,name)"),
useEntities("incominginvoices").select("*, statementallocations(*), vendor(*)"),
useEntities("accounts").selectSpecial("*", "number", true),
useEntities("ownaccounts").select(),
useEntities("customers").select(),
useEntities("vendors").select()
])
itemInfo.value = statement
if (itemInfo.value) oldItemInfo.value = JSON.parse(JSON.stringify(itemInfo.value))
manualAllocationSum.value = calculateOpenSum.value
allocationDepreciationStartDate.value = dayjs(itemInfo.value?.date || new Date()).format("YYYY-MM-DD")
createddocuments.value = documentItems
incominginvoices.value = invoiceItems.filter(i => i.state === "Gebucht")
accounts.value = accountItems
ownaccounts.value = ownAccountItems
customers.value = customerItems
vendors.value = vendorItems
rebuildDocumentLists()
if (itemInfo.value?.id) {
statementSuggestions.value = await useFunctions().useBankingStatementSuggestions(itemInfo.value.id)
@@ -189,7 +201,17 @@ const saveAllocation = async (allocation) => {
})
if (res) {
await setup()
itemInfo.value.statementallocations.push(res)
if (res.createddocument) {
const document = createddocuments.value.find(item => item.id === res.createddocument)
document?.statementallocations.push(res)
}
if (res.incominginvoice) {
const invoice = incominginvoices.value.find(item => item.id === res.incominginvoice)
invoice?.statementallocations.push(res)
}
rebuildDocumentLists()
manualAllocationSum.value = calculateOpenSum.value
accountToSave.value = null
vendorAccountToSave.value = null
customerAccountToSave.value = null
@@ -209,7 +231,15 @@ const removeAllocation = async (allocationId) => {
await useNuxtApp().$api(`/api/banking/statements/${allocationId}`, {
method: "DELETE"
})
await setup()
itemInfo.value.statementallocations = itemInfo.value.statementallocations.filter(item => item.id !== allocationId)
createddocuments.value.forEach(document => {
document.statementallocations = document.statementallocations.filter(item => item.id !== allocationId)
})
incominginvoices.value.forEach(invoice => {
invoice.statementallocations = invoice.statementallocations.filter(item => item.id !== allocationId)
})
rebuildDocumentLists()
manualAllocationSum.value = calculateOpenSum.value
}
const searchString = ref(tempStore.searchStrings["bankstatementsedit"] || '')
@@ -669,13 +699,12 @@ setup()
<span class="font-mono text-xs text-gray-500 mr-2">{{ option.number }}</span> {{ option.label }}
</template>
</USelectMenu>
<UTooltip text="Manuell Buchen">
<UButton
icon="i-heroicons-plus"
:disabled="!accountToSave"
@click="saveAllocation({bankstatement: itemInfo.id, amount: manualAllocationSum, account: accountToSave, description: allocationDescription })"
/>
</UTooltip>
<UButton
icon="i-heroicons-check"
label="Buchen"
:disabled="!accountToSave"
@click="saveAllocation({bankstatement: itemInfo.id, amount: manualAllocationSum, account: accountToSave, description: allocationDescription })"
/>
</div>
</UFormField>
</div>
@@ -688,29 +717,31 @@ setup()
</div>
</div>
<div class="mt-4 grid grid-cols-1 md:grid-cols-3 gap-3">
<UFormField label="Aufwandsart" size="sm">
<USelectMenu
v-model="allocationBookingMode"
:items="EXPENSE_BOOKING_MODE_ITEMS"
value-key="value"
label-key="label"
/>
</UFormField>
<div v-if="showMoreWithoutRecipe"
class="mt-4 p-3 bg-gray-50 dark:bg-gray-800 rounded-lg border border-gray-200 dark:border-gray-700">
<div class="grid grid-cols-1 md:grid-cols-3 gap-3">
<UFormField label="Aufwandsart" size="sm">
<USelectMenu
v-model="allocationBookingMode"
:items="EXPENSE_BOOKING_MODE_ITEMS"
value-key="value"
label-key="label"
/>
</UFormField>
<UFormField label="Abschreibungsdauer (Monate)" size="sm" v-if="isDepreciationAllocation">
<UInput v-model="allocationDepreciationMonths" type="number" min="1" step="1" />
</UFormField>
<UFormField label="Abschreibungsdauer (Monate)" size="sm" v-if="isDepreciationAllocation">
<UInput v-model="allocationDepreciationMonths" type="number" min="1" step="1" />
</UFormField>
<UFormField label="Methode" size="sm" v-if="isDepreciationAllocation">
<USelectMenu
v-model="allocationDepreciationMethod"
:items="DEPRECIATION_METHOD_ITEMS"
value-key="value"
label-key="label"
/>
</UFormField>
</div>
<UFormField label="Methode" size="sm" v-if="isDepreciationAllocation">
<USelectMenu
v-model="allocationDepreciationMethod"
:items="DEPRECIATION_METHOD_ITEMS"
value-key="value"
label-key="label"
/>
</UFormField>
</div>
<div class="mt-3 grid grid-cols-1 md:grid-cols-3 gap-3" v-if="isDepreciationAllocation">
<UFormField label="Start Abschreibung" size="sm">
@@ -738,9 +769,8 @@ setup()
/>
</div>
<div v-if="showMoreWithoutRecipe"
class="mt-4 p-3 bg-gray-50 dark:bg-gray-800 rounded-lg border border-gray-200 dark:border-gray-700 grid grid-cols-1 md:grid-cols-3 gap-3">
<USelectMenu :items="ownaccounts" value-key="id" label-key="name" v-model="ownAccountToSave"
<div class="mt-3 grid grid-cols-1 md:grid-cols-3 gap-3">
<USelectMenu :items="ownaccounts" value-key="id" label-key="name" v-model="ownAccountToSave"
:search-input="{ placeholder: 'Eigenes Konto' }" :filter-fields="['number','name']" placeholder="Eigenes Konto">
<template #default>
{{ ownAccountToSave ? ownaccounts.find(i => i.id === ownAccountToSave).name : 'Eigenes Konto' }}
@@ -758,9 +788,10 @@ setup()
{{ vendorAccountToSave ? vendors.find(i => i.id === vendorAccountToSave).name : 'Lieferant' }}
</template>
</USelectMenu>
<div class="md:col-span-3 flex justify-end">
<UButton size="xs" label="Zuweisen"
@click="saveAllocation({bankstatement: itemInfo.id, amount: manualAllocationSum, ownaccount: ownAccountToSave ? ownAccountToSave : null, customer: customerAccountToSave ? customerAccountToSave : null, vendor: vendorAccountToSave ? vendorAccountToSave : null, description: allocationDescription })"/>
<div class="md:col-span-3 flex justify-end">
<UButton size="xs" label="Zuweisen"
@click="saveAllocation({bankstatement: itemInfo.id, amount: manualAllocationSum, ownaccount: ownAccountToSave ? ownAccountToSave : null, customer: customerAccountToSave ? customerAccountToSave : null, vendor: vendorAccountToSave ? vendorAccountToSave : null, description: allocationDescription })"/>
</div>
</div>
</div>