@carbonbox/domain 0.21.0 → 0.22.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/build/carbonbox/emission-calculation-formulas/calculation-variables/domain/entity/CalculationVariable.js +15 -2
- package/build/carbonbox/emission-calculation-formulas/calculation-variables/domain/types/CalculationVariableOption.js +2 -0
- package/build/carbonbox/emission-calculation-formulas/calculation-variables/domain/types/CalculationVariableOptionOptions.js +2 -0
- package/build/carbonbox/emission-calculation-formulas/calculation-variables/domain/types/CalculationVariableOptionPrimitives.js +2 -0
- package/build/carbonbox/emission-calculation-formulas/calculation-variables/domain/value-objects/CalculationVariableOptions.js +197 -0
- package/build/carbonbox/shared/domain/value-objects/CarbonClientReference.js +33 -13
- package/build/carbonbox/shared/domain/value-objects/CarbonClientReferences.js +24 -10
- package/build/carbonbox/shared/domain/value-objects/StakeholderReference.js +25 -10
- package/build/carbonbox/shared/domain/value-objects/StakeholderReferences.js +34 -18
- package/build/main/index.js +15 -13
- package/build/types/carbonbox/emission-calculation-formulas/calculation-variables/domain/entity/CalculationVariable.d.ts +2 -0
- package/build/types/carbonbox/emission-calculation-formulas/calculation-variables/domain/entity/CalculationVariable.d.ts.map +1 -1
- package/build/types/carbonbox/emission-calculation-formulas/calculation-variables/domain/entity/ICalculationVariable.d.ts +2 -0
- package/build/types/carbonbox/emission-calculation-formulas/calculation-variables/domain/entity/ICalculationVariable.d.ts.map +1 -1
- package/build/types/carbonbox/emission-calculation-formulas/calculation-variables/domain/types/CalculationVariableOption.d.ts +8 -0
- package/build/types/carbonbox/emission-calculation-formulas/calculation-variables/domain/types/CalculationVariableOption.d.ts.map +1 -0
- package/build/types/carbonbox/emission-calculation-formulas/calculation-variables/domain/types/CalculationVariableOptionOptions.d.ts +5 -0
- package/build/types/carbonbox/emission-calculation-formulas/calculation-variables/domain/types/CalculationVariableOptionOptions.d.ts.map +1 -0
- package/build/types/carbonbox/emission-calculation-formulas/calculation-variables/domain/types/CalculationVariableOptionPrimitives.d.ts +8 -0
- package/build/types/carbonbox/emission-calculation-formulas/calculation-variables/domain/types/CalculationVariableOptionPrimitives.d.ts.map +1 -0
- package/build/types/carbonbox/emission-calculation-formulas/calculation-variables/domain/types/CalculationVariablePrimitives.d.ts +2 -0
- package/build/types/carbonbox/emission-calculation-formulas/calculation-variables/domain/types/CalculationVariablePrimitives.d.ts.map +1 -1
- package/build/types/carbonbox/emission-calculation-formulas/calculation-variables/domain/types/CalculationVariableProps.d.ts +2 -0
- package/build/types/carbonbox/emission-calculation-formulas/calculation-variables/domain/types/CalculationVariableProps.d.ts.map +1 -1
- package/build/types/carbonbox/emission-calculation-formulas/calculation-variables/domain/value-objects/CalculationVariableOptions.d.ts +38 -0
- package/build/types/carbonbox/emission-calculation-formulas/calculation-variables/domain/value-objects/CalculationVariableOptions.d.ts.map +1 -0
- package/build/types/carbonbox/shared/domain/types/CarbonClientReference.d.ts +1 -1
- package/build/types/carbonbox/shared/domain/types/CarbonClientReference.d.ts.map +1 -1
- package/build/types/carbonbox/shared/domain/types/CarbonClientReferencePrimitives.d.ts +1 -1
- package/build/types/carbonbox/shared/domain/types/CarbonClientReferencePrimitives.d.ts.map +1 -1
- package/build/types/carbonbox/shared/domain/types/StakeholderReference.d.ts +1 -1
- package/build/types/carbonbox/shared/domain/types/StakeholderReference.d.ts.map +1 -1
- package/build/types/carbonbox/shared/domain/types/StakeholderReferencePrimitives.d.ts +1 -1
- package/build/types/carbonbox/shared/domain/types/StakeholderReferencePrimitives.d.ts.map +1 -1
- package/build/types/carbonbox/shared/domain/value-objects/CarbonClientReference.d.ts +3 -3
- package/build/types/carbonbox/shared/domain/value-objects/CarbonClientReference.d.ts.map +1 -1
- package/build/types/carbonbox/shared/domain/value-objects/CarbonClientReferences.d.ts.map +1 -1
- package/build/types/carbonbox/shared/domain/value-objects/StakeholderReference.d.ts +4 -2
- package/build/types/carbonbox/shared/domain/value-objects/StakeholderReference.d.ts.map +1 -1
- package/build/types/carbonbox/shared/domain/value-objects/StakeholderReferences.d.ts.map +1 -1
- package/build/types/main/index.d.ts +4 -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 _CalculationVariable_code, _CalculationVariable_symbol, _CalculationVariable_name, _CalculationVariable_description, _CalculationVariable_dataType, _CalculationVariable_resolutionStrategy, _CalculationVariable_activityDataConditions, _CalculationVariable_defaultValue;
|
|
13
|
+
var _CalculationVariable_code, _CalculationVariable_symbol, _CalculationVariable_name, _CalculationVariable_description, _CalculationVariable_dataType, _CalculationVariable_resolutionStrategy, _CalculationVariable_activityDataConditions, _CalculationVariable_defaultValue, _CalculationVariable_options;
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
exports.CalculationVariable = void 0;
|
|
16
16
|
const AggregateRoot_1 = require("../../../../shared/domain/entities/AggregateRoot");
|
|
@@ -21,6 +21,7 @@ const CalculationVariableDefaultValue_1 = require("../value-objects/CalculationV
|
|
|
21
21
|
const CalculationVariableDescription_1 = require("../value-objects/CalculationVariableDescription");
|
|
22
22
|
const CalculationVariableId_1 = require("../value-objects/CalculationVariableId");
|
|
23
23
|
const CalculationVariableName_1 = require("../value-objects/CalculationVariableName");
|
|
24
|
+
const CalculationVariableOptions_1 = require("../value-objects/CalculationVariableOptions");
|
|
24
25
|
const CalculationVariableResolutionStrategy_1 = require("../value-objects/CalculationVariableResolutionStrategy");
|
|
25
26
|
const CalculationVariableSymbol_1 = require("../value-objects/CalculationVariableSymbol");
|
|
26
27
|
const InvalidCalculationVariableActivityDataConditionsForStrategyError_1 = require("../exceptions/InvalidCalculationVariableActivityDataConditionsForStrategyError");
|
|
@@ -38,6 +39,7 @@ class CalculationVariable extends AggregateRoot_1.AggregateRoot {
|
|
|
38
39
|
_CalculationVariable_resolutionStrategy.set(this, void 0);
|
|
39
40
|
_CalculationVariable_activityDataConditions.set(this, void 0);
|
|
40
41
|
_CalculationVariable_defaultValue.set(this, void 0);
|
|
42
|
+
_CalculationVariable_options.set(this, void 0);
|
|
41
43
|
if (skipDomainValidation === false) {
|
|
42
44
|
// Initialize with domain validation
|
|
43
45
|
__classPrivateFieldSet(this, _CalculationVariable_code, CalculationVariableCode_1.CalculationVariableCode.create(props.code), "f");
|
|
@@ -48,6 +50,9 @@ class CalculationVariable extends AggregateRoot_1.AggregateRoot {
|
|
|
48
50
|
__classPrivateFieldSet(this, _CalculationVariable_resolutionStrategy, CalculationVariableResolutionStrategy_1.CalculationVariableResolutionStrategy.create(props.resolutionStrategy), "f");
|
|
49
51
|
__classPrivateFieldSet(this, _CalculationVariable_activityDataConditions, CalculationVariableActivityDataConditions_1.CalculationVariableActivityDataConditions.create(props.activityDataConditions), "f");
|
|
50
52
|
__classPrivateFieldSet(this, _CalculationVariable_defaultValue, CalculationVariableDefaultValue_1.CalculationVariableDefaultValue.create(props.defaultValue), "f");
|
|
53
|
+
__classPrivateFieldSet(this, _CalculationVariable_options, props.options !== null
|
|
54
|
+
? CalculationVariableOptions_1.CalculationVariableOptions.create(props.options)
|
|
55
|
+
: CalculationVariableOptions_1.CalculationVariableOptions.create([]), "f");
|
|
51
56
|
}
|
|
52
57
|
else {
|
|
53
58
|
// Initialize from primitives (no per-VO domain validation)
|
|
@@ -59,6 +64,9 @@ class CalculationVariable extends AggregateRoot_1.AggregateRoot {
|
|
|
59
64
|
__classPrivateFieldSet(this, _CalculationVariable_resolutionStrategy, CalculationVariableResolutionStrategy_1.CalculationVariableResolutionStrategy.fromPrimitives(props.resolutionStrategy), "f");
|
|
60
65
|
__classPrivateFieldSet(this, _CalculationVariable_activityDataConditions, CalculationVariableActivityDataConditions_1.CalculationVariableActivityDataConditions.fromPrimitives(props.activityDataConditions), "f");
|
|
61
66
|
__classPrivateFieldSet(this, _CalculationVariable_defaultValue, CalculationVariableDefaultValue_1.CalculationVariableDefaultValue.fromPrimitives(props.defaultValue), "f");
|
|
67
|
+
__classPrivateFieldSet(this, _CalculationVariable_options, props.options !== null
|
|
68
|
+
? CalculationVariableOptions_1.CalculationVariableOptions.fromPrimitives(props.options)
|
|
69
|
+
: CalculationVariableOptions_1.CalculationVariableOptions.fromPrimitives([]), "f");
|
|
62
70
|
}
|
|
63
71
|
// Cross-field invariant is enforced ALWAYS, even when constructing
|
|
64
72
|
// via `fromPrimitives`. Per-VO validation can be skipped (because
|
|
@@ -82,6 +90,7 @@ class CalculationVariable extends AggregateRoot_1.AggregateRoot {
|
|
|
82
90
|
resolutionStrategy: primitives.resolutionStrategy,
|
|
83
91
|
activityDataConditions: primitives.activityDataConditions,
|
|
84
92
|
defaultValue: primitives.defaultValue,
|
|
93
|
+
options: primitives.options,
|
|
85
94
|
};
|
|
86
95
|
return new CalculationVariable(props, true);
|
|
87
96
|
}
|
|
@@ -96,6 +105,7 @@ class CalculationVariable extends AggregateRoot_1.AggregateRoot {
|
|
|
96
105
|
resolutionStrategy: __classPrivateFieldGet(this, _CalculationVariable_resolutionStrategy, "f").toPrimitives(),
|
|
97
106
|
activityDataConditions: __classPrivateFieldGet(this, _CalculationVariable_activityDataConditions, "f").toPrimitives(),
|
|
98
107
|
defaultValue: __classPrivateFieldGet(this, _CalculationVariable_defaultValue, "f").toPrimitives(),
|
|
108
|
+
options: __classPrivateFieldGet(this, _CalculationVariable_options, "f").isEmpty() ? null : __classPrivateFieldGet(this, _CalculationVariable_options, "f").toPrimitives(),
|
|
99
109
|
};
|
|
100
110
|
}
|
|
101
111
|
get code() {
|
|
@@ -122,6 +132,9 @@ class CalculationVariable extends AggregateRoot_1.AggregateRoot {
|
|
|
122
132
|
get defaultValue() {
|
|
123
133
|
return __classPrivateFieldGet(this, _CalculationVariable_defaultValue, "f");
|
|
124
134
|
}
|
|
135
|
+
get options() {
|
|
136
|
+
return __classPrivateFieldGet(this, _CalculationVariable_options, "f");
|
|
137
|
+
}
|
|
125
138
|
/**
|
|
126
139
|
* Cross-field invariant: the relationship between `resolutionStrategy`
|
|
127
140
|
* and `activityDataConditions` is owned by the aggregate root, not by
|
|
@@ -145,4 +158,4 @@ class CalculationVariable extends AggregateRoot_1.AggregateRoot {
|
|
|
145
158
|
}
|
|
146
159
|
}
|
|
147
160
|
exports.CalculationVariable = CalculationVariable;
|
|
148
|
-
_CalculationVariable_code = new WeakMap(), _CalculationVariable_symbol = new WeakMap(), _CalculationVariable_name = new WeakMap(), _CalculationVariable_description = new WeakMap(), _CalculationVariable_dataType = new WeakMap(), _CalculationVariable_resolutionStrategy = new WeakMap(), _CalculationVariable_activityDataConditions = new WeakMap(), _CalculationVariable_defaultValue = new WeakMap();
|
|
161
|
+
_CalculationVariable_code = new WeakMap(), _CalculationVariable_symbol = new WeakMap(), _CalculationVariable_name = new WeakMap(), _CalculationVariable_description = new WeakMap(), _CalculationVariable_dataType = new WeakMap(), _CalculationVariable_resolutionStrategy = new WeakMap(), _CalculationVariable_activityDataConditions = new WeakMap(), _CalculationVariable_defaultValue = new WeakMap(), _CalculationVariable_options = new WeakMap();
|
|
@@ -0,0 +1,197 @@
|
|
|
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 _a, _CalculationVariableOptions_options, _CalculationVariableOptions_guardAgainstInvalidType, _CalculationVariableOptions_guardAgainstInvalidEmptyArray, _CalculationVariableOptions_guardAgainstDuplicatedValues, _CalculationVariableOptions_guardAgainstDuplicatedDisplayOrders, _CalculationVariableOptions_guardAgainstInvalidOption;
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.CalculationVariableOptions = void 0;
|
|
16
|
+
const ValueObject_1 = require("../../../../shared/domain/value-objects/ValueObject");
|
|
17
|
+
const String_1 = require("../../../../shared/domain/value-objects/String");
|
|
18
|
+
const PositiveInteger_1 = require("../../../../shared/domain/value-objects/PositiveInteger");
|
|
19
|
+
const InvalidPropertyTypeError_1 = require("../../../../shared/domain/exceptions/InvalidPropertyTypeError");
|
|
20
|
+
const InvalidPropertyValueError_1 = require("../../../../shared/domain/exceptions/InvalidPropertyValueError");
|
|
21
|
+
/**
|
|
22
|
+
* Structured list of selectable options for a `dataType === SELECT` calculation
|
|
23
|
+
* variable (e.g. tipo de combustible: Diesel / Gasolina / Eléctrico). Mirrors the
|
|
24
|
+
* canonical `CollectionFieldOptions` value object (`FieldOption` shape) but lives
|
|
25
|
+
* in the `calculation-variables` bounded context so the two contexts stay
|
|
26
|
+
* independent.
|
|
27
|
+
*
|
|
28
|
+
* The value object is permissive (`allowEmpty: true`): a SELECT variable can exist
|
|
29
|
+
* with an empty list initially. Whether options are required/forbidden for a given
|
|
30
|
+
* `dataType` is an application-layer concern (gated in the Create/Update DTO +
|
|
31
|
+
* handler against `DataTypeEnum.SELECT`), exactly like `CollectionFieldOptions`.
|
|
32
|
+
*/
|
|
33
|
+
class CalculationVariableOptions extends ValueObject_1.ValueObject {
|
|
34
|
+
constructor(value, skipDomainValidation, propertyName = _a.DEFAULT_PROPERTY_NAME, options = _a.DEFAULT_OPTIONS) {
|
|
35
|
+
const finalOptions = { ..._a.DEFAULT_OPTIONS, ...options };
|
|
36
|
+
if (skipDomainValidation === false) {
|
|
37
|
+
_a.validateOptions(value, propertyName, finalOptions);
|
|
38
|
+
}
|
|
39
|
+
const primitives = _a.toPrimitivesArray(value);
|
|
40
|
+
super(primitives, skipDomainValidation, propertyName, 'The provided value must be an array of CalculationVariableOption from the domain layer');
|
|
41
|
+
_CalculationVariableOptions_options.set(this, void 0);
|
|
42
|
+
__classPrivateFieldSet(this, _CalculationVariableOptions_options, _a.toCleanOptions(value), "f");
|
|
43
|
+
}
|
|
44
|
+
static create(value) {
|
|
45
|
+
return new _a(value, false);
|
|
46
|
+
}
|
|
47
|
+
static fromPrimitives(primitives) {
|
|
48
|
+
const value = primitives.map((primitive) => ({
|
|
49
|
+
value: primitive.value,
|
|
50
|
+
label: primitive.label,
|
|
51
|
+
displayOrder: primitive.displayOrder,
|
|
52
|
+
isActive: primitive.isActive,
|
|
53
|
+
metadata: primitive.metadata,
|
|
54
|
+
}));
|
|
55
|
+
return new _a(value, true);
|
|
56
|
+
}
|
|
57
|
+
static validateOptions(value, propertyName, options) {
|
|
58
|
+
__classPrivateFieldGet(this, _a, "m", _CalculationVariableOptions_guardAgainstInvalidType).call(this, value, propertyName);
|
|
59
|
+
__classPrivateFieldGet(this, _a, "m", _CalculationVariableOptions_guardAgainstInvalidEmptyArray).call(this, value, options, propertyName);
|
|
60
|
+
if (options.allowDuplicates === false) {
|
|
61
|
+
__classPrivateFieldGet(this, _a, "m", _CalculationVariableOptions_guardAgainstDuplicatedValues).call(this, value, propertyName);
|
|
62
|
+
}
|
|
63
|
+
value.forEach((option, index) => {
|
|
64
|
+
__classPrivateFieldGet(this, _a, "m", _CalculationVariableOptions_guardAgainstInvalidOption).call(this, option, index, propertyName);
|
|
65
|
+
});
|
|
66
|
+
__classPrivateFieldGet(this, _a, "m", _CalculationVariableOptions_guardAgainstDuplicatedDisplayOrders).call(this, value, propertyName);
|
|
67
|
+
}
|
|
68
|
+
static toPrimitivesArray(value) {
|
|
69
|
+
return value.map((option) => ({
|
|
70
|
+
value: option.value.trim(),
|
|
71
|
+
label: option.label.trim(),
|
|
72
|
+
displayOrder: option.displayOrder,
|
|
73
|
+
isActive: option.isActive,
|
|
74
|
+
metadata: option.metadata,
|
|
75
|
+
}));
|
|
76
|
+
}
|
|
77
|
+
static toCleanOptions(value) {
|
|
78
|
+
return value.map((option) => ({
|
|
79
|
+
value: option.value.trim(),
|
|
80
|
+
label: option.label.trim(),
|
|
81
|
+
displayOrder: option.displayOrder,
|
|
82
|
+
isActive: option.isActive,
|
|
83
|
+
metadata: option.metadata,
|
|
84
|
+
}));
|
|
85
|
+
}
|
|
86
|
+
get options() {
|
|
87
|
+
return Object.freeze([...__classPrivateFieldGet(this, _CalculationVariableOptions_options, "f")]);
|
|
88
|
+
}
|
|
89
|
+
get count() {
|
|
90
|
+
return __classPrivateFieldGet(this, _CalculationVariableOptions_options, "f").length;
|
|
91
|
+
}
|
|
92
|
+
isEmpty() {
|
|
93
|
+
return __classPrivateFieldGet(this, _CalculationVariableOptions_options, "f").length === 0;
|
|
94
|
+
}
|
|
95
|
+
hasOptions() {
|
|
96
|
+
return __classPrivateFieldGet(this, _CalculationVariableOptions_options, "f").length > 0;
|
|
97
|
+
}
|
|
98
|
+
getValues() {
|
|
99
|
+
return __classPrivateFieldGet(this, _CalculationVariableOptions_options, "f").map((option) => option.value);
|
|
100
|
+
}
|
|
101
|
+
getByValue(value) {
|
|
102
|
+
return __classPrivateFieldGet(this, _CalculationVariableOptions_options, "f").find((option) => option.value.toUpperCase() === value.trim().toUpperCase());
|
|
103
|
+
}
|
|
104
|
+
hasValue(value) {
|
|
105
|
+
return __classPrivateFieldGet(this, _CalculationVariableOptions_options, "f").some((option) => option.value.toUpperCase() === value.trim().toUpperCase());
|
|
106
|
+
}
|
|
107
|
+
sortByDisplayOrder() {
|
|
108
|
+
return [...__classPrivateFieldGet(this, _CalculationVariableOptions_options, "f")].sort((a, b) => a.displayOrder - b.displayOrder);
|
|
109
|
+
}
|
|
110
|
+
equals(other) {
|
|
111
|
+
if (!(other instanceof _a)) {
|
|
112
|
+
return false;
|
|
113
|
+
}
|
|
114
|
+
if (__classPrivateFieldGet(this, _CalculationVariableOptions_options, "f").length !== __classPrivateFieldGet(other, _CalculationVariableOptions_options, "f").length) {
|
|
115
|
+
return false;
|
|
116
|
+
}
|
|
117
|
+
const thisValues = new Set(this.getValues().map((v) => v.toUpperCase()));
|
|
118
|
+
const otherValues = new Set(other.getValues().map((v) => v.toUpperCase()));
|
|
119
|
+
if (thisValues.size !== otherValues.size) {
|
|
120
|
+
return false;
|
|
121
|
+
}
|
|
122
|
+
for (const value of thisValues) {
|
|
123
|
+
if (otherValues.has(value) === false) {
|
|
124
|
+
return false;
|
|
125
|
+
}
|
|
126
|
+
const thisOption = this.getByValue(value);
|
|
127
|
+
const otherOption = other.getByValue(value);
|
|
128
|
+
if (thisOption?.label !== otherOption?.label
|
|
129
|
+
|| thisOption?.displayOrder !== otherOption?.displayOrder
|
|
130
|
+
|| thisOption?.isActive !== otherOption?.isActive) {
|
|
131
|
+
return false;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
return true;
|
|
135
|
+
}
|
|
136
|
+
toPrimitives() {
|
|
137
|
+
return __classPrivateFieldGet(this, _CalculationVariableOptions_options, "f").map((option) => ({
|
|
138
|
+
value: option.value,
|
|
139
|
+
label: option.label,
|
|
140
|
+
displayOrder: option.displayOrder,
|
|
141
|
+
isActive: option.isActive,
|
|
142
|
+
metadata: option.metadata,
|
|
143
|
+
}));
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
exports.CalculationVariableOptions = CalculationVariableOptions;
|
|
147
|
+
_a = CalculationVariableOptions, _CalculationVariableOptions_options = new WeakMap(), _CalculationVariableOptions_guardAgainstInvalidType = function _CalculationVariableOptions_guardAgainstInvalidType(value, propertyName) {
|
|
148
|
+
if (Array.isArray(value) === false) {
|
|
149
|
+
throw InvalidPropertyTypeError_1.InvalidPropertyTypeError.create(propertyName, 'array of CalculationVariableOption', typeof value);
|
|
150
|
+
}
|
|
151
|
+
}, _CalculationVariableOptions_guardAgainstInvalidEmptyArray = function _CalculationVariableOptions_guardAgainstInvalidEmptyArray(value, options, propertyName) {
|
|
152
|
+
if (options.allowEmpty === false && value.length === 0) {
|
|
153
|
+
throw InvalidPropertyValueError_1.InvalidPropertyValueError.create(propertyName, 'non-empty array', 'empty array');
|
|
154
|
+
}
|
|
155
|
+
}, _CalculationVariableOptions_guardAgainstDuplicatedValues = function _CalculationVariableOptions_guardAgainstDuplicatedValues(value, propertyName) {
|
|
156
|
+
const values = value.map((option) => option.value.trim().toUpperCase());
|
|
157
|
+
const uniqueValues = new Set(values);
|
|
158
|
+
if (values.length !== uniqueValues.size) {
|
|
159
|
+
throw InvalidPropertyValueError_1.InvalidPropertyValueError.create(`${propertyName}.values`, 'array with unique option values', 'array with duplicated option values');
|
|
160
|
+
}
|
|
161
|
+
}, _CalculationVariableOptions_guardAgainstDuplicatedDisplayOrders = function _CalculationVariableOptions_guardAgainstDuplicatedDisplayOrders(value, propertyName) {
|
|
162
|
+
const displayOrders = value.map((option) => option.displayOrder);
|
|
163
|
+
const uniqueDisplayOrders = new Set(displayOrders);
|
|
164
|
+
if (displayOrders.length !== uniqueDisplayOrders.size) {
|
|
165
|
+
throw InvalidPropertyValueError_1.InvalidPropertyValueError.create(`${propertyName}.displayOrders`, 'array with unique display orders', 'array with duplicated display orders');
|
|
166
|
+
}
|
|
167
|
+
}, _CalculationVariableOptions_guardAgainstInvalidOption = function _CalculationVariableOptions_guardAgainstInvalidOption(option, index, basePropertyName) {
|
|
168
|
+
const propertyName = `${basePropertyName}[${index}]`;
|
|
169
|
+
if (option === null || option === undefined || typeof option !== 'object') {
|
|
170
|
+
throw InvalidPropertyTypeError_1.InvalidPropertyTypeError.create(propertyName, 'CalculationVariableOption object', typeof option);
|
|
171
|
+
}
|
|
172
|
+
if (typeof option.value !== 'string') {
|
|
173
|
+
throw InvalidPropertyTypeError_1.InvalidPropertyTypeError.create(`${propertyName}.value`, 'string', typeof option.value);
|
|
174
|
+
}
|
|
175
|
+
if (typeof option.label !== 'string') {
|
|
176
|
+
throw InvalidPropertyTypeError_1.InvalidPropertyTypeError.create(`${propertyName}.label`, 'string', typeof option.label);
|
|
177
|
+
}
|
|
178
|
+
if (typeof option.displayOrder !== 'number') {
|
|
179
|
+
throw InvalidPropertyTypeError_1.InvalidPropertyTypeError.create(`${propertyName}.displayOrder`, 'number', typeof option.displayOrder);
|
|
180
|
+
}
|
|
181
|
+
if (typeof option.isActive !== 'boolean') {
|
|
182
|
+
throw InvalidPropertyTypeError_1.InvalidPropertyTypeError.create(`${propertyName}.isActive`, 'boolean', typeof option.isActive);
|
|
183
|
+
}
|
|
184
|
+
if (option.metadata !== null && typeof option.metadata !== 'object') {
|
|
185
|
+
throw InvalidPropertyTypeError_1.InvalidPropertyTypeError.create(`${propertyName}.metadata`, 'object or null', typeof option.metadata);
|
|
186
|
+
}
|
|
187
|
+
String_1.String.guardAgainstEmptyValue(option.value, `${propertyName}.value`);
|
|
188
|
+
String_1.String.guardAgainstEmptyValue(option.label, `${propertyName}.label`);
|
|
189
|
+
if (!PositiveInteger_1.PositiveInteger.isValidPositiveInteger(option.displayOrder)) {
|
|
190
|
+
throw InvalidPropertyTypeError_1.InvalidPropertyTypeError.create(`${propertyName}.displayOrder`, 'positive integer', option.displayOrder.toString());
|
|
191
|
+
}
|
|
192
|
+
};
|
|
193
|
+
CalculationVariableOptions.DEFAULT_PROPERTY_NAME = 'calculationVariableOptions';
|
|
194
|
+
CalculationVariableOptions.DEFAULT_OPTIONS = {
|
|
195
|
+
allowEmpty: true, // SELECT variables can be created without options initially
|
|
196
|
+
allowDuplicates: false, // Option values must be unique
|
|
197
|
+
};
|
|
@@ -31,6 +31,7 @@ class CarbonClientReference extends ObjectValueObject_1.ObjectValueObject {
|
|
|
31
31
|
super(value, skipDomainValidation, propertyName, 'The provided value must be of type CarbonClientReference from the domain layer', { allowNull: false, allowUndefined: false });
|
|
32
32
|
_CarbonClientReference_id.set(this, void 0);
|
|
33
33
|
_CarbonClientReference_displayName.set(this, void 0);
|
|
34
|
+
// USR-020: una referencia a una persona natural puede no tener identificación tributaria.
|
|
34
35
|
_CarbonClientReference_taxIdentification.set(this, void 0);
|
|
35
36
|
_CarbonClientReference_roleType.set(this, void 0);
|
|
36
37
|
_CarbonClientReference_accountType.set(this, void 0);
|
|
@@ -67,8 +68,8 @@ class CarbonClientReference extends ObjectValueObject_1.ObjectValueObject {
|
|
|
67
68
|
if (typeof value.displayName !== 'string') {
|
|
68
69
|
throw InvalidPropertyTypeError_1.InvalidPropertyTypeError.create('displayName', 'string', typeof value.displayName);
|
|
69
70
|
}
|
|
70
|
-
if (this.taxIdentificationIsInvalid(value.taxIdentification)) {
|
|
71
|
-
throw InvalidPropertyTypeError_1.InvalidPropertyTypeError.create('taxIdentification', 'TaxIdentification object', typeof value.taxIdentification);
|
|
71
|
+
if (value.taxIdentification !== null && this.taxIdentificationIsInvalid(value.taxIdentification)) {
|
|
72
|
+
throw InvalidPropertyTypeError_1.InvalidPropertyTypeError.create('taxIdentification', 'TaxIdentification object | null', typeof value.taxIdentification);
|
|
72
73
|
}
|
|
73
74
|
if (typeof value.roleType !== 'string') {
|
|
74
75
|
throw InvalidPropertyTypeError_1.InvalidPropertyTypeError.create('roleType', 'string', typeof value.roleType);
|
|
@@ -112,8 +113,9 @@ class CarbonClientReference extends ObjectValueObject_1.ObjectValueObject {
|
|
|
112
113
|
* Valida la identificación tributaria usando las validaciones del VO TaxIdentification.
|
|
113
114
|
*/
|
|
114
115
|
static guardAgainstInvalidTaxIdentification(taxIdentification) {
|
|
116
|
+
// USR-020: null es válido (persona natural sin identificación tributaria).
|
|
115
117
|
if (this.taxIdentificationIsNull(taxIdentification)) {
|
|
116
|
-
|
|
118
|
+
return;
|
|
117
119
|
}
|
|
118
120
|
// Usar las validaciones completas del VO TaxIdentification
|
|
119
121
|
TaxIdentification_1.TaxIdentification.validateCompletely(taxIdentification, 'taxIdentification');
|
|
@@ -219,18 +221,21 @@ class CarbonClientReference extends ObjectValueObject_1.ObjectValueObject {
|
|
|
219
221
|
* Verifica si la identificación tributaria tiene entidad emisora.
|
|
220
222
|
*/
|
|
221
223
|
hasIssuedBy() {
|
|
222
|
-
return __classPrivateFieldGet(this, _CarbonClientReference_taxIdentification, "f")
|
|
224
|
+
return (__classPrivateFieldGet(this, _CarbonClientReference_taxIdentification, "f")?.issuedBy ?? null) !== null;
|
|
223
225
|
}
|
|
224
226
|
/**
|
|
225
227
|
* Verifica si la identificación tributaria tiene fechas de validez.
|
|
226
228
|
*/
|
|
227
229
|
hasValidityPeriod() {
|
|
228
|
-
return __classPrivateFieldGet(this, _CarbonClientReference_taxIdentification, "f")
|
|
230
|
+
return (__classPrivateFieldGet(this, _CarbonClientReference_taxIdentification, "f")?.validFrom ?? null) !== null || (__classPrivateFieldGet(this, _CarbonClientReference_taxIdentification, "f")?.validUntil ?? null) !== null;
|
|
229
231
|
}
|
|
230
232
|
/**
|
|
231
233
|
* Verifica si el cliente puede participar en operaciones.
|
|
232
234
|
*/
|
|
233
235
|
canParticipateInOperations() {
|
|
236
|
+
if (__classPrivateFieldGet(this, _CarbonClientReference_taxIdentification, "f") === null) {
|
|
237
|
+
return true;
|
|
238
|
+
}
|
|
234
239
|
const now = new Date();
|
|
235
240
|
const today = new Date(now.getFullYear(), now.getMonth(), now.getDate());
|
|
236
241
|
if (__classPrivateFieldGet(this, _CarbonClientReference_taxIdentification, "f").validFrom) {
|
|
@@ -258,13 +263,13 @@ class CarbonClientReference extends ObjectValueObject_1.ObjectValueObject {
|
|
|
258
263
|
* Verifica si pertenece a un país específico.
|
|
259
264
|
*/
|
|
260
265
|
belongsToCountry(countryCode) {
|
|
261
|
-
return __classPrivateFieldGet(this, _CarbonClientReference_taxIdentification, "f")
|
|
266
|
+
return __classPrivateFieldGet(this, _CarbonClientReference_taxIdentification, "f")?.country === countryCode.trim().toUpperCase();
|
|
262
267
|
}
|
|
263
268
|
/**
|
|
264
269
|
* Verifica si requiere renovación próxima (dentro de 30 días).
|
|
265
270
|
*/
|
|
266
271
|
requiresRenewalSoon() {
|
|
267
|
-
if (__classPrivateFieldGet(this, _CarbonClientReference_taxIdentification, "f")
|
|
272
|
+
if ((__classPrivateFieldGet(this, _CarbonClientReference_taxIdentification, "f")?.validUntil ?? null) === null) {
|
|
268
273
|
return false; // Si no tiene fecha de vencimiento, no requiere renovación
|
|
269
274
|
}
|
|
270
275
|
const now = new Date();
|
|
@@ -275,6 +280,9 @@ class CarbonClientReference extends ObjectValueObject_1.ObjectValueObject {
|
|
|
275
280
|
* Verifica si la identificación tributaria será válida en una fecha específica.
|
|
276
281
|
*/
|
|
277
282
|
isValidOnDate(date) {
|
|
283
|
+
if (__classPrivateFieldGet(this, _CarbonClientReference_taxIdentification, "f") === null) {
|
|
284
|
+
return true;
|
|
285
|
+
}
|
|
278
286
|
const checkDate = new Date(date.getFullYear(), date.getMonth(), date.getDate());
|
|
279
287
|
if (__classPrivateFieldGet(this, _CarbonClientReference_taxIdentification, "f").validFrom) {
|
|
280
288
|
const fromDate = this.parseDate(__classPrivateFieldGet(this, _CarbonClientReference_taxIdentification, "f").validFrom);
|
|
@@ -294,12 +302,13 @@ class CarbonClientReference extends ObjectValueObject_1.ObjectValueObject {
|
|
|
294
302
|
* Obtiene días restantes hasta el vencimiento.
|
|
295
303
|
*/
|
|
296
304
|
getDaysUntilExpiration() {
|
|
297
|
-
|
|
305
|
+
const validUntil = __classPrivateFieldGet(this, _CarbonClientReference_taxIdentification, "f")?.validUntil ?? null;
|
|
306
|
+
if (validUntil === null) {
|
|
298
307
|
return null;
|
|
299
308
|
}
|
|
300
309
|
const now = new Date();
|
|
301
310
|
const today = new Date(now.getFullYear(), now.getMonth(), now.getDate());
|
|
302
|
-
const [day, month, year] =
|
|
311
|
+
const [day, month, year] = validUntil.split('/').map(Number);
|
|
303
312
|
const expirationDate = new Date(year, month - 1, day);
|
|
304
313
|
const diffTime = expirationDate.getTime() - today.getTime();
|
|
305
314
|
const diffDays = Math.ceil(diffTime / (1000 * 60 * 60 * 24));
|
|
@@ -309,15 +318,17 @@ class CarbonClientReference extends ObjectValueObject_1.ObjectValueObject {
|
|
|
309
318
|
* Obtiene una representación formateada para mostrar al usuario.
|
|
310
319
|
*/
|
|
311
320
|
getFormattedDisplay() {
|
|
312
|
-
const taxInfo =
|
|
321
|
+
const taxInfo = __classPrivateFieldGet(this, _CarbonClientReference_taxIdentification, "f") === null
|
|
322
|
+
? 'N/A'
|
|
323
|
+
: `${__classPrivateFieldGet(this, _CarbonClientReference_taxIdentification, "f").type}-${__classPrivateFieldGet(this, _CarbonClientReference_taxIdentification, "f").number}-${__classPrivateFieldGet(this, _CarbonClientReference_taxIdentification, "f").country}`;
|
|
313
324
|
return `${__classPrivateFieldGet(this, _CarbonClientReference_displayName, "f")} (${taxInfo}) - ${__classPrivateFieldGet(this, _CarbonClientReference_accountType, "f")} Carbon Client`;
|
|
314
325
|
}
|
|
315
326
|
/**
|
|
316
327
|
* Obtiene información resumida del cliente de carbono.
|
|
317
328
|
*/
|
|
318
329
|
getSummary() {
|
|
319
|
-
const
|
|
320
|
-
const taxType = __classPrivateFieldGet(this, _CarbonClientReference_taxIdentification, "f")
|
|
330
|
+
const country = __classPrivateFieldGet(this, _CarbonClientReference_taxIdentification, "f")?.country ?? 'N/A';
|
|
331
|
+
const taxType = __classPrivateFieldGet(this, _CarbonClientReference_taxIdentification, "f")?.type ?? 'N/A';
|
|
321
332
|
return `${__classPrivateFieldGet(this, _CarbonClientReference_displayName, "f")} - ${__classPrivateFieldGet(this, _CarbonClientReference_accountType, "f").toLowerCase()} carbon client from ${country} (${taxType})`;
|
|
322
333
|
}
|
|
323
334
|
/**
|
|
@@ -343,6 +354,9 @@ class CarbonClientReference extends ObjectValueObject_1.ObjectValueObject {
|
|
|
343
354
|
* Compara si dos identificaciones tributarias son iguales.
|
|
344
355
|
*/
|
|
345
356
|
taxIdentificationsAreEqual(other) {
|
|
357
|
+
if (__classPrivateFieldGet(this, _CarbonClientReference_taxIdentification, "f") === null || other === null) {
|
|
358
|
+
return __classPrivateFieldGet(this, _CarbonClientReference_taxIdentification, "f") === other;
|
|
359
|
+
}
|
|
346
360
|
return (__classPrivateFieldGet(this, _CarbonClientReference_taxIdentification, "f").type === other.type
|
|
347
361
|
&& __classPrivateFieldGet(this, _CarbonClientReference_taxIdentification, "f").number === other.number
|
|
348
362
|
&& __classPrivateFieldGet(this, _CarbonClientReference_taxIdentification, "f").country === other.country
|
|
@@ -364,6 +378,9 @@ class CarbonClientReference extends ObjectValueObject_1.ObjectValueObject {
|
|
|
364
378
|
* Compara si dos identificaciones tributarias representan el mismo identificador.
|
|
365
379
|
*/
|
|
366
380
|
hasSameIdentifier(other) {
|
|
381
|
+
if (__classPrivateFieldGet(this, _CarbonClientReference_taxIdentification, "f") === null || other === null) {
|
|
382
|
+
return false;
|
|
383
|
+
}
|
|
367
384
|
return (__classPrivateFieldGet(this, _CarbonClientReference_taxIdentification, "f").type === other.type
|
|
368
385
|
&& __classPrivateFieldGet(this, _CarbonClientReference_taxIdentification, "f").number === other.number
|
|
369
386
|
&& __classPrivateFieldGet(this, _CarbonClientReference_taxIdentification, "f").country === other.country);
|
|
@@ -372,7 +389,10 @@ class CarbonClientReference extends ObjectValueObject_1.ObjectValueObject {
|
|
|
372
389
|
* Genera un hash code para usar en colecciones.
|
|
373
390
|
*/
|
|
374
391
|
hashCode() {
|
|
375
|
-
const
|
|
392
|
+
const t = __classPrivateFieldGet(this, _CarbonClientReference_taxIdentification, "f");
|
|
393
|
+
const taxHash = t === null
|
|
394
|
+
? 'no-tax'
|
|
395
|
+
: `${t.type}_${t.number}_${t.country}_${t.issuedBy}_${t.validFrom}_${t.validUntil}`;
|
|
376
396
|
return `${__classPrivateFieldGet(this, _CarbonClientReference_id, "f")}_${__classPrivateFieldGet(this, _CarbonClientReference_displayName, "f")}_${taxHash}_${__classPrivateFieldGet(this, _CarbonClientReference_roleType, "f")}_${__classPrivateFieldGet(this, _CarbonClientReference_accountType, "f")}`;
|
|
377
397
|
}
|
|
378
398
|
/**
|
|
@@ -66,7 +66,9 @@ class CarbonClientReferences extends ValueObject_1.ValueObject {
|
|
|
66
66
|
* Valida que no haya identificaciones tributarias duplicadas.
|
|
67
67
|
*/
|
|
68
68
|
static guardAgainstDuplicateClientTaxIdentifications(value, propertyName) {
|
|
69
|
-
const taxIdentifications = value
|
|
69
|
+
const taxIdentifications = value
|
|
70
|
+
.filter((client) => client.taxIdentification !== null)
|
|
71
|
+
.map((client) => `${client.taxIdentification.type}-${client.taxIdentification.number}-${client.taxIdentification.country}`);
|
|
70
72
|
const uniqueIds = new Set(taxIdentifications);
|
|
71
73
|
if (taxIdentifications.length !== uniqueIds.size) {
|
|
72
74
|
throw InvalidPropertyValueError_1.InvalidPropertyValueError.create(`${propertyName}.taxIdentification`, 'unique tax identifications', 'duplicate tax identifications found');
|
|
@@ -96,8 +98,8 @@ class CarbonClientReferences extends ValueObject_1.ValueObject {
|
|
|
96
98
|
if (typeof clientReference.displayName !== 'string') {
|
|
97
99
|
throw InvalidPropertyTypeError_1.InvalidPropertyTypeError.create(`${propertyName}.displayName`, 'string', typeof clientReference.displayName);
|
|
98
100
|
}
|
|
99
|
-
if (
|
|
100
|
-
throw InvalidPropertyTypeError_1.InvalidPropertyTypeError.create(`${propertyName}.taxIdentification`, 'TaxIdentification object', typeof clientReference.taxIdentification);
|
|
101
|
+
if (clientReference.taxIdentification !== null && typeof clientReference.taxIdentification !== 'object') {
|
|
102
|
+
throw InvalidPropertyTypeError_1.InvalidPropertyTypeError.create(`${propertyName}.taxIdentification`, 'TaxIdentification object | null', typeof clientReference.taxIdentification);
|
|
101
103
|
}
|
|
102
104
|
if (typeof clientReference.roleType !== 'string') {
|
|
103
105
|
throw InvalidPropertyTypeError_1.InvalidPropertyTypeError.create(`${propertyName}.roleType`, 'string', typeof clientReference.roleType);
|
|
@@ -154,7 +156,8 @@ class CarbonClientReferences extends ValueObject_1.ValueObject {
|
|
|
154
156
|
* Obtiene un cliente por su identificación tributaria.
|
|
155
157
|
*/
|
|
156
158
|
getClientByTaxIdentification(type, number, country) {
|
|
157
|
-
const clientFound = __classPrivateFieldGet(this, _CarbonClientReferences_clientReferences, "f").find((client) => client.taxIdentification
|
|
159
|
+
const clientFound = __classPrivateFieldGet(this, _CarbonClientReferences_clientReferences, "f").find((client) => client.taxIdentification !== null
|
|
160
|
+
&& client.taxIdentification.type === type.trim()
|
|
158
161
|
&& client.taxIdentification.number === number.trim()
|
|
159
162
|
&& client.taxIdentification.country === country.trim().toUpperCase());
|
|
160
163
|
return clientFound || null;
|
|
@@ -197,7 +200,9 @@ class CarbonClientReferences extends ValueObject_1.ValueObject {
|
|
|
197
200
|
* Obtiene todas las identificaciones tributarias como strings.
|
|
198
201
|
*/
|
|
199
202
|
getAllTaxIdentificationStrings() {
|
|
200
|
-
return __classPrivateFieldGet(this, _CarbonClientReferences_clientReferences, "f").map((client) =>
|
|
203
|
+
return __classPrivateFieldGet(this, _CarbonClientReferences_clientReferences, "f").map((client) => (client.taxIdentification === null
|
|
204
|
+
? 'N/A'
|
|
205
|
+
: `${client.taxIdentification.type}-${client.taxIdentification.number}-${client.taxIdentification.country}`));
|
|
201
206
|
}
|
|
202
207
|
/**
|
|
203
208
|
* Busca clientes por texto en el nombre.
|
|
@@ -212,8 +217,8 @@ class CarbonClientReferences extends ValueObject_1.ValueObject {
|
|
|
212
217
|
findClientsMatching(searchText) {
|
|
213
218
|
const lowerSearchText = searchText.toLowerCase().trim();
|
|
214
219
|
return __classPrivateFieldGet(this, _CarbonClientReferences_clientReferences, "f").filter((client) => client.displayName.toLowerCase().includes(lowerSearchText)
|
|
215
|
-
|| client.taxIdentification.number.toLowerCase().includes(lowerSearchText)
|
|
216
|
-
|| client.taxIdentification.type.toLowerCase().includes(lowerSearchText));
|
|
220
|
+
|| (client.taxIdentification !== null && client.taxIdentification.number.toLowerCase().includes(lowerSearchText))
|
|
221
|
+
|| (client.taxIdentification !== null && client.taxIdentification.type.toLowerCase().includes(lowerSearchText)));
|
|
217
222
|
}
|
|
218
223
|
/**
|
|
219
224
|
* Obtiene los primeros N clientes.
|
|
@@ -238,14 +243,14 @@ class CarbonClientReferences extends ValueObject_1.ValueObject {
|
|
|
238
243
|
*/
|
|
239
244
|
getClientsByCountry(countryCode) {
|
|
240
245
|
const upperCountryCode = countryCode.trim().toUpperCase();
|
|
241
|
-
return __classPrivateFieldGet(this, _CarbonClientReferences_clientReferences, "f").filter((client) => client.taxIdentification
|
|
246
|
+
return __classPrivateFieldGet(this, _CarbonClientReferences_clientReferences, "f").filter((client) => client.taxIdentification?.country === upperCountryCode);
|
|
242
247
|
}
|
|
243
248
|
/**
|
|
244
249
|
* Obtiene clientes por tipo de identificación tributaria.
|
|
245
250
|
*/
|
|
246
251
|
getClientsByTaxType(taxType) {
|
|
247
252
|
const upperTaxType = taxType.trim().toUpperCase();
|
|
248
|
-
return __classPrivateFieldGet(this, _CarbonClientReferences_clientReferences, "f").filter((client) => client.taxIdentification
|
|
253
|
+
return __classPrivateFieldGet(this, _CarbonClientReferences_clientReferences, "f").filter((client) => client.taxIdentification?.type === upperTaxType);
|
|
249
254
|
}
|
|
250
255
|
/**
|
|
251
256
|
* Verifica si todos los clientes tienen nombres únicos.
|
|
@@ -308,6 +313,9 @@ class CarbonClientReferences extends ValueObject_1.ValueObject {
|
|
|
308
313
|
* Compara si dos identificaciones tributarias son iguales.
|
|
309
314
|
*/
|
|
310
315
|
taxIdentificationsAreEqual(tax1, tax2) {
|
|
316
|
+
if (tax1 === null || tax1 === undefined || tax2 === null || tax2 === undefined) {
|
|
317
|
+
return (tax1 ?? null) === (tax2 ?? null);
|
|
318
|
+
}
|
|
311
319
|
return (tax1.type === tax2.type
|
|
312
320
|
&& tax1.number === tax2.number
|
|
313
321
|
&& tax1.country === tax2.country
|
|
@@ -320,7 +328,13 @@ class CarbonClientReferences extends ValueObject_1.ValueObject {
|
|
|
320
328
|
*/
|
|
321
329
|
hashCode() {
|
|
322
330
|
const clientHashes = __classPrivateFieldGet(this, _CarbonClientReferences_clientReferences, "f")
|
|
323
|
-
.map((client) =>
|
|
331
|
+
.map((client) => {
|
|
332
|
+
const tax = client.taxIdentification;
|
|
333
|
+
const taxHash = tax === null
|
|
334
|
+
? 'no-tax'
|
|
335
|
+
: `${tax.type}_${tax.number}_${tax.country}`;
|
|
336
|
+
return `${client.id}_${client.displayName}_${client.accountType}_${taxHash}`;
|
|
337
|
+
})
|
|
324
338
|
.join('|');
|
|
325
339
|
const optionsHash = __classPrivateFieldGet(this, _CarbonClientReferences_options, "f").allowEmpty ? 'allowEmpty' : 'requireElements';
|
|
326
340
|
return `${optionsHash}_${clientHashes}`;
|