@pedro.araujo/ml-architecture-shared 0.1.45 → 0.1.47
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/dist/item-financial-event/create-item-financial-event-request.dto.d.ts +3 -3
- package/dist/item-financial-event/create-item-financial-event-request.dto.d.ts.map +1 -1
- package/dist/item-financial-event/create-item-financial-event-request.schema.d.ts.map +1 -1
- package/dist/item-financial-event/create-item-financial-event-request.schema.js +45 -3
- package/package.json +1 -1
|
@@ -6,8 +6,8 @@ export interface CreateItemFinancialEventRequestDTO {
|
|
|
6
6
|
occurredAt: string;
|
|
7
7
|
paymentType: PaymentType;
|
|
8
8
|
totalAmount: number;
|
|
9
|
-
downPayment?: number;
|
|
10
|
-
installmentsQty?: number;
|
|
11
|
-
note
|
|
9
|
+
downPayment?: number | null;
|
|
10
|
+
installmentsQty?: number | null;
|
|
11
|
+
note: string;
|
|
12
12
|
}
|
|
13
13
|
//# sourceMappingURL=create-item-financial-event-request.dto.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-item-financial-event-request.dto.d.ts","sourceRoot":"","sources":["../../src/item-financial-event/create-item-financial-event-request.dto.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,qCAAqC,CAAC;AAC7E,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAErD,MAAM,WAAW,kCAAkC;IACjD,aAAa,EAAE,MAAM,CAAC;IACtB,SAAS,EAAE,sBAAsB,CAAC;IAClC,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,WAAW,CAAC;IACzB,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,CAAC,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"create-item-financial-event-request.dto.d.ts","sourceRoot":"","sources":["../../src/item-financial-event/create-item-financial-event-request.dto.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,qCAAqC,CAAC;AAC7E,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAErD,MAAM,WAAW,kCAAkC;IACjD,aAAa,EAAE,MAAM,CAAC;IACtB,SAAS,EAAE,sBAAsB,CAAC;IAClC,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,WAAW,CAAC;IACzB,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,eAAe,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAChC,IAAI,EAAE,MAAM,CAAC;CACd"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-item-financial-event-request.schema.d.ts","sourceRoot":"","sources":["../../src/item-financial-event/create-item-financial-event-request.schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,OAAO,EAAE,kCAAkC,EAAE,MAAM,8CAA8C,CAAC;AAElG,eAAO,MAAM,qCAAqC,EAAE,CAAC,CAAC,OAAO,CAAC,kCAAkC,
|
|
1
|
+
{"version":3,"file":"create-item-financial-event-request.schema.d.ts","sourceRoot":"","sources":["../../src/item-financial-event/create-item-financial-event-request.schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,OAAO,EAAE,kCAAkC,EAAE,MAAM,8CAA8C,CAAC;AAElG,eAAO,MAAM,qCAAqC,EAAE,CAAC,CAAC,OAAO,CAAC,kCAAkC,CA4D5F,CAAC"}
|
|
@@ -7,7 +7,49 @@ export const CreateItemFinancialEventRequestSchema = z.object({
|
|
|
7
7
|
occurredAt: z.iso.datetime(),
|
|
8
8
|
paymentType: z.enum(PaymentType),
|
|
9
9
|
totalAmount: z.coerce.number().positive(),
|
|
10
|
-
downPayment: z.coerce.number().
|
|
11
|
-
installmentsQty: z.coerce.number().int().positive().optional(),
|
|
12
|
-
note: z.string().max(1000)
|
|
10
|
+
downPayment: z.coerce.number().positive().nullable().optional(),
|
|
11
|
+
installmentsQty: z.coerce.number().int().positive().nullable().optional(),
|
|
12
|
+
note: z.string().max(1000),
|
|
13
|
+
})
|
|
14
|
+
.superRefine((data, ctx) => {
|
|
15
|
+
const { paymentType, installmentsQty, downPayment, totalAmount, } = data;
|
|
16
|
+
if (paymentType === PaymentType.INSTALLMENT) {
|
|
17
|
+
if (!installmentsQty) {
|
|
18
|
+
ctx.addIssue({
|
|
19
|
+
path: ["installmentsQty"],
|
|
20
|
+
message: "Quantidade de parcelas é obrigatória para pagamento parcelado",
|
|
21
|
+
code: z.ZodIssueCode.custom,
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
else if (installmentsQty < 1) {
|
|
25
|
+
ctx.addIssue({
|
|
26
|
+
path: ["installmentsQty"],
|
|
27
|
+
message: "Pagamento parcelado deve ter no mínimo 1 parcela",
|
|
28
|
+
code: z.ZodIssueCode.custom,
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
if (paymentType !== PaymentType.INSTALLMENT && installmentsQty) {
|
|
33
|
+
ctx.addIssue({
|
|
34
|
+
path: ["installmentsQty"],
|
|
35
|
+
message: "parcelas só são permitidas para pagamento parcelado",
|
|
36
|
+
code: z.ZodIssueCode.custom,
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
if (downPayment !== undefined) {
|
|
40
|
+
if (paymentType !== PaymentType.INSTALLMENT) {
|
|
41
|
+
ctx.addIssue({
|
|
42
|
+
path: ["downPayment"],
|
|
43
|
+
message: "entrada só é permitida para pagamento parcelado",
|
|
44
|
+
code: z.ZodIssueCode.custom,
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
if (downPayment !== null && downPayment >= totalAmount) {
|
|
48
|
+
ctx.addIssue({
|
|
49
|
+
path: ["downPayment"],
|
|
50
|
+
message: "entrada deve ser menor que o valor total",
|
|
51
|
+
code: z.ZodIssueCode.custom,
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
}
|
|
13
55
|
});
|