@fiado/type-kit 3.497.0 → 3.499.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/_test_/unit/loanCredit/dtos/createCustomerPaymentRequest.test.ts +5 -1
- package/_test_/unit/loanCredit/dtos/createSellerPaymentRequest.test.ts +3 -3
- package/_test_/unit/retailLoan/paymentContract.test.ts +7 -0
- package/_test_/unit/retailPromotions/evaluatedSalePromotion.test.ts +2 -0
- package/_test_/unit/retailPromotions/resolveSalePromotionKind.test.ts +2 -0
- package/_test_/unit/retailPromotions/salePromotionConditions.test.ts +71 -0
- package/bin/loanCredit/dtos/requests/CreateCustomerPaymentRequest.js +1 -1
- package/bin/loanCredit/dtos/requests/CreateSellerPaymentRequest.js +1 -1
- package/bin/retailLoan/dtos/CreateMyPaymentRequest.js +1 -1
- package/bin/retailPromotions/dtos/responses/WizardSalePromotionResponses.d.ts +15 -0
- package/package.json +1 -1
- package/src/loanCredit/dtos/requests/CreateCustomerPaymentRequest.ts +1 -1
- package/src/loanCredit/dtos/requests/CreateSellerPaymentRequest.ts +1 -1
- package/src/retailLoan/dtos/CreateMyPaymentRequest.ts +1 -1
- package/src/retailPromotions/dtos/responses/WizardSalePromotionResponses.ts +16 -0
|
@@ -65,7 +65,11 @@ describe('CreateCustomerPaymentRequest', () => {
|
|
|
65
65
|
expect(await errorProperties({ ...VALID, type: LoanCustomerPaymentTypeEnum.ADVANCE, installmentCount: 3 })).toEqual([]);
|
|
66
66
|
});
|
|
67
67
|
|
|
68
|
-
it
|
|
68
|
+
it('acepta adelantar una sola cuota', async () => {
|
|
69
|
+
expect(await errorProperties({ ...VALID, type: LoanCustomerPaymentTypeEnum.ADVANCE, installmentCount: 1 })).toEqual([]);
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
it.each([[0], [2.5], ['3']])('rechaza el número de cuotas %p', async installmentCount => {
|
|
69
73
|
expect(await errorProperties({ ...VALID, type: LoanCustomerPaymentTypeEnum.ADVANCE, installmentCount })).toEqual([
|
|
70
74
|
'installmentCount',
|
|
71
75
|
]);
|
|
@@ -51,9 +51,9 @@ describe('CreateSellerPaymentRequest', () => {
|
|
|
51
51
|
expect(await errorPaths({ ...BASE, idempotencyKey: 'no-uuid' })).toEqual(['idempotencyKey']);
|
|
52
52
|
});
|
|
53
53
|
|
|
54
|
-
it('cuotas
|
|
55
|
-
expect(await errorPaths({ ...BASE, type: 'ADVANCE', installmentCount:
|
|
56
|
-
expect(await errorPaths({ ...BASE, type: 'ADVANCE', installmentCount:
|
|
54
|
+
it('cuotas desde 1', async () => {
|
|
55
|
+
expect(await errorPaths({ ...BASE, type: 'ADVANCE', installmentCount: 0 })).toEqual(['installmentCount']);
|
|
56
|
+
expect(await errorPaths({ ...BASE, type: 'ADVANCE', installmentCount: 1 })).toEqual([]);
|
|
57
57
|
});
|
|
58
58
|
|
|
59
59
|
it('no declara CLABE: con whitelist se descarta y nunca llega al dominio', () => {
|
|
@@ -72,6 +72,13 @@ describe('CreateMyPaymentRequest', () => {
|
|
|
72
72
|
it.each([[0], [-1050], [10.123], ['1050']])('rechaza el monto %p', async expectedAmount => {
|
|
73
73
|
expect(await errorProperties({ type: MyPaymentTypeEnum.SETTLEMENT, expectedAmount })).toEqual(['expectedAmount']);
|
|
74
74
|
});
|
|
75
|
+
|
|
76
|
+
it('pagar por adelantado acepta desde una cuota', async () => {
|
|
77
|
+
expect(await errorProperties({ type: MyPaymentTypeEnum.ADVANCE, expectedAmount: 1050, installmentCount: 1 })).toEqual([]);
|
|
78
|
+
expect(await errorProperties({ type: MyPaymentTypeEnum.ADVANCE, expectedAmount: 1050, installmentCount: 0 })).toEqual([
|
|
79
|
+
'installmentCount',
|
|
80
|
+
]);
|
|
81
|
+
});
|
|
75
82
|
});
|
|
76
83
|
|
|
77
84
|
describe('retailLoan — opciones y respuesta del pago', () => {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import 'reflect-metadata';
|
|
2
2
|
import {
|
|
3
3
|
EvaluatedSalePromotion,
|
|
4
|
+
PromotionAppliesToEnum,
|
|
4
5
|
RetailPromotionsErrorCodeEnum,
|
|
5
6
|
SalePromotionKindEnum,
|
|
6
7
|
} from '../../../src/retailPromotions/index';
|
|
@@ -17,6 +18,7 @@ const basePromotion: EvaluatedSalePromotion = {
|
|
|
17
18
|
giftOptions: [],
|
|
18
19
|
giftChooseCount: null,
|
|
19
20
|
afterSale: [],
|
|
21
|
+
appliesTo: PromotionAppliesToEnum.SUREKEEP_ONLY,
|
|
20
22
|
};
|
|
21
23
|
|
|
22
24
|
describe('EvaluatedSalePromotion.blockedBy', () => {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import 'reflect-metadata';
|
|
2
2
|
import {
|
|
3
3
|
EvaluatedSalePromotion,
|
|
4
|
+
PromotionAppliesToEnum,
|
|
4
5
|
SalePromotionKindEnum,
|
|
5
6
|
SalePromotionLeverEnum,
|
|
6
7
|
resolveSalePromotionKind,
|
|
@@ -40,6 +41,7 @@ describe('EvaluatedSalePromotion.kind', () => {
|
|
|
40
41
|
giftOptions: [],
|
|
41
42
|
giftChooseCount: 1,
|
|
42
43
|
afterSale: [],
|
|
44
|
+
appliesTo: PromotionAppliesToEnum.SUREKEEP_ONLY,
|
|
43
45
|
};
|
|
44
46
|
expect(promotion.kind).toBe(SalePromotionKindEnum.GIFT);
|
|
45
47
|
});
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import 'reflect-metadata';
|
|
2
|
+
import {
|
|
3
|
+
EvaluatedSalePromotion,
|
|
4
|
+
PromotionAppliesToEnum,
|
|
5
|
+
RetailPromotionsErrorCodeEnum,
|
|
6
|
+
SalePromotionConditions,
|
|
7
|
+
SalePromotionKindEnum,
|
|
8
|
+
StoreSalePromotionItem,
|
|
9
|
+
} from '../../../src/retailPromotions/index';
|
|
10
|
+
|
|
11
|
+
const storeItem: StoreSalePromotionItem = {
|
|
12
|
+
promotionId: 'promo-1',
|
|
13
|
+
version: 1,
|
|
14
|
+
name: 'Regalo',
|
|
15
|
+
customerText: 'Llévate un regalo',
|
|
16
|
+
levers: { gift: null, deviceDiscount: null, accessoryDiscount: null, coupon: null, walletBonus: null, extendedWarranty: null, airtime: null },
|
|
17
|
+
scope: { storeIds: null, productCategories: null, tiers: null, skus: null },
|
|
18
|
+
appliesTo: PromotionAppliesToEnum.ANY_FINANCIER,
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
const evaluated: EvaluatedSalePromotion = {
|
|
22
|
+
promotionId: 'promo-1',
|
|
23
|
+
version: 1,
|
|
24
|
+
kind: SalePromotionKindEnum.SALE,
|
|
25
|
+
name: 'Regalo',
|
|
26
|
+
customerText: 'Llévate un regalo',
|
|
27
|
+
levers: [],
|
|
28
|
+
lines: [],
|
|
29
|
+
totalDiscountCents: 0,
|
|
30
|
+
giftOptions: [],
|
|
31
|
+
giftChooseCount: null,
|
|
32
|
+
afterSale: [],
|
|
33
|
+
appliesTo: PromotionAppliesToEnum.SUREKEEP_ONLY,
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
describe('SalePromotionConditions', () => {
|
|
37
|
+
it('todas sus llaves son opcionales', () => {
|
|
38
|
+
const none: SalePromotionConditions = {};
|
|
39
|
+
expect(Object.keys(none)).toHaveLength(0);
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
it('acepta las tres condiciones del cliente', () => {
|
|
43
|
+
const all: SalePromotionConditions = { oncePerCustomer: true, requiresActiveSurekeepCredit: true, segmentIds: ['seg-1'] };
|
|
44
|
+
expect(all.segmentIds).toEqual(['seg-1']);
|
|
45
|
+
});
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
describe('StoreSalePromotionItem', () => {
|
|
49
|
+
it('trae appliesTo y no trae condiciones ni bloqueo cuando no aplican', () => {
|
|
50
|
+
expect(storeItem.appliesTo).toBe(PromotionAppliesToEnum.ANY_FINANCIER);
|
|
51
|
+
expect(storeItem.conditions).toBeUndefined();
|
|
52
|
+
expect(storeItem.blockedBy).toBeUndefined();
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
it('acepta condiciones y el motivo de bloqueo', () => {
|
|
56
|
+
const blocked: StoreSalePromotionItem = {
|
|
57
|
+
...storeItem,
|
|
58
|
+
conditions: { oncePerCustomer: true },
|
|
59
|
+
blockedBy: RetailPromotionsErrorCodeEnum.CUSTOMER_NOT_IDENTIFIED,
|
|
60
|
+
};
|
|
61
|
+
expect(blocked.blockedBy).toBe(RetailPromotionsErrorCodeEnum.CUSTOMER_NOT_IDENTIFIED);
|
|
62
|
+
});
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
describe('EvaluatedSalePromotion', () => {
|
|
66
|
+
it('trae appliesTo y condiciones opcionales', () => {
|
|
67
|
+
const withConditions: EvaluatedSalePromotion = { ...evaluated, conditions: { requiresActiveSurekeepCredit: true } };
|
|
68
|
+
expect(withConditions.appliesTo).toBe(PromotionAppliesToEnum.SUREKEEP_ONLY);
|
|
69
|
+
expect(withConditions.conditions?.requiresActiveSurekeepCredit).toBe(true);
|
|
70
|
+
});
|
|
71
|
+
});
|
|
@@ -37,6 +37,6 @@ __decorate([
|
|
|
37
37
|
(0, class_transformer_1.Expose)(),
|
|
38
38
|
(0, class_validator_1.IsOptional)(),
|
|
39
39
|
(0, class_validator_1.IsInt)(),
|
|
40
|
-
(0, class_validator_1.Min)(
|
|
40
|
+
(0, class_validator_1.Min)(1),
|
|
41
41
|
__metadata("design:type", Number)
|
|
42
42
|
], CreateCustomerPaymentRequest.prototype, "installmentCount", void 0);
|
|
@@ -34,7 +34,7 @@ __decorate([
|
|
|
34
34
|
(0, class_transformer_1.Expose)(),
|
|
35
35
|
(0, class_validator_1.IsOptional)(),
|
|
36
36
|
(0, class_validator_1.IsInt)(),
|
|
37
|
-
(0, class_validator_1.Min)(
|
|
37
|
+
(0, class_validator_1.Min)(1),
|
|
38
38
|
__metadata("design:type", Number)
|
|
39
39
|
], CreateSellerPaymentRequest.prototype, "installmentCount", void 0);
|
|
40
40
|
__decorate([
|
|
@@ -32,6 +32,6 @@ __decorate([
|
|
|
32
32
|
(0, class_transformer_1.Expose)(),
|
|
33
33
|
(0, class_validator_1.IsOptional)(),
|
|
34
34
|
(0, class_validator_1.IsInt)(),
|
|
35
|
-
(0, class_validator_1.Min)(
|
|
35
|
+
(0, class_validator_1.Min)(1),
|
|
36
36
|
__metadata("design:type", Number)
|
|
37
37
|
], CreateMyPaymentRequest.prototype, "installmentCount", void 0);
|
|
@@ -2,6 +2,7 @@ import { CouponScopeEnum } from '../../enums/CouponScopeEnum';
|
|
|
2
2
|
import { CouponStatusEnum } from '../../enums/CouponStatusEnum';
|
|
3
3
|
import { EntitlementKindEnum } from '../../enums/EntitlementKindEnum';
|
|
4
4
|
import { EntitlementStateEnum } from '../../enums/EntitlementStateEnum';
|
|
5
|
+
import { PromotionAppliesToEnum } from '../../enums/PromotionAppliesToEnum';
|
|
5
6
|
import { RetailPromotionsErrorCodeEnum } from '../../enums/RetailPromotionsErrorCodeEnum';
|
|
6
7
|
import { SaleCouponAvailabilityEnum } from '../../enums/SaleCouponAvailabilityEnum';
|
|
7
8
|
import { SalePromotionKindEnum } from '../../enums/SalePromotionKindEnum';
|
|
@@ -9,6 +10,12 @@ import { SalePromotionLeverEnum } from '../../enums/SalePromotionLeverEnum';
|
|
|
9
10
|
import { DiscountValue } from '../DiscountValue';
|
|
10
11
|
import { LinePromotionDiscount } from '../LinePromotionDiscount';
|
|
11
12
|
import { SalePromotionLevers, SalePromotionScope } from '../SalePromotionLevers';
|
|
13
|
+
/** Condiciones del cliente que pide la promo; solo vienen las que aplican. */
|
|
14
|
+
export interface SalePromotionConditions {
|
|
15
|
+
oncePerCustomer?: boolean;
|
|
16
|
+
requiresActiveSurekeepCredit?: boolean;
|
|
17
|
+
segmentIds?: string[];
|
|
18
|
+
}
|
|
12
19
|
/** Promo vigente en la tienda de la sesión, para los chips de «Elige el teléfono». */
|
|
13
20
|
export interface StoreSalePromotionItem {
|
|
14
21
|
promotionId: string;
|
|
@@ -18,6 +25,11 @@ export interface StoreSalePromotionItem {
|
|
|
18
25
|
levers: SalePromotionLevers;
|
|
19
26
|
/** Para cruzar con cada equipo; todo `null` = fila «Toda la tienda». */
|
|
20
27
|
scope: SalePromotionScope;
|
|
28
|
+
/** SUREKEEP_ONLY = solo con crédito SureKeep; ANY_FINANCIER = también contado o derivada. */
|
|
29
|
+
appliesTo: PromotionAppliesToEnum;
|
|
30
|
+
conditions?: SalePromotionConditions;
|
|
31
|
+
/** Si viene, todavía no se puede decidir para este cliente (ej. CUSTOMER_NOT_IDENTIFIED). */
|
|
32
|
+
blockedBy?: RetailPromotionsErrorCodeEnum | null;
|
|
21
33
|
}
|
|
22
34
|
export interface ListStoreSalePromotionsResponse {
|
|
23
35
|
items: StoreSalePromotionItem[];
|
|
@@ -49,6 +61,9 @@ export interface EvaluatedSalePromotion {
|
|
|
49
61
|
giftOptions: GiftOption[];
|
|
50
62
|
giftChooseCount: number | null;
|
|
51
63
|
afterSale: AfterSaleBenefit[];
|
|
64
|
+
/** SUREKEEP_ONLY = solo con crédito SureKeep; ANY_FINANCIER = también contado o derivada. */
|
|
65
|
+
appliesTo: PromotionAppliesToEnum;
|
|
66
|
+
conditions?: SalePromotionConditions;
|
|
52
67
|
/** Si viene, la promo se muestra pero no se puede elegir; dice por qué (ej. CUSTOMER_NOT_IDENTIFIED). */
|
|
53
68
|
blockedBy?: RetailPromotionsErrorCodeEnum | null;
|
|
54
69
|
}
|
package/package.json
CHANGED
|
@@ -2,6 +2,7 @@ import { CouponScopeEnum } from '../../enums/CouponScopeEnum';
|
|
|
2
2
|
import { CouponStatusEnum } from '../../enums/CouponStatusEnum';
|
|
3
3
|
import { EntitlementKindEnum } from '../../enums/EntitlementKindEnum';
|
|
4
4
|
import { EntitlementStateEnum } from '../../enums/EntitlementStateEnum';
|
|
5
|
+
import { PromotionAppliesToEnum } from '../../enums/PromotionAppliesToEnum';
|
|
5
6
|
import { RetailPromotionsErrorCodeEnum } from '../../enums/RetailPromotionsErrorCodeEnum';
|
|
6
7
|
import { SaleCouponAvailabilityEnum } from '../../enums/SaleCouponAvailabilityEnum';
|
|
7
8
|
import { SalePromotionKindEnum } from '../../enums/SalePromotionKindEnum';
|
|
@@ -10,6 +11,13 @@ import { DiscountValue } from '../DiscountValue';
|
|
|
10
11
|
import { LinePromotionDiscount } from '../LinePromotionDiscount';
|
|
11
12
|
import { SalePromotionLevers, SalePromotionScope } from '../SalePromotionLevers';
|
|
12
13
|
|
|
14
|
+
/** Condiciones del cliente que pide la promo; solo vienen las que aplican. */
|
|
15
|
+
export interface SalePromotionConditions {
|
|
16
|
+
oncePerCustomer?: boolean;
|
|
17
|
+
requiresActiveSurekeepCredit?: boolean;
|
|
18
|
+
segmentIds?: string[];
|
|
19
|
+
}
|
|
20
|
+
|
|
13
21
|
/** Promo vigente en la tienda de la sesión, para los chips de «Elige el teléfono». */
|
|
14
22
|
export interface StoreSalePromotionItem {
|
|
15
23
|
promotionId: string;
|
|
@@ -19,6 +27,11 @@ export interface StoreSalePromotionItem {
|
|
|
19
27
|
levers: SalePromotionLevers;
|
|
20
28
|
/** Para cruzar con cada equipo; todo `null` = fila «Toda la tienda». */
|
|
21
29
|
scope: SalePromotionScope;
|
|
30
|
+
/** SUREKEEP_ONLY = solo con crédito SureKeep; ANY_FINANCIER = también contado o derivada. */
|
|
31
|
+
appliesTo: PromotionAppliesToEnum;
|
|
32
|
+
conditions?: SalePromotionConditions;
|
|
33
|
+
/** Si viene, todavía no se puede decidir para este cliente (ej. CUSTOMER_NOT_IDENTIFIED). */
|
|
34
|
+
blockedBy?: RetailPromotionsErrorCodeEnum | null;
|
|
22
35
|
}
|
|
23
36
|
|
|
24
37
|
export interface ListStoreSalePromotionsResponse {
|
|
@@ -54,6 +67,9 @@ export interface EvaluatedSalePromotion {
|
|
|
54
67
|
giftOptions: GiftOption[];
|
|
55
68
|
giftChooseCount: number | null;
|
|
56
69
|
afterSale: AfterSaleBenefit[];
|
|
70
|
+
/** SUREKEEP_ONLY = solo con crédito SureKeep; ANY_FINANCIER = también contado o derivada. */
|
|
71
|
+
appliesTo: PromotionAppliesToEnum;
|
|
72
|
+
conditions?: SalePromotionConditions;
|
|
57
73
|
/** Si viene, la promo se muestra pero no se puede elegir; dice por qué (ej. CUSTOMER_NOT_IDENTIFIED). */
|
|
58
74
|
blockedBy?: RetailPromotionsErrorCodeEnum | null;
|
|
59
75
|
}
|