@tesouro/embedded-components-react 0.7.28 → 0.7.29
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.d.ts +1 -12
- package/dist/lib/CounterpartsWidget.d.ts +1 -12
- package/dist/lib/CounterpartsWidgetPublic.d.ts +1 -12
- package/dist/lib/CustomersWidget.d.ts +0 -2
- package/dist/lib/ReceivablesWidget.d.ts +0 -2
- package/dist/libs/tesouro-embedded-components-react/counterparts-widget/feature/dist/lib/CounterpartsWidget/CounterpartDetailsContainer.js +59 -38
- package/dist/libs/tesouro-embedded-components-react/counterparts-widget/feature/dist/lib/CounterpartsWidget/CounterpartDetailsPanel.js +137 -0
- package/dist/libs/tesouro-embedded-components-react/counterparts-widget/feature/dist/lib/CounterpartsWidget/CounterpartsWidget.js +86 -182
- package/dist/libs/tesouro-embedded-components-react/counterparts-widget/feature/dist/lib/CounterpartsWidget/useCounterpartDetailsActions.js +116 -0
- package/dist/libs/tesouro-embedded-components-react/counterparts-widget/feature/dist/lib/CounterpartsWidget/useCounterpartDetailsSheetView.js +16 -16
- package/dist/libs/tesouro-embedded-components-react/counterparts-widget/feature/dist/lib/CounterpartsWidget/useCounterpartsWidget.js +51 -108
- package/dist/libs/tesouro-embedded-components-react/counterparts-widget/feature/dist/lib/CounterpartsWidget/useRebaseOnRefresh.js +33 -0
- package/dist/libs/tesouro-embedded-components-react/counterparts-widget/feature/dist/lib/CounterpartsWidget/viewModels.js +40 -39
- package/dist/libs/tesouro-embedded-components-react/counterparts-widget/ui/dist/index.js +1 -1
- package/dist/libs/tesouro-embedded-components-react/counterparts-widget/ui/dist/index4.js +2 -65
- package/dist/libs/tesouro-embedded-components-react/counterparts-widget/ui/dist/index5.js +37 -181
- package/dist/libs/tesouro-embedded-components-react/counterparts-widget/ui/dist/index6.js +193 -502
- package/dist/libs/tesouro-embedded-components-react/counterparts-widget/ui/dist/index7.js +520 -0
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/ReceivablesWidget.js +2 -0
- package/dist/libs/tesouro-embedded-components-react/shared/counterpart-management/data-access/dist/index.js +3 -3
- package/dist/libs/tesouro-embedded-components-react/shared/counterpart-management/data-access/dist/index5.js +31 -55
- package/dist/libs/tesouro-embedded-components-react/shared/counterpart-management/feature/dist/index.js +11 -11
- package/dist/libs/tesouro-embedded-components-react/shared/counterpart-management/feature/dist/lib/helpers.js +98 -163
- package/dist/libs/tesouro-embedded-components-react/shared/counterpart-management/feature/dist/lib/labels.js +1 -3
- package/dist/libs/tesouro-embedded-components-react/shared/counterpart-management/feature/dist/lib/subEntityForms.js +37 -32
- package/dist/libs/tesouro-embedded-components-react/shared/counterpart-management/feature/dist/lib/useCounterpartForm.js +86 -93
- package/dist/libs/tesouro-embedded-components-react/shared/counterpart-management/ui/dist/index10.js +2 -0
- package/dist/libs/tesouro-embedded-components-react/shared/counterpart-management/ui/dist/index12.js +42 -173
- package/dist/libs/tesouro-embedded-components-react/shared/counterpart-management/ui/dist/index2.js +3 -12
- package/dist/libs/tesouro-embedded-components-react/shared/counterpart-management/ui/dist/index5.js +16 -16
- package/dist/libs/tesouro-embedded-components-react/shared/data-access/dist/index.js +42 -42
- package/dist/libs/tesouro-embedded-components-react/shared/data-access/dist/lib/rest/sdk.gen.js +117 -125
- package/dist/libs/tesouro-embedded-components-react/shared/feature/dist/lib/analytics/build-info.js +1 -1
- package/package.json +1 -1
|
@@ -6,27 +6,7 @@ import { EMPTY_ADDRESS_FORM_VALUES as i } from "../../../ui/dist/index6.js";
|
|
|
6
6
|
import "../../../ui/dist/index.js";
|
|
7
7
|
import { COUNTERPART_MESSAGE_LABELS_EN as a } from "./labels.js";
|
|
8
8
|
//#region ../../libs/tesouro-embedded-components-react/shared/counterpart-management/feature/dist/lib/helpers.js
|
|
9
|
-
|
|
10
|
-
"USD",
|
|
11
|
-
"EUR",
|
|
12
|
-
"GBP",
|
|
13
|
-
"CAD",
|
|
14
|
-
"AUD",
|
|
15
|
-
"JPY",
|
|
16
|
-
"CHF",
|
|
17
|
-
"CNY",
|
|
18
|
-
"INR",
|
|
19
|
-
"BRL",
|
|
20
|
-
"MXN",
|
|
21
|
-
"SGD"
|
|
22
|
-
];
|
|
23
|
-
function s(e) {
|
|
24
|
-
return Array.from(/* @__PURE__ */ new Set([...o, ...e ? [e] : []])).sort().map((e) => ({
|
|
25
|
-
value: e,
|
|
26
|
-
label: e
|
|
27
|
-
}));
|
|
28
|
-
}
|
|
29
|
-
function c(e) {
|
|
9
|
+
function o(e) {
|
|
30
10
|
try {
|
|
31
11
|
return new Intl.NumberFormat("en-US", {
|
|
32
12
|
style: "currency",
|
|
@@ -36,58 +16,58 @@ function c(e) {
|
|
|
36
16
|
return 2;
|
|
37
17
|
}
|
|
38
18
|
}
|
|
39
|
-
function
|
|
40
|
-
return e / 10 **
|
|
19
|
+
function s(e, t) {
|
|
20
|
+
return e / 10 ** o(t);
|
|
41
21
|
}
|
|
42
|
-
function
|
|
43
|
-
return e(
|
|
22
|
+
function c(t, n = "USD") {
|
|
23
|
+
return e(s(t, n), { currencyCode: n });
|
|
44
24
|
}
|
|
45
|
-
var
|
|
25
|
+
var l = new Intl.DateTimeFormat(void 0, {
|
|
46
26
|
year: "numeric",
|
|
47
27
|
month: "short",
|
|
48
28
|
day: "numeric"
|
|
49
29
|
});
|
|
50
|
-
function
|
|
30
|
+
function u(e) {
|
|
51
31
|
if (!e) return "";
|
|
52
32
|
let t = new Date(e);
|
|
53
|
-
return Number.isNaN(t.getTime()) ? "" :
|
|
33
|
+
return Number.isNaN(t.getTime()) ? "" : l.format(t);
|
|
54
34
|
}
|
|
55
|
-
function
|
|
35
|
+
function d(e) {
|
|
56
36
|
if ("organization" in e) return e.organization.legal_name;
|
|
57
37
|
let { first_name: t, last_name: n } = e.individual;
|
|
58
38
|
return [t, n].filter(Boolean).join(" ").trim();
|
|
59
39
|
}
|
|
60
|
-
function
|
|
40
|
+
function f(e) {
|
|
61
41
|
return "organization" in e ? e.organization.email ?? "" : e.individual.email ?? "";
|
|
62
42
|
}
|
|
63
|
-
function
|
|
43
|
+
function p(e) {
|
|
64
44
|
return "organization" in e ? e.organization.phone ?? "" : e.individual.phone ?? "";
|
|
65
45
|
}
|
|
66
|
-
function
|
|
46
|
+
function m(e) {
|
|
67
47
|
let t = /* @__PURE__ */ new Map();
|
|
68
48
|
for (let n of e ?? []) n.dimension_value && t.set(n.dimension_value, Math.round(n.metric_value));
|
|
69
49
|
return t;
|
|
70
50
|
}
|
|
71
|
-
var
|
|
72
|
-
function
|
|
51
|
+
var h = "-";
|
|
52
|
+
function g({ counterparts: e, addresses: n, billedAmounts: r, dueOrOwedAmounts: i, isBilledAmountLoading: a = !1, isDueOrOwedAmountLoading: o = !1, isBilledAmountError: s = !1, isDueOrOwedAmountError: l = !1 }) {
|
|
73
53
|
return e.map((e) => {
|
|
74
|
-
let
|
|
54
|
+
let u = r?.get(e.id) ?? 0, f = i?.get(e.id) ?? 0, p = u - f, m = a || o, g = s || l, _ = d(e);
|
|
75
55
|
return {
|
|
76
56
|
id: e.id,
|
|
77
|
-
name:
|
|
78
|
-
initials: t(
|
|
57
|
+
name: _,
|
|
58
|
+
initials: t(_),
|
|
79
59
|
entityType: e.type,
|
|
80
|
-
locationLabel:
|
|
81
|
-
billedAmountLabel: s ?
|
|
82
|
-
receivedOrPaidAmountLabel:
|
|
83
|
-
dueOrOwedAmountLabel:
|
|
60
|
+
locationLabel: v(n?.get(e.id)),
|
|
61
|
+
billedAmountLabel: s ? h : r && !a ? c(u) : "",
|
|
62
|
+
receivedOrPaidAmountLabel: g ? h : r && i && !m ? c(p) : "",
|
|
63
|
+
dueOrOwedAmountLabel: l ? h : i && !o ? c(f) : "",
|
|
84
64
|
isBilledAmountLoading: a && !s,
|
|
85
|
-
isReceivedOrPaidAmountLoading: m && !
|
|
86
|
-
isDueOrOwedAmountLoading: o && !
|
|
65
|
+
isReceivedOrPaidAmountLoading: m && !g,
|
|
66
|
+
isDueOrOwedAmountLoading: o && !l
|
|
87
67
|
};
|
|
88
68
|
});
|
|
89
69
|
}
|
|
90
|
-
function
|
|
70
|
+
function _(e) {
|
|
91
71
|
if (!e) return [];
|
|
92
72
|
let t = [
|
|
93
73
|
e.city,
|
|
@@ -101,27 +81,27 @@ function y(e) {
|
|
|
101
81
|
e.country
|
|
102
82
|
].filter((e) => !!(e && e.trim()));
|
|
103
83
|
}
|
|
104
|
-
function
|
|
84
|
+
function v(e) {
|
|
105
85
|
return e ? [e.country, e.city].filter(Boolean).join(" • ") : "";
|
|
106
86
|
}
|
|
107
|
-
function
|
|
87
|
+
function y({ counterpart: e, primaryAddress: t }) {
|
|
108
88
|
return {
|
|
109
|
-
name:
|
|
89
|
+
name: d(e),
|
|
110
90
|
entityType: e.type,
|
|
111
|
-
email:
|
|
112
|
-
phone:
|
|
91
|
+
email: f(e),
|
|
92
|
+
phone: p(e),
|
|
113
93
|
taxId: e.tax_id ?? "",
|
|
114
|
-
addressLines:
|
|
115
|
-
createdAtLabel:
|
|
116
|
-
updatedAtLabel:
|
|
94
|
+
addressLines: _(t),
|
|
95
|
+
createdAtLabel: u(e.created_at),
|
|
96
|
+
updatedAtLabel: u(e.updated_at)
|
|
117
97
|
};
|
|
118
98
|
}
|
|
119
|
-
function
|
|
99
|
+
function b(e) {
|
|
120
100
|
if (e) return `•••• ${e.slice(-4)}`;
|
|
121
101
|
}
|
|
122
|
-
function
|
|
102
|
+
function x(e) {
|
|
123
103
|
return (e ?? []).map((e) => {
|
|
124
|
-
let t =
|
|
104
|
+
let t = b(e.iban || e.account_number || void 0), n = [e.currency, t].filter(Boolean).join(" · ");
|
|
125
105
|
return {
|
|
126
106
|
id: e.id,
|
|
127
107
|
primary: e.name || e.account_holder_name || e.currency,
|
|
@@ -130,17 +110,17 @@ function C(e) {
|
|
|
130
110
|
};
|
|
131
111
|
});
|
|
132
112
|
}
|
|
133
|
-
function
|
|
113
|
+
function S(e) {
|
|
134
114
|
let t = (e ?? []).filter((e) => e.currency === "USD" && (!!e.routing_number || !!e.account_number));
|
|
135
115
|
return t.find((e) => e.is_default_for_currency) ?? t[0];
|
|
136
116
|
}
|
|
137
|
-
function
|
|
138
|
-
let r = n && (e ?? []).find((e) => e.id === n &&
|
|
117
|
+
function C(e, t = "USD", n) {
|
|
118
|
+
let r = n && (e ?? []).find((e) => e.id === n && V(e));
|
|
139
119
|
if (r) return r;
|
|
140
120
|
let i = (e ?? []).filter((e) => e.currency === t && !!e.account_holder_name && !!e.routing_number && !!e.account_number);
|
|
141
121
|
return i.find((e) => e.is_default_for_currency) ?? i[0];
|
|
142
122
|
}
|
|
143
|
-
function
|
|
123
|
+
function w(e, t = {}) {
|
|
144
124
|
let n = e.line2.trim();
|
|
145
125
|
return {
|
|
146
126
|
line1: e.line1.trim(),
|
|
@@ -151,7 +131,7 @@ function E(e, t = {}) {
|
|
|
151
131
|
country: "US"
|
|
152
132
|
};
|
|
153
133
|
}
|
|
154
|
-
function
|
|
134
|
+
function T(e) {
|
|
155
135
|
return {
|
|
156
136
|
line1: e.line1 ?? "",
|
|
157
137
|
line2: e.line2 ?? "",
|
|
@@ -160,10 +140,10 @@ function D(e) {
|
|
|
160
140
|
postalCode: e.postal_code ?? ""
|
|
161
141
|
};
|
|
162
142
|
}
|
|
163
|
-
function
|
|
164
|
-
return
|
|
143
|
+
function E(e) {
|
|
144
|
+
return w(e);
|
|
165
145
|
}
|
|
166
|
-
function
|
|
146
|
+
function D(e) {
|
|
167
147
|
return {
|
|
168
148
|
line1: e.line1.trim(),
|
|
169
149
|
line2: e.line2.trim(),
|
|
@@ -173,7 +153,7 @@ function k(e) {
|
|
|
173
153
|
country: "US"
|
|
174
154
|
};
|
|
175
155
|
}
|
|
176
|
-
function
|
|
156
|
+
function O(e = "organization", t) {
|
|
177
157
|
return {
|
|
178
158
|
entityType: e,
|
|
179
159
|
legalName: "",
|
|
@@ -192,11 +172,11 @@ function A(e = "organization", t) {
|
|
|
192
172
|
}
|
|
193
173
|
};
|
|
194
174
|
}
|
|
195
|
-
function
|
|
196
|
-
let n =
|
|
197
|
-
return n.email =
|
|
175
|
+
function k(e, t) {
|
|
176
|
+
let n = O(e.type);
|
|
177
|
+
return n.email = f(e), n.phone = p(e), n.taxId = e.tax_id ?? "", n.remindersEnabled = !!e.reminders_enabled, t && (n.address = T(t)), "organization" in e ? n.legalName = e.organization.legal_name : (n.firstName = e.individual.first_name, n.lastName = e.individual.last_name), n;
|
|
198
178
|
}
|
|
199
|
-
function
|
|
179
|
+
function A(e) {
|
|
200
180
|
return [
|
|
201
181
|
e.line1,
|
|
202
182
|
e.line2,
|
|
@@ -205,11 +185,11 @@ function M(e) {
|
|
|
205
185
|
e.postalCode
|
|
206
186
|
].some((e) => e.trim().length > 0);
|
|
207
187
|
}
|
|
208
|
-
function
|
|
209
|
-
return
|
|
188
|
+
function j(e) {
|
|
189
|
+
return A(e) ? w(e) : void 0;
|
|
210
190
|
}
|
|
211
|
-
function
|
|
212
|
-
let n = t === "customer", r = t === "vendor", i =
|
|
191
|
+
function M(e, t) {
|
|
192
|
+
let n = t === "customer", r = t === "vendor", i = j(e.address), a = e.taxId.trim() || void 0, o = e.email.trim(), s = e.phone.trim() || void 0, c = {
|
|
213
193
|
is_customer: n,
|
|
214
194
|
is_vendor: r,
|
|
215
195
|
language: "en",
|
|
@@ -238,9 +218,8 @@ function P(e, t) {
|
|
|
238
218
|
}
|
|
239
219
|
};
|
|
240
220
|
}
|
|
241
|
-
function
|
|
221
|
+
function N(e, t) {
|
|
242
222
|
let n = e.taxId.trim(), r = e.email.trim(), i = e.phone.trim(), a = {
|
|
243
|
-
language: "en",
|
|
244
223
|
reminders_enabled: t === "customer" ? e.remindersEnabled : void 0,
|
|
245
224
|
tax_id: n
|
|
246
225
|
};
|
|
@@ -256,13 +235,12 @@ function F(e, t) {
|
|
|
256
235
|
individual: {
|
|
257
236
|
first_name: e.firstName.trim(),
|
|
258
237
|
last_name: e.lastName.trim(),
|
|
259
|
-
title: e.title.trim(),
|
|
260
238
|
email: r,
|
|
261
239
|
phone: i
|
|
262
240
|
}
|
|
263
241
|
};
|
|
264
242
|
}
|
|
265
|
-
function
|
|
243
|
+
function P(e, t, n) {
|
|
266
244
|
let i = {
|
|
267
245
|
...r,
|
|
268
246
|
...n
|
|
@@ -273,20 +251,20 @@ function I(e, t, n) {
|
|
|
273
251
|
description: t === "vendor" ? i.vendorTaxIdHelp : i.customerTaxIdHelp
|
|
274
252
|
};
|
|
275
253
|
}
|
|
276
|
-
function
|
|
277
|
-
return
|
|
254
|
+
function F(e) {
|
|
255
|
+
return A(e.address);
|
|
278
256
|
}
|
|
279
|
-
function
|
|
257
|
+
function I(e) {
|
|
280
258
|
return [
|
|
281
259
|
e.accountHolderName,
|
|
282
260
|
e.routingNumber,
|
|
283
261
|
e.accountNumber
|
|
284
262
|
].some((e) => e.trim().length > 0);
|
|
285
263
|
}
|
|
286
|
-
function
|
|
287
|
-
return
|
|
264
|
+
function L(e) {
|
|
265
|
+
return I(e.bankAccount);
|
|
288
266
|
}
|
|
289
|
-
function
|
|
267
|
+
function R(e, t = {}) {
|
|
290
268
|
return {
|
|
291
269
|
account_holder_name: e.accountHolderName.trim() || void 0,
|
|
292
270
|
account_number: e.accountNumber.trim() || void 0,
|
|
@@ -296,7 +274,7 @@ function B(e, t = {}) {
|
|
|
296
274
|
is_default_for_currency: t.isDefaultForCurrency ?? !0
|
|
297
275
|
};
|
|
298
276
|
}
|
|
299
|
-
function
|
|
277
|
+
function z(e, t = {}) {
|
|
300
278
|
return {
|
|
301
279
|
account_holder_name: e.accountHolderName.trim() || void 0,
|
|
302
280
|
account_number: e.accountNumber.trim() || void 0,
|
|
@@ -307,7 +285,7 @@ function V(e, t = {}) {
|
|
|
307
285
|
} : {}
|
|
308
286
|
};
|
|
309
287
|
}
|
|
310
|
-
function
|
|
288
|
+
function B(e) {
|
|
311
289
|
return [
|
|
312
290
|
e.account_number,
|
|
313
291
|
e.iban,
|
|
@@ -316,145 +294,102 @@ function H(e) {
|
|
|
316
294
|
e.bic
|
|
317
295
|
].every((e) => !e);
|
|
318
296
|
}
|
|
319
|
-
function
|
|
320
|
-
return
|
|
297
|
+
function V(e) {
|
|
298
|
+
return B(e) ? !0 : !(e.country !== "US" || e.currency !== "USD" || e.iban || e.sort_code || e.bic || !e.routing_number && !e.account_number);
|
|
321
299
|
}
|
|
322
|
-
function
|
|
300
|
+
function H(e, t) {
|
|
323
301
|
if (t) {
|
|
324
302
|
let n = e?.find((e) => e.id === t);
|
|
325
303
|
return {
|
|
326
304
|
kind: "update",
|
|
327
305
|
bankAccountId: t,
|
|
328
|
-
includeAchDefaults: n ?
|
|
306
|
+
includeAchDefaults: n ? B(n) : !1
|
|
329
307
|
};
|
|
330
308
|
}
|
|
331
|
-
let n = e?.find(
|
|
309
|
+
let n = e?.find(B);
|
|
332
310
|
return n ? {
|
|
333
311
|
kind: "update",
|
|
334
312
|
bankAccountId: n.id,
|
|
335
313
|
includeAchDefaults: !0
|
|
336
314
|
} : {
|
|
337
315
|
kind: "create",
|
|
338
|
-
isDefaultForCurrency: !(e ?? []).some((e) => e.currency === "USD" && e.is_default_for_currency)
|
|
316
|
+
isDefaultForCurrency: !(e ?? []).some((e) => e.currency === "USD" && e.is_default_for_currency && V(e))
|
|
339
317
|
};
|
|
340
318
|
}
|
|
341
|
-
function
|
|
319
|
+
function U() {
|
|
342
320
|
return {
|
|
343
|
-
name: "",
|
|
344
321
|
accountHolderName: "",
|
|
345
|
-
accountNumber: "",
|
|
346
322
|
routingNumber: "",
|
|
347
|
-
|
|
348
|
-
bic: "",
|
|
349
|
-
sortCode: "",
|
|
350
|
-
currency: "USD",
|
|
351
|
-
isDefault: !1
|
|
323
|
+
accountNumber: ""
|
|
352
324
|
};
|
|
353
325
|
}
|
|
354
|
-
function
|
|
326
|
+
function W(e) {
|
|
355
327
|
return {
|
|
356
|
-
name: e.name ?? "",
|
|
357
328
|
accountHolderName: e.account_holder_name ?? "",
|
|
358
|
-
accountNumber: e.account_number ?? "",
|
|
359
329
|
routingNumber: e.routing_number ?? "",
|
|
360
|
-
|
|
361
|
-
bic: e.bic ?? "",
|
|
362
|
-
sortCode: e.sort_code ?? "",
|
|
363
|
-
currency: e.currency ?? "USD",
|
|
364
|
-
isDefault: e.is_default_for_currency ?? !1
|
|
330
|
+
accountNumber: e.account_number ?? ""
|
|
365
331
|
};
|
|
366
332
|
}
|
|
367
|
-
function
|
|
368
|
-
return {
|
|
369
|
-
name: e.name.trim() || void 0,
|
|
370
|
-
account_holder_name: e.accountHolderName.trim() || void 0,
|
|
371
|
-
account_number: e.accountNumber.trim() || void 0,
|
|
372
|
-
routing_number: e.routingNumber.trim() || void 0,
|
|
373
|
-
iban: e.iban.trim() || void 0,
|
|
374
|
-
bic: e.bic.trim() || void 0,
|
|
375
|
-
sort_code: e.sortCode.trim() || void 0,
|
|
376
|
-
currency: e.currency,
|
|
377
|
-
country: "US",
|
|
378
|
-
is_default_for_currency: e.isDefault
|
|
379
|
-
};
|
|
380
|
-
}
|
|
381
|
-
function q(e) {
|
|
382
|
-
return {
|
|
383
|
-
name: e.name.trim(),
|
|
384
|
-
account_holder_name: e.accountHolderName.trim(),
|
|
385
|
-
account_number: e.accountNumber.trim(),
|
|
386
|
-
routing_number: e.routingNumber.trim(),
|
|
387
|
-
iban: e.iban.trim(),
|
|
388
|
-
bic: e.bic.trim(),
|
|
389
|
-
sort_code: e.sortCode.trim(),
|
|
390
|
-
currency: e.currency,
|
|
391
|
-
country: "US"
|
|
392
|
-
};
|
|
393
|
-
}
|
|
394
|
-
function J(e) {
|
|
333
|
+
function G(e) {
|
|
395
334
|
return /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e);
|
|
396
335
|
}
|
|
397
|
-
function
|
|
336
|
+
function K(e, t) {
|
|
398
337
|
let n = {};
|
|
399
338
|
return e.line1.trim().length === 0 && (n.line1 = t.addressLine1Required), e.city.trim().length === 0 && (n.city = t.cityRequired), e.state.trim().length === 0 && (n.state = t.stateRequired), e.postalCode.trim().length === 0 && (n.postalCode = t.postalCodeRequired), n;
|
|
400
339
|
}
|
|
401
|
-
function
|
|
340
|
+
function q(e) {
|
|
402
341
|
return Object.values(e).some(Boolean);
|
|
403
342
|
}
|
|
404
|
-
function
|
|
343
|
+
function J(e) {
|
|
405
344
|
if (!/^\d{9}$/.test(e)) return !1;
|
|
406
345
|
let t = [...e].map(Number);
|
|
407
346
|
return (3 * (t[0] + t[3] + t[6]) + 7 * (t[1] + t[4] + t[7]) + (t[2] + t[5] + t[8])) % 10 == 0;
|
|
408
347
|
}
|
|
409
|
-
function
|
|
348
|
+
function Y(e, t = a) {
|
|
410
349
|
let r = {}, i = e.accountHolderName.trim(), o = e.routingNumber.trim(), s = e.accountNumber.trim();
|
|
411
|
-
return i.length === 0 && (r.accountHolderName = t.accountHolderNameRequired), (o.length === 0 || !
|
|
350
|
+
return i.length === 0 && (r.accountHolderName = t.accountHolderNameRequired), (o.length === 0 || !J(o)) && (r.routingNumber = t.routingNumberInvalid), n(s) || (r.accountNumber = t.accountNumberInvalid), r;
|
|
412
351
|
}
|
|
413
|
-
function
|
|
352
|
+
function X(e) {
|
|
414
353
|
let t = (/^(\+?[\d\s().-]+?)\s*(?:(?:x|ext\.?)\s*\d+)?$/i.exec(e)?.[1])?.replace(/\D/g, "").length ?? 0;
|
|
415
354
|
return t >= 7 && t <= 15;
|
|
416
355
|
}
|
|
417
|
-
function
|
|
356
|
+
function Z(e) {
|
|
418
357
|
return /^[\d\s-]+$/.test(e) && e.replace(/\D/g, "").length === 9;
|
|
419
358
|
}
|
|
420
|
-
function
|
|
359
|
+
function Q(e, t, n = a, r = "customer", i = !1) {
|
|
421
360
|
let o = {};
|
|
422
|
-
e.entityType === "organization" ? e.legalName.trim().length === 0 && (o.legalName = n.legalNameRequired) : (e.firstName.trim().length === 0 && (o.firstName = n.firstNameRequired), e.lastName.trim().length === 0 && (o.lastName = n.lastNameRequired)), e.email.trim().length === 0 ? o.email = n.emailRequired :
|
|
361
|
+
e.entityType === "organization" ? e.legalName.trim().length === 0 && (o.legalName = n.legalNameRequired) : (e.firstName.trim().length === 0 && (o.firstName = n.firstNameRequired), e.lastName.trim().length === 0 && (o.lastName = n.lastNameRequired)), e.email.trim().length === 0 ? o.email = n.emailRequired : G(e.email.trim()) || (o.email = n.emailInvalid);
|
|
423
362
|
let s = e.phone.trim();
|
|
424
|
-
s &&
|
|
363
|
+
s && !X(s) && (o.phone = n.phoneInvalid);
|
|
425
364
|
let c = e.taxId.trim();
|
|
426
|
-
if (c && !
|
|
427
|
-
let t =
|
|
428
|
-
|
|
365
|
+
if (c && !Z(c) && (o.taxId = n.taxIdInvalid), t === "create" && r === "vendor" || A(e.address)) {
|
|
366
|
+
let t = K(e.address, n);
|
|
367
|
+
q(t) && (o.address = t);
|
|
429
368
|
}
|
|
430
|
-
if (r === "vendor" && (i ||
|
|
431
|
-
let t =
|
|
432
|
-
|
|
369
|
+
if (r === "vendor" && (i || L(e))) {
|
|
370
|
+
let t = Y(e.bankAccount, n);
|
|
371
|
+
q(t) && (o.bankAccount = t);
|
|
433
372
|
}
|
|
434
373
|
return o;
|
|
435
374
|
}
|
|
436
|
-
function
|
|
375
|
+
function $(e, t, n) {
|
|
437
376
|
if (!n) return e;
|
|
438
377
|
let r = { ...e };
|
|
439
378
|
return t.phone.trim() === n.phone.trim() && delete r.phone, t.taxId.trim() === n.taxId.trim() && delete r.taxId, r;
|
|
440
379
|
}
|
|
441
|
-
function
|
|
380
|
+
function ee(e) {
|
|
442
381
|
let { address: t, bankAccount: n, ...r } = e;
|
|
443
|
-
return
|
|
382
|
+
return q(r) || (t ? q(t) : !1) || (n ? q(n) : !1);
|
|
444
383
|
}
|
|
445
|
-
function
|
|
446
|
-
|
|
447
|
-
return e.accountNumber.trim().length === 0 && e.iban.trim().length === 0 && (n.accountNumber = t.bankAccountIdentifierRequired), e.currency.trim().length === 0 && (n.currency = t.bankAccountCurrencyRequired), n;
|
|
448
|
-
}
|
|
449
|
-
function oe(e) {
|
|
450
|
-
return X(e);
|
|
384
|
+
function te(e) {
|
|
385
|
+
return q(e);
|
|
451
386
|
}
|
|
452
|
-
function
|
|
453
|
-
return
|
|
387
|
+
function ne(e, t = a) {
|
|
388
|
+
return K(e, t);
|
|
454
389
|
}
|
|
455
|
-
function
|
|
390
|
+
function re() {
|
|
456
391
|
let e = globalThis.getSelection?.();
|
|
457
392
|
return !!(e && e.toString().length > 0);
|
|
458
393
|
}
|
|
459
394
|
//#endregion
|
|
460
|
-
export {
|
|
395
|
+
export { E as addressFormToCreatePayload, D as addressFormToUpdatePayload, T as addressResponseToFormValues, W as bankAccountToAchFormValues, m as buildAnalyticsMap, x as buildBankAccountItems, y as buildCounterpartDetailsView, P as buildCounterpartFormTaxIdField, g as buildCounterpartRows, R as counterpartFormBankAccountToCreatePayload, z as counterpartFormBankAccountToUpdatePayload, M as counterpartFormToCreatePayload, N as counterpartFormToUpdatePayload, k as counterpartToFormValues, U as emptyAchFormValues, O as emptyCounterpartFormValues, u as formatCounterpartDate, c as formatMoney, s as fromMinorUnits, S as getAchInstructions, f as getCounterpartEmail, d as getCounterpartName, C as getPayableAchInstructions, te as hasAchFormErrors, I as hasAchFormValues, F as hasCounterpartFormAddressValues, L as hasCounterpartFormBankAccountValues, ee as hasCounterpartFormErrors, re as hasSelectedText, V as isAchCompatibleBankAccount, H as resolveCounterpartBankAccountWrite, Y as validateAchFormValues, ne as validateAddressForm, Q as validateCounterpartForm, $ as withoutUnchangedContactErrors };
|
|
@@ -11,15 +11,13 @@ var e = {
|
|
|
11
11
|
cityRequired: "City is required",
|
|
12
12
|
stateRequired: "State is required",
|
|
13
13
|
postalCodeRequired: "ZIP code is required",
|
|
14
|
-
bankAccountIdentifierRequired: "Enter an account number or IBAN for this bank account",
|
|
15
|
-
bankAccountCurrencyRequired: "Currency is required",
|
|
16
14
|
accountHolderNameRequired: "Account holder name is required",
|
|
17
15
|
routingNumberInvalid: "Enter a valid 9-digit ABA routing number",
|
|
18
16
|
accountNumberInvalid: "Enter a valid account number",
|
|
19
17
|
vatIdValueRequired: "VAT ID is required",
|
|
20
18
|
genericError: "Something went wrong. Please try again.",
|
|
21
19
|
amountsUnavailable: "Some amounts could not be loaded. Try refreshing the page.",
|
|
22
|
-
deleteTitle: "Delete
|
|
20
|
+
deleteTitle: "Delete {name}?",
|
|
23
21
|
deleteBankAccountTitle: "Delete bank account “{account}”?",
|
|
24
22
|
deleteCounterpartMessage: "This record and its contacts, bank accounts, and tax ID will be permanently removed. You can't undo this action.",
|
|
25
23
|
deleteBankAccountMessage: "This removes these payment instructions from the vendor. The vendor will not be deleted. You can't undo this action."
|
|
@@ -2,43 +2,48 @@
|
|
|
2
2
|
"use client";
|
|
3
3
|
"use client";
|
|
4
4
|
"use client";
|
|
5
|
-
import {
|
|
6
|
-
import { useCreateCounterpartBankAccountMutation as s,
|
|
5
|
+
import { bankAccountToAchFormValues as e, counterpartFormBankAccountToCreatePayload as t, counterpartFormBankAccountToUpdatePayload as n, emptyAchFormValues as r, hasAchFormErrors as i, resolveCounterpartBankAccountWrite as a, validateAchFormValues as o } from "./helpers.js";
|
|
6
|
+
import { useCreateCounterpartBankAccountMutation as s, useUpdateCounterpartBankAccountMutation as c } from "../../../data-access/dist/index5.js";
|
|
7
7
|
import "../../../data-access/dist/index.js";
|
|
8
|
-
import { useSubEntityForm as
|
|
9
|
-
import { useMemo as d } from "react";
|
|
8
|
+
import { useSubEntityForm as l } from "./useSubEntityForm.js";
|
|
10
9
|
//#region ../../libs/tesouro-embedded-components-react/shared/counterpart-management/feature/dist/lib/subEntityForms.js
|
|
11
|
-
function
|
|
12
|
-
let
|
|
13
|
-
items:
|
|
10
|
+
function u({ items: u, selectedId: d, messages: f }) {
|
|
11
|
+
let p = s(), m = c(), h = l({
|
|
12
|
+
items: u,
|
|
14
13
|
empty: r,
|
|
15
|
-
toFormValues:
|
|
16
|
-
validate: (e) => o(e,
|
|
17
|
-
hasErrors:
|
|
18
|
-
genericError:
|
|
19
|
-
onSubmit: async ({ mode:
|
|
20
|
-
if (!
|
|
21
|
-
let o = r;
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
14
|
+
toFormValues: e,
|
|
15
|
+
validate: (e) => o(e, f),
|
|
16
|
+
hasErrors: (e) => i(e),
|
|
17
|
+
genericError: f.genericError,
|
|
18
|
+
onSubmit: async ({ mode: e, id: r, values: i }) => {
|
|
19
|
+
if (!d) return;
|
|
20
|
+
let o = a(u, e === "edit" ? r : void 0);
|
|
21
|
+
if (o.kind === "update") {
|
|
22
|
+
await m.mutateAsync({
|
|
23
|
+
path: {
|
|
24
|
+
counterpart_id: d,
|
|
25
|
+
bank_account_id: o.bankAccountId
|
|
26
|
+
},
|
|
27
|
+
body: n(i, { includeAchDefaults: o.includeAchDefaults })
|
|
28
|
+
});
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
await p.mutateAsync({
|
|
32
|
+
path: { counterpart_id: d },
|
|
33
|
+
body: t(i, { isDefaultForCurrency: o.isDefaultForCurrency })
|
|
34
|
+
});
|
|
35
35
|
}
|
|
36
|
-
}),
|
|
36
|
+
}), g = h.sheet.mode === "edit" ? u?.find((e) => e.id === h.sheet.id) : void 0, _ = g ? {
|
|
37
|
+
accountHolderName: !h.values.accountHolderName.trim(),
|
|
38
|
+
routingNumber: !h.values.routingNumber.trim(),
|
|
39
|
+
accountNumber: !h.values.accountNumber.trim()
|
|
40
|
+
} : void 0, v = g ? e(g) : r(), y = Object.keys(v).some((e) => h.values[e] !== v[e]);
|
|
37
41
|
return {
|
|
38
|
-
form:
|
|
39
|
-
inProgress:
|
|
40
|
-
|
|
42
|
+
form: h,
|
|
43
|
+
inProgress: p.isPending || m.isPending,
|
|
44
|
+
highlightedFields: _,
|
|
45
|
+
isDirty: y
|
|
41
46
|
};
|
|
42
47
|
}
|
|
43
48
|
//#endregion
|
|
44
|
-
export {
|
|
49
|
+
export { u as useBankAccountForm };
|