@tesouro/embedded-components-react 0.5.3 → 0.5.5

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 (91) hide show
  1. package/dist/index.js +1 -1
  2. package/dist/lib/BillPayWidget.js +1 -1
  3. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index.js +13 -13
  4. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index10.js +70 -5
  5. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index11.js +37 -64
  6. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index12.js +110 -38
  7. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index13.js +73 -104
  8. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index14.js +7 -87
  9. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index15.js +21 -7
  10. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index16.js +22 -17
  11. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index17.js +63 -23
  12. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index18.js +2 -66
  13. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index19.js +81 -2
  14. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index20.js +3 -78
  15. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index21.js +5 -4
  16. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index22.js +4 -5
  17. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index23.js +32 -3
  18. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index24.js +39 -30
  19. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index25.js +166 -37
  20. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index26.js +39 -164
  21. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index27.js +1 -48
  22. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index28.js +50 -1
  23. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index29.js +11 -45
  24. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index30.js +8 -13
  25. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index31.js +14 -8
  26. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index32.js +59 -7
  27. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index33.js +8 -64
  28. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index34.js +24 -8
  29. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index35.js +139 -18
  30. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index36.js +16 -139
  31. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index37.js +4 -24
  32. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index38.js +41 -4
  33. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index39.js +14 -39
  34. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index40.js +8 -16
  35. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index41.js +91 -8
  36. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index42.js +86 -80
  37. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index43.js +3 -97
  38. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index44.js +49 -3
  39. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index45.js +135 -47
  40. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index46.js +33 -135
  41. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index47.js +186 -33
  42. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index48.js +75 -186
  43. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index49.js +21 -75
  44. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index5.js +25 -14
  45. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index50.js +232 -22
  46. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index51.js +210 -223
  47. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index52.js +103 -202
  48. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index53.js +13 -121
  49. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index54.js +47 -12
  50. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index55.js +31 -47
  51. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index56.js +198 -27
  52. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index57.js +31 -198
  53. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index58.js +234 -31
  54. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index59.js +19 -240
  55. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index6.js +24 -25
  56. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index60.js +427 -19
  57. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index61.js +4 -433
  58. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index62.js +38 -4
  59. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index63.js +220 -35
  60. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index64.js +3 -224
  61. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index65.js +4 -3
  62. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index66.js +44 -2
  63. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index67.js +1 -46
  64. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index68.js +8 -1
  65. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index69.js +10 -6
  66. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index7.js +57 -21
  67. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index70.js +110 -10
  68. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index71.js +3 -112
  69. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index72.js +127 -3
  70. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index73.js +8 -124
  71. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index74.js +7 -8
  72. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index75.js +46 -8
  73. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index76.js +18 -43
  74. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index77.js +28 -20
  75. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index78.js +82 -27
  76. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index79.js +47 -83
  77. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index8.js +5 -58
  78. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index80.js +250 -47
  79. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index81.js +101 -239
  80. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index82.js +202 -107
  81. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index83.js +3 -209
  82. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index84.js +8 -4
  83. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index85.js +113 -6
  84. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index86.js +1 -115
  85. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index87.js +24 -0
  86. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index9.js +4 -5
  87. package/dist/libs/tesouro-embedded-components-react/remote-check-capture/data-access/dist/index5.js +1 -0
  88. package/dist/libs/tesouro-embedded-components-react/shared/feature/dist/lib/analytics/build-info.js +1 -1
  89. package/dist/libs/tesouro-embedded-components-react/widget-suite/feature/dist/index8.js +1 -1
  90. package/package.json +1 -1
  91. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index88.js +0 -25
@@ -2,222 +2,123 @@
2
2
  "use client";
3
3
  "use client";
4
4
  "use client";
