Skip to content

Commit

Permalink
Refactor interfaces
Browse files Browse the repository at this point in the history
  • Loading branch information
huulbaek committed Oct 23, 2023
1 parent 30c3e5c commit 2ba0924
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 51 deletions.
6 changes: 5 additions & 1 deletion src/calculations/calculator.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import { readFileSync } from 'fs'
import { join } from 'path'
import { IConfig, ISpace, ISpaceCalculation, ISpaceResult, ISpaceConstant } from './interfaces/space'
import { ISpace } from './interfaces/space'
import { IConfig } from './interfaces/config'
import { ISpaceCalculation } from './interfaces/space_calculation'
import { ISpaceResult } from './interfaces/space_result'
import { ISpaceConstant } from './interfaces/space_constant'
import { IVariable } from './interfaces/variable'
import { IConstant } from './interfaces/constant'
import { ICalculationResult } from './interfaces/calculationresult'
Expand Down
7 changes: 7 additions & 0 deletions src/calculations/interfaces/config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { IConstant } from './constant'
import { ISpace } from './space'

export interface IConfig {
constants: IConstant // The constants used in the calculations
spaces: ISpace[] // The array of spaces to be calculated
}
52 changes: 2 additions & 50 deletions src/calculations/interfaces/space.ts
Original file line number Diff line number Diff line change
@@ -1,25 +1,5 @@
import { IConstant } from './constant'

export interface ISpaceConstant {
seatPersonRoom?: string // Optional, defines the type of space: seat, person or room
areaPerRole: number // The area required per role
personsPerType: number // The number of persons per type of space
minimumPersons?: number // The minimum number of persons for this space
minimumSquareMeters?: number // The minimum square meters required for this space
shouldCalculateCompensation: boolean // Whether to calculate compensation for this space
countsTowardsWorkspaceArea?: boolean // Whether this space counts towards the total workspace area
seatAreaPerSpot?: number // The seat area per spot
requiresAdditionalStorage?: boolean // Whether this space requires additional storage
adhereToGovernmentMinimum: boolean // Whether to adhere to the government minimum for this space
surchargeInternalCorridorShare?: number // The surcharge for the internal corridor share
areaPerPersonExcludingCorridor?: number // The area per person excluding the corridor
unitsPerPerson?: number // The units per person for this space
}

export interface IConfig {
constants: IConstant // The constants used in the calculations
spaces: ISpace[] // The array of spaces to be calculated
}
import { ISpaceConstant } from './space_constant'
import { ISpaceResult } from './space_result'

