Changes in Statement Allocation and Open Sum Calc
This commit is contained in:
@@ -11,32 +11,21 @@ defineShortcuts({
|
||||
//console.log(searchinput)
|
||||
//searchinput.value.focus()
|
||||
document.getElementById("searchinput").focus()
|
||||
},
|
||||
'escape': () => {
|
||||
//console.log(searchinput)
|
||||
//searchinput.value.focus()
|
||||
showStatementModal.value = false
|
||||
}
|
||||
})
|
||||
|
||||
const dataStore = useDataStore()
|
||||
const profileStore = useProfileStore()
|
||||
const router = useRouter()
|
||||
const supabase = useSupabaseClient()
|
||||
|
||||
const bankstatements = ref([])
|
||||
|
||||
const bankaccounts = ref([])
|
||||
|
||||
const setupPage = async () => {
|
||||
bankstatements.value = (await supabase.from("bankstatements").select("*, statementallocations(*)").eq('tenant', profileStore.currentTenant).order("date", {ascending:false})).data
|
||||
|
||||
bankaccounts.value = await useSupabaseSelect("bankaccounts")
|
||||
}
|
||||
|
||||
|
||||
|
||||
const selectedStatement = ref(null)
|
||||
const showStatementModal = ref(false)
|
||||
|
||||
const templateColumns = [
|
||||
{
|
||||
key: "account",
|
||||
@@ -73,35 +62,23 @@ const columns = computed(() => templateColumns.filter((column) => selectedColumn
|
||||
|
||||
|
||||
const searchString = ref('')
|
||||
const filterAccount = ref(dataStore.bankAccounts || [])
|
||||
const filterAccount = ref(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 || 0
|
||||
let startingAmount = 0
|
||||
|
||||
statement.statementallocations.forEach(item => {
|
||||
if(item.cd_id) {
|
||||
startingAmount = startingAmount - item.amount
|
||||
} else if(item.ii_id) {
|
||||
startingAmount = Number(startingAmount) + item.amount
|
||||
}
|
||||
startingAmount += Math.abs(item.amount)
|
||||
})
|
||||
|
||||
return startingAmount.toFixed(2)
|
||||
return (Math.abs(statement.amount) - startingAmount).toFixed(2)
|
||||
}
|
||||
|
||||
|
||||
@@ -134,11 +111,12 @@ setupPage()
|
||||
<UDashboardToolbar>
|
||||
<template #left>
|
||||
<USelectMenu
|
||||
:options="dataStore.bankAccounts"
|
||||
:options="bankaccounts"
|
||||
v-model="filterAccount"
|
||||
option-attribute="iban"
|
||||
multiple
|
||||
by="id"
|
||||
:ui-menu="{ width: 'min-w-max' }"
|
||||
>
|
||||
<template #label>
|
||||
Konto
|
||||
@@ -158,6 +136,7 @@ setupPage()
|
||||
multiple
|
||||
class="hidden lg:block"
|
||||
by="key"
|
||||
:ui-menu="{ width: 'min-w-max' }"
|
||||
>
|
||||
<template #label>
|
||||
Spalten
|
||||
@@ -175,7 +154,7 @@ setupPage()
|
||||
>
|
||||
|
||||
<template #account-data="{row}">
|
||||
{{row.account ? (dataStore.getBankAccountById(row.account).name ? dataStore.getBankAccountById(row.account).name :dataStore.getBankAccountById(row.account).iban) : ""}}
|
||||
{{row.account ? bankaccounts.find(i => i.id === row.account).iban : ""}}
|
||||
</template>
|
||||
<template #valueDate-data="{row}">
|
||||
{{dayjs(row.valueDate).format("DD.MM.YY")}}
|
||||
@@ -207,72 +186,7 @@ setupPage()
|
||||
</template>
|
||||
</UTable>
|
||||
|
||||
<UModal
|
||||
v-model="showStatementModal"
|
||||
class="no-doc-sroll"
|
||||
>
|
||||
|
||||
<UCard class="h-full">
|
||||
<template #header>
|
||||
<div class="flex items-center justify-between">
|
||||
<span
|
||||
v-if="selectedStatement.amount > 0"
|
||||
class="text-base font-semibold leading-6 text-gray-900 dark:text-white"
|
||||
>
|
||||
{{selectedStatement.debName}}
|
||||
</span>
|
||||
<span
|
||||
v-else-if="selectedStatement.amount < 0"
|
||||
class="text-base font-semibold leading-6 text-gray-900 dark:text-white"
|
||||
>
|
||||
{{selectedStatement.credName}}
|
||||
</span>
|
||||
|
||||
<UButton color="gray" variant="ghost" icon="i-heroicons-x-mark-20-solid" class="-my-1" @click="showStatementModal = false" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
{{selectedStatement.id}}
|
||||
|
||||
<div class="flex flex-row">
|
||||
<div class="w-1/2 truncate">
|
||||
<p>Betrag: {{String(selectedStatement.amount.toFixed(2)).replace(".",",")}} €</p>
|
||||
<p>Buchungsdatum: {{dayjs(selectedStatement.date).format("DD.MM.YYYY")}}</p>
|
||||
<p>Werstellungsdatum: {{dayjs(selectedStatement.valueDate).format("DD.MM.YYYY")}}</p>
|
||||
<p>Partner: {{selectedStatement.amount > 0 ? selectedStatement.debName : selectedStatement.credName}}</p>
|
||||
<p>Partner IBAN: {{selectedStatement.amount > 0 ? selectedStatement.debIban : selectedStatement.credIban}}</p>
|
||||
<p>Konto: {{selectedStatement.account}}</p>
|
||||
<p class="text-wrap">Beschreibung: <br>{{selectedStatement.text}}</p>
|
||||
</div>
|
||||
<div class="w-full p-2 overflow-scroll">
|
||||
<UCard
|
||||
v-for="document in dataStore.getOpenDocuments()"
|
||||
>
|
||||
|
||||
|
||||
{{document.documentNumber ||document.reference}}
|
||||
<!-- {{document}}-->
|
||||
</UCard>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- <UFormGroup>
|
||||
<USelectMenu
|
||||
:options="dataStore.createddocuments"
|
||||
/>
|
||||
</UFormGroup>-->
|
||||
|
||||
|
||||
|
||||
</UCard>
|
||||
|
||||
</UModal>
|
||||
</template>
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user