@carbonbox/domain 0.41.0 → 0.43.0
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/build/carbonbox/carbon-footprint-configurations/corporate-configurations/domain/entity/CorporateCarbonFootprintConfiguration.js +11 -2
- package/build/carbonbox/carbon-footprint-configurations/corporate-configurations/domain/value-objects/CorporateCarbonFootprintConfigurationBaseYear.js +32 -0
- package/build/carbonbox/reporting/report-instances/domain/entity/ReportInstance.js +18 -2
- package/build/carbonbox/reporting/shared/domain/enums/AssuranceLevel.js +23 -0
- package/build/carbonbox/reporting/shared/domain/enums/DataBindingSource.js +15 -0
- package/build/carbonbox/reporting/shared/domain/enums/VerificationType.js +22 -0
- package/build/carbonbox/reporting/shared/domain/exceptions/InvalidReportAssuranceError.js +29 -0
- package/build/carbonbox/reporting/shared/domain/types/ReportAssurancePrimitives.js +2 -0
- package/build/carbonbox/reporting/shared/domain/value-objects/ReportAssurance.js +78 -0
- package/build/carbonbox/shared/domain/enums/ErrorCode.js +1 -0
- package/build/carbonbox/shared/domain/types/BaseYear.js +2 -0
- package/build/carbonbox/shared/domain/types/BaseYearPrimitives.js +2 -0
- package/build/carbonbox/shared/domain/value-objects/BaseYear.js +156 -0
- package/build/main/index.js +30 -18
- package/build/types/carbonbox/carbon-footprint-configurations/corporate-configurations/domain/entity/CorporateCarbonFootprintConfiguration.d.ts +2 -0
- package/build/types/carbonbox/carbon-footprint-configurations/corporate-configurations/domain/entity/CorporateCarbonFootprintConfiguration.d.ts.map +1 -1
- package/build/types/carbonbox/carbon-footprint-configurations/corporate-configurations/domain/entity/ICorporateCarbonFootprintConfiguration.d.ts +2 -0
- package/build/types/carbonbox/carbon-footprint-configurations/corporate-configurations/domain/entity/ICorporateCarbonFootprintConfiguration.d.ts.map +1 -1
- package/build/types/carbonbox/carbon-footprint-configurations/corporate-configurations/domain/types/CorporateCarbonFootprintConfigurationPrimitives.d.ts +2 -0
- package/build/types/carbonbox/carbon-footprint-configurations/corporate-configurations/domain/types/CorporateCarbonFootprintConfigurationPrimitives.d.ts.map +1 -1
- package/build/types/carbonbox/carbon-footprint-configurations/corporate-configurations/domain/types/CorporateCarbonFootprintConfigurationProps.d.ts +2 -0
- package/build/types/carbonbox/carbon-footprint-configurations/corporate-configurations/domain/types/CorporateCarbonFootprintConfigurationProps.d.ts.map +1 -1
- package/build/types/carbonbox/carbon-footprint-configurations/corporate-configurations/domain/value-objects/CorporateCarbonFootprintConfigurationBaseYear.d.ts +10 -0
- package/build/types/carbonbox/carbon-footprint-configurations/corporate-configurations/domain/value-objects/CorporateCarbonFootprintConfigurationBaseYear.d.ts.map +1 -0
- package/build/types/carbonbox/reporting/report-instances/domain/entity/IReportInstance.d.ts +2 -0
- package/build/types/carbonbox/reporting/report-instances/domain/entity/IReportInstance.d.ts.map +1 -1
- package/build/types/carbonbox/reporting/report-instances/domain/entity/ReportInstance.d.ts +4 -0
- package/build/types/carbonbox/reporting/report-instances/domain/entity/ReportInstance.d.ts.map +1 -1
- package/build/types/carbonbox/reporting/report-instances/domain/types/ReportInstancePrimitives.d.ts +2 -0
- package/build/types/carbonbox/reporting/report-instances/domain/types/ReportInstancePrimitives.d.ts.map +1 -1
- package/build/types/carbonbox/reporting/report-instances/domain/types/ReportInstanceProps.d.ts +2 -0
- package/build/types/carbonbox/reporting/report-instances/domain/types/ReportInstanceProps.d.ts.map +1 -1
- package/build/types/carbonbox/reporting/shared/domain/enums/AssuranceLevel.d.ts +20 -0
- package/build/types/carbonbox/reporting/shared/domain/enums/AssuranceLevel.d.ts.map +1 -0
- package/build/types/carbonbox/reporting/shared/domain/enums/DataBindingSource.d.ts +11 -0
- package/build/types/carbonbox/reporting/shared/domain/enums/DataBindingSource.d.ts.map +1 -1
- package/build/types/carbonbox/reporting/shared/domain/enums/VerificationType.d.ts +19 -0
- package/build/types/carbonbox/reporting/shared/domain/enums/VerificationType.d.ts.map +1 -0
- package/build/types/carbonbox/reporting/shared/domain/exceptions/InvalidReportAssuranceError.d.ts +7 -0
- package/build/types/carbonbox/reporting/shared/domain/exceptions/InvalidReportAssuranceError.d.ts.map +1 -0
- package/build/types/carbonbox/reporting/shared/domain/types/ReportAssurancePrimitives.d.ts +13 -0
- package/build/types/carbonbox/reporting/shared/domain/types/ReportAssurancePrimitives.d.ts.map +1 -0
- package/build/types/carbonbox/reporting/shared/domain/value-objects/ReportAssurance.d.ts +26 -0
- package/build/types/carbonbox/reporting/shared/domain/value-objects/ReportAssurance.d.ts.map +1 -0
- package/build/types/carbonbox/shared/domain/enums/ErrorCode.d.ts +1 -0
- package/build/types/carbonbox/shared/domain/enums/ErrorCode.d.ts.map +1 -1
- package/build/types/carbonbox/shared/domain/types/BaseYear.d.ts +8 -0
- package/build/types/carbonbox/shared/domain/types/BaseYear.d.ts.map +1 -0
- package/build/types/carbonbox/shared/domain/types/BaseYearPrimitives.d.ts +8 -0
- package/build/types/carbonbox/shared/domain/types/BaseYearPrimitives.d.ts.map +1 -0
- package/build/types/carbonbox/shared/domain/value-objects/BaseYear.d.ts +46 -0
- package/build/types/carbonbox/shared/domain/value-objects/BaseYear.d.ts.map +1 -0
- package/build/types/main/index.d.ts +9 -0
- package/build/types/main/index.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -10,7 +10,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
10
10
|
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
11
11
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
12
12
|
};
|
|
13
|
-
var _CorporateCarbonFootprintConfiguration_facility, _CorporateCarbonFootprintConfiguration_executionPeriod, _CorporateCarbonFootprintConfiguration_segmentConfigurations;
|
|
13
|
+
var _CorporateCarbonFootprintConfiguration_facility, _CorporateCarbonFootprintConfiguration_executionPeriod, _CorporateCarbonFootprintConfiguration_baseYear, _CorporateCarbonFootprintConfiguration_segmentConfigurations;
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
exports.CorporateCarbonFootprintConfiguration = void 0;
|
|
16
16
|
const CarbonFootprintConfiguration_1 = require("../../../shared/domain/entities/CarbonFootprintConfiguration");
|
|
@@ -19,6 +19,7 @@ const CorporateCarbonFootprintConfigurationCollectionPeriod_1 = require("../valu
|
|
|
19
19
|
const CorporateCarbonFootprintConfigurationName_1 = require("../value-objects/CorporateCarbonFootprintConfigurationName");
|
|
20
20
|
const CorporateCarbonFootprintConfigurationCreatedByStakeholder_1 = require("../value-objects/CorporateCarbonFootprintConfigurationCreatedByStakeholder");
|
|
21
21
|
const CorporateCarbonFootprintConfigurationExecutionPeriod_1 = require("../value-objects/CorporateCarbonFootprintConfigurationExecutionPeriod");
|
|
22
|
+
const CorporateCarbonFootprintConfigurationBaseYear_1 = require("../value-objects/CorporateCarbonFootprintConfigurationBaseYear");
|
|
22
23
|
const CorporateCarbonFootprintConfigurationFacility_1 = require("../value-objects/CorporateCarbonFootprintConfigurationFacility");
|
|
23
24
|
const CorporateCarbonFootprintConfigurationFootprintType_1 = require("../value-objects/CorporateCarbonFootprintConfigurationFootprintType");
|
|
24
25
|
const CorporateCarbonFootprintConfigurationIntensityIndicatorConfigurations_1 = require("../value-objects/CorporateCarbonFootprintConfigurationIntensityIndicatorConfigurations");
|
|
@@ -73,17 +74,20 @@ class CorporateCarbonFootprintConfiguration extends CarbonFootprintConfiguration
|
|
|
73
74
|
}, skipDomainValidation);
|
|
74
75
|
_CorporateCarbonFootprintConfiguration_facility.set(this, void 0);
|
|
75
76
|
_CorporateCarbonFootprintConfiguration_executionPeriod.set(this, void 0);
|
|
77
|
+
_CorporateCarbonFootprintConfiguration_baseYear.set(this, void 0);
|
|
76
78
|
_CorporateCarbonFootprintConfiguration_segmentConfigurations.set(this, void 0);
|
|
77
79
|
if (skipDomainValidation === false) {
|
|
78
80
|
// Initialize with domain validation
|
|
79
81
|
__classPrivateFieldSet(this, _CorporateCarbonFootprintConfiguration_facility, CorporateCarbonFootprintConfigurationFacility_1.CorporateCarbonFootprintConfigurationFacility.create(props.facility), "f");
|
|
80
82
|
__classPrivateFieldSet(this, _CorporateCarbonFootprintConfiguration_executionPeriod, CorporateCarbonFootprintConfigurationExecutionPeriod_1.CorporateCarbonFootprintConfigurationExecutionPeriod.create(props.executionPeriod), "f");
|
|
83
|
+
__classPrivateFieldSet(this, _CorporateCarbonFootprintConfiguration_baseYear, CorporateCarbonFootprintConfigurationBaseYear_1.CorporateCarbonFootprintConfigurationBaseYear.create(props.baseYear), "f");
|
|
81
84
|
__classPrivateFieldSet(this, _CorporateCarbonFootprintConfiguration_segmentConfigurations, CorporateCarbonFootprintConfigurationSegmentConfigurations_1.CorporateCarbonFootprintConfigurationSegmentConfigurations.create(props.segmentConfigurations), "f");
|
|
82
85
|
}
|
|
83
86
|
else {
|
|
84
87
|
// Initialize from primitives (no domain validation)
|
|
85
88
|
__classPrivateFieldSet(this, _CorporateCarbonFootprintConfiguration_facility, CorporateCarbonFootprintConfigurationFacility_1.CorporateCarbonFootprintConfigurationFacility.fromPrimitives(props.facility), "f");
|
|
86
89
|
__classPrivateFieldSet(this, _CorporateCarbonFootprintConfiguration_executionPeriod, CorporateCarbonFootprintConfigurationExecutionPeriod_1.CorporateCarbonFootprintConfigurationExecutionPeriod.fromPrimitives(props.executionPeriod), "f");
|
|
90
|
+
__classPrivateFieldSet(this, _CorporateCarbonFootprintConfiguration_baseYear, CorporateCarbonFootprintConfigurationBaseYear_1.CorporateCarbonFootprintConfigurationBaseYear.fromPrimitives(props.baseYear), "f");
|
|
87
91
|
__classPrivateFieldSet(this, _CorporateCarbonFootprintConfiguration_segmentConfigurations, CorporateCarbonFootprintConfigurationSegmentConfigurations_1.CorporateCarbonFootprintConfigurationSegmentConfigurations.fromPrimitives(props.segmentConfigurations), "f");
|
|
88
92
|
}
|
|
89
93
|
}
|
|
@@ -104,6 +108,7 @@ class CorporateCarbonFootprintConfiguration extends CarbonFootprintConfiguration
|
|
|
104
108
|
createdByStakeholder: primitives.createdByStakeholder,
|
|
105
109
|
facility: primitives.facility,
|
|
106
110
|
executionPeriod: primitives.executionPeriod,
|
|
111
|
+
baseYear: primitives.baseYear,
|
|
107
112
|
segmentConfigurations: primitives.segmentConfigurations,
|
|
108
113
|
};
|
|
109
114
|
return new CorporateCarbonFootprintConfiguration(props, true);
|
|
@@ -122,6 +127,7 @@ class CorporateCarbonFootprintConfiguration extends CarbonFootprintConfiguration
|
|
|
122
127
|
createdByStakeholder: this.createdByStakeholder.toPrimitives(),
|
|
123
128
|
facility: this.facility.toPrimitives(),
|
|
124
129
|
executionPeriod: this.executionPeriod.toPrimitives(),
|
|
130
|
+
baseYear: this.baseYear.toPrimitives(),
|
|
125
131
|
segmentConfigurations: this.segmentConfigurations.toPrimitives(),
|
|
126
132
|
};
|
|
127
133
|
}
|
|
@@ -131,9 +137,12 @@ class CorporateCarbonFootprintConfiguration extends CarbonFootprintConfiguration
|
|
|
131
137
|
get executionPeriod() {
|
|
132
138
|
return __classPrivateFieldGet(this, _CorporateCarbonFootprintConfiguration_executionPeriod, "f");
|
|
133
139
|
}
|
|
140
|
+
get baseYear() {
|
|
141
|
+
return __classPrivateFieldGet(this, _CorporateCarbonFootprintConfiguration_baseYear, "f");
|
|
142
|
+
}
|
|
134
143
|
get segmentConfigurations() {
|
|
135
144
|
return __classPrivateFieldGet(this, _CorporateCarbonFootprintConfiguration_segmentConfigurations, "f");
|
|
136
145
|
}
|
|
137
146
|
}
|
|
138
147
|
exports.CorporateCarbonFootprintConfiguration = CorporateCarbonFootprintConfiguration;
|
|
139
|
-
_CorporateCarbonFootprintConfiguration_facility = new WeakMap(), _CorporateCarbonFootprintConfiguration_executionPeriod = new WeakMap(), _CorporateCarbonFootprintConfiguration_segmentConfigurations = new WeakMap();
|
|
148
|
+
_CorporateCarbonFootprintConfiguration_facility = new WeakMap(), _CorporateCarbonFootprintConfiguration_executionPeriod = new WeakMap(), _CorporateCarbonFootprintConfiguration_baseYear = new WeakMap(), _CorporateCarbonFootprintConfiguration_segmentConfigurations = new WeakMap();
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CorporateCarbonFootprintConfigurationBaseYear = void 0;
|
|
4
|
+
const BaseYear_1 = require("../../../../shared/domain/value-objects/BaseYear");
|
|
5
|
+
class CorporateCarbonFootprintConfigurationBaseYear extends BaseYear_1.BaseYear {
|
|
6
|
+
constructor(value, skipDomainValidation) {
|
|
7
|
+
super(value, skipDomainValidation);
|
|
8
|
+
}
|
|
9
|
+
static create(value) {
|
|
10
|
+
return new CorporateCarbonFootprintConfigurationBaseYear(value, false);
|
|
11
|
+
}
|
|
12
|
+
static fromPrimitives(primitives) {
|
|
13
|
+
const value = {
|
|
14
|
+
startDate: primitives.startDate,
|
|
15
|
+
endDate: primitives.endDate,
|
|
16
|
+
justification: primitives.justification,
|
|
17
|
+
recalculationPolicy: primitives.recalculationPolicy,
|
|
18
|
+
significanceThresholdPercentage: primitives.significanceThresholdPercentage,
|
|
19
|
+
};
|
|
20
|
+
return new CorporateCarbonFootprintConfigurationBaseYear(value, true);
|
|
21
|
+
}
|
|
22
|
+
toPrimitives() {
|
|
23
|
+
return {
|
|
24
|
+
startDate: this.startDate,
|
|
25
|
+
endDate: this.endDate,
|
|
26
|
+
justification: this.justification,
|
|
27
|
+
recalculationPolicy: this.recalculationPolicy,
|
|
28
|
+
significanceThresholdPercentage: this.significanceThresholdPercentage,
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
exports.CorporateCarbonFootprintConfigurationBaseYear = CorporateCarbonFootprintConfigurationBaseYear;
|
|
@@ -10,12 +10,13 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
10
10
|
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
11
11
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
12
12
|
};
|
|
13
|
-
var _ReportInstance_templateId, _ReportInstance_templateVersion, _ReportInstance_carbonClientId, _ReportInstance_period, _ReportInstance_filters, _ReportInstance_questionnaireAnswers, _ReportInstance_dataSnapshot, _ReportInstance_generatedContent, _ReportInstance_pdfUrl, _ReportInstance_status, _ReportInstance_approvals, _ReportInstance_aiExecutions, _ReportInstance_createdAt, _ReportInstance_updatedAt;
|
|
13
|
+
var _ReportInstance_templateId, _ReportInstance_templateVersion, _ReportInstance_carbonClientId, _ReportInstance_period, _ReportInstance_filters, _ReportInstance_questionnaireAnswers, _ReportInstance_assurance, _ReportInstance_dataSnapshot, _ReportInstance_generatedContent, _ReportInstance_pdfUrl, _ReportInstance_status, _ReportInstance_approvals, _ReportInstance_aiExecutions, _ReportInstance_createdAt, _ReportInstance_updatedAt;
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
exports.ReportInstance = void 0;
|
|
16
16
|
const AggregateRoot_1 = require("../../../../shared/domain/entities/AggregateRoot");
|
|
17
17
|
const ReportInstanceId_1 = require("../value-objects/ReportInstanceId");
|
|
18
18
|
const ReportInstanceStatus_1 = require("../enums/ReportInstanceStatus");
|
|
19
|
+
const ReportAssurance_1 = require("../../../shared/domain/value-objects/ReportAssurance");
|
|
19
20
|
const ReportInstanceCannotBeGeneratedError_1 = require("../exceptions/ReportInstanceCannotBeGeneratedError");
|
|
20
21
|
const ReportInstanceCannotBeApprovedInternallyError_1 = require("../exceptions/ReportInstanceCannotBeApprovedInternallyError");
|
|
21
22
|
const ReportInstanceCannotBeApprovedByClientError_1 = require("../exceptions/ReportInstanceCannotBeApprovedByClientError");
|
|
@@ -34,6 +35,7 @@ class ReportInstance extends AggregateRoot_1.AggregateRoot {
|
|
|
34
35
|
_ReportInstance_period.set(this, void 0);
|
|
35
36
|
_ReportInstance_filters.set(this, void 0);
|
|
36
37
|
_ReportInstance_questionnaireAnswers.set(this, void 0);
|
|
38
|
+
_ReportInstance_assurance.set(this, void 0);
|
|
37
39
|
_ReportInstance_dataSnapshot.set(this, void 0);
|
|
38
40
|
_ReportInstance_generatedContent.set(this, void 0);
|
|
39
41
|
_ReportInstance_pdfUrl.set(this, void 0);
|
|
@@ -48,6 +50,10 @@ class ReportInstance extends AggregateRoot_1.AggregateRoot {
|
|
|
48
50
|
__classPrivateFieldSet(this, _ReportInstance_period, props.period, "f");
|
|
49
51
|
__classPrivateFieldSet(this, _ReportInstance_filters, props.filters, "f");
|
|
50
52
|
__classPrivateFieldSet(this, _ReportInstance_questionnaireAnswers, props.questionnaireAnswers, "f");
|
|
53
|
+
// GAP 6: the declaration is validated on create (invariants between level, type and verifier)
|
|
54
|
+
__classPrivateFieldSet(this, _ReportInstance_assurance, skipDomainValidation
|
|
55
|
+
? ReportAssurance_1.ReportAssurance.fromPrimitives(props.assurance)
|
|
56
|
+
: ReportAssurance_1.ReportAssurance.create(props.assurance), "f");
|
|
51
57
|
__classPrivateFieldSet(this, _ReportInstance_dataSnapshot, props.dataSnapshot, "f");
|
|
52
58
|
__classPrivateFieldSet(this, _ReportInstance_generatedContent, props.generatedContent, "f");
|
|
53
59
|
__classPrivateFieldSet(this, _ReportInstance_pdfUrl, props.pdfUrl, "f");
|
|
@@ -80,6 +86,7 @@ class ReportInstance extends AggregateRoot_1.AggregateRoot {
|
|
|
80
86
|
period: primitives.period,
|
|
81
87
|
filters: primitives.filters,
|
|
82
88
|
questionnaireAnswers: primitives.questionnaireAnswers,
|
|
89
|
+
assurance: primitives.assurance,
|
|
83
90
|
dataSnapshot: primitives.dataSnapshot,
|
|
84
91
|
generatedContent: primitives.generatedContent,
|
|
85
92
|
pdfUrl: primitives.pdfUrl,
|
|
@@ -100,6 +107,7 @@ class ReportInstance extends AggregateRoot_1.AggregateRoot {
|
|
|
100
107
|
period: __classPrivateFieldGet(this, _ReportInstance_period, "f"),
|
|
101
108
|
filters: __classPrivateFieldGet(this, _ReportInstance_filters, "f"),
|
|
102
109
|
questionnaireAnswers: __classPrivateFieldGet(this, _ReportInstance_questionnaireAnswers, "f"),
|
|
110
|
+
assurance: __classPrivateFieldGet(this, _ReportInstance_assurance, "f").toPrimitives(),
|
|
103
111
|
dataSnapshot: __classPrivateFieldGet(this, _ReportInstance_dataSnapshot, "f"),
|
|
104
112
|
generatedContent: __classPrivateFieldGet(this, _ReportInstance_generatedContent, "f"),
|
|
105
113
|
pdfUrl: __classPrivateFieldGet(this, _ReportInstance_pdfUrl, "f"),
|
|
@@ -119,6 +127,7 @@ class ReportInstance extends AggregateRoot_1.AggregateRoot {
|
|
|
119
127
|
period: __classPrivateFieldGet(this, _ReportInstance_period, "f"),
|
|
120
128
|
filters: __classPrivateFieldGet(this, _ReportInstance_filters, "f"),
|
|
121
129
|
questionnaireAnswers: __classPrivateFieldGet(this, _ReportInstance_questionnaireAnswers, "f"),
|
|
130
|
+
assurance: __classPrivateFieldGet(this, _ReportInstance_assurance, "f").toPrimitives(),
|
|
122
131
|
dataSnapshot: __classPrivateFieldGet(this, _ReportInstance_dataSnapshot, "f"),
|
|
123
132
|
generatedContent: __classPrivateFieldGet(this, _ReportInstance_generatedContent, "f"),
|
|
124
133
|
pdfUrl: __classPrivateFieldGet(this, _ReportInstance_pdfUrl, "f"),
|
|
@@ -151,6 +160,9 @@ class ReportInstance extends AggregateRoot_1.AggregateRoot {
|
|
|
151
160
|
getQuestionnaireAnswers() {
|
|
152
161
|
return [...__classPrivateFieldGet(this, _ReportInstance_questionnaireAnswers, "f")];
|
|
153
162
|
}
|
|
163
|
+
getAssurance() {
|
|
164
|
+
return __classPrivateFieldGet(this, _ReportInstance_assurance, "f").toPrimitives();
|
|
165
|
+
}
|
|
154
166
|
getDataSnapshot() {
|
|
155
167
|
return __classPrivateFieldGet(this, _ReportInstance_dataSnapshot, "f");
|
|
156
168
|
}
|
|
@@ -363,6 +375,10 @@ class ReportInstance extends AggregateRoot_1.AggregateRoot {
|
|
|
363
375
|
// For now, we assume client approval is always required
|
|
364
376
|
return true;
|
|
365
377
|
}
|
|
378
|
+
/** GAP 6: whether the inventory of this report was verified (limited or reasonable assurance). */
|
|
379
|
+
isVerified() {
|
|
380
|
+
return __classPrivateFieldGet(this, _ReportInstance_assurance, "f").isVerified();
|
|
381
|
+
}
|
|
366
382
|
getApprovalCount() {
|
|
367
383
|
return __classPrivateFieldGet(this, _ReportInstance_approvals, "f").length;
|
|
368
384
|
}
|
|
@@ -381,4 +397,4 @@ class ReportInstance extends AggregateRoot_1.AggregateRoot {
|
|
|
381
397
|
}
|
|
382
398
|
}
|
|
383
399
|
exports.ReportInstance = ReportInstance;
|
|
384
|
-
_ReportInstance_templateId = new WeakMap(), _ReportInstance_templateVersion = new WeakMap(), _ReportInstance_carbonClientId = new WeakMap(), _ReportInstance_period = new WeakMap(), _ReportInstance_filters = new WeakMap(), _ReportInstance_questionnaireAnswers = new WeakMap(), _ReportInstance_dataSnapshot = new WeakMap(), _ReportInstance_generatedContent = new WeakMap(), _ReportInstance_pdfUrl = new WeakMap(), _ReportInstance_status = new WeakMap(), _ReportInstance_approvals = new WeakMap(), _ReportInstance_aiExecutions = new WeakMap(), _ReportInstance_createdAt = new WeakMap(), _ReportInstance_updatedAt = new WeakMap();
|
|
400
|
+
_ReportInstance_templateId = new WeakMap(), _ReportInstance_templateVersion = new WeakMap(), _ReportInstance_carbonClientId = new WeakMap(), _ReportInstance_period = new WeakMap(), _ReportInstance_filters = new WeakMap(), _ReportInstance_questionnaireAnswers = new WeakMap(), _ReportInstance_assurance = new WeakMap(), _ReportInstance_dataSnapshot = new WeakMap(), _ReportInstance_generatedContent = new WeakMap(), _ReportInstance_pdfUrl = new WeakMap(), _ReportInstance_status = new WeakMap(), _ReportInstance_approvals = new WeakMap(), _ReportInstance_aiExecutions = new WeakMap(), _ReportInstance_createdAt = new WeakMap(), _ReportInstance_updatedAt = new WeakMap();
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AssuranceLevel = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Assurance level enumeration (ISO 14064-3)
|
|
6
|
+
* Level of assurance a GHG inventory verification provides, as declared on a report instance
|
|
7
|
+
* (ISO 14064-1 §9.3.1: the report states whether the inventory was verified and at which level)
|
|
8
|
+
*/
|
|
9
|
+
var AssuranceLevel;
|
|
10
|
+
(function (AssuranceLevel) {
|
|
11
|
+
/**
|
|
12
|
+
* The inventory of the reporting period has not been verified
|
|
13
|
+
*/
|
|
14
|
+
AssuranceLevel["NONE"] = "NONE";
|
|
15
|
+
/**
|
|
16
|
+
* Limited assurance: the verifier found nothing indicating the inventory is materially misstated
|
|
17
|
+
*/
|
|
18
|
+
AssuranceLevel["LIMITED"] = "LIMITED";
|
|
19
|
+
/**
|
|
20
|
+
* Reasonable assurance: the verifier affirms the inventory is fairly stated (higher evidence)
|
|
21
|
+
*/
|
|
22
|
+
AssuranceLevel["REASONABLE"] = "REASONABLE";
|
|
23
|
+
})(AssuranceLevel || (exports.AssuranceLevel = AssuranceLevel = {}));
|
|
@@ -52,6 +52,20 @@ var DataBindingSource;
|
|
|
52
52
|
DataBindingSource["AGGREGATION_UNCERTAINTY_RANGE_MIN_TCO2E"] = "aggregation.uncertainty.rangeMinTCO2e";
|
|
53
53
|
DataBindingSource["AGGREGATION_UNCERTAINTY_RANGE_MAX_TCO2E"] = "aggregation.uncertainty.rangeMaxTCO2e";
|
|
54
54
|
DataBindingSource["AGGREGATION_UNCERTAINTY_BY_SOURCE"] = "aggregation.uncertainty.bySource";
|
|
55
|
+
// Base year and recalculation policy (GAP 3, ISO 14064-1 §6.4): declared on the corporate
|
|
56
|
+
// configuration and frozen into the snapshot with the base-year total and the variation
|
|
57
|
+
DataBindingSource["BASE_YEAR_PERIOD"] = "baseYear.period";
|
|
58
|
+
DataBindingSource["BASE_YEAR_TOTAL_TCO2E"] = "baseYear.totalTCO2e";
|
|
59
|
+
DataBindingSource["BASE_YEAR_VARIATION_PERCENTAGE"] = "baseYear.variationPercentage";
|
|
60
|
+
DataBindingSource["BASE_YEAR_JUSTIFICATION"] = "baseYear.justification";
|
|
61
|
+
DataBindingSource["BASE_YEAR_RECALCULATION_POLICY"] = "baseYear.recalculationPolicy";
|
|
62
|
+
DataBindingSource["BASE_YEAR_SIGNIFICANCE_THRESHOLD_PERCENTAGE"] = "baseYear.significanceThresholdPercentage";
|
|
63
|
+
// Assurance (GAP 6, ISO 14064-1 §9.3.1): whether the inventory was verified, by which party and
|
|
64
|
+
// with which level of assurance, as declared on the report instance (not part of the snapshot)
|
|
65
|
+
DataBindingSource["ASSURANCE_LEVEL"] = "assurance.level";
|
|
66
|
+
DataBindingSource["ASSURANCE_VERIFICATION_TYPE"] = "assurance.verificationType";
|
|
67
|
+
DataBindingSource["ASSURANCE_VERIFIER"] = "assurance.verifier";
|
|
68
|
+
DataBindingSource["ASSURANCE_STATEMENT"] = "assurance.statement";
|
|
55
69
|
// Emission Factors
|
|
56
70
|
DataBindingSource["EMISSION_FACTOR_VALUE"] = "emissionFactor.value";
|
|
57
71
|
DataBindingSource["EMISSION_FACTOR_UNIT"] = "emissionFactor.unit";
|
|
@@ -80,6 +94,7 @@ var DataBindingSource;
|
|
|
80
94
|
DataBindingSource["CHART_BY_GAS"] = "chart.byGas";
|
|
81
95
|
DataBindingSource["CHART_TREND_ANALYSIS"] = "chart.trendAnalysis";
|
|
82
96
|
DataBindingSource["CHART_UNCERTAINTY_BY_SOURCE"] = "chart.uncertaintyBySource";
|
|
97
|
+
DataBindingSource["CHART_BASE_YEAR_COMPARISON"] = "chart.baseYearComparison";
|
|
83
98
|
// Facilities/Locations
|
|
84
99
|
DataBindingSource["FACILITIES_COUNT"] = "facilities.count";
|
|
85
100
|
DataBindingSource["FACILITIES_LIST"] = "facilities.list";
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.VerificationType = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Verification type enumeration (ISO 14064-3 / ISO 17029 party types)
|
|
6
|
+
* Who performed the verification of the GHG inventory declared on a report instance
|
|
7
|
+
*/
|
|
8
|
+
var VerificationType;
|
|
9
|
+
(function (VerificationType) {
|
|
10
|
+
/**
|
|
11
|
+
* First-party: internal verification by the organization itself
|
|
12
|
+
*/
|
|
13
|
+
VerificationType["FIRST_PARTY"] = "FIRST_PARTY";
|
|
14
|
+
/**
|
|
15
|
+
* Second-party: verification by a party with a user interest (customer, group company)
|
|
16
|
+
*/
|
|
17
|
+
VerificationType["SECOND_PARTY"] = "SECOND_PARTY";
|
|
18
|
+
/**
|
|
19
|
+
* Third-party: verification by an independent body
|
|
20
|
+
*/
|
|
21
|
+
VerificationType["THIRD_PARTY"] = "THIRD_PARTY";
|
|
22
|
+
})(VerificationType || (exports.VerificationType = VerificationType = {}));
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.InvalidReportAssuranceError = void 0;
|
|
4
|
+
const CodedRootError_1 = require("../../../../shared/domain/exceptions/CodedRootError");
|
|
5
|
+
const ErrorCode_1 = require("../../../../shared/domain/enums/ErrorCode");
|
|
6
|
+
class InvalidReportAssuranceError extends CodedRootError_1.CodedRootError {
|
|
7
|
+
constructor(reason) {
|
|
8
|
+
const technicalMessage = `Invalid report assurance declaration: ${reason}`;
|
|
9
|
+
const context = {
|
|
10
|
+
reason,
|
|
11
|
+
timestamp: new Date().toISOString(),
|
|
12
|
+
};
|
|
13
|
+
const suggestions = [
|
|
14
|
+
'level must be a value of AssuranceLevel (NONE, LIMITED, REASONABLE)',
|
|
15
|
+
'With level NONE, verificationType and verifierName must be null',
|
|
16
|
+
'With level LIMITED or REASONABLE, verificationType must be a value of VerificationType and verifierName a non-empty name',
|
|
17
|
+
'Review the assurance declaration of the report instance',
|
|
18
|
+
];
|
|
19
|
+
super(ErrorCode_1.ErrorCode.INVALID_REPORT_ASSURANCE, technicalMessage, context, suggestions);
|
|
20
|
+
this.name = 'InvalidReportAssuranceError';
|
|
21
|
+
}
|
|
22
|
+
static create(reason) {
|
|
23
|
+
return new InvalidReportAssuranceError(reason);
|
|
24
|
+
}
|
|
25
|
+
logError() {
|
|
26
|
+
return `${this.name}: ${this.technicalMessage}`;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
exports.InvalidReportAssuranceError = InvalidReportAssuranceError;
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ReportAssurance = void 0;
|
|
4
|
+
const ValueObject_1 = require("../../../../shared/domain/value-objects/ValueObject");
|
|
5
|
+
const AssuranceLevel_1 = require("../enums/AssuranceLevel");
|
|
6
|
+
const VerificationType_1 = require("../enums/VerificationType");
|
|
7
|
+
const InvalidReportAssuranceError_1 = require("../exceptions/InvalidReportAssuranceError");
|
|
8
|
+
/**
|
|
9
|
+
* Assurance declaration of a report instance (GAP 6, ISO 14064-1 §9.3.1 / ISO 14064-3).
|
|
10
|
+
* Invariants: with level NONE nothing else is declared; with LIMITED or REASONABLE the
|
|
11
|
+
* verification type and the verifier name are mandatory.
|
|
12
|
+
*/
|
|
13
|
+
class ReportAssurance extends ValueObject_1.ValueObject {
|
|
14
|
+
constructor(value, skipDomainValidation) {
|
|
15
|
+
super(value, skipDomainValidation, ReportAssurance.PROPERTY_NAME, ReportAssurance.EXPECTED_TYPE);
|
|
16
|
+
if (!skipDomainValidation) {
|
|
17
|
+
this.validateReportAssurance(value);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
static create(value) {
|
|
21
|
+
return new ReportAssurance(value, false);
|
|
22
|
+
}
|
|
23
|
+
static fromPrimitives(primitives) {
|
|
24
|
+
return new ReportAssurance(primitives, true);
|
|
25
|
+
}
|
|
26
|
+
static notVerified() {
|
|
27
|
+
return new ReportAssurance({ level: AssuranceLevel_1.AssuranceLevel.NONE, verificationType: null, verifierName: null }, false);
|
|
28
|
+
}
|
|
29
|
+
validateReportAssurance(value) {
|
|
30
|
+
if (!Object.values(AssuranceLevel_1.AssuranceLevel).includes(value.level)) {
|
|
31
|
+
throw InvalidReportAssuranceError_1.InvalidReportAssuranceError.create(`level '${String(value.level)}' is not a value of AssuranceLevel`);
|
|
32
|
+
}
|
|
33
|
+
if (value.level === AssuranceLevel_1.AssuranceLevel.NONE) {
|
|
34
|
+
if (value.verificationType !== null) {
|
|
35
|
+
throw InvalidReportAssuranceError_1.InvalidReportAssuranceError.create('verificationType must be null when the inventory is not verified (level NONE)');
|
|
36
|
+
}
|
|
37
|
+
if (value.verifierName !== null) {
|
|
38
|
+
throw InvalidReportAssuranceError_1.InvalidReportAssuranceError.create('verifierName must be null when the inventory is not verified (level NONE)');
|
|
39
|
+
}
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
if (value.verificationType === null || !Object.values(VerificationType_1.VerificationType).includes(value.verificationType)) {
|
|
43
|
+
throw InvalidReportAssuranceError_1.InvalidReportAssuranceError.create(`verificationType '${String(value.verificationType)}' is required with level ${value.level} and must be a value of VerificationType`);
|
|
44
|
+
}
|
|
45
|
+
if (typeof value.verifierName !== 'string' || value.verifierName.trim() === '') {
|
|
46
|
+
throw InvalidReportAssuranceError_1.InvalidReportAssuranceError.create(`verifierName is required with level ${value.level}`);
|
|
47
|
+
}
|
|
48
|
+
if (value.verifierName.trim().length > ReportAssurance.VERIFIER_NAME_MAX_LENGTH) {
|
|
49
|
+
throw InvalidReportAssuranceError_1.InvalidReportAssuranceError.create(`verifierName cannot exceed ${ReportAssurance.VERIFIER_NAME_MAX_LENGTH} characters`);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
getLevel() {
|
|
53
|
+
return this.value.level;
|
|
54
|
+
}
|
|
55
|
+
getVerificationType() {
|
|
56
|
+
return this.value.verificationType;
|
|
57
|
+
}
|
|
58
|
+
getVerifierName() {
|
|
59
|
+
return this.value.verifierName;
|
|
60
|
+
}
|
|
61
|
+
isVerified() {
|
|
62
|
+
return this.value.level !== AssuranceLevel_1.AssuranceLevel.NONE;
|
|
63
|
+
}
|
|
64
|
+
isIndependentlyVerified() {
|
|
65
|
+
return this.value.verificationType === VerificationType_1.VerificationType.THIRD_PARTY;
|
|
66
|
+
}
|
|
67
|
+
toPrimitives() {
|
|
68
|
+
return {
|
|
69
|
+
level: this.value.level,
|
|
70
|
+
verificationType: this.value.verificationType,
|
|
71
|
+
verifierName: this.value.verifierName === null ? null : this.value.verifierName.trim(),
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
exports.ReportAssurance = ReportAssurance;
|
|
76
|
+
ReportAssurance.PROPERTY_NAME = 'reportAssurance';
|
|
77
|
+
ReportAssurance.EXPECTED_TYPE = 'ReportAssurancePrimitives';
|
|
78
|
+
ReportAssurance.VERIFIER_NAME_MAX_LENGTH = 255;
|
|
@@ -163,6 +163,7 @@ var ErrorCode;
|
|
|
163
163
|
ErrorCode["REPORT_PREPARATION_QUESTIONNAIRE_CANNOT_BE_REOPENED"] = "CBX-RPT-025";
|
|
164
164
|
ErrorCode["INVALID_PREPARATION_QUESTION"] = "CBX-RPT-026";
|
|
165
165
|
ErrorCode["INVALID_REPORT_BLOCK_DATA_BINDING"] = "CBX-RPT-027";
|
|
166
|
+
ErrorCode["INVALID_REPORT_ASSURANCE"] = "CBX-RPT-028";
|
|
166
167
|
// Shared/Common Errors (CBX-SHR-XXX)
|
|
167
168
|
ErrorCode["INVALID_EMAIL"] = "CBX-SHR-001";
|
|
168
169
|
ErrorCode["INVALID_DATE_FORMAT"] = "CBX-SHR-002";
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
3
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
4
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
5
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
6
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
7
|
+
};
|
|
8
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
9
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
10
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
11
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
12
|
+
};
|
|
13
|
+
var _BaseYear_startDate, _BaseYear_endDate, _BaseYear_justification, _BaseYear_recalculationPolicy, _BaseYear_significanceThresholdPercentage;
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.BaseYear = void 0;
|
|
16
|
+
const InvalidPropertyTypeError_1 = require("../exceptions/InvalidPropertyTypeError");
|
|
17
|
+
const InvalidPropertyValueError_1 = require("../exceptions/InvalidPropertyValueError");
|
|
18
|
+
const DateString_1 = require("./DateString");
|
|
19
|
+
const ObjectValueObject_1 = require("./ObjectValueObject");
|
|
20
|
+
const String_1 = require("./String");
|
|
21
|
+
/**
|
|
22
|
+
* Base year of a GHG inventory (ISO 14064-1 §6.4 / GHG Protocol "base year and recalculation
|
|
23
|
+
* policy", GAP 3). Modelled as a DATE RANGE rather than a calendar year so fiscal years
|
|
24
|
+
* (e.g. 1 July 2025 – 30 June 2026) are first-class. Carries the organization's justification
|
|
25
|
+
* for the choice, its recalculation policy and the significance threshold that triggers a
|
|
26
|
+
* recalculation. Immutable; subclasses give it an aggregate-specific name.
|
|
27
|
+
*/
|
|
28
|
+
class BaseYear extends ObjectValueObject_1.ObjectValueObject {
|
|
29
|
+
/**
|
|
30
|
+
* Constructor protegido para que solo clases hijas puedan instanciar.
|
|
31
|
+
* Aplica todas las validaciones de dominio al momento de construcción.
|
|
32
|
+
*/
|
|
33
|
+
constructor(value, skipDomainValidation, propertyName = BaseYear.DEFAULT_PROPERTY_NAME) {
|
|
34
|
+
super(value, skipDomainValidation, propertyName, 'The provided value must be of type BaseYear from the domain layer', { allowNull: false, allowUndefined: false });
|
|
35
|
+
_BaseYear_startDate.set(this, void 0);
|
|
36
|
+
_BaseYear_endDate.set(this, void 0);
|
|
37
|
+
_BaseYear_justification.set(this, void 0);
|
|
38
|
+
_BaseYear_recalculationPolicy.set(this, void 0);
|
|
39
|
+
_BaseYear_significanceThresholdPercentage.set(this, void 0);
|
|
40
|
+
if (skipDomainValidation === false) {
|
|
41
|
+
this.guardAgainstInvalidBaseYear(value);
|
|
42
|
+
}
|
|
43
|
+
__classPrivateFieldSet(this, _BaseYear_startDate, value.startDate, "f");
|
|
44
|
+
__classPrivateFieldSet(this, _BaseYear_endDate, value.endDate, "f");
|
|
45
|
+
__classPrivateFieldSet(this, _BaseYear_justification, value.justification, "f");
|
|
46
|
+
__classPrivateFieldSet(this, _BaseYear_recalculationPolicy, value.recalculationPolicy, "f");
|
|
47
|
+
__classPrivateFieldSet(this, _BaseYear_significanceThresholdPercentage, value.significanceThresholdPercentage, "f");
|
|
48
|
+
}
|
|
49
|
+
guardAgainstInvalidBaseYear(value) {
|
|
50
|
+
this.guardAgainstInvalidDate(value.startDate, 'startDate');
|
|
51
|
+
this.guardAgainstInvalidDate(value.endDate, 'endDate');
|
|
52
|
+
this.guardAgainstInvalidDateRange(value.startDate, value.endDate);
|
|
53
|
+
this.guardAgainstInvalidText(value.justification, 'justification');
|
|
54
|
+
this.guardAgainstInvalidText(value.recalculationPolicy, 'recalculationPolicy');
|
|
55
|
+
this.guardAgainstInvalidSignificanceThreshold(value.significanceThresholdPercentage);
|
|
56
|
+
}
|
|
57
|
+
guardAgainstInvalidDate(date, propertyName) {
|
|
58
|
+
this.guardAgainstNullOrUndefinedValue(date, propertyName);
|
|
59
|
+
String_1.String.guardAgainstInvalidType(date, propertyName);
|
|
60
|
+
String_1.String.guardAgainstEmptyValue(date, propertyName);
|
|
61
|
+
DateString_1.DateString.guardAgainstInvalidDateFormat(date);
|
|
62
|
+
}
|
|
63
|
+
guardAgainstInvalidText(text, propertyName) {
|
|
64
|
+
this.guardAgainstNullOrUndefinedValue(text, propertyName);
|
|
65
|
+
String_1.String.guardAgainstInvalidType(text, propertyName);
|
|
66
|
+
String_1.String.guardAgainstEmptyValue(text, propertyName);
|
|
67
|
+
}
|
|
68
|
+
guardAgainstInvalidDateRange(startDate, endDate) {
|
|
69
|
+
const start = this.parseDate(startDate);
|
|
70
|
+
const end = this.parseDate(endDate);
|
|
71
|
+
if (start >= end) {
|
|
72
|
+
throw InvalidPropertyValueError_1.InvalidPropertyValueError.create('endDate', 'date after start date', `start: ${startDate}, end: ${endDate}`);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
guardAgainstInvalidSignificanceThreshold(percentage) {
|
|
76
|
+
this.guardAgainstNullOrUndefinedValue(percentage, 'significanceThresholdPercentage');
|
|
77
|
+
if (typeof percentage !== 'number' || Number.isNaN(percentage) || !Number.isFinite(percentage)) {
|
|
78
|
+
throw InvalidPropertyTypeError_1.InvalidPropertyTypeError.create('significanceThresholdPercentage', 'finite number', typeof percentage);
|
|
79
|
+
}
|
|
80
|
+
if (percentage < BaseYear.MIN_SIGNIFICANCE_THRESHOLD_PERCENTAGE || percentage > BaseYear.MAX_SIGNIFICANCE_THRESHOLD_PERCENTAGE) {
|
|
81
|
+
throw InvalidPropertyValueError_1.InvalidPropertyValueError.create('significanceThresholdPercentage', `percentage between ${BaseYear.MIN_SIGNIFICANCE_THRESHOLD_PERCENTAGE} and ${BaseYear.MAX_SIGNIFICANCE_THRESHOLD_PERCENTAGE}`, `${percentage}`);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
guardAgainstNullOrUndefinedValue(value, propertyName) {
|
|
85
|
+
if (value === null || value === undefined) {
|
|
86
|
+
throw InvalidPropertyTypeError_1.InvalidPropertyTypeError.create(propertyName, 'non-null value', typeof value);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
parseDate(dateString) {
|
|
90
|
+
const [day, month, year] = dateString.split('/').map(Number);
|
|
91
|
+
return new Date(year, month - 1, day);
|
|
92
|
+
}
|
|
93
|
+
// Getters
|
|
94
|
+
get startDate() {
|
|
95
|
+
return __classPrivateFieldGet(this, _BaseYear_startDate, "f");
|
|
96
|
+
}
|
|
97
|
+
get endDate() {
|
|
98
|
+
return __classPrivateFieldGet(this, _BaseYear_endDate, "f");
|
|
99
|
+
}
|
|
100
|
+
get justification() {
|
|
101
|
+
return __classPrivateFieldGet(this, _BaseYear_justification, "f");
|
|
102
|
+
}
|
|
103
|
+
get recalculationPolicy() {
|
|
104
|
+
return __classPrivateFieldGet(this, _BaseYear_recalculationPolicy, "f");
|
|
105
|
+
}
|
|
106
|
+
get significanceThresholdPercentage() {
|
|
107
|
+
return __classPrivateFieldGet(this, _BaseYear_significanceThresholdPercentage, "f");
|
|
108
|
+
}
|
|
109
|
+
toPrimitives() {
|
|
110
|
+
return {
|
|
111
|
+
startDate: __classPrivateFieldGet(this, _BaseYear_startDate, "f"),
|
|
112
|
+
endDate: __classPrivateFieldGet(this, _BaseYear_endDate, "f"),
|
|
113
|
+
justification: __classPrivateFieldGet(this, _BaseYear_justification, "f"),
|
|
114
|
+
recalculationPolicy: __classPrivateFieldGet(this, _BaseYear_recalculationPolicy, "f"),
|
|
115
|
+
significanceThresholdPercentage: __classPrivateFieldGet(this, _BaseYear_significanceThresholdPercentage, "f"),
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
// Domain methods
|
|
119
|
+
getStartDateAsDate() {
|
|
120
|
+
return this.parseDate(__classPrivateFieldGet(this, _BaseYear_startDate, "f"));
|
|
121
|
+
}
|
|
122
|
+
getEndDateAsDate() {
|
|
123
|
+
return this.parseDate(__classPrivateFieldGet(this, _BaseYear_endDate, "f"));
|
|
124
|
+
}
|
|
125
|
+
/** `DD/MM/YYYY to DD/MM/YYYY`, the label reports print next to the base-year figures. */
|
|
126
|
+
getShortFormattedRange() {
|
|
127
|
+
return `${__classPrivateFieldGet(this, _BaseYear_startDate, "f")} to ${__classPrivateFieldGet(this, _BaseYear_endDate, "f")}`;
|
|
128
|
+
}
|
|
129
|
+
/** True when the base year is not a calendar year (starts on a day other than 1 January). */
|
|
130
|
+
isFiscalYear() {
|
|
131
|
+
const start = this.getStartDateAsDate();
|
|
132
|
+
return start.getMonth() !== 0 || start.getDate() !== 1;
|
|
133
|
+
}
|
|
134
|
+
/** Whether a change of the given magnitude (± %) must trigger a base-year recalculation. */
|
|
135
|
+
requiresRecalculation(changePercentage) {
|
|
136
|
+
return Math.abs(changePercentage) >= __classPrivateFieldGet(this, _BaseYear_significanceThresholdPercentage, "f");
|
|
137
|
+
}
|
|
138
|
+
containsDate(date) {
|
|
139
|
+
return date >= this.getStartDateAsDate() && date <= this.getEndDateAsDate();
|
|
140
|
+
}
|
|
141
|
+
coversSamePeriodAs(startDate, endDate) {
|
|
142
|
+
return __classPrivateFieldGet(this, _BaseYear_startDate, "f") === startDate && __classPrivateFieldGet(this, _BaseYear_endDate, "f") === endDate;
|
|
143
|
+
}
|
|
144
|
+
equals(other) {
|
|
145
|
+
return __classPrivateFieldGet(this, _BaseYear_startDate, "f") === __classPrivateFieldGet(other, _BaseYear_startDate, "f")
|
|
146
|
+
&& __classPrivateFieldGet(this, _BaseYear_endDate, "f") === __classPrivateFieldGet(other, _BaseYear_endDate, "f")
|
|
147
|
+
&& __classPrivateFieldGet(this, _BaseYear_justification, "f") === __classPrivateFieldGet(other, _BaseYear_justification, "f")
|
|
148
|
+
&& __classPrivateFieldGet(this, _BaseYear_recalculationPolicy, "f") === __classPrivateFieldGet(other, _BaseYear_recalculationPolicy, "f")
|
|
149
|
+
&& __classPrivateFieldGet(this, _BaseYear_significanceThresholdPercentage, "f") === __classPrivateFieldGet(other, _BaseYear_significanceThresholdPercentage, "f");
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
exports.BaseYear = BaseYear;
|
|
153
|
+
_BaseYear_startDate = new WeakMap(), _BaseYear_endDate = new WeakMap(), _BaseYear_justification = new WeakMap(), _BaseYear_recalculationPolicy = new WeakMap(), _BaseYear_significanceThresholdPercentage = new WeakMap();
|
|
154
|
+
BaseYear.DEFAULT_PROPERTY_NAME = 'baseYear';
|
|
155
|
+
BaseYear.MIN_SIGNIFICANCE_THRESHOLD_PERCENTAGE = 0;
|
|
156
|
+
BaseYear.MAX_SIGNIFICANCE_THRESHOLD_PERCENTAGE = 100;
|