export interface ISpace {
name: string, // The name of the space
Expand All @@ -29,31 +9,3 @@ export interface ISpace {
shouldCalculateCorridor?: boolean // Whether to calculate the corridor area needed for this space
shouldCalculateInnerwalls?: boolean // Whether to calculate the inner walls area needed for this space
}

export interface ISpaceCalculation {
calculateEmployeesPerWorkplaceTypeUnadjusted: () => number // Function to calculate the unadjusted number of employees per workplace type
calculateAreaExclCompensation: () => number // Function to calculate the area excluding compensation
calculateAdjustedAreaInclCompensation: (totalWorkplceArea: number, totalCompensationArea: number, totalUnadjustedArea: number) => number // Function to calculate the adjusted area including compensation
calculateNotAdjustedAddonArea: (totalWorkplaceArea: number, totalCompensationArea: number) => number // Function to calculate the not adjusted add-on area
calculateAdjustedAddonArea: (totalWorkplaceArea: number, totalCompensationArea: number, totalUnadjustedArea: number) => number // Function to calculate the adjusted add-on area
calculateNotAdjustedAddonPart: (totalWorkplaceArea: number, totalCompensationArea: number) => number // Function to calculate the not adjusted add-on part
calculateEmployeesPerWorkplaceTypeAdjusted: (totalEmployeesPerWorkplaceTypeUnadjusted: number, allEmployeesPerWorkplaceTypeUnadjusted: number[]) => number // Function to calculate the adjusted number of employees per workplace type
calculateAdjustedAreaInclCompensationWithAdjustmentAndCompensation: () => number // Function to calculate the adjusted area including compensation with adjustment and compensation
dimensionedAttendance: () => number // Function to calculate the dimensioned attendance
}

/**
* @todo Remove stuff from above and below
*/
export interface ISpaceResult {
areaExclCompensation?: number // The area excluding compensation
notAdjustedAddonArea?: number // The not adjusted add-on area
notAdjustedAddonPart?: number // The not adjusted add-on part
adjustedAddonArea?: number // The adjusted add-on area
adjustedAreaInclCompensation?: number // The adjusted area including compensation
adjustedAreaInclCompensationWithAdjustmentAndCompensation?: number // The adjusted area including compensation with adjustment and compensation
employeesPerWorkplaceTypeUnadjusted?: number // The unadjusted number of employees per workplace type
employeesPerWorkplaceTypeAdjusted?: number // The adjusted number of employees per workplace type
netArea?: number // The net area of the space
utilityFloorSpace?: number // The utility floor space of the space
}
11 changes: 11 additions & 0 deletions src/calculations/interfaces/space_calculation.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
export interface ISpaceCalculation {
calculateEmployeesPerWorkplaceTypeUnadjusted: () => number // Function to calculate the unadjusted number of employees per workplace type
calculateAreaExclCompensation: () => number // Function to calculate the area excluding compensation
calculateAdjustedAreaInclCompensation: (totalWorkplceArea: number, totalCompensationArea: number, totalUnadjustedArea: number) => number // Function to calculate the adjusted area including compensation
calculateNotAdjustedAddonArea: (totalWorkplaceArea: number, totalCompensationArea: number) => number // Function to calculate the not adjusted add-on area
calculateAdjustedAddonArea: (totalWorkplaceArea: number, totalCompensationArea: number, totalUnadjustedArea: number) => number // Function to calculate the adjusted add-on area
calculateNotAdjustedAddonPart: (totalWorkplaceArea: number, totalCompensationArea: number) => number // Function to calculate the not adjusted add-on part
calculateEmployeesPerWorkplaceTypeAdjusted: (totalEmployeesPerWorkplaceTypeUnadjusted: number, allEmployeesPerWorkplaceTypeUnadjusted: number[]) => number // Function to calculate the adjusted number of employees per workplace type
calculateAdjustedAreaInclCompensationWithAdjustmentAndCompensation: () => number // Function to calculate the adjusted area including compensation with adjustment and compensation
dimensionedAttendance: () => number // Function to calculate the dimensioned attendance
}
15 changes: 15 additions & 0 deletions src/calculations/interfaces/space_constant.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
export interface ISpaceConstant {
seatPersonRoom?: string // Optional, defines the type of space: seat, person or room
areaPerRole: number // The area required per role
personsPerType: number // The number of persons per type of space
minimumPersons?: number // The minimum number of persons for this space
minimumSquareMeters?: number // The minimum square meters required for this space
shouldCalculateCompensation: boolean // Whether to calculate compensation for this space
countsTowardsWorkspaceArea?: boolean // Whether this space counts towards the total workspace area
seatAreaPerSpot?: number // The seat area per spot
requiresAdditionalStorage?: boolean // Whether this space requires additional storage
adhereToGovernmentMinimum: boolean // Whether to adhere to the government minimum for this space
surchargeInternalCorridorShare?: number // The surcharge for the internal corridor share
areaPerPersonExcludingCorridor?: number // The area per person excluding the corridor
unitsPerPerson?: number // The units per person for this space
}
12 changes: 12 additions & 0 deletions src/calculations/interfaces/space_result.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
export interface ISpaceResult {
areaExclCompensation?: number // The area excluding compensation
notAdjustedAddonArea?: number // The not adjusted add-on area
notAdjustedAddonPart?: number // The not adjusted add-on part
adjustedAddonArea?: number // The adjusted add-on area
adjustedAreaInclCompensation?: number // The adjusted area including compensation
adjustedAreaInclCompensationWithAdjustmentAndCompensation?: number // The adjusted area including compensation with adjustment and compensation
employeesPerWorkplaceTypeUnadjusted?: number // The unadjusted number of employees per workplace type
employeesPerWorkplaceTypeAdjusted?: number // The adjusted number of employees per workplace type
netArea?: number // The net area of the space
utilityFloorSpace?: number // The utility floor space of the space
}

0 comments on commit 2ba0924

Please sign in to comment.