@tesouro/embedded-components-react 0.5.67 → 0.5.68

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.
@@ -30,7 +30,9 @@ var v = {
30
30
  unreadableTax: "Enter a valid tax amount.",
31
31
  unreadableTotal: "Enter a valid total amount.",
32
32
  totalNotGreaterThanZero: "Total amount must be greater than $0.",
33
- poNumberTooLong: "PO number must be 255 characters or fewer."
33
+ poNumberTooLong: "PO number must be 255 characters or fewer.",
34
+ implausibleDate: "Enter a date within the last 10 years and next year.",
35
+ dueBeforeInvoiceDate: "Due date must be on or after the invoice date."
34
36
  }, y = {
35
37
  paymentInstructionsValue: (e) => `Account ending in ${e}`,
36
38
  noMethod: "No payment method on file",
@@ -157,7 +159,7 @@ var w = {
157
159
  createTitle: "New vendor",
158
160
  editTitle: "Edit vendor",
159
161
  switchVendorFieldLabel: "Switch to a different vendor",
160
- nameLabel: "Name",
162
+ nameLabel: "Business name",
161
163
  addAddress: "Add address (optional)",
162
164
  cancel: "Cancel",
163
165
  save: "Save",
@@ -36,196 +36,193 @@ function me(e) {
36
36
  accountNumber: e.account_number ?? ""
37
37
  };
38
38
  }
39
- function v(e, t) {
39
+ function he(e, t) {
40
40
  return e.accountHolderName.trim() === t.accountHolderName.trim() && e.routingNumber.trim() === t.routingNumber.trim() && e.accountNumber.trim() === t.accountNumber.trim();
41
41
  }
42
- function he(e, t) {
42
+ function ge(e, t) {
43
43
  return e?.find((e) => e.id === t && d(e)) ?? c(e);
44
44
  }
45
- function y({ payableId: c, counterpartId: d, payableCounterpartId: y, payableCounterpartBankAccountId: ge, isVendorKnown: _e = !0, onCounterpartChange: ve, requiredError: ye, extractedVendor: b, readOnly: x = !1, canEditVendor: be = !0, canEditPaymentInstructions: xe = !0, canAddPaymentInstructions: Se = !0, confirmDiscard: S = (e) => e(), labels: Ce }) {
46
- let C = {
45
+ function v({ payableId: c, counterpartId: d, payableCounterpartId: v, payableCounterpartBankAccountId: _e, isVendorKnown: ve = !0, onCounterpartChange: ye, requiredError: be, extractedVendor: y, readOnly: b = !1, canEditVendor: xe = !0, canEditPaymentInstructions: Se = !0, canAddPaymentInstructions: Ce = !0, confirmDiscard: x = (e) => e(), labels: we }) {
46
+ let S = {
47
47
  ...ce,
48
- ...Ce
49
- }, { initResponse: we } = r(), Te = t(we?.scopes, [n.CounterpartReadOrg]), [w, Ee] = g(""), [T, De] = g(""), Oe = h(T), [E, ke] = g(), [Ae, je] = g("none"), [Me, Ne] = g(), [Pe, D] = g(!1), [O, k] = g(!1), [Fe, Ie] = g(!1), [A, j] = g(_), Le = h(A);
50
- Le.current = A;
51
- let M = h(_), [Re, N] = g(), [P, ze] = g(), F = h(void 0), Be = h(d), [Ve, He] = g(!1), [Ue, We] = g(!1), I = h(void 0), L = O && !v(A, M.current), R = f(() => {
52
- k(!1), j(_), M.current = _, N(void 0);
53
- }, []), z = f((e) => {
54
- He(!0), ve(e);
55
- }, [ve]), Ge = s(c, { enabled: !x && !!c && !d && !y }).data?.suggested_counterpart?.id, Ke = b?.name;
48
+ ...we
49
+ }, { initResponse: Te } = r(), Ee = t(Te?.scopes, [n.CounterpartReadOrg]), [C, De] = g(""), [w, Oe] = g(""), ke = h(w), [T, Ae] = g(), [je, Me] = g("none"), [Ne, Pe] = g(), [Fe, E] = g(!1), [D, O] = g(!1), [k, A] = g(_), Ie = h(k);
50
+ Ie.current = k;
51
+ let j = h(_), [Le, M] = g(), [N, Re] = g(), P = h(void 0), ze = h(d), [Be, Ve] = g(!1), [He, Ue] = g(!1), F = h(void 0), We = D && !he(k, j.current), I = f(() => {
52
+ O(!1), A(_), j.current = _, M(void 0);
53
+ }, []), L = f((e) => {
54
+ Ve(!0), ye(e);
55
+ }, [ye]), Ge = s(c, { enabled: !b && !!c && !d && !v }).data?.suggested_counterpart?.id, Ke = y?.name;
56
56
  p(() => {
57
- Ie(!1);
58
- }, [c]), p(() => {
59
- !x && !Ve && !d && !y && Ge && z(Ge);
57
+ !b && !Be && !d && !v && Ge && L(Ge);
60
58
  }, [
61
59
  d,
62
- y,
63
- x,
64
- Ve,
60
+ v,
61
+ b,
62
+ Be,
65
63
  Ge,
66
- z
64
+ L
67
65
  ]), p(() => {
68
- Be.current !== d && (Be.current = d, R(), ze(void 0));
69
- }, [d, R]), p(() => {
66
+ ze.current !== d && (ze.current = d, I(), Re(void 0));
67
+ }, [d, I]), p(() => {
70
68
  let e = setTimeout(() => {
71
- De(w.trim());
69
+ Oe(C.trim());
72
70
  }, pe);
73
71
  return () => clearTimeout(e);
74
- }, [w]);
75
- let B = i({
72
+ }, [C]);
73
+ let R = i({
76
74
  sort: "counterpart_name",
77
75
  order: "asc",
78
76
  limit: fe,
79
- counterpart_name__icontains: T || void 0,
77
+ counterpart_name__icontains: w || void 0,
80
78
  is_vendor: !0,
81
- enabled: !x && (E === "edit" || !E && !d) && _e && Te
79
+ enabled: !b && (T === "edit" || !T && !d) && ve && Ee
82
80
  });
83
81
  p(() => {
84
- B.isPlaceholderData || (Oe.current = T);
85
- }, [T, B.isPlaceholderData]);
86
- let qe = B.isPlaceholderData && Oe.current !== T, V = oe({
82
+ R.isPlaceholderData || (ke.current = w);
83
+ }, [w, R.isPlaceholderData]);
84
+ let qe = R.isPlaceholderData && ke.current !== w, z = oe({
87
85
  selectedId: d,
88
- enabled: Te
89
- }), Je = a(), Ye = o(), H = se({
90
- view: Ae,
91
- setView: je,
92
- selectedId: Me,
93
- setSelectedId: Ne,
86
+ enabled: Ee
87
+ }), Je = a(), Ye = o(), B = se({
88
+ view: je,
89
+ setView: Me,
90
+ selectedId: Ne,
91
+ setSelectedId: Pe,
94
92
  messages: ee,
95
93
  counterpartType: "vendor",
96
- counterpart: V.counterpart,
97
- primaryAddress: V.primaryAddress,
94
+ counterpart: z.counterpart,
95
+ primaryAddress: z.primaryAddress,
98
96
  includeBankAccount: !1
99
- }), { openCreate: Xe, openEdit: Ze, close: Qe, setValues: U, submit: $e } = H, W = m(() => {
100
- let e = V.counterpart;
97
+ }), { openCreate: Xe, openEdit: Ze, close: Qe, setValues: V, submit: $e } = B, H = m(() => {
98
+ let e = z.counterpart;
101
99
  if (!e) return;
102
- if (V.isBankAccountsLoading) return {
100
+ if (z.isBankAccountsLoading) return {
103
101
  name: u(e),
104
102
  email: l(e),
105
- methodLabel: C.paymentMethodLoading,
103
+ methodLabel: S.paymentMethodLoading,
106
104
  hasPaymentInstructions: !1
107
105
  };
108
- if (V.isBankAccountsError) return {
106
+ if (z.isBankAccountsError) return {
109
107
  name: u(e),
110
108
  email: l(e),
111
- methodLabel: C.paymentMethodUnavailable,
109
+ methodLabel: S.paymentMethodUnavailable,
112
110
  hasPaymentInstructions: !1
113
111
  };
114
- let t = re(V.bankAccounts);
112
+ let t = re(z.bankAccounts);
115
113
  return {
116
114
  name: u(e),
117
115
  email: l(e),
118
- methodLabel: t ? C.paymentInstructionsValue(t.account_number?.slice(-4) ?? "") : C.noMethod,
116
+ methodLabel: t ? S.paymentInstructionsValue(t.account_number?.slice(-4) ?? "") : S.noMethod,
119
117
  hasPaymentInstructions: !!t
120
118
  };
121
119
  }, [
122
- V.bankAccounts,
123
- V.counterpart,
124
- V.isBankAccountsError,
125
- V.isBankAccountsLoading,
126
- C
120
+ z.bankAccounts,
121
+ z.counterpart,
122
+ z.isBankAccountsError,
123
+ z.isBankAccountsLoading,
124
+ S
127
125
  ]), et = m(() => {
128
126
  let e = Ke?.trim();
129
- if (!(!e || d || E || Fe)) return {
127
+ if (!(!e || d || T)) return {
130
128
  name: e,
131
- email: b?.email ?? "",
132
- description: C.pendingVendorDescription,
129
+ email: y?.email ?? "",
130
+ description: S.pendingVendorDescription,
133
131
  methodLabel: "",
134
132
  hasPaymentInstructions: !1
135
133
  };
136
134
  }, [
137
135
  d,
138
- b?.email,
136
+ y?.email,
139
137
  Ke,
140
- E,
141
- Fe,
142
- C.pendingVendorDescription
143
- ]), G = d === y ? ge : void 0, K = m(() => he(V.bankAccounts, G), [V.bankAccounts, G]), tt = m(() => re(V.bankAccounts)?.id, [V.bankAccounts]), q = !V.counterpart || V.isLoading || V.isFetching || V.isError || V.isAddressesLoading || V.isAddressesFetching || V.isAddressesError || V.isBankAccountsLoading || V.isBankAccountsFetching || V.isBankAccountsError, J = f(() => {
144
- Qe(), ke(void 0), D(!1), F.current = void 0;
145
- }, [Qe]), Y = m(() => le(b), [b]), nt = f((e) => {
146
- if (D(!1), F.current = void 0, e === "edit") Ne(d), Ze();
138
+ T,
139
+ S.pendingVendorDescription
140
+ ]), U = d === v ? _e : void 0, W = m(() => ge(z.bankAccounts, U), [z.bankAccounts, U]), tt = m(() => re(z.bankAccounts)?.id, [z.bankAccounts]), G = !z.counterpart || z.isLoading || z.isFetching || z.isError || z.isAddressesLoading || z.isAddressesFetching || z.isAddressesError || z.isBankAccountsLoading || z.isBankAccountsFetching || z.isBankAccountsError, K = f(() => {
141
+ Qe(), Ae(void 0), E(!1), P.current = void 0;
142
+ }, [Qe]), q = m(() => le(y), [y]), nt = f((e) => {
143
+ if (E(!1), P.current = void 0, e === "edit") Pe(d), Ze();
147
144
  else {
148
145
  Xe();
149
- let e = w.trim();
150
- U((t) => ({
146
+ let e = C.trim();
147
+ V((t) => ({
151
148
  ...t,
152
149
  entityType: "organization",
153
- legalName: e || Y?.legalName || t.legalName,
154
- email: Y?.email || t.email,
155
- phone: Y?.phone || t.phone,
156
- address: Y?.address ?? t.address
150
+ legalName: e || q?.legalName || t.legalName,
151
+ email: q?.email || t.email,
152
+ phone: q?.phone || t.phone,
153
+ address: q?.address ?? t.address
157
154
  }));
158
155
  }
159
- ke(e);
156
+ Ae(e);
160
157
  }, [
161
158
  d,
162
159
  Xe,
163
160
  Ze,
164
- w,
165
- U,
166
- Y
167
- ]), rt = f(() => {
168
- let e = K ? me(K) : _;
169
- M.current = e, j(e), N(void 0), k(!0);
170
- }, [K]), it = f(() => {
171
- L ? S(R) : R();
161
+ C,
162
+ V,
163
+ q
164
+ ]), J = f(() => {
165
+ let e = W ? me(W) : _;
166
+ j.current = e, A(e), M(void 0), O(!0);
167
+ }, [W]), rt = f(() => {
168
+ We ? x(I) : I();
172
169
  }, [
173
- R,
174
- S,
175
- L
176
- ]), X = f(() => {
177
- J(), R();
178
- }, [R, J]), Z = Pe || L, Q = f((e) => {
170
+ I,
171
+ x,
172
+ We
173
+ ]), Y = f(() => {
174
+ K(), I();
175
+ }, [I, K]), X = Fe || We, Z = f((e) => {
179
176
  let t = () => {
180
- X(), e();
177
+ Y(), e();
181
178
  };
182
- Z ? S(t) : t();
179
+ X ? x(t) : t();
183
180
  }, [
184
- S,
185
- X,
186
- Z
187
- ]), at = f(() => {
188
- Z ? S(X) : X();
181
+ x,
182
+ Y,
183
+ X
184
+ ]), it = f(() => {
185
+ X ? x(Y) : Y();
189
186
  }, [
190
- S,
191
- X,
192
- Z
193
- ]), ot = f(async (t) => {
194
- let n = d, r = !1, i = Le.current;
195
- if (!v(i, M.current)) {
187
+ x,
188
+ Y,
189
+ X
190
+ ]), at = f(async (t) => {
191
+ let n = d, r = !1, i = Ie.current;
192
+ if (!he(i, j.current)) {
196
193
  let e = ae(i);
197
- if (Object.keys(e).length > 0) return N(e), k(!0), { ok: !1 };
194
+ if (Object.keys(e).length > 0) return M(e), O(!0), { ok: !1 };
198
195
  }
199
- if (E === "edit" && q) return { ok: !1 };
200
- if (E) {
201
- if (E === "create" && F.current) n = F.current;
196
+ if (T === "edit" && G) return { ok: !1 };
197
+ if (T) {
198
+ if (T === "create" && P.current) n = P.current;
202
199
  else {
203
200
  let e = await $e();
204
201
  if (!e.ok) return { ok: !1 };
205
- E === "create" ? (n = e.counterpartId, F.current = n) : n = e.counterpartId ?? n;
202
+ T === "create" ? (n = e.counterpartId, P.current = n) : n = e.counterpartId ?? n;
206
203
  }
207
- E === "create" && (r = !0);
204
+ T === "create" && (r = !0);
208
205
  }
209
206
  if (!n) return { ok: !0 };
210
- let a = V.isBankAccountsLoading || V.isBankAccountsFetching || V.isBankAccountsError;
211
- if (v(i, M.current)) {
212
- let e = P ?? G;
213
- return e ? (t && (k(!1), E && J()), r && z(n), {
207
+ let a = z.isBankAccountsLoading || z.isBankAccountsFetching || z.isBankAccountsError;
208
+ if (he(i, j.current)) {
209
+ let e = N ?? U;
210
+ return e ? (t && (O(!1), T && K()), r && L(n), {
214
211
  ok: !0,
215
212
  counterpartId: n,
216
213
  counterpartBankAccountId: e
217
- }) : r ? (t && J(), z(n), {
214
+ }) : r ? (t && K(), L(n), {
218
215
  ok: !0,
219
216
  counterpartId: n
220
- }) : a ? { ok: !1 } : (t && (k(!1), E && J()), {
217
+ }) : a ? { ok: !1 } : (t && (O(!1), T && K()), {
221
218
  ok: !0,
222
219
  counterpartId: n,
223
220
  counterpartBankAccountId: tt
224
221
  });
225
222
  }
226
223
  if (a) return { ok: !1 };
227
- N(void 0);
228
- let o = ie(V.bankAccounts, P ?? K?.id), s;
224
+ M(void 0);
225
+ let o = ie(z.bankAccounts, N ?? W?.id), s;
229
226
  try {
230
227
  o.kind === "update" ? (await Ye.mutateAsync({
231
228
  path: {
@@ -238,58 +235,58 @@ function y({ payableId: c, counterpartId: d, payableCounterpartId: y, payableCou
238
235
  body: te(i, { isDefaultForCurrency: o.isDefaultForCurrency })
239
236
  }))?.id;
240
237
  } catch {
241
- return e.error(C.bankAccountSaveFailed), {
238
+ return e.error(S.bankAccountSaveFailed), {
242
239
  ok: !1,
243
240
  counterpartId: n
244
241
  };
245
242
  }
246
- return M.current = i, ze(s), t && (k(!1), E && J()), r && z(n), {
243
+ return j.current = i, Re(s), t && (O(!1), T && K()), r && L(n), {
247
244
  ok: !0,
248
245
  counterpartId: n,
249
246
  counterpartBankAccountId: s
250
247
  };
251
248
  }, [
252
- J,
249
+ K,
253
250
  d,
254
251
  Je,
255
- V.bankAccounts,
256
- V.isBankAccountsError,
257
- V.isBankAccountsFetching,
258
- V.isBankAccountsLoading,
259
- E,
260
- q,
252
+ z.bankAccounts,
253
+ z.isBankAccountsError,
254
+ z.isBankAccountsFetching,
255
+ z.isBankAccountsLoading,
256
+ T,
261
257
  G,
258
+ U,
262
259
  tt,
263
- z,
264
- K,
260
+ L,
261
+ W,
265
262
  $e,
266
263
  Ye,
267
- P
268
- ]), st = f((e) => {
269
- if (I.current) return I.current;
264
+ N
265
+ ]), ot = f((e) => {
266
+ if (F.current) return F.current;
270
267
  let t = e?.closeOnSuccess ?? !0, n = (async () => {
271
- We(!0);
268
+ Ue(!0);
272
269
  try {
273
- return await ot(t);
270
+ return await at(t);
274
271
  } finally {
275
- I.current = void 0, We(!1);
272
+ F.current = void 0, Ue(!1);
276
273
  }
277
274
  })();
278
- return I.current = n, n;
279
- }, [ot]), ct = f(() => {
280
- k(!1), E && J();
281
- }, [E, J]), lt = m(() => (B.data?.data ?? []).map((e) => ({
275
+ return F.current = n, n;
276
+ }, [at]), st = f(() => {
277
+ O(!1), T && K();
278
+ }, [T, K]), ct = m(() => (R.data?.data ?? []).map((e) => ({
282
279
  name: u(e),
283
280
  email: l(e),
284
281
  onSelect: () => {
285
- Q(() => z(e.id));
282
+ Z(() => L(e.id));
286
283
  }
287
284
  })), [
288
- B.data,
289
- Q,
290
- z
291
- ]), ut = f((e) => {
292
- D(!0), U((t) => e.entityType === "individual" && t.entityType !== "individual" ? {
285
+ R.data,
286
+ Z,
287
+ L
288
+ ]), lt = f((e) => {
289
+ E(!0), V((t) => e.entityType === "individual" && t.entityType !== "individual" ? {
293
290
  ...t,
294
291
  ...e,
295
292
  firstName: t.firstName || t.legalName,
@@ -302,87 +299,87 @@ function y({ payableId: c, counterpartId: d, payableCounterpartId: y, payableCou
302
299
  ...t,
303
300
  ...e
304
301
  });
305
- }, [U]), dt = f((e) => {
306
- D(!0), U((t) => ({
302
+ }, [V]), ut = f((e) => {
303
+ E(!0), V((t) => ({
307
304
  ...t,
308
305
  address: {
309
306
  ...t.address,
310
307
  ...e
311
308
  }
312
309
  }));
313
- }, [U]), ft = {
314
- query: w,
315
- onQueryChange: Ee,
316
- isLoading: !_e || !we || !!d && V.isLoading || B.isLoading || B.isFetching && qe,
310
+ }, [V]), dt = {
311
+ query: C,
312
+ onQueryChange: De,
313
+ isLoading: !ve || !Te || !!d && z.isLoading || R.isLoading || R.isFetching && qe,
317
314
  onAddVendor: () => {
318
- Q(() => nt("create"));
315
+ Z(() => nt("create"));
319
316
  },
320
- results: lt
321
- }, pt = Se && (E === "create" || !q) ? {
322
- isOpen: O,
323
- values: A,
324
- errors: Re,
325
- onOpen: rt,
326
- onCancel: it,
317
+ results: ct
318
+ }, Q = Ce && (T === "create" || !G) ? {
319
+ isOpen: D,
320
+ values: k,
321
+ errors: Le,
322
+ onOpen: J,
323
+ onCancel: rt,
327
324
  onChange: (e) => {
328
- j((t) => ({
325
+ A((t) => ({
329
326
  ...t,
330
327
  ...e
331
- })), N(void 0);
328
+ })), M(void 0);
332
329
  }
333
- } : void 0, mt = E !== "create" && pt ? {
334
- ...pt,
335
- onOpen: E === "edit" ? () => Q(rt) : pt.onOpen,
336
- canEditExisting: xe
337
- } : void 0, ht = H.isSubmitting || Je.isPending || Ye.isPending, $ = {
338
- prepareVendorForSave: st,
339
- isVendorSavePending: Ue || ht,
340
- hasUnsavedVendorChanges: Z,
330
+ } : void 0, ft = T !== "create" && Q ? {
331
+ ...Q,
332
+ onOpen: T === "edit" ? () => Z(J) : Q.onOpen,
333
+ canEditExisting: Se
334
+ } : void 0, pt = B.isSubmitting || Je.isPending || Ye.isPending, $ = {
335
+ prepareVendorForSave: ot,
336
+ isVendorSavePending: He || pt,
337
+ hasUnsavedVendorChanges: X,
341
338
  isPendingVendor: !!et,
342
- isEditingPayTo: !!E || O,
343
- activePayToOperation: E ? "vendor" : O ? W?.hasPaymentInstructions ? "existingInstructions" : "missingInstructions" : void 0,
344
- discardPayToEdits: X,
345
- finalizePayToSave: ct,
346
- openPaymentInstructions: rt,
347
- paymentInstructions: mt
339
+ isEditingPayTo: !!T || D,
340
+ activePayToOperation: T ? "vendor" : D ? H?.hasPaymentInstructions ? "existingInstructions" : "missingInstructions" : void 0,
341
+ discardPayToEdits: Y,
342
+ finalizePayToSave: st,
343
+ openPaymentInstructions: J,
344
+ paymentInstructions: ft
348
345
  };
349
- return E ? {
346
+ return T ? {
350
347
  mode: "creating",
351
- summary: W,
348
+ summary: H,
352
349
  newVendorForm: /* @__PURE__ */ de(ue, {
353
- mode: E,
354
- values: H.values,
355
- errors: H.errors,
356
- onChange: ut,
357
- onAddressChange: dt,
358
- sectionsToExpand: H.sectionsToExpand,
359
- onAddressExpand: H.expandAddress,
360
- onCancel: at,
361
- onSave: st,
362
- isSaving: ht,
363
- search: E === "edit" && !x ? ft : void 0
350
+ mode: T,
351
+ values: B.values,
352
+ errors: B.errors,
353
+ onChange: lt,
354
+ onAddressChange: ut,
355
+ sectionsToExpand: B.sectionsToExpand,
356
+ onAddressExpand: B.expandAddress,
357
+ onCancel: it,
358
+ onSave: ot,
359
+ isSaving: pt,
360
+ search: T === "edit" && !b ? dt : void 0
364
361
  }),
365
362
  ...$
366
- } : W ? {
363
+ } : H ? {
367
364
  mode: "resolved",
368
- summary: W,
369
- onEdit: be && !q ? () => Q(() => nt("edit")) : void 0,
365
+ summary: H,
366
+ onEdit: xe && !G ? () => Z(() => nt("edit")) : void 0,
370
367
  ...$
371
368
  } : et ? {
372
369
  mode: "resolved",
373
370
  summary: et,
374
- onEdit: be ? () => Q(() => {
375
- He(!0), Ie(!0);
371
+ onEdit: xe ? () => Z(() => {
372
+ Ve(!0), nt("create");
376
373
  }) : void 0,
377
374
  showPaymentInstructions: !1,
378
- error: ye,
375
+ error: be,
379
376
  ...$
380
377
  } : {
381
378
  mode: "selecting",
382
- error: B.isError ? C.searchFailed : V.isError ? C.vendorDetailsFailed : ye,
383
- search: ft,
379
+ error: R.isError ? S.searchFailed : z.isError ? S.vendorDetailsFailed : be,
380
+ search: dt,
384
381
  ...$
385
382
  };
386
383
  }
387
384
  //#endregion
388
- export { y as useVendorSectionProps };
385
+ export { v as useVendorSectionProps };
@@ -1,16 +1,24 @@
1
1
  import { BILL_CREATE_MESSAGE_LABELS_EN as e } from "./index49.js";
2
2
  import { isPersistableLineItem as t, parseMoneyToMinorUnits as n, parseQuantity as r } from "./index55.js";
3
3
  //#region ../../libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index56.js
4
- var i = /^(?:\d{1,3}(?:,\d{3})+(?:\.\d+)?|\d+(?:\.\d+)?|\.\d+)$/, a = 255;
5
- function o(t, n = e) {
4
+ var i = /^(?:\d{1,3}(?:,\d{3})+(?:\.\d+)?|\d+(?:\.\d+)?|\.\d+)$/, a = 255, o = 10, s = 1;
5
+ function c(e) {
6
+ let t = new Date(e);
7
+ if (Number.isNaN(t.getTime())) return !1;
8
+ let n = /* @__PURE__ */ new Date(), r = Date.UTC(n.getUTCFullYear(), n.getUTCMonth(), n.getUTCDate()), i = new Date(r);
9
+ i.setUTCFullYear(i.getUTCFullYear() - o);
10
+ let a = new Date(r);
11
+ return a.setUTCFullYear(a.getUTCFullYear() + s), t < i || t > a;
12
+ }
13
+ function l(t, n = e) {
6
14
  let r = {};
7
15
  return t.poNumber.length > a && (r.poNumber = n.poNumberTooLong), Object.keys(r).length ? r : void 0;
8
16
  }
9
- function s(e) {
17
+ function u(e) {
10
18
  let t = e.trim();
11
19
  return !t || n(t) !== null ? !0 : i.test(t) ? Number(t.replaceAll(",", "")) === 0 : !1;
12
20
  }
13
- function c(t, i = e) {
21
+ function d(t, i = e) {
14
22
  let a = {};
15
23
  for (let e of t) {
16
24
  let t = n(e.price), o = n(e.amount), s = {};
@@ -18,44 +26,46 @@ function c(t, i = e) {
18
26
  }
19
27
  return Object.keys(a).length ? a : void 0;
20
28
  }
21
- function l(i, a, o, s = e) {
22
- let c = {};
23
- a || (c.vendor = s.requiredField), i.invoiceNumber.trim() || (c.invoiceNumber = s.requiredField), i.invoiceDate.trim() || (c.invoiceDate = s.requiredField), i.dueDate.trim() || (c.dueDate = s.requiredField);
29
+ function f(i, a, o, s = e) {
24
30
  let l = {};
31
+ a || (l.vendor = s.requiredField), i.invoiceNumber.trim() || (l.invoiceNumber = s.requiredField);
32
+ let u = i.invoiceDate.trim(), d = i.dueDate.trim();
33
+ u ? c(u) && (l.invoiceDate = s.implausibleDate) : l.invoiceDate = s.requiredField, d ? c(d) ? l.dueDate = s.implausibleDate : u && d < u && (l.dueDate = s.dueBeforeInvoiceDate) : l.dueDate = s.requiredField;
34
+ let f = {};
25
35
  return o.forEach((e, i) => {
26
36
  if (i > 0 && !t(e)) return;
27
37
  let a = {};
28
- e.description.trim() || (a.description = s.requiredField), r(e.quantity) === null && (a.quantity = s.requiredField), n(e.price) === null && n(e.amount) === null && (a.price = s.requiredField, a.amount = s.requiredField), Object.keys(a).length && (l[e.id] = a);
38
+ e.description.trim() || (a.description = s.requiredField), r(e.quantity) === null && (a.quantity = s.requiredField), n(e.price) === null && n(e.amount) === null && (a.price = s.requiredField, a.amount = s.requiredField), Object.keys(a).length && (f[e.id] = a);
29
39
  }), {
30
- formErrors: Object.keys(c).length ? c : void 0,
31
- lineItemErrors: Object.keys(l).length ? l : void 0
40
+ formErrors: Object.keys(l).length ? l : void 0,
41
+ lineItemErrors: Object.keys(f).length ? f : void 0
32
42
  };
33
43
  }
34
- function u(e) {
44
+ function p(e) {
35
45
  let t = e.trim();
36
46
  if (!t) return !0;
37
47
  let n = t.startsWith("-") ? t.slice(1) : t;
38
48
  return i.test(n) ? Number(t.replaceAll(",", "")) <= 0 : !1;
39
49
  }
40
- function d(e, t) {
41
- if (n(e) === null) return u(e) ? t.totalNotGreaterThanZero : t.unreadableTotal;
50
+ function m(e, t) {
51
+ if (n(e) === null) return p(e) ? t.totalNotGreaterThanZero : t.unreadableTotal;
42
52
  }
43
- function f(t, n = e) {
44
- let r = d(t, n);
53
+ function h(t, n = e) {
54
+ let r = m(t, n);
45
55
  return r ? { total: r } : void 0;
46
56
  }
47
- function p(t, r = e) {
57
+ function g(t, r = e) {
48
58
  if (t === void 0) return;
49
59
  let i = n(t);
50
60
  if (i !== null) return i > 0 ? void 0 : { total: r.totalNotGreaterThanZero };
51
61
  }
52
- function m(t, n, r, i = e) {
62
+ function _(t, n, r, i = e) {
53
63
  let a = {};
54
- if (s(t) || (a.discount = i.unreadableDiscount), s(n) || (a.tax = i.unreadableTax), r !== void 0) {
55
- let e = d(r, i);
64
+ if (u(t) || (a.discount = i.unreadableDiscount), u(n) || (a.tax = i.unreadableTax), r !== void 0) {
65
+ let e = m(r, i);
56
66
  e && (a.total = e);
57
67
  }
58
68
  return Object.keys(a).length ? a : void 0;
59
69
  }
60
70
  //#endregion
61
- export { s as isReadableMoneyOrZero, l as validateBillCompleteness, f as validateBillTotalIsPayable, m as validateBillTotals, o as validateBillValues, c as validateLineItems, p as validateStoredAmountDue };
71
+ export { u as isReadableMoneyOrZero, f as validateBillCompleteness, h as validateBillTotalIsPayable, _ as validateBillTotals, l as validateBillValues, d as validateLineItems, g as validateStoredAmountDue };