@tesouro/embedded-components-react 0.5.280 → 0.5.281

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 (52) hide show
  1. package/dist/index.css +8 -0
  2. package/dist/index.d.ts +2 -2
  3. package/dist/lib/BankAccountOnboardingWidget.d.ts +2 -2
  4. package/dist/lib/WidgetSuite.d.ts +2 -2
  5. package/dist/libs/tesouro-embedded-components-react/bank-account-onboarding-widget/feature/dist/lib/BankAccountOnboardingWidget/labels.js +2 -2
  6. package/dist/libs/tesouro-embedded-components-react/bank-account-onboarding-widget/ui/dist/index30.js +1 -1
  7. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/data-access/dist/index18.js +1 -0
  8. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index.js +6 -6
  9. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index13.js +8 -8
  10. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index14.js +7 -28
  11. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index15.js +8 -160
  12. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index16.js +20 -13
  13. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index17.js +148 -27
  14. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index18.js +21 -96
  15. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index19.js +37 -79
  16. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index20.js +98 -3
  17. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index21.js +83 -54
  18. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index22.js +3 -113
  19. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index23.js +54 -184
  20. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index24.js +108 -75
  21. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index25.js +181 -29
  22. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index26.js +74 -83
  23. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index27.js +27 -412
  24. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index28.js +88 -12
  25. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index29.js +413 -77
  26. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index30.js +13 -80
  27. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index31.js +77 -226
  28. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index32.js +78 -41
  29. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index33.js +216 -234
  30. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index34.js +44 -23
  31. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index35.js +233 -611
  32. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index36.js +25 -4
  33. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index37.js +647 -39
  34. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index38.js +4 -243
  35. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index39.js +42 -3
  36. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index40.js +250 -3
  37. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index41.js +2 -66
  38. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index42.js +5 -1
  39. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index43.js +67 -0
  40. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index44.js +1 -0
  41. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/ui/dist/index12.js +11 -11
  42. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/ui/dist/index15.js +47 -47
  43. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/data-access/dist/lib/invalidatePayableQueries/invalidatePayableQueries.js +2 -2
  44. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/data-access/dist/lib/invalidatePayableQueries/reconcileCancelledPaymentQueries.js +19 -19
  45. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/lib/BillPayWidgetNative/BillsTab.js +1 -1
  46. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/pay-bill/data-access/dist/index4.js +15 -15
  47. package/dist/libs/tesouro-embedded-components-react/shared/data-access/dist/lib/rest/zod.gen.js +2 -0
  48. package/dist/libs/tesouro-embedded-components-react/shared/data-access/dist/lib/user/useAllOrganizationUsersQuery.js +1 -0
  49. package/dist/libs/tesouro-embedded-components-react/shared/feature/dist/lib/analytics/build-info.js +1 -1
  50. package/dist/libs/tesouro-embedded-components-react/shared/ui/dist/lib/OnboardingShell/OnboardingShell.js +1 -1
  51. package/dist/libs/tesouro-embedded-components-react/shared/ui/dist/lib/OnboardingShell/labels.js +2 -2
  52. package/package.json +1 -1
@@ -1,87 +1,423 @@
1
- import { parseDecimalAmountToMinorUnits as e } from "../../../../shared/util/dist/lib/parseDecimalAmountToMinorUnits.js";
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 { VENDOR_SECTION_PROPS_LABELS_EN as i } from "./index25.js";
13
+ import { usePayableSuggestionsQuery as ee } from "../../data-access/dist/index19.js";
14
+ import "../../data-access/dist/index.js";
15
+ import { resolvePaymentInstructionsGestures as a } from "./index14.js";
16
+ import { buildVendorPrefill as o } from "./index27.js";
17
+ import { COUNTERPART_MESSAGE_LABELS_EN as te } from "../../../../shared/counterpart-management/feature/dist/lib/labels.js";
18
+ import { counterpartFormBankAccountToCreatePayload as ne, counterpartFormBankAccountToUpdatePayload as re, getAchInstructions as ie, getCounterpartEmail as s, getCounterpartName as c, getPayableAchInstructions as ae, isAchCompatibleBankAccount as l, resolveCounterpartBankAccountWrite as oe, validateAchFormValues as se } from "../../../../shared/counterpart-management/feature/dist/lib/helpers.js";
19
+ import { useCounterpartsQuery as ce } from "../../../../shared/counterpart-management/data-access/dist/index3.js";
20
+ import { useCreateCounterpartBankAccountMutation as le, useUpdateCounterpartBankAccountMutation as ue } from "../../../../shared/counterpart-management/data-access/dist/index5.js";
21
+ import { useCounterpartDetails as de } from "../../../../shared/counterpart-management/feature/dist/lib/useCounterpartDetails.js";
22
+ import { useCounterpartForm as fe } from "../../../../shared/counterpart-management/feature/dist/lib/useCounterpartForm.js";
23
+ import "../../../../shared/counterpart-management/feature/dist/index.js";
24
+ import { VendorInlineForm as pe } from "./index28.js";
25
+ import { useCallback as u, useEffect as d, useMemo as f, useRef as p, useState as m } from "react";
26
+ import { jsx as me } from "react/jsx-runtime";
2
27
  //#region ../../libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index29.js