5
- import { hasAnyScope as e } from "../../../shared/data-access/dist/lib/hasAnyScope.js";
6
- import { Scope as t } from "../../../shared/data-access/dist/lib/scopes.js";
7
- import "../../../shared/data-access/dist/index.js";
8
- import { useWidgetConfig as n } from "../../../shared/feature/dist/lib/WidgetProvider/hooks.js";
9
- import "../../../shared/feature/dist/index.js";
10
- import { useCounterpartsQuery as r } from "../../../shared/counterpart-management/data-access/dist/index3.js";
11
- import { useCreateCounterpartBankAccountMutation as ee, useUpdateCounterpartBankAccountMutation as te } from "../../../shared/counterpart-management/data-access/dist/index5.js";
12
- import { usePayableSuggestionsQuery as i } from "../../data-access/dist/index18.js";
5
+ import { toast as e } from "../../../../../packages/shared-ui-shadcn/dist/index.js";
6
+ import "../../../shared/ui/dist/index.js";
7
+ import { useUpdatePayableMutation as t } from "../../data-access/dist/index13.js";
8
+ import { useCounterpartBankAccountsQuery as n, useCreateCounterpartBankAccountMutation as r } from "../../../shared/counterpart-management/data-access/dist/index5.js";
9
+ import { useUpdatePayableCounterpartBankAccountMutation as i } from "../../data-access/dist/index14.js";
13
10
  import "../../data-access/dist/index.js";
14
- import { maskAccountNumber as a } from "./index23.js";
15
- import { counterpartFormBankAccountToCreatePayload as ne, counterpartFormBankAccountToUpdatePayload as re, getAchInstructions as ie, getCounterpartEmail as o, getCounterpartName as s, getPayableAchInstructions as c, hasAchFormValues as l, resolveCounterpartBankAccountWrite as ae, validateAchFormValues as oe } from "../../../shared/counterpart-management/feature/dist/lib/helpers.js";
16
- import { useCounterpartDetails as se } from "../../../shared/counterpart-management/feature/dist/lib/useCounterpartDetails.js";
11
+ import { counterpartFormBankAccountToCreatePayload as a, counterpartFormBankAccountToUpdatePayload as o, getAchInstructions as s, isAchCompatibleBankAccount as c, resolveCounterpartBankAccountWrite as l, validateAchFormValues as u } from "../../../shared/counterpart-management/feature/dist/lib/helpers.js";
17
12
  import "../../../shared/counterpart-management/feature/dist/index.js";
18
- import { VENDOR_SECTION_PROPS_LABELS_EN as ce } from "./index48.js";
19
- import { buildVendorPrefill as le } from "./index50.js";
20
- import { VendorInlineForm as ue } from "./index51.js";
21
- import { useCallback as u, useEffect as d, useMemo as f, useRef as p, useState as m } from "react";
22
- import { jsx as de } from "react/jsx-runtime";
13
+ import { useCallback as d, useEffect as f, useRef as p, useState as m } from "react";
23
14
  //#region ../../libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index52.js
