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

@@ -6,6 +6,8 @@ const tenants = (await supabase.from("tenants").select()).data
const dataStore = useDataStore()
const viewport = useViewport()
console.log("1.")
/*watch(viewport.breakpoint, (newBreakpoint, oldBreakpoint) => {
console.log('Breakpoint updated:', oldBreakpoint, '->', newBreakpoint)
})*/

View File

@@ -27,6 +27,7 @@ const openShowModal = ref(false)
const openDocument = async () => {
//selectedDocument.value = doc
openShowModal.value = true
console.log("open")
}
const updateDocument = async () => {
@@ -131,7 +132,7 @@ const updateDocumentAssignment = async () => {
</script>
<template>
<div class="documentListItem" @click="returnEmit ? $emit('clicked', documentData.id) : openDocument">
<div class="documentListItem" @click="returnEmit ? $emit('clicked', documentData.id) : openShowModal = true">
<object
:data="`${documentData.url}#toolbar=0&navpanes=0&scrollbar=0`"
class="previewEmbed"

View File

@@ -8,6 +8,8 @@ const supabase = useSupabaseClient()
const router = useRouter()
const route = useRoute()
console.log("2.")
dataStore.initializeData((await supabase.auth.getUser()).data.user.id)

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>

View File

@@ -53,9 +53,23 @@ const getInvoiceSum = (invoice) => {
sum += account.amountTax
sum += account.amountNet
})
return sum
return sum.toFixed(2)
}
const calculateOpenSum = computed(() => {
let startingAmount = itemInfo.value.amount
itemInfo.value.assignments.forEach(item => {
if(item.type === "createdDocument") {
let doc = dataStore.getCreatedDocumentById(item.id)
startingAmount = startingAmount - getDocumentSum(doc)
}
})
return startingAmount.toFixed(2)
})
setup()
</script>
@@ -121,9 +135,11 @@ setup()
</template>
</UDashboardNavbar>
<UDashboardPanelContent>
<UDashboardPanelContent
class="flex flex-row"
>
<UCard
class="w-4/5 mx-auto mt-10"
class="w-2/5 mx-auto mt-5"
v-if="itemInfo"
>
<template #header>
@@ -190,12 +206,28 @@ setup()
</td>
</tr>
<tr class="flex-row flex justify-between">
<td>
<td colspan="2">
<span class="font-semibold">Verknüpftes Dokument:</span>
</td>
</tr>
<tr
class="flex-row flex justify-between mb-3"
v-for="item in itemInfo.assignments"
>
<td>
<span v-if="itemInfo.createdDocument"><nuxt-link :to="`/createDocument/show/${itemInfo.createdDocument}`">{{dataStore.createddocuments.find(i => i.id === itemInfo.createdDocument).documentNumber}}</nuxt-link></span>
<span v-else-if="itemInfo.incomingInvoice"><nuxt-link :to="`/incominInvoices/show/${itemInfo.incomingInvoice}`">{{dataStore.getIncomingInvoiceById(itemInfo.incomingInvoice).reference}}</nuxt-link></span>
<!-- <span v-if="itemInfo.createdDocument"><nuxt-link :to="`/createDocument/show/${itemInfo.createdDocument}`">{{dataStore.createddocuments.find(i => i.id === itemInfo.createdDocument).documentNumber}}</nuxt-link></span>
<span v-else-if="itemInfo.incomingInvoice"><nuxt-link :to="`/incominInvoices/show/${itemInfo.incomingInvoice}`">{{dataStore.getIncomingInvoiceById(itemInfo.incomingInvoice).reference}}</nuxt-link></span>-->
<span v-if="item.type === 'createdDocument'">
{{dataStore.getCreatedDocumentById(item.id).documentNumber}}
</span>
</td>
<td>
<UButton
variant="outline"
icon="i-heroicons-arrow-right-end-on-rectangle"
@click="router.push(`/createDocument/show/${item.id}`)"
/>
</td>
</tr>
<tr class="flex-row flex justify-between">
@@ -209,32 +241,53 @@ setup()
</td>
</tr>
</table>
</UCard>
<UDivider
class="mt-5 w-4/5 mx-auto"
<!-- <UDivider
class="mt-5 w-2/5 mx-auto"
v-if="!itemInfo.createdDocument && !itemInfo.incomingInvoice"
/>
/>-->
<UCard
class="w-4/5 mx-auto mt-5"
v-if="itemInfo.amount > 0 && !itemInfo.createdDocument"
:ui="{ring: itemInfo.createdDocument === document.id ? 'ring-primary-500' : 'ring-gray-200 dark:ring-gray-800'}"
v-for="document in dataStore.getOpenDocuments()"
<div
class="w-2/5 mx-auto"
v-if="itemInfo.amount > 0 "
>
<template #header>
<div class="flex flex-row justify-between">
<span>{{dataStore.getCustomerById(document.customer).name}} - {{document.documentNumber}}</span>
<span class="font-semibold text-primary-500">{{displayCurrency(getDocumentSum(document))}}</span>
</div>
</template>
<UButton
icon="i-heroicons-check"
variant="outline"
v-if="Number(getDocumentSum(document)) === itemInfo.amount"
@click="itemInfo.createdDocument = document.id"
/>
</UCard>
<UDivider
label="Test"
>
<span>Offene Summe: {{displayCurrency(calculateOpenSum)}}</span>
</UDivider>
<UCard
class="mt-5"
:ui="{ring: itemInfo.assignments.find(i => i.id === document.id) ? 'ring-primary-500' : 'ring-gray-200 dark:ring-gray-800'}"
v-for="document in dataStore.getOpenDocuments()"
>
<template #header>
<div class="flex flex-row justify-between">
<span>{{dataStore.getCustomerById(document.customer).name}} - {{document.documentNumber}}</span>
<span class="font-semibold text-primary-500">{{displayCurrency(getDocumentSum(document))}}</span>
</div>
</template>
<UButton
icon="i-heroicons-check"
variant="outline"
class="mr-3"
v-if="!itemInfo.assignments.find(i => i.id === document.id)"
@click="itemInfo.assignments.push({type: 'createdDocument',id: document.id})"
/>
<UButton
icon="i-heroicons-x-mark"
variant="outline"
color="rose"
v-if="itemInfo.assignments.find(i => i.id === document.id)"
@click="itemInfo.assignments = itemInfo.assignments.filter(i => i.id !== document.id)"
/>
</UCard>
</div>

