@tesouro/embedded-components-react 0.3.45 → 0.3.47
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 +9 -9
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index22.js +42 -39
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index24.js +4 -41
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index25.js +40 -55
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index26.js +56 -5
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index27.js +5 -73
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index28.js +72 -48
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index29.js +47 -91
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index30.js +91 -33
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index31.js +33 -160
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index32.js +163 -75
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index33.js +75 -21
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index34.js +23 -210
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index35.js +198 -202
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index36.js +197 -88
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index37.js +105 -13
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index38.js +12 -46
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index39.js +47 -30
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index40.js +26 -182
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index41.js +187 -31
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index42.js +32 -98
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index43.js +102 -16
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index44.js +16 -301
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index45.js +322 -4
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index46.js +4 -33
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index47.js +31 -83
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index48.js +77 -159
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index49.js +167 -3
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index50.js +3 -4
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index51.js +2 -44
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index52.js +46 -1
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index53.js +1 -8
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index54.js +6 -9
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index55.js +9 -92
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index56.js +94 -3
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index57.js +3 -9
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index58.js +7 -20
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index59.js +14 -51
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index60.js +59 -3
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index61.js +3 -128
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index62.js +125 -8
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index63.js +8 -43
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index64.js +41 -18
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index65.js +20 -28
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index66.js +27 -82
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index67.js +83 -47
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index68.js +47 -250
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index69.js +240 -101
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index70.js +107 -204
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index71.js +211 -3
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index72.js +4 -8
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index73.js +6 -113
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index74.js +115 -1
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index75.js +0 -24
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index76.js +25 -0
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index44.js +28 -27
- 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
|
@@ -1,190 +1,34 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
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/index8.js";
|
|
8
|
-
import { useCreatePayableMutation as n, useDeletePayableFileMutation as r, useSubmitPayableForApprovalMutation as i, useUpdatePayableMutation as a, useValidatePayableMutation as o } from "../../data-access/dist/index11.js";
|
|
9
|
-
import "../../data-access/dist/index.js";
|
|
10
|
-
import { BILL_CREATE_MESSAGE_LABELS_EN as s } from "./index31.js";
|
|
11
|
-
import { encodeFileToBase64 as c } from "./index37.js";
|
|
12
|
-
import { mapBillFormToPayload as l, mapLineItemsToPayload as u } from "./index38.js";
|
|
13
|
-
import { validateBillCompleteness as d, validateBillTotals as f, validateLineItems as p } from "./index39.js";
|
|
14
|
-
import { useCallback as m, useRef as h, useState as g } from "react";
|
|
1
|
+
import { BILL_CREATE_MESSAGE_LABELS_EN as e } from "./index32.js";
|
|
2
|
+
import { isPersistableLineItem as t, parseMoneyToMinorUnits as n, parseQuantity as r } from "./index39.js";
|
|
15
3
|
//#region ../../libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index40.js
|
|
16
|
-
var
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
counterpart_id: "vendor"
|
|
21
|
-
};
|
|
22
|
-
function v(e) {
|
|
23
|
-
return e.type === "type_error.none.not_allowed" || e.msg === "none is not an allowed value";
|
|
4
|
+
var i = /^(?:\d{1,3}(?:,\d{3})+(?:\.\d+)?|\d+(?:\.\d+)?|\.\d+)$/;
|
|
5
|
+
function a(e) {
|
|
6
|
+
let t = e.trim();
|
|
7
|
+
return !t || n(t) !== null ? !0 : i.test(t) ? Number(t.replaceAll(",", "")) === 0 : !1;
|
|
24
8
|
}
|
|
25
|
-
function
|
|
26
|
-
let
|
|
27
|
-
for (let
|
|
28
|
-
let
|
|
29
|
-
|
|
9
|
+
function o(t, i = e) {
|
|
10
|
+
let a = {};
|
|
11
|
+
for (let e of t) {
|
|
12
|
+
let t = n(e.price), o = n(e.amount), s = {};
|
|
13
|
+
e.price.trim() && t === null && (s.price = i.unreadableMoney), e.amount.trim() && o === null && (s.amount = i.unreadableMoney), (t !== null || o !== null) && r(e.quantity) === null && (s.quantity = i.unusableQuantity), Object.keys(s).length && (a[e.id] = s);
|
|
30
14
|
}
|
|
31
|
-
return
|
|
15
|
+
return Object.keys(a).length ? a : void 0;
|
|
32
16
|
}
|
|
33
|
-
function
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
17
|
+
function s(i, a, o, s = e) {
|
|
18
|
+
let c = {};
|
|
19
|
+
a || (c.vendor = s.requiredField), i.invoiceNumber.trim() || (c.invoiceNumber = s.requiredField), i.invoiceDate.trim() || (c.invoiceDate = s.requiredField), i.dueDate.trim() || (c.dueDate = s.requiredField);
|
|
20
|
+
let l = {};
|
|
21
|
+
return o.forEach((e, i) => {
|
|
22
|
+
if (i > 0 && !t(e)) return;
|
|
23
|
+
let a = {};
|
|
24
|
+
e.description.trim() || (a.description = s.requiredField), r(e.quantity) === null && (a.quantity = s.requiredField), n(e.price) === null && n(e.amount) === null && (a.price = s.requiredField, a.amount = s.requiredField), Object.keys(a).length && (l[e.id] = a);
|
|
25
|
+
}), {
|
|
26
|
+
formErrors: Object.keys(c).length ? c : void 0,
|
|
27
|
+
lineItemErrors: Object.keys(l).length ? l : void 0
|
|
39
28
|
};
|
|
40
|
-
return n;
|
|
41
29
|
}
|
|
42
|
-
function
|
|
43
|
-
|
|
44
|
-
...s,
|
|
45
|
-
...O
|
|
46
|
-
}, [A, j] = g(), M = _ ?? A, [N, P] = g(), F = m(() => P(void 0), []), [I, L] = g(!1), R = m(() => L(!0), []), [z, B] = g(), V = h(!1), H = n(), U = r(), W = a(), G = t(), K = o(), q = i(), J = m(() => v.isTotalsDirty ? f(v.discount, v.tax, v.totalOverride, k) : void 0, [v, k]), Y = m(() => {
|
|
47
|
-
let t = p(v.lineItems, k), n = J();
|
|
48
|
-
return v.setLineItemErrors(t), !t && !n || (t ? (v.setErrors(void 0), e.error(k.lineItemsNeedAttention)) : v.setErrors(n), !1);
|
|
49
|
-
}, [
|
|
50
|
-
v,
|
|
51
|
-
k,
|
|
52
|
-
J
|
|
53
|
-
]), X = m(async (e) => {
|
|
54
|
-
let t = !M && N ? {
|
|
55
|
-
base64EncodedFile: await c(N),
|
|
56
|
-
fileName: N.name
|
|
57
|
-
} : void 0, n = l({
|
|
58
|
-
values: v.values,
|
|
59
|
-
counterpartId: x,
|
|
60
|
-
clearCounterpart: S,
|
|
61
|
-
counterpartBankAccountId: e,
|
|
62
|
-
editedTotals: v.isTotalsDirty ? {
|
|
63
|
-
discount: v.discount,
|
|
64
|
-
tax: v.tax,
|
|
65
|
-
total: v.totalOverride
|
|
66
|
-
} : void 0,
|
|
67
|
-
document: t
|
|
68
|
-
}), r = M;
|
|
69
|
-
if (r ? await W.mutateAsync({
|
|
70
|
-
path: { payable_id: r },
|
|
71
|
-
body: n
|
|
72
|
-
}) : (r = (await H.mutateAsync({ body: n }))?.id, r && (j(r), T?.(r), t && P(void 0))), !r) throw Error("Payable was created without an id");
|
|
73
|
-
if (I) {
|
|
74
|
-
try {
|
|
75
|
-
await U.mutateAsync({ path: { payable_id: r } });
|
|
76
|
-
} catch {}
|
|
77
|
-
L(!1);
|
|
78
|
-
}
|
|
79
|
-
return await G.mutateAsync({
|
|
80
|
-
path: { payable_id: r },
|
|
81
|
-
body: { data: u(v.lineItems) }
|
|
82
|
-
}), r;
|
|
83
|
-
}, [
|
|
84
|
-
x,
|
|
85
|
-
S,
|
|
86
|
-
H,
|
|
87
|
-
U,
|
|
88
|
-
I,
|
|
89
|
-
v.discount,
|
|
90
|
-
v.isTotalsDirty,
|
|
91
|
-
v.lineItems,
|
|
92
|
-
v.tax,
|
|
93
|
-
v.totalOverride,
|
|
94
|
-
v.values,
|
|
95
|
-
T,
|
|
96
|
-
M,
|
|
97
|
-
G,
|
|
98
|
-
N,
|
|
99
|
-
W
|
|
100
|
-
]), Z = m(async () => {
|
|
101
|
-
M && (await U.mutateAsync({ path: { payable_id: M } }), L(!1));
|
|
102
|
-
}, [U, M]);
|
|
103
|
-
return {
|
|
104
|
-
saveDraft: m(async () => {
|
|
105
|
-
if (!V.current && Y()) {
|
|
106
|
-
V.current = !0, B("draft");
|
|
107
|
-
try {
|
|
108
|
-
let t = await C?.();
|
|
109
|
-
if (t && !t.ok) return;
|
|
110
|
-
let n = await X(t?.counterpartBankAccountId);
|
|
111
|
-
return v.setErrors(void 0), w?.(n), E?.(n), e.success(k.draftSaved), n;
|
|
112
|
-
} catch {
|
|
113
|
-
v.setErrors({ form: k.saveFailed });
|
|
114
|
-
return;
|
|
115
|
-
} finally {
|
|
116
|
-
B(void 0), V.current = !1;
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
}, [
|
|
120
|
-
v,
|
|
121
|
-
Y,
|
|
122
|
-
k.draftSaved,
|
|
123
|
-
k.saveFailed,
|
|
124
|
-
E,
|
|
125
|
-
w,
|
|
126
|
-
C,
|
|
127
|
-
X
|
|
128
|
-
]),
|
|
129
|
-
finalize: m(async () => {
|
|
130
|
-
if (V.current) return;
|
|
131
|
-
let t = p(v.lineItems, k), n = J(), { formErrors: r, lineItemErrors: i } = d(v.values, x, v.lineItems, k), a = b(i, t);
|
|
132
|
-
v.setLineItemErrors(a);
|
|
133
|
-
let o = {
|
|
134
|
-
...r,
|
|
135
|
-
...n
|
|
136
|
-
};
|
|
137
|
-
if (v.setErrors(Object.keys(o).length ? o : void 0), t && e.error(k.lineItemsNeedAttention), !(a || Object.keys(o).length)) {
|
|
138
|
-
V.current = !0, B("finalize");
|
|
139
|
-
try {
|
|
140
|
-
let t;
|
|
141
|
-
try {
|
|
142
|
-
let e = await C?.();
|
|
143
|
-
if (e && !e.ok) return;
|
|
144
|
-
t = await X(e?.counterpartBankAccountId);
|
|
145
|
-
} catch {
|
|
146
|
-
v.setErrors({ form: k.saveFailed });
|
|
147
|
-
return;
|
|
148
|
-
}
|
|
149
|
-
w?.(t);
|
|
150
|
-
try {
|
|
151
|
-
let n = await K.mutateAsync({ path: { payable_id: t } });
|
|
152
|
-
if (n.validation_errors.length) {
|
|
153
|
-
v.setErrors(y(n.validation_errors, k));
|
|
154
|
-
return;
|
|
155
|
-
}
|
|
156
|
-
await q.mutateAsync({ path: { payable_id: t } }), v.setErrors(void 0), D?.(t), e.success(k.billFinalized);
|
|
157
|
-
} catch {
|
|
158
|
-
v.setErrors({ form: k.finalizeFailed });
|
|
159
|
-
}
|
|
160
|
-
} finally {
|
|
161
|
-
B(void 0), V.current = !1;
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
}, [
|
|
165
|
-
x,
|
|
166
|
-
v,
|
|
167
|
-
k,
|
|
168
|
-
D,
|
|
169
|
-
w,
|
|
170
|
-
C,
|
|
171
|
-
X,
|
|
172
|
-
q,
|
|
173
|
-
J,
|
|
174
|
-
K
|
|
175
|
-
]),
|
|
176
|
-
payableId: M,
|
|
177
|
-
isSavingDraft: z === "draft",
|
|
178
|
-
isFinalizing: z === "finalize",
|
|
179
|
-
stagedFile: N,
|
|
180
|
-
stageFile: P,
|
|
181
|
-
clearStagedFile: F,
|
|
182
|
-
isFileDeletionPending: I,
|
|
183
|
-
requestFileDeletion: R,
|
|
184
|
-
detachFileNow: Z,
|
|
185
|
-
isDeletingFile: U.isPending,
|
|
186
|
-
hasFileDeletionFailed: U.isError
|
|
187
|
-
};
|
|
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;
|
|
188
32
|
}
|
|
189
33
|
//#endregion
|
|
190
|
-
export {
|
|
34
|
+
export { s as validateBillCompleteness, c as validateBillTotals, o as validateLineItems };
|
|
@@ -1,38 +1,194 @@
|
|
|
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/index8.js";
|
|
8
|
+
import { useCreatePayableMutation as n, useDeletePayableFileMutation as r, useSubmitPayableForApprovalMutation as i, useUpdatePayableMutation as a, useValidatePayableMutation as o } from "../../data-access/dist/index11.js";
|
|
9
|
+
import "../../data-access/dist/index.js";
|
|
10
|
+
import { BILL_CREATE_MESSAGE_LABELS_EN as s } from "./index32.js";
|
|
11
|
+
import { encodeFileToBase64 as c } from "./index38.js";
|
|
12
|
+
import { mapBillFormToPayload as l, mapLineItemsToPayload as u } from "./index39.js";
|
|
13
|
+
import { validateBillCompleteness as d, validateBillTotals as f, validateLineItems as p } from "./index40.js";
|
|
14
|
+
import { useCallback as m, useRef as h, useState as g } from "react";
|
|
1
15
|
//#region ../../libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index41.js
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
};
|
|
16
|
+
var _ = {
|
|
17
|
+
document_id: "invoiceNumber",
|
|
18
|
+
issued_at: "invoiceDate",
|
|
19
|
+
due_date: "dueDate",
|
|
20
|
+
counterpart_id: "vendor"
|
|
21
|
+
};
|
|
22
|
+
function v(e) {
|
|
23
|
+
return e.type === "type_error.none.not_allowed" || e.msg === "none is not an allowed value";
|
|
11
24
|
}
|
|
12
|
-
function
|
|
13
|
-
|
|
25
|
+
function y(e, t = s) {
|
|
26
|
+
let n = {}, r = [];
|
|
27
|
+
for (let i of e) {
|
|
28
|
+
let e = i.loc[0] ?? t.unknownValidationField, a = _[e], o = v(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 b(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;
|
|
14
41
|
}
|
|
15
|
-
function
|
|
16
|
-
let
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
42
|
+
function x({ payableId: _, form: v, counterpartId: x, clearCounterpart: S, prepareVendorForSave: C, onSaved: w, onPayableCreated: T, readSavedStatus: E, onDraftSaved: D, onFinalized: O, labels: k }) {
|
|
43
|
+
let A = {
|
|
44
|
+
...s,
|
|
45
|
+
...k
|
|
46
|
+
}, [j, M] = g(), N = _ ?? j, [P, F] = g(), I = m(() => F(void 0), []), [L, R] = g(!1), z = m(() => R(!0), []), [B, V] = g(), H = h(!1), U = n(), W = r(), G = a(), K = t(), q = o(), J = i(), Y = m(() => v.isTotalsDirty ? f(v.discount, v.tax, v.totalOverride, A) : void 0, [v, A]), X = m(() => {
|
|
47
|
+
let t = p(v.lineItems, A), n = Y();
|
|
48
|
+
return v.setLineItemErrors(t), !t && !n || (t ? (v.setErrors(void 0), e.error(A.lineItemsNeedAttention)) : v.setErrors(n), !1);
|
|
49
|
+
}, [
|
|
50
|
+
v,
|
|
51
|
+
A,
|
|
52
|
+
Y
|
|
53
|
+
]), Z = m(async (e) => {
|
|
54
|
+
let t = !N && P ? {
|
|
55
|
+
base64EncodedFile: await c(P),
|
|
56
|
+
fileName: P.name
|
|
57
|
+
} : void 0, n = l({
|
|
58
|
+
values: v.values,
|
|
59
|
+
counterpartId: x,
|
|
60
|
+
clearCounterpart: S,
|
|
61
|
+
counterpartBankAccountId: e,
|
|
62
|
+
editedTotals: v.isTotalsDirty ? {
|
|
63
|
+
discount: v.discount,
|
|
64
|
+
tax: v.tax,
|
|
65
|
+
total: v.totalOverride
|
|
66
|
+
} : void 0,
|
|
67
|
+
document: t
|
|
68
|
+
}), r = N;
|
|
69
|
+
if (r ? await G.mutateAsync({
|
|
70
|
+
path: { payable_id: r },
|
|
71
|
+
body: n
|
|
72
|
+
}) : (r = (await U.mutateAsync({ body: n }))?.id, r && (M(r), T?.(r), t && F(void 0))), !r) throw Error("Payable was created without an id");
|
|
73
|
+
if (L) {
|
|
74
|
+
try {
|
|
75
|
+
await W.mutateAsync({ path: { payable_id: r } });
|
|
76
|
+
} catch {}
|
|
77
|
+
R(!1);
|
|
78
|
+
}
|
|
79
|
+
return await K.mutateAsync({
|
|
80
|
+
path: { payable_id: r },
|
|
81
|
+
body: { data: u(v.lineItems) }
|
|
82
|
+
}), r;
|
|
83
|
+
}, [
|
|
84
|
+
x,
|
|
85
|
+
S,
|
|
86
|
+
U,
|
|
87
|
+
W,
|
|
88
|
+
L,
|
|
89
|
+
v.discount,
|
|
90
|
+
v.isTotalsDirty,
|
|
91
|
+
v.lineItems,
|
|
92
|
+
v.tax,
|
|
93
|
+
v.totalOverride,
|
|
94
|
+
v.values,
|
|
95
|
+
T,
|
|
96
|
+
N,
|
|
97
|
+
K,
|
|
98
|
+
P,
|
|
99
|
+
G
|
|
100
|
+
]), Q = m(async () => {
|
|
101
|
+
N && (await W.mutateAsync({ path: { payable_id: N } }), R(!1));
|
|
102
|
+
}, [W, N]);
|
|
29
103
|
return {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
104
|
+
saveDraft: m(async () => {
|
|
105
|
+
if (!H.current && X()) {
|
|
106
|
+
H.current = !0, V("draft");
|
|
107
|
+
try {
|
|
108
|
+
let t = await C?.();
|
|
109
|
+
if (t && !t.ok) return;
|
|
110
|
+
let n = await Z(t?.counterpartBankAccountId);
|
|
111
|
+
v.setErrors(void 0), w?.(n), D?.(n);
|
|
112
|
+
let r = await E?.();
|
|
113
|
+
return e.success(r === "draft" ? A.submittedDemoted : A.draftSaved), n;
|
|
114
|
+
} catch {
|
|
115
|
+
v.setErrors({ form: A.saveFailed });
|
|
116
|
+
return;
|
|
117
|
+
} finally {
|
|
118
|
+
V(void 0), H.current = !1;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
}, [
|
|
122
|
+
v,
|
|
123
|
+
X,
|
|
124
|
+
A.draftSaved,
|
|
125
|
+
A.saveFailed,
|
|
126
|
+
A.submittedDemoted,
|
|
127
|
+
D,
|
|
128
|
+
w,
|
|
129
|
+
E,
|
|
130
|
+
C,
|
|
131
|
+
Z
|
|
132
|
+
]),
|
|
133
|
+
finalize: m(async () => {
|
|
134
|
+
if (H.current) return;
|
|
135
|
+
let t = p(v.lineItems, A), n = Y(), { formErrors: r, lineItemErrors: i } = d(v.values, x, v.lineItems, A), a = b(i, t);
|
|
136
|
+
v.setLineItemErrors(a);
|
|
137
|
+
let o = {
|
|
138
|
+
...r,
|
|
139
|
+
...n
|
|
140
|
+
};
|
|
141
|
+
if (v.setErrors(Object.keys(o).length ? o : void 0), t && e.error(A.lineItemsNeedAttention), !(a || Object.keys(o).length)) {
|
|
142
|
+
H.current = !0, V("finalize");
|
|
143
|
+
try {
|
|
144
|
+
let t;
|
|
145
|
+
try {
|
|
146
|
+
let e = await C?.();
|
|
147
|
+
if (e && !e.ok) return;
|
|
148
|
+
t = await Z(e?.counterpartBankAccountId);
|
|
149
|
+
} catch {
|
|
150
|
+
v.setErrors({ form: A.saveFailed });
|
|
151
|
+
return;
|
|
152
|
+
}
|
|
153
|
+
w?.(t);
|
|
154
|
+
try {
|
|
155
|
+
let n = await q.mutateAsync({ path: { payable_id: t } });
|
|
156
|
+
if (n.validation_errors.length) {
|
|
157
|
+
v.setErrors(y(n.validation_errors, A));
|
|
158
|
+
return;
|
|
159
|
+
}
|
|
160
|
+
await J.mutateAsync({ path: { payable_id: t } }), v.setErrors(void 0), O?.(t), e.success(A.billFinalized);
|
|
161
|
+
} catch {
|
|
162
|
+
v.setErrors({ form: A.finalizeFailed });
|
|
163
|
+
}
|
|
164
|
+
} finally {
|
|
165
|
+
V(void 0), H.current = !1;
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
}, [
|
|
169
|
+
x,
|
|
170
|
+
v,
|
|
171
|
+
A,
|
|
172
|
+
O,
|
|
173
|
+
w,
|
|
174
|
+
C,
|
|
175
|
+
Z,
|
|
176
|
+
J,
|
|
177
|
+
Y,
|
|
178
|
+
q
|
|
179
|
+
]),
|
|
180
|
+
payableId: N,
|
|
181
|
+
isSavingDraft: B === "draft",
|
|
182
|
+
isFinalizing: B === "finalize",
|
|
183
|
+
stagedFile: P,
|
|
184
|
+
stageFile: F,
|
|
185
|
+
clearStagedFile: I,
|
|
186
|
+
isFileDeletionPending: L,
|
|
187
|
+
requestFileDeletion: z,
|
|
188
|
+
detachFileNow: Q,
|
|
189
|
+
isDeletingFile: W.isPending,
|
|
190
|
+
hasFileDeletionFailed: W.isError
|
|
35
191
|
};
|
|
36
192
|
}
|
|
37
193
|
//#endregion
|
|
38
|
-
export {
|
|
194
|
+
export { y as mapValidationErrorsToForm, x as useBillCreateController };
|
|
@@ -1,104 +1,38 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
"use client";
|
|
3
|
-
"use client";
|
|
4
|
-
"use client";
|
|
5
|
-
import { calculateTotal as e, displayLineAmount as t, parseMoneyToMinorUnits as n } from "./index38.js";
|
|
6
|
-
import { emptyLineItem as r, mapPayableToBillForm as i } from "./index41.js";
|
|
7
|
-
import { useCallback as a, useEffect as o, useMemo as s, useState as c } from "react";
|
|
8
1
|
//#region ../../libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index42.js
|
|
9
|
-
function
|
|
10
|
-
return
|
|
2
|
+
function e() {
|
|
3
|
+
return {
|
|
4
|
+
id: crypto.randomUUID(),
|
|
5
|
+
description: "",
|
|
6
|
+
glCode: "",
|
|
7
|
+
quantity: "1",
|
|
8
|
+
price: "",
|
|
9
|
+
amount: ""
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
function t(e) {
|
|
13
|
+
return typeof e == "number" ? (e / 100).toFixed(2) : "";
|
|
11
14
|
}
|
|
12
|
-
function
|
|
13
|
-
let
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
...t,
|
|
27
|
-
...e
|
|
28
|
-
})), E(!0);
|
|
29
|
-
}, []), M = a((e) => {
|
|
30
|
-
w((t) => {
|
|
31
|
-
if (!t?.[e]) return t;
|
|
32
|
-
let n = { ...t };
|
|
33
|
-
return delete n[e], Object.keys(n).length ? n : void 0;
|
|
34
|
-
});
|
|
35
|
-
}, []), N = a((e, t) => {
|
|
36
|
-
M(e), m((n) => n.map((n) => {
|
|
37
|
-
if (n.id !== e) return n;
|
|
38
|
-
let r = {
|
|
39
|
-
...n,
|
|
40
|
-
...t
|
|
41
|
-
};
|
|
42
|
-
return "amount" in t ? r : {
|
|
43
|
-
...r,
|
|
44
|
-
amount: l(r.quantity, r.price, r.amount)
|
|
45
|
-
};
|
|
46
|
-
})), O(!0), b(void 0);
|
|
47
|
-
}, [M]), P = a((e, t) => {
|
|
48
|
-
M(e), m((n) => n.map((n) => {
|
|
49
|
-
if (n.id !== e) return n;
|
|
50
|
-
let r = Number.parseFloat(n.quantity), i = String(Math.max(1, (Number.isFinite(r) ? r : 1) + t));
|
|
51
|
-
return {
|
|
52
|
-
...n,
|
|
53
|
-
quantity: i,
|
|
54
|
-
amount: l(i, n.price, n.amount)
|
|
55
|
-
};
|
|
56
|
-
})), O(!0), b(void 0);
|
|
57
|
-
}, [M]), F = a((e) => {
|
|
58
|
-
M(e), m((t) => t.length <= 1 ? t : t.filter((t) => t.id !== e)), O(!0), b(void 0);
|
|
59
|
-
}, [M]), I = a(() => {
|
|
60
|
-
m((e) => [...e, r()]), O(!0), b(void 0);
|
|
61
|
-
}, []), L = a((e) => {
|
|
62
|
-
g(e), A(!0), b(void 0);
|
|
63
|
-
}, []), R = a((e) => {
|
|
64
|
-
v(e), A(!0), b(void 0);
|
|
65
|
-
}, []), z = a((e) => {
|
|
66
|
-
b(e), A(!0);
|
|
67
|
-
}, []), B = s(() => p.map((e) => ({
|
|
68
|
-
...e,
|
|
69
|
-
onChange: (t) => N(e.id, t),
|
|
70
|
-
onQuantityStep: (t) => P(e.id, t),
|
|
71
|
-
onRemove: () => F(e.id)
|
|
72
|
-
})), [
|
|
73
|
-
p,
|
|
74
|
-
N,
|
|
75
|
-
F,
|
|
76
|
-
P
|
|
77
|
-
]), V = s(() => e(p, _, h), [
|
|
78
|
-
p,
|
|
79
|
-
_,
|
|
80
|
-
h
|
|
81
|
-
]);
|
|
15
|
+
function n({ payable: n, lineItems: r }) {
|
|
16
|
+
let i = {
|
|
17
|
+
invoiceNumber: n.document_id ?? "",
|
|
18
|
+
invoiceDate: n.issued_at ?? "",
|
|
19
|
+
dueDate: n.due_date ?? "",
|
|
20
|
+
poNumber: ""
|
|
21
|
+
}, a = r.map((e) => ({
|
|
22
|
+
id: e.id,
|
|
23
|
+
description: e.name ?? "",
|
|
24
|
+
glCode: e.ledger_account_id ?? "",
|
|
25
|
+
quantity: e.quantity == null ? "" : String(e.quantity),
|
|
26
|
+
price: t(e.unit_price),
|
|
27
|
+
amount: t(e.subtotal)
|
|
28
|
+
}));
|
|
82
29
|
return {
|
|
83
|
-
values:
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
onChange: j,
|
|
89
|
-
lineItems: p,
|
|
90
|
-
lineItemRows: B,
|
|
91
|
-
discount: h,
|
|
92
|
-
onDiscountChange: L,
|
|
93
|
-
tax: _,
|
|
94
|
-
onTaxChange: R,
|
|
95
|
-
total: y ?? V,
|
|
96
|
-
totalOverride: y,
|
|
97
|
-
onTotalChange: z,
|
|
98
|
-
onAddLineItem: I,
|
|
99
|
-
isTotalsDirty: k,
|
|
100
|
-
isDirty: T || D || k
|
|
30
|
+
values: i,
|
|
31
|
+
lineItems: a.length ? a : [e()],
|
|
32
|
+
discount: t(n.discount),
|
|
33
|
+
tax: t(n.tax_amount),
|
|
34
|
+
total: n.total_amount ? t(n.total_amount) : ""
|
|
101
35
|
};
|
|
102
36
|
}
|
|
103
37
|
//#endregion
|
|
104
|
-
export {
|
|
38
|
+
export { e as emptyLineItem, n as mapPayableToBillForm };
|