24
- var fe = 10, h = 300, g = {
15
+ var h = {
25
16
  accountHolderName: "",
26
17
  routingNumber: "",
27
18
  accountNumber: ""
28
19
  };
29
- function _({ payableId: _, counterpartId: v, payableCounterpartId: y, payableCounterpartBankAccountId: b, isVendorKnown: x = !0, onCounterpartChange: S, requiredError: pe, extractedVendor: C, labels: me }) {
30
- let w = {
31
- ...ce,
32
- ...me
33
- }, { initResponse: T } = n(), he = e(T?.scopes, [t.CounterpartReadOrg]), [E, D] = m(""), [ge, _e] = m(""), [O, k] = m(), [ve, A] = m(!1), [j, M] = m(g), N = p(j);
34
- N.current = j;
35
- let [P, F] = m(!1), I = l(j) || P, [ye, L] = m(), [R, z] = m(), B = p(v), [V, be] = m(!1), H = u(() => {
36
- A(!1), M(g), L(void 0), z(void 0);
37
- }, []), U = u((e) => {
38
- be(!0), S(e);
39
- }, [S]), W = i(_, { enabled: !!_ && !v && !y }).data?.suggested_counterpart?.id;
40
- d(() => {
41
- !V && !v && !y && W && U(W);
20
+ function g(e, t) {
21
+ return e?.find((e) => e.id === t && c(e)) ?? s(e);
22
+ }
23
+ function _({ payableId: c, counterpartId: _, currentBankAccountId: v, canReadCounterpartBankAccounts: y = !0, saveErrorMessage: b, linkErrorMessage: x }) {
24
+ let [S, C] = m(!1), [w, T] = m(h), [E, D] = m(), O = n(_, { enabled: y }), k = O.data?.data, A = r(), j = i(), M = t(), N = p(void 0), P = p(!1);
25
+ f(() => {
26
+ N.current = void 0;
27
+ }, [_, c]);
28
+ let F = d(() => {
29
+ if (S) return;
30
+ let e = O.isFetching ? void 0 : g(k, v);
31
+ T(e ? {
32
+ accountHolderName: e.account_holder_name ?? "",
33
+ routingNumber: e.routing_number ?? "",
34
+ accountNumber: e.account_number ?? ""
35
+ } : h), N.current = e?.id ?? N.current, P.current = !O.isFetching, D(void 0), C(!0);
42
36
  }, [
37
+ k,
38
+ O.isFetching,
43
39
  v,
44
- y,
45
- V,
46
- W,
47
- U
48
- ]), d(() => {
49
- B.current !== v && (B.current = v, H());
50
- }, [v, H]), d(() => {
51
- let e = setTimeout(() => {
52
- _e(E.trim());
53
- }, h);
54
- return () => clearTimeout(e);
55
- }, [E]);
56
- let G = r({
57
- sort: "counterpart_name",
58
- order: "asc",
59
- limit: fe,
60
- counterpart_name__icontains: ge || void 0,
61
- is_vendor: !0,
62
- enabled: !O && !v && x && he
63
- }), K = se({ selectedId: v }), q = ee(), J = te(), Y = f(() => {
64
- let e = K.counterpart;
65
- if (!e) return;
66
- if (K.isBankAccountsLoading) return {
67
- name: s(e),
68
- email: o(e),
69
- methodLabel: w.paymentMethodLoading,
70
- fields: []
71
- };
72
- if (K.isBankAccountsError) return {
73
- name: s(e),
74
- email: o(e),
75
- methodLabel: w.paymentMethodUnavailable,
76
- fields: []
77
- };
78
- let t = c(K.bankAccounts);
79
- return {
80
- name: s(e),
81
- email: o(e),
82
- methodLabel: t ? w.achMethod : w.noMethod,
83
- fields: t ? [
84
- {
85
- label: w.accountHolder,
86
- value: t.account_holder_name ?? ""
87
- },
88
- {
89
- label: w.routingNumber,
90
- value: t.routing_number ?? ""
91
- },
92
- {
93
- label: w.accountNumber,
94
- value: t.account_number ?? "",
95
- maskedValue: t.account_number ? a(t.account_number) : ""
96
- }
97
- ] : []
98
- };
40
+ S
41
+ ]);
42
+ f(() => {
43
+ if (!S || P.current || O.isFetching) return;
44
+ P.current = !0;
45
+ let e = g(k, v);
46
+ e && (T((t) => t.accountHolderName === "" && t.routingNumber === "" && t.accountNumber === "" ? {
47
+ accountHolderName: e.account_holder_name ?? "",
48
+ routingNumber: e.routing_number ?? "",
49
+ accountNumber: e.account_number ?? ""
50
+ } : t), N.current = e.id);
99
51
  }, [
100
- K.bankAccounts,
101
- K.counterpart,
102
- K.isBankAccountsError,
103
- K.isBankAccountsLoading,
104
- w
105
- ]), X = f(() => ie(K.bankAccounts), [K.bankAccounts]), Z = f(() => c(K.bankAccounts)?.id, [K.bankAccounts]), Q = u(async () => {
106
- let e = N.current;
107
- if (!v) return { ok: !0 };
108
- if (!l(e)) return b && v === y ? {
109
- ok: !0,
110
- counterpartBankAccountId: b
111
- } : K.isBankAccountsLoading || K.isBankAccountsFetching || K.isBankAccountsError ? { ok: !1 } : {
112
- ok: !0,
113
- counterpartBankAccountId: Z
114
- };
115
- if (K.isBankAccountsLoading || K.isBankAccountsFetching || K.isBankAccountsError) return { ok: !1 };
116
- let t = oe(e);
117
- if (Object.keys(t).length > 0) return L(t), A(!0), { ok: !1 };
118
- L(void 0);
119
- let n = ae(K.bankAccounts, R ?? X?.id);
120
- if (n.kind === "update") return await J.mutateAsync({
121
- path: {
122
- counterpart_id: v,
123
- bank_account_id: n.bankAccountId
124
- },
125
- body: re(e, { includeAchDefaults: n.includeAchDefaults })
126
- }), z(n.bankAccountId), {
127
- ok: !0,
128
- counterpartBankAccountId: n.bankAccountId
129
- };
130
- let r = await q.mutateAsync({
131
- path: { counterpart_id: v },
132
- body: ne(e, { isDefaultForCurrency: n.isDefaultForCurrency })
133
- });
134
- return z(r?.id), {
135
- ok: !0,
136
- counterpartBankAccountId: r?.id
137
- };
52
+ S,
53
+ O.isFetching,
54
+ k,
55
+ v,
56
+ y
57
+ ]);
58
+ let I = d(() => {
59
+ C(!1);
60
+ }, []), L = d((e) => {
61
+ T((t) => ({
62
+ ...t,
63
+ ...e
64
+ }));
65
+ }, []), R = d(async () => {
66
+ if (!c || !_) return !1;
67
+ let t = u(w);
68
+ if (Object.keys(t).length > 0) return D(t), !1;
69
+ if (D(void 0), !y || O.isFetching || O.isError) return e.error(b), !1;
70
+ let n = N.current;
71
+ try {
72
+ let e = l(k, n ?? s(k)?.id);
73
+ e.kind === "update" ? (await j.mutateAsync({
74
+ path: {
75
+ counterpart_id: _,
76
+ bank_account_id: e.bankAccountId
77
+ },
78
+ body: o(w, { includeAchDefaults: e.includeAchDefaults }),
79
+ payableId: c,
80
+ makeDefault: e.includeAchDefaults || !k?.find((t) => t.id === e.bankAccountId)?.is_default_for_currency
81
+ }), n = e.bankAccountId) : n = (await A.mutateAsync({
82
+ path: { counterpart_id: _ },
83
+ body: a(w, { isDefaultForCurrency: e.isDefaultForCurrency })
84
+ }))?.id, N.current = n;
85
+ } catch {
86
+ return e.error(b), !1;
87
+ }
88
+ if (n !== v) try {
89
+ await M.mutateAsync({
90
+ path: { payable_id: c },
91
+ body: { counterpart_bank_account_id: n }
92
+ });
93
+ } catch {
94
+ return e.error(x), !1;
95
+ }
96
+ return C(!1), !0;
138
97
  }, [
139
- X,
98
+ k,
99
+ O.isError,
100
+ O.isFetching,
101
+ y,
102
+ _,
103
+ A,
140
104
  v,
141
- q,
142
- K.bankAccounts,
143
- K.isBankAccountsError,
144
- K.isBankAccountsFetching,
145
- K.isBankAccountsLoading,
146
- R,
147
- Z,
105
+ x,
106
+ c,
148
107
  b,
149
- y,
150
- J
151
- ]), xe = f(() => (G.data?.data ?? []).map((e) => ({
152
- name: s(e),
153
- email: o(e),
154
- onSelect: () => U(e.id)
155
- })), [G.data, U]), Se = f(() => le(C), [C]), $ = u(() => {
156
- k(void 0), F(!1);
157
- }, []), Ce = u((e) => {
158
- k(void 0), F(!1), U(e);
159
- }, [U]);
160
- if (O) return {
161
- mode: "creating",
162
- newVendorForm: /* @__PURE__ */ de(ue, {
163
- mode: O,
164
- counterpart: O === "edit" ? K.counterpart : void 0,
165
- primaryAddress: O === "edit" ? K.primaryAddress : void 0,
166
- bankAccounts: O === "edit" ? K.bankAccounts : void 0,
167
- isBankAccountsLoading: O === "edit" ? K.isBankAccountsLoading : void 0,
168
- isBankAccountsError: O === "edit" ? K.isBankAccountsError : void 0,
169
- initialName: O === "create" ? E : void 0,
170
- initialValues: O === "create" ? Se : void 0,
171
- onSaved: Ce,
172
- onCancel: $,
173
- onDirtyChange: F
174
- }),
175
- onClear: $,
176
- hasUnsavedVendorChanges: I
177
- };
178
- if (Y) {
179
- let e = K.isBankAccountsLoading || K.isBankAccountsFetching || K.isBankAccountsError;
180
- return {
181
- mode: "resolved",
182
- summary: Y,
183
- onEdit: e ? void 0 : () => k("edit"),
184
- onClear: () => U(void 0),
185
- paymentInstructions: e ? void 0 : {
186
- isOpen: ve,
187
- values: j,
188
- errors: ye,
189
- onOpen: () => {
190
- A(!0), X && (M({
191
- accountHolderName: X.account_holder_name ?? "",
192
- routingNumber: X.routing_number ?? "",
193
- accountNumber: X.account_number ?? ""
194
- }), z(X.id));
195
- },
196
- onChange: (e) => {
197
- M((t) => ({
198
- ...t,
199
- ...e
200
- })), L(void 0);
201
- }
202
- },
203
- savePaymentInstructions: Q,
204
- hasUnsavedVendorChanges: I
205
- };
206
- }
207
- let we = !x || !T || !!v && K.isLoading;
108
+ j,
109
+ M,
110
+ w
111
+ ]);
208
112
  return {
209
- mode: "selecting",
210
- error: G.isError ? w.searchFailed : K.isError ? w.vendorDetailsFailed : pe,
211
- search: {
212
- query: E,
213
- onQueryChange: D,
214
- isLoading: we || G.isFetching,
215
- onAddVendor: () => k("create"),
216
- results: xe
217
- },
218
- savePaymentInstructions: Q,
219
- hasUnsavedVendorChanges: I
113
+ isOpen: S,
114
+ values: w,
115
+ errors: E,
116
+ isSaving: A.isPending || j.isPending || M.isPending,
117
+ open: F,
118
+ close: I,
119
+ onChange: L,
120
+ save: R
220
121
  };
221
122
  }
222
123
  //#endregion
223
- export { _ as useVendorSectionProps };
124
+ export { _ as usePaymentInstructionsForm };
@@ -1,124 +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 "../../../shared/ui/dist/index.js";
7
- import { useUpdatePayableMutation as t } from "../../data-access/dist/index13.js";
8
- import { useCounterpartBankAccountsQuery as n, useCreateCounterpartBankAccountMutation as r } from "../../../shared/counterpart-management/data-access/dist/index5.js";
9
- import { useUpdatePayableCounterpartBankAccountMutation as i } from "../../data-access/dist/index14.js";
10
- import "../../data-access/dist/index.js";
11
- import { counterpartFormBankAccountToCreatePayload as a, counterpartFormBankAccountToUpdatePayload as o, getAchInstructions as s, isAchCompatibleBankAccount as c, resolveCounterpartBankAccountWrite as l, validateAchFormValues as u } from "../../../shared/counterpart-management/feature/dist/lib/helpers.js";
12
- import "../../../shared/counterpart-management/feature/dist/index.js";
13
- import { useCallback as d, useEffect as f, useRef as p, useState as m } from "react";
14
1
  //#region ../../libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index53.js
15
- var h = {
16
- accountHolderName: "",
17
- routingNumber: "",
18
- accountNumber: ""
19
- };
20
- function g(e, t) {
21
- return e?.find((e) => e.id === t && c(e)) ?? s(e);
22
- }
23
- function _({ payableId: c, counterpartId: _, currentBankAccountId: v, canReadCounterpartBankAccounts: y = !0, saveErrorMessage: b, linkErrorMessage: x }) {
24
- let [S, C] = m(!1), [w, T] = m(h), [E, D] = m(), O = n(_, { enabled: y }), k = O.data?.data, A = r(), j = i(), M = t(), N = p(void 0), P = p(!1);
25
- f(() => {
26
- N.current = void 0;
27
- }, [_, c]);
28
- let F = d(() => {
29
- if (S) return;
30
- let e = O.isFetching ? void 0 : g(k, v);
31
- T(e ? {
32
- accountHolderName: e.account_holder_name ?? "",
33
- routingNumber: e.routing_number ?? "",
34
- accountNumber: e.account_number ?? ""
35
- } : h), N.current = e?.id ?? N.current, P.current = !O.isFetching, D(void 0), C(!0);
36
- }, [
37
- k,
38
- O.isFetching,
39
- v,
40
- S
41
- ]);
42
- f(() => {
43
- if (!S || P.current || O.isFetching) return;
44
- P.current = !0;
45
- let e = g(k, v);
46
- e && (T((t) => t.accountHolderName === "" && t.routingNumber === "" && t.accountNumber === "" ? {
47
- accountHolderName: e.account_holder_name ?? "",
48
- routingNumber: e.routing_number ?? "",
49
- accountNumber: e.account_number ?? ""
50
- } : t), N.current = e.id);
51
- }, [
52
- S,
53
- O.isFetching,
54
- k,
55
- v,
56
- y
57
- ]);
58
- let I = d(() => {
59
- C(!1);
60
- }, []), L = d((e) => {
61
- T((t) => ({
62
- ...t,
63
- ...e
64
- }));
65
- }, []), R = d(async () => {
66
- if (!c || !_) return !1;
67
- let t = u(w);
68
- if (Object.keys(t).length > 0) return D(t), !1;
69
- if (D(void 0), !y || O.isFetching || O.isError) return e.error(b), !1;
70
- let n = N.current;
71
- try {
72
- let e = l(k, n ?? s(k)?.id);
73
- e.kind === "update" ? (await j.mutateAsync({
74
- path: {
75
- counterpart_id: _,
76
- bank_account_id: e.bankAccountId
77
- },
78
- body: o(w, { includeAchDefaults: e.includeAchDefaults }),
79
- payableId: c,
80
- makeDefault: e.includeAchDefaults || !k?.find((t) => t.id === e.bankAccountId)?.is_default_for_currency
81
- }), n = e.bankAccountId) : n = (await A.mutateAsync({
82
- path: { counterpart_id: _ },
83
- body: a(w, { isDefaultForCurrency: e.isDefaultForCurrency })
84
- }))?.id, N.current = n;
85
- } catch {
86
- return e.error(b), !1;
87
- }
88
- if (n !== v) try {
89
- await M.mutateAsync({
90
- path: { payable_id: c },
91
- body: { counterpart_bank_account_id: n }
92
- });
93
- } catch {
94
- return e.error(x), !1;
95
- }
96
- return C(!1), !0;
97
- }, [
98
- k,
99
- O.isError,
100
- O.isFetching,
101
- y,
102
- _,
103
- A,
104
- v,
105
- x,
106
- c,
107
- b,
108
- j,
109
- M,
110
- w
111
- ]);
112
- return {
113
- isOpen: S,
114
- values: w,
115
- errors: E,
116
- isSaving: A.isPending || j.isPending || M.isPending,
117
- open: F,
118
- close: I,
119
- onChange: L,
120
- save: R
121
- };
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
+ });
122
14
  }
