Changes in CreatedDocuments Edit

This commit is contained in:
2024-12-30 09:32:44 +01:00
parent da3dc1e663
commit a55d4817bd

View File

@@ -6,7 +6,6 @@ import { v4 as uuidv4 } from 'uuid';
const dataStore = useDataStore()
const profileStore = useProfileStore()
const user = useSupabaseUser()
const route = useRoute()
const router = useRouter()
const supabase = useSupabaseClient()
@@ -63,7 +62,6 @@ const itemInfo = ref({
})
const letterheads = ref([])
const createdDocuments = ref([])
const projects = ref([])
@@ -189,6 +187,7 @@ const setupPage = async () => {
}
setupPage()
const openAdvanceInvoices = ref([])
const checkForOpenAdvanceInvoices = async () => {
const {data,error} = await supabase.from("createddocuments").select().eq("project", itemInfo.value.project).eq("advanceInvoiceResolved", false).eq("type","advanceInvoices")
@@ -473,8 +472,8 @@ const documentTotal = computed(() => {
return {
totalNet: `${String(totalNet.toFixed(2)).replace(".",",")}`,
total19: `${String(total19.toFixed(2)).replace(".",",")}`,
totalNet: renderCurrency(totalNet),
total19: renderCurrency(total19),
totalGross: renderCurrency(totalGross),
totalGrossAlreadyPaid: renderCurrency(totalGrossAlreadyPaid),
totalSumToPay: renderCurrency(sumToPay)
@@ -559,7 +558,7 @@ const getDocumentData = () => {
if(!['pagebreak','title','text'].includes(row.mode)) {
if(row.mode === 'normal') row.text = products.value.find(i => i.id === row.product).name
if(row.mode === 'service') row.text = dataStore.getServiceById(row.service).name
if(row.mode === 'service') row.text = services.value.find(i => i.id === row.service).name
return {
@@ -636,13 +635,26 @@ const generateDocument = async () => {
const ownTenant = profileStore.ownTenant
const path = letterheads.value.find(i => i.id === itemInfo.value.letterhead).path
const {data,error} = await supabase.functions.invoke('create_pdf',{
body: {
invoiceData: getDocumentData(),
backgroundPath: path,
returnMode: "base64"
}
})
const {data,error} = await supabase.storage.from("files").download(path)
//const {data,error} = await supabase.storage.from("files").download(path)
//console.log(data)
//console.log(error)
uri.value = await useCreatePdf(getDocumentData(), await data.arrayBuffer())
//console.log(JSON.stringify(getDocumentData()))
uri.value = `data:${data.mimeType};base64,${data.base64}`
//uri.value = await useCreatePdf(getDocumentData(), await data.arrayBuffer())
//alert(uri.value)
showDocument.value = true
//console.log(uri.value)
@@ -821,7 +833,23 @@ const closeDocument = async () => {
//console.log(uri)
}
setupPage()
const setRowData = (row) => {
if(row.service) {
row.unit = services.value.find(i => i.id === row.service).unit
row.price = services.value.find(i => i.id === row.service).sellingPriceComposed.total || services.value.find(i => i.id === row.service).sellingPrice
row.description = services.value.find(i => i.id === row.service).description
}
if(row.product) {
row.unit = services.value.find(i => i.id === row.service).unit
row.price = services.value.find(i => i.id === row.service).sellingPriceComposed.total || services.value.find(i => i.id === row.service).sellingPrice
row.description = services.value.find(i => i.id === row.service).description
}
}
</script>
<template>
@@ -854,8 +882,6 @@ setupPage()
<UDashboardPanelContent>
<UTabs class="p-5" :items="tabItems" @change="onChangeTab" v-if="loaded">
<template #item="{item}">
<div v-if="item.label === 'Editor'">
<UAlert
@@ -878,29 +904,6 @@ setupPage()
<InputGroup>
<div class="w-1/3 mr-5">
<UFormGroup
v-if="itemInfo.linkedDocument"
label="Verknüpftes Dokument:"
>
<InputGroup class="w-full">
<USelectMenu
class="flex-auto"
:options="createdDocuments"
v-model="itemInfo.linkedDocument"
option-attribute="documentNumber"
value-attribute="id"
disabled
/>
<UButton
variant="outline"
color="rose"
v-if="itemInfo.linkedDocument"
icon="i-heroicons-x-mark"
@click="itemInfo.linkedDocument = null"
/>
</InputGroup>
</UFormGroup>
<UFormGroup
label="Dokumenttyp:"
>
@@ -910,7 +913,7 @@ setupPage()
v-model="itemInfo.type"
value-attribute="type"
option-attribute="label"
@change="setDocumentTypeConfig"
@input="setDocumentTypeConfig"
class="flex-auto"
>
<template #label>
@@ -1005,7 +1008,7 @@ setupPage()
searchable
searchable-placeholder="Suche..."
v-model="itemInfo.customer"
@change="setCustomerData"
@input="setCustomerData"
class="flex-auto mr-2"
>
<UButton
@@ -1013,14 +1016,10 @@ setupPage()
variant="outline"
class="w-full"
>
<!-- <span class="truncate text-left">{{dataStore.getCustomerById(itemInfo.customer) ? dataStore.getCustomerById(itemInfo.customer).name : "Kein Kunde ausgewählt"}}</span>-->
{{dataStore.getCustomerById(itemInfo.customer) ? dataStore.getCustomerById(itemInfo.customer).name : "Kein Kunde ausgewählt"}}
<UIcon name="i-heroicons-chevron-right-20-solid" class="w-5 h-5 transition-transform text-gray-400 dark:text-gray-500" :class="['transform rotate-90']" />
</UButton>
<!-- <template #label>
{{dataStore.getCustomerById(itemInfo.customer) ? dataStore.getCustomerById(itemInfo.customer).name : "Kein Kunde ausgewählt"}}
</template>-->
</USelectMenu>
<UButton
variant="outline"
@@ -1200,7 +1199,7 @@ setupPage()
v-model="itemInfo.contactPerson"
option-attribute="fullName"
value-attribute="id"
@change="setContactPersonData"
@input="setContactPersonData"
/>
</UFormGroup>
<UFormGroup
@@ -1231,7 +1230,7 @@ setupPage()
:search-attributes="['name']"
class="w-full"
:disabled="!itemInfo.customer"
@change="checkForOpenAdvanceInvoices"
@input="checkForOpenAdvanceInvoices"
>
<template #label>
{{dataStore.getProjectById(itemInfo.project) ? dataStore.getProjectById(itemInfo.project).name : "Kein Projekt ausgewählt"}}
@@ -1401,7 +1400,6 @@ setupPage()
<th v-if="itemInfo.type !== 'deliveryNotes'">Gesamt</th>
</tr>
</thead>
<tbody>
<draggable
v-model="itemInfo.rows"
handle=".handle"
@@ -1466,7 +1464,7 @@ setupPage()
searchable-placeholder="Suche ..."
:search-attributes="['name']"
v-model="row.product"
@change="row.unit = products.find(i => i.id === row.product).unit,
@input="row.unit = products.find(i => i.id === row.product).unit,
row.price = (products.find(i => i.id === row.product).sellingPrice || 0),
row.description = products.find(i => i.id === row.product).description"
>
@@ -1532,12 +1530,10 @@ setupPage()
searchable-placeholder="Suche ..."
:search-attributes="['name']"
v-model="row.service"
@change="row.unit = dataStore.getServiceById(row.service).unit,
row.price = dataStore.getServiceById(row.service).sellingPrice || 0,
row.description = dataStore.getServiceById(row.service).description"
@input="setRowData(row)"
>
<template #label>
<span class="truncate">{{dataStore.getServiceById(row.service) ? dataStore.getServiceById(row.service).name : "Keine Leistung ausgewählt" }}</span>
<span class="truncate">{{services.find(i => i.id === row.service) ? services.find(i => i.id === row.service).name : "Keine Leistung ausgewählt" }}</span>
</template>
</USelectMenu>
<UButton
@@ -1571,9 +1567,7 @@ setupPage()
:empty-state="{ icon: 'i-heroicons-circle-stack-20-solid', label: 'Keine Leistungen anzuzeigen' }"
@select=" (i) => {
row.service = i.id
row.unit = dataStore.getServiceById(row.service).unit,
row.price = dataStore.getServiceById(row.service).sellingPrice || 0,
row.description = dataStore.getServiceById(row.service).description
setRowData(row)
showServiceSelectionModal = false}"
>
@@ -1760,7 +1754,6 @@ setupPage()
</tr>
</template>
</draggable>
</tbody>
</table>
<UAlert
v-else
@@ -1819,8 +1812,6 @@ setupPage()
Noch nicht abgerechnete Abschlagsrechnungen
</UDivider>
<!-- Abzurechnende Abschlagsrechnungen -->
<div
v-for="advanceInvoice in openAdvanceInvoices"
:key="advanceInvoice.id"