This commit is contained in:
2024-02-21 16:38:48 +01:00
parent 6e2e419a1c
commit ddb3b90788
13 changed files with 409 additions and 34 deletions

View File

@@ -9,7 +9,9 @@ const router = useRouter()
const supabase = useSupabaseClient()
definePageMeta({
middleware: "auth"
})
@@ -142,6 +144,15 @@ const addPosition = (mode) => {
taxPercent: 19,
discountPercent: 0
})
} else if(mode === 'service'){
itemInfo.value.rows.push({
id: lastId +1,
mode: "service",
quantity: 1,
price: 0,
taxPercent: 19,
discountPercent: 0
})
} else if(mode === "pagebreak") {
itemInfo.value.rows.push({
id: lastId +1,
@@ -202,6 +213,7 @@ const getDocumentData = () => {
let customerData = dataStore.getCustomerById(itemInfo.value.customer)
let contactData = dataStore.getContactById(itemInfo.value.contact)
let userData = dataStore.getProfileById(user.value.id)
let businessInfo = dataStore.ownTenant.businessInfo
@@ -236,14 +248,14 @@ const getDocumentData = () => {
const returnData = {
adressLine: `${businessInfo.name}, ${businessInfo.street}, ${businessInfo.zip} ${businessInfo.city}`,
recipient: {
name: customerData.name,
contact: contactData ? `${contactData.firstName} ${contactData.lastName}` : "",
street: customerData.infoData.street,
special: "",
city: customerData.infoData.city,
zip: customerData.infoData.zip
street: itemInfo.value.address.street || customerData.infoData.street,
special: itemInfo.value.address.special || customerData.infoData.special,
city: itemInfo.value.address.city || customerData.infoData.city,
zip: itemInfo.value.address.zip || customerData.infoData.zip
},
info: {
customerNumber: customerData.customerNumber,
@@ -276,12 +288,8 @@ const uri = ref("")
const generateDocument = async () => {
const ownTenant = dataStore.ownTenant
const path = ownTenant.letterheadConfig[itemInfo.value.type]
console.log(path)
console.log(ownTenant)
const {data,error} = await supabase.storage.from("files").download(path)
console.log(data)
console.log(error)
uri.value = await useCreatePdf(getDocumentData(), await data.arrayBuffer())
//alert(uri.value)
@@ -297,7 +305,7 @@ const onChangeTab = (index) => {
const setPosNumbers = () => {
let index = 1
let rows = itemInfo.value.rows.map(row => {
if(row.mode === 'free' ||row.mode === 'normal') {
if(row.mode !== 'pagebreak') {
row.pos = index
index += 1
}
@@ -480,29 +488,28 @@ setupPage()
<UInput
v-model="itemInfo.address.street"
:placeholder="dataStore.getCustomerById(itemInfo.customer) ? dataStore.getCustomerById(itemInfo.customer).infoData.street : 'Straße + Hausnummer'"
:color="itemInfo.address.street ? 'primary' : 'rose'"
/>
<UInput
v-model="itemInfo.address.special"
class="mt-3"
:placeholder="dataStore.getCustomerById(itemInfo.customer) ? dataStore.getCustomerById(itemInfo.customer).infoData.special : 'Adresszusatz'"
/>
<InputGroup class="mt-3">
<UInput
class="flex-auto"
v-model="itemInfo.address.zip"
:placeholder="dataStore.getCustomerById(itemInfo.customer) ? dataStore.getCustomerById(itemInfo.customer).infoData.zip : 'PLZ'"
:color="itemInfo.address.zip ? 'primary' : 'rose'"
/>
<UInput
class="flex-auto"
v-model="itemInfo.address.city"
:placeholder="dataStore.getCustomerById(itemInfo.customer) ? dataStore.getCustomerById(itemInfo.customer).infoData.city : 'Ort'"
:color="itemInfo.address.city ? 'primary' : 'rose'"
/>
</InputGroup>
</UFormGroup>
</div>
<div class="flex-auto">
<UFormGroup
@@ -697,7 +704,7 @@ setupPage()
<UDivider/>
</td>
<td
v-if="row.mode === 'free' || row.mode === 'normal'"
v-if="row.mode !== 'pagebreak'"
>{{row.pos}}</td>
<td
class="w-120"
@@ -729,9 +736,29 @@ setupPage()
</template>
</USelectMenu>
</td>
<td
class="w-120"
v-else-if="row.mode === 'service'"
>
<USelectMenu
:options="dataStore.services"
option-attribute="name"
value-attribute="id"
searchable
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"
>
<template #label>
{{dataStore.getServiceById(row.service) ? dataStore.getServiceById(row.service).name : "Keine Leistung ausgewählt" }}
</template>
</USelectMenu>
</td>
<td
class="w-20"
v-if="row.mode === 'free' || row.mode === 'normal'"
v-if="row.mode !== 'pagebreak'"
>
<UInput
v-model="row.quantity"
@@ -742,7 +769,7 @@ setupPage()
</td>
<td
class="w-40"
v-if="row.mode === 'free' || row.mode === 'normal'"
v-if="row.mode !== 'pagebreak'"
>
<USelectMenu
v-model="row.unit"
@@ -756,7 +783,7 @@ setupPage()
</USelectMenu>
</td>
<td
v-if="row.mode === 'free' || row.mode === 'normal'"
v-if="row.mode !== 'pagebreak'"
>
<UInput
v-model="row.price"
@@ -770,7 +797,7 @@ setupPage()
</td>
<td
class="w-40"
v-if="row.mode === 'free' || row.mode === 'normal'"
v-if="row.mode !== 'pagebreak'"
>
<USelectMenu
@@ -788,7 +815,7 @@ setupPage()
</td>
<td
class="w-40"
v-if="row.mode === 'free' || row.mode === 'normal'"
v-if="row.mode !== 'pagebreak'"
>
<UInput
v-model="row.discountPercent"
@@ -802,7 +829,7 @@ setupPage()
</UInput>
</td>
<td
v-if="row.mode === 'free' || row.mode === 'normal'"
v-if="row.mode !== 'pagebreak'"
>
<p class="text-right font-bold whitespace-nowrap">{{getRowAmount(row)}} </p>
</td>
@@ -970,6 +997,12 @@ setupPage()
</table>
<InputGroup>
<UButton
@click="addPosition('service')"
class="mt-3"
>
+ Leistungsposition
</UButton>
<UButton
@click="addPosition('normal')"
class="mt-3"

View File

@@ -1,5 +1,7 @@
<script setup>
definePageMeta({
middleware: "auth"
})
const dataStore = useDataStore()
const route = useRoute()
const router = useRouter()