123
15
  //#endregion
124
- export { _ as usePaymentInstructionsForm };
16
+ export { e as encodeFileToBase64 };
@@ -1,16 +1,51 @@
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
+ return (e / 100).toFixed(2);
26
+ }
27
+ function c({ values: e, counterpartId: r, clearCounterpart: i, counterpartBankAccountId: a, editedTotals: o, document: s }) {
28
+ let c = { currency: t };
29
+ return r ? c.counterpart_id = r : i && (c.counterpart_id = null), r ? c.counterpart_bank_account_id = a ?? null : i && (c.counterpart_bank_account_id = null), e.invoiceNumber && (c.document_id = e.invoiceNumber), e.invoiceDate && (c.issued_at = e.invoiceDate), e.dueDate && (c.due_date = e.dueDate), s && (c.base64_encoded_file = s.base64EncodedFile, c.file_name = s.fileName), o && (c.discount = n(o.discount) ?? 0, c.tax_amount = n(o.tax) ?? 0, o.total !== void 0 && (c.total_amount = n(o.total) ?? 0)), c;
30
+ }
31
+ function l(e) {
32
+ return e.filter(i).map((e) => {
33
+ 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);
34
+ return {
35
+ name: e.description,
36
+ quantity: i,
37
+ unit_price: a,
38
+ tax: 0,
39
+ ...t !== null && t !== o ? { subtotal: t } : {},
40
+ ...e.glCode ? { ledger_account_id: e.glCode } : {}
41
+ };
13
42
  });