View File

@@ -684,6 +684,7 @@ setupPage()
/>
</UFormGroup>
<InputGroup class="w-full">
<UFormGroup
label="Datum:"
@@ -923,7 +924,8 @@ setupPage()
:search-attributes="['name']"
v-model="row.product"
@change="row.unit = dataStore.getProductById(row.product).unit,
row.price = dataStore.getProductById(row.product).sellingPrice || 0"
row.price = dataStore.getProductById(row.product).sellingPrice || 0,
row.description = dataStore.getProductById(row.product).description"
>
<template #label>
<span class="truncate">{{dataStore.getProductById(row.product) ?dataStore.getProductById(row.product).name : "Kein Produkt ausgewählt" }}</span>

View File

@@ -106,8 +106,9 @@
<span :class="dayjs(row.dueDate).diff(dayjs()) <= 0 ? ['text-rose-500'] : '' ">{{row.dueDate ? dayjs(row.dueDate).format("DD.MM.YY") : ''}}</span>
</template>
<template #paid-data="{row}">
<span v-if="row.paid" class="text-primary-500">Bezahlt</span>
<span v-if="!row.paid" :class="dayjs(row.dueDate).diff(dayjs()) <= 0 ? ['text-rose-500'] : ['text-cyan-500'] ">Offen</span>
<span v-if="dataStore.bankstatements.find(x => x.assignments.find(y => y.id === row.id))" class="text-primary-500">Bezahlt</span>
<span v-else :class="dayjs(row.dueDate).diff(dayjs()) <= 0 ? ['text-rose-500'] : ['text-cyan-500'] ">Offen</span>
<!-- {{dataStore.bankstatements.find(x => x.assignments.find(y => y.id === row.id)) ? true : false}}-->
</template>
<template #amount-data="{row}">
<div

View File

