@pedro.araujo/ml-architecture-shared 0.1.119 → 0.1.120

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.
@@ -10,6 +10,7 @@ export interface CreateItemFinancialEventRequestDTO {
10
10
  totalAmount: number;
11
11
  downPayment?: number | null;
12
12
  installmentsQty?: number | null;
13
+ firstInstallmentDueDate?: string | null;
13
14
  note: string;
14
15
  users?: {
15
16
  userId: number;
@@ -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,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,aAAa,EAAE,MAAM,CAAC;IACtB,SAAS,EAAE,sBAAsB,CAAC;IAClC,cAAc,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,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;IAEb,KAAK,CAAC,EAAE;QACN,MAAM,EAAE,MAAM,CAAC;QACf,UAAU,EAAE,MAAM,CAAC;KACpB,EAAE,CAAC;CACL"}
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,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,aAAa,EAAE,MAAM,CAAC;IACtB,SAAS,EAAE,sBAAsB,CAAC;IAClC,cAAc,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,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,uBAAuB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACxC,IAAI,EAAE,MAAM,CAAC;IAEb,KAAK,CAAC,EAAE;QACN,MAAM,EAAE,MAAM,CAAC;QACf,UAAU,EAAE,MAAM,CAAC;KACpB,EAAE,CAAC;CACL"}
@@ -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,CAsE5F,CAAC"}
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,CAwE5F,CAAC"}
@@ -11,6 +11,7 @@ export const CreateItemFinancialEventRequestSchema = z.object({
11
11
  totalAmount: z.number().positive(),
12
12
  downPayment: z.number().positive().nullable().optional(),
13
13
  installmentsQty: z.number().int().positive().nullable().optional(),
14
+ firstInstallmentDueDate: z.iso.datetime().nullable().optional(),
14
15
  note: z.string().max(1000),
15
16
  users: z
16
17
  .array(z.object({
@@ -20,7 +21,7 @@ export const CreateItemFinancialEventRequestSchema = z.object({
20
21
  .optional(),
21
22
  })
22
23
  .superRefine((data, ctx) => {
23
- const { paymentType, installmentsQty, downPayment, totalAmount, users, } = data;
24
+ const { paymentType, installmentsQty, firstInstallmentDueDate, downPayment, totalAmount, users, } = data;
24
25
  if (paymentType === PaymentType.INSTALLMENT) {
25
26
  if (!installmentsQty) {
26
27
  ctx.addIssue({
@@ -29,22 +30,20 @@ export const CreateItemFinancialEventRequestSchema = z.object({
29
30
  code: z.ZodIssueCode.custom,
30
31
  });
31
32
  }
32
- else if (installmentsQty < 1) {
33
+ if (!firstInstallmentDueDate) {
33
34
  ctx.addIssue({
34
- path: ["installmentsQty"],
35
- message: "Pagamento parcelado deve ter no mínimo 1 parcela",
35
+ path: ["firstInstallmentDueDate"],
36
+ message: "Data do vencimento da primeira parcela é obrigatória para pagamento parcelado",
36
37
  code: z.ZodIssueCode.custom,
37
38
  });
38
39
  }
39
40
  }
40
- if (downPayment) {
41
- if (downPayment >= totalAmount) {
42
- ctx.addIssue({
43
- path: ["downPayment"],
44
- message: "entrada deve ser menor que o valor total",
45
- code: z.ZodIssueCode.custom,
46
- });
47
- }
41
+ if (downPayment != null && downPayment >= totalAmount) {
42
+ ctx.addIssue({
43
+ path: ["downPayment"],
44
+ message: "Entrada deve ser menor que o valor total",
45
+ code: z.ZodIssueCode.custom,
46
+ });
48
47
  }
49
48
  if (users && users.length > 0) {
50
49
  const totalPercentage = users.reduce((sum, u) => sum + u.percentage, 0);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pedro.araujo/ml-architecture-shared",
3
- "version": "0.1.119",
3
+ "version": "0.1.120",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "main": "dist/index.js",