@tesouro/embedded-components-react 0.5.0 → 0.5.1
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 +10 -9
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index40.js +14 -88
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index41.js +8 -96
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index42.js +91 -3
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index43.js +96 -48
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index44.js +3 -137
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index45.js +49 -35
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index46.js +129 -180
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index47.js +32 -74
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index48.js +186 -21
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index49.js +70 -226
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index50.js +22 -219
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index51.js +221 -109
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index52.js +220 -13
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index53.js +119 -46
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index54.js +13 -32
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index55.js +43 -198
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index56.js +29 -32
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index57.js +186 -222
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index58.js +37 -19
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index59.js +229 -420
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index60.js +21 -4
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index61.js +429 -34
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index62.js +4 -224
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index63.js +38 -3
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index64.js +222 -2
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index65.js +3 -46
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index66.js +4 -1
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index67.js +44 -6
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index68.js +1 -12
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index69.js +6 -110
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index70.js +12 -3
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index71.js +109 -124
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index72.js +3 -11
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index73.js +124 -7
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index74.js +8 -45
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index75.js +8 -21
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index76.js +45 -28
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index77.js +20 -83
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index78.js +28 -47
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index79.js +76 -243
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index80.js +48 -113
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index81.js +239 -196
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index82.js +115 -4
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index83.js +207 -5
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index84.js +3 -114
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index85.js +8 -1
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index86.js +106 -16
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index87.js +1 -0
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index88.js +25 -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/index8.js +1 -1
- package/package.json +1 -1
|
@@ -2,241 +2,205 @@
|
|
|
2
2
|
"use client";
|
|
3
3
|
"use client";
|
|
4
4
|
"use client";
|
|
5
|
-
import {
|
|
6
|
-
import
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
5
|
+
import { toast as e } from "../../../../../packages/shared-ui-shadcn/dist/index.js";
|
|
6
|
+
import "../../../shared/ui/dist/index.js";
|
|
7
|
+
import { extractApiErrorMessage as t } from "../../../shared/util/dist/lib/apiErrors.js";
|
|
8
|
+
import { useReplacePayableLineItemsMutation as n } from "../../data-access/dist/index10.js";
|
|
9
|
+
import { useCreatePayableMutation as r, useDeletePayableFileMutation as i, useSubmitPayableForApprovalMutation as a, useUpdatePayableMutation as o, useValidatePayableMutation as s } from "../../data-access/dist/index13.js";
|
|
10
|
+
import "../../data-access/dist/index.js";
|
|
11
|
+
import { BILL_CREATE_MESSAGE_LABELS_EN as c } from "./index48.js";
|
|
12
|
+
import { encodeFileToBase64 as ee } from "./index54.js";
|
|
13
|
+
import { mapBillFormToPayload as l, mapLineItemsToPayload as u } from "./index55.js";
|
|
14
|
+
import { validateBillCompleteness as d, validateBillTotals as f, validateLineItems as p } from "./index56.js";
|
|
15
|
+
import { useCallback as m, useRef as h, useState as g } from "react";
|
|
10
16
|
//#region ../../libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index57.js
|
|
11
|
-
var
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
17
|
+
var _ = {
|
|
18
|
+
document_id: "invoiceNumber",
|
|
19
|
+
issued_at: "invoiceDate",
|
|
20
|
+
due_date: "dueDate",
|
|
21
|
+
counterpart_id: "vendor"
|
|
22
|
+
}, v = { tax_amount: "tax" };
|
|
23
|
+
function y(e) {
|
|
24
|
+
return e.type === "type_error.none.not_allowed" || e.msg === "none is not an allowed value";
|
|
15
25
|
}
|
|
16
|
-
|
|
17
|
-
"
|
|
18
|
-
"price",
|
|
19
|
-
"amount"
|
|
20
|
-
];
|
|
21
|
-
function h(e) {
|
|
22
|
-
let t = e.trim(), n = /[.,]$/.test(t) ? t.slice(0, -1) : t;
|
|
23
|
-
return t && !n ? null : n;
|
|
26
|
+
function b(e) {
|
|
27
|
+
return !!t(e)?.includes("line_items_enabled");
|
|
24
28
|
}
|
|
25
|
-
function
|
|
26
|
-
|
|
27
|
-
let
|
|
28
|
-
|
|
29
|
+
function x(e, t = c) {
|
|
30
|
+
let n = {}, r = {}, i = [];
|
|
31
|
+
for (let a of e) {
|
|
32
|
+
let e = a.loc[0] ?? t.unknownValidationField, o = _[e], s = v[e], c = y(a) ? t.requiredField : a.msg;
|
|
33
|
+
o ? n[o] = c : s ? r[s] = c : i.push(t.unmappedValidationError(e, c));
|
|
34
|
+
}
|
|
35
|
+
return i.length && (n.form = i.join(" ")), {
|
|
36
|
+
formErrors: n,
|
|
37
|
+
totalsErrors: Object.keys(r).length ? r : void 0
|
|
38
|
+
};
|
|
29
39
|
}
|
|
30
|
-
function
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
40
|
+
function S(e, t) {
|
|
41
|
+
if (!e && !t) return;
|
|
42
|
+
let n = {}, r = /* @__PURE__ */ new Set([...Object.keys(e ?? {}), ...Object.keys(t ?? {})]);
|
|
43
|
+
for (let i of r) n[i] = {
|
|
44
|
+
...e?.[i],
|
|
45
|
+
...t?.[i]
|
|
34
46
|
};
|
|
35
|
-
for (let i of ["price", "amount"]) {
|
|
36
|
-
let o = h(e[i]);
|
|
37
|
-
o !== null && (a[i] = r(o), o && a[i] === null && (n[i] = t.unreadableMoney));
|
|
38
|
-
}
|
|
39
|
-
let o = h(e.quantity);
|
|
40
|
-
if (o !== null) {
|
|
41
|
-
let e = a.price !== null || a.amount !== null;
|
|
42
|
-
i(o) === null && (o || e) && (n.quantity = t.unusableQuantity);
|
|
43
|
-
}
|
|
44
47
|
return n;
|
|
45
48
|
}
|
|
46
|
-
function
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
}), [n, r]), [f, h] = d(a.values), [y, b] = d(a.lineItems), [x, S] = d(a.discount), [C, w] = d(a.tax), [T, E] = d(a.total || void 0), [te, D] = d(), O = ee(void 0), k = c((e) => {
|
|
54
|
-
D((t) => {
|
|
55
|
-
let n = typeof e == "function" ? e(t) : e;
|
|
56
|
-
return n?.form !== O.current && (O.current = void 0), n;
|
|
57
|
-
});
|
|
58
|
-
}, []), A = c((e) => {
|
|
59
|
-
O.current = e, D((t) => ({
|
|
60
|
-
...t,
|
|
61
|
-
form: e
|
|
62
|
-
}));
|
|
63
|
-
}, []), j = c(() => {
|
|
64
|
-
D((e) => {
|
|
65
|
-
if (!e?.form || e.form !== O.current) return e;
|
|
66
|
-
O.current = void 0;
|
|
67
|
-
let { form: t, ...n } = e;
|
|
68
|
-
return Object.keys(n).length ? n : void 0;
|
|
69
|
-
});
|
|
70
|
-
}, []), [M, N] = d(), [P, F] = d(), [I, L] = d(!1), [R, z] = d(!1), [B, V] = d(!1);
|
|
71
|
-
l(() => {
|
|
72
|
-
I || h(a.values);
|
|
73
|
-
}, [a]), l(() => {
|
|
74
|
-
R || b(a.lineItems);
|
|
75
|
-
}, [a]), l(() => {
|
|
76
|
-
B || (S(a.discount), w(a.tax), E(a.total || void 0));
|
|
77
|
-
}, [a]);
|
|
78
|
-
let H = c((e) => {
|
|
79
|
-
h((t) => ({
|
|
80
|
-
...t,
|
|
81
|
-
...e
|
|
82
|
-
})), L(!0), D((t) => {
|
|
83
|
-
if (!t) return t;
|
|
84
|
-
let n = { ...t };
|
|
85
|
-
for (let t of Object.keys(e)) delete n[t];
|
|
86
|
-
return Object.keys(n).length ? n : void 0;
|
|
87
|
-
}), j();
|
|
88
|
-
}, [j]), U = c((e, t) => {
|
|
89
|
-
N((n) => {
|
|
90
|
-
if (!n?.[e] && !t) return n;
|
|
91
|
-
let r = {
|
|
92
|
-
...n,
|
|
93
|
-
[e]: t
|
|
94
|
-
};
|
|
95
|
-
return t || delete r[e], Object.keys(r).length ? r : void 0;
|
|
96
|
-
});
|
|
97
|
-
}, []), W = c((e, t) => {
|
|
98
|
-
U(e, g(e, t, i));
|
|
99
|
-
}, [i, U]), G = c(() => {
|
|
100
|
-
E(void 0), W("total", void 0), j();
|
|
101
|
-
}, [W, j]), K = c((e, t = []) => {
|
|
102
|
-
let n = _(e, i);
|
|
103
|
-
F((r) => {
|
|
104
|
-
let i = r?.[e.id], a = { ...i };
|
|
105
|
-
for (let e of [
|
|
106
|
-
"price",
|
|
107
|
-
"amount",
|
|
108
|
-
"quantity"
|
|
109
|
-
]) n[e] ? a[e] = n[e] : delete a[e];
|
|
110
|
-
t.includes("description") && delete a.description;
|
|
111
|
-
let o = Object.keys(a).length > 0;
|
|
112
|
-
if (!i && !o) return r;
|
|
113
|
-
let s = { ...r };
|
|
114
|
-
return o ? s[e.id] = a : delete s[e.id], Object.keys(s).length ? s : void 0;
|
|
115
|
-
});
|
|
116
|
-
}, [i]), q = c((e, t, n) => {
|
|
117
|
-
F((r) => ({
|
|
118
|
-
...r,
|
|
119
|
-
[e]: {
|
|
120
|
-
...r?.[e],
|
|
121
|
-
[t]: n
|
|
122
|
-
}
|
|
123
|
-
}));
|
|
124
|
-
}, []), J = c((e, t, n = []) => {
|
|
125
|
-
let r = y.find((t) => t.id === e);
|
|
126
|
-
if (!r) return;
|
|
127
|
-
let i = t(r);
|
|
128
|
-
b(y.map((t) => t.id === e ? i : t)), K(i, n), z(!0), G();
|
|
129
|
-
}, [
|
|
130
|
-
G,
|
|
131
|
-
y,
|
|
132
|
-
K
|
|
133
|
-
]), Y = c((e, t) => {
|
|
134
|
-
let n = { ...t };
|
|
135
|
-
for (let r of m) {
|
|
136
|
-
let a = t[r];
|
|
137
|
-
if (a === void 0) continue;
|
|
138
|
-
let o = p(a);
|
|
139
|
-
if (o === null) {
|
|
140
|
-
q(e, r, i.numbersOnly);
|
|
141
|
-
return;
|
|
142
|
-
}
|
|
143
|
-
n[r] = o;
|
|
144
|
-
}
|
|
145
|
-
J(e, (e) => {
|
|
146
|
-
let t = {
|
|
147
|
-
...e,
|
|
148
|
-
...n
|
|
149
|
-
};
|
|
150
|
-
return "amount" in n ? t : {
|
|
151
|
-
...t,
|
|
152
|
-
amount: v(t.quantity, t.price, t.amount)
|
|
153
|
-
};
|
|
154
|
-
}, Object.keys(n));
|
|
155
|
-
}, [
|
|
156
|
-
J,
|
|
157
|
-
i,
|
|
158
|
-
q
|
|
159
|
-
]), X = c((e, t) => {
|
|
160
|
-
J(e, (e) => {
|
|
161
|
-
let n = Number.parseFloat(e.quantity), r = String(Math.max(1, (Number.isFinite(n) ? n : 1) + t));
|
|
162
|
-
return {
|
|
163
|
-
...e,
|
|
164
|
-
quantity: r,
|
|
165
|
-
amount: v(r, e.price, e.amount)
|
|
166
|
-
};
|
|
167
|
-
});
|
|
168
|
-
}, [J]), Z = c((e) => {
|
|
169
|
-
F((t) => {
|
|
170
|
-
if (!t?.[e]) return t;
|
|
171
|
-
let n = { ...t };
|
|
172
|
-
return delete n[e], Object.keys(n).length ? n : void 0;
|
|
173
|
-
});
|
|
174
|
-
}, []), Q = c((e) => {
|
|
175
|
-
Z(e), b((t) => t.length <= 1 ? t : t.filter((t) => t.id !== e)), z(!0), G();
|
|
176
|
-
}, [Z, G]), ne = c(() => {
|
|
177
|
-
b((e) => [...e, o()]), z(!0), G();
|
|
178
|
-
}, [G]), $ = c((e, t, n) => {
|
|
179
|
-
let r = p(t);
|
|
180
|
-
if (r === null) {
|
|
181
|
-
U(e, i.numbersOnly);
|
|
182
|
-
return;
|
|
183
|
-
}
|
|
184
|
-
n(r), V(!0), G(), W(e, r);
|
|
49
|
+
function C({ payableId: t, form: _, counterpartId: v, clearCounterpart: y, prepareVendorForSave: C, onSaved: w, onPayableCreated: T, readSavedStatus: E, onDraftSaved: D, onFinalized: O, labels: k }) {
|
|
50
|
+
let A = {
|
|
51
|
+
...c,
|
|
52
|
+
...k
|
|
53
|
+
}, [j, M] = g(), N = t ?? j, [P, F] = g(), I = m(() => F(void 0), []), [L, R] = g(!1), z = m(() => R(!0), []), [B, V] = g(), H = h(!1), [U, te] = g(0), W = m(() => te((e) => e + 1), []), G = r(), K = i(), q = o(), J = n(), Y = s(), X = a(), Z = m(() => _.isTotalsDirty ? f(_.discount, _.tax, _.totalOverride, A) : void 0, [_, A]), Q = m(() => {
|
|
54
|
+
let t = p(_.lineItems, A), n = Z();
|
|
55
|
+
return _.setLineItemErrors(t), _.setTotalsErrors(n), !t && !n || (_.setErrors(void 0), t && e.error(A.lineItemsNeedAttention), W(), !1);
|
|
185
56
|
}, [
|
|
186
|
-
|
|
187
|
-
|
|
57
|
+
_,
|
|
58
|
+
A,
|
|
188
59
|
W,
|
|
189
|
-
|
|
190
|
-
]),
|
|
191
|
-
let t =
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
60
|
+
Z
|
|
61
|
+
]), $ = m(async (e) => {
|
|
62
|
+
let t = !N && P ? {
|
|
63
|
+
base64EncodedFile: await ee(P),
|
|
64
|
+
fileName: P.name
|
|
65
|
+
} : void 0, n = l({
|
|
66
|
+
values: _.values,
|
|
67
|
+
counterpartId: v,
|
|
68
|
+
clearCounterpart: y,
|
|
69
|
+
counterpartBankAccountId: e,
|
|
70
|
+
editedTotals: _.isTotalsDirty ? {
|
|
71
|
+
discount: _.discount,
|
|
72
|
+
tax: _.tax,
|
|
73
|
+
total: _.totalOverride
|
|
74
|
+
} : void 0,
|
|
75
|
+
document: t
|
|
76
|
+
}), r = N;
|
|
77
|
+
if (r ? await q.mutateAsync({
|
|
78
|
+
path: { payable_id: r },
|
|
79
|
+
body: n
|
|
80
|
+
}) : (r = (await G.mutateAsync({ body: n }))?.id, r && (M(r), T?.(r), t && F(void 0))), !r) throw Error("Payable was created without an id");
|
|
81
|
+
if (L) {
|
|
82
|
+
try {
|
|
83
|
+
await K.mutateAsync({ path: { payable_id: r } });
|
|
84
|
+
} catch {}
|
|
85
|
+
R(!1);
|
|
195
86
|
}
|
|
196
|
-
|
|
87
|
+
return await J.mutateAsync({
|
|
88
|
+
path: { payable_id: r },
|
|
89
|
+
body: { data: u(_.lineItems) }
|
|
90
|
+
}), r;
|
|
197
91
|
}, [
|
|
198
|
-
|
|
199
|
-
i,
|
|
200
|
-
W,
|
|
201
|
-
U
|
|
202
|
-
]), oe = u(() => y.map((e) => ({
|
|
203
|
-
...e,
|
|
204
|
-
onChange: (t) => Y(e.id, t),
|
|
205
|
-
onQuantityStep: (t) => X(e.id, t),
|
|
206
|
-
onRemove: () => Q(e.id)
|
|
207
|
-
})), [
|
|
208
|
-
y,
|
|
209
|
-
Y,
|
|
210
|
-
Q,
|
|
211
|
-
X
|
|
212
|
-
]), se = u(() => t(y, C, x), [
|
|
92
|
+
v,
|
|
213
93
|
y,
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
94
|
+
G,
|
|
95
|
+
K,
|
|
96
|
+
L,
|
|
97
|
+
_.discount,
|
|
98
|
+
_.isTotalsDirty,
|
|
99
|
+
_.lineItems,
|
|
100
|
+
_.tax,
|
|
101
|
+
_.totalOverride,
|
|
102
|
+
_.values,
|
|
103
|
+
T,
|
|
104
|
+
N,
|
|
105
|
+
J,
|
|
106
|
+
P,
|
|
107
|
+
q
|
|
108
|
+
]), ne = m(async () => {
|
|
109
|
+
N && (await K.mutateAsync({ path: { payable_id: N } }), R(!1));
|
|
110
|
+
}, [K, N]);
|
|
217
111
|
return {
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
112
|
+
saveDraft: m(async () => {
|
|
113
|
+
if (!H.current && Q()) {
|
|
114
|
+
H.current = !0, V("draft");
|
|
115
|
+
try {
|
|
116
|
+
let t = await C?.();
|
|
117
|
+
if (t && !t.ok) return;
|
|
118
|
+
let n = await $(t?.counterpartBankAccountId);
|
|
119
|
+
_.setErrors(void 0), w?.(n), D?.(n);
|
|
120
|
+
let r = await E?.();
|
|
121
|
+
return e.success(r === "draft" ? A.submittedDemoted : A.draftSaved), n;
|
|
122
|
+
} catch (e) {
|
|
123
|
+
_.setSaveFailureMessage(b(e) ? A.discountTaxBlockedByLineItems : A.saveFailed), W();
|
|
124
|
+
return;
|
|
125
|
+
} finally {
|
|
126
|
+
V(void 0), H.current = !1;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
}, [
|
|
130
|
+
_,
|
|
131
|
+
Q,
|
|
132
|
+
A.discountTaxBlockedByLineItems,
|
|
133
|
+
A.draftSaved,
|
|
134
|
+
A.saveFailed,
|
|
135
|
+
A.submittedDemoted,
|
|
136
|
+
D,
|
|
137
|
+
w,
|
|
138
|
+
E,
|
|
139
|
+
C,
|
|
140
|
+
$,
|
|
141
|
+
W
|
|
142
|
+
]),
|
|
143
|
+
finalize: m(async () => {
|
|
144
|
+
if (H.current) return;
|
|
145
|
+
let t = p(_.lineItems, A), n = Z(), { formErrors: r, lineItemErrors: i } = d(_.values, v, _.lineItems, A), a = S(i, t);
|
|
146
|
+
_.setLineItemErrors(a), _.setTotalsErrors(n);
|
|
147
|
+
let o = r ?? {};
|
|
148
|
+
if (_.setErrors(Object.keys(o).length ? o : void 0), t && e.error(A.lineItemsNeedAttention), a || n || Object.keys(o).length) {
|
|
149
|
+
W();
|
|
150
|
+
return;
|
|
151
|
+
}
|
|
152
|
+
H.current = !0, V("finalize");
|
|
153
|
+
try {
|
|
154
|
+
let t;
|
|
155
|
+
try {
|
|
156
|
+
let e = await C?.();
|
|
157
|
+
if (e && !e.ok) return;
|
|
158
|
+
t = await $(e?.counterpartBankAccountId);
|
|
159
|
+
} catch (e) {
|
|
160
|
+
_.setSaveFailureMessage(b(e) ? A.discountTaxBlockedByLineItems : A.saveFailed), W();
|
|
161
|
+
return;
|
|
162
|
+
}
|
|
163
|
+
w?.(t);
|
|
164
|
+
try {
|
|
165
|
+
let n = await Y.mutateAsync({ path: { payable_id: t } });
|
|
166
|
+
if (n.validation_errors.length) {
|
|
167
|
+
let e = x(n.validation_errors, A);
|
|
168
|
+
_.setErrors(e.formErrors), _.setTotalsErrors(e.totalsErrors), W();
|
|
169
|
+
return;
|
|
170
|
+
}
|
|
171
|
+
await X.mutateAsync({ path: { payable_id: t } }), _.setErrors(void 0), O?.(t), e.success(A.billFinalized);
|
|
172
|
+
} catch {
|
|
173
|
+
_.setSaveFailureMessage(A.finalizeFailed), W();
|
|
174
|
+
}
|
|
175
|
+
} finally {
|
|
176
|
+
V(void 0), H.current = !1;
|
|
177
|
+
}
|
|
178
|
+
}, [
|
|
179
|
+
v,
|
|
180
|
+
_,
|
|
181
|
+
A,
|
|
182
|
+
O,
|
|
183
|
+
w,
|
|
184
|
+
C,
|
|
185
|
+
$,
|
|
186
|
+
W,
|
|
187
|
+
X,
|
|
188
|
+
Z,
|
|
189
|
+
Y
|
|
190
|
+
]),
|
|
191
|
+
payableId: N,
|
|
192
|
+
isSavingDraft: B === "draft",
|
|
193
|
+
isFinalizing: B === "finalize",
|
|
194
|
+
stagedFile: P,
|
|
195
|
+
stageFile: F,
|
|
196
|
+
clearStagedFile: I,
|
|
197
|
+
scrollToErrorToken: U,
|
|
198
|
+
isFileDeletionPending: L,
|
|
199
|
+
requestFileDeletion: z,
|
|
200
|
+
detachFileNow: ne,
|
|
201
|
+
isDeletingFile: K.isPending,
|
|
202
|
+
hasFileDeletionFailed: K.isError
|
|
239
203
|
};
|
|
240
204
|
}
|
|
241
205
|
//#endregion
|
|
242
|
-
export {
|
|
206
|
+
export { x as mapValidationErrorsToForm, C as useBillCreateController };
|
|
@@ -1,21 +1,39 @@
|
|
|
1
|
+
import { resolveLineItemAmountMinorUnits as e } from "./index41.js";
|
|
1
2
|
//#region ../../libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index58.js
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
3
|
+
function t() {
|
|
4
|
+
return {
|
|
5
|
+
id: crypto.randomUUID(),
|
|
6
|
+
description: "",
|
|
7
|
+
glCode: "",
|
|
8
|
+
quantity: "1",
|
|
9
|
+
price: "",
|
|
10
|
+
amount: ""
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
function n(e) {
|
|
14
|
+
return typeof e == "number" ? (e / 100).toFixed(2) : "";
|
|
15
|
+
}
|
|
16
|
+
function r({ payable: r, lineItems: i }) {
|
|
17
|
+
let a = {
|
|
18
|
+
invoiceNumber: r.document_id ?? "",
|
|
19
|
+
invoiceDate: r.issued_at ?? "",
|
|
20
|
+
dueDate: r.due_date ?? "",
|
|
21
|
+
poNumber: ""
|
|
22
|
+
}, o = i.map((t) => ({
|
|
23
|
+
id: t.id,
|
|
24
|
+
description: t.name ?? "",
|
|
25
|
+
glCode: t.ledger_account_id ?? "",
|
|
26
|
+
quantity: t.quantity == null ? "" : String(t.quantity),
|
|
27
|
+
price: n(t.unit_price),
|
|
28
|
+
amount: n(e(t))
|
|
29
|
+
})), s = r.amount_due ?? (r.total_amount == null ? void 0 : r.total_amount - (r.discount ?? 0));
|
|
30
|
+
return {
|
|
31
|
+
values: a,
|
|
32
|
+
lineItems: o.length ? o : [t()],
|
|
33
|
+
discount: n(r.discount),
|
|
34
|
+
tax: n(r.tax_amount),
|
|
35
|
+
total: s ? n(s) : ""
|
|
36
|
+
};
|
|
37
|
+
}
|
|
20
38
|
//#endregion
|
|
21
|
-
export {
|
|
39
|
+
export { t as emptyLineItem, r as mapPayableToBillForm };
|