This commit is contained in:
2024-05-23 10:27:52 +02:00
parent 28ff274107
commit eca1cd380b
10 changed files with 166 additions and 41 deletions

View File

@@ -76,6 +76,9 @@
class="text-rose-500"
>{{String(row.amount.toFixed(2)).replace(".",",")}} </span>
</template>
<template #openAmount-data="{row}">
{{displayCurrency(calculateOpenSum(row))}}
</template>
<template #partner-data="{row}">
<span
v-if="row.amount < 0"
@@ -200,6 +203,11 @@ const templateColumns = [
label: "Betrag",
sortable: true
},
{
key: "openAmount",
label: "Offener Betrag",
sortable: true
},
{
key: "partner",
label: "Name",
@@ -219,9 +227,36 @@ const searchString = ref('')
const filterAccount = ref(dataStore.bankAccounts || [])
const showOnlyNotAssigned = ref(true)
const displayCurrency = (value, currency = "€") => {
return `${Number(value).toFixed(2).replace(".",",")} ${currency}`
}
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 calculateOpenSum = (statement) => {
let startingAmount = statement.amount
statement.assignments.forEach(item => {
if(item.type === "createdDocument") {
let doc = dataStore.getCreatedDocumentById(item.id)
startingAmount = startingAmount - getDocumentSum(doc)
}
})
return startingAmount.toFixed(2)
}
const filteredRows = computed(() => {
return useSearch(searchString.value, dataStore.bankstatements.filter(i => filterAccount.value.find(x => x.id === i.account) && (showOnlyNotAssigned.value ? (!i.createdDocument && !i.incomingInvoice) : true)))
return useSearch(searchString.value, dataStore.bankstatements.filter(i => filterAccount.value.find(x => x.id === i.account) && (showOnlyNotAssigned.value ? Number(calculateOpenSum(i)) !== 0 : true)))
})
</script>