@tesouro/embedded-components-react 0.5.58 → 0.5.60
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/README.md +9 -9
- package/dist/index.d.ts +5 -3
- package/dist/lib/CounterpartsWidget.d.ts +5 -3
- package/dist/lib/ReceivablesWidget.d.ts +3 -2
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index49.js +53 -53
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index52.js +42 -65
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index53.js +288 -226
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index57.js +104 -101
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index61.js +313 -285
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index26.js +12 -4
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index27.js +2 -0
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index28.js +41 -31
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index31.js +8 -1
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index46.js +9 -0
- package/dist/libs/tesouro-embedded-components-react/counterparts-widget/feature/dist/index8.js +1 -1
- package/dist/libs/tesouro-embedded-components-react/shared/counterpart-management/feature/dist/lib/helpers.js +1 -1
- package/dist/libs/tesouro-embedded-components-react/shared/counterpart-management/feature/dist/lib/labels.js +2 -2
- package/dist/libs/tesouro-embedded-components-react/shared/counterpart-management/feature/dist/lib/useDeleteController.js +4 -4
- package/dist/libs/tesouro-embedded-components-react/shared/counterpart-management/ui/dist/index11.js +121 -115
- package/dist/libs/tesouro-embedded-components-react/shared/counterpart-management/ui/dist/index2.js +2 -1
- package/dist/libs/tesouro-embedded-components-react/shared/counterpart-management/ui/dist/index6.js +1 -0
- package/dist/libs/tesouro-embedded-components-react/shared/data-access/dist/lib/rest/zod.gen.js +1419 -1397
- package/dist/libs/tesouro-embedded-components-react/shared/feature/dist/lib/analytics/build-info.js +1 -1
- package/package.json +1 -1
|
@@ -10,28 +10,31 @@ import { useCreatePayableMutation as r, useDeletePayableFileMutation as i, useSu
|
|
|
10
10
|
import "../../data-access/dist/index.js";
|
|
11
11
|
import { BILL_CREATE_MESSAGE_LABELS_EN as c } from "./index49.js";
|
|
12
12
|
import { encodeFileToBase64 as l } from "./index54.js";
|
|
13
|
-
import { mapBillFormToPayload as u, mapLineItemsToPayload as
|
|
14
|
-
import { validateBillCompleteness as
|
|
15
|
-
import { useCallback as h, useRef as
|
|
13
|
+
import { mapBillFormToPayload as u, mapLineItemsToPayload as ee, mapPayableAmountFieldsToPayload as te } from "./index55.js";
|
|
14
|
+
import { validateBillCompleteness as ne, validateBillTotalIsPayable as d, validateBillTotals as re, validateBillValues as f, validateLineItems as p, validateStoredAmountDue as m } from "./index56.js";
|
|
15
|
+
import { useCallback as h, useRef as ie, useState as g } from "react";
|
|
16
16
|
//#region ../../libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index57.js
|
|
17
|
-
var
|
|
17
|
+
var _ = {
|
|
18
18
|
document_id: "invoiceNumber",
|
|
19
19
|
issued_at: "invoiceDate",
|
|
20
20
|
due_date: "dueDate",
|
|
21
21
|
counterpart_id: "vendor",
|
|
22
22
|
purchase_order_number: "poNumber"
|
|
23
|
-
},
|
|
24
|
-
function
|
|
23
|
+
}, v = { tax_amount: "tax" };
|
|
24
|
+
function y(e) {
|
|
25
25
|
return e.type === "type_error.none.not_allowed" || e.msg === "none is not an allowed value";
|
|
26
26
|
}
|
|
27
|
-
var
|
|
28
|
-
function
|
|
27
|
+
var ae = "pending-vendor";
|
|
28
|
+
function b(e) {
|
|
29
29
|
return !!t(e)?.includes("line_items_enabled");
|
|
30
30
|
}
|
|
31
|
+
function x(e) {
|
|
32
|
+
return !!t(e)?.includes("A vendor could not be linked or created for this payable");
|
|
33
|
+
}
|
|
31
34
|
function S(e, t = c) {
|
|
32
35
|
let n = {}, r = {}, i = [];
|
|
33
36
|
for (let a of e) {
|
|
34
|
-
let e = a.loc[0] ?? t.unknownValidationField, o =
|
|
37
|
+
let e = a.loc[0] ?? t.unknownValidationField, o = _[e], s = v[e], c = y(a) ? t.requiredField : a.msg;
|
|
35
38
|
o ? n[o] = c : s ? r[s] = c : i.push(t.unmappedValidationError(e, c));
|
|
36
39
|
}
|
|
37
40
|
return i.length && (n.form = i.join(" ")), {
|
|
@@ -39,7 +42,7 @@ function S(e, t = c) {
|
|
|
39
42
|
totalsErrors: Object.keys(r).length ? r : void 0
|
|
40
43
|
};
|
|
41
44
|
}
|
|
42
|
-
function
|
|
45
|
+
function C(e, t) {
|
|
43
46
|
if (!e && !t) return;
|
|
44
47
|
let n = {}, r = /* @__PURE__ */ new Set([...Object.keys(e ?? {}), ...Object.keys(t ?? {})]);
|
|
45
48
|
for (let i of r) n[i] = {
|
|
@@ -48,182 +51,182 @@ function ae(e, t) {
|
|
|
48
51
|
};
|
|
49
52
|
return n;
|
|
50
53
|
}
|
|
51
|
-
function
|
|
52
|
-
let
|
|
54
|
+
function w({ payableId: t, form: _, counterpartId: v, isVendorPending: y, clearCounterpart: w, prepareVendorForSave: T, onSaved: E, onPayableCreated: D, readSavedStatus: O, onDraftSaved: k, onFinalized: A, labels: j }) {
|
|
55
|
+
let M = {
|
|
53
56
|
...c,
|
|
54
|
-
...
|
|
55
|
-
}, [
|
|
56
|
-
let t =
|
|
57
|
-
return
|
|
57
|
+
...j
|
|
58
|
+
}, [N, P] = g(), F = t ?? N, [I, L] = g(), R = h(() => L(void 0), []), [z, B] = g(!1), oe = h(() => B(!0), []), [V, H] = g(), U = ie(!1), [se, ce] = g(0), W = h(() => ce((e) => e + 1), []), G = r(), K = i(), q = o(), J = n(), Y = s(), X = a(), Z = h(() => _.isTotalsDirty ? re(_.discount, _.tax, _.totalOverride, M) : void 0, [_, M]), Q = h(() => {
|
|
59
|
+
let t = f(_.values, M), n = p(_.lineItems, M), r = Z();
|
|
60
|
+
return _.setErrors(t), _.setLineItemErrors(n), _.setTotalsErrors(r), !t && !n && !r || (n && e.error(M.lineItemsNeedAttention), W(), !1);
|
|
58
61
|
}, [
|
|
59
|
-
|
|
60
|
-
|
|
62
|
+
_,
|
|
63
|
+
M,
|
|
61
64
|
W,
|
|
62
65
|
Z
|
|
63
66
|
]), $ = h(async (e, t) => {
|
|
64
|
-
let n = !
|
|
65
|
-
base64EncodedFile: await l(
|
|
66
|
-
fileName:
|
|
67
|
-
} : void 0, r =
|
|
68
|
-
discount:
|
|
69
|
-
tax:
|
|
70
|
-
total:
|
|
67
|
+
let n = !F && I ? {
|
|
68
|
+
base64EncodedFile: await l(I),
|
|
69
|
+
fileName: I.name
|
|
70
|
+
} : void 0, r = _.isTotalsDirty ? {
|
|
71
|
+
discount: _.discount,
|
|
72
|
+
tax: _.tax,
|
|
73
|
+
total: _.totalOverride
|
|
71
74
|
} : void 0, i = u({
|
|
72
|
-
values:
|
|
73
|
-
initialLineItems:
|
|
74
|
-
counterpartId: t ??
|
|
75
|
-
clearCounterpart:
|
|
75
|
+
values: _.values,
|
|
76
|
+
initialLineItems: F ? void 0 : _.lineItems,
|
|
77
|
+
counterpartId: t ?? v,
|
|
78
|
+
clearCounterpart: w,
|
|
76
79
|
counterpartBankAccountId: e,
|
|
77
80
|
currentTotals: {
|
|
78
|
-
discount:
|
|
79
|
-
tax:
|
|
80
|
-
total:
|
|
81
|
+
discount: _.discount,
|
|
82
|
+
tax: _.tax,
|
|
83
|
+
total: _.totalOverride
|
|
81
84
|
},
|
|
82
|
-
lineItems:
|
|
85
|
+
lineItems: _.lineItems,
|
|
83
86
|
editedTotals: r,
|
|
84
87
|
document: n
|
|
85
|
-
}), a =
|
|
88
|
+
}), a = F;
|
|
86
89
|
if (a ? await q.mutateAsync({
|
|
87
90
|
path: { payable_id: a },
|
|
88
91
|
body: i
|
|
89
|
-
}) : (a = (await G.mutateAsync({ body: i }))?.id, a && (
|
|
90
|
-
if (
|
|
92
|
+
}) : (a = (await G.mutateAsync({ body: i }))?.id, a && (P(a), D?.(a), n && L(void 0))), !a) throw Error("Payable was created without an id");
|
|
93
|
+
if (z) {
|
|
91
94
|
try {
|
|
92
95
|
await K.mutateAsync({ path: { payable_id: a } });
|
|
93
96
|
} catch {}
|
|
94
|
-
|
|
97
|
+
B(!1);
|
|
95
98
|
}
|
|
96
99
|
return await J.mutateAsync({
|
|
97
100
|
path: { payable_id: a },
|
|
98
|
-
body: { data:
|
|
101
|
+
body: { data: ee(_.lineItems) }
|
|
99
102
|
}), r && await q.mutateAsync({
|
|
100
103
|
path: { payable_id: a },
|
|
101
|
-
body:
|
|
102
|
-
lineItems:
|
|
104
|
+
body: te({
|
|
105
|
+
lineItems: _.lineItems,
|
|
103
106
|
editedTotals: r
|
|
104
107
|
})
|
|
105
108
|
}), a;
|
|
106
109
|
}, [
|
|
107
|
-
|
|
108
|
-
|
|
110
|
+
v,
|
|
111
|
+
w,
|
|
109
112
|
G,
|
|
110
113
|
K,
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
P,
|
|
120
|
-
J,
|
|
114
|
+
z,
|
|
115
|
+
_.discount,
|
|
116
|
+
_.isTotalsDirty,
|
|
117
|
+
_.lineItems,
|
|
118
|
+
_.tax,
|
|
119
|
+
_.totalOverride,
|
|
120
|
+
_.values,
|
|
121
|
+
D,
|
|
121
122
|
F,
|
|
123
|
+
J,
|
|
124
|
+
I,
|
|
122
125
|
q
|
|
123
|
-
]),
|
|
124
|
-
|
|
125
|
-
}, [K,
|
|
126
|
+
]), le = h(async () => {
|
|
127
|
+
F && (await K.mutateAsync({ path: { payable_id: F } }), B(!1));
|
|
128
|
+
}, [K, F]);
|
|
126
129
|
return {
|
|
127
130
|
saveDraft: h(async () => {
|
|
128
|
-
if (!
|
|
129
|
-
|
|
131
|
+
if (!U.current && Q()) {
|
|
132
|
+
U.current = !0, H("draft");
|
|
130
133
|
try {
|
|
131
|
-
let t = await
|
|
134
|
+
let t = await T?.();
|
|
132
135
|
if (t && !t.ok) return;
|
|
133
136
|
let n = await $(t?.counterpartBankAccountId, t?.counterpartId);
|
|
134
|
-
|
|
135
|
-
let r = await
|
|
136
|
-
return e.success(r === "draft" ?
|
|
137
|
+
_.setErrors(void 0), E?.(n), k?.(n);
|
|
138
|
+
let r = await O?.();
|
|
139
|
+
return e.success(r === "draft" ? M.submittedDemoted : M.draftSaved), n;
|
|
137
140
|
} catch (e) {
|
|
138
|
-
|
|
141
|
+
_.setSaveFailureMessage(b(e) ? M.discountTaxBlockedByLineItems : M.saveFailed), W();
|
|
139
142
|
return;
|
|
140
143
|
} finally {
|
|
141
|
-
|
|
144
|
+
H(void 0), U.current = !1;
|
|
142
145
|
}
|
|
143
146
|
}
|
|
144
147
|
}, [
|
|
145
|
-
|
|
148
|
+
_,
|
|
146
149
|
Q,
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
150
|
+
M.discountTaxBlockedByLineItems,
|
|
151
|
+
M.draftSaved,
|
|
152
|
+
M.saveFailed,
|
|
153
|
+
M.submittedDemoted,
|
|
154
|
+
k,
|
|
155
|
+
E,
|
|
151
156
|
O,
|
|
152
157
|
T,
|
|
153
|
-
D,
|
|
154
|
-
w,
|
|
155
158
|
$,
|
|
156
159
|
W
|
|
157
160
|
]),
|
|
158
161
|
finalize: h(async () => {
|
|
159
|
-
if (
|
|
160
|
-
let t =
|
|
162
|
+
if (U.current) return;
|
|
163
|
+
let t = p(_.lineItems, M), n = f(_.values, M), r = Z(), i = d(_.total, M), a = _.isTotalsDirty ? m(_.totalOverride, M) : void 0, o = r || i || a ? {
|
|
161
164
|
...a,
|
|
162
165
|
...i,
|
|
163
166
|
...r
|
|
164
|
-
} : void 0, { formErrors: s, lineItemErrors: c } =
|
|
165
|
-
|
|
167
|
+
} : void 0, { formErrors: s, lineItemErrors: c } = ne(_.values, v ?? (y ? ae : void 0), _.lineItems, M), l = C(c, t);
|
|
168
|
+
_.setLineItemErrors(l), _.setTotalsErrors(o);
|
|
166
169
|
let u = {
|
|
167
170
|
...s,
|
|
168
171
|
...n
|
|
169
172
|
};
|
|
170
|
-
if (
|
|
173
|
+
if (_.setErrors(Object.keys(u).length ? u : void 0), t && e.error(M.lineItemsNeedAttention), l || o || Object.keys(u).length) {
|
|
171
174
|
W();
|
|
172
175
|
return;
|
|
173
176
|
}
|
|
174
|
-
|
|
177
|
+
U.current = !0, H("finalize");
|
|
175
178
|
try {
|
|
176
179
|
let t;
|
|
177
180
|
try {
|
|
178
|
-
let e = await
|
|
181
|
+
let e = await T?.();
|
|
179
182
|
if (e && !e.ok) return;
|
|
180
183
|
t = await $(e?.counterpartBankAccountId, e?.counterpartId);
|
|
181
184
|
} catch (e) {
|
|
182
|
-
|
|
185
|
+
_.setSaveFailureMessage(b(e) ? M.discountTaxBlockedByLineItems : M.saveFailed), W();
|
|
183
186
|
return;
|
|
184
187
|
}
|
|
185
|
-
|
|
188
|
+
E?.(t);
|
|
186
189
|
try {
|
|
187
190
|
let n = await Y.mutateAsync({ path: { payable_id: t } });
|
|
188
191
|
if (n.validation_errors.length) {
|
|
189
|
-
let e = S(n.validation_errors,
|
|
190
|
-
|
|
192
|
+
let e = S(n.validation_errors, M);
|
|
193
|
+
_.setErrors(e.formErrors), _.setTotalsErrors(e.totalsErrors), W();
|
|
191
194
|
return;
|
|
192
195
|
}
|
|
193
|
-
await X.mutateAsync({ path: { payable_id: t } }),
|
|
194
|
-
} catch {
|
|
195
|
-
|
|
196
|
+
await X.mutateAsync({ path: { payable_id: t } }), _.setErrors(void 0), A?.(t), e.success(M.billFinalized);
|
|
197
|
+
} catch (e) {
|
|
198
|
+
x(e) ? _.setErrors({ vendor: M.vendorResolutionFailed }) : _.setSaveFailureMessage(M.finalizeFailed), W();
|
|
196
199
|
}
|
|
197
200
|
} finally {
|
|
198
|
-
|
|
201
|
+
H(void 0), U.current = !1;
|
|
199
202
|
}
|
|
200
203
|
}, [
|
|
201
|
-
y,
|
|
202
|
-
b,
|
|
203
204
|
v,
|
|
204
|
-
|
|
205
|
-
|
|
205
|
+
y,
|
|
206
|
+
_,
|
|
207
|
+
M,
|
|
208
|
+
A,
|
|
209
|
+
E,
|
|
206
210
|
T,
|
|
207
|
-
w,
|
|
208
211
|
$,
|
|
209
212
|
W,
|
|
210
213
|
X,
|
|
211
214
|
Z,
|
|
212
215
|
Y
|
|
213
216
|
]),
|
|
214
|
-
payableId:
|
|
215
|
-
isSavingDraft:
|
|
216
|
-
isFinalizing:
|
|
217
|
-
stagedFile:
|
|
218
|
-
stageFile:
|
|
219
|
-
clearStagedFile:
|
|
220
|
-
scrollToErrorToken:
|
|
221
|
-
isFileDeletionPending:
|
|
222
|
-
requestFileDeletion:
|
|
223
|
-
detachFileNow:
|
|
217
|
+
payableId: F,
|
|
218
|
+
isSavingDraft: V === "draft",
|
|
219
|
+
isFinalizing: V === "finalize",
|
|
220
|
+
stagedFile: I,
|
|
221
|
+
stageFile: L,
|
|
222
|
+
clearStagedFile: R,
|
|
223
|
+
scrollToErrorToken: se,
|
|
224
|
+
isFileDeletionPending: z,
|
|
225
|
+
requestFileDeletion: oe,
|
|
226
|
+
detachFileNow: le,
|
|
224
227
|
isDeletingFile: K.isPending,
|
|
225
228
|
hasFileDeletionFailed: K.isError
|
|
226
229
|
};
|
|
227
230
|
}
|
|
228
231
|
//#endregion
|
|
229
|
-
export { S as mapValidationErrorsToForm,
|
|
232
|
+
export { S as mapValidationErrorsToForm, w as useBillCreateController };
|