@carbonbox/domain 0.20.1 → 0.21.2

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.
Files changed (68) hide show
  1. package/build/carbonbox/shared/domain/enums/IdentityDocumentType.js +10 -0
  2. package/build/carbonbox/shared/domain/exceptions/InvalidIdentityDocumentTypeError.js +18 -0
  3. package/build/carbonbox/shared/domain/types/IdentityDocument.js +2 -0
  4. package/build/carbonbox/shared/domain/types/IdentityDocumentPrimitives.js +2 -0
  5. package/build/carbonbox/shared/domain/value-objects/CarbonClientReference.js +33 -13
  6. package/build/carbonbox/shared/domain/value-objects/CarbonClientReferences.js +24 -10
  7. package/build/carbonbox/shared/domain/value-objects/IdentityDocument.js +336 -0
  8. package/build/carbonbox/shared/domain/value-objects/StakeholderReference.js +25 -10
  9. package/build/carbonbox/shared/domain/value-objects/StakeholderReferences.js +34 -18
  10. package/build/carbonbox/stakeholders/carbon-clients/domain/entity/CarbonClient.js +22 -5
  11. package/build/carbonbox/stakeholders/carbon-clients/domain/value-objects/CarbonClientIdentityDocument.js +27 -0
  12. package/build/carbonbox/stakeholders/carbon-coordinators/domain/entity/CarbonCoordinator.js +22 -5
  13. package/build/carbonbox/stakeholders/carbon-coordinators/domain/value-objects/CarbonCoordinatorIdentityDocument.js +27 -0
  14. package/build/carbonbox/stakeholders/carbon-host/domain/entity/CarbonHost.js +15 -5
  15. package/build/carbonbox/stakeholders/carbon-managers/domain/entity/CarbonManager.js +22 -5
  16. package/build/carbonbox/stakeholders/carbon-managers/domain/value-objects/CarbonManagerIdentityDocument.js +27 -0
  17. package/build/carbonbox/stakeholders/shared/domain/entity/Stakeholder.js +21 -4
  18. package/build/carbonbox/stakeholders/shared/domain/value-objects/StakeholderIdentityDocument.js +47 -0
  19. package/build/main/index.js +16 -1
  20. package/build/types/carbonbox/shared/domain/enums/IdentityDocumentType.d.ts +7 -0
  21. package/build/types/carbonbox/shared/domain/enums/IdentityDocumentType.d.ts.map +1 -0
  22. package/build/types/carbonbox/shared/domain/exceptions/InvalidIdentityDocumentTypeError.d.ts +7 -0
  23. package/build/types/carbonbox/shared/domain/exceptions/InvalidIdentityDocumentTypeError.d.ts.map +1 -0
  24. package/build/types/carbonbox/shared/domain/types/CarbonClientReference.d.ts +1 -1
  25. package/build/types/carbonbox/shared/domain/types/CarbonClientReference.d.ts.map +1 -1
  26. package/build/types/carbonbox/shared/domain/types/CarbonClientReferencePrimitives.d.ts +1 -1
  27. package/build/types/carbonbox/shared/domain/types/CarbonClientReferencePrimitives.d.ts.map +1 -1
  28. package/build/types/carbonbox/shared/domain/types/IdentityDocument.d.ts +9 -0
  29. package/build/types/carbonbox/shared/domain/types/IdentityDocument.d.ts.map +1 -0
  30. package/build/types/carbonbox/shared/domain/types/IdentityDocumentPrimitives.d.ts +9 -0
  31. package/build/types/carbonbox/shared/domain/types/IdentityDocumentPrimitives.d.ts.map +1 -0
  32. package/build/types/carbonbox/shared/domain/types/StakeholderReference.d.ts +1 -1
  33. package/build/types/carbonbox/shared/domain/types/StakeholderReference.d.ts.map +1 -1
  34. package/build/types/carbonbox/shared/domain/types/StakeholderReferencePrimitives.d.ts +1 -1
  35. package/build/types/carbonbox/shared/domain/types/StakeholderReferencePrimitives.d.ts.map +1 -1
  36. package/build/types/carbonbox/shared/domain/value-objects/CarbonClientReference.d.ts +3 -3
  37. package/build/types/carbonbox/shared/domain/value-objects/CarbonClientReference.d.ts.map +1 -1
  38. package/build/types/carbonbox/shared/domain/value-objects/CarbonClientReferences.d.ts.map +1 -1
  39. package/build/types/carbonbox/shared/domain/value-objects/IdentityDocument.d.ts +132 -0
  40. package/build/types/carbonbox/shared/domain/value-objects/IdentityDocument.d.ts.map +1 -0
  41. package/build/types/carbonbox/shared/domain/value-objects/StakeholderReference.d.ts +4 -2
  42. package/build/types/carbonbox/shared/domain/value-objects/StakeholderReference.d.ts.map +1 -1
  43. package/build/types/carbonbox/shared/domain/value-objects/StakeholderReferences.d.ts.map +1 -1
  44. package/build/types/carbonbox/stakeholders/carbon-clients/domain/entity/CarbonClient.d.ts.map +1 -1
  45. package/build/types/carbonbox/stakeholders/carbon-clients/domain/value-objects/CarbonClientIdentityDocument.d.ts +10 -0
  46. package/build/types/carbonbox/stakeholders/carbon-clients/domain/value-objects/CarbonClientIdentityDocument.d.ts.map +1 -0
  47. package/build/types/carbonbox/stakeholders/carbon-coordinators/domain/entity/CarbonCoordinator.d.ts.map +1 -1
  48. package/build/types/carbonbox/stakeholders/carbon-coordinators/domain/value-objects/CarbonCoordinatorIdentityDocument.d.ts +10 -0
  49. package/build/types/carbonbox/stakeholders/carbon-coordinators/domain/value-objects/CarbonCoordinatorIdentityDocument.d.ts.map +1 -0
  50. package/build/types/carbonbox/stakeholders/carbon-host/domain/entity/CarbonHost.d.ts.map +1 -1
  51. package/build/types/carbonbox/stakeholders/carbon-managers/domain/entity/CarbonManager.d.ts.map +1 -1
  52. package/build/types/carbonbox/stakeholders/carbon-managers/domain/value-objects/CarbonManagerIdentityDocument.d.ts +10 -0
  53. package/build/types/carbonbox/stakeholders/carbon-managers/domain/value-objects/CarbonManagerIdentityDocument.d.ts.map +1 -0
  54. package/build/types/carbonbox/stakeholders/shared/domain/entity/IStakeholder.d.ts +3 -1
  55. package/build/types/carbonbox/stakeholders/shared/domain/entity/IStakeholder.d.ts.map +1 -1
  56. package/build/types/carbonbox/stakeholders/shared/domain/entity/Stakeholder.d.ts +3 -1
  57. package/build/types/carbonbox/stakeholders/shared/domain/entity/Stakeholder.d.ts.map +1 -1
  58. package/build/types/carbonbox/stakeholders/shared/domain/types/StakeholderPrimitives.d.ts +3 -1
  59. package/build/types/carbonbox/stakeholders/shared/domain/types/StakeholderPrimitives.d.ts.map +1 -1
  60. package/build/types/carbonbox/stakeholders/shared/domain/types/StakeholderProps.d.ts +3 -1
  61. package/build/types/carbonbox/stakeholders/shared/domain/types/StakeholderProps.d.ts.map +1 -1
  62. package/build/types/carbonbox/stakeholders/shared/domain/types/StakeholderPropsWithHashedPassword.d.ts +3 -1
  63. package/build/types/carbonbox/stakeholders/shared/domain/types/StakeholderPropsWithHashedPassword.d.ts.map +1 -1
  64. package/build/types/carbonbox/stakeholders/shared/domain/value-objects/StakeholderIdentityDocument.d.ts +22 -0
  65. package/build/types/carbonbox/stakeholders/shared/domain/value-objects/StakeholderIdentityDocument.d.ts.map +1 -0
  66. package/build/types/main/index.d.ts +9 -0
  67. package/build/types/main/index.d.ts.map +1 -1
  68. package/package.json +1 -1
