From 2ba09241aa87b55634304daf58444356a4f3648e Mon Sep 17 00:00:00 2001 From: Thomas T Date: Mon, 23 Oct 2023 10:56:02 +0200 Subject: [PATCH] Refactor interfaces --- src/calculations/calculator.ts | 6 ++- src/calculations/interfaces/config.ts | 7 +++ src/calculations/interfaces/space.ts | 52 +------------------ .../interfaces/space_calculation.ts | 11 ++++ src/calculations/interfaces/space_constant.ts | 15 ++++++ src/calculations/interfaces/space_result.ts | 12 +++++ 6 files changed, 52 insertions(+), 51 deletions(-) create mode 100644 src/calculations/interfaces/config.ts create mode 100644 src/calculations/interfaces/space_calculation.ts create mode 100644 src/calculations/interfaces/space_constant.ts create mode 100644 src/calculations/interfaces/space_result.ts diff --git a/src/calculations/calculator.ts b/src/calculations/calculator.ts index 600389a..5013941 100644 --- a/src/calculations/calculator.ts +++ b/src/calculations/calculator.ts @@ -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' diff --git a/src/calculations/interfaces/config.ts b/src/calculations/interfaces/config.ts new file mode 100644 index 0000000..9c3ca85 --- /dev/null +++ b/src/calculations/interfaces/config.ts @@ -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 +} diff --git a/src/calculations/interfaces/space.ts b/src/calculations/interfaces/space.ts index 502b988..ed567ff 100644 --- a/src/calculations/interfaces/space.ts +++ b/src/calculations/interfaces/space.ts @@ -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 @@ -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 -} diff --git a/src/calculations/interfaces/space_calculation.ts b/src/calculations/interfaces/space_calculation.ts new file mode 100644 index 0000000..6d56f05 --- /dev/null +++ b/src/calculations/interfaces/space_calculation.ts @@ -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 +} diff --git a/src/calculations/interfaces/space_constant.ts b/src/calculations/interfaces/space_constant.ts new file mode 100644 index 0000000..b25437f --- /dev/null +++ b/src/calculations/interfaces/space_constant.ts @@ -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 +} diff --git a/src/calculations/interfaces/space_result.ts b/src/calculations/interfaces/space_result.ts new file mode 100644 index 0000000..9df1dcd --- /dev/null +++ b/src/calculations/interfaces/space_result.ts @@ -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 +}