Changes in CreatedDocuments Edit
This commit is contained in:
@@ -6,7 +6,6 @@ import { v4 as uuidv4 } from 'uuid';
|
|||||||
|
|
||||||
const dataStore = useDataStore()
|
const dataStore = useDataStore()
|
||||||
const profileStore = useProfileStore()
|
const profileStore = useProfileStore()
|
||||||
const user = useSupabaseUser()
|
|
||||||
const route = useRoute()
|
const route = useRoute()
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
const supabase = useSupabaseClient()
|
const supabase = useSupabaseClient()
|
||||||
@@ -63,7 +62,6 @@ const itemInfo = ref({
|
|||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
const letterheads = ref([])
|
const letterheads = ref([])
|
||||||
const createdDocuments = ref([])
|
const createdDocuments = ref([])
|
||||||
const projects = ref([])
|
const projects = ref([])
|
||||||
@@ -189,6 +187,7 @@ const setupPage = async () => {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
setupPage()
|
||||||
const openAdvanceInvoices = ref([])
|
const openAdvanceInvoices = ref([])
|
||||||
const checkForOpenAdvanceInvoices = async () => {
|
const checkForOpenAdvanceInvoices = async () => {
|
||||||
const {data,error} = await supabase.from("createddocuments").select().eq("project", itemInfo.value.project).eq("advanceInvoiceResolved", false).eq("type","advanceInvoices")
|
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 {
|
return {
|
||||||
totalNet: `${String(totalNet.toFixed(2)).replace(".",",")} €`,
|
totalNet: renderCurrency(totalNet),
|
||||||
total19: `${String(total19.toFixed(2)).replace(".",",")} €`,
|
total19: renderCurrency(total19),
|
||||||
totalGross: renderCurrency(totalGross),
|
totalGross: renderCurrency(totalGross),
|
||||||
totalGrossAlreadyPaid: renderCurrency(totalGrossAlreadyPaid),
|
totalGrossAlreadyPaid: renderCurrency(totalGrossAlreadyPaid),
|
||||||
totalSumToPay: renderCurrency(sumToPay)
|
totalSumToPay: renderCurrency(sumToPay)
|
||||||
@@ -559,7 +558,7 @@ const getDocumentData = () => {
|
|||||||
|
|
||||||
if(!['pagebreak','title','text'].includes(row.mode)) {
|
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 === '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 {
|
return {
|
||||||
@@ -636,13 +635,26 @@ const generateDocument = async () => {
|
|||||||
const ownTenant = profileStore.ownTenant
|
const ownTenant = profileStore.ownTenant
|
||||||
const path = letterheads.value.find(i => i.id === itemInfo.value.letterhead).path
|
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(data)
|
||||||
//console.log(error)
|
//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)
|
//alert(uri.value)
|
||||||
showDocument.value = true
|
showDocument.value = true
|
||||||
//console.log(uri.value)
|
//console.log(uri.value)
|
||||||
@@ -821,7 +833,23 @@ const closeDocument = async () => {
|
|||||||
//console.log(uri)
|
//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>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
@@ -854,8 +882,6 @@ setupPage()
|
|||||||
<UDashboardPanelContent>
|
<UDashboardPanelContent>
|
||||||
<UTabs class="p-5" :items="tabItems" @change="onChangeTab" v-if="loaded">
|
<UTabs class="p-5" :items="tabItems" @change="onChangeTab" v-if="loaded">
|
||||||
<template #item="{item}">
|
<template #item="{item}">
|
||||||
|
|
||||||
|
|
||||||
<div v-if="item.label === 'Editor'">
|
<div v-if="item.label === 'Editor'">
|
||||||
|
|
||||||
<UAlert
|
<UAlert
|
||||||
@@ -878,29 +904,6 @@ setupPage()
|
|||||||
|
|
||||||
<InputGroup>
|
<InputGroup>
|
||||||
<div class="w-1/3 mr-5">
|
<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
|
<UFormGroup
|
||||||
label="Dokumenttyp:"
|
label="Dokumenttyp:"
|
||||||
>
|
>
|
||||||
@@ -910,7 +913,7 @@ setupPage()
|
|||||||
v-model="itemInfo.type"
|
v-model="itemInfo.type"
|
||||||
value-attribute="type"
|
value-attribute="type"
|
||||||
option-attribute="label"
|
option-attribute="label"
|
||||||
@change="setDocumentTypeConfig"
|
@input="setDocumentTypeConfig"
|
||||||
class="flex-auto"
|
class="flex-auto"
|
||||||
>
|
>
|
||||||
<template #label>
|
<template #label>
|
||||||
@@ -1005,7 +1008,7 @@ setupPage()
|
|||||||
searchable
|
searchable
|
||||||
searchable-placeholder="Suche..."
|
searchable-placeholder="Suche..."
|
||||||
v-model="itemInfo.customer"
|
v-model="itemInfo.customer"
|
||||||
@change="setCustomerData"
|
@input="setCustomerData"
|
||||||
class="flex-auto mr-2"
|
class="flex-auto mr-2"
|
||||||
>
|
>
|
||||||
<UButton
|
<UButton
|
||||||
@@ -1013,14 +1016,10 @@ setupPage()
|
|||||||
variant="outline"
|
variant="outline"
|
||||||
class="w-full"
|
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"}}
|
{{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']" />
|
<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>
|
</UButton>
|
||||||
<!-- <template #label>
|
|
||||||
{{dataStore.getCustomerById(itemInfo.customer) ? dataStore.getCustomerById(itemInfo.customer).name : "Kein Kunde ausgewählt"}}
|
|
||||||
</template>-->
|
|
||||||
</USelectMenu>
|
</USelectMenu>
|
||||||
<UButton
|
<UButton
|
||||||
variant="outline"
|
variant="outline"
|
||||||
@@ -1200,7 +1199,7 @@ setupPage()
|
|||||||
v-model="itemInfo.contactPerson"
|
v-model="itemInfo.contactPerson"
|
||||||
option-attribute="fullName"
|
option-attribute="fullName"
|
||||||
value-attribute="id"
|
value-attribute="id"
|
||||||
@change="setContactPersonData"
|
@input="setContactPersonData"
|
||||||
/>
|
/>
|
||||||
</UFormGroup>
|
</UFormGroup>
|
||||||
<UFormGroup
|
<UFormGroup
|
||||||
@@ -1231,7 +1230,7 @@ setupPage()
|
|||||||
:search-attributes="['name']"
|
:search-attributes="['name']"
|
||||||
class="w-full"
|
class="w-full"
|
||||||
:disabled="!itemInfo.customer"
|
:disabled="!itemInfo.customer"
|
||||||
@change="checkForOpenAdvanceInvoices"
|
@input="checkForOpenAdvanceInvoices"
|
||||||
>
|
>
|
||||||
<template #label>
|
<template #label>
|
||||||
{{dataStore.getProjectById(itemInfo.project) ? dataStore.getProjectById(itemInfo.project).name : "Kein Projekt ausgewählt"}}
|
{{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>
|
<th v-if="itemInfo.type !== 'deliveryNotes'">Gesamt</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
|
||||||
<draggable
|
<draggable
|
||||||
v-model="itemInfo.rows"
|
v-model="itemInfo.rows"
|
||||||
handle=".handle"
|
handle=".handle"
|
||||||
@@ -1466,7 +1464,7 @@ setupPage()
|
|||||||
searchable-placeholder="Suche ..."
|
searchable-placeholder="Suche ..."
|
||||||
:search-attributes="['name']"
|
:search-attributes="['name']"
|
||||||
v-model="row.product"
|
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.price = (products.find(i => i.id === row.product).sellingPrice || 0),
|
||||||
row.description = products.find(i => i.id === row.product).description"
|
row.description = products.find(i => i.id === row.product).description"
|
||||||
>
|
>
|
||||||
@@ -1532,12 +1530,10 @@ setupPage()
|
|||||||
searchable-placeholder="Suche ..."
|
searchable-placeholder="Suche ..."
|
||||||
:search-attributes="['name']"
|
:search-attributes="['name']"
|
||||||
v-model="row.service"
|
v-model="row.service"
|
||||||
@change="row.unit = dataStore.getServiceById(row.service).unit,
|
@input="setRowData(row)"
|
||||||
row.price = dataStore.getServiceById(row.service).sellingPrice || 0,
|
|
||||||
row.description = dataStore.getServiceById(row.service).description"
|
|
||||||
>
|
>
|
||||||
<template #label>
|
<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>
|
</template>
|
||||||
</USelectMenu>
|
</USelectMenu>
|
||||||
<UButton
|
<UButton
|
||||||
@@ -1571,9 +1567,7 @@ setupPage()
|
|||||||
:empty-state="{ icon: 'i-heroicons-circle-stack-20-solid', label: 'Keine Leistungen anzuzeigen' }"
|
:empty-state="{ icon: 'i-heroicons-circle-stack-20-solid', label: 'Keine Leistungen anzuzeigen' }"
|
||||||
@select=" (i) => {
|
@select=" (i) => {
|
||||||
row.service = i.id
|
row.service = i.id
|
||||||
row.unit = dataStore.getServiceById(row.service).unit,
|
setRowData(row)
|
||||||
row.price = dataStore.getServiceById(row.service).sellingPrice || 0,
|
|
||||||
row.description = dataStore.getServiceById(row.service).description
|
|
||||||
showServiceSelectionModal = false}"
|
showServiceSelectionModal = false}"
|
||||||
>
|
>
|
||||||
|
|
||||||
@@ -1760,7 +1754,6 @@ setupPage()
|
|||||||
</tr>
|
</tr>
|
||||||
</template>
|
</template>
|
||||||
</draggable>
|
</draggable>
|
||||||
</tbody>
|
|
||||||
</table>
|
</table>
|
||||||
<UAlert
|
<UAlert
|
||||||
v-else
|
v-else
|
||||||
@@ -1819,8 +1812,6 @@ setupPage()
|
|||||||
Noch nicht abgerechnete Abschlagsrechnungen
|
Noch nicht abgerechnete Abschlagsrechnungen
|
||||||
</UDivider>
|
</UDivider>
|
||||||
|
|
||||||
<!-- Abzurechnende Abschlagsrechnungen -->
|
|
||||||
|
|
||||||
<div
|
<div
|
||||||
v-for="advanceInvoice in openAdvanceInvoices"
|
v-for="advanceInvoice in openAdvanceInvoices"
|
||||||
:key="advanceInvoice.id"
|
:key="advanceInvoice.id"
|
||||||
|
|||||||
Reference in New Issue
Block a user