@@ -30,6 +30,7 @@ class StakeholderReference extends ObjectValueObject_1.ObjectValueObject {
30
30
  super(value, skipDomainValidation, propertyName, 'The provided value must be of type StakeholderReference from the domain layer', { allowNull: false, allowUndefined: false });
31
31
  _StakeholderReference_id.set(this, void 0);
32
32
  _StakeholderReference_displayName.set(this, void 0);
33
+ // USR-020: una referencia a una persona natural puede no tener identificación tributaria.
33
34
  _StakeholderReference_taxIdentification.set(this, void 0);
34
35
  _StakeholderReference_roleType.set(this, void 0);
35
36
  if (skipDomainValidation === false) {
@@ -63,8 +64,8 @@ class StakeholderReference extends ObjectValueObject_1.ObjectValueObject {
63
64
  if (typeof value.displayName !== 'string') {
64
65
  throw InvalidPropertyTypeError_1.InvalidPropertyTypeError.create('displayName', 'string', typeof value.displayName);
65
66
  }
66
- if (this.taxIdentificationIsInvalid(value.taxIdentification)) {
67
- throw InvalidPropertyTypeError_1.InvalidPropertyTypeError.create('taxIdentification', 'TaxIdentification object', typeof value.taxIdentification);
67
+ if (value.taxIdentification !== null && this.taxIdentificationIsInvalid(value.taxIdentification)) {
68
+ throw InvalidPropertyTypeError_1.InvalidPropertyTypeError.create('taxIdentification', 'TaxIdentification object | null', typeof value.taxIdentification);
68
69
  }
69
70
  if (typeof value.roleType !== 'string') {
70
71
  throw InvalidPropertyTypeError_1.InvalidPropertyTypeError.create('roleType', 'string', typeof value.roleType);
@@ -102,8 +103,9 @@ class StakeholderReference extends ObjectValueObject_1.ObjectValueObject {
102
103
  * Valida la identificación tributaria usando las validaciones del VO TaxIdentification.
103
104
  */
104
105
  static guardAgainstInvalidTaxIdentification(taxIdentification) {
106
+ // USR-020: null es válido (persona natural sin identificación tributaria).
105
107
  if (this.taxIdentificationIsNull(taxIdentification)) {
106
- throw InvalidPropertyTypeError_1.InvalidPropertyTypeError.create('taxIdentification', 'TaxIdentification object', 'null or undefined');
108
+ return;
107
109
  }
108
110
  // Usar las validaciones completas del VO TaxIdentification
109
111
  TaxIdentification_1.TaxIdentification.validateCompletely(taxIdentification, 'taxIdentification');
@@ -202,18 +204,21 @@ class StakeholderReference extends ObjectValueObject_1.ObjectValueObject {
202
204
  * Verifica si la identificación tributaria tiene entidad emisora.
203
205
  */
204
206
  hasIssuedBy() {
205
- return __classPrivateFieldGet(this, _StakeholderReference_taxIdentification, "f").issuedBy !== null;
207
+ return (__classPrivateFieldGet(this, _StakeholderReference_taxIdentification, "f")?.issuedBy ?? null) !== null;
206
208
  }
207
209
  /**
208
210
  * Verifica si la identificación tributaria tiene fechas de validez.
209
211
  */
210
212
  hasValidityPeriod() {
211
- return __classPrivateFieldGet(this, _StakeholderReference_taxIdentification, "f").validFrom !== null || __classPrivateFieldGet(this, _StakeholderReference_taxIdentification, "f").validUntil !== null;
213
+ return (__classPrivateFieldGet(this, _StakeholderReference_taxIdentification, "f")?.validFrom ?? null) !== null || (__classPrivateFieldGet(this, _StakeholderReference_taxIdentification, "f")?.validUntil ?? null) !== null;
212
214
  }
213
215
  /**
214
216
  * Verifica si el stakeholder puede participar en operaciones.
215
217
  */
216
218
  canParticipateInOperations() {
219
+ if (__classPrivateFieldGet(this, _StakeholderReference_taxIdentification, "f") === null) {
220
+ return true;
221
+ }
217
222
  const now = new Date();
218
223
  const today = new Date(now.getFullYear(), now.getMonth(), now.getDate());
219
224
  if (__classPrivateFieldGet(this, _StakeholderReference_taxIdentification, "f").validFrom) {
@@ -241,21 +246,23 @@ class StakeholderReference extends ObjectValueObject_1.ObjectValueObject {
241
246
  * Verifica si pertenece a un país específico.
242
247
  */
243
248
  belongsToCountry(countryCode) {
244
- return __classPrivateFieldGet(this, _StakeholderReference_taxIdentification, "f").country === countryCode.trim().toUpperCase();
249
+ return __classPrivateFieldGet(this, _StakeholderReference_taxIdentification, "f")?.country === countryCode.trim().toUpperCase();
245
250
  }
246
251
  /**
247
252
  * Obtiene una representación formateada para mostrar al usuario.
248
253
  */
249
254
  getFormattedDisplay() {
250
- const taxInfo = __classPrivateFieldGet(this, _StakeholderReference_taxIdentification, "f").toString();
255
+ const taxInfo = __classPrivateFieldGet(this, _StakeholderReference_taxIdentification, "f") === null
256
+ ? 'N/A'
257
+ : `${__classPrivateFieldGet(this, _StakeholderReference_taxIdentification, "f").type}-${__classPrivateFieldGet(this, _StakeholderReference_taxIdentification, "f").number}-${__classPrivateFieldGet(this, _StakeholderReference_taxIdentification, "f").country}`;
251
258
  return `${__classPrivateFieldGet(this, _StakeholderReference_displayName, "f")} (${taxInfo}) - ${__classPrivateFieldGet(this, _StakeholderReference_roleType, "f")}`;
252
259
  }
253
260
  /**
254
261
  * Obtiene información resumida del stakeholder.
255
262
  */
256
263
  getSummary() {
257
- const { country } = __classPrivateFieldGet(this, _StakeholderReference_taxIdentification, "f");
258
- const taxType = __classPrivateFieldGet(this, _StakeholderReference_taxIdentification, "f").type;
264
+ const country = __classPrivateFieldGet(this, _StakeholderReference_taxIdentification, "f")?.country ?? 'N/A';
265
+ const taxType = __classPrivateFieldGet(this, _StakeholderReference_taxIdentification, "f")?.type ?? 'N/A';
259
266
  const role = __classPrivateFieldGet(this, _StakeholderReference_roleType, "f").replace('CARBON_', '').toLowerCase();
260
267
  return `${__classPrivateFieldGet(this, _StakeholderReference_displayName, "f")} - ${role} from ${country} (${taxType})`;
261
268
  }
@@ -277,8 +284,13 @@ class StakeholderReference extends ObjectValueObject_1.ObjectValueObject {
277
284
  }
278
285
  /**
279
286
  * Compara si dos identificaciones tributarias representan el mismo identificador.
287
+ * Si alguna referencia no tiene identificación tributaria (persona natural), no
288
+ * se las considera el mismo identificador por esta vía.
280
289
  */
281
290
  hasSameIdentifier(other) {
291
+ if (__classPrivateFieldGet(this, _StakeholderReference_taxIdentification, "f") === null || other === null) {
292
+ return false;
293
+ }
282
294
  return (__classPrivateFieldGet(this, _StakeholderReference_taxIdentification, "f").type === other.type
283
295
  && __classPrivateFieldGet(this, _StakeholderReference_taxIdentification, "f").number === other.number
284
296
  && __classPrivateFieldGet(this, _StakeholderReference_taxIdentification, "f").country === other.country);
@@ -296,7 +308,10 @@ class StakeholderReference extends ObjectValueObject_1.ObjectValueObject {
296
308
  * Genera un hash code para usar en colecciones.
297
309
  */
298
310
  hashCode() {
299
- const taxHash = `${__classPrivateFieldGet(this, _StakeholderReference_taxIdentification, "f").type}_${__classPrivateFieldGet(this, _StakeholderReference_taxIdentification, "f").number}_${__classPrivateFieldGet(this, _StakeholderReference_taxIdentification, "f").country}_${__classPrivateFieldGet(this, _StakeholderReference_taxIdentification, "f").issuedBy}_${__classPrivateFieldGet(this, _StakeholderReference_taxIdentification, "f").validFrom}_${__classPrivateFieldGet(this, _StakeholderReference_taxIdentification, "f").validUntil}`;
311
+ const t = __classPrivateFieldGet(this, _StakeholderReference_taxIdentification, "f");
312
+ const taxHash = t === null
313
+ ? 'no-tax'
314
+ : `${t.type}_${t.number}_${t.country}_${t.issuedBy}_${t.validFrom}_${t.validUntil}`;
300
315
  return `${__classPrivateFieldGet(this, _StakeholderReference_displayName, "f")}_${taxHash}_${__classPrivateFieldGet(this, _StakeholderReference_roleType, "f")}`;
301
316
  }
302
317
  /**
@@ -78,7 +78,9 @@ class StakeholderReferences extends ValueObject_1.ValueObject {
78
78
  * Valida que no haya identificaciones tributarias duplicadas.
79
79
  */
80
80
  static guardAgainstDuplicateStakeholderTaxIdentifications(value, propertyName) {
81
- const taxIdentifications = value.map((stakeholder) => `${stakeholder.taxIdentification.type}-${stakeholder.taxIdentification.number}-${stakeholder.taxIdentification.country}`);
81
+ const taxIdentifications = value
82
+ .filter((stakeholder) => stakeholder.taxIdentification !== null)
83
+ .map((stakeholder) => `${stakeholder.taxIdentification.type}-${stakeholder.taxIdentification.number}-${stakeholder.taxIdentification.country}`);
82
84
  const uniqueIds = new Set(taxIdentifications);
83
85
  if (taxIdentifications.length !== uniqueIds.size) {
84
86
  throw InvalidPropertyValueError_1.InvalidPropertyValueError.create(`${propertyName}.taxIdentification`, 'unique tax identifications', 'duplicate tax identifications found');
@@ -109,8 +111,8 @@ class StakeholderReferences extends ValueObject_1.ValueObject {
109
111
  if (typeof stakeholderReference.displayName !== 'string') {
110
112
  throw InvalidPropertyTypeError_1.InvalidPropertyTypeError.create(`${propertyName}.displayName`, 'string', typeof stakeholderReference.displayName);
111
113
  }
112
- if (!stakeholderReference.taxIdentification || typeof stakeholderReference.taxIdentification !== 'object') {
113
- throw InvalidPropertyTypeError_1.InvalidPropertyTypeError.create(`${propertyName}.taxIdentification`, 'TaxIdentification object', typeof stakeholderReference.taxIdentification);
114
+ if (stakeholderReference.taxIdentification !== null && typeof stakeholderReference.taxIdentification !== 'object') {
115
+ throw InvalidPropertyTypeError_1.InvalidPropertyTypeError.create(`${propertyName}.taxIdentification`, 'TaxIdentification object | null', typeof stakeholderReference.taxIdentification);
114
116
  }
115
117
  if (typeof stakeholderReference.roleType !== 'string') {
116
118
  throw InvalidPropertyTypeError_1.InvalidPropertyTypeError.create(`${propertyName}.roleType`, 'string', typeof stakeholderReference.roleType);
@@ -185,7 +187,8 @@ class StakeholderReferences extends ValueObject_1.ValueObject {
185
187
  * Obtiene un stakeholder por su identificación tributaria.
186
188
  */
187
189
  getStakeholderByTaxIdentification(type, number, country) {
188
- const stakeholderFound = __classPrivateFieldGet(this, _StakeholderReferences_stakeholderReferences, "f").find((stakeholder) => stakeholder.taxIdentification.type === type.trim()
190
+ const stakeholderFound = __classPrivateFieldGet(this, _StakeholderReferences_stakeholderReferences, "f").find((stakeholder) => stakeholder.taxIdentification !== null
191
+ && stakeholder.taxIdentification.type === type.trim()
189
192
  && stakeholder.taxIdentification.number === number.trim()
190
193
  && stakeholder.taxIdentification.country === country.trim().toUpperCase());
191
194
  return stakeholderFound || null;
@@ -285,7 +288,9 @@ class StakeholderReferences extends ValueObject_1.ValueObject {
285
288
  * Obtiene todas las identificaciones tributarias como strings.
286
289
  */
287
290
  getAllTaxIdentificationStrings() {
288
- return __classPrivateFieldGet(this, _StakeholderReferences_stakeholderReferences, "f").map((stakeholder) => `${stakeholder.taxIdentification.type}-${stakeholder.taxIdentification.number}-${stakeholder.taxIdentification.country}`);
291
+ return __classPrivateFieldGet(this, _StakeholderReferences_stakeholderReferences, "f").map((stakeholder) => (stakeholder.taxIdentification === null
292
+ ? 'N/A'
293
+ : `${stakeholder.taxIdentification.type}-${stakeholder.taxIdentification.number}-${stakeholder.taxIdentification.country}`));
289
294
  }
290
295
  /**
291
296
  * Obtiene todos los roles únicos en la colección.
@@ -307,8 +312,8 @@ class StakeholderReferences extends ValueObject_1.ValueObject {
307
312
  findStakeholdersMatching(searchText) {
308
313
  const lowerSearchText = searchText.toLowerCase().trim();
309
314
  return __classPrivateFieldGet(this, _StakeholderReferences_stakeholderReferences, "f").filter((stakeholder) => stakeholder.displayName.toLowerCase().includes(lowerSearchText)
310
- || stakeholder.taxIdentification.number.toLowerCase().includes(lowerSearchText)
311
- || stakeholder.taxIdentification.type.toLowerCase().includes(lowerSearchText)
315
+ || (stakeholder.taxIdentification !== null && stakeholder.taxIdentification.number.toLowerCase().includes(lowerSearchText))
316
+ || (stakeholder.taxIdentification !== null && stakeholder.taxIdentification.type.toLowerCase().includes(lowerSearchText))
312
317
  || stakeholder.roleType.toLowerCase().includes(lowerSearchText));
313
318
  }
314
319
  /**
@@ -334,14 +339,14 @@ class StakeholderReferences extends ValueObject_1.ValueObject {
334
339
  */
335
340
  getStakeholdersByCountry(countryCode) {
336
341
  const upperCountryCode = countryCode.trim().toUpperCase();
337
- return __classPrivateFieldGet(this, _StakeholderReferences_stakeholderReferences, "f").filter((stakeholder) => stakeholder.taxIdentification.country === upperCountryCode);
342
+ return __classPrivateFieldGet(this, _StakeholderReferences_stakeholderReferences, "f").filter((stakeholder) => stakeholder.taxIdentification?.country === upperCountryCode);
338
343
  }
339
344
  /**
340
345
  * Obtiene stakeholders por tipo de identificación tributaria.
341
346
  */
342
347
  getStakeholdersByTaxType(taxType) {
343
348
  const upperTaxType = taxType.trim().toUpperCase();
344
- return __classPrivateFieldGet(this, _StakeholderReferences_stakeholderReferences, "f").filter((stakeholder) => stakeholder.taxIdentification.type === upperTaxType);
349
+ return __classPrivateFieldGet(this, _StakeholderReferences_stakeholderReferences, "f").filter((stakeholder) => stakeholder.taxIdentification?.type === upperTaxType);
345
350
  }
346
351
  /**
347
352
  * Verifica si todos los stakeholders tienen nombres únicos.
@@ -434,6 +439,9 @@ class StakeholderReferences extends ValueObject_1.ValueObject {
434
439
  * Compara si dos identificaciones tributarias son iguales.
435
440
  */
436
441
  taxIdentificationsAreEqual(tax1, tax2) {
442
+ if (tax1 === null || tax1 === undefined || tax2 === null || tax2 === undefined) {
443
+ return (tax1 ?? null) === (tax2 ?? null);
444
+ }
437
445
  return (tax1.type === tax2.type
438
446
  && tax1.number === tax2.number
439
447
  && tax1.country === tax2.country
@@ -446,7 +454,13 @@ class StakeholderReferences extends ValueObject_1.ValueObject {
446
454
  */
447
455
  hashCode() {
448
456
  const stakeholderHashes = __classPrivateFieldGet(this, _StakeholderReferences_stakeholderReferences, "f")
449
- .map((stakeholder) => `${stakeholder.displayName}_${stakeholder.roleType}_${stakeholder.taxIdentification.type}_${stakeholder.taxIdentification.number}_${stakeholder.taxIdentification.country}`)
457
+ .map((stakeholder) => {
458
+ const tax = stakeholder.taxIdentification;
459
+ const taxHash = tax === null
460
+ ? 'no-tax'
461
+ : `${tax.type}_${tax.number}_${tax.country}`;
462
+ return `${stakeholder.displayName}_${stakeholder.roleType}_${taxHash}`;
463
+ })
450
464
  .join('|');
451
465
  const optionsHash = __classPrivateFieldGet(this, _StakeholderReferences_options, "f").allowEmpty ? 'allowEmpty' : 'requireElements';
452
466
  return `${optionsHash}_${stakeholderHashes}`;
@@ -458,14 +472,16 @@ class StakeholderReferences extends ValueObject_1.ValueObject {
458
472
  return __classPrivateFieldGet(this, _StakeholderReferences_stakeholderReferences, "f").map((stakeholder) => ({
459
473
  id: stakeholder.id,
460
474
  displayName: stakeholder.displayName,
461
- taxIdentification: {
462
- type: stakeholder.taxIdentification.type,
463
- number: stakeholder.taxIdentification.number,
464
- country: stakeholder.taxIdentification.country,
465
- issuedBy: stakeholder.taxIdentification.issuedBy,
466
- validFrom: stakeholder.taxIdentification.validFrom,
467
- validUntil: stakeholder.taxIdentification.validUntil,
468
- },
475
+ taxIdentification: stakeholder.taxIdentification === null
476
+ ? null
477
+ : {
478
+ type: stakeholder.taxIdentification.type,
479
+ number: stakeholder.taxIdentification.number,
480
+ country: stakeholder.taxIdentification.country,
481
+ issuedBy: stakeholder.taxIdentification.issuedBy,
482
+ validFrom: stakeholder.taxIdentification.validFrom,
483
+ validUntil: stakeholder.taxIdentification.validUntil,
484
+ },
469
485
  roleType: stakeholder.roleType,
470
486
  }));
471
487
  }
@@ -34,6 +34,7 @@ const CarbonClientPrimaryContactPhone_1 = require("../value-objects/CarbonClient
34
34
  const CarbonClientRoleType_1 = require("../value-objects/CarbonClientRoleType");
35
35
  const CarbonClientSupervisedByStakeholder_1 = require("../value-objects/CarbonClientSupervisedByStakeholder");
36
36
  const CarbonClientTaxIdentification_1 = require("../value-objects/CarbonClientTaxIdentification");
37
+ const CarbonClientIdentityDocument_1 = require("../value-objects/CarbonClientIdentityDocument");
37
38
  const CarbonClientUserType_1 = require("../value-objects/CarbonClientUserType");
38
39
  const CarbonClientWebsiteUrl_1 = require("../value-objects/CarbonClientWebsiteUrl");
39
40
  class CarbonClient extends Stakeholder_1.Stakeholder {
@@ -56,9 +57,16 @@ class CarbonClient extends Stakeholder_1.Stakeholder {
56
57
  const lastAccessAt = skipDomainValidation
57
58
  ? CarbonClientLastAccessAt_1.CarbonClientLastAccessAt.fromPrimitives(props.lastAccessAt).toPrimitives()
58
59
  : CarbonClientLastAccessAt_1.CarbonClientLastAccessAt.create(props.lastAccessAt).toPrimitives();
59
- const taxIdentification = skipDomainValidation
60
- ? CarbonClientTaxIdentification_1.CarbonClientTaxIdentification.fromPrimitives(props.taxIdentification).toPrimitives()
61
- : CarbonClientTaxIdentification_1.CarbonClientTaxIdentification.create(props.taxIdentification).toPrimitives();
60
+ const taxIdentification = props.taxIdentification === null
61
+ ? null
62
+ : (skipDomainValidation
63
+ ? CarbonClientTaxIdentification_1.CarbonClientTaxIdentification.fromPrimitives(props.taxIdentification).toPrimitives()
64
+ : CarbonClientTaxIdentification_1.CarbonClientTaxIdentification.create(props.taxIdentification).toPrimitives());
65
+ const identityDocument = props.identityDocument === null
66
+ ? null
67
+ : (skipDomainValidation
68
+ ? CarbonClientIdentityDocument_1.CarbonClientIdentityDocument.fromPrimitives(props.identityDocument).toPrimitives()
69
+ : CarbonClientIdentityDocument_1.CarbonClientIdentityDocument.create(props.identityDocument).toPrimitives());
62
70
  const roleType = skipDomainValidation
63
71
  ? CarbonClientRoleType_1.CarbonClientRoleType.fromPrimitives(props.roleType).toEnum()
64
72
  : CarbonClientRoleType_1.CarbonClientRoleType.create(props.roleType).toEnum();
@@ -79,6 +87,7 @@ class CarbonClient extends Stakeholder_1.Stakeholder {
79
87
  displayName,
80
88
  lastAccessAt,
81
89
  taxIdentification,
90
+ identityDocument,
82
91
  roleType,
83
92
  businessStatus,
84
93
  userType,
@@ -134,6 +143,7 @@ class CarbonClient extends Stakeholder_1.Stakeholder {
134
143
  displayName: primitives.displayName,
135
144
  lastAccessAt: primitives.lastAccessAt,
136
145
  taxIdentification: primitives.taxIdentification,
146
+ identityDocument: primitives.identityDocument,
137
147
  roleType: primitives.roleType,
138
148
  businessStatus: primitives.businessStatus,
139
149
  userType: primitives.userType,
@@ -159,7 +169,12 @@ class CarbonClient extends Stakeholder_1.Stakeholder {
159
169
  const email = CarbonClientEmail_1.CarbonClientEmail.create(props.email).toPrimitives();
160
170
  const displayName = CarbonClientDisplayName_1.CarbonClientDisplayName.create(props.displayName).toPrimitives();
161
171
  const lastAccessAt = CarbonClientLastAccessAt_1.CarbonClientLastAccessAt.create(props.lastAccessAt).toPrimitives();
162
- const taxIdentification = CarbonClientTaxIdentification_1.CarbonClientTaxIdentification.create(props.taxIdentification).toPrimitives();
172
+ const taxIdentification = props.taxIdentification === null
173
+ ? null
174
+ : CarbonClientTaxIdentification_1.CarbonClientTaxIdentification.create(props.taxIdentification).toPrimitives();
175
+ const identityDocument = props.identityDocument === null
176
+ ? null
177
+ : CarbonClientIdentityDocument_1.CarbonClientIdentityDocument.create(props.identityDocument).toPrimitives();
163
178
  const roleType = CarbonClientRoleType_1.CarbonClientRoleType.create(props.roleType).toEnum();
164
179
  const businessStatus = CarbonClientBusinessStatus_1.CarbonClientBusinessStatus.create(props.businessStatus).toEnum();
165
180
  const userType = CarbonClientUserType_1.CarbonClientUserType.create(props.userType).toEnum();
@@ -182,6 +197,7 @@ class CarbonClient extends Stakeholder_1.Stakeholder {
182
197
  displayName,
183
198
  lastAccessAt,
184
199
  taxIdentification,
200
+ identityDocument,
185
201
  roleType,
186
202
  businessStatus,
187
203
  userType,
@@ -212,7 +228,8 @@ class CarbonClient extends Stakeholder_1.Stakeholder {
212
228
  businessStatus: this.businessStatus.toEnum(),
213
229
  userType: this.userType.toEnum(),
214
230
  legalBusinessName: this.legalBusinessName.toPrimitives(),
215
- taxIdentification: this.taxIdentification.toPrimitives(),
231
+ taxIdentification: this.taxIdentification?.toPrimitives() ?? null,
232
+ identityDocument: this.identityDocument?.toPrimitives() ?? null,
216
233
  industryType: this.industryType.toPrimitives(),
217
234
  organizationSize: this.organizationSize.toEnum(),
218
235
  physicalAddress: this.physicalAddress.toPrimitives(),
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CarbonClientIdentityDocument = void 0;
4
+ const StakeholderIdentityDocument_1 = require("../../../shared/domain/value-objects/StakeholderIdentityDocument");
5
+ class CarbonClientIdentityDocument extends StakeholderIdentityDocument_1.StakeholderIdentityDocument {
6
+ constructor(value, skipDomainValidation) {
7
+ super(value, skipDomainValidation);
8
+ }
9
+ static create(value) {
10
+ return new CarbonClientIdentityDocument(value, false);
11
+ }
12
+ static fromPrimitives(primitives) {
13
+ const value = {
14
+ country: primitives.country,
15
+ issuedBy: primitives.issuedBy,
16
+ number: primitives.number,
17
+ type: primitives.type,
18
+ validFrom: primitives.validFrom,
19
+ validUntil: primitives.validUntil,
20
+ };
21
+ return new CarbonClientIdentityDocument(value, true);
22
+ }
23
+ toPrimitives() {
24
+ return this.value;
25
+ }
26
+ }
27
+ exports.CarbonClientIdentityDocument = CarbonClientIdentityDocument;
@@ -30,6 +30,7 @@ const CarbonCoordinatorPermissions_1 = require("../value-objects/CarbonCoordinat
30
30
  const CarbonCoordinatorReportsToStakeholder_1 = require("../value-objects/CarbonCoordinatorReportsToStakeholder");
31
31
  const CarbonCoordinatorRoleType_1 = require("../value-objects/CarbonCoordinatorRoleType");
32
32
  const CarbonCoordinatorTaxIdentification_1 = require("../value-objects/CarbonCoordinatorTaxIdentification");
33
+ const CarbonCoordinatorIdentityDocument_1 = require("../value-objects/CarbonCoordinatorIdentityDocument");
33
34
  const CarbonCoordinatorUserType_1 = require("../value-objects/CarbonCoordinatorUserType");
34
35
  const CarbonCoordinatorWeeklyWorkingSchedule_1 = require("../value-objects/CarbonCoordinatorWeeklyWorkingSchedule");
35
36
  class CarbonCoordinator extends Stakeholder_1.Stakeholder {
@@ -52,9 +53,16 @@ class CarbonCoordinator extends Stakeholder_1.Stakeholder {
52
53
  const lastAccessAt = skipDomainValidation
53
54
  ? CarbonCoordinatorLastAccessAt_1.CarbonCoordinatorLastAccessAt.fromPrimitives(props.lastAccessAt).toPrimitives()
54
55
  : CarbonCoordinatorLastAccessAt_1.CarbonCoordinatorLastAccessAt.create(props.lastAccessAt).toPrimitives();
55
- const taxIdentification = skipDomainValidation
56
- ? CarbonCoordinatorTaxIdentification_1.CarbonCoordinatorTaxIdentification.fromPrimitives(props.taxIdentification).toPrimitives()
57
- : CarbonCoordinatorTaxIdentification_1.CarbonCoordinatorTaxIdentification.create(props.taxIdentification).toPrimitives();
56
+ const taxIdentification = props.taxIdentification === null
57
+ ? null
58
+ : (skipDomainValidation
59
+ ? CarbonCoordinatorTaxIdentification_1.CarbonCoordinatorTaxIdentification.fromPrimitives(props.taxIdentification).toPrimitives()
60
+ : CarbonCoordinatorTaxIdentification_1.CarbonCoordinatorTaxIdentification.create(props.taxIdentification).toPrimitives());
61
+ const identityDocument = props.identityDocument === null
62
+ ? null
63
+ : (skipDomainValidation
64
+ ? CarbonCoordinatorIdentityDocument_1.CarbonCoordinatorIdentityDocument.fromPrimitives(props.identityDocument).toPrimitives()
65
+ : CarbonCoordinatorIdentityDocument_1.CarbonCoordinatorIdentityDocument.create(props.identityDocument).toPrimitives());
58
66
  const roleType = skipDomainValidation
59
67
  ? CarbonCoordinatorRoleType_1.CarbonCoordinatorRoleType.fromPrimitives(props.roleType).toEnum()
60
68
  : CarbonCoordinatorRoleType_1.CarbonCoordinatorRoleType.create(props.roleType).toEnum();
@@ -75,6 +83,7 @@ class CarbonCoordinator extends Stakeholder_1.Stakeholder {
75
83
  displayName,
76
84
  lastAccessAt,
77
85
  taxIdentification,
86
+ identityDocument,
78
87
  roleType,
79
88
  businessStatus,
80
89
  userType,
@@ -118,6 +127,7 @@ class CarbonCoordinator extends Stakeholder_1.Stakeholder {
118
127
  displayName: primitives.displayName,
119
128
  lastAccessAt: primitives.lastAccessAt,
120
129
  taxIdentification: primitives.taxIdentification,
130
+ identityDocument: primitives.identityDocument,
121
131
  roleType: primitives.roleType,
122
132
  businessStatus: primitives.businessStatus,
123
133
  userType: primitives.userType,
@@ -139,7 +149,12 @@ class CarbonCoordinator extends Stakeholder_1.Stakeholder {
139
149
  const email = CarbonCoordinatorEmail_1.CarbonCoordinatorEmail.create(props.email).toPrimitives();
140
150
  const displayName = CarbonCoordinatorDisplayName_1.CarbonCoordinatorDisplayName.create(props.displayName).toPrimitives();
141
151
  const lastAccessAt = CarbonCoordinatorLastAccessAt_1.CarbonCoordinatorLastAccessAt.create(props.lastAccessAt).toPrimitives();
142
- const taxIdentification = CarbonCoordinatorTaxIdentification_1.CarbonCoordinatorTaxIdentification.create(props.taxIdentification).toPrimitives();
152
+ const taxIdentification = props.taxIdentification === null
153
+ ? null
154
+ : CarbonCoordinatorTaxIdentification_1.CarbonCoordinatorTaxIdentification.create(props.taxIdentification).toPrimitives();
155
+ const identityDocument = props.identityDocument === null
156
+ ? null
157
+ : CarbonCoordinatorIdentityDocument_1.CarbonCoordinatorIdentityDocument.create(props.identityDocument).toPrimitives();
143
158
  const roleType = CarbonCoordinatorRoleType_1.CarbonCoordinatorRoleType.create(props.roleType).toEnum();
144
159
  const businessStatus = CarbonCoordinatorBusinessStatus_1.CarbonCoordinatorBusinessStatus.create(props.businessStatus).toEnum();
145
160
  const userType = CarbonCoordinatorUserType_1.CarbonCoordinatorUserType.create(props.userType).toEnum();
@@ -158,6 +173,7 @@ class CarbonCoordinator extends Stakeholder_1.Stakeholder {
158
173
  displayName,
159
174
  lastAccessAt,
160
175
  taxIdentification,
176
+ identityDocument,
161
177
  roleType,
162
178
  businessStatus,
163
179
  userType,
@@ -183,7 +199,8 @@ class CarbonCoordinator extends Stakeholder_1.Stakeholder {
183
199
  roleType: this.roleType.toEnum(),
184
200
  businessStatus: this.businessStatus.toEnum(),
185
201
  userType: this.userType.toEnum(),
186
- taxIdentification: this.taxIdentification.toPrimitives(),
202
+ taxIdentification: this.taxIdentification?.toPrimitives() ?? null,
203
+ identityDocument: this.identityDocument?.toPrimitives() ?? null,
187
204
  availabilityStatus: __classPrivateFieldGet(this, _CarbonCoordinator_availabilityStatus, "f").toEnum(),
188
205
  weeklyWorkingSchedule: __classPrivateFieldGet(this, _CarbonCoordinator_weeklyWorkingSchedule, "f").toPrimitives(),
189
206
  gender: __classPrivateFieldGet(this, _CarbonCoordinator_gender, "f").toEnum(),
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CarbonCoordinatorIdentityDocument = void 0;
4
+ const StakeholderIdentityDocument_1 = require("../../../shared/domain/value-objects/StakeholderIdentityDocument");
5
+ class CarbonCoordinatorIdentityDocument extends StakeholderIdentityDocument_1.StakeholderIdentityDocument {
6
+ constructor(value, skipDomainValidation) {
7
+ super(value, skipDomainValidation);
8
+ }
9
+ static create(value) {
10
+ return new CarbonCoordinatorIdentityDocument(value, false);
11
+ }
12
+ static fromPrimitives(primitives) {
13
+ const value = {
14
+ country: primitives.country,
15
+ issuedBy: primitives.issuedBy,
16
+ number: primitives.number,
17
+ type: primitives.type,
18
+ validFrom: primitives.validFrom,
19
+ validUntil: primitives.validUntil,
20
+ };
21
+ return new CarbonCoordinatorIdentityDocument(value, true);
22
+ }
23
+ toPrimitives() {
24
+ return this.value;
25
+ }
26
+ }
27
+ exports.CarbonCoordinatorIdentityDocument = CarbonCoordinatorIdentityDocument;
@@ -34,9 +34,13 @@ class CarbonHost extends Stakeholder_1.Stakeholder {
34
34
  const lastAccessAt = skipDomainValidation
35
35
  ? CarbonHostLastAccessAt_1.CarbonHostLastAccessAt.fromPrimitives(props.lastAccessAt).toPrimitives()
36
36
  : CarbonHostLastAccessAt_1.CarbonHostLastAccessAt.create(props.lastAccessAt).toPrimitives();
37
- const taxIdentification = skipDomainValidation
38
- ? CarbonHostTaxIdentification_1.CarbonHostTaxIdentification.fromPrimitives(props.taxIdentification).toPrimitives()
39
- : CarbonHostTaxIdentification_1.CarbonHostTaxIdentification.create(props.taxIdentification).toPrimitives();
37
+ // USR-020: Host conserva taxIdentification (a nivel app sigue requerido); identityDocument
38
+ // no aplica al Host (siempre null). El tipo base es nullable, de ahí el manejo defensivo.
39
+ const taxIdentification = props.taxIdentification === null
40
+ ? null
41
+ : (skipDomainValidation
42
+ ? CarbonHostTaxIdentification_1.CarbonHostTaxIdentification.fromPrimitives(props.taxIdentification).toPrimitives()
43
+ : CarbonHostTaxIdentification_1.CarbonHostTaxIdentification.create(props.taxIdentification).toPrimitives());
40
44
  const roleType = skipDomainValidation
41
45
  ? CarbonHostRoleType_1.CarbonHostRoleType.fromPrimitives(props.roleType).toEnum()
42
46
  : CarbonHostRoleType_1.CarbonHostRoleType.create(props.roleType).toEnum();
@@ -57,6 +61,7 @@ class CarbonHost extends Stakeholder_1.Stakeholder {
57
61
  displayName,
58
62
  lastAccessAt,
59
63
  taxIdentification,
64
+ identityDocument: null,
60
65
  roleType,
61
66
  businessStatus,
62
67
  userType,
@@ -76,6 +81,7 @@ class CarbonHost extends Stakeholder_1.Stakeholder {
76
81
  displayName: primitives.displayName,
77
82
  lastAccessAt: primitives.lastAccessAt,
78
83
  taxIdentification: primitives.taxIdentification,
84
+ identityDocument: primitives.identityDocument,
79
85
  roleType: primitives.roleType,
80
86
  businessStatus: primitives.businessStatus,
81
87
  userType: primitives.userType,
@@ -91,7 +97,9 @@ class CarbonHost extends Stakeholder_1.Stakeholder {
91
97
  const email = CarbonHostEmail_1.CarbonHostEmail.create(props.email).toPrimitives();
92
98
  const displayName = CarbonHostDisplayName_1.CarbonHostDisplayName.create(props.displayName).toPrimitives();
93
99
  const lastAccessAt = CarbonHostLastAccessAt_1.CarbonHostLastAccessAt.create(props.lastAccessAt).toPrimitives();
94
- const taxIdentification = CarbonHostTaxIdentification_1.CarbonHostTaxIdentification.create(props.taxIdentification).toPrimitives();
100
+ const taxIdentification = props.taxIdentification === null
101
+ ? null
102
+ : CarbonHostTaxIdentification_1.CarbonHostTaxIdentification.create(props.taxIdentification).toPrimitives();
95
103
  const roleType = CarbonHostRoleType_1.CarbonHostRoleType.create(props.roleType).toEnum();
96
104
  const businessStatus = CarbonHostBusinessStatus_1.CarbonHostBusinessStatus.create(props.businessStatus).toEnum();
97
105
  const userType = CarbonHostUserType_1.CarbonHostUserType.create(props.userType).toEnum();
@@ -104,6 +112,7 @@ class CarbonHost extends Stakeholder_1.Stakeholder {
104
112
  displayName,
105
113
  lastAccessAt,
106
114
  taxIdentification,
115
+ identityDocument: null,
107
116
  roleType,
108
117
  businessStatus,
109
118
  userType,
@@ -123,7 +132,8 @@ class CarbonHost extends Stakeholder_1.Stakeholder {
123
132
  roleType: this.roleType.toEnum(),
124
133
  businessStatus: this.businessStatus.toEnum(),
125
134
  userType: this.userType.toEnum(),
126
- taxIdentification: this.taxIdentification.toPrimitives(),
135
+ taxIdentification: this.taxIdentification?.toPrimitives() ?? null,
136
+ identityDocument: this.identityDocument?.toPrimitives() ?? null,
127
137
  permissions: this.permissions.toEnums(),
128
138
  preferredLocale: this.preferredLocale.toEnum(),
129
139
  };
@@ -26,6 +26,7 @@ const CarbonManagerPassword_1 = require("../value-objects/CarbonManagerPassword"
26
26
  const CarbonManagerPermissions_1 = require("../value-objects/CarbonManagerPermissions");
27
27
  const CarbonManagerRoleType_1 = require("../value-objects/CarbonManagerRoleType");
28
28
  const CarbonManagerTaxIdentification_1 = require("../value-objects/CarbonManagerTaxIdentification");
29
+ const CarbonManagerIdentityDocument_1 = require("../value-objects/CarbonManagerIdentityDocument");
29
30
  const CarbonManagerUserType_1 = require("../value-objects/CarbonManagerUserType");
30
31
  class CarbonManager extends Stakeholder_1.Stakeholder {
31
32
  constructor(props, skipDomainValidation) {
@@ -47,9 +48,16 @@ class CarbonManager extends Stakeholder_1.Stakeholder {
47
48
  const lastAccessAt = skipDomainValidation
48
49
  ? CarbonManagerLastAccessAt_1.CarbonManagerLastAccessAt.fromPrimitives(props.lastAccessAt).toPrimitives()
49
50
  : CarbonManagerLastAccessAt_1.CarbonManagerLastAccessAt.create(props.lastAccessAt).toPrimitives();
50
- const taxIdentification = skipDomainValidation
51
- ? CarbonManagerTaxIdentification_1.CarbonManagerTaxIdentification.fromPrimitives(props.taxIdentification).toPrimitives()
52
- : CarbonManagerTaxIdentification_1.CarbonManagerTaxIdentification.create(props.taxIdentification).toPrimitives();
51
+ const taxIdentification = props.taxIdentification === null
52
+ ? null
53
+ : (skipDomainValidation
54
+ ? CarbonManagerTaxIdentification_1.CarbonManagerTaxIdentification.fromPrimitives(props.taxIdentification).toPrimitives()
55
+ : CarbonManagerTaxIdentification_1.CarbonManagerTaxIdentification.create(props.taxIdentification).toPrimitives());
56
+ const identityDocument = props.identityDocument === null
57
+ ? null
58
+ : (skipDomainValidation
59
+ ? CarbonManagerIdentityDocument_1.CarbonManagerIdentityDocument.fromPrimitives(props.identityDocument).toPrimitives()
60
+ : CarbonManagerIdentityDocument_1.CarbonManagerIdentityDocument.create(props.identityDocument).toPrimitives());
53
61
  const roleType = skipDomainValidation
54
62
  ? CarbonManagerRoleType_1.CarbonManagerRoleType.fromPrimitives(props.roleType).toEnum()
55
63
  : CarbonManagerRoleType_1.CarbonManagerRoleType.create(props.roleType).toEnum();
@@ -70,6 +78,7 @@ class CarbonManager extends Stakeholder_1.Stakeholder {
70
78
  displayName,
71
79
  lastAccessAt,
72
80
  taxIdentification,
81
+ identityDocument,
73
82
  roleType,
74
83
  businessStatus,
75
84
  userType,
@@ -98,6 +107,7 @@ class CarbonManager extends Stakeholder_1.Stakeholder {
98
107
  displayName: primitives.displayName,
99
108
  lastAccessAt: primitives.lastAccessAt,
100
109
  taxIdentification: primitives.taxIdentification,
110
+ identityDocument: primitives.identityDocument,
101
111
  roleType: primitives.roleType,
102
112
  businessStatus: primitives.businessStatus,
103
113
  userType: primitives.userType,
@@ -114,7 +124,12 @@ class CarbonManager extends Stakeholder_1.Stakeholder {
114
124
  const email = CarbonManagerEmail_1.CarbonManagerEmail.create(props.email).toPrimitives();
115
125
  const displayName = CarbonManagerDisplayName_1.CarbonManagerDisplayName.create(props.displayName).toPrimitives();
116
126
  const lastAccessAt = CarbonManagerLastAccessAt_1.CarbonManagerLastAccessAt.create(props.lastAccessAt).toPrimitives();
117
- const taxIdentification = CarbonManagerTaxIdentification_1.CarbonManagerTaxIdentification.create(props.taxIdentification).toPrimitives();
127
+ const taxIdentification = props.taxIdentification === null
128
+ ? null
129
+ : CarbonManagerTaxIdentification_1.CarbonManagerTaxIdentification.create(props.taxIdentification).toPrimitives();
130
+ const identityDocument = props.identityDocument === null
131
+ ? null
132
+ : CarbonManagerIdentityDocument_1.CarbonManagerIdentityDocument.create(props.identityDocument).toPrimitives();
118
133
  const roleType = CarbonManagerRoleType_1.CarbonManagerRoleType.create(props.roleType).toEnum();
119
134
  const businessStatus = CarbonManagerBusinessStatus_1.CarbonManagerBusinessStatus.create(props.businessStatus).toEnum();
120
135
  const userType = CarbonManagerUserType_1.CarbonManagerUserType.create(props.userType).toEnum();
@@ -128,6 +143,7 @@ class CarbonManager extends Stakeholder_1.Stakeholder {
128
143
  displayName,
129
144
  lastAccessAt,
130
145
  taxIdentification,
146
+ identityDocument,
131
147
  roleType,
132
148
  businessStatus,
133
149
  userType,
@@ -148,7 +164,8 @@ class CarbonManager extends Stakeholder_1.Stakeholder {
148
164
  roleType: this.roleType.toEnum(),
149
165
  businessStatus: this.businessStatus.toEnum(),
150
166
  userType: this.userType.toEnum(),
151
- taxIdentification: this.taxIdentification.toPrimitives(),
167
+ taxIdentification: this.taxIdentification?.toPrimitives() ?? null,
168
+ identityDocument: this.identityDocument?.toPrimitives() ?? null,
152
169
  permissions: this.permissions.toEnums(),
153
170
  preferredLocale: this.preferredLocale.toEnum(),
154
171
  managedStakeholders: __classPrivateFieldGet(this, _CarbonManager_managedStakeholders, "f").toPrimitives(),
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CarbonManagerIdentityDocument = void 0;
4
+ const StakeholderIdentityDocument_1 = require("../../../shared/domain/value-objects/StakeholderIdentityDocument");
5
+ class CarbonManagerIdentityDocument extends StakeholderIdentityDocument_1.StakeholderIdentityDocument {
6
+ constructor(value, skipDomainValidation) {
7
+ super(value, skipDomainValidation);
8
+ }
9
+ static create(value) {
10
+ return new CarbonManagerIdentityDocument(value, false);
11
+ }
12
+ static fromPrimitives(primitives) {
13
+ const value = {
14
+ country: primitives.country,
15
+ issuedBy: primitives.issuedBy,
16
+ number: primitives.number,
17
+ type: primitives.type,
18
+ validFrom: primitives.validFrom,
19
+ validUntil: primitives.validUntil,
20
+ };
21
+ return new CarbonManagerIdentityDocument(value, true);
22
+ }
23
+ toPrimitives() {
24
+ return this.value;
25
+ }
26
+ }
27
+ exports.CarbonManagerIdentityDocument = CarbonManagerIdentityDocument;