@fiado/type-kit 3.646.0 → 3.647.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.
@@ -0,0 +1,15 @@
1
+ import type { TenantCostCenters } from '../../../src/collection/index';
2
+
3
+ describe('TenantCostCenters', () => {
4
+ it('cada movimiento del tenant tiene su centro de costo opcional', () => {
5
+ const all: TenantCostCenters = {
6
+ welcomeBonus: 'SK-BONO-BIENVENIDA',
7
+ creditPromotion: 'SK-PROMO-CREDITO',
8
+ salePromotion: 'SK-PROMO-VENTA',
9
+ commission: 'SK-COMISIONES',
10
+ };
11
+ const none: TenantCostCenters = {};
12
+ expect(Object.keys(all)).toEqual(['welcomeBonus', 'creditPromotion', 'salePromotion', 'commission']);
13
+ expect(none).toEqual({});
14
+ });
15
+ });
@@ -235,6 +235,17 @@ describe('feed genérico de los dueños', () => {
235
235
  expect(errorsOf(PrivateGetReconciliationFeedRecordQuery, { tenantId: 'surekeep' })).toContain('author');
236
236
  });
237
237
 
238
+ it('el registro por recordId acepta costCenterIds opcionales en csv o arreglo', () => {
239
+ const base = { tenantId: 'surekeep', author: 'reconciliation-engine-business' };
240
+ expect(errorsOf(PrivateGetReconciliationFeedRecordQuery, { ...base, costCenterIds: 'SK-COBRANZA, SK-BONOS' })).toEqual([]);
241
+ const dto = plainToInstance(PrivateGetReconciliationFeedRecordQuery, { ...base, costCenterIds: 'SK-COBRANZA, SK-BONOS' }, { excludeExtraneousValues: true });
242
+ expect(dto.costCenterIds).toEqual(['SK-COBRANZA', 'SK-BONOS']);
243
+ expect(errorsOf(PrivateGetReconciliationFeedRecordQuery, { ...base, costCenterIds: ['SK-COBRANZA'] })).toEqual([]);
244
+ expect(errorsOf(PrivateGetReconciliationFeedRecordQuery, { ...base, costCenterIds: 'SK-COBRANZA,' })).toContain('costCenterIds');
245
+ expect(errorsOf(PrivateGetReconciliationFeedRecordQuery, { ...base, costCenterIds: '' })).toContain('costCenterIds');
246
+ expect(errorsOf(PrivateGetReconciliationFeedRecordQuery, { ...base, costCenterIds: [7] })).toContain('costCenterIds');
247
+ });
248
+
238
249
  it('el concepto del path es del catálogo de feeds', () => {
239
250
  expect(errorsOf(ReconciliationFeedPathParams, { concept: ReconciliationFeedConceptEnum.SIGNED_CREDIT })).toEqual([]);
240
251
  expect(errorsOf(ReconciliationFeedPathParams, { concept: 'ADJUSTMENT' })).toContain('concept');
@@ -37,6 +37,14 @@ describe('PrivateAuthorizeReconciliationAdjustmentRequest', () => {
37
37
  expect(errorsOf(rest)).toEqual([]);
38
38
  });
39
39
 
40
+ it('costCenterId es opcional y, si llega, es texto no vacío', () => {
41
+ expect(errorsOf({ ...valid, costCenterId: 'SK-COBRANZA' })).toEqual([]);
42
+ expect(errorsOf({ ...valid, costCenterId: '' })).toContain('costCenterId');
43
+ expect(errorsOf({ ...valid, costCenterId: 7 })).toContain('costCenterId');
44
+ const dto = plainToInstance(PrivateAuthorizeReconciliationAdjustmentRequest, { ...valid, costCenterId: 'SK-COBRANZA' }, { excludeExtraneousValues: true });
45
+ expect(dto.costCenterId).toBe('SK-COBRANZA');
46
+ });
47
+
40
48
  it('la llave debe empezar con el tenantId', () => {
41
49
  expect(errorsOf({ ...valid, adjustmentKey: 'otro#INSTALLMENT_COLLECTION_L1#exec-1#1' })).toEqual(['adjustmentKey']);
42
50
  expect(errorsOf({ ...valid, adjustmentKey: 'INSTALLMENT_COLLECTION_L1#exec-1#1' })).toEqual(['adjustmentKey']);
@@ -13,6 +13,7 @@ export * from './enums/RedriveOutboxStatus';
13
13
  export * from './enums/DisbursementType';
14
14
  export * from './constants/CollectionResultLimits';
15
15
  export * from './validators/IsCentPrecision';
16
+ export * from './interfaces/TenantCostCenters';
16
17
  export * from './dtos/PendingChargeDto';
17
18
  export * from './dtos/CollectRequest';
18
19
  export * from './dtos/CollectResponse';
@@ -31,6 +31,8 @@ __exportStar(require("./enums/DisbursementType"), exports);
31
31
  // Constantes y validadores
32
32
  __exportStar(require("./constants/CollectionResultLimits"), exports);
33
33
  __exportStar(require("./validators/IsCentPrecision"), exports);
34
+ // Interfaces
35
+ __exportStar(require("./interfaces/TenantCostCenters"), exports);
34
36
  // DTOs
35
37
  __exportStar(require("./dtos/PendingChargeDto"), exports);
36
38
  __exportStar(require("./dtos/CollectRequest"), exports);
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Centros de costo de un tenant para los movimientos que paga desde su bolsa. Cada servicio que
3
+ * dispersa lee el suyo de la configuración del tenant; si falta, el ledger lo asienta como no asignado.
4
+ */
5
+ export interface TenantCostCenters {
6
+ /** Bono de bienvenida al alta del cliente. */
7
+ welcomeBonus?: string;
8
+ /** Promociones ligadas al crédito. */
9
+ creditPromotion?: string;
10
+ /** Promociones ligadas a la venta. */
11
+ salePromotion?: string;
12
+ /** Comisiones a vendedores. */
13
+ commission?: string;
14
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -25,4 +25,9 @@ export declare class PrivateGetReconciliationFeedRecordQuery {
25
25
  author: string;
26
26
  /** Email del operador cuando la lectura sale del detalle de una partida. */
27
27
  actor?: string;
28
+ /**
29
+ * Centros de costo de la fuente, en csv (`a,b`) o repetidos. El dueño del feed del ledger solo
30
+ * devuelve el registro si pertenece a uno de ellos.
31
+ */
32
+ costCenterIds?: string[];
28
33
  }
@@ -78,3 +78,12 @@ __decorate([
78
78
  (0, reconciliationRequestDecorators_1.OptionalEmail)(),
79
79
  __metadata("design:type", String)
80
80
  ], PrivateGetReconciliationFeedRecordQuery.prototype, "actor", void 0);
81
+ __decorate([
82
+ (0, class_transformer_1.Expose)(),
83
+ (0, class_validator_1.IsOptional)(),
84
+ (0, class_transformer_1.Transform)(({ value }) => (typeof value === 'string' ? value.split(',').map((id) => id.trim()) : value)),
85
+ (0, class_validator_1.IsArray)(),
86
+ (0, class_validator_1.IsString)({ each: true }),
87
+ (0, class_validator_1.IsNotEmpty)({ each: true }),
88
+ __metadata("design:type", Array)
89
+ ], PrivateGetReconciliationFeedRecordQuery.prototype, "costCenterIds", void 0);
@@ -21,6 +21,8 @@ export declare class PrivateAuthorizeReconciliationAdjustmentRequest {
21
21
  originalTransactionId: string;
22
22
  /** Intento del cobro original, si lo hubo. */
23
23
  executionId?: string;
24
+ /** Centro de costo de la fuente ejecutada de la partida; el processor lo asienta en el ledger. */
25
+ costCenterId?: string;
24
26
  reference: ReconciliationAdjustmentReference;
25
27
  reason: string;
26
28
  /** Email del operador que resolvió la partida. */
@@ -81,6 +81,13 @@ __decorate([
81
81
  (0, class_validator_1.IsNotEmpty)(),
82
82
  __metadata("design:type", String)
83
83
  ], PrivateAuthorizeReconciliationAdjustmentRequest.prototype, "executionId", void 0);
84
+ __decorate([
85
+ (0, class_transformer_1.Expose)(),
86
+ (0, class_validator_1.IsOptional)(),
87
+ (0, class_validator_1.IsString)(),
88
+ (0, class_validator_1.IsNotEmpty)(),
89
+ __metadata("design:type", String)
90
+ ], PrivateAuthorizeReconciliationAdjustmentRequest.prototype, "costCenterId", void 0);
84
91
  __decorate([
85
92
  (0, class_transformer_1.Expose)(),
86
93
  (0, class_validator_1.ValidateNested)(),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fiado/type-kit",
3
- "version": "3.646.0",
3
+ "version": "3.647.0",
4
4
  "description": "",
5
5
  "main": "bin/index.js",
6
6
  "types": "bin/index.d.ts",
@@ -17,6 +17,9 @@ export * from './enums/DisbursementType';
17
17
  export * from './constants/CollectionResultLimits';
18
18
  export * from './validators/IsCentPrecision';
19
19
 
20
+ // Interfaces
21
+ export * from './interfaces/TenantCostCenters';
22
+
20
23
  // DTOs
21
24
  export * from './dtos/PendingChargeDto';
22
25
  export * from './dtos/CollectRequest';
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Centros de costo de un tenant para los movimientos que paga desde su bolsa. Cada servicio que
3
+ * dispersa lee el suyo de la configuración del tenant; si falta, el ledger lo asienta como no asignado.
4
+ */
5
+ export interface TenantCostCenters {
6
+ /** Bono de bienvenida al alta del cliente. */
7
+ welcomeBonus?: string;
8
+ /** Promociones ligadas al crédito. */
9
+ creditPromotion?: string;
10
+ /** Promociones ligadas a la venta. */
11
+ salePromotion?: string;
12
+ /** Comisiones a vendedores. */
13
+ commission?: string;
14
+ }
@@ -56,4 +56,16 @@ export class PrivateGetReconciliationFeedRecordQuery {
56
56
  /** Email del operador cuando la lectura sale del detalle de una partida. */
57
57
  @OptionalEmail()
58
58
  actor?: string;
59
+
60
+ /**
61
+ * Centros de costo de la fuente, en csv (`a,b`) o repetidos. El dueño del feed del ledger solo
62
+ * devuelve el registro si pertenece a uno de ellos.
63
+ */
64
+ @Expose()
65
+ @IsOptional()
66
+ @Transform(({ value }) => (typeof value === 'string' ? value.split(',').map((id) => id.trim()) : value))
67
+ @IsArray()
68
+ @IsString({ each: true })
69
+ @IsNotEmpty({ each: true })
70
+ costCenterIds?: string[];
59
71
  }
@@ -77,6 +77,13 @@ export class PrivateAuthorizeReconciliationAdjustmentRequest {
77
77
  @IsNotEmpty()
78
78
  executionId?: string;
79
79
 
80
+ /** Centro de costo de la fuente ejecutada de la partida; el processor lo asienta en el ledger. */
81
+ @Expose()
82
+ @IsOptional()
83
+ @IsString()
84
+ @IsNotEmpty()
85
+ costCenterId?: string;
86
+
80
87
  @Expose()
81
88
  @ValidateNested()
82
89
  @Type(() => ReconciliationAdjustmentReference)