@@ -141,6 +141,7 @@ const downloadSelected = async () => {
<DocumentList
:documents="filteredDocuments"
@selectDocument="(info) => console.log(info)"
/>
</div>
<USlideover

View File

@@ -17,7 +17,11 @@ const {vendors} = storeToRefs(useDataStore())
const {fetchVendorInvoices} = useDataStore()
const availableDocuments = computed(() => {
return dataStore.documents.filter(i => i.tags.includes('Eingangsrechnung' /*&& dataStore.incominginvoices.filter(x => x.document === i).length === 0*/))
//console.log(dataStore.documents.filter(i => i.tags.includes('Eingangsrechnung') && !dataStore.incominginvoices.find(x => x.document === i.id)))
//console.log(dataStore.documents.filter(i => i.tags.includes('Eingangsrechnung')).length)
return dataStore.documents.filter(i => i.tags.includes('Eingangsrechnung') && !dataStore.incominginvoices.find(x => x.document === i.id))
})
@@ -111,7 +115,7 @@ const totalCalculated = computed(() => {
itemInfo.value.accounts.forEach(account => {
if(account.amountNet) totalNet += account.amountNet
if(account.taxType === 19 && account.amountTax) {
if(account.taxType === "19" && account.amountTax) {
totalAmount19Tax += account.amountTax
}
})
@@ -157,11 +161,11 @@ setupPage()
</UButton>
<UTooltip
text="Bearbeiten ist nur im Entwurfsstatus möglich"
v-if="mode !== 'edit'"
>
<UButton
:disabled="itemInfo.state !== 'Entwurf'"
@click="router.push(`/incominginvoices/edit/${itemInfo.id}`)"
v-if="mode !== 'edit'"
>
Bearbeiten
</UButton>
@@ -210,9 +214,9 @@ setupPage()
v-if="currentDocument ? currentDocument.url : false"
:data="currentDocument.url + '#toolbar=0&navpanes=0&scrollbar=0&statusbar=0&messages=0&scrollbar=0'"
type="application/pdf"
class="mx-5 documentPreview"
class="mx-5 documentPreview w-full"
/>
<div class="w-2/5 mx-5">
<div class="w-3/5 mx-5">
<div v-if="mode === 'show'">
@@ -444,6 +448,7 @@ setupPage()
</UInput>
</UFormGroup>
{{item}}
</InputGroup>
@@ -451,7 +456,7 @@ setupPage()
<UButton
class="mt-3"
@click="itemInfo.accounts = [...itemInfo.accounts.slice(0,index+1),{account:null, amountNet: null, amountTax:null, taxType: null} , ...itemInfo.accounts.slice(index+1)]"
@click="itemInfo.accounts = [...itemInfo.accounts.slice(0,index+1),{account:null, amountNet: null, amountTax:null, taxType: '19'} , ...itemInfo.accounts.slice(index+1)]"
>
Position hinzufügen
</UButton>
@@ -477,7 +482,6 @@ setupPage()
<style scoped>
.documentPreview {
width: 30vw;
aspect-ratio: 1 / 1.414;
}

View File

@@ -279,11 +279,13 @@ export const useDataStore = defineStore('data', () => {
])
async function initializeData (userId) {
console.log("init")
let profileconnections = (await supabase.from("profileconnections").select()).data
let profiles = (await supabase.from("profiles").select()).data
let activeProfileConnection = profileconnections.find(i => i.active)
if(activeProfileConnection) {
console.log("Active Profile Selected")
activeProfile.value = profiles.find(i => i.id === activeProfileConnection.profile_id)
currentTenant.value = activeProfile.value.tenant
@@ -329,11 +331,15 @@ export const useDataStore = defineStore('data', () => {
}
async function fetchData () {
console.log("Fetch Start")
await fetchOwnProfiles()
await fetchProfiles()
await fetchDocuments()
await fetchTenants()
await fetchOwnTenant()
//loaded.value = true
await fetchDocuments()
await fetchEvents()
await fetchTasks()
await fetchProjects()
@@ -372,6 +378,9 @@ export const useDataStore = defineStore('data', () => {
await fetchServiceCategories()
await fetchResources()
loaded.value = true
console.log("Data Fetched")
}
function clearStore () {
@@ -1519,7 +1528,22 @@ export const useDataStore = defineStore('data', () => {
const getOpenDocuments = computed(() => (itemId) => {
return createddocuments.value.filter(i => (i.type === "invoices" || i.type === "advanceInvoices") && !bankstatements.value.some(x => x.createdDocument === i.id))
let items = createddocuments.value.filter(i => i.type === "invoices" || i.type === "advanceInvoices")
items = items.filter(i => bankstatements.value.filter(x => x.assignments.find(y => y.id === i.id)).length === 0)
/*let finalItems = []
items.forEach(item => {
if(bankstatements.value.filter(i => i.assignments.find(x => x.id === item.id))){
finalItems.push(item)
}
})
return finalItems*/
return items
//return createddocuments.value.filter(i => (i.type === "invoices" || i.type === "advanceInvoices") && !bankstatements.value.some(x => x.amount -))
})
const getOpenIncomingInvoices = computed(() => (itemId) => {