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