diff --git a/pages/createDocument/edit/[[id]].vue b/pages/createDocument/edit/[[id]].vue index 8b4a68c..004bf00 100644 --- a/pages/createDocument/edit/[[id]].vue +++ b/pages/createDocument/edit/[[id]].vue @@ -17,9 +17,6 @@ definePageMeta({ middleware: "auth" }) -const showProductSelectionModal = ref(false) -const showServiceSelectionModal = ref(false) - const itemInfo = ref({ type: "invoices", @@ -107,7 +104,7 @@ const setupPage = async () => { checkCompatibilityWithInputPrice() } - if(itemInfo.value.project) checkForOpenAdvanceInvoices() + if(itemInfo.value.project) await checkForOpenAdvanceInvoices() if(!itemInfo.value.deliveryDateType) itemInfo.value.deliveryDateType = "Lieferdatum" @@ -236,8 +233,11 @@ const setupPage = async () => { } else { // Import all + if(process.dev) console.log(linkedDocument) + itemInfo.value.taxType = linkedDocument.taxType itemInfo.value.customer = linkedDocument.customer + await setCustomerData(null,true) itemInfo.value.letterhead = linkedDocument.letterhead itemInfo.value.contact = linkedDocument.contact itemInfo.value.deliveryDateType = linkedDocument.deliveryDateType @@ -256,7 +256,7 @@ const setupPage = async () => { itemInfo.value.endText = linkedDocument.endText } - setCustomerData(null,true) + 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(() => { 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(() => { @@ -638,6 +629,8 @@ const tabItems = computed(() => { const renderCurrency = (value, currency = "€") => { return Number(value).toFixed(2).replace(".",",") + " €" + //return Number(value).toFixed(2).replace(".",",") + " " + currency + return useCurrency(value, currency) } const documentTotal = computed(() => { @@ -731,18 +724,15 @@ const documentReport = computed(() => { itemInfo.value.rows.filter(i => !i.optional && !i.alternative).forEach(row => { if(row.product) { let product = products.value.find(i => i.id === row.product) - console.log(product.purchasePrice) totalProductsPurchasePrice += product.purchasePrice * row.quantity } else if(row.service) { let service = services.value.find(i => i.id === row.service) - console.log(service) if(service.materialComposition) { service.materialComposition.forEach(entry => { let productData = products.value.find(i => i.id === entry.product) - console.log(productData) totalProductsFromServicesPurchasePrice += productData.purchasePrice * entry.quantity * row.quantity }) @@ -1070,7 +1060,6 @@ const getDocumentData = () => { const showDocument = ref(false) const uri = ref("") const generateDocument = async () => { - const ownTenant = profileStore.ownTenant const path = letterheads.value.find(i => i.id === itemInfo.value.letterhead).path /*const {data,error} = await supabase.functions.invoke('create_pdf',{ @@ -1316,7 +1305,6 @@ const getTextTemplateByType = (type, pos) => { const checkCompatibilityWithInputPrice = () => { itemInfo.value.rows.forEach(row => { - console.log(row) if(!row.inputPrice) { row.inputPrice = row.price } @@ -1653,7 +1641,7 @@ const setRowData = async (row, service = {sellingPriceComposed: {}}, product = { - {{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"}}