Changes
This commit is contained in:
@@ -1,3 +1,116 @@
|
||||
<script setup>
|
||||
|
||||
import dayjs from "dayjs";
|
||||
|
||||
definePageMeta({
|
||||
middleware: "auth"
|
||||
})
|
||||
|
||||
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 router = useRouter()
|
||||
const supabase = useSupabaseClient()
|
||||
|
||||
const bankstatements = ref([])
|
||||
|
||||
|
||||
const setupPage = async () => {
|
||||
bankstatements.value = (await supabase.from("bankstatements").select("*, statementallocations(*)").eq('tenant', dataStore.currentTenant).order("date", {ascending:false})).data
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
const selectedStatement = ref(null)
|
||||
const showStatementModal = ref(false)
|
||||
|
||||
const templateColumns = [
|
||||
{
|
||||
key: "account",
|
||||
label: "Konto",
|
||||
sortable: true
|
||||
},{
|
||||
key: "valueDate",
|
||||
label: "Valuta",
|
||||
sortable: true
|
||||
},
|
||||
{
|
||||
key: "amount",
|
||||
label: "Betrag",
|
||||
sortable: true
|
||||
},
|
||||
{
|
||||
key: "openAmount",
|
||||
label: "Offener Betrag",
|
||||
sortable: true
|
||||
},
|
||||
{
|
||||
key: "partner",
|
||||
label: "Name",
|
||||
sortable: true
|
||||
},
|
||||
{
|
||||
key: "text",
|
||||
label: "Beschreibung",
|
||||
sortable: true
|
||||
}
|
||||
]
|
||||
const selectedColumns = ref(templateColumns)
|
||||
const columns = computed(() => templateColumns.filter((column) => selectedColumns.value.includes(column)))
|
||||
|
||||
|
||||
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 || 0
|
||||
|
||||
statement.statementallocations.forEach(item => {
|
||||
if(item.cd_id) {
|
||||
startingAmount = startingAmount - item.amount
|
||||
} else if(item.ii_id) {
|
||||
startingAmount = Number(startingAmount) + item.amount
|
||||
}
|
||||
})
|
||||
|
||||
return startingAmount.toFixed(2)
|
||||
}
|
||||
|
||||
|
||||
const filteredRows = computed(() => {
|
||||
return useSearch(searchString.value, bankstatements.value.filter(i => filterAccount.value.find(x => x.id === i.account) && (showOnlyNotAssigned.value ? Number(calculateOpenSum(i)) !== 0 : true)))
|
||||
})
|
||||
|
||||
setupPage()
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<UDashboardNavbar title="Bankbuchungen">
|
||||
<template #right>
|
||||
@@ -161,104 +274,7 @@
|
||||
</UModal>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
|
||||
import dayjs from "dayjs";
|
||||
|
||||
definePageMeta({
|
||||
middleware: "auth"
|
||||
})
|
||||
|
||||
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 router = useRouter()
|
||||
|
||||
const selectedStatement = ref(null)
|
||||
const showStatementModal = ref(false)
|
||||
|
||||
const templateColumns = [
|
||||
{
|
||||
key: "account",
|
||||
label: "Konto",
|
||||
sortable: true
|
||||
},{
|
||||
key: "valueDate",
|
||||
label: "Valuta",
|
||||
sortable: true
|
||||
},
|
||||
{
|
||||
key: "amount",
|
||||
label: "Betrag",
|
||||
sortable: true
|
||||
},
|
||||
{
|
||||
key: "openAmount",
|
||||
label: "Offener Betrag",
|
||||
sortable: true
|
||||
},
|
||||
{
|
||||
key: "partner",
|
||||
label: "Name",
|
||||
sortable: true
|
||||
},
|
||||
{
|
||||
key: "text",
|
||||
label: "Beschreibung",
|
||||
sortable: true
|
||||
}
|
||||
]
|
||||
const selectedColumns = ref(templateColumns)
|
||||
const columns = computed(() => templateColumns.filter((column) => selectedColumns.value.includes(column)))
|
||||
|
||||
|
||||
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 ? Number(calculateOpenSum(i)) !== 0 : true)))
|
||||
})
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user