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