Added Document Report

This commit is contained in:
2025-04-19 17:34:45 +02:00
parent d762bb3228
commit 8edd996b89

View File

@@ -696,6 +696,74 @@ const documentTotal = computed(() => {
}
})
const documentReport = computed(() => {
let totalProductsPurchasePrice = 0
let totalProductsFromServicesPurchasePrice = 0
let totalHoursFromServices = {
total: 0,
totalPurchasePrice: 0,
byName: {}
}
let totalHoursSellingPrice = 0
itemInfo.value.rows.forEach(row => {
if(row.product) {
let product = products.value.find(i => i.id === row.product)
console.log(product)
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
})
}
if(service.personalComposition) {
service.personalComposition.forEach(entry => {
totalHoursFromServices.total += entry.quantity
totalHoursFromServices.totalPurchasePrice += entry.quantity * entry.purchasePrice
totalHoursSellingPrice += entry.quantity * entry.price
if(totalHoursFromServices.byName[entry.name]) {
totalHoursFromServices.byName[entry.name] += entry.quantity
} else {
totalHoursFromServices.byName[entry.name] = entry.quantity
}
})
}
//totalProductsPurchasePrice += product.purchasePrice * row.quantity
}
})
let totalMargin = documentTotal.value.totalNet - totalProductsPurchasePrice - totalProductsFromServicesPurchasePrice - totalHoursFromServices.totalPurchasePrice
return {
totalProductsPurchasePrice,
totalProductsFromServicesPurchasePrice,
totalMargin,
totalHoursFromServices,
totalHoursSellingPrice,
}
})
const processDieselPosition = () => {
let agricultureData = {
dieselUsageTotal: 0,
@@ -2499,11 +2567,41 @@ const setRowData = async (row, service = {sellingPriceComposed: {}}, product = {
</tr>
</table>
<UDivider class="my-3" v-if="itemInfo.rows.length > 0">Gesamt</UDivider>
<UDivider class="my-3" v-if="itemInfo.rows.length > 0">Auswertung & Gesamt</UDivider>
<div class="w-full flex justify-end" v-if="itemInfo.type !== 'deliveryNotes'">
<table class="w-1/3" v-if="itemInfo.rows.length > 0">
<div class="w-full flex justify-between" v-if="itemInfo.type !== 'deliveryNotes'">
<table class="w-1/2">
<tr v-if="documentReport.totalProductsPurchasePrice !== 0">
<td>Einkaufspreis Artikel Gesamt:</td>
<td class="text-right">{{useCurrency(documentReport.totalProductsPurchasePrice)}}</td>
</tr>
<tr v-if="documentReport.totalProductsFromServicesPurchasePrice !== 0">
<td>Einkaufspreis Artikel aus Leistungen Gesamt:</td>
<td class="text-right">{{useCurrency(documentReport.totalProductsFromServicesPurchasePrice)}}</td>
</tr>
<tr v-if="documentReport.totalHoursFromServices.totalPurchasePrice !== 0">
<td>Einkaufspreis Personal aus Leistungen Gesamt:</td>
<td class="text-right">{{useCurrency(documentReport.totalHoursFromServices.totalPurchasePrice)}}</td>
</tr>
<tr>
<td>Gewinn Gesamt:</td>
<td class="text-right">{{useCurrency(documentReport.totalMargin)}}</td>
</tr>
<tr v-if="documentReport.totalHoursSellingPrice !== 0">
<td>Lohnkosten Verkauf:</td>
<td class="text-right">{{useCurrency(documentReport.totalHoursSellingPrice)}}</td>
</tr>
<tr v-for="key in Object.keys(documentReport.totalHoursFromServices.byName)">
<td>{{key}}</td>
<td class="text-right">{{documentReport.totalHoursFromServices.byName[key]}} h</td>
</tr>
<tr v-if="documentReport.totalHoursFromServices.total !== 0">
<td>Stunden Gesamt:</td>
<td class="text-right">{{documentReport.totalHoursFromServices.total}} h</td>
</tr>
</table>
<table class="w-1/3 h-full" v-if="itemInfo.rows.length > 0">
<tr>
<td class="font-bold">Netto:</td>
<td class="text-right">{{renderCurrency(documentTotal.totalNet)}}</td>
@@ -2527,6 +2625,45 @@ const setRowData = async (row, service = {sellingPriceComposed: {}}, product = {
</table>
</div>
<!-- <UDivider
class="my-3"
>Auswertung</UDivider>
<div class="w-full flex justify-end">
<table class="w-1/3">
<tr v-if="documentReport.totalProductsPurchasePrice !== 0">
<td>Einkaufspreis Artikel Gesamt:</td>
<td class="text-right">{{useCurrency(documentReport.totalProductsPurchasePrice)}}</td>
</tr>
<tr v-if="documentReport.totalProductsFromServicesPurchasePrice !== 0">
<td>Einkaufspreis Artikel aus Leistungen Gesamt:</td>
<td class="text-right">{{useCurrency(documentReport.totalProductsFromServicesPurchasePrice)}}</td>
</tr>
<tr v-if="documentReport.totalHoursFromServices.totalPurchasePrice !== 0">
<td>Einkaufspreis Personal aus Leistungen Gesamt:</td>
<td class="text-right">{{useCurrency(documentReport.totalHoursFromServices.totalPurchasePrice)}}</td>
</tr>
<tr>
<td>Gewinn Gesamt:</td>
<td class="text-right">{{useCurrency(documentReport.totalMargin)}}</td>
</tr>
<tr v-if="documentReport.totalHoursSellingPrice !== 0">
<td>Lohnkosten Verkauf:</td>
<td class="text-right">{{useCurrency(documentReport.totalHoursSellingPrice)}}</td>
</tr>
<tr v-for="key in Object.keys(documentReport.totalHoursFromServices.byName)">
<td>{{key}}</td>
<td class="text-right">{{documentReport.totalHoursFromServices.byName[key]}} h</td>
</tr>
<tr v-if="documentReport.totalHoursFromServices.total !== 0">
<td>Stunden Gesamt:</td>
<td class="text-right">{{documentReport.totalHoursFromServices.total}} h</td>
</tr>
</table>
</div>-->
<UDivider
class="my-3"
/>