Eingangsbelege um offenen Betrag ergänzen
This commit is contained in:
@@ -58,6 +58,7 @@ const isPreparing = ref(false)
|
||||
|
||||
const type = "incominginvoices"
|
||||
const dataType = dataStore.dataTypes[type]
|
||||
const openAmountColumnKey = "openAmount"
|
||||
|
||||
const setupPage = async () => {
|
||||
items.value = await useEntities(type).select("*, vendor(id,name), statementallocations(id,amount)",sort.value.column,sort.value.direction === "asc")
|
||||
@@ -93,7 +94,13 @@ const prepareInvoices = async () => {
|
||||
|
||||
setupPage()
|
||||
|
||||
const selectedColumns = ref(tempStore.columns[type] ? tempStore.columns[type] : dataType.templateColumns.filter(i => !i.disabledInTable))
|
||||
const selectedColumns = ref(tempStore.columns[type] ? [...tempStore.columns[type]] : dataType.templateColumns.filter(i => !i.disabledInTable))
|
||||
if (!selectedColumns.value.find((column) => column.key === openAmountColumnKey)) {
|
||||
const openAmountColumn = dataType.templateColumns.find((column) => column.key === openAmountColumnKey)
|
||||
if (openAmountColumn) {
|
||||
selectedColumns.value.splice(5, 0, openAmountColumn)
|
||||
}
|
||||
}
|
||||
const columns = computed(() => dataType.templateColumns.filter((column) => !column.disabledInTable && selectedColumns.value.find(i => i.key === column.key)))
|
||||
|
||||
const selectableFilters = ref(dataType.filters.map(i => i.name))
|
||||
@@ -142,10 +149,18 @@ const getInvoiceSum = (invoice) => {
|
||||
return sum.toFixed(2)
|
||||
}
|
||||
|
||||
const isPaid = (item) => {
|
||||
const getPaidAmount = (item) => {
|
||||
let amountPaid = 0
|
||||
item.statementallocations.forEach(allocation => amountPaid += allocation.amount)
|
||||
return Math.abs(amountPaid) === Math.abs(Number(getInvoiceSum(item)))
|
||||
return Number(Math.abs(amountPaid).toFixed(2))
|
||||
}
|
||||
|
||||
const isPaid = (item) => {
|
||||
return getPaidAmount(item) >= Number(Math.abs(Number(getInvoiceSum(item))).toFixed(2))
|
||||
}
|
||||
|
||||
const getOpenAmount = (item) => {
|
||||
return Number(Math.max(0, Number(getInvoiceSum(item)) - getPaidAmount(item)).toFixed(2))
|
||||
}
|
||||
|
||||
const unwrapInvoiceRow = (invoiceLike) => invoiceLike?.original || invoiceLike
|
||||
@@ -283,6 +298,11 @@ const selectIncomingInvoice = (invoiceLike) => {
|
||||
<template #amount-cell="{row}">
|
||||
{{displayCurrency(sum.getIncomingInvoiceSum(row.original))}}
|
||||
</template>
|
||||
<template #openAmount-cell="{row}">
|
||||
<span v-if="row.original.state === 'Gebucht' && !isPaid(row.original)">
|
||||
{{ displayCurrency(getOpenAmount(row.original)) }}
|
||||
</span>
|
||||
</template>
|
||||
<template #dueDate-cell="{row}">
|
||||
<span v-if="row.original.dueDate">{{dayjs(row.original.dueDate).format("DD.MM.YYYY")}}</span>
|
||||
</template>
|
||||
|
||||
@@ -2200,6 +2200,10 @@ export const useDataStore = defineStore('data', () => {
|
||||
key: "amount",
|
||||
label: "Betrag",
|
||||
},
|
||||
{
|
||||
key: "openAmount",
|
||||
label: "Offener Betrag",
|
||||
},
|
||||
{
|
||||
key: "dueDate",
|
||||
label: "Fälligkeitsdatum",
|
||||
|
||||
Reference in New Issue
Block a user