Fixed Problems in LinkedDocuments and Storno

This commit is contained in:
2025-01-17 18:49:19 +01:00
parent 6626bd568d
commit e71281dcee
2 changed files with 19 additions and 8 deletions

View File

@@ -156,12 +156,18 @@ const setupPage = async () => {
setPosNumbers() 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") itemInfo.value.rows = itemInfo.value.rows.filter(i => i.key !== "dieselPos")
//Add Total Title
itemInfo.value.rows.push({ itemInfo.value.rows.push({
id:uuidv4(), id:uuidv4(),
mode: "text", mode: "title",
text: "Allgemein" text: "Allgemein"
}) })
@@ -443,6 +449,7 @@ const findDocumentErrors = computed(() => {
errors.push({message: "Es sind keine Positionen angegeben", type: "breaking"}) errors.push({message: "Es sind keine Positionen angegeben", type: "breaking"})
} else { } else {
itemInfo.value.rows.forEach(row => { 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 === "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 === "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"}) 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(["normal","service","free"].includes(row.mode)){
if(!row.taxPercent) errors.push({message: `In Position ${row.pos} ist kein Steuersatz 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 || row.price === 0) errors.push({message: `In Position ${row.pos} ist kein Preis 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){
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"}) 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) { if(row.agriculture && row.agriculture.dieselUsage) {
agricultureData.dieselUsageTotal += Number(row.agriculture.dieselUsage) agricultureData.dieselUsageTotal += Number(row.agriculture.dieselUsage)
agricultureData.dieselPriceTotal += Number(row.agriculture.dieselPrice) * 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' " v-if="itemInfo.type !== 'serialInvoices' "
:disabled="!itemInfo.customer" :disabled="!itemInfo.customer"
> >
Entwurf speichern Speichern
</UButton> </UButton>
<UButton <UButton
@click="closeDocument" @click="closeDocument"

View File

@@ -215,6 +215,9 @@ const templateTypes = [
{ {
key: "invoices", key: "invoices",
label: "Rechnungen" label: "Rechnungen"
},{
key: "cancellationInvoices",
label: "Stornorechnungen"
},{ },{
key: "advanceInvoices", key: "advanceInvoices",
label: "Abschlagsrechnungen" label: "Abschlagsrechnungen"
@@ -269,7 +272,7 @@ const calculateDocSum = (row) => {
row.rows.forEach(row => { row.rows.forEach(row => {
if(row.mode === "normal" || row.mode === "service" || row.mode === "free") { 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)
} }
}) })