@fiado/type-kit 3.653.0 → 3.654.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.
@@ -45,6 +45,21 @@ describe('CatalogItemRequest', () => {
45
45
  expect(await props(asCatalog(override))).toContain(property);
46
46
  });
47
47
 
48
+ it('costCenterId es opcional: ausente, null o un texto de hasta 64', async () => {
49
+ expect(await validate(asCatalog())).toHaveLength(0);
50
+ expect(await validate(asCatalog({ costCenterId: null }))).toHaveLength(0);
51
+ expect(await validate(asCatalog({ costCenterId: 'CC-VENTA-CELULARES' }))).toHaveLength(0);
52
+ expect(asCatalog({ costCenterId: 'CC-1' }).costCenterId).toBe('CC-1');
53
+ });
54
+
55
+ it.each<[string, JsonValue]>([
56
+ ['vacío', ''],
57
+ ['> 64', 'c'.repeat(65)],
58
+ ['no texto', 5],
59
+ ])('rechaza costCenterId %s', async (_nombre, costCenterId) => {
60
+ expect(await props(asCatalog({ costCenterId }))).toContain('costCenterId');
61
+ });
62
+
48
63
  it('acepta costo 0 (recompensa gratuita para el aliado)', async () => {
49
64
  expect(await validate(asCatalog({ cost: { amount: 0, currency: 'MXN' } }))).toHaveLength(0);
50
65
  });
@@ -15,5 +15,10 @@ export declare class CatalogItemRequest {
15
15
  };
16
16
  cost: RewardCostInput;
17
17
  chargeTo: RewardChargeToInput;
18
+ /**
19
+ * Centro de costo con que el ledger imputa lo que esta recompensa paga (saldo, recarga). Viaja en cada
20
+ * `disburse`. Ausente o `null` = sin centro: el pago se asienta como `UNASSIGNED`.
21
+ */
22
+ costCenterId?: string | null;
18
23
  status: RewardStatusEnum;
19
24
  }
@@ -12,6 +12,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.CatalogItemRequest = void 0;
13
13
  const class_transformer_1 = require("class-transformer");
14
14
  const class_validator_1 = require("class-validator");
15
+ const costCenter_1 = require("../../../transaction/constants/costCenter");
15
16
  const BackofficeLimits_1 = require("../../constants/BackofficeLimits");
16
17
  const RewardStatusEnum_1 = require("../../enums/RewardStatusEnum");
17
18
  const RewardChargeToInput_1 = require("./RewardChargeToInput");
@@ -63,6 +64,14 @@ __decorate([
63
64
  (0, class_transformer_1.Type)(() => RewardChargeToInput_1.RewardChargeToInput),
64
65
  __metadata("design:type", RewardChargeToInput_1.RewardChargeToInput)
65
66
  ], CatalogItemRequest.prototype, "chargeTo", void 0);
67
+ __decorate([
68
+ (0, class_transformer_1.Expose)(),
69
+ (0, class_validator_1.IsOptional)(),
70
+ (0, class_validator_1.IsString)(),
71
+ (0, class_validator_1.IsNotEmpty)(),
72
+ (0, class_validator_1.MaxLength)(costCenter_1.COST_CENTER_ID_MAX_LENGTH),
73
+ __metadata("design:type", String)
74
+ ], CatalogItemRequest.prototype, "costCenterId", void 0);
66
75
  __decorate([
67
76
  (0, class_transformer_1.Expose)(),
68
77
  (0, class_validator_1.IsEnum)(RewardStatusEnum_1.RewardStatusEnum),
@@ -13,6 +13,8 @@ export declare class CatalogItemResponse {
13
13
  };
14
14
  cost: RewardCost;
15
15
  chargeTo: RewardChargeTo;
16
+ /** Centro de costo de lo que paga esta recompensa; ausente = `UNASSIGNED` en el ledger. */
17
+ costCenterId?: string;
16
18
  /** Solo lectura: las calcula el tipo a partir de `config`. */
17
19
  dependencies: RewardDependency[];
18
20
  status: RewardStatusEnum;
@@ -11,4 +11,6 @@ export interface MobileTopupContributionResponse {
11
11
  carrier?: MobileTopupContributionCarrier;
12
12
  /** Precio unitario cobrado al aliado (MXN, 2 decimales); no cambia nunca. Solo falta en aportes legacy. */
13
13
  unitPrice?: number;
14
+ /** Centro de costo del ítem al otorgar; lo llevan todas las recargas del aporte. Ausente = `UNASSIGNED`. */
15
+ costCenterId?: string;
14
16
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fiado/type-kit",
3
- "version": "3.653.0",
3
+ "version": "3.654.0",
4
4
  "description": "",
5
5
  "main": "bin/index.js",
6
6
  "types": "bin/index.d.ts",
@@ -1,6 +1,7 @@
1
1
  import { Expose, Type } from 'class-transformer';
2
- import { IsEnum, IsNotEmpty, IsObject, IsString, Matches, MaxLength, ValidateNested } from 'class-validator';
2
+ import { IsEnum, IsNotEmpty, IsObject, IsOptional, IsString, Matches, MaxLength, ValidateNested } from 'class-validator';
3
3
  import { JsonValue } from '../../../common';
4
+ import { COST_CENTER_ID_MAX_LENGTH } from '../../../transaction/constants/costCenter';
4
5
  import { REWARD_ID_PATTERN } from '../../constants/BackofficeLimits';
5
6
  import { RewardStatusEnum } from '../../enums/RewardStatusEnum';
6
7
  import { RewardChargeToInput } from './RewardChargeToInput';
@@ -46,6 +47,17 @@ export class CatalogItemRequest {
46
47
  @Type(() => RewardChargeToInput)
47
48
  chargeTo: RewardChargeToInput;
48
49
 
50
+ /**
51
+ * Centro de costo con que el ledger imputa lo que esta recompensa paga (saldo, recarga). Viaja en cada
52
+ * `disburse`. Ausente o `null` = sin centro: el pago se asienta como `UNASSIGNED`.
53
+ */
54
+ @Expose()
55
+ @IsOptional()
56
+ @IsString()
57
+ @IsNotEmpty()
58
+ @MaxLength(COST_CENTER_ID_MAX_LENGTH)
59
+ costCenterId?: string | null;
60
+
49
61
  @Expose()
50
62
  @IsEnum(RewardStatusEnum)
51
63
  status: RewardStatusEnum;
@@ -12,6 +12,8 @@ export class CatalogItemResponse {
12
12
  config: { [key: string]: JsonValue };
13
13
  cost: RewardCost;
14
14
  chargeTo: RewardChargeTo;
15
+ /** Centro de costo de lo que paga esta recompensa; ausente = `UNASSIGNED` en el ledger. */
16
+ costCenterId?: string;
15
17
  /** Solo lectura: las calcula el tipo a partir de `config`. */
16
18
  dependencies: RewardDependency[];
17
19
  status: RewardStatusEnum;
@@ -12,4 +12,6 @@ export interface MobileTopupContributionResponse {
12
12
  carrier?: MobileTopupContributionCarrier;
13
13
  /** Precio unitario cobrado al aliado (MXN, 2 decimales); no cambia nunca. Solo falta en aportes legacy. */
14
14
  unitPrice?: number;
15
+ /** Centro de costo del ítem al otorgar; lo llevan todas las recargas del aporte. Ausente = `UNASSIGNED`. */
16
+ costCenterId?: string;
15
17
  }