@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,4 +1,5 @@
|
|
|
1
1
|
import { getColumnLetter } from '../../utils/cellAddressing';
|
|
2
|
+
import { lineChartYearRange } from './ChartDataSheetBuilder';
|
|
2
3
|
const CHART_SERIES = [
|
|
3
4
|
{
|
|
4
5
|
seriesKey: 'energy',
|
|
@@ -91,6 +92,7 @@ export class ChartsSheetBuilder {
|
|
|
91
92
|
this.config = config;
|
|
92
93
|
}
|
|
93
94
|
build(scenarios, chartDataSheet) {
|
|
95
|
+
const multiYear = this.config.outputMode === 'multi-year';
|
|
94
96
|
const N = scenarios.length;
|
|
95
97
|
// Last column in the chart data sheet for N scenarios: getColumnLetter(N) (0-based)
|
|
96
98
|
const lastDataCol = getColumnLetter(N);
|
|
@@ -117,7 +119,7 @@ export class ChartsSheetBuilder {
|
|
|
117
119
|
seriesBy: 'Columns',
|
|
118
120
|
position: `A${startRow}:C${endRow}`,
|
|
119
121
|
title: {
|
|
120
|
-
text: series.titleTokenTotal,
|
|
122
|
+
text: multiYear ? `${series.titleTokenTotal} (i18n:general.annualAvg)` : series.titleTokenTotal,
|
|
121
123
|
visible: true,
|
|
122
124
|
},
|
|
123
125
|
axes: {
|
|
@@ -144,7 +146,7 @@ export class ChartsSheetBuilder {
|
|
|
144
146
|
seriesBy: 'Columns',
|
|
145
147
|
position: `D${startRow}:F${endRow}`,
|
|
146
148
|
title: {
|
|
147
|
-
text: series.titleTokenPerHH,
|
|
149
|
+
text: multiYear ? `${series.titleTokenPerHH} (i18n:general.annualAvg)` : series.titleTokenPerHH,
|
|
148
150
|
visible: true,
|
|
149
151
|
},
|
|
150
152
|
axes: {
|
|
@@ -164,6 +166,105 @@ export class ChartsSheetBuilder {
|
|
|
164
166
|
series: scenarios.map((sc, idx) => ({ index: idx, name: sc.title })),
|
|
165
167
|
});
|
|
166
168
|
});
|
|
169
|
+
// ── Cumulative Line charts (9 metrics, earliest build-out year–endYear) ───
|
|
170
|
+
// Data is in ChartDataSheet starting at row 73 (see ChartDataSheetBuilder).
|
|
171
|
+
// Each block: 1 header + N_years data rows + 1 separator = N_years + 2 rows.
|
|
172
|
+
// Layout: column A = year axis; columns B..N = one series per scenario.
|
|
173
|
+
// The x-axis starts at the earliest build-out year (also used in the chart title),
|
|
174
|
+
// so no empty years lead the chart. Shared with ChartDataSheetBuilder.
|
|
175
|
+
const { firstYear: earliestYear, endYear, nYears: N_years } = lineChartYearRange(scenarios);
|
|
176
|
+
const LINE_START_ROW = 12 * 2 * 3 + 1; // 73 — must match ChartDataSheetBuilder
|
|
177
|
+
// Last data column in the line chart range (A = year, B..N = scenarios)
|
|
178
|
+
const lineLastDataCol = getColumnLetter(N);
|
|
179
|
+
const LINE_CHART_DEFS = [
|
|
180
|
+
{
|
|
181
|
+
seriesKey: 'energy',
|
|
182
|
+
titleToken: 'i18n:scenario.energyUse',
|
|
183
|
+
unitsToken: 'GJ',
|
|
184
|
+
},
|
|
185
|
+
{
|
|
186
|
+
seriesKey: 'emissions',
|
|
187
|
+
titleToken: 'i18n:scenario.emissions',
|
|
188
|
+
unitsToken: 'tCO2e',
|
|
189
|
+
},
|
|
190
|
+
{
|
|
191
|
+
seriesKey: 'serviceOMCost',
|
|
192
|
+
titleToken: 'i18n:scenario.modules.servicesOMCost',
|
|
193
|
+
unitsToken: '$',
|
|
194
|
+
},
|
|
195
|
+
{
|
|
196
|
+
seriesKey: 'infOMCost',
|
|
197
|
+
titleToken: 'i18n:scenario.modules.infrastructureOMCost',
|
|
198
|
+
unitsToken: '$',
|
|
199
|
+
},
|
|
200
|
+
{
|
|
201
|
+
seriesKey: 'taxes',
|
|
202
|
+
titleToken: 'i18n:appConfig.revenue.revenueTypes.municipalRevTaxes',
|
|
203
|
+
unitsToken: '$',
|
|
204
|
+
},
|
|
205
|
+
{
|
|
206
|
+
seriesKey: 'puv',
|
|
207
|
+
titleToken: 'i18n:forms.fields.puvVKT',
|
|
208
|
+
unitsToken: 'VKT',
|
|
209
|
+
},
|
|
210
|
+
{
|
|
211
|
+
seriesKey: 'transit',
|
|
212
|
+
titleToken: 'i18n:forms.fields.transitVKT',
|
|
213
|
+
unitsToken: 'VKT',
|
|
214
|
+
},
|
|
215
|
+
{
|
|
216
|
+
seriesKey: 'bike',
|
|
217
|
+
titleToken: 'i18n:forms.fields.bikeKT',
|
|
218
|
+
unitsToken: 'AKT',
|
|
219
|
+
},
|
|
220
|
+
{
|
|
221
|
+
seriesKey: 'walk',
|
|
222
|
+
titleToken: 'i18n:forms.fields.walkKT',
|
|
223
|
+
unitsToken: 'AKT',
|
|
224
|
+
},
|
|
225
|
+
];
|
|
226
|
+
// Last bar chart row: s=11, startRow = 5 + 11*15 = 170, endRow = 184
|
|
227
|
+
const lastBarRow = 5 + (CHART_SERIES.length - 1) * 15 + 14;
|
|
228
|
+
// Line charts exist only in multi-year mode
|
|
229
|
+
if (multiYear)
|
|
230
|
+
LINE_CHART_DEFS.forEach((def, li) => {
|
|
231
|
+
const blockStart = LINE_START_ROW + li * (N_years + 3);
|
|
232
|
+
const headerRow = blockStart + 1;
|
|
233
|
+
const lastYearRow = blockStart + 1 + N_years; // row for endYear (last data row)
|
|
234
|
+
// Each line chart occupies 18 rows; gap of 3 rows after the bar charts
|
|
235
|
+
const lineChartStart = lastBarRow + 3 + li * 18;
|
|
236
|
+
const lineChartEnd = lineChartStart + 17;
|
|
237
|
+
const sourceRange = `'${chartDataToken}'!A${headerRow}:${lineLastDataCol}${lastYearRow}`;
|
|
238
|
+
charts.push({
|
|
239
|
+
name: `${def.seriesKey}_line`,
|
|
240
|
+
chartType: 'Line',
|
|
241
|
+
sourceDataRange: sourceRange,
|
|
242
|
+
seriesBy: 'Columns',
|
|
243
|
+
position: `A${lineChartStart}:F${lineChartEnd}`,
|
|
244
|
+
title: {
|
|
245
|
+
text: `${def.titleToken} i18n:general.cumulativeTotal ${earliestYear}-${endYear}`,
|
|
246
|
+
visible: true,
|
|
247
|
+
},
|
|
248
|
+
axes: {
|
|
249
|
+
value: {
|
|
250
|
+
title: { text: def.unitsToken, visible: true },
|
|
251
|
+
displayUnit: 'Thousands',
|
|
252
|
+
minimum: 0,
|
|
253
|
+
},
|
|
254
|
+
category: {
|
|
255
|
+
title: { text: 'i18n:general.year', visible: true },
|
|
256
|
+
},
|
|
257
|
+
},
|
|
258
|
+
legend: {
|
|
259
|
+
visible: true,
|
|
260
|
+
position: 'Right',
|
|
261
|
+
},
|
|
262
|
+
series: scenarios.map((sc, idx) => ({ index: idx, name: sc.title })),
|
|
263
|
+
// Markers keep short series visible; a 2050 build-out has a single data point
|
|
264
|
+
markerStyle: 'Circle',
|
|
265
|
+
markerSize: 5,
|
|
266
|
+
});
|
|
267
|
+
});
|
|
167
268
|
// Title row
|
|
168
269
|
const titleCell = {
|
|
169
270
|
column: 'A',
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { FormattingUtils } from '../../utils/formatting';
|
|
2
2
|
import infrastructureConfigFn from '../../config/domain/infrastructure';
|
|
3
|
-
import { InfrastructureUnit } from '../../config/types';
|
|
3
|
+
import { InfrastructureUnit, InfrastructureUnitSingular } from '../../config/types';
|
|
4
4
|
import { ktUnitToken } from '../../utils/transportationUnits';
|
|
5
5
|
export class InputDataSheetBuilder {
|
|
6
6
|
config;
|
|
@@ -89,8 +89,9 @@ export class InputDataSheetBuilder {
|
|
|
89
89
|
const inf = infRaw;
|
|
90
90
|
const qtyUnit = infraConfig.infrastructureTypes[key]?.units ?? InfrastructureUnit.Meters;
|
|
91
91
|
const qtyUnitCell = `i18n:${qtyUnit}`;
|
|
92
|
-
const
|
|
93
|
-
const
|
|
92
|
+
const perUnitCell = `i18n:${InfrastructureUnitSingular[qtyUnit] ?? qtyUnit}`;
|
|
93
|
+
const capUnit = `$/${perUnitCell}`;
|
|
94
|
+
const maintUnit = `$/${perUnitCell}/i18n:general.yearAbbr`;
|
|
94
95
|
addProp('i18n:scenario.modules.infrastructure', `i18n:appConfig.infrastructure.infrastructureTypes.${key} - i18n:scenario.inputs.quantity`, inf.qty, qtyUnitCell, `infrastructure.${key}.qty`);
|
|
95
96
|
const infIdCell = `"i18n:appConfig.infrastructure.infrastructureTypes.${key}"`;
|
|
96
97
|
const capLookup = `VLOOKUP(${infIdCell},${tables.infrastructure},2,FALSE)`;
|
|
@@ -36,6 +36,8 @@ export interface ScenarioOutputRefs {
|
|
|
36
36
|
srvOMTotalRow: number;
|
|
37
37
|
/** Row of the infrastructure O&M total in the Scenario sheet outputs table (-1 if absent) */
|
|
38
38
|
infOMTotalRow: number;
|
|
39
|
+
/** Row of the property taxes line in the Scenario sheet revenue totals; column E holds the build-year–2050 total (-1 if absent) */
|
|
40
|
+
propTaxTotalRow: number;
|
|
39
41
|
}
|
|
40
42
|
export declare class ScenarioDetailsBuilder {
|
|
41
43
|
private config;
|
|
@@ -132,7 +132,7 @@ export class ScenarioDetailsBuilder {
|
|
|
132
132
|
}]
|
|
133
133
|
});
|
|
134
134
|
for (const [key, bldgRefs] of Object.entries(refs.buildings)) {
|
|
135
|
-
const qty = scenario.buildings[key]?.qty ?? 0;
|
|
135
|
+
const qty = scenario.buildings?.[key]?.qty ?? 0;
|
|
136
136
|
// C.1 Building type header
|
|
137
137
|
mergedRanges.push(`A${currentRow}:${cumCol}${currentRow}`);
|
|
138
138
|
rows.push({
|
|
@@ -445,9 +445,9 @@ export class ScenarioDetailsBuilder {
|
|
|
445
445
|
rows.push({ rowIndex: currentRow++, cells: emPDCells });
|
|
446
446
|
// ── Build column width specs ─────────────────────────────────────────────
|
|
447
447
|
const columnWidths = [
|
|
448
|
-
{ range: 'A:A', width:
|
|
449
|
-
{ range: 'B:B', width:
|
|
450
|
-
{ range: 'C:C', width:
|
|
448
|
+
{ range: 'A:A', width: 220 }, // fits "Année de construction complète" in bold
|
|
449
|
+
{ range: 'B:B', width: 200 }, // fits the longest label, e.g. "Total de la surface aménagée"
|
|
450
|
+
{ range: 'C:C', width: 110 }, // fits unit labels such as "tCO₂e/logement/an"
|
|
451
451
|
{ range: `D:${lastYrCol}`, width: 72 },
|
|
452
452
|
{ range: `${avgCol}:${cumCol}`, width: 90 }
|
|
453
453
|
];
|
|
@@ -2,6 +2,7 @@ import { SheetSpec } from '../../types/workbook.types';
|
|
|
2
2
|
import { Scenario } from '../../types/scenario.types';
|
|
3
3
|
import { GeneratorConfig } from '../../types/config.types';
|
|
4
4
|
import { AssumptionTables } from './AssumptionsBuilder';
|
|
5
|
+
import { ScenarioOutputRefs } from './ScenarioDetailsBuilder';
|
|
5
6
|
import { EmissionCalcContext } from './CalculationSheetBuilder';
|
|
6
7
|
export declare class ScenarioSheetBuilder {
|
|
7
8
|
private config;
|
|
@@ -9,6 +10,7 @@ export declare class ScenarioSheetBuilder {
|
|
|
9
10
|
build(scenario: Scenario, tables: AssumptionTables, refs: Record<string, string>): {
|
|
10
11
|
sheet: SheetSpec;
|
|
11
12
|
calcContexts: EmissionCalcContext[];
|
|
13
|
+
scenarioOutputRefs: ScenarioOutputRefs;
|
|
12
14
|
};
|
|
13
15
|
private appendAssumptionsAndReferences;
|
|
14
16
|
}
|
|
@@ -17,15 +17,24 @@ export class ScenarioSheetBuilder {
|
|
|
17
17
|
const rows = [];
|
|
18
18
|
const mergedRanges = [];
|
|
19
19
|
let currentRow = 1;
|
|
20
|
+
const sheetNameStr = scenario.title.length > 28 ? scenario.title.substring(0, 28) : scenario.title;
|
|
21
|
+
const c = this.config.theme.scenario;
|
|
22
|
+
const buildYear = scenario.year;
|
|
23
|
+
// Single-year mode (default) reproduces the 1.3.0 sheet: emissions come from a Calc sheet
|
|
24
|
+
// and there are no "Total (year-2050)" columns. Multi-year mode reads emissions from the Details sheet.
|
|
25
|
+
const multiYear = this.config.outputMode === 'multi-year';
|
|
26
|
+
// Single-year only: rows of the Calc sheet that this sheet's emission cells point to.
|
|
20
27
|
const calcContexts = [];
|
|
21
28
|
let calcSheetCurrentRow = 1;
|
|
22
|
-
// Excel limits sheet names to 31 characters.
|
|
23
|
-
// The main scenario sheet name is truncated to 28 characters.
|
|
24
|
-
const sheetNameStr = scenario.title.substring(0, 28);
|
|
25
29
|
// The calculation sheet name needs room for the translated " Calc" suffix (5 characters).
|
|
26
30
|
const calcSheetName = sheetNameStr.substring(0, 26) + 'i18n:worksheets.calcSuffix';
|
|
27
31
|
const escapedCalcSheetName = calcSheetName.replace(/'/g, "''");
|
|
28
|
-
|
|
32
|
+
// Track row positions for ScenarioOutputRefs
|
|
33
|
+
const buildingOutputRowsMap = {};
|
|
34
|
+
const transportOutputRowsMap = {};
|
|
35
|
+
let srvOMTotalRow = -1;
|
|
36
|
+
let infOMTotalRow = -1;
|
|
37
|
+
let propTaxTotalRow = -1;
|
|
29
38
|
const padEmptyCells = (count, color) => {
|
|
30
39
|
const cols = ['C', 'D', 'E'];
|
|
31
40
|
return cols.slice(0, count).map(col => ({
|
|
@@ -241,14 +250,27 @@ export class ScenarioSheetBuilder {
|
|
|
241
250
|
}
|
|
242
251
|
}
|
|
243
252
|
const outputsStartRow = currentRow;
|
|
253
|
+
// §2.1 Column-header sub-row: "Average Annual" | "Total (year–2050)"
|
|
254
|
+
if (multiYear)
|
|
255
|
+
rows.push({
|
|
256
|
+
rowIndex: currentRow++,
|
|
257
|
+
cells: [
|
|
258
|
+
{ column: 'B', value: '', format: c.data.grayFill },
|
|
259
|
+
{ column: 'D', value: 'i18n:scenario.avgAnnualEnergyEmissions', format: { font: { bold: true } } },
|
|
260
|
+
{ column: 'E', value: `Total (${buildYear}\u20132050)`, format: { font: { bold: true } } }
|
|
261
|
+
]
|
|
262
|
+
});
|
|
263
|
+
// §2.2 Energy use row: col D = unchanged formula, col E = cumulative total
|
|
244
264
|
const energyUseRow = currentRow;
|
|
245
265
|
rows.push({
|
|
246
266
|
rowIndex: currentRow++,
|
|
247
267
|
cells: [
|
|
248
268
|
{ column: 'B', value: '', format: c.data.grayFill },
|
|
249
|
-
{ column: 'C', value: 'i18n:scenario.energyUse', format: { font: { bold: true } } },
|
|
269
|
+
{ column: 'C', value: multiYear ? 'i18n:scenario.energyUse (GJ/i18n:general.yearAbbr)' : 'i18n:scenario.energyUse', format: { font: { bold: true } } },
|
|
250
270
|
{ column: 'D', formula: `=D${totalSpaceRow}*D${euiRow}*0.001`, format: { numberFormat: '#,##0', horizontalAlignment: 'Right' } },
|
|
251
|
-
|
|
271
|
+
multiYear
|
|
272
|
+
? { column: 'E', formula: `=D${energyUseRow}*(2050-${buildYear}+1)`, format: { numberFormat: '#,##0', horizontalAlignment: 'Right' } }
|
|
273
|
+
: { column: 'E', value: 'GJ/yr', format: { horizontalAlignment: 'Left' } }
|
|
252
274
|
]
|
|
253
275
|
});
|
|
254
276
|
rows.push({
|
|
@@ -258,7 +280,10 @@ export class ScenarioSheetBuilder {
|
|
|
258
280
|
{ column: 'C', value: 'i18n:scenario.emissions', format: { font: { bold: true } } }
|
|
259
281
|
]
|
|
260
282
|
});
|
|
261
|
-
|
|
283
|
+
// Track per-gas rows for ScenarioOutputRefs and for Details back-injection
|
|
284
|
+
let co2Row = -1, ch4Row = -1, n2oRow = -1, totalEmRow = -1;
|
|
285
|
+
if (!multiYear && bldg.emissions) {
|
|
286
|
+
// Single-year (1.3.0): each gas reads its total from the Calc sheet
|
|
262
287
|
const emKeys = ['CO2', 'CH4', 'N2O', 'i18n:general.total'];
|
|
263
288
|
const numMixes = energyMixRows.length;
|
|
264
289
|
calcSheetCurrentRow += 1; // item header
|
|
@@ -293,6 +318,49 @@ export class ScenarioSheetBuilder {
|
|
|
293
318
|
rows.push({ rowIndex: currentRow++, cells: rowCells });
|
|
294
319
|
});
|
|
295
320
|
}
|
|
321
|
+
else if (bldg.emissions) {
|
|
322
|
+
// §2.2 CO2, CH4, N2O rows: col D = Details AVG_COL ref (placeholder), col E = Details CUM_COL ref (placeholder)
|
|
323
|
+
for (const gas of ['CO2', 'CH4', 'N2O']) {
|
|
324
|
+
if (gas === 'CO2')
|
|
325
|
+
co2Row = currentRow;
|
|
326
|
+
if (gas === 'CH4')
|
|
327
|
+
ch4Row = currentRow;
|
|
328
|
+
if (gas === 'N2O')
|
|
329
|
+
n2oRow = currentRow;
|
|
330
|
+
const gasLower = gas.toLowerCase();
|
|
331
|
+
const rowCells = [
|
|
332
|
+
{ column: 'B', value: '', format: c.data.grayFill },
|
|
333
|
+
{ column: 'C', value: `${gas} (tCO2e/i18n:general.yearAbbr)`, format: { font: { bold: true } } },
|
|
334
|
+
// Placeholders replaced in WorkbookGenerator after Details sheet is built
|
|
335
|
+
{ column: 'D', formula: `__DETAILS_AVG_${key}_${gasLower}__`, format: { numberFormat: '#,##0.00', horizontalAlignment: 'Right' } },
|
|
336
|
+
{ column: 'E', formula: `__DETAILS_CUM_${key}_${gasLower}__`, format: { numberFormat: '#,##0.00', horizontalAlignment: 'Right' } }
|
|
337
|
+
];
|
|
338
|
+
rows.push({ rowIndex: currentRow++, cells: rowCells });
|
|
339
|
+
}
|
|
340
|
+
// §2.2 Total emissions row: col D = SUM unchanged, col E = SUM of E rows
|
|
341
|
+
totalEmRow = currentRow;
|
|
342
|
+
const sumFormula = `=SUM(D${co2Row}:D${n2oRow})`;
|
|
343
|
+
const sumFormulaE = `=SUM(E${co2Row}:E${n2oRow})`;
|
|
344
|
+
rows.push({
|
|
345
|
+
rowIndex: currentRow++,
|
|
346
|
+
cells: [
|
|
347
|
+
{ column: 'B', value: '', format: c.data.grayFill },
|
|
348
|
+
{ column: 'C', value: 'i18n:general.total (tCO2e/i18n:general.yearAbbr)', format: { font: { bold: true } } },
|
|
349
|
+
{ column: 'D', formula: sumFormula, format: { numberFormat: '#,##0.00', horizontalAlignment: 'Right' } },
|
|
350
|
+
{ column: 'E', formula: sumFormulaE, format: { numberFormat: '#,##0.00', horizontalAlignment: 'Right' } }
|
|
351
|
+
]
|
|
352
|
+
});
|
|
353
|
+
}
|
|
354
|
+
// Record output row positions for this building type
|
|
355
|
+
buildingOutputRowsMap[key] = {
|
|
356
|
+
totalFloorspaceRow: totalSpaceRow,
|
|
357
|
+
energyUseRow,
|
|
358
|
+
energyMixRows: energyMixRows.map(m => ({ sourceId: m.sourceId, rowIdx: m.rowIdx })),
|
|
359
|
+
co2Row,
|
|
360
|
+
ch4Row,
|
|
361
|
+
n2oRow,
|
|
362
|
+
totalEmissionsRow: totalEmRow
|
|
363
|
+
};
|
|
296
364
|
const outputsEndRow = currentRow - 1;
|
|
297
365
|
// Apply "i18n:scenario.outputs" label to the middle row of the group in Column B
|
|
298
366
|
const outputsMiddleRowIdx = Math.floor((outputsStartRow + outputsEndRow) / 2);
|
|
@@ -390,7 +458,7 @@ export class ScenarioSheetBuilder {
|
|
|
390
458
|
{ column: 'B', value: 'i18n:scenario.modules.service', format: FormattingUtils.header(c.colors.servicesSub) },
|
|
391
459
|
{ column: 'C', value: 'i18n:forms.fields.capitalCosts (i18n:general.total)', format: FormattingUtils.header(c.colors.servicesSub) },
|
|
392
460
|
{ column: 'D', value: 'i18n:forms.fields.maintCosts (i18n:general.total/yr)', format: FormattingUtils.header(c.colors.servicesSub) },
|
|
393
|
-
{ column: 'E', value: '', format: FormattingUtils.header(c.colors.servicesSub) },
|
|
461
|
+
{ column: 'E', value: multiYear ? `i18n:general.maintTotal (${buildYear}\u20132050)` : '', format: FormattingUtils.header(c.colors.servicesSub) },
|
|
394
462
|
]
|
|
395
463
|
});
|
|
396
464
|
const outputsDataStartRow = currentRow;
|
|
@@ -406,6 +474,7 @@ export class ScenarioSheetBuilder {
|
|
|
406
474
|
// Costs read the per-unit rows above, which in turn read the Input sheet.
|
|
407
475
|
const capCell = `C${servicesInputsRows[key]}`;
|
|
408
476
|
const maintCell = `D${servicesInputsRows[key]}`;
|
|
477
|
+
const dataRow = currentRow;
|
|
409
478
|
rows.push({
|
|
410
479
|
rowIndex: currentRow++,
|
|
411
480
|
cells: [
|
|
@@ -420,7 +489,12 @@ export class ScenarioSheetBuilder {
|
|
|
420
489
|
column: 'D',
|
|
421
490
|
formula: new FormulaBuilder().start().ref(srvQtyFormula).multiplyBy(maintCell).build(),
|
|
422
491
|
format: FormattingUtils.currency(0)
|
|
423
|
-
}
|
|
492
|
+
},
|
|
493
|
+
...(multiYear ? [{
|
|
494
|
+
column: 'E',
|
|
495
|
+
formula: `=D${dataRow}*(2050-${buildYear}+1)`,
|
|
496
|
+
format: FormattingUtils.currency(0)
|
|
497
|
+
}] : [])
|
|
424
498
|
]
|
|
425
499
|
});
|
|
426
500
|
}
|
|
@@ -432,9 +506,11 @@ export class ScenarioSheetBuilder {
|
|
|
432
506
|
{ column: 'A', value: '', format: c.data.grayFill },
|
|
433
507
|
{ column: 'B', value: 'i18n:general.total', format: { font: { bold: true } } },
|
|
434
508
|
{ column: 'C', formula: `=SUM(C${outputsDataStartRow}:C${outputsDataEndRow})`, format: { ...FormattingUtils.currency(0), font: { bold: true } } },
|
|
435
|
-
{ column: 'D', formula: `=SUM(D${outputsDataStartRow}:D${outputsDataEndRow})`, format: { ...FormattingUtils.currency(0), font: { bold: true } } }
|
|
509
|
+
{ column: 'D', formula: `=SUM(D${outputsDataStartRow}:D${outputsDataEndRow})`, format: { ...FormattingUtils.currency(0), font: { bold: true } } },
|
|
510
|
+
...(multiYear ? [{ column: 'E', formula: `=SUM(E${outputsDataStartRow}:E${outputsDataEndRow})`, format: { ...FormattingUtils.currency(0), font: { bold: true } } }] : [])
|
|
436
511
|
]
|
|
437
512
|
});
|
|
513
|
+
srvOMTotalRow = currentRow - 1;
|
|
438
514
|
const outputsEndRow = currentRow - 1;
|
|
439
515
|
const outputsMiddleRowIdx = Math.floor((outputsStartRow + outputsEndRow) / 2);
|
|
440
516
|
const outputsMiddleRow = rows.find(r => r.rowIndex === outputsMiddleRowIdx);
|
|
@@ -548,7 +624,7 @@ export class ScenarioSheetBuilder {
|
|
|
548
624
|
{ column: 'B', value: 'i18n:scenario.modules.infrastructure', format: FormattingUtils.header(c.colors.infraSub) },
|
|
549
625
|
{ column: 'C', value: 'i18n:forms.fields.capitalCosts (i18n:general.total)', format: FormattingUtils.header(c.colors.infraSub) },
|
|
550
626
|
{ column: 'D', value: 'i18n:forms.fields.maintCosts (i18n:general.total/yr)', format: FormattingUtils.header(c.colors.infraSub) },
|
|
551
|
-
{ column: 'E', value: '', format: FormattingUtils.header(c.colors.infraSub) },
|
|
627
|
+
{ column: 'E', value: multiYear ? `i18n:general.maintTotal (${buildYear}\u20132050)` : '', format: FormattingUtils.header(c.colors.infraSub) },
|
|
552
628
|
]
|
|
553
629
|
});
|
|
554
630
|
const outputsDataStartRow = currentRow;
|
|
@@ -558,6 +634,7 @@ export class ScenarioSheetBuilder {
|
|
|
558
634
|
const qtyFormula = `C${qtyRows[key]}`;
|
|
559
635
|
const capRef = `C${inputsRows[key]}`;
|
|
560
636
|
const maintRef = `D${inputsRows[key]}`;
|
|
637
|
+
const dataRow = currentRow;
|
|
561
638
|
rows.push({
|
|
562
639
|
rowIndex: currentRow++,
|
|
563
640
|
cells: [
|
|
@@ -572,7 +649,12 @@ export class ScenarioSheetBuilder {
|
|
|
572
649
|
column: 'D',
|
|
573
650
|
formula: new FormulaBuilder().start().ref(qtyFormula).multiplyBy(maintRef).build(),
|
|
574
651
|
format: FormattingUtils.currency(0)
|
|
575
|
-
}
|
|
652
|
+
},
|
|
653
|
+
...(multiYear ? [{
|
|
654
|
+
column: 'E',
|
|
655
|
+
formula: `=D${dataRow}*(2050-${buildYear}+1)`,
|
|
656
|
+
format: FormattingUtils.currency(0)
|
|
657
|
+
}] : [])
|
|
576
658
|
]
|
|
577
659
|
});
|
|
578
660
|
}
|
|
@@ -584,9 +666,11 @@ export class ScenarioSheetBuilder {
|
|
|
584
666
|
{ column: 'A', value: '', format: c.data.grayFill },
|
|
585
667
|
{ column: 'B', value: 'i18n:general.total', format: { font: { bold: true } } },
|
|
586
668
|
{ column: 'C', formula: `=SUM(C${outputsDataStartRow}:C${outputsDataEndRow})`, format: { ...FormattingUtils.currency(0), font: { bold: true } } },
|
|
587
|
-
{ column: 'D', formula: `=SUM(D${outputsDataStartRow}:D${outputsDataEndRow})`, format: { ...FormattingUtils.currency(0), font: { bold: true } } }
|
|
669
|
+
{ column: 'D', formula: `=SUM(D${outputsDataStartRow}:D${outputsDataEndRow})`, format: { ...FormattingUtils.currency(0), font: { bold: true } } },
|
|
670
|
+
...(multiYear ? [{ column: 'E', formula: `=SUM(E${outputsDataStartRow}:E${outputsDataEndRow})`, format: { ...FormattingUtils.currency(0), font: { bold: true } } }] : [])
|
|
588
671
|
]
|
|
589
672
|
});
|
|
673
|
+
infOMTotalRow = currentRow - 1;
|
|
590
674
|
const outputsEndRow = currentRow - 1;
|
|
591
675
|
const outputsMiddleRowIdx = Math.floor((outputsStartRow + outputsEndRow) / 2);
|
|
592
676
|
const outputsMiddleRow = rows.find(r => r.rowIndex === outputsMiddleRowIdx);
|
|
@@ -704,8 +788,22 @@ export class ScenarioSheetBuilder {
|
|
|
704
788
|
}
|
|
705
789
|
if (!isNonMotorized) {
|
|
706
790
|
const outputsStartRow = currentRow;
|
|
791
|
+
// Column-header sub-row: "Average Annual" | "Total (year–2050)"
|
|
792
|
+
if (multiYear)
|
|
793
|
+
rows.push({
|
|
794
|
+
rowIndex: currentRow++,
|
|
795
|
+
cells: [
|
|
796
|
+
{ column: 'B', value: '', format: c.data.grayFill },
|
|
797
|
+
{ column: 'D', value: 'i18n:scenario.avgAnnualEnergyEmissions', format: { font: { bold: true } } },
|
|
798
|
+
{ column: 'E', value: `Total (${buildYear}\u20132050)`, format: { font: { bold: true } } }
|
|
799
|
+
]
|
|
800
|
+
});
|
|
801
|
+
// Multi-year: reference fuel consumption cells in the references section (placeholders replaced
|
|
802
|
+
// after appendAssumptionsAndReferences). Single-year (1.3.0): write the config value into the formula.
|
|
707
803
|
const tptFuelConsumption = transportationConfigFn().transportationTypes[key]?.fuelConsumption || {};
|
|
708
804
|
const energyFormulaParts = energyMixRowsTpt.map(({ sourceId, rowIdx }) => {
|
|
805
|
+
if (multiYear)
|
|
806
|
+
return `D${rowIdx}*__FC_${key}_${sourceId}__`;
|
|
709
807
|
const fc = tptFuelConsumption[sourceId] ?? 0;
|
|
710
808
|
return `D${rowIdx}*${fc}`;
|
|
711
809
|
});
|
|
@@ -720,7 +818,9 @@ export class ScenarioSheetBuilder {
|
|
|
720
818
|
{ column: 'B', value: '', format: c.data.grayFill },
|
|
721
819
|
{ column: 'C', value: 'i18n:scenario.energyUse', format: { font: { bold: true } } },
|
|
722
820
|
{ column: 'D', formula: energyFormula, format: { numberFormat: '#,##0.00', horizontalAlignment: 'Right' } },
|
|
723
|
-
|
|
821
|
+
multiYear
|
|
822
|
+
? { column: 'E', formula: `=D${energyUseRowTpt}*(2050-${buildYear}+1)`, format: { numberFormat: '#,##0.00', horizontalAlignment: 'Right' } }
|
|
823
|
+
: { column: 'E', value: 'GJ/i18n:general.yearAbbr', format: { horizontalAlignment: 'Left' } }
|
|
724
824
|
]
|
|
725
825
|
});
|
|
726
826
|
rows.push({
|
|
@@ -730,7 +830,8 @@ export class ScenarioSheetBuilder {
|
|
|
730
830
|
{ column: 'C', value: 'i18n:scenario.emissions', format: { font: { bold: true } } }
|
|
731
831
|
]
|
|
732
832
|
});
|
|
733
|
-
if (tpt.emissions) {
|
|
833
|
+
if (!multiYear && tpt.emissions) {
|
|
834
|
+
// Single-year (1.3.0): each gas reads its total from the Calc sheet
|
|
734
835
|
const emKeys = ['CO2', 'CH4', 'N2O', 'i18n:general.total'];
|
|
735
836
|
const numMixes = energyMixRowsTpt.length;
|
|
736
837
|
calcSheetCurrentRow += 1;
|
|
@@ -765,7 +866,35 @@ export class ScenarioSheetBuilder {
|
|
|
765
866
|
rows.push({ rowIndex: currentRow++, cells: rowCells });
|
|
766
867
|
});
|
|
767
868
|
}
|
|
869
|
+
else if (tpt.emissions) {
|
|
870
|
+
const emKeys = ['CO2', 'CH4', 'N2O', 'i18n:general.total'];
|
|
871
|
+
const firstTptGasRow = currentRow;
|
|
872
|
+
emKeys.forEach((gas, idx) => {
|
|
873
|
+
const rowCells = [
|
|
874
|
+
{ column: 'B', value: '', format: c.data.grayFill },
|
|
875
|
+
{ column: 'C', value: gas, format: { font: { bold: true } } }
|
|
876
|
+
];
|
|
877
|
+
if (gas === 'i18n:general.total') {
|
|
878
|
+
const sumFormulaD = `=SUM(D${firstTptGasRow}:D${currentRow - 1})`;
|
|
879
|
+
const sumFormulaE = `=SUM(E${firstTptGasRow}:E${currentRow - 1})`;
|
|
880
|
+
rowCells.push({ column: 'D', formula: sumFormulaD, format: { numberFormat: '#,##0.00', horizontalAlignment: 'Right' } });
|
|
881
|
+
rowCells.push({ column: 'E', formula: sumFormulaE, format: { numberFormat: '#,##0.00', horizontalAlignment: 'Right' } });
|
|
882
|
+
}
|
|
883
|
+
else {
|
|
884
|
+
// Placeholders replaced in WorkbookGenerator after Details sheet is built
|
|
885
|
+
const gasLower = gas.toLowerCase();
|
|
886
|
+
rowCells.push({ column: 'D', formula: `__DETAILS_TPT_AVG_${key}_${gasLower}__`, format: { numberFormat: '#,##0.00', horizontalAlignment: 'Right' } });
|
|
887
|
+
rowCells.push({ column: 'E', formula: `__DETAILS_TPT_CUM_${key}_${gasLower}__`, format: { numberFormat: '#,##0.00', horizontalAlignment: 'Right' } });
|
|
888
|
+
}
|
|
889
|
+
rows.push({ rowIndex: currentRow++, cells: rowCells });
|
|
890
|
+
});
|
|
891
|
+
}
|
|
768
892
|
const outputsEndRow = currentRow - 1;
|
|
893
|
+
// Track transport output refs for Details sheet
|
|
894
|
+
transportOutputRowsMap[key] = {
|
|
895
|
+
energyUseRow: energyUseRowTpt,
|
|
896
|
+
energyMixRows: energyMixRowsTpt.map(m => ({ sourceId: m.sourceId, rowIdx: m.rowIdx }))
|
|
897
|
+
};
|
|
769
898
|
const outputsMiddleRowIdx = Math.floor((outputsStartRow + outputsEndRow) / 2);
|
|
770
899
|
const outputsMiddleRow = rows.find(r => r.rowIndex === outputsMiddleRowIdx);
|
|
771
900
|
if (outputsMiddleRow) {
|
|
@@ -803,7 +932,8 @@ export class ScenarioSheetBuilder {
|
|
|
803
932
|
cells: [
|
|
804
933
|
{ column: 'B', value: 'i18n:appConfig.revenue.revenueTypes.developmentCharges', format: { font: { bold: true }, ...revSubHeaderFill } },
|
|
805
934
|
{ column: 'C', value: '$/i18n:general.dwelling', format: { font: { bold: true }, ...revSubHeaderFill, horizontalAlignment: 'Center' } },
|
|
806
|
-
{ column: 'D', value: 'i18n:general.total', format: { font: { bold: true }, ...revSubHeaderFill, horizontalAlignment: 'Center' } },
|
|
935
|
+
{ column: 'D', value: multiYear ? 'i18n:general.total/i18n:general.yearAbbr' : 'i18n:general.total', format: { font: { bold: true }, ...revSubHeaderFill, horizontalAlignment: 'Center' } },
|
|
936
|
+
...(multiYear ? [{ column: 'E', value: `i18n:general.grandTotal (${buildYear}\u20132050)`, format: { font: { bold: true }, ...revSubHeaderFill, horizontalAlignment: 'Center' } }] : []),
|
|
807
937
|
]
|
|
808
938
|
});
|
|
809
939
|
devChargesStartRow = currentRow;
|
|
@@ -820,7 +950,8 @@ export class ScenarioSheetBuilder {
|
|
|
820
950
|
cells: [
|
|
821
951
|
{ column: 'B', value: `i18n:appConfig.buildings.homeTypes.${bType}`, format: { font: { bold: true } } },
|
|
822
952
|
perUnitCell,
|
|
823
|
-
{ column: 'D', formula: `=${refStr}*C${currentRow}`, format: FormattingUtils.currency(0) }
|
|
953
|
+
{ column: 'D', formula: `=${refStr}*C${currentRow}`, format: FormattingUtils.currency(0) },
|
|
954
|
+
...(multiYear ? [{ column: 'E', formula: `=D${currentRow}`, format: FormattingUtils.currency(0) }] : [])
|
|
824
955
|
]
|
|
825
956
|
});
|
|
826
957
|
currentRow++;
|
|
@@ -838,7 +969,8 @@ export class ScenarioSheetBuilder {
|
|
|
838
969
|
cells: [
|
|
839
970
|
{ column: 'B', value: 'i18n:appConfig.revenue.revenueTypes.propertyTaxes', format: { font: { bold: true }, ...revSubHeaderFill } },
|
|
840
971
|
{ column: 'C', value: '$/i18n:general.dwelling/i18n:general.yearAbbr', format: { font: { bold: true }, ...revSubHeaderFill, horizontalAlignment: 'Center' } },
|
|
841
|
-
{ column: 'D', value: 'i18n:general.total/i18n:general.yearAbbr', format: { font: { bold: true }, ...revSubHeaderFill, horizontalAlignment: 'Center' } }
|
|
972
|
+
{ column: 'D', value: 'i18n:general.total/i18n:general.yearAbbr', format: { font: { bold: true }, ...revSubHeaderFill, horizontalAlignment: 'Center' } },
|
|
973
|
+
...(multiYear ? [{ column: 'E', value: `i18n:general.grandTotal (${buildYear}\u20132050)`, format: { font: { bold: true }, ...revSubHeaderFill, horizontalAlignment: 'Center' } }] : [])
|
|
842
974
|
]
|
|
843
975
|
});
|
|
844
976
|
propTaxesStartRow = currentRow;
|
|
@@ -855,7 +987,8 @@ export class ScenarioSheetBuilder {
|
|
|
855
987
|
cells: [
|
|
856
988
|
{ column: 'B', value: `i18n:appConfig.buildings.homeTypes.${bType}`, format: { font: { bold: true } } },
|
|
857
989
|
perUnitCell,
|
|
858
|
-
{ column: 'D', formula: `=${refStr}*C${currentRow}`, format: FormattingUtils.currency(0) }
|
|
990
|
+
{ column: 'D', formula: `=${refStr}*C${currentRow}`, format: FormattingUtils.currency(0) },
|
|
991
|
+
...(multiYear ? [{ column: 'E', formula: `=D${currentRow}*(2050-${buildYear}+1)`, format: FormattingUtils.currency(0) }] : [])
|
|
859
992
|
]
|
|
860
993
|
});
|
|
861
994
|
currentRow++;
|
|
@@ -881,23 +1014,40 @@ export class ScenarioSheetBuilder {
|
|
|
881
1014
|
rowIndex: currentRow++,
|
|
882
1015
|
cells: [
|
|
883
1016
|
{ column: 'C', value: 'i18n:appConfig.revenue.revenueTypes.developmentCharges', format: { font: { bold: true } } },
|
|
884
|
-
{ column: 'D', formula: `=SUM(D${devChargesStartRow}:D${devChargesEndRow})`, format: FormattingUtils.currency(0) }
|
|
1017
|
+
{ column: 'D', formula: `=SUM(D${devChargesStartRow}:D${devChargesEndRow})`, format: FormattingUtils.currency(0) },
|
|
1018
|
+
...(multiYear ? [{ column: 'E', formula: `=SUM(D${devChargesStartRow}:D${devChargesEndRow})`, format: FormattingUtils.currency(0) }] : [])
|
|
885
1019
|
]
|
|
886
1020
|
});
|
|
887
1021
|
}
|
|
888
1022
|
if (propTaxesStartRow !== -1) {
|
|
1023
|
+
propTaxTotalRow = currentRow;
|
|
889
1024
|
rows.push({
|
|
890
1025
|
rowIndex: currentRow++,
|
|
891
1026
|
cells: [
|
|
892
1027
|
{ column: 'C', value: 'i18n:appConfig.revenue.revenueTypes.propertyTaxes', format: { font: { bold: true } } },
|
|
893
|
-
{ column: 'D', formula: `=SUM(D${propTaxesStartRow}:D${propTaxesEndRow})`, format: FormattingUtils.currency(0) }
|
|
1028
|
+
{ column: 'D', formula: `=SUM(D${propTaxesStartRow}:D${propTaxesEndRow})`, format: FormattingUtils.currency(0) },
|
|
1029
|
+
...(multiYear ? [{ column: 'E', formula: `=SUM(E${propTaxesStartRow}:E${propTaxesEndRow})`, format: FormattingUtils.currency(0) }] : [])
|
|
894
1030
|
]
|
|
895
1031
|
});
|
|
896
1032
|
}
|
|
897
1033
|
}
|
|
898
1034
|
currentRow++; // Spacer before Assumptions & References
|
|
899
|
-
this.appendAssumptionsAndReferences(scenario, currentRow, rows, mergedRanges);
|
|
1035
|
+
const { fuelConsumptionRefRows } = this.appendAssumptionsAndReferences(scenario, currentRow, rows, mergedRanges);
|
|
900
1036
|
currentRow = rows[rows.length - 1].rowIndex + 1;
|
|
1037
|
+
// Post-process transportation energy formulas: replace __FC_key_srcId__ placeholders
|
|
1038
|
+
// with cell references to the fuel consumption values in the references section
|
|
1039
|
+
for (const row of rows) {
|
|
1040
|
+
if (!row.cells)
|
|
1041
|
+
continue;
|
|
1042
|
+
for (const cell of row.cells) {
|
|
1043
|
+
if (!cell.formula)
|
|
1044
|
+
continue;
|
|
1045
|
+
cell.formula = cell.formula.replace(/__FC_(\w+)_(\w+)__/g, (_, tKey, srcId) => {
|
|
1046
|
+
const refRow = fuelConsumptionRefRows[tKey]?.[srcId];
|
|
1047
|
+
return refRow !== undefined ? `B${refRow}` : '0';
|
|
1048
|
+
});
|
|
1049
|
+
}
|
|
1050
|
+
}
|
|
901
1051
|
const sheetName = scenario.title.length > 28 ? scenario.title.substring(0, 28) : scenario.title;
|
|
902
1052
|
// Force 'charts' array to exist as requested
|
|
903
1053
|
const charts = [];
|
|
@@ -922,10 +1072,22 @@ export class ScenarioSheetBuilder {
|
|
|
922
1072
|
charts,
|
|
923
1073
|
rows
|
|
924
1074
|
};
|
|
925
|
-
|
|
1075
|
+
const scenarioOutputRefs = {
|
|
1076
|
+
sheetName: sheet.name,
|
|
1077
|
+
buildYear: scenario.year,
|
|
1078
|
+
provId: scenario.provId,
|
|
1079
|
+
buildings: buildingOutputRowsMap,
|
|
1080
|
+
transportation: transportOutputRowsMap,
|
|
1081
|
+
dwellingQtyRows,
|
|
1082
|
+
srvOMTotalRow,
|
|
1083
|
+
infOMTotalRow,
|
|
1084
|
+
propTaxTotalRow
|
|
1085
|
+
};
|
|
1086
|
+
return { sheet, calcContexts, scenarioOutputRefs };
|
|
926
1087
|
}
|
|
927
1088
|
appendAssumptionsAndReferences(scenario, currentRow, rows, mergedRanges) {
|
|
928
1089
|
const c = this.config.theme.scenario;
|
|
1090
|
+
const multiYear = this.config.outputMode === 'multi-year';
|
|
929
1091
|
const energySourcesConfig = energySourcesConfigFn(scenario.provId);
|
|
930
1092
|
const transportationConfig = transportationConfigFn();
|
|
931
1093
|
const buildingsConfig = buildingsConfigFn();
|
|
@@ -1019,14 +1181,31 @@ export class ScenarioSheetBuilder {
|
|
|
1019
1181
|
const transit = transportationConfig.transportationTypes.transit;
|
|
1020
1182
|
const scenarioPuvSources = Object.keys(scenario.transportation?.puv?.energySources || {});
|
|
1021
1183
|
const scenarioTransitSources = Object.keys(scenario.transportation?.transit?.energySources || {});
|
|
1184
|
+
const fuelConsumptionRefRows = { puv: {}, transit: {} };
|
|
1022
1185
|
rows.push({ rowIndex: currentRow++, cells: [{ column: 'A', value: 'i18n:forms.fields.fuelConsumption', format: { font: { bold: true } } }] });
|
|
1023
1186
|
rows.push({ rowIndex: currentRow++, cells: [{ column: 'A', value: 'i18n:appConfig.transportation.transportationTypes.puv', format: { font: { bold: true } } }] });
|
|
1024
1187
|
Object.entries(puv.fuelConsumption || {}).filter(([srcId]) => scenarioPuvSources.includes(srcId)).forEach(([srcId, val]) => {
|
|
1025
|
-
|
|
1188
|
+
fuelConsumptionRefRows['puv'][srcId] = currentRow;
|
|
1189
|
+
rows.push({ rowIndex: currentRow++, cells: multiYear ? [
|
|
1190
|
+
{ column: 'A', value: `i18n:appConfig.energySources.energySources.${srcId}` },
|
|
1191
|
+
{ column: 'B', value: val, format: { numberFormat: '#,##0.00', horizontalAlignment: 'Right' } },
|
|
1192
|
+
{ column: 'C', value: 'MJ/100km', format: { horizontalAlignment: 'Left' } }
|
|
1193
|
+
] : [
|
|
1194
|
+
{ column: 'A', value: `i18n:appConfig.energySources.energySources.${srcId}` },
|
|
1195
|
+
{ column: 'B', value: `${val} MJ/100km`, format: { horizontalAlignment: 'Right' } }
|
|
1196
|
+
] });
|
|
1026
1197
|
});
|
|
1027
1198
|
rows.push({ rowIndex: currentRow++, cells: [{ column: 'A', value: 'i18n:appConfig.transportation.transportationTypes.transit', format: { font: { bold: true } } }] });
|
|
1028
1199
|
Object.entries(transit.fuelConsumption || {}).filter(([srcId]) => scenarioTransitSources.includes(srcId)).forEach(([srcId, val]) => {
|
|
1029
|
-
|
|
1200
|
+
fuelConsumptionRefRows['transit'][srcId] = currentRow;
|
|
1201
|
+
rows.push({ rowIndex: currentRow++, cells: multiYear ? [
|
|
1202
|
+
{ column: 'A', value: `i18n:appConfig.energySources.energySources.${srcId}` },
|
|
1203
|
+
{ column: 'B', value: val, format: { numberFormat: '#,##0.00', horizontalAlignment: 'Right' } },
|
|
1204
|
+
{ column: 'C', value: 'MJ/100km', format: { horizontalAlignment: 'Left' } }
|
|
1205
|
+
] : [
|
|
1206
|
+
{ column: 'A', value: `i18n:appConfig.energySources.energySources.${srcId}` },
|
|
1207
|
+
{ column: 'B', value: `${val} MJ/100km`, format: { horizontalAlignment: 'Right' } }
|
|
1208
|
+
] });
|
|
1030
1209
|
});
|
|
1031
1210
|
// Transportation references from neighbourhood sectorReferences (falls back to global config)
|
|
1032
1211
|
rows.push({ rowIndex: currentRow++, cells: [{ column: 'A', value: 'i18n:general.referencesTitle', format: { font: { bold: true } } }] });
|
|
@@ -1088,5 +1267,6 @@ export class ScenarioSheetBuilder {
|
|
|
1088
1267
|
rows.push({ rowIndex: currentRow++, cells: [{ column: 'A', value: 'CO2' }, { column: 'B', value: 1, format: { horizontalAlignment: 'Right' } }] });
|
|
1089
1268
|
rows.push({ rowIndex: currentRow++, cells: [{ column: 'A', value: 'CH4' }, { column: 'B', value: energySourcesConfig.gwp.values.CH4 || 25, format: { horizontalAlignment: 'Right' } }] });
|
|
1090
1269
|
rows.push({ rowIndex: currentRow++, cells: [{ column: 'A', value: 'N2O' }, { column: 'B', value: energySourcesConfig.gwp.values.N2O || 298, format: { horizontalAlignment: 'Right' } }] });
|
|
1270
|
+
return { fuelConsumptionRefRows };
|
|
1091
1271
|
}
|
|
1092
1272
|
}
|