diff --git a/frontend/pages/createDocument/edit/[[id]].vue b/frontend/pages/createDocument/edit/[[id]].vue index 7116948..d85b54a 100644 --- a/frontend/pages/createDocument/edit/[[id]].vue +++ b/frontend/pages/createDocument/edit/[[id]].vue @@ -351,6 +351,10 @@ const normalizeCreatedDocumentRow = (row) => { const normalizeCreatedDocumentRows = (rows) => Array.isArray(rows) ? rows.map((row) => normalizeCreatedDocumentRow(row)) : [] +const isImportedAdvanceInvoiceRow = (row) => { + return Array.isArray(row.linkedEntitys) + && row.linkedEntitys.some(i => i.type === "createddocuments" && i.subtype === "advanceInvoices") +} const setupPage = async () => { await setupData() @@ -507,6 +511,8 @@ const setupPage = async () => { }) for await (const doc of linkedDocuments.filter(i => i.type === "advanceInvoices")) { + const advanceInvoiceNet = useSum().getCreatedDocumentSumDetailed(doc).totalNet * -1 + itemInfo.value.rows.push({ mode: "free", text: `Abschlagsrechnung ${doc.documentNumber}`, @@ -514,7 +520,8 @@ const setupPage = async () => { taxPercent: 19, // TODO TAX PERCENTAGE discountPercent: 0, unit: 10, - inputPrice: useSum().getCreatedDocumentSumDetailed(doc).totalNet * -1, + inputPrice: advanceInvoiceNet, + price: advanceInvoiceNet, linkedEntitys: [ { type: "createddocuments", @@ -1799,15 +1806,15 @@ const checkCompatibilityWithInputPrice = () => { const updateCustomSurcharge = () => { itemInfo.value.rows.forEach(row => { - if (!["pagebreak", "title", "text"].includes(row.mode) /*&& !row.linkedEntitys.find(i => i.type === "createddocuments" && i.subtype === "advanceInvoices")*/) { + if (!["pagebreak", "title", "text"].includes(row.mode) && isImportedAdvanceInvoiceRow(row)) { + row.price = Number(row.inputPrice || 0) + } else if (!["pagebreak", "title", "text"].includes(row.mode)) { //setRowData(row) row.price = Number((row.inputPrice * (1 + itemInfo.value.customSurchargePercentage / 100)).toFixed(2)) - }/* else if(!["pagebreak","title","text"].includes(row.mode) /!*&& row.linkedEntitys.find(i => i.type === "createddocuments" && i.subtype === "advanceInvoices")*!/) { - row.price = row.inputPrice - }*/ + } }) } @@ -3289,7 +3296,7 @@ const setRowData = async (row, service = {sellingPriceComposed: {}}, product = {