From e71281dceee1eea6df9d0987c30c19e2436aabc0 Mon Sep 17 00:00:00 2001 From: florianfederspiel Date: Fri, 17 Jan 2025 18:49:19 +0100 Subject: [PATCH] Fixed Problems in LinkedDocuments and Storno --- pages/createDocument/edit/[[id]].vue | 22 +++++++++++++++------- pages/createDocument/index.vue | 5 ++++- 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/pages/createDocument/edit/[[id]].vue b/pages/createDocument/edit/[[id]].vue index 6bde368..6fa4bc3 100644 --- a/pages/createDocument/edit/[[id]].vue +++ b/pages/createDocument/edit/[[id]].vue @@ -156,12 +156,18 @@ const setupPage = async () => { setPosNumbers() - if(linkedDocuments.find(i => i.agriculture.dieselUsage)){ + console.log(linkedDocuments) + + if(linkedDocuments.find(i => i.rows.find( x => x.agriculture.dieselUsage))){ + console.log("has diesel") + + //Remove Existing Total Diesel Pos itemInfo.value.rows = itemInfo.value.rows.filter(i => i.key !== "dieselPos") + //Add Total Title itemInfo.value.rows.push({ id:uuidv4(), - mode: "text", + mode: "title", text: "Allgemein" }) @@ -443,6 +449,7 @@ const findDocumentErrors = computed(() => { errors.push({message: "Es sind keine Positionen angegeben", type: "breaking"}) } else { 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`, type: "breaking"}) @@ -451,15 +458,17 @@ const findDocumentErrors = computed(() => { if(["normal","service","free"].includes(row.mode)){ - if(!row.taxPercent) errors.push({message: `In Position ${row.pos} ist kein Steuersatz hinterlegt`, type: "breaking"}) - if(!row.price || row.price === 0) errors.push({message: `In Position ${row.pos} ist kein Preis hinterlegt`, type: "breaking"}) + if(!row.taxPercent && typeof row.taxPercent !== "number") errors.push({message: `In Position ${row.pos} ist kein Steuersatz hinterlegt`, type: "breaking"}) + if(!row.price && typeof row.price !== "number") errors.push({message: `In Position ${row.pos} ist kein Preis hinterlegt`, type: "breaking"}) } if(row.agriculture){ - if(row.agriculture.dieselUsage && (!row.agriculture.dieselPrice || row.agriculture.dieselPrice === 0)) { + if(row.agriculture.dieselUsage && (!row.agriculture.dieselPrice && typeof row.agriculture.dieselPrice !== "number")) { errors.push({message: `In Position ${row.pos} ist kein Dieselpreis hinterlegt`, type: "breaking"}) + } else if(row.agriculture.dieselUsage && row.agriculture.dieselPrice === 0) { + errors.push({message: `In Position ${row.pos} ist 0,00 € als Dieselpreis hinterlegt`, type: "info"}) } } @@ -552,7 +561,6 @@ const processDieselPosition = () => { if(row.agriculture && row.agriculture.dieselUsage) { agricultureData.dieselUsageTotal += Number(row.agriculture.dieselUsage) agricultureData.dieselPriceTotal += Number(row.agriculture.dieselPrice) * Number(row.agriculture.dieselUsage) - } }) @@ -970,7 +978,7 @@ const setRowData = (row) => { v-if="itemInfo.type !== 'serialInvoices' " :disabled="!itemInfo.customer" > - Entwurf speichern + Speichern { row.rows.forEach(row => { if(row.mode === "normal" || row.mode === "service" || row.mode === "free") { - sum += row.quantity * row.price * (1 - row.discountPercent / 100) * (1 + row.taxPercent / 100) + sum += row.quantity * row.price * (1 - row.discountPercent / 100) * (1 + (row.taxPercent || 0) / 100) } })