This commit is contained in:
2025-07-31 20:34:29 +02:00
parent 23573caceb
commit 80d68e0aa9

View File

@@ -17,9 +17,6 @@ definePageMeta({
middleware: "auth" middleware: "auth"
}) })
const showProductSelectionModal = ref(false)
const showServiceSelectionModal = ref(false)
const itemInfo = ref({ const itemInfo = ref({
type: "invoices", type: "invoices",
@@ -107,7 +104,7 @@ const setupPage = async () => {
checkCompatibilityWithInputPrice() checkCompatibilityWithInputPrice()
} }
if(itemInfo.value.project) checkForOpenAdvanceInvoices() if(itemInfo.value.project) await checkForOpenAdvanceInvoices()
if(!itemInfo.value.deliveryDateType) itemInfo.value.deliveryDateType = "Lieferdatum" if(!itemInfo.value.deliveryDateType) itemInfo.value.deliveryDateType = "Lieferdatum"
@@ -236,8 +233,11 @@ const setupPage = async () => {
} else { } else {
// Import all // Import all
if(process.dev) console.log(linkedDocument)
itemInfo.value.taxType = linkedDocument.taxType itemInfo.value.taxType = linkedDocument.taxType
itemInfo.value.customer = linkedDocument.customer itemInfo.value.customer = linkedDocument.customer
await setCustomerData(null,true)
itemInfo.value.letterhead = linkedDocument.letterhead itemInfo.value.letterhead = linkedDocument.letterhead
itemInfo.value.contact = linkedDocument.contact itemInfo.value.contact = linkedDocument.contact
itemInfo.value.deliveryDateType = linkedDocument.deliveryDateType itemInfo.value.deliveryDateType = linkedDocument.deliveryDateType
@@ -256,7 +256,7 @@ const setupPage = async () => {
itemInfo.value.endText = linkedDocument.endText itemInfo.value.endText = linkedDocument.endText
} }
setCustomerData(null,true)
checkCompatibilityWithInputPrice() checkCompatibilityWithInputPrice()
@@ -546,15 +546,6 @@ const removePosition = (id) => {
} }
const getRowMargin = (row) => {
if(row.mode === "normal" && row.product) {
let purchasePrice = products.value.find(i => i.id === row.product).purchasePrice || 0
return row.price - purchasePrice
} else {
return 0
}
}
const findDocumentErrors = computed(() => { const findDocumentErrors = computed(() => {
let errors = [] let errors = []
@@ -621,7 +612,7 @@ const findDocumentErrors = computed(() => {
} }
return errors.sort((a,b) => (a.type === "breaking") ? -1 : 1) return errors.sort((a) => (a.type === "breaking") ? -1 : 1)
}) })
const tabItems = computed(() => { const tabItems = computed(() => {
@@ -638,6 +629,8 @@ const tabItems = computed(() => {
const renderCurrency = (value, currency = "€") => { const renderCurrency = (value, currency = "€") => {
return Number(value).toFixed(2).replace(".",",") + " €" return Number(value).toFixed(2).replace(".",",") + " €"
//return Number(value).toFixed(2).replace(".",",") + " " + currency
return useCurrency(value, currency)
} }
const documentTotal = computed(() => { const documentTotal = computed(() => {
@@ -731,18 +724,15 @@ const documentReport = computed(() => {
itemInfo.value.rows.filter(i => !i.optional && !i.alternative).forEach(row => { itemInfo.value.rows.filter(i => !i.optional && !i.alternative).forEach(row => {
if(row.product) { if(row.product) {
let product = products.value.find(i => i.id === row.product) let product = products.value.find(i => i.id === row.product)
console.log(product.purchasePrice)
totalProductsPurchasePrice += product.purchasePrice * row.quantity totalProductsPurchasePrice += product.purchasePrice * row.quantity
} else if(row.service) { } else if(row.service) {
let service = services.value.find(i => i.id === row.service) let service = services.value.find(i => i.id === row.service)
console.log(service)
if(service.materialComposition) { if(service.materialComposition) {
service.materialComposition.forEach(entry => { service.materialComposition.forEach(entry => {
let productData = products.value.find(i => i.id === entry.product) let productData = products.value.find(i => i.id === entry.product)
console.log(productData)
totalProductsFromServicesPurchasePrice += productData.purchasePrice * entry.quantity * row.quantity totalProductsFromServicesPurchasePrice += productData.purchasePrice * entry.quantity * row.quantity
}) })
@@ -1070,7 +1060,6 @@ const getDocumentData = () => {
const showDocument = ref(false) const showDocument = ref(false)
const uri = ref("") const uri = ref("")
const generateDocument = async () => { const generateDocument = async () => {
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',{ /*const {data,error} = await supabase.functions.invoke('create_pdf',{
@@ -1316,7 +1305,6 @@ const getTextTemplateByType = (type, pos) => {
const checkCompatibilityWithInputPrice = () => { const checkCompatibilityWithInputPrice = () => {
itemInfo.value.rows.forEach(row => { itemInfo.value.rows.forEach(row => {
console.log(row)
if(!row.inputPrice) { if(!row.inputPrice) {
row.inputPrice = row.price row.inputPrice = row.price
} }
@@ -1653,7 +1641,7 @@ const setRowData = async (row, service = {sellingPriceComposed: {}}, product = {
</UFormGroup> </UFormGroup>
<UFormGroup <UFormGroup
label="Ansprechpartner:" label="Ansprechpartner:"
v-if="itemInfo.customer ? dataStore.getCustomerById(itemInfo.customer).isCompany : false " v-if="itemInfo.customer ? customers.find(i => i.id === itemInfo.customer).isCompany : false "
> >
<InputGroup> <InputGroup>
<USelectMenu <USelectMenu
@@ -1672,13 +1660,13 @@ const setRowData = async (row, service = {sellingPriceComposed: {}}, product = {
class="w-full" class="w-full"
:disabled="!itemInfo.customer" :disabled="!itemInfo.customer"
> >
<span class="truncate">{{dataStore.getContactById(itemInfo.contact) ? dataStore.getContactById(itemInfo.contact).fullName : "Kein Kontakt ausgewählt"}}</span> <span class="truncate">{{itemInfo.contact ? contacts.find(i => i.id === itemInfo.contact).fullName : "Kein Kontakt ausgewählt"}}</span>
<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> <template #label>
{{dataStore.getContactById(itemInfo.contact) ? dataStore.getContactById(itemInfo.contact).fullName : "Kein Kontakt ausgewählt"}} {{ itemInfo.contact ? contacts.find(i => i.id === itemInfo.contact).fullName : "Kein Kontakt ausgewählt"}}
</template> </template>
</USelectMenu> </USelectMenu>
<!-- <UButton <!-- <UButton
@@ -1690,7 +1678,7 @@ const setRowData = async (row, service = {sellingPriceComposed: {}}, product = {
<EntityModalButtons <EntityModalButtons
type="contacts" type="contacts"
:id="itemInfo.contact" :id="itemInfo.contact"
:create-query="{customerId: itemInfo.customer}" :create-query="{customer: itemInfo.customer}"
@return-data="(data) => itemInfo.contact = data.id" @return-data="(data) => itemInfo.contact = data.id"
/> />
</InputGroup> </InputGroup>
@@ -1702,25 +1690,25 @@ const setRowData = async (row, service = {sellingPriceComposed: {}}, product = {
> >
<UInput <UInput
v-model="itemInfo.address.street" v-model="itemInfo.address.street"
:placeholder="dataStore.getCustomerById(itemInfo.customer) ? dataStore.getCustomerById(itemInfo.customer).infoData.street : 'Straße + Hausnummer'" :placeholder="itemInfo.customer ? customers.find(i => i.id === itemInfo.customer).infoData.street : 'Straße + Hausnummer'"
:color="itemInfo.address.street ? 'primary' : 'rose'" :color="itemInfo.address.street ? 'primary' : 'rose'"
/> />
<UInput <UInput
v-model="itemInfo.address.special" v-model="itemInfo.address.special"
class="mt-3" class="mt-3"
:placeholder="dataStore.getCustomerById(itemInfo.customer) ? dataStore.getCustomerById(itemInfo.customer).infoData.special : 'Adresszusatz'" :placeholder="itemInfo.customer ? customers.find(i => i.id === itemInfo.customer).infoData.special : 'Adresszusatz'"
/> />
<InputGroup class="mt-3"> <InputGroup class="mt-3">
<UInput <UInput
class="flex-auto" class="flex-auto"
v-model="itemInfo.address.zip" v-model="itemInfo.address.zip"
:placeholder="dataStore.getCustomerById(itemInfo.customer) ? dataStore.getCustomerById(itemInfo.customer).infoData.zip : 'PLZ'" :placeholder="itemInfo.customer ? customers.find(i => i.id === itemInfo.customer).infoData.zip : 'PLZ'"
:color="itemInfo.address.zip ? 'primary' : 'rose'" :color="itemInfo.address.zip ? 'primary' : 'rose'"
/> />
<UInput <UInput
class="flex-auto" class="flex-auto"
v-model="itemInfo.address.city" v-model="itemInfo.address.city"
:placeholder="dataStore.getCustomerById(itemInfo.customer) ? dataStore.getCustomerById(itemInfo.customer).infoData.city : 'Ort'" :placeholder="itemInfo.customer ? customers.find(i => i.id === itemInfo.customer).infoData.city : 'Ort'"
:color="itemInfo.address.city ? 'primary' : 'rose'" :color="itemInfo.address.city ? 'primary' : 'rose'"
/> />
</InputGroup> </InputGroup>
@@ -1915,7 +1903,7 @@ const setRowData = async (row, service = {sellingPriceComposed: {}}, product = {
@change="checkForOpenAdvanceInvoices" @change="checkForOpenAdvanceInvoices"
> >
<template #label> <template #label>
{{dataStore.getProjectById(itemInfo.project) ? dataStore.getProjectById(itemInfo.project).name : "Kein Projekt ausgewählt"}} {{itemInfo.project ? projects.find(i => i.id === itemInfo.project).name : "Kein Projekt ausgewählt"}}
</template> </template>
<template #option="{option: project}"> <template #option="{option: project}">
{{dataStore.getCustomerById(project.customer).name}} - {{project.name}} {{dataStore.getCustomerById(project.customer).name}} - {{project.name}}