@fiado/type-kit 3.566.0 → 3.567.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/retailCustomer/customerReferralContract.test.ts +8 -0
- package/_test_/unit/retailWizard/backofficeCustomerReferrals.test.ts +13 -0
- package/_test_/unit/retailWizard/promotionM2mRequests.test.ts +10 -0
- package/bin/retailCustomer/dtos/requests/CreateCustomerReferralsRequest.d.ts +2 -0
- package/bin/retailCustomer/dtos/requests/CreateCustomerReferralsRequest.js +7 -0
- package/bin/retailWizard/dtos/responses/BackofficeCustomerReferralsResponse.d.ts +2 -0
- package/bin/retailWizard/dtos/responses/PrivateWizardSessionResponse.d.ts +4 -0
- package/package.json +1 -1
- package/src/retailCustomer/dtos/requests/CreateCustomerReferralsRequest.ts +7 -0
- package/src/retailWizard/dtos/responses/BackofficeCustomerReferralsResponse.ts +2 -0
- package/src/retailWizard/dtos/responses/PrivateWizardSessionResponse.ts +4 -0
|
@@ -61,6 +61,7 @@ describe('enums de referidos', () => {
|
|
|
61
61
|
|
|
62
62
|
const SALE_BATCH = {
|
|
63
63
|
source: 'SALE',
|
|
64
|
+
retailerId: 'r-1',
|
|
64
65
|
storeId: 'st-1',
|
|
65
66
|
wizardSessionId: 'ws-1',
|
|
66
67
|
capturedBy: 'seller-1',
|
|
@@ -98,6 +99,13 @@ describe('CreateCustomerReferralsRequest', () => {
|
|
|
98
99
|
expect(errorsOf(CreateCustomerReferralsRequest, { ...SALE_BATCH, capturedBy: ' ' })).toContain('capturedBy');
|
|
99
100
|
});
|
|
100
101
|
|
|
102
|
+
it('exige la cadena de captura, también desde el cajón', () => {
|
|
103
|
+
const { retailerId: _retailerId, ...noRetailer } = SALE_BATCH;
|
|
104
|
+
expect(errorsOf(CreateCustomerReferralsRequest, noRetailer)).toEqual(['retailerId']);
|
|
105
|
+
expect(errorsOf(CreateCustomerReferralsRequest, { ...noRetailer, source: 'BACKOFFICE' })).toEqual(['retailerId']);
|
|
106
|
+
expect(errorsOf(CreateCustomerReferralsRequest, { ...SALE_BATCH, retailerId: ' ' })).toEqual(['retailerId']);
|
|
107
|
+
});
|
|
108
|
+
|
|
101
109
|
it('rechaza un origen fuera del catálogo', () => {
|
|
102
110
|
expect(errorsOf(CreateCustomerReferralsRequest, { ...SALE_BATCH, source: 'WEB' })).toContain('source');
|
|
103
111
|
});
|
|
@@ -45,6 +45,19 @@ describe('BackofficeCustomerReferralsResponse', () => {
|
|
|
45
45
|
expect(response.referrals[0].capture.source).toBe('SALE');
|
|
46
46
|
});
|
|
47
47
|
|
|
48
|
+
it('acepta el nombre visible de quien capturó, opcional y nullable', () => {
|
|
49
|
+
const named: BackofficeCustomerReferral = {
|
|
50
|
+
...referral,
|
|
51
|
+
capture: { ...referral.capture, capturedByName: 'Laura Méndez (Admin SK)' },
|
|
52
|
+
};
|
|
53
|
+
const unresolved: BackofficeCustomerReferral = { ...referral, capture: { ...referral.capture, capturedByName: null } };
|
|
54
|
+
expect([named.capture.capturedByName, unresolved.capture.capturedByName, referral.capture.capturedByName]).toEqual([
|
|
55
|
+
'Laura Méndez (Admin SK)',
|
|
56
|
+
null,
|
|
57
|
+
undefined,
|
|
58
|
+
]);
|
|
59
|
+
});
|
|
60
|
+
|
|
48
61
|
it('suma premios por referido y el bloque «llegó recomendado por» en la tanda B', () => {
|
|
49
62
|
const response: BackofficeCustomerReferralsResponse = {
|
|
50
63
|
referrals: [{ ...referral, rewards: [{ ...reward, role: ReferralRoleEnum.REFERRER }] }],
|
|
@@ -256,5 +256,15 @@ describe('respuestas de los M2M de Promociones', () => {
|
|
|
256
256
|
undefined,
|
|
257
257
|
]);
|
|
258
258
|
expect(asString).toBeDefined();
|
|
259
|
+
|
|
260
|
+
const referred: PrivateWizardSessionResponse = { ...base, customerPhone: '5512345678', customerPurchaseNumber: 2 };
|
|
261
|
+
// @ts-expect-error el número de compra es numérico
|
|
262
|
+
const purchaseAsString: PrivateWizardSessionResponse = { ...base, customerPurchaseNumber: '2' };
|
|
263
|
+
expect([referred.customerPhone, referred.customerPurchaseNumber, base.customerPurchaseNumber]).toEqual([
|
|
264
|
+
'5512345678',
|
|
265
|
+
2,
|
|
266
|
+
undefined,
|
|
267
|
+
]);
|
|
268
|
+
expect(purchaseAsString).toBeDefined();
|
|
259
269
|
});
|
|
260
270
|
});
|
|
@@ -8,6 +8,8 @@ export declare class CustomerReferralInput {
|
|
|
8
8
|
/** Body de `privateCreateCustomerReferrals`: lote de referidos de un cliente. */
|
|
9
9
|
export declare class CreateCustomerReferralsRequest {
|
|
10
10
|
source: ReferralSourceEnum;
|
|
11
|
+
/** Cadena donde se captura el referido; «gana el primero» busca por cadena + teléfono. */
|
|
12
|
+
retailerId: string;
|
|
11
13
|
/** Tienda de captura; obligatoria en venta y apertura. */
|
|
12
14
|
storeId?: string;
|
|
13
15
|
wizardSessionId?: string;
|
|
@@ -52,6 +52,13 @@ __decorate([
|
|
|
52
52
|
(0, class_validator_1.IsEnum)(ReferralSourceEnum_1.ReferralSourceEnum),
|
|
53
53
|
__metadata("design:type", String)
|
|
54
54
|
], CreateCustomerReferralsRequest.prototype, "source", void 0);
|
|
55
|
+
__decorate([
|
|
56
|
+
(0, class_transformer_1.Expose)(),
|
|
57
|
+
(0, Trim_1.Trim)(),
|
|
58
|
+
(0, class_validator_1.IsString)(),
|
|
59
|
+
(0, class_validator_1.IsNotEmpty)(),
|
|
60
|
+
__metadata("design:type", String)
|
|
61
|
+
], CreateCustomerReferralsRequest.prototype, "retailerId", void 0);
|
|
55
62
|
__decorate([
|
|
56
63
|
(0, class_transformer_1.Expose)(),
|
|
57
64
|
(0, class_validator_1.ValidateIf)((o) => o.source !== ReferralSourceEnum_1.ReferralSourceEnum.BACKOFFICE || o.storeId !== undefined),
|
|
@@ -26,6 +26,8 @@ export interface BackofficeReferralCapture {
|
|
|
26
26
|
/** Solo en `OPENING`. */
|
|
27
27
|
accountOpeningSessionId: string | null;
|
|
28
28
|
capturedBy: string;
|
|
29
|
+
/** Nombre visible de quien capturó; `null` si no se resolvió. */
|
|
30
|
+
capturedByName?: string | null;
|
|
29
31
|
capturedAt: string;
|
|
30
32
|
}
|
|
31
33
|
/** Referido del cliente en el cajón. */
|
|
@@ -34,4 +34,8 @@ export interface PrivateWizardSessionResponse {
|
|
|
34
34
|
payment?: WizardPayment | null;
|
|
35
35
|
/** Valor efectivo del flag SPLIT_FINANCING_ENABLED del wizard. */
|
|
36
36
|
splitFinancingEnabled?: boolean;
|
|
37
|
+
/** Teléfono del cliente de la sesión, 10 dígitos. */
|
|
38
|
+
customerPhone?: string;
|
|
39
|
+
/** Número de compra que sería esta venta en la cadena: 1 + ventas previas no canceladas. */
|
|
40
|
+
customerPurchaseNumber?: number;
|
|
37
41
|
}
|
package/package.json
CHANGED
|
@@ -46,6 +46,13 @@ export class CreateCustomerReferralsRequest {
|
|
|
46
46
|
@IsEnum(ReferralSourceEnum)
|
|
47
47
|
source!: ReferralSourceEnum;
|
|
48
48
|
|
|
49
|
+
/** Cadena donde se captura el referido; «gana el primero» busca por cadena + teléfono. */
|
|
50
|
+
@Expose()
|
|
51
|
+
@Trim()
|
|
52
|
+
@IsString()
|
|
53
|
+
@IsNotEmpty()
|
|
54
|
+
retailerId!: string;
|
|
55
|
+
|
|
49
56
|
/** Tienda de captura; obligatoria en venta y apertura. */
|
|
50
57
|
@Expose()
|
|
51
58
|
@ValidateIf((o: CreateCustomerReferralsRequest) => o.source !== ReferralSourceEnum.BACKOFFICE || o.storeId !== undefined)
|
|
@@ -28,6 +28,8 @@ export interface BackofficeReferralCapture {
|
|
|
28
28
|
/** Solo en `OPENING`. */
|
|
29
29
|
accountOpeningSessionId: string | null;
|
|
30
30
|
capturedBy: string;
|
|
31
|
+
/** Nombre visible de quien capturó; `null` si no se resolvió. */
|
|
32
|
+
capturedByName?: string | null;
|
|
31
33
|
capturedAt: string;
|
|
32
34
|
}
|
|
33
35
|
|
|
@@ -35,4 +35,8 @@ export interface PrivateWizardSessionResponse {
|
|
|
35
35
|
payment?: WizardPayment | null;
|
|
36
36
|
/** Valor efectivo del flag SPLIT_FINANCING_ENABLED del wizard. */
|
|
37
37
|
splitFinancingEnabled?: boolean;
|
|
38
|
+
/** Teléfono del cliente de la sesión, 10 dígitos. */
|
|
39
|
+
customerPhone?: string;
|
|
40
|
+
/** Número de compra que sería esta venta en la cadena: 1 + ventas previas no canceladas. */
|
|
41
|
+
customerPurchaseNumber?: number;
|
|
38
42
|
}
|