3
- var t = "USD";
4
- function n(n) {
5
- return e(n, t);
6
- }
7
- function r(e) {
8
- let t = e.trim();
9
- if (!t) return null;
10
- let n = Number(t);
11
- return Number.isFinite(n) && n > 0 ? n : null;
12
- }
13
- function i(e) {
14
- return !!(e.description.trim() || e.glCode.trim() || n(e.price) !== null || n(e.amount) !== null);
15
- }
16
- function a(e) {
17
- return n(e) ?? 0;
18
- }
19
- function o(e) {
20
- let t = Number.parseFloat(e);
21
- return Number.isFinite(t) ? t : 0;
28
+ var he = 10, ge = 300, h = {
29
+ accountHolderName: "",
30
+ routingNumber: "",
31
+ accountNumber: ""
32
+ };
33
+ function _e(e) {
34
+ return {
35
+ accountHolderName: e.account_holder_name ?? "",
36
+ routingNumber: e.routing_number ?? "",
37
+ accountNumber: e.account_number ?? ""
38
+ };
22
39
  }
23
- function s(e) {
24
- let t = n(e);
25
- return t === null ? e : c(t);
40
+ function g(e, t) {
41
+ return e.accountHolderName.trim() === t.accountHolderName.trim() && e.routingNumber.trim() === t.routingNumber.trim() && e.accountNumber.trim() === t.accountNumber.trim();
26
42
  }
27
- function c(e) {
28
- return (e / 100).toFixed(2);
43
+ function ve(e, t) {
44
+ return e?.find((e) => e.id === t && l(e)) ?? ie(e);
29
45
  }
30
- function l({ values: e, initialLineItems: r, counterpartId: i, clearCounterpart: a, counterpartBankAccountId: o, editedTotals: s, currentTotals: c, lineItems: l, document: f, includeBlankPoNumber: p = !0 }) {
31
- let m = { currency: t };
32
- 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);
33
- let h = e.poNumber.trim();
34
- 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) {
35
- 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;
36
- e !== void 0 && (m.subtotal = e), m.discount = r, m.tax_amount = t, m.total_amount = i;
37
- } else if (r && !("total_amount" in m)) {
38
- let e = u(r, {
39
- tax: s?.tax,
40
- discount: s?.discount
46
+ function _({ payableId: ie, counterpartId: l, payableCounterpartId: _, payableCounterpartBankAccountId: ye, isVendorKnown: be = !0, onCounterpartChange: xe, requiredError: Se, extractedVendor: v, readOnly: y = !1, canEditVendor: b = !0, canEditPaymentInstructions: Ce = !0, canAddPaymentInstructions: we = !0, confirmDiscard: x = (e) => e(), labels: Te }) {
47
+ let S = {
48
+ ...i,
49
+ ...Te
50
+ }, Ee = Te?.messages, C = f(() => ({
51
+ ...te,
52
+ ...Ee
53
+ }), [Ee]), { initResponse: De } = r(), Oe = t(De?.scopes, [n.CounterpartReadOrg]), [w, ke] = m(""), [T, Ae] = m(""), je = p(T), [E, Me] = m(), [Ne, Pe] = m("none"), [Fe, Ie] = m(), [Le, D] = m(!1), [O, k] = m(!1), [A, j] = m(h), Re = p(A);
54
+ Re.current = A;
55
+ let M = p(h), [ze, N] = m(), [Be, Ve] = m(), He = Be?.bankAccountId, P = p(void 0), Ue = p(l), [We, Ge] = m(!1), [Ke, qe] = m(!1), F = p(void 0), I = (O || E === "create") && !g(A, M.current), L = u(() => {
56
+ k(!1), j(h), M.current = h, N(void 0);
57
+ }, []), R = u((e) => {
58
+ Ge(!0), xe(e);
59
+ }, [xe]), Je = ee(ie, { enabled: !y && !!ie && !l && !_ }).data?.suggested_counterpart?.id, Ye = v?.name;
60
+ d(() => {
61
+ !y && !We && !l && !_ && Je && R(Je);
62
+ }, [
63
+ l,
64
+ _,
65
+ y,
66
+ We,
67
+ Je,
68
+ R
69
+ ]), d(() => {
70
+ Ue.current !== l && (Ue.current = l, L(), Ve((e) => e?.counterpartId === l ? e : void 0));
71
+ }, [l, L]), d(() => {
72
+ let e = setTimeout(() => {
73
+ Ae(w.trim());
74
+ }, ge);
75
+ return () => clearTimeout(e);
76
+ }, [w]);
77
+ let z = ce({
78
+ sort: "counterpart_name",
79
+ order: "asc",
80
+ limit: he,
81
+ counterpart_name__icontains: T || void 0,
82
+ is_vendor: !0,
83
+ enabled: !y && (E === "edit" || !E && !l) && be && Oe
84
+ });
85
+ d(() => {
86
+ z.isPlaceholderData || (je.current = T);
87
+ }, [T, z.isPlaceholderData]);
88
+ let Xe = z.isPlaceholderData && je.current !== T, B = de({
89
+ selectedId: l,
90
+ enabled: Oe
91
+ }), Ze = le(), Qe = ue(), V = fe({
92
+ view: Ne,
93
+ setView: Pe,
94
+ selectedId: Fe,
95
+ setSelectedId: Ie,
96
+ messages: C,
97
+ counterpartType: "vendor",
98
+ counterpart: B.counterpart,
99
+ primaryAddress: B.primaryAddress,
100
+ includeBankAccount: !1
101
+ }), { openCreate: $e, openEdit: et, close: tt, setValues: H, submit: nt } = V, U = f(() => o(v), [v]), W = U?.bankAccount, G = f(() => {
102
+ let e = B.counterpart;
103
+ if (!e) return;
104
+ if (B.isBankAccountsLoading) return {
105
+ name: c(e),
106
+ email: s(e),
107
+ methodLabel: S.paymentMethodLoading,
108
+ hasPaymentInstructions: !1
109
+ };
110
+ if (B.isBankAccountsError) return {
111
+ name: c(e),
112
+ email: s(e),
113
+ methodLabel: S.paymentMethodUnavailable,
114
+ hasPaymentInstructions: !1
115
+ };
116
+ let t = ae(B.bankAccounts);
117
+ return {
118
+ name: c(e),
119
+ email: s(e),
120
+ methodLabel: t ? S.paymentInstructionsValue(t.account_number?.slice(-4) ?? "") : S.noMethod,
121
+ hasPaymentInstructions: !!t
122
+ };
123
+ }, [
124
+ B.bankAccounts,
125
+ B.counterpart,
126
+ B.isBankAccountsError,
127
+ B.isBankAccountsLoading,
128
+ S
129
+ ]), K = f(() => {
130
+ let e = Ye?.trim();
131
+ if (!e || l || E) return;
132
+ let t = W?.accountNumber;
133
+ return {
134
+ name: e,
135
+ email: v?.email ?? "",
136
+ description: S.pendingVendorDescription,
137
+ methodLabel: t ? S.paymentInstructionsValue(t.slice(-4)) : "",
138
+ hasPaymentInstructions: !!t
139
+ };
140
+ }, [
141
+ l,
142
+ W?.accountNumber,
143
+ v?.email,
144
+ Ye,
145
+ E,
146
+ S.paymentInstructionsValue,
147
+ S.pendingVendorDescription
148
+ ]), q = l === _ ? ye : void 0, J = f(() => ve(B.bankAccounts, q), [B.bankAccounts, q]), rt = f(() => ae(B.bankAccounts)?.id, [B.bankAccounts]), it = !B.counterpart || B.isLoading || B.isFetching || B.isError || B.isBankAccountsLoading || B.isBankAccountsFetching || B.isBankAccountsError, at = it || B.isAddressesLoading || B.isAddressesFetching || B.isAddressesError, ot = b && !it && B.isAddressesError ? { onRetry: B.refetchAddresses } : void 0, Y = u(() => {
149
+ tt(), Me(void 0), D(!1), P.current = void 0;
150
+ }, [tt]), st = u((e) => {
151
+ if (D(!1), P.current = void 0, e === "edit") Ie(l), et();
152
+ else {
153
+ $e();
154
+ let e = w.trim();
155
+ H((t) => ({
156
+ ...t,
157
+ entityType: "organization",
158
+ legalName: e || U?.legalName || t.legalName,
159
+ email: U?.email || t.email,
160
+ phone: U?.phone || t.phone,
161
+ address: U?.address ?? t.address
162
+ })), j(W ?? h), N(void 0), M.current = h;
163
+ }
164
+ Me(e);
165
+ }, [
166
+ l,
167
+ W,
168
+ $e,
169
+ et,
170
+ w,
171
+ H,
172
+ U
173
+ ]), ct = u(() => {
174
+ let e = J ? _e(J) : h;
175
+ M.current = e, j(e), N(void 0), k(!0);
176
+ }, [J]), lt = u((e) => {
177
+ j((t) => ({
178
+ ...t,
179
+ ...e
180
+ })), N(void 0);
181
+ }, []), ut = u(() => {
182
+ I ? x(L) : L();
183
+ }, [
184
+ L,
185
+ x,
186
+ I
187
+ ]), X = u(() => {
188
+ Y(), L();
189
+ }, [L, Y]), Z = Le || I, Q = u((e) => {
190
+ let t = () => {
191
+ X(), e();
192
+ };
193
+ Z ? x(t) : t();
194
+ }, [
195
+ x,
196
+ X,
197
+ Z
198
+ ]), dt = u(() => {
199
+ Z ? x(X) : X();
200
+ }, [
201
+ x,
202
+ X,
203
+ Z
204
+ ]), ft = u(async (t) => {
205
+ let n = l, r = !1, i = Re.current;
206
+ if (!g(i, M.current)) {
207
+ let e = se(i, C);
208
+ if (Object.keys(e).length > 0) return N(e), E !== "create" && k(!0), { ok: !1 };
209
+ }
210
+ if (E === "edit" && at) return { ok: !1 };
211
+ if (E) {
212
+ if (E === "create" && P.current) n = P.current;
213
+ else {
214
+ let e = await nt();
215
+ if (!e.ok) return { ok: !1 };
216
+ E === "create" ? (n = e.counterpartId, P.current = n) : n = e.counterpartId ?? n;
217
+ }
218
+ E === "create" && (r = !0);
219
+ }
220
+ if (!n) return { ok: !0 };
221
+ let ee = B.isBankAccountsLoading || B.isBankAccountsFetching || B.isBankAccountsError;
222
+ if (g(i, M.current)) {
223
+ let e = He ?? q;
224
+ return e ? (t && (k(!1), E && Y()), r && R(n), {
225
+ ok: !0,
226
+ counterpartId: n,
227
+ counterpartBankAccountId: e
228
+ }) : r ? (t && Y(), R(n), {
229
+ ok: !0,
230
+ counterpartId: n
231
+ }) : ee ? { ok: !1 } : (t && (k(!1), E && Y()), {
232
+ ok: !0,
233
+ counterpartId: n,
234
+ counterpartBankAccountId: rt
235
+ });
236
+ }
237
+ if (ee) return { ok: !1 };
238
+ N(void 0);
239
+ let a = oe(B.bankAccounts, He ?? J?.id), o;
240
+ try {
241
+ a.kind === "update" ? (await Qe.mutateAsync({
242
+ path: {
243
+ counterpart_id: n,
244
+ bank_account_id: a.bankAccountId
245
+ },
246
+ body: re(i, { includeAchDefaults: a.includeAchDefaults })
247
+ }), o = a.bankAccountId) : o = (await Ze.mutateAsync({
248
+ path: { counterpart_id: n },
249
+ body: ne(i, { isDefaultForCurrency: a.isDefaultForCurrency })
250
+ }))?.id;
251
+ } catch {
252
+ return e.error(S.bankAccountSaveFailed), {
253
+ ok: !1,
254
+ counterpartId: n
255
+ };
256
+ }
257
+ return M.current = i, Ve(o ? {
258
+ counterpartId: n,
259
+ bankAccountId: o
260
+ } : void 0), t && (k(!1), E && Y()), r && R(n), {
261
+ ok: !0,
262
+ counterpartId: n,
263
+ counterpartBankAccountId: o
264
+ };
265
+ }, [
266
+ Y,
267
+ l,
268
+ Ze,
269
+ B.bankAccounts,
270
+ B.isBankAccountsError,
271
+ B.isBankAccountsFetching,
272
+ B.isBankAccountsLoading,
273
+ E,
274
+ at,
275
+ q,
276
+ C,
277
+ rt,
278
+ R,
279
+ J,
280
+ nt,
281
+ Qe,
282
+ He
283
+ ]), pt = u((e) => {
284
+ if (F.current) return F.current;
285
+ let t = e?.closeOnSuccess ?? !0, n = (async () => {
286
+ qe(!0);
287
+ try {
288
+ return await ft(t);
289
+ } finally {
290
+ F.current = void 0, qe(!1);
291
+ }
292
+ })();
293
+ return F.current = n, n;
294
+ }, [ft]), mt = u(() => {
295
+ k(!1), E && Y();
296
+ }, [E, Y]), ht = f(() => (z.data?.data ?? []).map((e) => ({
297
+ name: c(e),
298
+ email: s(e),
299
+ onSelect: () => {
300
+ Q(() => R(e.id));
301
+ }
302
+ })), [
303
+ z.data,
304
+ Q,
305
+ R
306
+ ]), gt = u((e) => {
307
+ D(!0), H((t) => e.entityType === "individual" && t.entityType !== "individual" ? {
308
+ ...t,
309
+ ...e,
310
+ firstName: t.firstName || t.legalName,
311
+ legalName: t.legalName
312
+ } : e.entityType === "organization" && t.entityType !== "organization" ? {
313
+ ...t,
314
+ ...e,
315
+ legalName: t.legalName || [t.firstName, t.lastName].filter(Boolean).join(" ")
316
+ } : {
317
+ ...t,
318
+ ...e
41
319
  });
42
- e !== void 0 && (m.total_amount = e);
43
- }
44
- return m;
45
- }
46
- function u(e, { tax: t, discount: r }) {
47
- let i = d(e);
48
- if (i !== void 0) return i + (t ? n(t) ?? 0 : 0) - (r ? n(r) ?? 0 : 0);
49
- }
50
- function d(e) {
51
- let t = !1, r = e.reduce((e, r) => {
52
- if (!i(r)) return e;
53
- let a = n(r.amount);
54
- return a === null ? e : (t = !0, e + a);
55
- }, 0);
56
- if (t) return r;
57
- }
58
- function f({ lineItems: e, editedTotals: t }) {
59
- let r = d(e), i = n(t.tax) ?? 0, a = n(t.discount) ?? 0, o = {
60
- discount: a,
61
- tax_amount: i
320
+ }, [H]), _t = u((e) => {
321
+ D(!0), H((t) => ({
322
+ ...t,
323
+ address: {
324
+ ...t.address,
325
+ ...e
326
+ }
327
+ }));
328
+ }, [H]), vt = {
329
+ query: w,
330
+ onQueryChange: ke,
331
+ isLoading: !be || !De || !!l && B.isLoading || z.isLoading || z.isFetching && Xe,
332
+ onAddVendor: () => {
333
+ Q(() => st("create"));
334
+ },
335
+ results: ht
336
+ }, yt = we && (E === "create" || !it) ? {
337
+ isOpen: O,
338
+ values: A,
339
+ errors: ze,
340
+ onOpen: ct,
341
+ onCancel: ut,
342
+ onChange: lt
343
+ } : void 0, bt = E !== "create" && yt ? {
344
+ ...yt,
345
+ onOpen: E === "edit" ? () => Q(ct) : yt.onOpen,
346
+ canEditExisting: Ce
347
+ } : void 0, xt = V.isSubmitting || Ze.isPending || Qe.isPending, $ = {
348
+ prepareVendorForSave: pt,
349
+ isVendorSavePending: Ke || xt,
350
+ hasUnsavedVendorChanges: Z,
351
+ isPendingVendor: !!K,
352
+ isEditingPayTo: !!E || O,
353
+ activePayToOperation: E ? "vendor" : O ? G?.hasPaymentInstructions ? "existingInstructions" : "missingInstructions" : void 0,
354
+ discardPayToEdits: X,
355
+ finalizePayToSave: mt,
356
+ openPaymentInstructions: ct,
357
+ paymentInstructions: a(bt, !!G?.hasPaymentInstructions),
358
+ paymentInstructionsEditor: bt,
359
+ detailsWarning: ot
360
+ }, St = E === "create" && we ? {
361
+ values: A,
362
+ errors: ze,
363
+ onChange: lt,
364
+ isExtracted: !!(W && g(A, W))
365
+ } : void 0;
366
+ if (E) return {
367
+ mode: "creating",
368
+ summary: G,
369
+ newVendorForm: /* @__PURE__ */ me(pe, {
370
+ mode: E,
371
+ values: V.values,
372
+ errors: V.errors,
373
+ onChange: gt,
374
+ onAddressChange: _t,
375
+ sectionsToExpand: V.sectionsToExpand,
376
+ onAddressExpand: V.expandAddress,
377
+ onCancel: dt,
378
+ onSave: pt,
379
+ isSaving: xt,
380
+ search: E === "edit" && !y ? vt : void 0,
381
+ paymentInstructions: St,
382
+ labels: Te?.inlineForm
383
+ }),
384
+ ...$
62
385
  };
63
- 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;
64
- }
65
- function p(e) {
66
- return e.filter(i).map((e) => {
67
- 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;
386
+ if (G) return {
387
+ mode: "resolved",
388
+ summary: G,
389
+ onEdit: b && !at ? () => Q(() => st("edit")) : void 0,
390
+ ...$
391
+ };
392
+ if (K) {
393
+ let e = () => Q(() => {
394
+ Ge(!0), st("create");
395
+ }), t = b && we ? {
396
+ isOpen: !1,
397
+ values: A,
398
+ errors: ze,
399
+ onOpen: e,
400
+ onChange: lt,
401
+ onCancel: ut,
402
+ canEditExisting: !0
403
+ } : void 0;
68
404
  return {
69
- name: e.description,
70
- quantity: i,
71
- unit_price: a,
72
- tax: 0,
73
- subtotal: s,
74
- tax_amount: 0,
75
- total: s,
76
- ...e.glCode ? { ledger_account_id: e.glCode } : {}
405
+ mode: "resolved",
406
+ summary: K,
407
+ onEdit: b ? e : void 0,
408
+ error: Se,
409
+ ...$,
410
+ showPaymentInstructions: !0,
411
+ paymentInstructions: a(t, K.hasPaymentInstructions),
412
+ paymentInstructionsEditor: t
77
413
  };
78
- });
79
- }
80
- function m(e, t) {
81
- return c(Math.round(o(e) * a(t)));
82
- }
83
- function h(e, t, n) {
84
- return c(e.reduce((e, t) => e + a(t.amount), 0) + a(t) - a(n));
414
+ }
415
+ return {
416
+ mode: "selecting",
417
+ error: z.isError ? S.searchFailed : B.isError ? S.vendorDetailsFailed : Se,
418
+ search: vt,
419
+ ...$
420
+ };
85
421
  }
86
422
  //#endregion
87
- 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 };
423
+ export { _ as useVendorSectionProps };
@@ -1,83 +1,16 @@
1
- import { BILL_CREATE_MESSAGE_LABELS_EN as e } from "./index23.js";
2
- import { isPersistableLineItem as t, parseMoneyToMinorUnits as n, parseQuantity as r } from "./index29.js";
3
1
  //#region ../../libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index30.js
4
- var i = /^(?:\d{1,3}(?:,\d{3})+(?:\.\d+)?|\d+(?:\.\d+)?|\.\d+)$/, a = 255, o = 10, s = 5, c = 30, l = 864e5;
5
- function u() {
6
- let e = /* @__PURE__ */ new Date();
7
- return Date.UTC(e.getFullYear(), e.getMonth(), e.getDate());
8
- }
9
- function d() {
10
- let e = new Date(u());
11
- return e.setUTCFullYear(e.getUTCFullYear() - o), e;
12
- }
13
- function f(e) {
14
- let t = new Date(e);
15
- if (Number.isNaN(t.getTime())) return !1;
16
- let n = new Date(u() + c * l);
17
- return t < d() || t > n;
18
- }
19
- function p(e) {
20
- let t = new Date(e);
21
- if (Number.isNaN(t.getTime())) return !1;
22
- let n = new Date(u());
23
- return n.setUTCFullYear(n.getUTCFullYear() + s), t < d() || t > n;
24
- }
25
- function m(t, n = e) {
26
- let r = {};
27
- return t.poNumber.length > a && (r.poNumber = n.poNumberTooLong), Object.keys(r).length ? r : void 0;
28
- }
29
- function h(e) {
30
- let t = e.trim();
31
- return !t || n(t) !== null ? !0 : i.test(t) ? Number(t.replaceAll(",", "")) === 0 : !1;
32
- }
33
- function g(t, i = e) {
34
- let a = {};
35
- for (let e of t) {
36
- let t = n(e.price), o = n(e.amount), s = {};
37
- 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);
38
- }
39
- return Object.keys(a).length ? a : void 0;
40
- }
41
- function _(i, a, o, s = e) {
42
- let c = {};
43
- a || (c.vendor = s.requiredField), i.invoiceNumber.trim() || (c.invoiceNumber = s.requiredField);
44
- let l = i.invoiceDate.trim(), u = i.dueDate.trim();
45
- l ? f(l) && (c.invoiceDate = s.implausibleInvoiceDate) : c.invoiceDate = s.requiredField, u ? p(u) ? c.dueDate = s.implausibleDueDate : l && u < l && (c.dueDate = s.dueBeforeInvoiceDate) : c.dueDate = s.requiredField;
46
- let d = {};
47
- return o.forEach((e, i) => {
48
- if (i > 0 && !t(e)) return;
49
- let a = {};
50
- 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);
51
- }), {
52
- formErrors: Object.keys(c).length ? c : void 0,
53
- lineItemErrors: Object.keys(d).length ? d : void 0
54
- };
55
- }
56
- function v(e) {
57
- let t = e.trim();
58
- if (!t) return !0;
59
- let n = t.startsWith("-") ? t.slice(1) : t;
60
- return i.test(n) ? Number(t.replaceAll(",", "")) <= 0 : !1;
61
- }
62
- function y(e, t) {
63
- if (n(e) === null) return v(e) ? t.totalNotGreaterThanZero : t.unreadableTotal;
64
- }
65
- function b(t, n = e) {
66
- let r = y(t, n);
67
- return r ? { total: r } : void 0;
68
- }
69
- function x(t, r = e) {
70
- if (t === void 0) return;
71
- let i = n(t);
72
- if (i !== null) return i > 0 ? void 0 : { total: r.totalNotGreaterThanZero };
73
- }
74
- function S(t, n, r, i = e) {
75
- let a = {};
76
- if (h(t) || (a.discount = i.unreadableDiscount), h(n) || (a.tax = i.unreadableTax), r !== void 0) {
77
- let e = y(r, i);
78
- e && (a.total = e);
79
- }
80
- return Object.keys(a).length ? a : void 0;
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);
13
+ });
81
14
  }
82
15
  //#endregion
83
- export { h as isReadableMoneyOrZero, _ as validateBillCompleteness, b as validateBillTotalIsPayable, S as validateBillTotals, m as validateBillValues, g as validateLineItems, x as validateStoredAmountDue };
16
+ export { e as encodeFileToBase64 };