Some Changes in Pos Numbering and Problem Display
This commit is contained in:
@@ -119,7 +119,7 @@ const setCustomerData = () => {
|
||||
}
|
||||
|
||||
const setContactPersonData = async () => {
|
||||
console.log(itemInfo.value.contactPerson)
|
||||
//console.log(itemInfo.value.contactPerson)
|
||||
let profile = await useSupabaseSelectSingle("profiles",itemInfo.value.contactPerson, '*')
|
||||
|
||||
itemInfo.value.contactPersonName = profile.fullName
|
||||
@@ -220,6 +220,11 @@ const addPosition = (mode) => {
|
||||
id: lastId +1,
|
||||
mode: "title",
|
||||
})
|
||||
} else if(mode === "text") {
|
||||
itemInfo.value.rows.push({
|
||||
id: lastId +1,
|
||||
mode: "text",
|
||||
})
|
||||
}
|
||||
|
||||
setPosNumbers()
|
||||
@@ -268,6 +273,7 @@ const findDocumentErrors = computed(() => {
|
||||
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 === "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
|
||||
|
||||
itemInfo.value.rows.forEach(row => {
|
||||
if(row.mode !== 'pagebreak' && row.mode !== 'title'){
|
||||
console.log(row)
|
||||
if(!['pagebreak','title','text'].includes(row.mode)){
|
||||
//console.log(row)
|
||||
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)
|
||||
|
||||
if(row.taxPercent === 19) {
|
||||
@@ -329,7 +335,7 @@ const getDocumentData = () => {
|
||||
|
||||
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 === 'service') row.text = dataStore.getServiceById(row.service).name
|
||||
|
||||
@@ -350,11 +356,11 @@ const getDocumentData = () => {
|
||||
//Compile Start & EndText
|
||||
const templateStartText = Handlebars.compile(itemInfo.value.startText);
|
||||
const templateEndText = Handlebars.compile(itemInfo.value.endText);
|
||||
console.log(templateStartText({
|
||||
/*console.log(templateStartText({
|
||||
vorname: contactData ? contactData.firstName : "",
|
||||
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
|
||||
}
|
||||
|
||||
console.log(returnData)
|
||||
//console.log(returnData)
|
||||
|
||||
return returnData
|
||||
}
|
||||
@@ -407,13 +413,13 @@ const generateDocument = async () => {
|
||||
|
||||
const {data,error} = await supabase.storage.from("files").download(path)
|
||||
|
||||
console.log(data)
|
||||
console.log(error)
|
||||
//console.log(data)
|
||||
//console.log(error)
|
||||
|
||||
uri.value = await useCreatePdf(getDocumentData(), await data.arrayBuffer())
|
||||
//alert(uri.value)
|
||||
showDocument.value = true
|
||||
console.log(uri.value)
|
||||
//console.log(uri.value)
|
||||
}
|
||||
|
||||
const onChangeTab = (index) => {
|
||||
@@ -423,12 +429,22 @@ const onChangeTab = (index) => {
|
||||
}
|
||||
|
||||
const setPosNumbers = () => {
|
||||
let mainIndex = 0
|
||||
let subIndex = 1
|
||||
let index = 1
|
||||
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
|
||||
index += 1
|
||||
}
|
||||
}*/
|
||||
return row
|
||||
})
|
||||
}
|
||||
@@ -541,8 +557,8 @@ setupPage()
|
||||
|
||||
<UAlert
|
||||
class="my-5"
|
||||
title="Probleme:"
|
||||
:color="findDocumentErrors.filter(i => i.type === 'breaking').length > 0 ? 'rose' : ''"
|
||||
title="Vorhandene Probleme:"
|
||||
:color="findDocumentErrors.filter(i => i.type === 'breaking').length > 0 ? 'rose' : 'white'"
|
||||
variant="outline"
|
||||
v-if="findDocumentErrors.length > 0"
|
||||
>
|
||||
@@ -1003,16 +1019,21 @@ setupPage()
|
||||
<UDivider/>
|
||||
</td>
|
||||
<td
|
||||
v-if="row.mode === 'title'"
|
||||
v-if="row.mode === 'text'"
|
||||
colspan="9"
|
||||
>
|
||||
<UInput
|
||||
v-model="row.text"
|
||||
placeholder="Titel"
|
||||
/>
|
||||
<UTextarea
|
||||
class="mt-2"
|
||||
v-model="row.description"
|
||||
placeholder="Text"
|
||||
/>
|
||||
</td>
|
||||
<td
|
||||
v-if="row.mode !== 'pagebreak' && row.mode !== 'title'"
|
||||
v-if="!['pagebreak','text'].includes(row.mode)"
|
||||
>{{row.pos}}</td>
|
||||
<td
|
||||
class="w-120"
|
||||
@@ -1028,7 +1049,7 @@ setupPage()
|
||||
v-else-if="row.mode === 'normal'"
|
||||
>
|
||||
<USelectMenu
|
||||
class="w-40"
|
||||
class="max-w-60"
|
||||
:options="dataStore.products"
|
||||
:color="row.product ? 'primary' : 'rose'"
|
||||
option-attribute="name"
|
||||
@@ -1054,7 +1075,6 @@ setupPage()
|
||||
v-else-if="row.mode === 'service'"
|
||||
>
|
||||
<USelectMenu
|
||||
class="w-40"
|
||||
:options="dataStore.services"
|
||||
:color="row.service ? 'primary' : 'rose'"
|
||||
option-attribute="name"
|
||||
@@ -1074,7 +1094,7 @@ setupPage()
|
||||
</td>
|
||||
<td
|
||||
class="w-20"
|
||||
v-if="row.mode !== 'pagebreak' && row.mode !== 'title'"
|
||||
v-if="!['pagebreak','title','text'].includes(row.mode)"
|
||||
>
|
||||
<UInput
|
||||
v-model="row.quantity"
|
||||
@@ -1085,7 +1105,7 @@ setupPage()
|
||||
</td>
|
||||
<td
|
||||
class="w-40"
|
||||
v-if="row.mode !== 'pagebreak' && row.mode !== 'title'"
|
||||
v-if="!['pagebreak','title','text'].includes(row.mode)"
|
||||
>
|
||||
<USelectMenu
|
||||
v-model="row.unit"
|
||||
@@ -1100,7 +1120,7 @@ setupPage()
|
||||
</td>
|
||||
<td
|
||||
class="w-40"
|
||||
v-if="row.mode !== 'pagebreak' && row.mode !== 'title'"
|
||||
v-if="!['pagebreak','title','text'].includes(row.mode)"
|
||||
>
|
||||
<UInput
|
||||
v-model="row.price"
|
||||
@@ -1114,7 +1134,7 @@ setupPage()
|
||||
</td>
|
||||
<td
|
||||
class="w-40"
|
||||
v-if="row.mode !== 'pagebreak' && row.mode !== 'title'"
|
||||
v-if="!['pagebreak','title','text'].includes(row.mode)"
|
||||
|
||||
>
|
||||
<USelectMenu
|
||||
@@ -1132,7 +1152,7 @@ setupPage()
|
||||
</td>
|
||||
<td
|
||||
class="w-40"
|
||||
v-if="row.mode !== 'pagebreak' && row.mode !== 'title'"
|
||||
v-if="!['pagebreak','title','text'].includes(row.mode)"
|
||||
>
|
||||
<UInput
|
||||
v-model="row.discountPercent"
|
||||
@@ -1147,7 +1167,7 @@ setupPage()
|
||||
</td>
|
||||
<td
|
||||
class="w-40"
|
||||
v-if="row.mode !== 'pagebreak' && row.mode !== 'title'"
|
||||
v-if="!['pagebreak','title','text'].includes(row.mode)"
|
||||
>
|
||||
<UButton
|
||||
icon="i-heroicons-document-text"
|
||||
@@ -1177,11 +1197,20 @@ setupPage()
|
||||
</UModal>
|
||||
</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>
|
||||
</td>
|
||||
<td
|
||||
v-if="row.mode === 'title'"
|
||||
colspan="8"
|
||||
>
|
||||
<UInput
|
||||
v-model="row.text"
|
||||
placeholder="Titel"
|
||||
/>
|
||||
</td>
|
||||
<td>
|
||||
<UButton
|
||||
variant="ghost"
|
||||
@@ -1200,19 +1229,19 @@ setupPage()
|
||||
@click="addPosition('service')"
|
||||
class="mt-3"
|
||||
>
|
||||
+ Leistungsposition
|
||||
+ Leistung
|
||||
</UButton>
|
||||
<UButton
|
||||
@click="addPosition('normal')"
|
||||
class="mt-3"
|
||||
>
|
||||
+ Artikelposition
|
||||
+ Artikel
|
||||
</UButton>
|
||||
<UButton
|
||||
@click="addPosition('free')"
|
||||
class="mt-3"
|
||||
>
|
||||
+ Freitextposition
|
||||
+ Freie Position
|
||||
</UButton>
|
||||
<UButton
|
||||
@click="addPosition('pagebreak')"
|
||||
@@ -1228,20 +1257,23 @@ setupPage()
|
||||
</UButton>
|
||||
</InputGroup>
|
||||
|
||||
<table>
|
||||
<tr>
|
||||
<td class="font-bold">Netto:</td>
|
||||
<td>{{documentTotal.totalNet}}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="font-bold">zzgl. 19 % USt:</td>
|
||||
<td>{{documentTotal.total19}}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="font-bold">Brutto:</td>
|
||||
<td>{{documentTotal.totalGross}}</td>
|
||||
</tr>
|
||||
</table>
|
||||
<div class="w-full flex justify-end">
|
||||
<table class="w-1/3">
|
||||
<tr>
|
||||
<td class="font-bold">Netto:</td>
|
||||
<td class="text-right">{{documentTotal.totalNet}}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="font-bold">zzgl. 19 % USt:</td>
|
||||
<td class="text-right">{{documentTotal.total19}}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="font-bold">Brutto:</td>
|
||||
<td class="text-right">{{documentTotal.totalGross}}</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user