Changed Booking

Changed Columns in Incoming Invoices
This commit is contained in:
2025-03-24 13:33:39 +01:00
parent b5b1741f21
commit ee1aa1bbed
2 changed files with 42 additions and 65 deletions

View File

@@ -39,7 +39,7 @@ const ownaccounts = ref([])
const loading = ref(true)
const setup = async () => {
if(route.params.id) {
itemInfo.value = (await supabase.from("bankstatements").select("*, statementallocations(*, cd_id(*, customer(*)), ii_id(*))").eq("id",route.params.id).single()).data //dataStore.bankstatements.find(i => i.id === Number(route.params.id))
itemInfo.value = (await supabase.from("bankstatements").select("*, statementallocations(*, cd_id(*), ii_id(*))").eq("id",route.params.id).single()).data //dataStore.bankstatements.find(i => i.id === Number(route.params.id))
}
if(itemInfo.value) oldItemInfo.value = JSON.parse(JSON.stringify(itemInfo.value))
@@ -98,17 +98,23 @@ const getInvoiceSum = (invoice) => {
sum += account.amountTax
sum += account.amountNet
})
console.log(sum)
if(invoice.expense) {
return (sum * -1).toFixed(2)
} else {
return sum.toFixed(2)
}
}
const calculateOpenSum = computed(() => {
let startingAmount = 0
itemInfo.value.statementallocations.forEach(item => {
startingAmount += Math.abs(item.amount)
startingAmount += item.amount
})
return (Math.abs(itemInfo.value.amount) - startingAmount).toFixed(2)
return (itemInfo.value.amount - startingAmount).toFixed(2)
})
@@ -150,6 +156,10 @@ const saveAllocation = async (allocation) => {
if(data) {
await setup()
accountToSave.value = null
vendorAccountToSave.value = null
customerAccountToSave.value = null
ownAccountToSave.value = null
allocationDescription.value = null
}
@@ -351,15 +361,15 @@ setup()
<UAlert
class="mb-3 mt-3"
:color="calculateOpenSum > 0 ? 'rose' : 'primary'"
:color="calculateOpenSum != 0 ? 'rose' : 'primary'"
variant="outline"
:title="calculateOpenSum > 0 ? `${displayCurrency(calculateOpenSum)} von ${displayCurrency(Math.abs(itemInfo.amount))} nicht zugewiesen` : 'Kontobewegung vollständig zugewiesen'"
:title="calculateOpenSum != 0 ? `${displayCurrency(Math.abs(calculateOpenSum))} von ${displayCurrency(Math.abs(itemInfo.amount))} nicht zugewiesen` : 'Kontobewegung vollständig zugewiesen'"
>
<template #description>
<UProgress
:value="Math.abs(itemInfo.amount) - calculateOpenSum"
:max="Math.abs(itemInfo.amount)"
:color="calculateOpenSum > 0 ? 'rose' : 'primary'"
:color="calculateOpenSum != 0 ? 'rose' : 'primary'"
/>
</template>
</UAlert>
@@ -443,74 +453,39 @@ setup()
</UCard>
<UCard
class="mt-5"
:ui="{ring: itemInfo.statementallocations.find(i => i.cd_id === item.cd_id) ? 'ring-primary-500' : 'ring-gray-200 dark:ring-gray-800'}"
v-for="item in itemInfo.statementallocations.filter(i => i.ii_id)"
>
<template #header>
<div class="flex flex-row justify-between">
<span>{{vendors.find(i => i.id === item.ii_id.vendor).vendorNumber}} - {{vendors.find(i => i.id === item.ii_id.vendor).name}}</span>
<span class="font-semibold text-nowrap">{{displayCurrency(item.amount)}}</span>
</div>
</template>
<UButton
icon="i-heroicons-x-mark"
variant="outline"
color="rose"
class="mr-3"
@click="removeAllocation(item.id)"
/>
</UCard>
<UCard
class="mt-5"
v-for="item in itemInfo.statementallocations.filter(i => i.cd_id)"
>
<template #header>
<div class="flex flex-row justify-between">
<span>{{item.cd_id.customer ? item.cd_id.customer.name : ""}} - {{item.cd_id.documentNumber}}</span>
<span v-if="customers.find(i => i.id === item.cd_id.customer)">{{customers.find(i => i.id === item.cd_id.customer).customerNumber}} - {{customers.find(i => i.id === item.cd_id.customer).name}}</span>
<span class="font-semibold text-nowrap">{{displayCurrency(item.amount)}}</span>
</div>
</template>
<!-- <UButton
icon="i-heroicons-check"
variant="outline"
class="mr-3"
v-if="!itemInfo.statementallocations.find(i => i.cd_id === document.id)"
@click="saveAllocation({cd_id: document.id, bs_id: itemInfo.id, amount: Number(useSum().getCreatedDocumentSum(document,createddocuments))})"
/>-->
<UButton
icon="i-heroicons-x-mark"
variant="outline"
color="rose"
class=""
class="mr-3"
@click="removeAllocation(item.id)"
/>
<!-- <EntityModalButtons
:button-create="false"
:button-edit="false"
:id="item.cd_id.id"
type="createddocuments"/>
{{item.cd_id.id}}-->
<!-- <UButton
variant="outline"
icon="i-heroicons-arrow-right-end-on-rectangle"
@click="router.push(`/createDocument/show/${document.id}`)"
/>-->
</UCard>
<UCard
class="mt-5"
:ui="{ring: itemInfo.statementallocations.find(i => i.ii_id === invoice.id) ? 'ring-primary-500' : 'ring-gray-200 dark:ring-gray-800'}"
v-for="invoice in allocatedIncomingInvoices"
>
<template #header>
<div class="flex flex-row justify-between">
<span>{{invoice.vendor ? invoice.vendor.name : ""}} - {{invoice.reference}}</span>
<span class="font-semibold text-nowrap">{{displayCurrency(getInvoiceSum(invoice))}}</span>
</div>
</template>
<UButton
icon="i-heroicons-check"
variant="outline"
class="mr-3"
v-if="!itemInfo.statementallocations.find(i => i.ii_id === invoice.id)"
@click="saveAllocation({ii_id: document.id, bs_id: itemInfo.id, amount: Number(getInvoiceSum(invoice)), description: allocationDescription})"
/>
<UButton
icon="i-heroicons-x-mark"
variant="outline"
color="rose"
class="mr-3"
v-if="itemInfo.statementallocations.find(i => i.ii_id === invoice.id)"
@click="removeAllocation(itemInfo.statementallocations.find(i => i.ii_id === invoice.id).id)"
/>
<UButton
variant="outline"
icon="i-heroicons-arrow-right-end-on-rectangle"
@click="router.push(`/createDocument/show/${document.id}`)"
/>
</UCard>
</div>
</div>
@@ -721,8 +696,6 @@ setup()
</InputGroup>
</UFormGroup>
<UDivider
class="my-3"
>
@@ -787,7 +760,7 @@ setup()
<template #header>
<div class="flex flex-row justify-between">
<span>{{item.vendor ? item.vendor.name : ''}} - {{item.reference}}</span>
<span class="font-semibold text-rose-600 text-nowrap">-{{displayCurrency(getInvoiceSum(item))}}</span>
<span class="font-semibold text-rose-600 text-nowrap">{{displayCurrency(getInvoiceSum(item))}}</span>
</div>
</template>
<UButton

View File

@@ -81,6 +81,10 @@ const templateColumns = [
{
key: "paymentType",
label: "Zahlart"
},
{
key: "description",
label: "Beschreibung"
}
]
const selectedColumns = ref(templateColumns)