@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,149 +0,0 @@
|
|
|
1
|
-
import { FormattingUtils } from '../../utils/formatting';
|
|
2
|
-
import appConfig from '../../config/appConfig';
|
|
3
|
-
export class CalculationSheetBuilder {
|
|
4
|
-
config;
|
|
5
|
-
constructor(config) {
|
|
6
|
-
this.config = config;
|
|
7
|
-
}
|
|
8
|
-
build(scenarioTitle, calcContexts, tables, linkedScenarioSheetName, studentCalc) {
|
|
9
|
-
const rows = [];
|
|
10
|
-
let currentRow = 1;
|
|
11
|
-
const sheetName = scenarioTitle.length > 26 ? scenarioTitle.substring(0, 26) + 'i18n:worksheets.calcSuffix' : scenarioTitle + 'i18n:worksheets.calcSuffix';
|
|
12
|
-
const escapedScenarioSheetName = linkedScenarioSheetName.replace(/'/g, "''");
|
|
13
|
-
const theme = this.config.theme;
|
|
14
|
-
const ccalc = theme.calc;
|
|
15
|
-
const c = theme.scenario;
|
|
16
|
-
let totalStudentsRef;
|
|
17
|
-
for (const ctx of calcContexts) {
|
|
18
|
-
rows.push({
|
|
19
|
-
rowIndex: currentRow++,
|
|
20
|
-
cells: [
|
|
21
|
-
{ column: 'A', value: `${ctx.category === 'Buildings' ? 'i18n:scenario.modules.buildings' : 'i18n:scenario.modules.transportation'} - ` + (ctx.category.toLowerCase() === 'buildings' ? `i18n:appConfig.buildings.homeTypes.${ctx.itemName} ` : `i18n:appConfig.transportation.transportationTypes.${ctx.itemName} `), format: FormattingUtils.header(ctx.category === 'Buildings' ? c.colors.buildingsHeader : c.colors.transHeader) }
|
|
22
|
-
]
|
|
23
|
-
});
|
|
24
|
-
const totalEmissionsRefs = {};
|
|
25
|
-
for (const gas of ['CO2', 'CH4', 'N2O']) {
|
|
26
|
-
rows.push({
|
|
27
|
-
rowIndex: currentRow++,
|
|
28
|
-
cells: [
|
|
29
|
-
{ column: 'A', value: `${gas} i18n:scenario.calc.calculation`, format: FormattingUtils.boldText(c.colors.topRow) }
|
|
30
|
-
]
|
|
31
|
-
});
|
|
32
|
-
const targetYearRow = currentRow;
|
|
33
|
-
const { startYear, endYear } = appConfig();
|
|
34
|
-
rows.push({
|
|
35
|
-
rowIndex: currentRow++,
|
|
36
|
-
cells: [
|
|
37
|
-
{ column: 'A', value: 'i18n:scenario.calc.targetYear', format: c.data.grayFill },
|
|
38
|
-
{ column: 'B', formula: `= MAX(${startYear}, MIN(VALUE('${escapedScenarioSheetName}'!$B$4), ${endYear}))`, format: { horizontalAlignment: 'Right' } }
|
|
39
|
-
]
|
|
40
|
-
});
|
|
41
|
-
const yearIndexRow = currentRow;
|
|
42
|
-
rows.push({
|
|
43
|
-
rowIndex: currentRow++,
|
|
44
|
-
cells: [
|
|
45
|
-
{ column: 'A', value: 'i18n:scenario.calc.yearColumnIndex', format: c.data.grayFill },
|
|
46
|
-
{ column: 'B', formula: `= MATCH(B${targetYearRow}, 'i18n:worksheets.emissionFactors'!$D$2:$AE$2, 0)`, format: { horizontalAlignment: 'Right' } }
|
|
47
|
-
]
|
|
48
|
-
});
|
|
49
|
-
const gwpRow = currentRow;
|
|
50
|
-
rows.push({
|
|
51
|
-
rowIndex: currentRow++,
|
|
52
|
-
cells: [
|
|
53
|
-
{ column: 'A', value: 'i18n:scenario.calc.gwpMultiplier', format: c.data.grayFill },
|
|
54
|
-
{ column: 'B', formula: `= VLOOKUP("${gas}", ${tables.gwp}, 2, FALSE)`, format: { horizontalAlignment: 'Right' } }
|
|
55
|
-
]
|
|
56
|
-
});
|
|
57
|
-
const factorRows = [];
|
|
58
|
-
for (const mix of ctx.energyMixRefs) {
|
|
59
|
-
const factorRow = currentRow;
|
|
60
|
-
factorRows.push(factorRow);
|
|
61
|
-
rows.push({
|
|
62
|
-
rowIndex: currentRow++,
|
|
63
|
-
cells: [
|
|
64
|
-
{ column: 'A', value: `i18n:appConfig.energySources.energySources.${mix.sourceId === 'NG' ? 'natGas' : mix.sourceId} i18n:scenario.calc.factor`, format: c.data.grayFill },
|
|
65
|
-
{ column: 'B', formula: `= SUMIFS(INDEX('i18n:worksheets.emissionFactors'!$D$2:$AE$1000, 0, B${yearIndexRow}), 'i18n:worksheets.emissionFactors'!$A$2:$A$1000, '${escapedScenarioSheetName}'!$B$3, 'i18n:worksheets.emissionFactors'!$B$2:$B$1000, "${mix.sourceId}", 'i18n:worksheets.emissionFactors'!$C$2:$C$1000, "${gas}")`, format: { horizontalAlignment: 'Right' } }
|
|
66
|
-
]
|
|
67
|
-
});
|
|
68
|
-
}
|
|
69
|
-
const totalRow = currentRow;
|
|
70
|
-
totalEmissionsRefs[gas] = `B${totalRow} `;
|
|
71
|
-
const mathParts = ctx.energyMixRefs.map((mix, idx) => {
|
|
72
|
-
return `('${escapedScenarioSheetName}'!$D$${mix.mixRow} * B${factorRows[idx]})`;
|
|
73
|
-
});
|
|
74
|
-
const formula = mathParts.length > 0
|
|
75
|
-
? `= ('${escapedScenarioSheetName}'!$D$${ctx.energyUseRow} * 1000 * (${mathParts.join(' + ')}) * B${gwpRow}) / 1000000`
|
|
76
|
-
: `=0`;
|
|
77
|
-
rows.push({
|
|
78
|
-
rowIndex: currentRow++,
|
|
79
|
-
cells: [
|
|
80
|
-
{ column: 'A', value: 'i18n:scenario.calc.totalEmissions', format: FormattingUtils.boldText() },
|
|
81
|
-
{ column: 'B', formula: formula, format: { numberFormat: '#,##0.00', horizontalAlignment: 'Right' } }
|
|
82
|
-
]
|
|
83
|
-
});
|
|
84
|
-
currentRow++; // Spacer
|
|
85
|
-
}
|
|
86
|
-
const totalSumFormula = `=SUM(${totalEmissionsRefs['CO2']}, ${totalEmissionsRefs['CH4']}, ${totalEmissionsRefs['N2O']})`;
|
|
87
|
-
rows.push({
|
|
88
|
-
rowIndex: currentRow++,
|
|
89
|
-
cells: [
|
|
90
|
-
{ column: 'A', value: 'i18n:general.total (tCO2e/i18n:general.yearAbbr)', format: FormattingUtils.boldText() },
|
|
91
|
-
{ column: 'B', formula: totalSumFormula, format: { numberFormat: '#,##0.00', font: { bold: true }, horizontalAlignment: 'Right' } }
|
|
92
|
-
]
|
|
93
|
-
});
|
|
94
|
-
currentRow++; // Spacer
|
|
95
|
-
}
|
|
96
|
-
// --- Student Calculation (Optional) ---
|
|
97
|
-
if (studentCalc) {
|
|
98
|
-
rows.push({
|
|
99
|
-
rowIndex: currentRow++,
|
|
100
|
-
cells: [
|
|
101
|
-
{ column: 'A', value: 'i18n:scenario.calc.studentCalculation', format: FormattingUtils.header(c.colors.servicesHeader) }
|
|
102
|
-
]
|
|
103
|
-
});
|
|
104
|
-
const totalDwellingsRow = currentRow;
|
|
105
|
-
rows.push({
|
|
106
|
-
rowIndex: currentRow++,
|
|
107
|
-
cells: [
|
|
108
|
-
{ column: 'A', value: 'i18n:forms.fields.floorspaceTotal', format: c.data.grayFill },
|
|
109
|
-
{ column: 'B', formula: studentCalc.totalDwellingsFormula, format: { ...FormattingUtils.number(0), horizontalAlignment: 'Right' } }
|
|
110
|
-
]
|
|
111
|
-
});
|
|
112
|
-
const studentsPerDwellingRow = currentRow;
|
|
113
|
-
rows.push({
|
|
114
|
-
rowIndex: currentRow++,
|
|
115
|
-
cells: [
|
|
116
|
-
{ column: 'A', value: 'i18n:scenario.calc.studentsPerDwelling', format: c.data.grayFill },
|
|
117
|
-
{ column: 'B', formula: `=${studentCalc.studentFactorLookup}`, format: { ...FormattingUtils.number(2), horizontalAlignment: 'Right' } }
|
|
118
|
-
]
|
|
119
|
-
});
|
|
120
|
-
const totalStudentsRow = currentRow;
|
|
121
|
-
rows.push({
|
|
122
|
-
rowIndex: currentRow++,
|
|
123
|
-
cells: [
|
|
124
|
-
{ column: 'A', value: 'i18n:scenario.calc.totalStudents', format: FormattingUtils.boldText() },
|
|
125
|
-
{ column: 'B', formula: `=B${totalDwellingsRow}*B${studentsPerDwellingRow}`, format: { ...FormattingUtils.number(0), font: { bold: true }, horizontalAlignment: 'Right' } }
|
|
126
|
-
]
|
|
127
|
-
});
|
|
128
|
-
totalStudentsRef = `'${sheetName}'!$B$${totalStudentsRow}`;
|
|
129
|
-
currentRow++; // Spacer
|
|
130
|
-
}
|
|
131
|
-
const sheet = {
|
|
132
|
-
name: sheetName,
|
|
133
|
-
sheetType: 'data',
|
|
134
|
-
visibility: 'Visible',
|
|
135
|
-
tabColor: null,
|
|
136
|
-
showGridlines: false,
|
|
137
|
-
customProperties: {
|
|
138
|
-
'ssg-type': 'calculation'
|
|
139
|
-
},
|
|
140
|
-
columnWidths: [
|
|
141
|
-
{ range: 'A:A', width: ccalc.columns.A.width },
|
|
142
|
-
{ range: 'B:B', width: ccalc.columns.B.width }
|
|
143
|
-
],
|
|
144
|
-
mergedRanges: [],
|
|
145
|
-
rows
|
|
146
|
-
};
|
|
147
|
-
return { sheet, totalStudentsRef };
|
|
148
|
-
}
|
|
149
|
-
}
|
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
import { FormattingUtils } from '../../utils/formatting';
|
|
2
|
-
import { emissionFactorsData } from '../../config/domain/emissionFactors';
|
|
3
|
-
import { getColumnLetter, colLetterToIndex } from '../../utils/cellAddressing';
|
|
4
|
-
import appConfig from '../../config/appConfig';
|
|
5
|
-
export class EmissionFactorsSheetBuilder {
|
|
6
|
-
config;
|
|
7
|
-
constructor(config) {
|
|
8
|
-
this.config = config;
|
|
9
|
-
}
|
|
10
|
-
build() {
|
|
11
|
-
const { startYear, endYear } = appConfig();
|
|
12
|
-
const rows = [];
|
|
13
|
-
let currentRow = 1;
|
|
14
|
-
const theme = this.config.theme;
|
|
15
|
-
const cemission = theme.emissionFactors;
|
|
16
|
-
const c = theme.scenario;
|
|
17
|
-
// Header Row
|
|
18
|
-
const totalCols = 3 + (endYear - startYear + 1);
|
|
19
|
-
const topRowCells = [];
|
|
20
|
-
for (let i = 0; i < totalCols; i++) {
|
|
21
|
-
topRowCells.push({ column: getColumnLetter(i), value: i === 0 ? 'i18n:scenario.assumptions.emissionFactorsTitle' : '', format: FormattingUtils.header(c.colors.topRow) });
|
|
22
|
-
}
|
|
23
|
-
rows.push({
|
|
24
|
-
rowIndex: currentRow++,
|
|
25
|
-
cells: topRowCells
|
|
26
|
-
});
|
|
27
|
-
const headerCells = [
|
|
28
|
-
{ column: 'A', value: 'i18n:scenario.inputs.provid', format: FormattingUtils.header(c.colors.topRow) },
|
|
29
|
-
{ column: 'B', value: 'i18n:scenario.inputs.energysource_id', format: FormattingUtils.header(c.colors.topRow) },
|
|
30
|
-
{ column: 'C', value: 'i18n:scenario.inputs.gas', format: FormattingUtils.header(c.colors.topRow) },
|
|
31
|
-
];
|
|
32
|
-
// Dynamic Year Headers
|
|
33
|
-
let colIdx = colLetterToIndex('D');
|
|
34
|
-
for (let year = startYear; year <= endYear; year++) {
|
|
35
|
-
headerCells.push({
|
|
36
|
-
column: getColumnLetter(colIdx++),
|
|
37
|
-
value: year,
|
|
38
|
-
format: FormattingUtils.header(c.colors.topRow)
|
|
39
|
-
});
|
|
40
|
-
}
|
|
41
|
-
rows.push({
|
|
42
|
-
rowIndex: currentRow++,
|
|
43
|
-
cells: headerCells
|
|
44
|
-
});
|
|
45
|
-
// Data Rows
|
|
46
|
-
emissionFactorsData.forEach((row) => {
|
|
47
|
-
const dataCells = [
|
|
48
|
-
{ column: 'A', value: row.provid, format: c.data.labelFormat },
|
|
49
|
-
{ column: 'B', value: row.energysource_id, format: c.data.grayFill },
|
|
50
|
-
{ column: 'C', value: row.gas, format: c.data.grayFill },
|
|
51
|
-
];
|
|
52
|
-
let dataColIdx = colLetterToIndex('D');
|
|
53
|
-
for (let year = startYear; year <= endYear; year++) {
|
|
54
|
-
dataCells.push({
|
|
55
|
-
column: getColumnLetter(dataColIdx++),
|
|
56
|
-
value: row[year.toString()],
|
|
57
|
-
format: { horizontalAlignment: 'Right' }
|
|
58
|
-
});
|
|
59
|
-
}
|
|
60
|
-
rows.push({
|
|
61
|
-
rowIndex: currentRow++,
|
|
62
|
-
cells: dataCells
|
|
63
|
-
});
|
|
64
|
-
});
|
|
65
|
-
const sheetName = 'i18n:worksheets.emissionFactors';
|
|
66
|
-
const lastYearCol = getColumnLetter(colLetterToIndex('D') + (endYear - startYear));
|
|
67
|
-
const sheet = {
|
|
68
|
-
name: sheetName,
|
|
69
|
-
sheetType: 'data',
|
|
70
|
-
visibility: 'Visible',
|
|
71
|
-
tabColor: theme.emissionFactors.tabColor || null,
|
|
72
|
-
customProperties: { "ssg-type": "data" },
|
|
73
|
-
showGridlines: true,
|
|
74
|
-
columnWidths: [
|
|
75
|
-
{ range: 'A:A', width: cemission.columns.A.width },
|
|
76
|
-
{ range: 'B:B', width: cemission.columns.B.width },
|
|
77
|
-
{ range: 'C:C', width: cemission.columns.C.width },
|
|
78
|
-
{ range: 'D:' + lastYearCol, width: cemission.columns.DPlus.width }
|
|
79
|
-
],
|
|
80
|
-
mergedRanges: [],
|
|
81
|
-
charts: [],
|
|
82
|
-
rows
|
|
83
|
-
};
|
|
84
|
-
return sheet;
|
|
85
|
-
}
|
|
86
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { SheetSpec } from '../../types/workbook.types';
|
|
2
|
-
import { AssumptionTables } from './AssumptionsBuilder';
|
|
3
|
-
import { Scenario } from '../../types/scenario.types';
|
|
4
|
-
import { GeneratorConfig } from '../../types/config.types';
|
|
5
|
-
export interface InputDataResult {
|
|
6
|
-
sheet: SheetSpec;
|
|
7
|
-
refs: Record<string, string>;
|
|
8
|
-
}
|
|
9
|
-
export declare class InputDataSheetBuilder {
|
|
10
|
-
private config;
|
|
11
|
-
constructor(config: GeneratorConfig);
|
|
12
|
-
build(scenario: Scenario, tables: AssumptionTables): InputDataResult;
|
|
13
|
-
}
|
|
@@ -1,114 +0,0 @@
|
|
|
1
|
-
import { FormattingUtils } from '../../utils/formatting';
|
|
2
|
-
export class InputDataSheetBuilder {
|
|
3
|
-
config;
|
|
4
|
-
constructor(config) {
|
|
5
|
-
this.config = config;
|
|
6
|
-
}
|
|
7
|
-
build(scenario, tables) {
|
|
8
|
-
const theme = this.config.theme;
|
|
9
|
-
const cinput = theme.inputData;
|
|
10
|
-
const c = theme.scenario;
|
|
11
|
-
const sheetName = `i18n:worksheets.inputPrefix ${scenario.title.slice(0, 20)}`;
|
|
12
|
-
const sheet = {
|
|
13
|
-
name: sheetName,
|
|
14
|
-
sheetType: 'data',
|
|
15
|
-
visibility: 'Visible',
|
|
16
|
-
tabColor: null,
|
|
17
|
-
customProperties: { "ssg-type": "data" },
|
|
18
|
-
showGridlines: true,
|
|
19
|
-
columnWidths: [
|
|
20
|
-
{ range: "A:A", width: cinput.columns.A.width },
|
|
21
|
-
{ range: "B:B", width: cinput.columns.B.width },
|
|
22
|
-
{ range: "C:C", width: cinput.columns.CDE.width },
|
|
23
|
-
{ range: "D:D", width: cinput.columns.CDE.width },
|
|
24
|
-
{ range: "E:E", width: cinput.columns.CDE.width }
|
|
25
|
-
],
|
|
26
|
-
mergedRanges: [],
|
|
27
|
-
charts: [],
|
|
28
|
-
rows: []
|
|
29
|
-
};
|
|
30
|
-
const refs = {};
|
|
31
|
-
let currentRow = 1;
|
|
32
|
-
// Title
|
|
33
|
-
sheet.rows.push({
|
|
34
|
-
rowIndex: currentRow++,
|
|
35
|
-
cells: [
|
|
36
|
-
{ column: 'A', value: 'i18n:forms.fields.category', format: FormattingUtils.header(c.colors.topRow) },
|
|
37
|
-
{ column: 'B', value: 'i18n:scenario.inputs.variable', format: FormattingUtils.header(c.colors.topRow) },
|
|
38
|
-
{ column: 'C', value: 'i18n:scenario.inputs.value', format: FormattingUtils.header(c.colors.topRow) },
|
|
39
|
-
{ column: 'D', value: 'i18n:scenario.inputs.unit', format: FormattingUtils.header(c.colors.topRow) },
|
|
40
|
-
{ column: 'E', value: 'i18n:scenario.inputs.status', format: FormattingUtils.header(c.colors.topRow) }
|
|
41
|
-
]
|
|
42
|
-
});
|
|
43
|
-
// Helper to add property
|
|
44
|
-
const addProp = (category, variable, value, unit, refKey, defaultFormula) => {
|
|
45
|
-
const val = value !== undefined && value !== null ? value : 0;
|
|
46
|
-
// Handle numeric values vs string values securely
|
|
47
|
-
const cellValue = typeof val === 'object' ? JSON.stringify(val) : val;
|
|
48
|
-
const cells = [
|
|
49
|
-
{ column: 'A', value: category, format: c.data.labelFormat },
|
|
50
|
-
{ column: 'B', value: variable, format: c.data.grayFill },
|
|
51
|
-
{ column: 'C', value: cellValue, format: { horizontalAlignment: 'Right' } },
|
|
52
|
-
{ column: 'D', value: unit }
|
|
53
|
-
];
|
|
54
|
-
if (defaultFormula) {
|
|
55
|
-
cells.push({
|
|
56
|
-
column: 'E',
|
|
57
|
-
formula: `=IF(C${currentRow}=${defaultFormula}, "i18n:scenario.inputs.defaultValue", "i18n:scenario.inputs.overriddenByUser")`
|
|
58
|
-
});
|
|
59
|
-
}
|
|
60
|
-
sheet.rows.push({
|
|
61
|
-
rowIndex: currentRow,
|
|
62
|
-
cells
|
|
63
|
-
});
|
|
64
|
-
// Escape sheet name if it contains spaces
|
|
65
|
-
refs[refKey] = `='${sheetName}'!$C$${currentRow}`;
|
|
66
|
-
currentRow++;
|
|
67
|
-
};
|
|
68
|
-
// Buildings
|
|
69
|
-
if (scenario.buildings) {
|
|
70
|
-
for (const [key, bldg] of Object.entries(scenario.buildings)) {
|
|
71
|
-
addProp('i18n:scenario.modules.buildings', `i18n:appConfig.buildings.homeTypes.${key} - i18n:scenario.inputs.quantity`, bldg.qty, 'i18n:general.dwelling', `buildings.${key}.qty`);
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
// Transportation
|
|
75
|
-
if (scenario.transportation) {
|
|
76
|
-
for (const [key, tpt] of Object.entries(scenario.transportation)) {
|
|
77
|
-
addProp('i18n:scenario.modules.transportation', `i18n:appConfig.transportation.transportationTypes.${key} - i18n:scenario.inputs.quantity`, tpt.qty, 'VKT/i18n:general.dwelling', `transportation.${key}.qty`);
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
// Infrastructure
|
|
81
|
-
if (scenario.infrastructure) {
|
|
82
|
-
for (const [key, infRaw] of Object.entries(scenario.infrastructure)) {
|
|
83
|
-
const inf = infRaw;
|
|
84
|
-
addProp('i18n:scenario.modules.infrastructure', `i18n:appConfig.infrastructure.infrastructureTypes.${key} - i18n:scenario.inputs.quantity`, inf.qty, 'm', `infrastructure.${key}.qty`);
|
|
85
|
-
const infIdCell = `"i18n:appConfig.infrastructure.infrastructureTypes.${key}"`;
|
|
86
|
-
const capLookup = `VLOOKUP(${infIdCell},${tables.infrastructure},2,FALSE)`;
|
|
87
|
-
addProp('i18n:scenario.modules.infrastructure', `i18n:appConfig.infrastructure.infrastructureTypes.${key} - i18n:forms.fields.capitalCost`, inf.capCostIntensity, '$/m', `infrastructure.${key}.capCostIntensity`, capLookup);
|
|
88
|
-
const maintLookup = `VLOOKUP(${infIdCell},${tables.infrastructure},3,FALSE)`;
|
|
89
|
-
addProp('i18n:scenario.modules.infrastructure', `i18n:appConfig.infrastructure.infrastructureTypes.${key} - i18n:forms.fields.maintCost`, inf.maintCostIntensity, '$/m/i18n:general.yearAbbr', `infrastructure.${key}.maintCostIntensity`, maintLookup);
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
// Services
|
|
93
|
-
if (scenario.services) {
|
|
94
|
-
for (const [key, srv] of Object.entries(scenario.services)) {
|
|
95
|
-
const unit = key === 'school' ? 'i18n:scenario.calc.totalStudents' : 'i18n:general.dwelling';
|
|
96
|
-
addProp('i18n:scenario.modules.services', `i18n:appConfig.services.serviceTypes.${key} - i18n:scenario.inputs.quantity`, srv.qty, unit, `services.${key}.qty`);
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
// Municipal Revenue
|
|
100
|
-
if (scenario.revenue) {
|
|
101
|
-
if (scenario.revenue.developmentCharges) {
|
|
102
|
-
for (const [bType, rev] of Object.entries(scenario.revenue.developmentCharges)) {
|
|
103
|
-
addProp('i18n:scenario.modules.revenue', `i18n:appConfig.revenue.revenueTypes.developmentCharges - i18n:appConfig.buildings.homeTypes.${bType}`, rev.perUnit, '$/i18n:general.dwelling', `revenue.developmentCharges.${bType}.perUnit`);
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
if (scenario.revenue.propertyTaxes) {
|
|
107
|
-
for (const [bType, rev] of Object.entries(scenario.revenue.propertyTaxes)) {
|
|
108
|
-
addProp('i18n:scenario.modules.revenue', `i18n:appConfig.revenue.revenueTypes.propertyTaxes - i18n:appConfig.buildings.homeTypes.${bType}`, rev.perUnit, '$/i18n:general.dwelling/i18n:general.yearAbbr', `revenue.propertyTaxes.${bType}.perUnit`);
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
return { sheet, refs };
|
|
113
|
-
}
|
|
114
|
-
}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { SheetSpec } from '../../types/workbook.types';
|
|
2
|
-
import { Scenario } from '../../types/scenario.types';
|
|
3
|
-
import { GeneratorConfig } from '../../types/config.types';
|
|
4
|
-
import { AssumptionTables } from './AssumptionsBuilder';
|
|
5
|
-
import { EmissionCalcContext } from './CalculationSheetBuilder';
|
|
6
|
-
export interface StudentCalcMetadata {
|
|
7
|
-
totalDwellingsFormula: string;
|
|
8
|
-
studentFactorLookup: string;
|
|
9
|
-
}
|
|
10
|
-
export declare class ScenarioSheetBuilder {
|
|
11
|
-
private config;
|
|
12
|
-
constructor(config: GeneratorConfig);
|
|
13
|
-
build(scenario: Scenario, tables: AssumptionTables, refs: Record<string, string>): {
|
|
14
|
-
sheet: SheetSpec;
|
|
15
|
-
calcContexts: EmissionCalcContext[];
|
|
16
|
-
studentCalc?: StudentCalcMetadata;
|
|
17
|
-
};
|
|
18
|
-
private appendAssumptionsAndReferences;
|
|
19
|
-
}
|