@tesouro/embedded-components-react 0.5.75 → 0.5.76

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.
Files changed (88) hide show
  1. package/dist/index.css +0 -8
  2. package/dist/index.js +1 -1
  3. package/dist/lib/BillPayWidget.js +1 -1
  4. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index.js +8 -8
  5. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index45.js +140 -7
  6. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index46.js +46 -140
  7. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index47.js +114 -47
  8. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index48.js +163 -112
  9. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index49.js +75 -164
  10. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index50.js +21 -75
  11. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index51.js +71 -23
  12. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index52.js +376 -65
  13. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index53.js +12 -381
  14. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index54.js +84 -12
  15. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index55.js +54 -79
  16. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index56.js +223 -54
  17. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index57.js +37 -223
  18. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index58.js +245 -37
  19. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index59.js +21 -252
  20. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index60.js +571 -21
  21. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index61.js +4 -572
  22. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index62.js +44 -4
  23. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index63.js +247 -38
  24. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index64.js +3 -234
  25. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index65.js +4 -3
  26. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index66.js +44 -2
  27. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index67.js +1 -46
  28. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index68.js +8 -1
  29. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index69.js +11 -6
  30. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index70.js +127 -11
  31. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index71.js +3 -129
  32. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index72.js +127 -3
  33. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index73.js +8 -124
  34. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index74.js +7 -8
  35. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index75.js +47 -8
  36. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index76.js +18 -44
  37. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index77.js +28 -20
  38. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index78.js +82 -27
  39. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index79.js +47 -83
  40. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index80.js +250 -47
  41. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index81.js +123 -241
  42. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index82.js +211 -126
  43. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index83.js +3 -219
  44. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index84.js +7 -4
  45. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index85.js +98 -5
  46. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index86.js +1 -100
  47. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index87.js +26 -0
  48. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index.js +10 -10
  49. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index30.js +2 -72
  50. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index31.js +12 -269
  51. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index33.js +2 -19
  52. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index34.js +16 -50
  53. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index36.js +97 -15
  54. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index37.js +76 -47
  55. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index38.js +277 -2
  56. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index39.js +2 -35
  57. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index40.js +16 -369
  58. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index41.js +56 -2
  59. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index42.js +2 -23
  60. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index43.js +15 -93
  61. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index44.js +50 -2
  62. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index45.js +1 -31
  63. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index46.js +32 -49
  64. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index47.js +374 -2
  65. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index48.js +1 -55
  66. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index49.js +20 -10
  67. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index50.js +87 -188
  68. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index51.js +1 -1
  69. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index52.js +30 -2
  70. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index53.js +48 -37
  71. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index55.js +47 -10
  72. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index56.js +10 -85
  73. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index57.js +197 -2
  74. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index58.js +2 -4
  75. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index59.js +2 -14
  76. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index60.js +41 -2
  77. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index61.js +2 -4
  78. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index62.js +14 -17
  79. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index63.js +88 -2
  80. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index64.js +1 -94
  81. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index65.js +167 -161
  82. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index82.js +5 -5
  83. package/dist/libs/tesouro-embedded-components-react/shared/feature/dist/lib/analytics/build-info.js +1 -1
  84. package/dist/libs/tesouro-embedded-components-react/shared/util/dist/lib/auditHistory/buildPayableAuditHistory.js +5 -1
  85. package/dist/libs/tesouro-embedded-components-react/widget-suite/feature/dist/index8.js +1 -1
  86. package/dist/packages/shared-ui-shadcn/dist/index.js +1391 -1369
  87. package/package.json +1 -1
  88. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index88.js +0 -27
