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); },