Some Changes in Pos Numbering and Problem Display

This commit is contained in:
2024-09-26 18:42:17 +02:00
parent eee6060e58
commit 3c5f80f8b5

View File

@@ -119,7 +119,7 @@ const setCustomerData = () => {
} }
const setContactPersonData = async () => { const setContactPersonData = async () => {
console.log(itemInfo.value.contactPerson) //console.log(itemInfo.value.contactPerson)
let profile = await useSupabaseSelectSingle("profiles",itemInfo.value.contactPerson, '*') let profile = await useSupabaseSelectSingle("profiles",itemInfo.value.contactPerson, '*')
itemInfo.value.contactPersonName = profile.fullName itemInfo.value.contactPersonName = profile.fullName
@@ -220,6 +220,11 @@ const addPosition = (mode) => {
id: lastId +1, id: lastId +1,
mode: "title", mode: "title",
}) })
} else if(mode === "text") {
itemInfo.value.rows.push({
id: lastId +1,
mode: "text",
})
} }
setPosNumbers() setPosNumbers()
@@ -268,6 +273,7 @@ const findDocumentErrors = computed(() => {
itemInfo.value.rows.forEach(row => { itemInfo.value.rows.forEach(row => {
if(row.mode === "normal" && !row.product) errors.push({message: `In Position ${row.pos} ist kein Artikel ausgewählt`, type: "breaking"}) if(row.mode === "normal" && !row.product) errors.push({message: `In Position ${row.pos} ist kein Artikel ausgewählt`, type: "breaking"})
if(row.mode === "service" && !row.service) errors.push({message: `In Position ${row.pos} ist keine Leistung ausgewählt`, type: "breaking"}) if(row.mode === "service" && !row.service) errors.push({message: `In Position ${row.pos} ist keine Leistung ausgewählt`, type: "breaking"})
if(row.mode === "title" && !row.text) errors.push({message: `In Position ${row.pos} ist kein Titel hinterlegt ausgewählt`, type: "breaking"})
}) })
@@ -292,10 +298,10 @@ const documentTotal = computed(() => {
let totalGross = 0 let totalGross = 0
itemInfo.value.rows.forEach(row => { itemInfo.value.rows.forEach(row => {
if(row.mode !== 'pagebreak' && row.mode !== 'title'){ if(!['pagebreak','title','text'].includes(row.mode)){
console.log(row) //console.log(row)
let rowPrice = Number(Number(row.quantity) * Number(row.price) * (1 - Number(row.discountPercent) /100) ).toFixed(2) let rowPrice = Number(Number(row.quantity) * Number(row.price) * (1 - Number(row.discountPercent) /100) ).toFixed(2)
console.log(rowPrice) //console.log(rowPrice)
totalNet = totalNet + Number(rowPrice) totalNet = totalNet + Number(rowPrice)
if(row.taxPercent === 19) { if(row.taxPercent === 19) {
@@ -329,7 +335,7 @@ const getDocumentData = () => {
let unit = dataStore.units.find(i => i.id === row.unit) let unit = dataStore.units.find(i => i.id === row.unit)
if(row.mode !== 'pagebreak' && row.mode !== 'title') { if(!['pagebreak','title','text'].includes(row.mode)) {
if(row.mode === 'normal') row.text = dataStore.getProductById(row.product).name if(row.mode === 'normal') row.text = dataStore.getProductById(row.product).name
if(row.mode === 'service') row.text = dataStore.getServiceById(row.service).name if(row.mode === 'service') row.text = dataStore.getServiceById(row.service).name
@@ -350,11 +356,11 @@ const getDocumentData = () => {
//Compile Start & EndText //Compile Start & EndText
const templateStartText = Handlebars.compile(itemInfo.value.startText); const templateStartText = Handlebars.compile(itemInfo.value.startText);
const templateEndText = Handlebars.compile(itemInfo.value.endText); const templateEndText = Handlebars.compile(itemInfo.value.endText);
console.log(templateStartText({ /*console.log(templateStartText({
vorname: contactData ? contactData.firstName : "", vorname: contactData ? contactData.firstName : "",
nachname: contactData ? contactData.lastName : "" nachname: contactData ? contactData.lastName : ""
})) }))*/
console.log(templateEndText({zahlungsziel_in_tagen: itemInfo.value.paymentDays})) //console.log(templateEndText({zahlungsziel_in_tagen: itemInfo.value.paymentDays}))
@@ -391,7 +397,7 @@ const getDocumentData = () => {
total: documentTotal.value total: documentTotal.value
} }
console.log(returnData) //console.log(returnData)
return returnData return returnData
} }
@@ -407,13 +413,13 @@ const generateDocument = async () => {
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()) 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)
} }
const onChangeTab = (index) => { const onChangeTab = (index) => {
@@ -423,12 +429,22 @@ const onChangeTab = (index) => {
} }
const setPosNumbers = () => { const setPosNumbers = () => {
let mainIndex = 0
let subIndex = 1
let index = 1 let index = 1
let rows = itemInfo.value.rows.map(row => { let rows = itemInfo.value.rows.map(row => {
if(row.mode !== 'pagebreak' && row.mode !== 'title') { if(row.mode === 'title') {
mainIndex += 1
row.pos = mainIndex
subIndex = 1
} else if(!['pagebreak','title','text'].includes(row.mode)) {
row.pos = `${mainIndex}.${subIndex}`
subIndex += 1
}
/*if(!['pagebreak','title','text'].includes(row.mode)) {
row.pos = index row.pos = index
index += 1 index += 1
} }*/
return row return row
}) })
} }
@@ -541,8 +557,8 @@ setupPage()
<UAlert <UAlert
class="my-5" class="my-5"
title="Probleme:" title="Vorhandene Probleme:"
:color="findDocumentErrors.filter(i => i.type === 'breaking').length > 0 ? 'rose' : ''" :color="findDocumentErrors.filter(i => i.type === 'breaking').length > 0 ? 'rose' : 'white'"
variant="outline" variant="outline"
v-if="findDocumentErrors.length > 0" v-if="findDocumentErrors.length > 0"
> >
@@ -1003,16 +1019,21 @@ setupPage()
<UDivider/> <UDivider/>
</td> </td>
<td <td
v-if="row.mode === 'title'" v-if="row.mode === 'text'"
colspan="9" colspan="9"
> >
<UInput <UInput
v-model="row.text" v-model="row.text"
placeholder="Titel"
/>
<UTextarea
class="mt-2"
v-model="row.description"
placeholder="Text" placeholder="Text"
/> />
</td> </td>
<td <td
v-if="row.mode !== 'pagebreak' && row.mode !== 'title'" v-if="!['pagebreak','text'].includes(row.mode)"
>{{row.pos}}</td> >{{row.pos}}</td>
<td <td
class="w-120" class="w-120"
@@ -1028,7 +1049,7 @@ setupPage()
v-else-if="row.mode === 'normal'" v-else-if="row.mode === 'normal'"
> >
<USelectMenu <USelectMenu
class="w-40" class="max-w-60"
:options="dataStore.products" :options="dataStore.products"
:color="row.product ? 'primary' : 'rose'" :color="row.product ? 'primary' : 'rose'"
option-attribute="name" option-attribute="name"
@@ -1054,7 +1075,6 @@ setupPage()
v-else-if="row.mode === 'service'" v-else-if="row.mode === 'service'"
> >
<USelectMenu <USelectMenu
class="w-40"
:options="dataStore.services" :options="dataStore.services"
:color="row.service ? 'primary' : 'rose'" :color="row.service ? 'primary' : 'rose'"
option-attribute="name" option-attribute="name"
@@ -1074,7 +1094,7 @@ setupPage()
</td> </td>
<td <td
class="w-20" class="w-20"
v-if="row.mode !== 'pagebreak' && row.mode !== 'title'" v-if="!['pagebreak','title','text'].includes(row.mode)"
> >
<UInput <UInput
v-model="row.quantity" v-model="row.quantity"
@@ -1085,7 +1105,7 @@ setupPage()
</td> </td>
<td <td
class="w-40" class="w-40"
v-if="row.mode !== 'pagebreak' && row.mode !== 'title'" v-if="!['pagebreak','title','text'].includes(row.mode)"
> >
<USelectMenu <USelectMenu
v-model="row.unit" v-model="row.unit"
@@ -1100,7 +1120,7 @@ setupPage()
</td> </td>
<td <td
class="w-40" class="w-40"
v-if="row.mode !== 'pagebreak' && row.mode !== 'title'" v-if="!['pagebreak','title','text'].includes(row.mode)"
> >
<UInput <UInput
v-model="row.price" v-model="row.price"
@@ -1114,7 +1134,7 @@ setupPage()
</td> </td>
<td <td
class="w-40" class="w-40"
v-if="row.mode !== 'pagebreak' && row.mode !== 'title'" v-if="!['pagebreak','title','text'].includes(row.mode)"
> >
<USelectMenu <USelectMenu
@@ -1132,7 +1152,7 @@ setupPage()
</td> </td>
<td <td
class="w-40" class="w-40"
v-if="row.mode !== 'pagebreak' && row.mode !== 'title'" v-if="!['pagebreak','title','text'].includes(row.mode)"
> >
<UInput <UInput
v-model="row.discountPercent" v-model="row.discountPercent"
@@ -1147,7 +1167,7 @@ setupPage()
</td> </td>
<td <td
class="w-40" class="w-40"
v-if="row.mode !== 'pagebreak' && row.mode !== 'title'" v-if="!['pagebreak','title','text'].includes(row.mode)"
> >
<UButton <UButton
icon="i-heroicons-document-text" icon="i-heroicons-document-text"
@@ -1177,11 +1197,20 @@ setupPage()
</UModal> </UModal>
</td> </td>
<td <td
v-if="row.mode !== 'pagebreak' && row.mode !== 'title'" v-if="!['pagebreak','title','text'].includes(row.mode)"
> >
<p class="text-right font-bold whitespace-nowrap"><span v-if="row.discountPercent !== 0" class="line-through mr-2 text-rose-500">{{getRowAmountUndiscounted(row)}} </span>{{getRowAmount(row)}} </p> <p class="text-right font-bold whitespace-nowrap"><span v-if="row.discountPercent !== 0" class="line-through mr-2 text-rose-500">{{getRowAmountUndiscounted(row)}} </span>{{getRowAmount(row)}} </p>
</td> </td>
<td
v-if="row.mode === 'title'"
colspan="8"
>
<UInput
v-model="row.text"
placeholder="Titel"
/>
</td>
<td> <td>
<UButton <UButton
variant="ghost" variant="ghost"
@@ -1200,19 +1229,19 @@ setupPage()
@click="addPosition('service')" @click="addPosition('service')"
class="mt-3" class="mt-3"
> >
+ Leistungsposition + Leistung
</UButton> </UButton>
<UButton <UButton
@click="addPosition('normal')" @click="addPosition('normal')"
class="mt-3" class="mt-3"
> >
+ Artikelposition + Artikel
</UButton> </UButton>
<UButton <UButton
@click="addPosition('free')" @click="addPosition('free')"
class="mt-3" class="mt-3"
> >
+ Freitextposition + Freie Position
</UButton> </UButton>
<UButton <UButton
@click="addPosition('pagebreak')" @click="addPosition('pagebreak')"
@@ -1228,20 +1257,23 @@ setupPage()
</UButton> </UButton>
</InputGroup> </InputGroup>
<table> <div class="w-full flex justify-end">
<table class="w-1/3">
<tr> <tr>
<td class="font-bold">Netto:</td> <td class="font-bold">Netto:</td>
<td>{{documentTotal.totalNet}}</td> <td class="text-right">{{documentTotal.totalNet}}</td>
</tr> </tr>
<tr> <tr>
<td class="font-bold">zzgl. 19 % USt:</td> <td class="font-bold">zzgl. 19 % USt:</td>
<td>{{documentTotal.total19}}</td> <td class="text-right">{{documentTotal.total19}}</td>
</tr> </tr>
<tr> <tr>
<td class="font-bold">Brutto:</td> <td class="font-bold">Brutto:</td>
<td>{{documentTotal.totalGross}}</td> <td class="text-right">{{documentTotal.totalGross}}</td>
</tr> </tr>
</table> </table>
</div>