@@ -1,385 +1,16 @@
1
- "use client";
2
- "use client";
3
- "use client";
4
- "use client";
5
- import { toast as e } from "../../../../../packages/shared-ui-shadcn/dist/index.js";
6
- import { hasAnyScope as t } from "../../../shared/data-access/dist/lib/hasAnyScope.js";
7
- import { Scope as n } from "../../../shared/data-access/dist/lib/scopes.js";
8
- import "../../../shared/data-access/dist/index.js";
9
- import "../../../shared/ui/dist/index.js";
10
- import { useWidgetConfig as r } from "../../../shared/feature/dist/lib/WidgetProvider/hooks.js";
11
- import "../../../shared/feature/dist/index.js";
12
- import { useCounterpartsQuery as i } from "../../../shared/counterpart-management/data-access/dist/index3.js";
13
- import { useCreateCounterpartBankAccountMutation as a, useUpdateCounterpartBankAccountMutation as o } from "../../../shared/counterpart-management/data-access/dist/index5.js";
14
- import { usePayableSuggestionsQuery as s } from "../../data-access/dist/index18.js";
15
- import "../../data-access/dist/index.js";
16
- import { COUNTERPART_MESSAGE_LABELS_EN as ee } from "../../../shared/counterpart-management/feature/dist/lib/labels.js";
17
- import { counterpartFormBankAccountToCreatePayload as te, counterpartFormBankAccountToUpdatePayload as ne, getAchInstructions as c, getCounterpartEmail as l, getCounterpartName as u, getPayableAchInstructions as re, isAchCompatibleBankAccount as d, resolveCounterpartBankAccountWrite as ie, validateAchFormValues as ae } from "../../../shared/counterpart-management/feature/dist/lib/helpers.js";
18
- import { useCounterpartDetails as oe } from "../../../shared/counterpart-management/feature/dist/lib/useCounterpartDetails.js";
19
- import { useCounterpartForm as se } from "../../../shared/counterpart-management/feature/dist/lib/useCounterpartForm.js";
20
- import "../../../shared/counterpart-management/feature/dist/index.js";
21
- import { VENDOR_SECTION_PROPS_LABELS_EN as ce } from "./index49.js";
22
- import { buildVendorPrefill as le } from "./index51.js";
23
- import { VendorInlineForm as ue } from "./index52.js";
24
- import { useCallback as f, useEffect as p, useMemo as m, useRef as h, useState as g } from "react";
25
- import { jsx as de } from "react/jsx-runtime";
26
1
  //#region ../../libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index53.js
