@ssg-coop/luic-calculator-core 1.3.0 → 1.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +12 -2
- package/dist/api/domain.d.ts +5 -0
- package/dist/api/domain.js +5 -0
- package/dist/config/i18n/en.d.ts +19 -0
- package/dist/config/i18n/en.js +19 -0
- package/dist/config/i18n/fr.d.ts +19 -0
- package/dist/config/i18n/fr.js +19 -0
- package/dist/config/types.d.ts +2 -0
- package/dist/config/types.js +5 -0
- package/dist/generator/WorkbookGenerator.d.ts +4 -0
- package/dist/generator/WorkbookGenerator.js +69 -9
- package/dist/generator/builders/ChartDataSheetBuilder.d.ts +10 -0
- package/dist/generator/builders/ChartDataSheetBuilder.js +160 -7
- package/dist/generator/builders/ChartsSheetBuilder.js +103 -2
- package/dist/generator/builders/InputDataSheetBuilder.js +4 -3
- package/dist/generator/builders/ScenarioDetailsBuilder.d.ts +2 -0
- package/dist/generator/builders/ScenarioDetailsBuilder.js +4 -4
- package/dist/generator/builders/ScenarioSheetBuilder.d.ts +2 -0
- package/dist/generator/builders/ScenarioSheetBuilder.js +205 -25
- package/dist/generator/builders/SummarySheetBuilder.d.ts +3 -2
- package/dist/generator/builders/SummarySheetBuilder.js +109 -9
- package/dist/types/config.types.d.ts +9 -0
- package/dist/types/workbook.types.d.ts +52 -1
- package/package.json +1 -1
- package/dist/package.json +0 -31
- package/dist/src/config/appConfig.d.ts +0 -11
- package/dist/src/config/appConfig.js +0 -38
- package/dist/src/config/core/calculatorUtils.d.ts +0 -17
- package/dist/src/config/core/calculatorUtils.js +0 -212
- package/dist/src/config/core/genericUtils.d.ts +0 -10
- package/dist/src/config/core/genericUtils.js +0 -79
- package/dist/src/config/domain/buildings.d.ts +0 -14
- package/dist/src/config/domain/buildings.js +0 -282
- package/dist/src/config/domain/emissionFactors.d.ts +0 -2
- package/dist/src/config/domain/emissionFactors.js +0 -42
- package/dist/src/config/domain/energySources.d.ts +0 -18
- package/dist/src/config/domain/energySources.js +0 -370
- package/dist/src/config/domain/infrastructure.d.ts +0 -8
- package/dist/src/config/domain/infrastructure.js +0 -56
- package/dist/src/config/domain/neighbourhoodTypes.d.ts +0 -10
- package/dist/src/config/domain/neighbourhoodTypes.js +0 -366
- package/dist/src/config/domain/regions.d.ts +0 -8
- package/dist/src/config/domain/regions.js +0 -423
- package/dist/src/config/domain/services.d.ts +0 -8
- package/dist/src/config/domain/services.js +0 -48
- package/dist/src/config/domain/transportation.d.ts +0 -12
- package/dist/src/config/domain/transportation.js +0 -81
- package/dist/src/config/i18n/en.d.ts +0 -445
- package/dist/src/config/i18n/en.js +0 -488
- package/dist/src/config/i18n/fr.d.ts +0 -445
- package/dist/src/config/i18n/fr.js +0 -491
- package/dist/src/config/types.d.ts +0 -80
- package/dist/src/config/types.js +0 -5
- package/dist/src/generator/FormulaBuilder.d.ts +0 -58
- package/dist/src/generator/FormulaBuilder.js +0 -101
- package/dist/src/generator/WorkbookGenerator.d.ts +0 -7
- package/dist/src/generator/WorkbookGenerator.js +0 -77
- package/dist/src/generator/builders/AssumptionsBuilder.d.ts +0 -20
- package/dist/src/generator/builders/AssumptionsBuilder.js +0 -311
- package/dist/src/generator/builders/CalculationSheetBuilder.d.ts +0 -20
- package/dist/src/generator/builders/CalculationSheetBuilder.js +0 -149
- package/dist/src/generator/builders/EmissionFactorsSheetBuilder.d.ts +0 -7
- package/dist/src/generator/builders/EmissionFactorsSheetBuilder.js +0 -86
- package/dist/src/generator/builders/InputDataSheetBuilder.d.ts +0 -13
- package/dist/src/generator/builders/InputDataSheetBuilder.js +0 -114
- package/dist/src/generator/builders/ScenarioSheetBuilder.d.ts +0 -19
- package/dist/src/generator/builders/ScenarioSheetBuilder.js +0 -1067
- package/dist/src/generator/builders/SummarySheetBuilder.d.ts +0 -8
- package/dist/src/generator/builders/SummarySheetBuilder.js +0 -304
- package/dist/src/index.d.ts +0 -57
- package/dist/src/index.js +0 -103
- package/dist/src/theme/defaultTheme.d.ts +0 -2
- package/dist/src/theme/defaultTheme.js +0 -254
- package/dist/src/theme/index.d.ts +0 -2
- package/dist/src/theme/index.js +0 -2
- package/dist/src/theme/sunsetTheme.d.ts +0 -2
- package/dist/src/theme/sunsetTheme.js +0 -310
- package/dist/src/types/config.types.d.ts +0 -69
- package/dist/src/types/config.types.js +0 -1
- package/dist/src/types/scenario.types.d.ts +0 -63
- package/dist/src/types/scenario.types.js +0 -1
- package/dist/src/types/workbook.types.d.ts +0 -181
- package/dist/src/types/workbook.types.js +0 -1
- package/dist/src/utils/ReactivityUtils.d.ts +0 -7
- package/dist/src/utils/ReactivityUtils.js +0 -26
- package/dist/src/utils/cellAddressing.d.ts +0 -16
- package/dist/src/utils/cellAddressing.js +0 -35
- package/dist/src/utils/formatting.d.ts +0 -9
- package/dist/src/utils/formatting.js +0 -32
- package/dist/src/writers/JsonExporter.d.ts +0 -11
- package/dist/src/writers/JsonExporter.js +0 -14
- package/dist/types/blinktagtypes.d.ts +0 -167
- package/dist/types/blinktagtypes.js +0 -21
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Helper class to construct Excel formula strings, keeping
|
|
3
|
-
* the code readable and ensuring everything starts with '='.
|
|
4
|
-
*/
|
|
5
|
-
export class FormulaBuilder {
|
|
6
|
-
parts = [];
|
|
7
|
-
constructor() { }
|
|
8
|
-
/**
|
|
9
|
-
* Start a new formula. Overrides any existing.
|
|
10
|
-
*/
|
|
11
|
-
start() {
|
|
12
|
-
this.parts = ['='];
|
|
13
|
-
return this;
|
|
14
|
-
}
|
|
15
|
-
/**
|
|
16
|
-
* Reference a cell or named range.
|
|
17
|
-
*/
|
|
18
|
-
ref(nameOrAddress) {
|
|
19
|
-
this.parts.push(nameOrAddress);
|
|
20
|
-
return this;
|
|
21
|
-
}
|
|
22
|
-
/**
|
|
23
|
-
* Add a literal number.
|
|
24
|
-
*/
|
|
25
|
-
number(val) {
|
|
26
|
-
this.parts.push(val.toString());
|
|
27
|
-
return this;
|
|
28
|
-
}
|
|
29
|
-
/**
|
|
30
|
-
* Add a math operator (+, -, *, /)
|
|
31
|
-
*/
|
|
32
|
-
op(operator) {
|
|
33
|
-
this.parts.push(operator);
|
|
34
|
-
return this;
|
|
35
|
-
}
|
|
36
|
-
/**
|
|
37
|
-
* Multiply
|
|
38
|
-
*/
|
|
39
|
-
multiplyBy(val) {
|
|
40
|
-
this.op('*');
|
|
41
|
-
if (typeof val === 'number') {
|
|
42
|
-
return this.number(val);
|
|
43
|
-
}
|
|
44
|
-
return this.ref(val);
|
|
45
|
-
}
|
|
46
|
-
/**
|
|
47
|
-
* Divide
|
|
48
|
-
*/
|
|
49
|
-
divideBy(val) {
|
|
50
|
-
this.op('/');
|
|
51
|
-
if (typeof val === 'number') {
|
|
52
|
-
return this.number(val);
|
|
53
|
-
}
|
|
54
|
-
return this.ref(val);
|
|
55
|
-
}
|
|
56
|
-
/**
|
|
57
|
-
* Open parenthesis
|
|
58
|
-
*/
|
|
59
|
-
openParen() {
|
|
60
|
-
this.parts.push('(');
|
|
61
|
-
return this;
|
|
62
|
-
}
|
|
63
|
-
/**
|
|
64
|
-
* Close parenthesis
|
|
65
|
-
*/
|
|
66
|
-
closeParen() {
|
|
67
|
-
this.parts.push(')');
|
|
68
|
-
return this;
|
|
69
|
-
}
|
|
70
|
-
/**
|
|
71
|
-
* Wraps the current expression in an Excel function call, e.g., SUM, INDEX, MATCH
|
|
72
|
-
*/
|
|
73
|
-
func(functionName, ...args) {
|
|
74
|
-
this.parts.push(`${functionName}(${args.join(',')})`);
|
|
75
|
-
return this;
|
|
76
|
-
}
|
|
77
|
-
/**
|
|
78
|
-
* Returns the completed formula string.
|
|
79
|
-
*/
|
|
80
|
-
build() {
|
|
81
|
-
if (this.parts.length === 0 || this.parts[0] !== '=') {
|
|
82
|
-
this.start(); // Ensure it starts with '='
|
|
83
|
-
}
|
|
84
|
-
// Remove spaces around parts except within function arguments if they had them
|
|
85
|
-
return this.parts.join('');
|
|
86
|
-
}
|
|
87
|
-
/**
|
|
88
|
-
* Static quick-build for simple multiplication
|
|
89
|
-
* e.g. FormulaBuilder.multiply('D13', 'D14') => '=D13*D14'
|
|
90
|
-
*/
|
|
91
|
-
static multiply(...refs) {
|
|
92
|
-
return '=' + refs.join('*');
|
|
93
|
-
}
|
|
94
|
-
/**
|
|
95
|
-
* Static quick-build for addition
|
|
96
|
-
* e.g. FormulaBuilder.add('D13', 'D14') => '=D13+D14'
|
|
97
|
-
*/
|
|
98
|
-
static add(...refs) {
|
|
99
|
-
return '=' + refs.join('+');
|
|
100
|
-
}
|
|
101
|
-
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { WorkbookSpec } from '../types/workbook.types';
|
|
2
|
-
import { Scenario } from '../types/scenario.types';
|
|
3
|
-
import { GeneratorConfig } from '../types/config.types';
|
|
4
|
-
/**
|
|
5
|
-
* Main generator function - pure, no side effects
|
|
6
|
-
*/
|
|
7
|
-
export declare function generateWorkbook(rawScenarios: Scenario[], config?: GeneratorConfig): WorkbookSpec;
|
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
import { AssumptionsBuilder } from './builders/AssumptionsBuilder';
|
|
2
|
-
import { ScenarioSheetBuilder } from './builders/ScenarioSheetBuilder';
|
|
3
|
-
import { SummarySheetBuilder } from './builders/SummarySheetBuilder';
|
|
4
|
-
import { ReactivityUtils } from '../utils/ReactivityUtils';
|
|
5
|
-
import { InputDataSheetBuilder } from './builders/InputDataSheetBuilder';
|
|
6
|
-
import { EmissionFactorsSheetBuilder } from './builders/EmissionFactorsSheetBuilder';
|
|
7
|
-
import { CalculationSheetBuilder } from './builders/CalculationSheetBuilder';
|
|
8
|
-
import { defaultTheme } from '../theme';
|
|
9
|
-
import packageJson from '../../package.json' assert { type: 'json' };
|
|
10
|
-
/**
|
|
11
|
-
* Main generator function - pure, no side effects
|
|
12
|
-
*/
|
|
13
|
-
export function generateWorkbook(rawScenarios, config = {}) {
|
|
14
|
-
// 0. Clean data (Unwrap Vue reactivity proxies before processing)
|
|
15
|
-
const scenarios = ReactivityUtils.unwrap(rawScenarios);
|
|
16
|
-
// Ensure config is populated with defaults
|
|
17
|
-
config.theme = config.theme || defaultTheme;
|
|
18
|
-
config.locale = config.locale || 'en';
|
|
19
|
-
const assumptionsBuilder = new AssumptionsBuilder(config);
|
|
20
|
-
const inputBuilder = new InputDataSheetBuilder(config);
|
|
21
|
-
const scenarioBuilder = new ScenarioSheetBuilder(config);
|
|
22
|
-
const summaryBuilder = new SummarySheetBuilder(config);
|
|
23
|
-
const emissionFactorsBuilder = new EmissionFactorsSheetBuilder(config);
|
|
24
|
-
const calcBuilder = new CalculationSheetBuilder(config);
|
|
25
|
-
// 1. Generate Assumptions Tables
|
|
26
|
-
const provId = scenarios.length > 0 ? scenarios[0].provId : '';
|
|
27
|
-
const assumptionsResult = assumptionsBuilder.build(provId);
|
|
28
|
-
// 2. Generate Scenarios and Input Data sheets
|
|
29
|
-
const scenarioSheets = [];
|
|
30
|
-
const inputSheets = [];
|
|
31
|
-
for (const scenario of scenarios) {
|
|
32
|
-
// Build Input sheet first to get external references
|
|
33
|
-
const inputResult = inputBuilder.build(scenario, assumptionsResult.tables);
|
|
34
|
-
inputSheets.push(inputResult.sheet);
|
|
35
|
-
// Build Scenario sheet, injecting input references
|
|
36
|
-
const { sheet: scenarioSheet, calcContexts, studentCalc } = scenarioBuilder.build(scenario, assumptionsResult.tables, inputResult.refs);
|
|
37
|
-
scenarioSheets.push(scenarioSheet);
|
|
38
|
-
// Build Calculation Sheet
|
|
39
|
-
const { sheet: calcSheet, totalStudentsRef } = calcBuilder.build(scenario.title, calcContexts, assumptionsResult.tables, scenarioSheet.name, studentCalc);
|
|
40
|
-
// Post-process the scenario sheet to inject the dynamic total students reference
|
|
41
|
-
if (totalStudentsRef) {
|
|
42
|
-
for (const row of scenarioSheet.rows) {
|
|
43
|
-
if (row.cells) {
|
|
44
|
-
for (const cell of row.cells) {
|
|
45
|
-
if (cell.formula && cell.formula.includes('__TOTAL_STUDENTS_REF__')) {
|
|
46
|
-
cell.formula = cell.formula.replace('__TOTAL_STUDENTS_REF__', totalStudentsRef);
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
scenarioSheets.push(calcSheet);
|
|
53
|
-
}
|
|
54
|
-
// 3. Generate Summary
|
|
55
|
-
const scenarioOnlySheets = scenarioSheets.filter(s => s.sheetType === 'scenario');
|
|
56
|
-
const summarySheet = summaryBuilder.build(scenarios, scenarioOnlySheets);
|
|
57
|
-
// 4. Generate Emission Factors
|
|
58
|
-
const emissionFactorsSheet = emissionFactorsBuilder.build();
|
|
59
|
-
// Gather
|
|
60
|
-
const sheets = [
|
|
61
|
-
summarySheet,
|
|
62
|
-
...scenarioSheets,
|
|
63
|
-
...inputSheets,
|
|
64
|
-
...assumptionsResult.sheets,
|
|
65
|
-
emissionFactorsSheet
|
|
66
|
-
];
|
|
67
|
-
return {
|
|
68
|
-
metadata: {
|
|
69
|
-
generatedAt: new Date().toISOString(),
|
|
70
|
-
generatorVersion: packageJson.version,
|
|
71
|
-
locale: config.locale
|
|
72
|
-
},
|
|
73
|
-
namedRanges: [],
|
|
74
|
-
sheets,
|
|
75
|
-
typography: config.theme?.typography
|
|
76
|
-
};
|
|
77
|
-
}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { SheetSpec } from '../../types/workbook.types';
|
|
2
|
-
import { GeneratorConfig } from '../../types/config.types';
|
|
3
|
-
export interface AssumptionTables {
|
|
4
|
-
buildings: string;
|
|
5
|
-
services: string;
|
|
6
|
-
infrastructure: string;
|
|
7
|
-
transportation: string;
|
|
8
|
-
energySources: string;
|
|
9
|
-
neighbourhoods: string;
|
|
10
|
-
gwp: string;
|
|
11
|
-
}
|
|
12
|
-
export interface AssumptionsResult {
|
|
13
|
-
sheets: SheetSpec[];
|
|
14
|
-
tables: AssumptionTables;
|
|
15
|
-
}
|
|
16
|
-
export declare class AssumptionsBuilder {
|
|
17
|
-
private config;
|
|
18
|
-
constructor(config: GeneratorConfig);
|
|
19
|
-
build(provId?: string): AssumptionsResult;
|
|
20
|
-
}
|
|
@@ -1,311 +0,0 @@
|
|
|
1
|
-
import { FormattingUtils } from '../../utils/formatting';
|
|
2
|
-
import buildingsConfigFn from '../../config/domain/buildings';
|
|
3
|
-
import servicesConfigFn from '../../config/domain/services';
|
|
4
|
-
import infrastructureConfigFn from '../../config/domain/infrastructure';
|
|
5
|
-
import transportationConfigFn from '../../config/domain/transportation';
|
|
6
|
-
import energySourcesConfigFn from '../../config/domain/energySources';
|
|
7
|
-
import neighbourhoodTypesConfigFn from '../../config/domain/neighbourhoodTypes';
|
|
8
|
-
export class AssumptionsBuilder {
|
|
9
|
-
config;
|
|
10
|
-
constructor(config) {
|
|
11
|
-
this.config = config;
|
|
12
|
-
}
|
|
13
|
-
build(provId = '') {
|
|
14
|
-
const dummyT = (key) => 'i18n:' + key;
|
|
15
|
-
const buildingsConfig = buildingsConfigFn(dummyT);
|
|
16
|
-
const servicesConfig = servicesConfigFn(dummyT);
|
|
17
|
-
const infrastructureConfig = infrastructureConfigFn(dummyT);
|
|
18
|
-
const transportationConfig = transportationConfigFn(dummyT);
|
|
19
|
-
const energySourcesConfig = energySourcesConfigFn(dummyT, provId);
|
|
20
|
-
const neighbourhoodConfig = neighbourhoodTypesConfigFn(dummyT);
|
|
21
|
-
const theme = this.config.theme;
|
|
22
|
-
const c = theme.assumptions.columns;
|
|
23
|
-
const scenTheme = theme.scenario;
|
|
24
|
-
const evalYear = 2025; // Default evaluation year for EFs
|
|
25
|
-
const sheets = [];
|
|
26
|
-
let r = 1;
|
|
27
|
-
const fillTitle = (title, color, numCols) => {
|
|
28
|
-
const cells = [];
|
|
29
|
-
for (let i = 0; i < numCols; i++) {
|
|
30
|
-
cells.push({ column: String.fromCharCode(65 + i), value: i === 0 ? title : '', format: FormattingUtils.header(color) });
|
|
31
|
-
}
|
|
32
|
-
return { rowIndex: r++, cells };
|
|
33
|
-
};
|
|
34
|
-
const getColWidths = (numCols, aWidth, bWidth) => {
|
|
35
|
-
const widths = [{ range: 'A:A', width: aWidth }];
|
|
36
|
-
for (let i = 1; i < numCols; i++) {
|
|
37
|
-
const col = String.fromCharCode(65 + i);
|
|
38
|
-
widths.push({ range: `${col}:${col}`, width: bWidth });
|
|
39
|
-
}
|
|
40
|
-
return widths;
|
|
41
|
-
};
|
|
42
|
-
// --- Buildings ---
|
|
43
|
-
const bRows = [];
|
|
44
|
-
r = 1;
|
|
45
|
-
const homeTypes = Object.keys(buildingsConfig.homeTypes);
|
|
46
|
-
const bColsCount = 1 + homeTypes.length + 2;
|
|
47
|
-
bRows.push(fillTitle('i18n:scenario.assumptions.buildings', scenTheme.colors.buildingsHeader, bColsCount));
|
|
48
|
-
// Add a row for home type sizes
|
|
49
|
-
const sizeHeader = [
|
|
50
|
-
{ column: 'A', value: 'i18n:scenario.assumptions.baseSize', format: FormattingUtils.boldText() }
|
|
51
|
-
];
|
|
52
|
-
homeTypes.forEach((ht, i) => {
|
|
53
|
-
const sizeValue = buildingsConfig.homeTypes[ht].size_m2;
|
|
54
|
-
sizeHeader.push({ column: String.fromCharCode(66 + i), value: sizeValue, format: FormattingUtils.boldText() });
|
|
55
|
-
});
|
|
56
|
-
bRows.push({ rowIndex: r++, cells: sizeHeader });
|
|
57
|
-
const bHeader = [
|
|
58
|
-
{ column: 'A', value: 'i18n:scenario.assumptions.codeName', format: FormattingUtils.boldText() }
|
|
59
|
-
];
|
|
60
|
-
homeTypes.forEach((ht, i) => {
|
|
61
|
-
bHeader.push({ column: String.fromCharCode(66 + i), value: `i18n:scenario.assumptions.eui ${buildingsConfig.homeTypes[ht].name} (MJ/m2/i18n:general.yearAbbr)`, format: FormattingUtils.boldText() });
|
|
62
|
-
});
|
|
63
|
-
bHeader.push({ column: String.fromCharCode(66 + homeTypes.length), value: 'i18n:scenario.assumptions.reference', format: FormattingUtils.boldText() });
|
|
64
|
-
bHeader.push({ column: String.fromCharCode(66 + homeTypes.length + 1), value: 'i18n:scenario.assumptions.description', format: FormattingUtils.boldText() });
|
|
65
|
-
bRows.push({ rowIndex: r++, cells: bHeader });
|
|
66
|
-
const bStartRow = r;
|
|
67
|
-
buildingsConfig.getBuildingEnergyCodesAsArray().forEach((code) => {
|
|
68
|
-
const cells = [
|
|
69
|
-
{ column: 'A', value: `i18n:appConfig.buildings.buildingEnergyCodes.${code.id}`, format: scenTheme.data.grayFill }
|
|
70
|
-
];
|
|
71
|
-
homeTypes.forEach((ht, i) => {
|
|
72
|
-
cells.push({ column: String.fromCharCode(66 + i), value: code.eui[ht] || 0 });
|
|
73
|
-
});
|
|
74
|
-
const refsText = code.references ? code.references.map((cr) => cr[0]).join('\n') : '';
|
|
75
|
-
cells.push({ column: String.fromCharCode(66 + homeTypes.length), value: refsText, format: { wrapText: true } });
|
|
76
|
-
cells.push({ column: String.fromCharCode(66 + homeTypes.length + 1), value: code.description || '', format: { wrapText: true } });
|
|
77
|
-
bRows.push({ rowIndex: r++, cells });
|
|
78
|
-
});
|
|
79
|
-
const bEndRow = r - 1;
|
|
80
|
-
const bLastCol = String.fromCharCode(66 + homeTypes.length + 1);
|
|
81
|
-
const buildingsTable = `i18n:worksheets.assumptions_buildings!$A$${bStartRow}:$${bLastCol}$${bEndRow}`;
|
|
82
|
-
const bColumnWidths = getColWidths(bColsCount, c.buildings.A.width, c.buildings.BPlus.width);
|
|
83
|
-
bColumnWidths[bColumnWidths.length - 2].width = 40;
|
|
84
|
-
bColumnWidths[bColumnWidths.length - 1].width = 40;
|
|
85
|
-
sheets.push({
|
|
86
|
-
name: 'i18n:worksheets.assumptions_buildings',
|
|
87
|
-
sheetType: 'assumptions',
|
|
88
|
-
visibility: 'Visible',
|
|
89
|
-
tabColor: theme.assumptions.tabColor || null,
|
|
90
|
-
showGridlines: false,
|
|
91
|
-
customProperties: { 'ssg-type': 'assumptions', 'ssg-category': 'buildings' },
|
|
92
|
-
columnWidths: bColumnWidths,
|
|
93
|
-
rows: bRows,
|
|
94
|
-
mergedRanges: []
|
|
95
|
-
});
|
|
96
|
-
// --- Services ---
|
|
97
|
-
const sRows = [];
|
|
98
|
-
r = 1;
|
|
99
|
-
sRows.push(fillTitle('i18n:scenario.assumptions.services', scenTheme.colors.servicesHeader, 3));
|
|
100
|
-
sRows.push({
|
|
101
|
-
rowIndex: r++, cells: [
|
|
102
|
-
{ column: 'A', value: 'i18n:scenario.assumptions.name', format: FormattingUtils.boldText() },
|
|
103
|
-
{ column: 'B', value: 'i18n:scenario.assumptions.capCost', format: FormattingUtils.boldText() },
|
|
104
|
-
{ column: 'C', value: 'i18n:scenario.assumptions.maintCost', format: FormattingUtils.boldText() }
|
|
105
|
-
]
|
|
106
|
-
});
|
|
107
|
-
const sStartRow = r;
|
|
108
|
-
servicesConfig.getServicesAsArray().forEach((srv) => {
|
|
109
|
-
sRows.push({
|
|
110
|
-
rowIndex: r++, cells: [
|
|
111
|
-
{ column: 'A', value: `i18n:appConfig.services.serviceTypes.${srv.id}`, format: scenTheme.data.grayFill },
|
|
112
|
-
{ column: 'B', value: srv.capCostIntensity, format: FormattingUtils.number(0) },
|
|
113
|
-
{ column: 'C', value: srv.maintCostIntensity, format: FormattingUtils.number(0) }
|
|
114
|
-
]
|
|
115
|
-
});
|
|
116
|
-
});
|
|
117
|
-
const sEndRow = r - 1;
|
|
118
|
-
const servicesTable = `i18n:worksheets.assumptions_services!$A$${sStartRow}:$C$${sEndRow}`;
|
|
119
|
-
sheets.push({
|
|
120
|
-
name: 'i18n:worksheets.assumptions_services',
|
|
121
|
-
sheetType: 'assumptions',
|
|
122
|
-
visibility: 'Visible',
|
|
123
|
-
tabColor: theme.assumptions.tabColor || null,
|
|
124
|
-
showGridlines: false,
|
|
125
|
-
customProperties: { 'ssg-type': 'assumptions', 'ssg-category': 'services' },
|
|
126
|
-
columnWidths: getColWidths(3, c.services.A.width, c.services.BPlus.width),
|
|
127
|
-
rows: sRows,
|
|
128
|
-
mergedRanges: []
|
|
129
|
-
});
|
|
130
|
-
// --- Infrastructure ---
|
|
131
|
-
const iRows = [];
|
|
132
|
-
r = 1;
|
|
133
|
-
iRows.push(fillTitle('i18n:scenario.assumptions.infrastructure', scenTheme.colors.infraHeader, 3));
|
|
134
|
-
iRows.push({
|
|
135
|
-
rowIndex: r++, cells: [
|
|
136
|
-
{ column: 'A', value: 'i18n:scenario.assumptions.name', format: FormattingUtils.boldText() },
|
|
137
|
-
{ column: 'B', value: 'i18n:scenario.assumptions.capCost', format: FormattingUtils.boldText() },
|
|
138
|
-
{ column: 'C', value: 'i18n:scenario.assumptions.maintCost', format: FormattingUtils.boldText() }
|
|
139
|
-
]
|
|
140
|
-
});
|
|
141
|
-
const iStartRow = r;
|
|
142
|
-
infrastructureConfig.getInfrastructureTypesAsArray().forEach((inf) => {
|
|
143
|
-
iRows.push({
|
|
144
|
-
rowIndex: r++, cells: [
|
|
145
|
-
{ column: 'A', value: `i18n:appConfig.infrastructure.infrastructureTypes.${inf.id}`, format: scenTheme.data.grayFill },
|
|
146
|
-
{ column: 'B', value: inf.capCostIntensity, format: FormattingUtils.number(0) },
|
|
147
|
-
{ column: 'C', value: inf.maintCostIntensity, format: FormattingUtils.number(0) }
|
|
148
|
-
]
|
|
149
|
-
});
|
|
150
|
-
});
|
|
151
|
-
const iEndRow = r - 1;
|
|
152
|
-
const infrastructureTable = `i18n:worksheets.assumptions_infrastructure!$A$${iStartRow}:$C$${iEndRow}`;
|
|
153
|
-
sheets.push({
|
|
154
|
-
name: 'i18n:worksheets.assumptions_infrastructure',
|
|
155
|
-
sheetType: 'assumptions',
|
|
156
|
-
visibility: 'Visible',
|
|
157
|
-
tabColor: theme.assumptions.tabColor || null,
|
|
158
|
-
showGridlines: false,
|
|
159
|
-
customProperties: { 'ssg-type': 'assumptions', 'ssg-category': 'infrastructure' },
|
|
160
|
-
columnWidths: getColWidths(3, c.infrastructure.A.width, c.infrastructure.BPlus.width),
|
|
161
|
-
rows: iRows,
|
|
162
|
-
mergedRanges: []
|
|
163
|
-
});
|
|
164
|
-
// --- Transportation ---
|
|
165
|
-
const tRows = [];
|
|
166
|
-
r = 1;
|
|
167
|
-
const transSources = energySourcesConfig.getEnergySourcesForSector('transportation');
|
|
168
|
-
tRows.push(fillTitle('i18n:scenario.assumptions.transportation', scenTheme.colors.transHeader, 1 + transSources.length));
|
|
169
|
-
const tHeader = [
|
|
170
|
-
{ column: 'A', value: 'i18n:scenario.assumptions.name', format: FormattingUtils.boldText() }
|
|
171
|
-
];
|
|
172
|
-
transSources.forEach((src, i) => {
|
|
173
|
-
tHeader.push({ column: String.fromCharCode(66 + i), value: `i18n:scenario.assumptions.fuelCons ${src.name} (MJ/100km)`, format: FormattingUtils.boldText() });
|
|
174
|
-
});
|
|
175
|
-
tRows.push({ rowIndex: r++, cells: tHeader });
|
|
176
|
-
const tStartRow = r;
|
|
177
|
-
transportationConfig.getTransAsArray().forEach((trans) => {
|
|
178
|
-
const cells = [
|
|
179
|
-
{ column: 'A', value: `i18n:appConfig.transportation.transportationTypes.${trans.id}`, format: scenTheme.data.grayFill }
|
|
180
|
-
];
|
|
181
|
-
transSources.forEach((src, i) => {
|
|
182
|
-
cells.push({ column: String.fromCharCode(66 + i), value: trans.fuelConsumption?.[src.id] || 0 });
|
|
183
|
-
});
|
|
184
|
-
tRows.push({ rowIndex: r++, cells });
|
|
185
|
-
});
|
|
186
|
-
const tEndRow = Math.max(r - 1, tStartRow);
|
|
187
|
-
const tLastCol = String.fromCharCode(66 + Math.max(0, transSources.length - 1));
|
|
188
|
-
const transportationTable = `i18n:worksheets.assumptions_transportation!$A$${tStartRow}:$${tLastCol}$${tEndRow}`;
|
|
189
|
-
sheets.push({
|
|
190
|
-
name: 'i18n:worksheets.assumptions_transportation',
|
|
191
|
-
sheetType: 'assumptions',
|
|
192
|
-
visibility: 'Visible',
|
|
193
|
-
tabColor: theme.assumptions.tabColor || null,
|
|
194
|
-
showGridlines: false,
|
|
195
|
-
customProperties: { 'ssg-type': 'assumptions', 'ssg-category': 'transportation' },
|
|
196
|
-
columnWidths: getColWidths(1 + transSources.length, c.transportation.A.width, c.transportation.BPlus.width),
|
|
197
|
-
rows: tRows,
|
|
198
|
-
mergedRanges: []
|
|
199
|
-
});
|
|
200
|
-
// --- Energy Sources ---
|
|
201
|
-
const eRows = [];
|
|
202
|
-
r = 1;
|
|
203
|
-
eRows.push(fillTitle('i18n:scenario.assumptions.energySources', scenTheme.colors.topRow, 4));
|
|
204
|
-
eRows.push({
|
|
205
|
-
rowIndex: r++, cells: [
|
|
206
|
-
{ column: 'A', value: 'i18n:scenario.assumptions.name', format: FormattingUtils.boldText() },
|
|
207
|
-
{ column: 'B', value: 'i18n:scenario.assumptions.co2EF', format: FormattingUtils.boldText() },
|
|
208
|
-
{ column: 'C', value: 'i18n:scenario.assumptions.ch4EF', format: FormattingUtils.boldText() },
|
|
209
|
-
{ column: 'D', value: 'i18n:scenario.assumptions.n2oEF', format: FormattingUtils.boldText() }
|
|
210
|
-
]
|
|
211
|
-
});
|
|
212
|
-
const eStartRow = r;
|
|
213
|
-
energySourcesConfig.getEnergySourcesAsArray().forEach((src) => {
|
|
214
|
-
const co2 = energySourcesConfig.getEFForSourceByIdGasYear(src.id, 'CO2', evalYear);
|
|
215
|
-
const ch4 = energySourcesConfig.getEFForSourceByIdGasYear(src.id, 'CH4', evalYear);
|
|
216
|
-
const n2o = energySourcesConfig.getEFForSourceByIdGasYear(src.id, 'N2O', evalYear);
|
|
217
|
-
eRows.push({
|
|
218
|
-
rowIndex: r++, cells: [
|
|
219
|
-
{ column: 'A', value: `i18n:appConfig.energySources.energySources.${src.id}`, format: scenTheme.data.grayFill },
|
|
220
|
-
{ column: 'B', value: co2, format: { horizontalAlignment: 'Right' } },
|
|
221
|
-
{ column: 'C', value: ch4, format: { horizontalAlignment: 'Right' } },
|
|
222
|
-
{ column: 'D', value: n2o, format: { horizontalAlignment: 'Right' } }
|
|
223
|
-
]
|
|
224
|
-
});
|
|
225
|
-
});
|
|
226
|
-
const eEndRow = Math.max(r - 1, eStartRow);
|
|
227
|
-
const energySourcesTable = `i18n:worksheets.assumptions_energy!$A$${eStartRow}:$D$${eEndRow}`;
|
|
228
|
-
sheets.push({
|
|
229
|
-
name: 'i18n:worksheets.assumptions_energy',
|
|
230
|
-
sheetType: 'assumptions',
|
|
231
|
-
visibility: 'Visible',
|
|
232
|
-
tabColor: theme.assumptions.tabColor || null,
|
|
233
|
-
showGridlines: false,
|
|
234
|
-
customProperties: { 'ssg-type': 'assumptions', 'ssg-category': 'energy' },
|
|
235
|
-
columnWidths: getColWidths(4, c.energy.A.width, c.energy.BPlus.width),
|
|
236
|
-
rows: eRows,
|
|
237
|
-
mergedRanges: []
|
|
238
|
-
});
|
|
239
|
-
// --- Neighbourhoods ---
|
|
240
|
-
const nRows = [];
|
|
241
|
-
r = 1;
|
|
242
|
-
nRows.push(fillTitle('i18n:scenario.assumptions.neighbourhoods', scenTheme.colors.topRow, 2));
|
|
243
|
-
nRows.push({
|
|
244
|
-
rowIndex: r++, cells: [
|
|
245
|
-
{ column: 'A', value: 'i18n:scenario.assumptions.name', format: FormattingUtils.boldText() },
|
|
246
|
-
{ column: 'B', value: 'i18n:scenario.assumptions.schoolFactor', format: FormattingUtils.boldText() }
|
|
247
|
-
]
|
|
248
|
-
});
|
|
249
|
-
const nStartRow = r;
|
|
250
|
-
Object.entries(neighbourhoodConfig.neighbourhoods).forEach(([id, n]) => {
|
|
251
|
-
nRows.push({
|
|
252
|
-
rowIndex: r++, cells: [
|
|
253
|
-
{ column: 'A', value: `i18n:appConfig.neighbourhoods.neighbourhoodTypes.${id}`, format: scenTheme.data.labelFormat },
|
|
254
|
-
{ column: 'B', value: n.sectorDefaults?.services?.school || 0, format: { ...FormattingUtils.number(2), horizontalAlignment: 'Right' } }
|
|
255
|
-
]
|
|
256
|
-
});
|
|
257
|
-
});
|
|
258
|
-
const nEndRow = r - 1;
|
|
259
|
-
const neighbourhoodTable = `i18n:worksheets.assumptions_neighbourhood!$A$${nStartRow}:$B$${nEndRow}`;
|
|
260
|
-
sheets.push({
|
|
261
|
-
name: 'i18n:worksheets.assumptions_neighbourhood',
|
|
262
|
-
sheetType: 'assumptions',
|
|
263
|
-
visibility: 'Visible',
|
|
264
|
-
tabColor: theme.assumptions.tabColor || null,
|
|
265
|
-
showGridlines: false,
|
|
266
|
-
customProperties: { 'ssg-type': 'assumptions', 'ssg-category': 'neighbourhoods' },
|
|
267
|
-
columnWidths: getColWidths(2, c.neighbourhoods.A.width, c.neighbourhoods.BPlus.width),
|
|
268
|
-
rows: nRows,
|
|
269
|
-
mergedRanges: []
|
|
270
|
-
});
|
|
271
|
-
// --- GWPs ---
|
|
272
|
-
const gRows = [];
|
|
273
|
-
r = 1;
|
|
274
|
-
gRows.push(fillTitle('i18n:scenario.assumptions.gwp', scenTheme.colors.topRow, 2));
|
|
275
|
-
gRows.push({
|
|
276
|
-
rowIndex: r++, cells: [
|
|
277
|
-
{ column: 'A', value: 'i18n:scenario.assumptions.gasLabel', format: FormattingUtils.boldText() },
|
|
278
|
-
{ column: 'B', value: 'i18n:scenario.assumptions.gwpLabel', format: FormattingUtils.boldText() }
|
|
279
|
-
]
|
|
280
|
-
});
|
|
281
|
-
const gStartRow = r;
|
|
282
|
-
gRows.push({ rowIndex: r++, cells: [{ column: 'A', value: 'CO2', format: scenTheme.data.grayFill }, { column: 'B', value: 1, format: { horizontalAlignment: 'Right' } }] });
|
|
283
|
-
gRows.push({ rowIndex: r++, cells: [{ column: 'A', value: 'CH4', format: scenTheme.data.grayFill }, { column: 'B', value: energySourcesConfig.gwp.values.CH4 || 25, format: { horizontalAlignment: 'Right' } }] });
|
|
284
|
-
gRows.push({ rowIndex: r++, cells: [{ column: 'A', value: 'N2O', format: scenTheme.data.grayFill }, { column: 'B', value: energySourcesConfig.gwp.values.N2O || 298, format: { horizontalAlignment: 'Right' } }] });
|
|
285
|
-
const gEndRow = r - 1;
|
|
286
|
-
const gwpTable = `i18n:worksheets.assumptions_gwp!$A$${gStartRow}:$B$${gEndRow}`;
|
|
287
|
-
sheets.push({
|
|
288
|
-
name: 'i18n:worksheets.assumptions_gwp',
|
|
289
|
-
sheetType: 'assumptions',
|
|
290
|
-
visibility: 'Visible',
|
|
291
|
-
tabColor: theme.assumptions.tabColor || null,
|
|
292
|
-
showGridlines: false,
|
|
293
|
-
customProperties: { 'ssg-type': 'assumptions', 'ssg-category': 'gwp' },
|
|
294
|
-
columnWidths: getColWidths(2, c.gwp.A.width, c.gwp.A.width),
|
|
295
|
-
rows: gRows,
|
|
296
|
-
mergedRanges: []
|
|
297
|
-
});
|
|
298
|
-
return {
|
|
299
|
-
sheets,
|
|
300
|
-
tables: {
|
|
301
|
-
buildings: buildingsTable,
|
|
302
|
-
services: servicesTable,
|
|
303
|
-
infrastructure: infrastructureTable,
|
|
304
|
-
transportation: transportationTable,
|
|
305
|
-
energySources: energySourcesTable,
|
|
306
|
-
neighbourhoods: neighbourhoodTable,
|
|
307
|
-
gwp: gwpTable
|
|
308
|
-
}
|
|
309
|
-
};
|
|
310
|
-
}
|
|
311
|
-
}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { SheetSpec } from '../../types/workbook.types';
|
|
2
|
-
import { GeneratorConfig } from '../../types/config.types';
|
|
3
|
-
export interface EnergyMixRef {
|
|
4
|
-
sourceId: string;
|
|
5
|
-
mixRow: number;
|
|
6
|
-
}
|
|
7
|
-
export interface EmissionCalcContext {
|
|
8
|
-
category: string;
|
|
9
|
-
itemName: string;
|
|
10
|
-
energyMixRefs: EnergyMixRef[];
|
|
11
|
-
energyUseRow: number;
|
|
12
|
-
}
|
|
13
|
-
export declare class CalculationSheetBuilder {
|
|
14
|
-
private config;
|
|
15
|
-
constructor(config: GeneratorConfig);
|
|
16
|
-
build(scenarioTitle: string, calcContexts: EmissionCalcContext[], tables: any, linkedScenarioSheetName: string, studentCalc?: any): {
|
|
17
|
-
sheet: SheetSpec;
|
|
18
|
-
totalStudentsRef?: string;
|
|
19
|
-
};
|
|
20
|
-
}
|