From 2a3a2b258f5bfcd4aab4caef8352f230dac70dc4 Mon Sep 17 00:00:00 2001 From: "Torsten Schulz (local)" Date: Fri, 12 Sep 2025 15:24:50 +0200 Subject: [PATCH] =?UTF-8?q?=C3=84nderung:=20Verbesserung=20der=20Berechnun?= =?UTF-8?q?gslogik=20in=20HouseView.vue?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Änderungen: - Hinzugefügte Überprüfungen in den Methoden `getRenovationCost`, `getWorth` und `buyCost`, um sicherzustellen, dass die erforderlichen Daten vorhanden sind, bevor Berechnungen durchgeführt werden. - Diese Anpassungen erhöhen die Robustheit der Preisberechnungen und verhindern Fehler bei fehlenden Informationen. --- frontend/src/views/falukant/HouseView.vue | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/frontend/src/views/falukant/HouseView.vue b/frontend/src/views/falukant/HouseView.vue index ba8548c..aebd1a8 100644 --- a/frontend/src/views/falukant/HouseView.vue +++ b/frontend/src/views/falukant/HouseView.vue @@ -125,6 +125,7 @@ export default { return new Intl.NumberFormat('de-DE', { minimumFractionDigits: 2, maximumFractionDigits: 2 }).format(value); }, getRenovationCost(key, value) { + if (!this.userHouse || !this.userHouse.houseType) return this.formatPrice(0); const base = this.userHouse.houseType.cost || 0; const weights = { roofCondition: 0.25, wallCondition: 0.25, floorCondition: 0.25, windowCondition: 0.25 }; const weight = weights[key] || 0; @@ -141,12 +142,13 @@ export default { }, getWorth() { const vals = Object.values(this.status); - if (!vals.length) return this.formatPrice(0); + if (!vals.length || !this.houseType) return this.formatPrice(0); const avg = vals.reduce((s, v) => s + v, 0) / vals.length; const price = this.houseType.cost || 0; return this.formatPrice(price * avg / 100 * 0.8); }, buyCost(house) { + if (!house || !house.houseType) return this.formatPrice(0); const avg = (house.roofCondition + house.wallCondition + house.floorCondition + house.windowCondition) / 4; return this.formatPrice(house.houseType.cost * avg / 100); },