27
- var fe = 10, pe = 300, _ = {
28
- accountHolderName: "",
29
- routingNumber: "",
30
- accountNumber: ""
31
- };
32
- function me(e) {
33
- return {
34
- accountHolderName: e.account_holder_name ?? "",
35
- routingNumber: e.routing_number ?? "",
36
- accountNumber: e.account_number ?? ""
37
- };
38
- }
39
- function he(e, t) {
40
- return e.accountHolderName.trim() === t.accountHolderName.trim() && e.routingNumber.trim() === t.routingNumber.trim() && e.accountNumber.trim() === t.accountNumber.trim();
41
- }
42
- function ge(e, t) {
43
- return e?.find((e) => e.id === t && d(e)) ?? c(e);
44
- }
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
- ...ce,
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
- p(() => {
57
- !b && !Be && !d && !v && Ge && L(Ge);
58
- }, [
59
- d,
60
- v,
61
- b,
62
- Be,
63
- Ge,
64
- L
65
- ]), p(() => {
66
- ze.current !== d && (ze.current = d, I(), Re(void 0));
67
- }, [d, I]), p(() => {
68
- let e = setTimeout(() => {
69
- Oe(C.trim());
70
- }, pe);
71
- return () => clearTimeout(e);
72
- }, [C]);
73
- let R = i({
74
- sort: "counterpart_name",
75
- order: "asc",
76
- limit: fe,
77
- counterpart_name__icontains: w || void 0,
78
- is_vendor: !0,
79
- enabled: !b && (T === "edit" || !T && !d) && ve && Ee
80
- });
81
- p(() => {
82
- R.isPlaceholderData || (ke.current = w);
83
- }, [w, R.isPlaceholderData]);
84
- let qe = R.isPlaceholderData && ke.current !== w, z = oe({
85
- selectedId: d,
86
- enabled: Ee
87
- }), Je = a(), Ye = o(), B = se({
88
- view: je,
89
- setView: Me,
90
- selectedId: Ne,
91
- setSelectedId: Pe,
92
- messages: ee,
93
- counterpartType: "vendor",
94
- counterpart: z.counterpart,
95
- primaryAddress: z.primaryAddress,
96
- includeBankAccount: !1
97
- }), { openCreate: Xe, openEdit: Ze, close: Qe, setValues: V, submit: $e } = B, H = m(() => {
98
- let e = z.counterpart;
99
- if (!e) return;
100
- if (z.isBankAccountsLoading) return {
101
- name: u(e),
102
- email: l(e),
103
- methodLabel: S.paymentMethodLoading,
104
- hasPaymentInstructions: !1
105
- };
106
- if (z.isBankAccountsError) return {
107
- name: u(e),
108
- email: l(e),
109
- methodLabel: S.paymentMethodUnavailable,
110
- hasPaymentInstructions: !1
111
- };
112
- let t = re(z.bankAccounts);
113
- return {
114
- name: u(e),
115
- email: l(e),
116
- methodLabel: t ? S.paymentInstructionsValue(t.account_number?.slice(-4) ?? "") : S.noMethod,
117
- hasPaymentInstructions: !!t
118
- };
119
- }, [
120
- z.bankAccounts,
121
- z.counterpart,
122
- z.isBankAccountsError,
123
- z.isBankAccountsLoading,
124
- S
125
- ]), et = m(() => {
126
- let e = Ke?.trim();
127
- if (!(!e || d || T)) return {
128
- name: e,
129
- email: y?.email ?? "",
130
- description: S.pendingVendorDescription,
131
- methodLabel: "",
132
- hasPaymentInstructions: !1
133
- };
134
- }, [
135
- d,
136
- y?.email,
137
- Ke,
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();
144
- else {
145
- Xe();
146
- let e = C.trim();
147
- V((t) => ({
148
- ...t,
149
- entityType: "organization",
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
154
- }));
155
- }
156
- Ae(e);
157
- }, [
158
- d,
159
- Xe,
160
- Ze,
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();
169
- }, [
170
- I,
171
- x,
172
- We
173
- ]), Y = f(() => {
174
- K(), I();
175
- }, [I, K]), X = Fe || We, Z = f((e) => {
176
- let t = () => {
177
- Y(), e();
178
- };
179
- X ? x(t) : t();
180
- }, [
181
- x,
182
- Y,
183
- X
184
- ]), it = f(() => {
185
- X ? x(Y) : Y();
186
- }, [
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)) {
193
- let e = ae(i);
194
- if (Object.keys(e).length > 0) return M(e), O(!0), { ok: !1 };
195
- }
196
- if (T === "edit" && G) return { ok: !1 };
197
- if (T) {
198
- if (T === "create" && P.current) n = P.current;
199
- else {
200
- let e = await $e();
201
- if (!e.ok) return { ok: !1 };
202
- T === "create" ? (n = e.counterpartId, P.current = n) : n = e.counterpartId ?? n;
2
+ function e(e) {
3
+ return new Promise((t, n) => {
4
+ let r = new FileReader();
5
+ r.onerror = () => n(r.error ?? /* @__PURE__ */ Error("Failed to read file")), r.onload = () => {
6
+ let e = r.result;
7
+ if (typeof e != "string") {
8
+ n(/* @__PURE__ */ Error("Failed to read file as a data URL"));
9
+ return;
203
10
  }
204
- T === "create" && (r = !0);
205
- }
206
- if (!n) return { ok: !0 };
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), {
211
- ok: !0,
212
- counterpartId: n,
213
- counterpartBankAccountId: e
214
- }) : r ? (t && K(), L(n), {
215
- ok: !0,
216
- counterpartId: n
217
- }) : a ? { ok: !1 } : (t && (O(!1), T && K()), {
218
- ok: !0,
219
- counterpartId: n,
220
- counterpartBankAccountId: tt
221
- });
222
- }
223
- if (a) return { ok: !1 };
224
- M(void 0);
225
- let o = ie(z.bankAccounts, N ?? W?.id), s;
226
- try {
227
- o.kind === "update" ? (await Ye.mutateAsync({
228
- path: {
229
- counterpart_id: n,
230
- bank_account_id: o.bankAccountId
231
- },
232
- body: ne(i, { includeAchDefaults: o.includeAchDefaults })
233
- }), s = o.bankAccountId) : s = (await Je.mutateAsync({
234
- path: { counterpart_id: n },
235
- body: te(i, { isDefaultForCurrency: o.isDefaultForCurrency })
236
- }))?.id;
237
- } catch {
238
- return e.error(S.bankAccountSaveFailed), {
239
- ok: !1,
240
- counterpartId: n
241
- };
242
- }
243
- return j.current = i, Re(s), t && (O(!1), T && K()), r && L(n), {
244
- ok: !0,
245
- counterpartId: n,
246
- counterpartBankAccountId: s
247
- };
248
- }, [
249
- K,
250
- d,
251
- Je,
252
- z.bankAccounts,
253
- z.isBankAccountsError,
254
- z.isBankAccountsFetching,
255
- z.isBankAccountsLoading,
256
- T,
257
- G,
258
- U,
259
- tt,
260
- L,
261
- W,
262
- $e,
263
- Ye,
264
- N
265
- ]), ot = f((e) => {
266
- if (F.current) return F.current;
267
- let t = e?.closeOnSuccess ?? !0, n = (async () => {
268
- Ue(!0);
269
- try {
270
- return await at(t);
271
- } finally {
272
- F.current = void 0, Ue(!1);
273
- }
274
- })();
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) => ({
279
- name: u(e),
280
- email: l(e),
281
- onSelect: () => {
282
- Z(() => L(e.id));
283
- }
284
- })), [
285
- R.data,
286
- Z,
287
- L
288
- ]), lt = f((e) => {
289
- E(!0), V((t) => e.entityType === "individual" && t.entityType !== "individual" ? {
290
- ...t,
291
- ...e,
292
- firstName: t.firstName || t.legalName,
293
- legalName: t.legalName
294
- } : e.entityType === "organization" && t.entityType !== "organization" ? {
295
- ...t,
296
- ...e,
297
- legalName: t.legalName || [t.firstName, t.lastName].filter(Boolean).join(" ")
298
- } : {
299
- ...t,
300
- ...e
301
- });
302
- }, [V]), ut = f((e) => {
303
- E(!0), V((t) => ({
304
- ...t,
305
- address: {
306
- ...t.address,
307
- ...e
308
- }
309
- }));
310
- }, [V]), dt = {
311
- query: C,
312
- onQueryChange: De,
313
- isLoading: !ve || !Te || !!d && z.isLoading || R.isLoading || R.isFetching && qe,
314
- onAddVendor: () => {
315
- Z(() => nt("create"));
316
- },
317
- results: ct
318
- }, Q = Ce && (T === "create" || !G) ? {
319
- isOpen: D,
320
- values: k,
321
- errors: Le,
322
- onOpen: J,
323
- onCancel: rt,
324
- onChange: (e) => {
325
- A((t) => ({
326
- ...t,
327
- ...e
328
- })), M(void 0);
329
- }
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,
338
- isPendingVendor: !!et,
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
345
- };
346
- return T ? {
347
- mode: "creating",
348
- summary: H,
349
- newVendorForm: /* @__PURE__ */ de(ue, {
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
361
- }),
362
- ...$
363
- } : H ? {
364
- mode: "resolved",
365
- summary: H,
366
- onEdit: xe && !G ? () => Z(() => nt("edit")) : void 0,
367
- ...$
368
- } : et ? {
369
- mode: "resolved",
370
- summary: et,
371
- onEdit: xe ? () => Z(() => {
372
- Ve(!0), nt("create");
373
- }) : void 0,
374
- showPaymentInstructions: !1,
375
- error: be,
376
- ...$
377
- } : {
378
- mode: "selecting",
379
- error: R.isError ? S.searchFailed : z.isError ? S.vendorDetailsFailed : be,
380
- search: dt,
381
- ...$
382
- };
11
+ t(e.slice(e.indexOf(",") + 1));
12
+ }, r.readAsDataURL(e);
13
+ });
383
14
  }