14
43
  }
44
+ function u(e, t) {
45
+ return s(Math.round(o(e) * a(t)));
46
+ }
47
+ function d(e, t, n) {
48
+ return s(e.reduce((e, t) => e + a(t.amount), 0) + a(t) - a(n));
49
+ }
15
50
  //#endregion
16
- export { e as encodeFileToBase64 };
51
+ export { d as calculateTotal, u as displayLineAmount, i as isPersistableLineItem, c as mapBillFormToPayload, l as mapLineItemsToPayload, n as parseMoneyToMinorUnits, r as parseQuantity };
@@ -1,51 +1,35 @@
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 "./index47.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
- }
4
+ var i = /^(?:\d{1,3}(?:,\d{3})+(?:\.\d+)?|\d+(?:\.\d+)?|\.\d+)$/;
17
5
  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
- return (e / 100).toFixed(2);
26
- }
27
- function c({ values: e, counterpartId: r, clearCounterpart: i, counterpartBankAccountId: a, editedTotals: o, document: s }) {
28
- let c = { currency: t };
29
- return r ? c.counterpart_id = r : i && (c.counterpart_id = null), r ? c.counterpart_bank_account_id = a ?? null : i && (c.counterpart_bank_account_id = null), e.invoiceNumber && (c.document_id = e.invoiceNumber), e.invoiceDate && (c.issued_at = e.invoiceDate), e.dueDate && (c.due_date = e.dueDate), s && (c.base64_encoded_file = s.base64EncodedFile, c.file_name = s.fileName), o && (c.discount = n(o.discount) ?? 0, c.tax_amount = n(o.tax) ?? 0, o.total !== void 0 && (c.total_amount = n(o.total) ?? 0)), c;
30
- }
31
- function l(e) {
32
- return e.filter(i).map((e) => {
33
- 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);
34
- return {
35
- name: e.description,
36
- quantity: i,
37
- unit_price: a,
38
- tax: 0,
39
- ...t !== null && t !== o ? { subtotal: t } : {},
40
- ...e.glCode ? { ledger_account_id: e.glCode } : {}
41
- };
42
- });
43
- }
44
- function u(e, t) {
45
- return s(Math.round(o(e) * a(t)));
46
- }
47
- function d(e, t, n) {
48
- return s(e.reduce((e, t) => e + a(t.amount), 0) + a(t) - a(n));
6
+ let t = e.trim();
7
+ return !t || n(t) !== null ? !0 : i.test(t) ? Number(t.replaceAll(",", "")) === 0 : !1;
8
+ }
9
+ function o(t, i = e) {
10
+ let a = {};
11
+ for (let e of t) {
12
+ let t = n(e.price), o = n(e.amount), s = {};
13
+ 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);
14
+ }
15
+ return Object.keys(a).length ? a : void 0;
16
+ }
17
+ function s(i, a, o, s = e) {
18
+ let c = {};
19
+ 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);
20
+ let l = {};
21
+ return o.forEach((e, i) => {
22
+ if (i > 0 && !t(e)) return;
23
+ let a = {};
24
+ 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);
25
+ }), {
26
+ formErrors: Object.keys(c).length ? c : void 0,
27
+ lineItemErrors: Object.keys(l).length ? l : void 0
28
+ };
29
+ }
30
+ function c(t, r, i, o = e) {
31
+ let s = {};
32
+ return a(t) || (s.discount = o.unreadableDiscount), a(r) || (s.tax = o.unreadableTax), i !== void 0 && n(i) === null && (s.total = o.unreadableTotal), Object.keys(s).length ? s : void 0;
49
33
  }
50
34
  //#endregion
51
- export { d as calculateTotal, u as displayLineAmount, i as isPersistableLineItem, c as mapBillFormToPayload, l as mapLineItemsToPayload, n as parseMoneyToMinorUnits, r as parseQuantity };
35
+ export { a as isReadableMoneyOrZero, s as validateBillCompleteness, c as validateBillTotals, o as validateLineItems };