Fix False Open State for cancelled Invoices
This commit is contained in:
@@ -75,16 +75,16 @@
|
||||
<template #state-data="{row}">
|
||||
<span v-if="row.state === 'Entwurf'" class="text-rose-500">{{ row.state }}</span>
|
||||
<span
|
||||
v-if="row.state === 'Gebucht' && !items.find(i => i.createddocument && i.createddocument.id === row.id)"
|
||||
v-if="row.state === 'Gebucht' && !hasCancellationInvoice(row)"
|
||||
class="text-primary-500"
|
||||
>
|
||||
{{ row.state }}
|
||||
</span>
|
||||
<span
|
||||
v-else-if="row.state === 'Gebucht' && items.find(i => i.createddocument && i.createddocument.id === row.id && i.type === 'cancellationInvoices') && ['invoices','advanceInvoices'].includes(row.type)"
|
||||
v-else-if="row.state === 'Gebucht' && hasCancellationInvoice(row) && ['invoices','advanceInvoices'].includes(row.type)"
|
||||
class="text-cyan-500"
|
||||
>
|
||||
Storniert mit {{ items.find(i => i.createddocument && i.createddocument.id === row.id).documentNumber }}
|
||||
Storniert mit {{ getCancellationInvoice(row)?.documentNumber }}
|
||||
</span>
|
||||
<span v-else-if="row.state === 'Gebucht'" class="text-primary-500">{{ row.state }}</span>
|
||||
</template>
|
||||
@@ -108,7 +108,7 @@
|
||||
|
||||
<template #dueDate-data="{row}">
|
||||
<span
|
||||
v-if="row.state === 'Gebucht' && row.paymentDays && ['invoices','advanceInvoices'].includes(row.type) && !items.find(i => i.linkedDocument && i.linkedDocument.id === row.id)"
|
||||
v-if="row.state === 'Gebucht' && row.paymentDays && ['invoices','advanceInvoices'].includes(row.type) && !hasCancellationInvoice(row)"
|
||||
:class="dayjs(row.documentDate).add(row.paymentDays,'day').diff(dayjs()) <= 0 && !isPaid(row) ? ['text-rose-500'] : '' "
|
||||
>
|
||||
{{ row.documentDate ? dayjs(row.documentDate).add(row.paymentDays, 'day').format("DD.MM.YY") : '' }}
|
||||
@@ -117,7 +117,7 @@
|
||||
|
||||
<template #paid-data="{row}">
|
||||
<div
|
||||
v-if="(row.type === 'invoices' ||row.type === 'advanceInvoices') && row.state === 'Gebucht' && !items.find(i => i.linkedDocument && i.linkedDocument.id === row.id)">
|
||||
v-if="(row.type === 'invoices' ||row.type === 'advanceInvoices') && row.state === 'Gebucht' && !hasCancellationInvoice(row)">
|
||||
<span v-if="useSum().getIsPaid(row,items)" class="text-primary-500">Bezahlt</span>
|
||||
<span v-else class="text-rose-600">Offen</span>
|
||||
</div>
|
||||
@@ -129,8 +129,8 @@
|
||||
|
||||
<template #amountOpen-data="{row}">
|
||||
<span
|
||||
v-if="!['deliveryNotes','cancellationInvoices','quotes','confirmationOrders'].includes(row.type) && row.state !== 'Entwurf' && !useSum().getIsPaid(row,items) && !items.find(i => i.linkedDocument && i.linkedDocument.id === row.id) ">
|
||||
{{ displayCurrency(useSum().getCreatedDocumentSum(row, items) - row.statementallocations.reduce((n, {amount}) => n + amount, 0)) }}
|
||||
v-if="!['deliveryNotes','cancellationInvoices','quotes','confirmationOrders'].includes(row.type) && row.state !== 'Entwurf' && !hasCancellationInvoice(row) && !useSum().getIsPaid(row,items) ">
|
||||
{{ displayCurrency(useSum().getCreatedDocumentOpenAmount(row, items)) }}
|
||||
</span>
|
||||
</template>
|
||||
</UTable>
|
||||
@@ -264,13 +264,22 @@ const clearSearchString = () => {
|
||||
debouncedSearchString.value = ''
|
||||
}
|
||||
|
||||
const getCancellationInvoice = (row) => {
|
||||
return items.value.find((item) => {
|
||||
const linkedDocumentId = item.createddocument?.id || item.createddocument
|
||||
return item.type === 'cancellationInvoices'
|
||||
&& item.state !== 'Entwurf'
|
||||
&& !item.archived
|
||||
&& linkedDocumentId === row.id
|
||||
})
|
||||
}
|
||||
|
||||
const hasCancellationInvoice = (row) => Boolean(getCancellationInvoice(row))
|
||||
|
||||
const openUnpaidInvoicesFilter = {
|
||||
name: 'Nur offene Rechnungen',
|
||||
filterFunction: (row) => {
|
||||
return ['invoices', 'advanceInvoices'].includes(row.type)
|
||||
&& row.state === 'Gebucht'
|
||||
&& !useSum().getIsPaid(row, items.value)
|
||||
&& !items.value.find(i => i.linkedDocument && i.linkedDocument.id === row.id)
|
||||
return useSum().isOpenCreatedDocument(row, items.value)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -319,8 +328,6 @@ const getRowsForTab = (tabKey) => {
|
||||
}
|
||||
|
||||
const isPaid = (item) => {
|
||||
let amountPaid = 0
|
||||
item.statementallocations.forEach(allocation => amountPaid += allocation.amount)
|
||||
return Number(amountPaid.toFixed(2)) === useSum().getCreatedDocumentSum(item, items.value)
|
||||
return useSum().getIsPaid(item, items.value)
|
||||
}
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user