Cahnges in Invoice allocation in statements
This commit is contained in:
@@ -42,7 +42,7 @@ const items = ref([])
|
||||
const selectedItem = ref(0)
|
||||
|
||||
const setupPage = async () => {
|
||||
items.value = await useSupabaseSelect("incominginvoices","*, vendor(id,name)")
|
||||
items.value = await useSupabaseSelect("incominginvoices","*, vendor(id,name), statementallocations(id,amount)")
|
||||
}
|
||||
|
||||
setupPage()
|
||||
@@ -66,6 +66,10 @@ const templateColumns = [
|
||||
key: "vendor",
|
||||
label: "Lieferant"
|
||||
},
|
||||
{
|
||||
key: "amount",
|
||||
label: "Betrag"
|
||||
},
|
||||
{
|
||||
key: "dueDate",
|
||||
label: "Fälligkeitsdatum"
|
||||
@@ -89,6 +93,25 @@ const filteredRows = computed(() => {
|
||||
|
||||
})
|
||||
|
||||
const displayCurrency = (value, currency = "€") => {
|
||||
return `${Number(value).toFixed(2).replace(".",",")} ${currency}`
|
||||
}
|
||||
const getInvoiceSum = (invoice) => {
|
||||
let sum = 0
|
||||
invoice.accounts.forEach(account => {
|
||||
sum += account.amountTax
|
||||
sum += account.amountNet
|
||||
})
|
||||
return sum.toFixed(2)
|
||||
}
|
||||
|
||||
const isPaid = (item) => {
|
||||
let amountPaid = 0
|
||||
item.statementallocations.forEach(allocation => amountPaid += allocation.amount)
|
||||
|
||||
return amountPaid === Number(getInvoiceSum(item))
|
||||
}
|
||||
|
||||
|
||||
|
||||
</script>
|
||||
@@ -149,12 +172,15 @@ const filteredRows = computed(() => {
|
||||
<template #vendor-data="{row}">
|
||||
{{row.vendor ? row.vendor.name : ""}}
|
||||
</template>
|
||||
<template #amount-data="{row}">
|
||||
{{displayCurrency(getInvoiceSum(row))}}
|
||||
</template>
|
||||
<template #dueDate-data="{row}">
|
||||
{{dayjs(row.dueDate).format("DD.MM.YYYY")}}
|
||||
</template>
|
||||
<template #paid-data="{row}">
|
||||
<!-- <span v-if="dataStore.bankstatements.find(x => x.statementallocations.find(y => y.ii_id === row.id))" class="text-primary-500">Bezahlt</span>
|
||||
<span v-else class="text-rose-600">Offen</span>-->
|
||||
<span v-if="isPaid(row)" class="text-primary-500">Bezahlt</span>
|
||||
<span v-else class="text-rose-600">Offen</span>
|
||||
</template>
|
||||
</UTable>
|
||||
</UDashboardPanelContent>
|
||||
|
||||
Reference in New Issue
Block a user