Skip to content

Commit

Permalink
Add sum for rooms
Browse files Browse the repository at this point in the history
  • Loading branch information
huulbaek committed Nov 21, 2023
1 parent 2d56e93 commit 80c92d5
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/calculations/calculator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,7 @@ export default class Calculator {
let childSum_adjustedAreaInclCompensation = 0
let childSum_notAdjustedAddonArea = 0
let childSum_adjustedAreaInclCompensationWithAdjustmentAndCompensation = 0
let childSum_numberOfRooms = 0

if (space.spaces) {
for (const child of space.spaces) {
Expand All @@ -233,6 +234,7 @@ export default class Calculator {
childSum_adjustedAreaInclCompensation += r.adjustedAreaInclCompensation || 0
childSum_notAdjustedAddonArea += r.notAdjustedAddonArea || 0
childSum_adjustedAreaInclCompensationWithAdjustmentAndCompensation += r.adjustedAreaInclCompensationWithAdjustmentAndCompensation || 0
childSum_numberOfRooms += r.numberOfRooms || 0
}
}

Expand All @@ -241,13 +243,15 @@ export default class Calculator {
space.result.adjustedAreaInclCompensation = space.result.adjustedAreaInclCompensation || childSum_adjustedAreaInclCompensation
space.result.notAdjustedAddonArea = space.result.notAdjustedAddonArea || childSum_notAdjustedAddonArea
space.result.adjustedAreaInclCompensationWithAdjustmentAndCompensation = space.result.adjustedAreaInclCompensationWithAdjustmentAndCompensation || childSum_adjustedAreaInclCompensationWithAdjustmentAndCompensation
space.result.numberOfRooms = space.result.numberOfRooms || childSum_numberOfRooms

// Return the total sum
return {
areaExclCompensation: space.result.areaExclCompensation,
adjustedAreaInclCompensation: space.result.adjustedAreaInclCompensation,
notAdjustedAddonArea: space.result.notAdjustedAddonArea,
adjustedAreaInclCompensationWithAdjustmentAndCompensation: space.result.adjustedAreaInclCompensationWithAdjustmentAndCompensation
adjustedAreaInclCompensationWithAdjustmentAndCompensation: space.result.adjustedAreaInclCompensationWithAdjustmentAndCompensation,
numberOfRooms: space.result.numberOfRooms,
}
}

Expand Down

0 comments on commit 80c92d5

Please sign in to comment.