384
15
  //#endregion
385
- export { v as useVendorSectionProps };
16
+ export { e as encodeFileToBase64 };
@@ -1,16 +1,88 @@
1
+ import { parseDecimalAmountToMinorUnits as e } from "../../../shared/util/dist/lib/parseDecimalAmountToMinorUnits.js";
2
+ import "../../data-access/dist/index.js";
1
3
  //#region ../../libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index54.js
2
- function e(e) {
3
- return new Promise((t, n) => {
4
- let r = new FileReader();
5
- r.onerror = () => n(r.error ?? /* @__PURE__ */ Error("Failed to read file")), r.onload = () => {
6
- let e = r.result;
7
- if (typeof e != "string") {
8
- n(/* @__PURE__ */ Error("Failed to read file as a data URL"));
9
- return;
10
- }
11
- t(e.slice(e.indexOf(",") + 1));
12
- }, r.readAsDataURL(e);
4
+ var t = "USD";
5
+ function n(n) {
6
+ return e(n, t);
7
+ }
8
+ function r(e) {
9
+ let t = e.trim();
10
+ if (!t) return null;
11
+ let n = Number(t);
12
+ return Number.isFinite(n) && n > 0 ? n : null;
13
+ }
14
+ function i(e) {
15
+ return !!(e.description.trim() || e.glCode.trim() || n(e.price) !== null || n(e.amount) !== null);
16
+ }
17
+ function a(e) {
18
+ return n(e) ?? 0;
19
+ }
20
+ function o(e) {
21
+ let t = Number.parseFloat(e);
22
+ return Number.isFinite(t) ? t : 0;
23
+ }
24
+ function s(e) {
25
+ let t = n(e);
26
+ return t === null ? e : c(t);
27
+ }
28
+ function c(e) {
29
+ return (e / 100).toFixed(2);
30
+ }
31
+ function l({ values: e, initialLineItems: r, counterpartId: i, clearCounterpart: a, counterpartBankAccountId: o, editedTotals: s, currentTotals: c, lineItems: l, document: f, includeBlankPoNumber: p = !0 }) {
32
+ let m = { currency: t };
33
+ i ? m.counterpart_id = i : a && (m.counterpart_id = null), i ? m.counterpart_bank_account_id = o ?? null : a && (m.counterpart_bank_account_id = null), e.invoiceNumber && (m.document_id = e.invoiceNumber), e.invoiceDate && (m.issued_at = e.invoiceDate), e.dueDate && (m.due_date = e.dueDate);
34
+ let h = e.poNumber.trim();
35
+ if ((h || p) && (m.purchase_order_number = h || null), f && (m.base64_encoded_file = f.base64EncodedFile, m.file_name = f.fileName), s && (m.discount = n(s.discount) ?? 0, m.tax_amount = n(s.tax) ?? 0, s.total !== void 0 && (m.total_amount = n(s.total) ?? 0)), c && l) {
36
+ let e = d(l), t = n(c.tax) ?? 0, r = n(c.discount) ?? 0, i = c.total === void 0 ? (e ?? 0) - r + t : n(c.total) ?? 0;
37
+ e !== void 0 && (m.subtotal = e), m.discount = r, m.tax_amount = t, m.total_amount = i;
38
+ } else if (r && !("total_amount" in m)) {
39
+ let e = u(r, {
40
+ tax: s?.tax,
41
+ discount: s?.discount
42
+ });
43
+ e !== void 0 && (m.total_amount = e);
44
+ }
45
+ return m;
46
+ }
47
+ function u(e, { tax: t, discount: r }) {
48
+ let i = d(e);
49
+ if (i !== void 0) return i + (t ? n(t) ?? 0 : 0) - (r ? n(r) ?? 0 : 0);
50
+ }
51
+ function d(e) {
52
+ let t = !1, r = e.reduce((e, r) => {
53
+ if (!i(r)) return e;
54
+ let a = n(r.amount);
55
+ return a === null ? e : (t = !0, e + a);
56
+ }, 0);
57
+ if (t) return r;
58
+ }
59
+ function f({ lineItems: e, editedTotals: t }) {
60
+ let r = d(e), i = n(t.tax) ?? 0, a = n(t.discount) ?? 0, o = {
61
+ discount: a,
62
+ tax_amount: i
63
+ };
64
+ return r !== void 0 && (o.subtotal = r), t.total === void 0 ? r !== void 0 && (o.total_amount = r - a + i) : o.total_amount = n(t.total) ?? 0, o;
65
+ }
66
+ function p(e) {
67
+ return e.filter(i).map((e) => {
68
+ let t = n(e.amount), i = r(e.quantity) ?? 1, a = n(e.price) ?? (t === null ? 0 : Math.round(t / i)), o = Math.round(i * a), s = t ?? o;
69
+ return {
70
+ name: e.description,
71
+ quantity: i,
72
+ unit_price: a,
73
+ tax: 0,
74
+ subtotal: s,
75
+ tax_amount: 0,
76
+ total: s,
77
+ ...e.glCode ? { ledger_account_id: e.glCode } : {}
78
+ };
13
79
  });
14
80
  }
81
+ function m(e, t) {
82
+ return c(Math.round(o(e) * a(t)));
83
+ }
84
+ function h(e, t, n) {
85
+ return c(e.reduce((e, t) => e + a(t.amount), 0) + a(t) - a(n));
86
+ }
15
87
  //#endregion
16
- export { e as encodeFileToBase64 };
88
+ export { h as calculateTotal, m as displayLineAmount, i as isPersistableLineItem, l as mapBillFormToPayload, p as mapLineItemsToPayload, f as mapPayableAmountFieldsToPayload, s as normalizeMoneyOnBlur, n as parseMoneyToMinorUnits, r as parseQuantity };
@@ -1,88 +1,63 @@
1
- import { parseDecimalAmountToMinorUnits as e } from "../../../shared/util/dist/lib/parseDecimalAmountToMinorUnits.js";
2
- import "../../data-access/dist/index.js";
1
+ import { BILL_CREATE_MESSAGE_LABELS_EN as e } from "./index48.js";
2
+ import { isPersistableLineItem as t, parseMoneyToMinorUnits as n, parseQuantity as r } from "./index54.js";
3
3
  //#region ../../libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index55.js
4
- var t = "USD";
5
- function n(n) {
6
- return e(n, t);
7
- }
8
- function r(e) {
9
- let t = e.trim();
10
- if (!t) return null;
11
- let n = Number(t);
12
- return Number.isFinite(n) && n > 0 ? n : null;
13
- }
14
- function i(e) {
15
- return !!(e.description.trim() || e.glCode.trim() || n(e.price) !== null || n(e.amount) !== null);
16
- }
17
- function a(e) {
18
- return n(e) ?? 0;
19
- }
20
- function o(e) {
21
- let t = Number.parseFloat(e);
22
- return Number.isFinite(t) ? t : 0;
4
+ var i = /^(?:\d{1,3}(?:,\d{3})+(?:\.\d+)?|\d+(?:\.\d+)?|\.\d+)$/, a = 255;
5
+ function o(t, n = e) {
6
+ let r = {};
7
+ return t.poNumber.length > a && (r.poNumber = n.poNumberTooLong), Object.keys(r).length ? r : void 0;
23
8
  }
24
9
  function s(e) {
25
- let t = n(e);
26
- return t === null ? e : c(t);
27
- }
28
- function c(e) {
29
- return (e / 100).toFixed(2);
10
+ let t = e.trim();
11
+ return !t || n(t) !== null ? !0 : i.test(t) ? Number(t.replaceAll(",", "")) === 0 : !1;
30
12
  }
31
- function l({ values: e, initialLineItems: r, counterpartId: i, clearCounterpart: a, counterpartBankAccountId: o, editedTotals: s, currentTotals: c, lineItems: l, document: f, includeBlankPoNumber: p = !0 }) {
32
- let m = { currency: t };
33
- i ? m.counterpart_id = i : a && (m.counterpart_id = null), i ? m.counterpart_bank_account_id = o ?? null : a && (m.counterpart_bank_account_id = null), e.invoiceNumber && (m.document_id = e.invoiceNumber), e.invoiceDate && (m.issued_at = e.invoiceDate), e.dueDate && (m.due_date = e.dueDate);
34
- let h = e.poNumber.trim();
35
- if ((h || p) && (m.purchase_order_number = h || null), f && (m.base64_encoded_file = f.base64EncodedFile, m.file_name = f.fileName), s && (m.discount = n(s.discount) ?? 0, m.tax_amount = n(s.tax) ?? 0, s.total !== void 0 && (m.total_amount = n(s.total) ?? 0)), c && l) {
36
- let e = d(l), t = n(c.tax) ?? 0, r = n(c.discount) ?? 0, i = c.total === void 0 ? (e ?? 0) - r + t : n(c.total) ?? 0;
37
- e !== void 0 && (m.subtotal = e), m.discount = r, m.tax_amount = t, m.total_amount = i;
38
- } else if (r && !("total_amount" in m)) {
39
- let e = u(r, {
40
- tax: s?.tax,
41
- discount: s?.discount
42
- });
43
- e !== void 0 && (m.total_amount = e);
13
+ function c(t, i = e) {
14
+ let a = {};
15
+ for (let e of t) {
16
+ let t = n(e.price), o = n(e.amount), s = {};
17
+ e.price.trim() && t === null && (s.price = i.unreadableMoney), e.amount.trim() && o === null && (s.amount = i.unreadableMoney), r(e.quantity) === null && (e.quantity.trim() || t !== null || o !== null) && (s.quantity = i.unusableQuantity), Object.keys(s).length && (a[e.id] = s);
44
18
  }
45
- return m;
46
- }
47
- function u(e, { tax: t, discount: r }) {
48
- let i = d(e);
49
- if (i !== void 0) return i + (t ? n(t) ?? 0 : 0) - (r ? n(r) ?? 0 : 0);
50
- }
51
- function d(e) {
52
- let t = !1, r = e.reduce((e, r) => {
53
- if (!i(r)) return e;
54
- let a = n(r.amount);
55
- return a === null ? e : (t = !0, e + a);
56
- }, 0);
57
- if (t) return r;
58
- }
59
- function f({ lineItems: e, editedTotals: t }) {
60
- let r = d(e), i = n(t.tax) ?? 0, a = n(t.discount) ?? 0, o = {
61
- discount: a,
62
- tax_amount: i
19
+ return Object.keys(a).length ? a : void 0;
20
+ }
21
+ function l(i, a, o, s = e) {
22
+ let c = {};
23
+ a || (c.vendor = s.requiredField), i.invoiceNumber.trim() || (c.invoiceNumber = s.requiredField);
24
+ let l = i.invoiceDate.trim(), u = i.dueDate.trim();
25
+ l || (c.invoiceDate = s.requiredField), u ? l && u < l && (c.dueDate = s.dueBeforeInvoiceDate) : c.dueDate = s.requiredField;
26
+ let d = {};
27
+ return o.forEach((e, i) => {
28
+ if (i > 0 && !t(e)) return;
29
+ let a = {};
30
+ 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 && (d[e.id] = a);
31
+ }), {
32
+ formErrors: Object.keys(c).length ? c : void 0,
33
+ lineItemErrors: Object.keys(d).length ? d : void 0
63
34
  };
64
- return r !== void 0 && (o.subtotal = r), t.total === void 0 ? r !== void 0 && (o.total_amount = r - a + i) : o.total_amount = n(t.total) ?? 0, o;
65
- }
66
- function p(e) {
67
- return e.filter(i).map((e) => {
68
- let t = n(e.amount), i = r(e.quantity) ?? 1, a = n(e.price) ?? (t === null ? 0 : Math.round(t / i)), o = Math.round(i * a), s = t ?? o;
69
- return {
70
- name: e.description,
71
- quantity: i,
72
- unit_price: a,
73
- tax: 0,
74
- subtotal: s,
75
- tax_amount: 0,
76
- total: s,
77
- ...e.glCode ? { ledger_account_id: e.glCode } : {}
78
- };
79
- });
80
35
  }
81
- function m(e, t) {
82
- return c(Math.round(o(e) * a(t)));
83
- }
84
- function h(e, t, n) {
85
- return c(e.reduce((e, t) => e + a(t.amount), 0) + a(t) - a(n));
36
+ function u(e) {
37
+ let t = e.trim();
38
+ if (!t) return !0;
39
+ let n = t.startsWith("-") ? t.slice(1) : t;
40
+ return i.test(n) ? Number(t.replaceAll(",", "")) <= 0 : !1;
41
+ }
42
+ function d(e, t) {
43
+ if (n(e) === null) return u(e) ? t.totalNotGreaterThanZero : t.unreadableTotal;
44
+ }
45
+ function f(t, n = e) {
46
+ let r = d(t, n);
47
+ return r ? { total: r } : void 0;
48
+ }
49
+ function p(t, r = e) {
50
+ if (t === void 0) return;
51
+ let i = n(t);
52
+ if (i !== null) return i > 0 ? void 0 : { total: r.totalNotGreaterThanZero };
53
+ }
54
+ function m(t, n, r, i = e) {
55
+ let a = {};
56
+ if (s(t) || (a.discount = i.unreadableDiscount), s(n) || (a.tax = i.unreadableTax), r !== void 0) {
57
+ let e = d(r, i);
58
+ e && (a.total = e);
59
+ }
60
+ return Object.keys(a).length ? a : void 0;
86
61
  }
87
62
  //#endregion
88
- export { h as calculateTotal, m as displayLineAmount, i as isPersistableLineItem, l as mapBillFormToPayload, p as mapLineItemsToPayload, f as mapPayableAmountFieldsToPayload, s as normalizeMoneyOnBlur, n as parseMoneyToMinorUnits, r as parseQuantity };
63
+ export { s as isReadableMoneyOrZero, l as validateBillCompleteness, f as validateBillTotalIsPayable, m as validateBillTotals, o as validateBillValues, c as validateLineItems, p as validateStoredAmountDue };