Fixed Invoicing Problem and some other Changes
This commit is contained in:
@@ -63,7 +63,7 @@ const itemInfo = ref({
|
||||
|
||||
|
||||
const letterheads = ref([])
|
||||
const createdDocuments = ref([])
|
||||
const createddocuments = ref([])
|
||||
const projects = ref([])
|
||||
const products = ref([])
|
||||
const productcategories = ref([])
|
||||
@@ -79,14 +79,13 @@ const loaded = ref(false)
|
||||
const setupPage = async () => {
|
||||
|
||||
letterheads.value = (await useSupabaseSelect("letterheads","*")).filter(i => i.documentTypes.length === 0 || i.documentTypes.includes(itemInfo.value.type))
|
||||
createdDocuments.value = (await useSupabaseSelect("createddocuments","*"))
|
||||
createddocuments.value = (await useSupabaseSelect("createddocuments","*"))
|
||||
projects.value = (await useSupabaseSelect("projects","*"))
|
||||
services.value = (await useSupabaseSelect("services","*"))
|
||||
servicecategories.value = (await useSupabaseSelect("servicecategories","*"))
|
||||
products.value = (await useSupabaseSelect("products","*"))
|
||||
productcategories.value = (await useSupabaseSelect("productcategories","*"))
|
||||
customers.value = (await useSupabaseSelect("customers","*","customerNumber"))
|
||||
console.log(customers.value)
|
||||
contacts.value = (await useSupabaseSelect("contacts","*"))
|
||||
texttemplates.value = (await useSupabaseSelect("texttemplates","*"))
|
||||
if(productcategories.value.length > 0) selectedProductcategorie.value = productcategories.value[0].id
|
||||
@@ -175,7 +174,6 @@ const setupPage = async () => {
|
||||
|
||||
if(route.query.project) {
|
||||
itemInfo.value.project = Number(route.query.project)
|
||||
checkForOpenAdvanceInvoices()
|
||||
}
|
||||
if(route.query.contact) itemInfo.value.contact = Number(route.query.contact)
|
||||
if(route.query.customer) {
|
||||
@@ -184,6 +182,8 @@ const setupPage = async () => {
|
||||
}
|
||||
}
|
||||
|
||||
//if(itemInfo.value.project) checkForOpenAdvanceInvoices()
|
||||
|
||||
loaded.value = true
|
||||
|
||||
}
|
||||
@@ -238,6 +238,9 @@ const setCustomerData = () => {
|
||||
itemInfo.value.address.zip = customer.infoData.zip
|
||||
itemInfo.value.address.city = customer.infoData.city
|
||||
itemInfo.value.address.special = customer.infoData.special
|
||||
|
||||
if(customer.customPaymentDays) itemInfo.value.paymentDays = customer.customPaymentDays
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -458,7 +461,7 @@ const documentTotal = computed(() => {
|
||||
let totalGrossAlreadyPaid = 0
|
||||
|
||||
itemInfo.value.usedAdvanceInvoices.forEach(advanceInvoiceId => {
|
||||
let advanceInvoice = openAdvanceInvoices.value.find(i => i.id === advanceInvoiceId)
|
||||
let advanceInvoice = createddocuments.value.find(i => i.id === advanceInvoiceId)
|
||||
|
||||
let priceNet = advanceInvoice.rows.find(i => i.advanceInvoiceData).price
|
||||
|
||||
@@ -474,11 +477,11 @@ const documentTotal = computed(() => {
|
||||
|
||||
|
||||
return {
|
||||
totalNet: renderCurrency(totalNet),
|
||||
total19: renderCurrency(total19),
|
||||
totalGross: renderCurrency(totalGross),
|
||||
totalGrossAlreadyPaid: renderCurrency(totalGrossAlreadyPaid),
|
||||
totalSumToPay: renderCurrency(sumToPay)
|
||||
totalNet: totalNet,
|
||||
total19: total19,
|
||||
totalGross: totalGross,
|
||||
totalGrossAlreadyPaid: totalGrossAlreadyPaid,
|
||||
totalSumToPay: sumToPay
|
||||
|
||||
}
|
||||
|
||||
@@ -532,7 +535,7 @@ const processDieselPosition = () => {
|
||||
|
||||
const getDocumentData = () => {
|
||||
|
||||
let customerData = customers.find(i => i.id === itemInfo.value.customer)
|
||||
let customerData = customers.value.find(i => i.id === itemInfo.value.customer)
|
||||
let contactData = dataStore.getContactById(itemInfo.value.contact)
|
||||
let businessInfo = profileStore.ownTenant.businessInfo
|
||||
|
||||
@@ -549,12 +552,14 @@ const getDocumentData = () => {
|
||||
let unit = dataStore.units.find(i => i.id === row.unit)
|
||||
|
||||
if(!['pagebreak','title'].includes(row.mode)){
|
||||
if(row.agriculture?.description) {
|
||||
if(row.agriculture && row.agriculture.description) {
|
||||
console.log("Row has Agri")
|
||||
row.descriptionText = row.agriculture.description
|
||||
} else if(row.description) {
|
||||
console.log("Row has no Agri")
|
||||
row.descriptionText = row.description
|
||||
} else {
|
||||
delete row.descriptionText
|
||||
}
|
||||
}
|
||||
|
||||
@@ -591,6 +596,8 @@ const getDocumentData = () => {
|
||||
}
|
||||
}
|
||||
|
||||
let contactPerson = profileStore.getProfileById(itemInfo.value.contactPerson)
|
||||
|
||||
const returnData = {
|
||||
type: itemInfo.value.type,
|
||||
adressLine: `${businessInfo.name}, ${businessInfo.street}, ${businessInfo.zip} ${businessInfo.city}`,
|
||||
@@ -609,9 +616,9 @@ const getDocumentData = () => {
|
||||
documentDate: dayjs(itemInfo.value.documentDate).format("DD.MM.YYYY"),
|
||||
deliveryDate: dayjs(itemInfo.value.deliveryDate).format("DD.MM.YYYY"),
|
||||
deliveryDateType: itemInfo.value.deliveryDateType,
|
||||
contactPerson: itemInfo.value.contactPersonName,
|
||||
contactTel: itemInfo.value.contactTel,
|
||||
contactEMail: itemInfo.value.contactEMail,
|
||||
contactPerson: contactPerson.fullName,
|
||||
contactTel: contactPerson.fixedTel || contactPerson.mobileTel,
|
||||
contactEMail: contactPerson.email,
|
||||
project: dataStore.getProjectById(itemInfo.value.project) ? dataStore.getProjectById(itemInfo.value.project).name : null
|
||||
},
|
||||
title: itemInfo.value.title,
|
||||
@@ -619,14 +626,20 @@ const getDocumentData = () => {
|
||||
endText: templateEndText(generateContext(itemInfo.value, contactData)),
|
||||
startText: templateStartText(generateContext(itemInfo.value, contactData)),
|
||||
rows: rows,
|
||||
total: documentTotal.value,
|
||||
total: {
|
||||
totalNet: renderCurrency(documentTotal.value.totalNet),
|
||||
total19: renderCurrency(documentTotal.value.total19),
|
||||
totalGross: renderCurrency(documentTotal.value.totalGross),
|
||||
totalGrossAlreadyPaid: renderCurrency(documentTotal.value.totalGrossAlreadyPaid),
|
||||
totalSumToPay: renderCurrency(documentTotal.value.totalSumToPay)
|
||||
},
|
||||
agriculture: itemInfo.value.agriculture,
|
||||
usedAdvanceInvoices: itemInfo.value.usedAdvanceInvoices.map(i => {
|
||||
return openAdvanceInvoices.value.find(x => x.id === i)
|
||||
return createddocuments.value.find(x => x.id === i)
|
||||
})
|
||||
}
|
||||
|
||||
//console.log(returnData)
|
||||
console.log(returnData)
|
||||
|
||||
return returnData
|
||||
}
|
||||
@@ -715,7 +728,7 @@ const saveSerialInvoice = async () => {
|
||||
await router.push(`/createDocument/edit/${data[0].id}`)
|
||||
}
|
||||
|
||||
const saveDocument = async (state) => {
|
||||
const saveDocument = async (state,resetup = false) => {
|
||||
|
||||
itemInfo.value.state = state
|
||||
|
||||
@@ -788,21 +801,22 @@ const saveDocument = async (state) => {
|
||||
if(route.params.id) {
|
||||
await dataStore.updateItem("createddocuments", {...createData, id: itemInfo.value.id})
|
||||
} else {
|
||||
const {data} = await dataStore.createNewItem("createddocuments", createData)
|
||||
const data = await dataStore.createNewItem("createddocuments", createData)
|
||||
console.log(data)
|
||||
await router.push(`/createDocument/edit/${data[0].id}`)
|
||||
}
|
||||
|
||||
await setupPage()
|
||||
|
||||
if(resetup) await setupPage()
|
||||
}
|
||||
|
||||
const closeDocument = async () => {
|
||||
|
||||
loaded.value = false
|
||||
|
||||
await saveDocument("Gebucht")
|
||||
|
||||
await generateDocument()
|
||||
|
||||
|
||||
let fileData = {
|
||||
tags: [],
|
||||
project: null
|
||||
@@ -828,14 +842,12 @@ const closeDocument = async () => {
|
||||
|
||||
await dataStore.uploadFiles(fileData, [file], true)
|
||||
|
||||
|
||||
|
||||
await router.push(`/createDocument/show/${itemInfo.value.id}`)
|
||||
|
||||
//console.log(uri)
|
||||
}
|
||||
|
||||
const setRowData = (row) => {
|
||||
console.log(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
|
||||
@@ -859,7 +871,7 @@ const setRowData = (row) => {
|
||||
<template #right>
|
||||
<UButton
|
||||
icon="i-mdi-content-save"
|
||||
@click="saveDocument('Entwurf')"
|
||||
@click="saveDocument('Entwurf',true)"
|
||||
v-if="itemInfo.type !== 'serialInvoices' "
|
||||
:disabled="!itemInfo.customer"
|
||||
>
|
||||
@@ -882,6 +894,7 @@ const setRowData = (row) => {
|
||||
</UDashboardNavbar>
|
||||
|
||||
<UDashboardPanelContent>
|
||||
{{itemInfo}}
|
||||
<UTabs class="p-5" :items="tabItems" @change="onChangeTab" v-if="loaded">
|
||||
<template #item="{item}">
|
||||
<div v-if="item.label === 'Editor'">
|
||||
@@ -1028,7 +1041,7 @@ const setRowData = (row) => {
|
||||
class="w-25"
|
||||
v-if="itemInfo.customer"
|
||||
icon="i-heroicons-arrow-right-end-on-rectangle"
|
||||
@click="router.push(`/customers/show/${itemInfo.customer}`)"
|
||||
@click="router.push(`/standardEntity/customers/show/${itemInfo.customer}`)"
|
||||
>Kunde</UButton>
|
||||
</div>
|
||||
|
||||
@@ -1084,7 +1097,7 @@ const setRowData = (row) => {
|
||||
variant="outline"
|
||||
v-if="itemInfo.contact"
|
||||
icon="i-heroicons-arrow-right-end-on-rectangle"
|
||||
@click="router.push(`/contacts/show/${itemInfo.contact}`)"
|
||||
@click="router.push(`/standardEntity/contacts/show/${itemInfo.contact}`)"
|
||||
>Kontakt</UButton>
|
||||
</InputGroup>
|
||||
|
||||
@@ -1232,7 +1245,7 @@ const setRowData = (row) => {
|
||||
:search-attributes="['name']"
|
||||
class="w-full"
|
||||
:disabled="!itemInfo.customer"
|
||||
@input="checkForOpenAdvanceInvoices"
|
||||
@change="checkForOpenAdvanceInvoices"
|
||||
>
|
||||
<template #label>
|
||||
{{dataStore.getProjectById(itemInfo.project) ? dataStore.getProjectById(itemInfo.project).name : "Kein Projekt ausgewählt"}}
|
||||
@@ -1252,7 +1265,7 @@ const setRowData = (row) => {
|
||||
variant="outline"
|
||||
v-if="itemInfo.project"
|
||||
icon="i-heroicons-arrow-right-end-on-rectangle"
|
||||
@click="router.push(`/projects/show/${itemInfo.project}`)"
|
||||
@click="router.push(`/standardEntity/projects/show/${itemInfo.project}`)"
|
||||
>Projekt</UButton>
|
||||
</InputGroup>
|
||||
|
||||
@@ -1341,7 +1354,7 @@ const setRowData = (row) => {
|
||||
<UFormGroup
|
||||
label="Titel:"
|
||||
>
|
||||
<UInput v-model="itemInfo.title"/>
|
||||
<UInput v-model="itemInfo.title" disabled/>
|
||||
</UFormGroup>
|
||||
<UFormGroup
|
||||
label="Beschreibung:"
|
||||
@@ -1532,7 +1545,7 @@ const setRowData = (row) => {
|
||||
searchable-placeholder="Suche ..."
|
||||
:search-attributes="['name']"
|
||||
v-model="row.service"
|
||||
@input="setRowData(row)"
|
||||
@change="setRowData(row)"
|
||||
>
|
||||
<template #label>
|
||||
<span class="truncate">{{services.find(i => i.id === row.service) ? services.find(i => i.id === row.service).name : "Keine Leistung ausgewählt" }}</span>
|
||||
@@ -1612,7 +1625,6 @@ const setRowData = (row) => {
|
||||
v-model="row.price"
|
||||
type="number"
|
||||
step="0.001"
|
||||
:color="getRowMargin(row) > 0 ? 'primary' : 'rose'"
|
||||
>
|
||||
<template #trailing>
|
||||
<span class="text-gray-500 dark:text-gray-400 text-xs">EUR</span>
|
||||
@@ -1847,29 +1859,24 @@ const setRowData = (row) => {
|
||||
<table class="w-1/3" v-if="itemInfo.rows.length > 0">
|
||||
<tr>
|
||||
<td class="font-bold">Netto:</td>
|
||||
<td class="text-right">{{documentTotal.totalNet}}</td>
|
||||
<td class="text-right">{{renderCurrency(documentTotal.totalNet)}}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="font-bold">zzgl. 19 % USt:</td>
|
||||
<td class="text-right">{{documentTotal.total19}}</td>
|
||||
<td class="text-right">{{renderCurrency(documentTotal.total19)}}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="font-bold">Brutto:</td>
|
||||
<td class="text-right">{{documentTotal.totalGross}}</td>
|
||||
<td class="text-right">{{renderCurrency(documentTotal.totalGross)}}</td>
|
||||
</tr>
|
||||
|
||||
|
||||
<tr v-if="documentTotal.totalGrossAlreadyPaid !== '0,00 €'">
|
||||
<td class="font-bold">Bereits bezahlt:</td>
|
||||
<td class="text-right">{{documentTotal.totalGrossAlreadyPaid}}</td>
|
||||
<td class="text-right">{{renderCurrency(documentTotal.totalGrossAlreadyPaid)}}</td>
|
||||
</tr>
|
||||
|
||||
|
||||
<tr v-if="documentTotal.totalGrossAlreadyPaid !== '0,00 €'">
|
||||
<td class="font-bold">Offene Summe:</td>
|
||||
<td class="text-right">{{documentTotal.totalSumToPay}}</td>
|
||||
<td class="text-right">{{renderCurrency(documentTotal.totalSumToPay)}}</td>
|
||||
</tr>
|
||||
|
||||
</table>
|
||||
</div>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user