Fix Createddocs

This commit is contained in:
2025-09-07 19:32:59 +02:00
parent 6d233f5bfb
commit c7e18d689e
4 changed files with 728 additions and 688 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -31,11 +31,11 @@
</UDashboardNavbar>
<UDashboardToolbar>
<template #left>
<!-- <UCheckbox
v-model="showDrafts"
label="Entwürfe Anzeigen"
class="my-auto mr-3"
/>-->
<!-- <UCheckbox
v-model="showDrafts"
label="Entwürfe Anzeigen"
class="my-auto mr-3"
/>-->
<USelectMenu
v-model="selectedTypes"
icon="i-heroicons-adjustments-horizontal-solid"
@@ -204,7 +204,6 @@ const items = ref([])
const selectedItem = ref(0)
const setupPage = async () => {
//items.value = (await useSupabaseSelect("createddocuments","*, customer(id,name), statementallocations(id,amount),linkedDocument(*)","documentNumber")).filter(i => !i.archived)
items.value = (await useEntities("createddocuments").select("*, customer(id,name), statementallocations(id,amount),linkedDocument(*)","documentNumber")).filter(i => !i.archived)
}
@@ -220,7 +219,7 @@ const templateColumns = [
key: 'type',
label: "Typ",
sortable: true
},{
}, {
key: 'state',
label: "Status",
sortable: true
@@ -288,19 +287,19 @@ const types = computed(() => {
const selectItem = (item) => {
console.log(item)
if(item.state === "Entwurf"){
if (item.state === "Entwurf") {
router.push(`/createDocument/edit/${item.id}`)
} else if(item.state !== "Entwurf") {
} else if (item.state !== "Entwurf") {
router.push(`/createDocument/show/${item.id}`)
}
}
const displayCurrency = (value, currency = "€") => {
return `${Number(value).toFixed(2).replace(".",",")} ${currency}`
return `${Number(value).toFixed(2).replace(".", ",")} ${currency}`
}
const searchString = ref(tempStore.searchStrings['createddocuments'] ||'')
const searchString = ref(tempStore.searchStrings['createddocuments'] || '')
const clearSearchString = () => {
tempStore.clearSearchString('createddocuments')
@@ -309,7 +308,7 @@ const clearSearchString = () => {
const selectedFilters = ref([])
const filteredRows = computed(() => {
let temp = items.value.filter(i => types.value.find(x => x.key === 'invoices' ? ['invoices','advanceInvoices','cancellationInvoices'].includes(i.type) : x.key === i.type))
let temp = items.value.filter(i => types.value.find(x => x.key === 'invoices' ? ['invoices', 'advanceInvoices', 'cancellationInvoices'].includes(i.type) : x.key === i.type))
temp = temp.filter(i => i.type !== "serialInvoices")
/*if(showDrafts.value === true) {
@@ -318,7 +317,7 @@ const filteredRows = computed(() => {
temp = temp.filter(i => i.state !== "Entwurf")
}*/
if(selectedFilters.value.includes("Nur offene anzeigen")){
if (selectedFilters.value.includes("Nur offene anzeigen")) {
temp = temp.filter(i => !isPaid(i))
}

View File

@@ -126,7 +126,6 @@ const items = ref([])
const selectedItem = ref(0)
const setupPage = async () => {
//items.value = await useSupabaseSelect("createddocuments","*, customer(id,name)","documentDate")
items.value = await useEntities("createddocuments").select("*, customer(id,name)","documentDate")
}

View File

@@ -9,41 +9,28 @@ defineShortcuts({
},
})
const supabase = useSupabaseClient()
const modal = useModal()
const dataStore = useDataStore()
const profileStore = useProfileStore()
const route = useRoute()
const router = useRouter()
const auth = useAuthStore()
const itemInfo = ref({})
const linkedDocument =ref({})
const currentTenant = ref({})
const setupPage = async () => {
if(route.params) {
if(route.params.id) itemInfo.value = await useSupabaseSelectSingle("createddocuments",route.params.id,"*, files(*)")
if(route.params.id) itemInfo.value = await useEntities("createddocuments").selectSingle(route.params.id,"*, files(*)")
console.log(itemInfo.value)
linkedDocument.value = await useFiles().selectDocument(itemInfo.value.files[0].id)
//const {data,error} = await supabase.from("files").select("id").eq("createddocument", route.params.id).order("id",{ascending:true})
//linkedDocument.value = data[data.length -1]
}
currentTenant.value = (await supabase.from("tenants").select().eq("id",profileStore.currentTenant).single()).data
console.log(currentTenant.value)
}
setupPage()
const openEmail = () => {
if(["invoices","advanceInvoices"].includes(itemInfo.value.type)){
router.push(`/email/new?loadDocuments=["${linkedDocument.value.id}"]&bcc=${encodeURIComponent(currentTenant.value.standardEmailForInvoices || "")}`)
router.push(`/email/new?loadDocuments=["${linkedDocument.value.id}"]&bcc=${encodeURIComponent(auth.activeTenantData.standardEmailForInvoices || "")}`)
} else {
router.push(`/email/new?loadDocuments=["${linkedDocument.value.id}"]`)
}
@@ -52,7 +39,7 @@ const openEmail = () => {
<template>
<UDashboardNavbar
title="Erstelltes Dokument anzeigen"
title="Erstelltes Dokument anzeigen"
>
</UDashboardNavbar>
@@ -64,10 +51,10 @@ const openEmail = () => {
>
Bearbeiten
</UButton>
<!-- <UButton
:to="dataStore.documents.find(i => i.createdDocument === itemInfo.id) ? dataStore.documents.find(i => i.createdDocument === itemInfo.id).url : ''"
target="_blank"
>In neuen Tab anzeigen</UButton>-->
<!-- <UButton
:to="dataStore.documents.find(i => i.createdDocument === itemInfo.id) ? dataStore.documents.find(i => i.createdDocument === itemInfo.id).url : ''"
target="_blank"
>In neuen Tab anzeigen</UButton>-->
<UButton
icon="i-heroicons-arrow-right-end-on-rectangle"
@click="modal.open(CopyCreatedDocumentModal, {
@@ -79,8 +66,8 @@ const openEmail = () => {
Kopieren
</UButton>
<UButton
@click="openEmail"
icon="i-heroicons-envelope"
@click="openEmail"
icon="i-heroicons-envelope"
>
E-Mail
</UButton>
@@ -94,16 +81,16 @@ const openEmail = () => {
</UButton>
<UButton
v-if="itemInfo.project"
@click="router.push(`/standardEntity/projects/show/${itemInfo.project}`)"
icon="i-heroicons-link"
@click="router.push(`/standardEntity/projects/show/${itemInfo.project}`)"
icon="i-heroicons-link"
variant="outline"
>
Projekt
</UButton>
<UButton
v-if="itemInfo.customer"
@click="router.push(`/standardEntity/customers/show/${itemInfo.customer}`)"
icon="i-heroicons-link"
@click="router.push(`/standardEntity/customers/show/${itemInfo.customer}`)"
icon="i-heroicons-link"
variant="outline"
>
Kunde