@tesouro/embedded-components-react 0.9.22 → 0.9.25
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.css +82 -55
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index.js +7 -7
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index10.js +14 -8
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index11.js +59 -7
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index12.js +10 -65
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index13.js +9 -10
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index14.js +7 -8
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index15.js +9 -7
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index16.js +29 -11
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index17.js +24 -24
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index18.js +14 -22
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index19.js +155 -14
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index20.js +13 -157
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index21.js +18 -12
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index22.js +32 -15
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index23.js +99 -39
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index24.js +69 -85
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index25.js +3 -85
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index26.js +57 -4
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index27.js +114 -57
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index28.js +190 -111
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index29.js +75 -187
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index3.js +35 -15
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index30.js +67 -75
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index31.js +111 -69
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index32.js +461 -108
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index33.js +102 -452
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index34.js +12 -116
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index35.js +85 -12
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index36.js +67 -73
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index37.js +231 -73
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index38.js +38 -232
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index39.js +245 -38
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index4.js +169 -38
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index40.js +21 -252
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index41.js +534 -23
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index42.js +4 -542
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index43.js +43 -4
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index44.js +236 -39
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index45.js +3 -240
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index46.js +6 -3
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index47.js +63 -4
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index48.js +1 -65
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index5.js +82 -225
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index6.js +45 -83
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index7.js +4 -47
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index8.js +13 -4
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index9.js +8 -13
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/ui/dist/index14.js +1 -1
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/ui/dist/index15.js +1 -1
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/ui/dist/index31.js +1 -1
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/ui/dist/index33.js +1 -1
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/ui/dist/index34.js +2 -2
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/ui/dist/index36.js +5 -5
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/ui/dist/index37.js +138 -155
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/ui/dist/index48.js +1 -1
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/ui/dist/index49.js +1 -1
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/ui/dist/index5.js +1 -1
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-upload/ui/dist/index3.js +2 -2
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bills-list/feature/dist/index16.js +48 -43
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bills-list/feature/dist/index17.js +219 -207
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bills-list/feature/dist/index4.js +13 -13
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bills-list/feature/dist/index6.js +5 -4
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bills-list/feature/dist/index7.js +6 -6
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bills-list/ui/dist/index18.js +1 -5
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bills-list/ui/dist/index2.js +1 -1
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bills-list/ui/dist/index20.js +278 -322
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bills-list/ui/dist/index3.js +1 -1
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/lib/BillPayWidget/BillPayWidget.js +1 -1
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/lib/BillPayWidget/BillsTab.js +1 -1
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/mocks/labels.js +1 -1
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/pay-bill/ui/dist/index5.js +1 -1
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/pay-bill/ui/dist/index6.js +1 -1
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index.js +18 -16
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index10.js +2 -41
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index11.js +4 -2
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index12.js +39 -9
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index13.js +2 -78
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index14.js +11 -0
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index15.js +78 -2
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index17.js +2 -4
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index18.js +25 -26
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index19.js +4 -2
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index20.js +28 -5
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index21.js +2 -34
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index22.js +7 -2
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index23.js +34 -0
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index24.js +2 -0
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index6.js +31 -15
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index7.js +1 -54
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index8.js +18 -2
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index9.js +52 -2
- package/dist/libs/tesouro-embedded-components-react/shared/feature/dist/lib/analytics/build-info.js +1 -1
- package/dist/libs/tesouro-embedded-components-react/shared/util/dist/lib/theme/themeTokens.js +1 -1
- package/dist/packages/shared-ui-shadcn/dist/index.js +4696 -4681
- package/package.json +1 -1
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index49.js +0 -1
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index16.js +0 -29
|
@@ -1,83 +1,241 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
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 { extractApiErrorMessage as t } from "../../../../shared/util/dist/lib/apiErrors.js";
|
|
7
|
+
import "../../../../shared/util/dist/index.js";
|
|
8
|
+
import "../../../../shared/ui/dist/index.js";
|
|
9
|
+
import { BILL_CREATE_MESSAGE_LABELS_EN as n } from "./index28.js";
|
|
10
|
+
import { encodeFileToBase64 as r } from "./index34.js";
|
|
11
|
+
import { mapBillFormToPayload as i, mapLineItemsToPayload as a, mapPayableAmountFieldsToPayload as o } from "./index35.js";
|
|
12
|
+
import { validateBillCompleteness as s, validateBillTotalIsPayable as c, validateBillTotals as l, validateBillValues as u, validateLineItems as d, validateStoredAmountDue as ee } from "./index36.js";
|
|
13
|
+
import { useReplacePayableLineItemsMutation as f } from "../../data-access/dist/index4.js";
|
|
14
|
+
import { useCreatePayableMutation as p } from "../../data-access/dist/index8.js";
|
|
15
|
+
import { useDeletePayableFileMutation as m } from "../../data-access/dist/index9.js";
|
|
16
|
+
import { useSubmitPayableForApprovalMutation as h } from "../../data-access/dist/index14.js";
|
|
17
|
+
import { useUpdatePayableMutation as g } from "../../data-access/dist/index15.js";
|
|
18
|
+
import { useValidatePayableMutation as te } from "../../data-access/dist/index16.js";
|
|
19
|
+
import "../../data-access/dist/index.js";
|
|
20
|
+
import { useCallback as _, useRef as ne, useState as v } from "react";
|
|
3
21
|
//#region ../../libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index37.js
|
|
4
|
-
var
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
22
|
+
var y = {
|
|
23
|
+
document_id: "invoiceNumber",
|
|
24
|
+
issued_at: "invoiceDate",
|
|
25
|
+
due_date: "dueDate",
|
|
26
|
+
counterpart_id: "vendor",
|
|
27
|
+
purchase_order_number: "poNumber"
|
|
28
|
+
}, b = { tax_amount: "tax" };
|
|
29
|
+
function x(e) {
|
|
30
|
+
return e.type === "type_error.none.not_allowed" || e.msg === "none is not an allowed value";
|
|
8
31
|
}
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
return
|
|
32
|
+
var re = "pending-vendor";
|
|
33
|
+
function S(e) {
|
|
34
|
+
return !!t(e)?.includes("line_items_enabled");
|
|
12
35
|
}
|
|
13
|
-
function
|
|
14
|
-
|
|
15
|
-
if (Number.isNaN(t.getTime())) return !1;
|
|
16
|
-
let n = new Date(u() + c * l);
|
|
17
|
-
return t < d() || t > n;
|
|
36
|
+
function ie(e) {
|
|
37
|
+
return !!t(e)?.includes("A vendor could not be linked or created for this payable");
|
|
18
38
|
}
|
|
19
|
-
function
|
|
20
|
-
let
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
}
|
|
25
|
-
function m(t, n = e) {
|
|
26
|
-
let r = {};
|
|
27
|
-
return t.poNumber.length > a && (r.poNumber = n.poNumberTooLong), Object.keys(r).length ? r : void 0;
|
|
28
|
-
}
|
|
29
|
-
function h(e) {
|
|
30
|
-
let t = e.trim();
|
|
31
|
-
return !t || n(t) !== null ? !0 : i.test(t) ? Number(t.replaceAll(",", "")) === 0 : !1;
|
|
32
|
-
}
|
|
33
|
-
function g(t, i = e) {
|
|
34
|
-
let a = {};
|
|
35
|
-
for (let e of t) {
|
|
36
|
-
let t = n(e.price), o = n(e.amount), s = {};
|
|
37
|
-
e.price.trim() && t === null && (s.price = i.unreadableMoney), e.amount.trim() && o === null && (s.amount = i.unreadableMoney), r(e.quantity) === null && (e.quantity.trim() || t !== null || o !== null) && (s.quantity = i.unusableQuantity), Object.keys(s).length && (a[e.id] = s);
|
|
39
|
+
function C(e, t = n) {
|
|
40
|
+
let r = {}, i = {}, a = [];
|
|
41
|
+
for (let n of e) {
|
|
42
|
+
let e = n.loc[0] ?? t.unknownValidationField, o = y[e], s = b[e], c = x(n) ? t.requiredField : n.msg;
|
|
43
|
+
o ? r[o] = c : s ? i[s] = c : a.push(t.unmappedValidationError(e, c));
|
|
38
44
|
}
|
|
39
|
-
return
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
let c = {};
|
|
43
|
-
a || (c.vendor = s.requiredField), i.invoiceNumber.trim() || (c.invoiceNumber = s.requiredField);
|
|
44
|
-
let l = i.invoiceDate.trim(), u = i.dueDate.trim();
|
|
45
|
-
l ? f(l) && (c.invoiceDate = s.implausibleInvoiceDate) : c.invoiceDate = s.requiredField, u ? p(u) ? c.dueDate = s.implausibleDueDate : l && u < l && (c.dueDate = s.dueBeforeInvoiceDate) : c.dueDate = s.requiredField;
|
|
46
|
-
let d = {};
|
|
47
|
-
return o.forEach((e, i) => {
|
|
48
|
-
if (i > 0 && !t(e)) return;
|
|
49
|
-
let a = {};
|
|
50
|
-
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 && (d[e.id] = a);
|
|
51
|
-
}), {
|
|
52
|
-
formErrors: Object.keys(c).length ? c : void 0,
|
|
53
|
-
lineItemErrors: Object.keys(d).length ? d : void 0
|
|
45
|
+
return a.length && (r.form = a.join(" ")), {
|
|
46
|
+
formErrors: r,
|
|
47
|
+
totalsErrors: Object.keys(i).length ? i : void 0
|
|
54
48
|
};
|
|
55
49
|
}
|
|
56
|
-
function
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
let
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
}
|
|
65
|
-
function b(t, n = e) {
|
|
66
|
-
let r = y(t, n);
|
|
67
|
-
return r ? { total: r } : void 0;
|
|
68
|
-
}
|
|
69
|
-
function x(t, r = e) {
|
|
70
|
-
if (t === void 0) return;
|
|
71
|
-
let i = n(t);
|
|
72
|
-
if (i !== null) return i > 0 ? void 0 : { total: r.totalNotGreaterThanZero };
|
|
50
|
+
function ae(e, t) {
|
|
51
|
+
if (!e && !t) return;
|
|
52
|
+
let n = {}, r = /* @__PURE__ */ new Set([...Object.keys(e ?? {}), ...Object.keys(t ?? {})]);
|
|
53
|
+
for (let i of r) n[i] = {
|
|
54
|
+
...e?.[i],
|
|
55
|
+
...t?.[i]
|
|
56
|
+
};
|
|
57
|
+
return n;
|
|
73
58
|
}
|
|
74
|
-
function
|
|
75
|
-
let
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
59
|
+
function w({ payableId: t, form: y, counterpartId: b, isVendorPending: x, onVendorIncomplete: w, clearCounterpart: T, prepareVendorForSave: E, onSaved: D, onPayableCreated: O, readSavedStatus: k, onDraftSaved: A, onFinalized: j, labels: M }) {
|
|
60
|
+
let N = {
|
|
61
|
+
...n,
|
|
62
|
+
...M
|
|
63
|
+
}, [P, F] = v(), I = t ?? P, [L, R] = v(), oe = _(() => R(void 0), []), [z, B] = v(!1), se = _(() => B(!0), []), [V, H] = v(), U = ne(!1), [ce, le] = v(0), W = _(() => le((e) => e + 1), []), G = p(), K = m(), q = g(), J = f(), Y = te(), X = h(), Z = _(() => y.isTotalsDirty ? l(y.discount, y.tax, y.totalOverride, N) : void 0, [y, N]), Q = _(() => {
|
|
64
|
+
let t = u(y.values, N), n = d(y.lineItems, N), r = Z();
|
|
65
|
+
return y.setErrors(t), y.setLineItemErrors(n), y.setTotalsErrors(r), !t && !n && !r || (n && e.error(N.lineItemsNeedAttention), W(), !1);
|
|
66
|
+
}, [
|
|
67
|
+
y,
|
|
68
|
+
N,
|
|
69
|
+
W,
|
|
70
|
+
Z
|
|
71
|
+
]), $ = _(async (e, t, n) => {
|
|
72
|
+
let s = !I && L ? {
|
|
73
|
+
base64EncodedFile: await r(L),
|
|
74
|
+
fileName: L.name
|
|
75
|
+
} : void 0, c = y.isTotalsDirty ? {
|
|
76
|
+
discount: y.discount,
|
|
77
|
+
tax: y.tax,
|
|
78
|
+
total: y.totalOverride
|
|
79
|
+
} : void 0, l = i({
|
|
80
|
+
values: y.values,
|
|
81
|
+
initialLineItems: I ? void 0 : y.lineItems,
|
|
82
|
+
counterpartId: t ?? b,
|
|
83
|
+
clearCounterpart: T,
|
|
84
|
+
counterpartBankAccountId: e,
|
|
85
|
+
currentTotals: {
|
|
86
|
+
discount: y.discount,
|
|
87
|
+
tax: y.tax,
|
|
88
|
+
total: y.totalOverride
|
|
89
|
+
},
|
|
90
|
+
lineItems: y.lineItems,
|
|
91
|
+
editedTotals: c,
|
|
92
|
+
document: s
|
|
93
|
+
}), u = n ? {
|
|
94
|
+
...l,
|
|
95
|
+
counterpart_raw_data: n
|
|
96
|
+
} : l, d = I;
|
|
97
|
+
if (d ? await q.mutateAsync({
|
|
98
|
+
path: { payable_id: d },
|
|
99
|
+
body: u
|
|
100
|
+
}) : (d = (await G.mutateAsync({ body: u }))?.id, d && (F(d), O?.(d), s && R(void 0))), !d) throw Error("Payable was created without an id");
|
|
101
|
+
if (z) {
|
|
102
|
+
try {
|
|
103
|
+
await K.mutateAsync({ path: { payable_id: d } });
|
|
104
|
+
} catch {}
|
|
105
|
+
B(!1);
|
|
106
|
+
}
|
|
107
|
+
return await J.mutateAsync({
|
|
108
|
+
path: { payable_id: d },
|
|
109
|
+
body: { data: a(y.lineItems) }
|
|
110
|
+
}), c && await q.mutateAsync({
|
|
111
|
+
path: { payable_id: d },
|
|
112
|
+
body: o({
|
|
113
|
+
lineItems: y.lineItems,
|
|
114
|
+
editedTotals: c
|
|
115
|
+
})
|
|
116
|
+
}), d;
|
|
117
|
+
}, [
|
|
118
|
+
b,
|
|
119
|
+
T,
|
|
120
|
+
G,
|
|
121
|
+
K,
|
|
122
|
+
z,
|
|
123
|
+
y.discount,
|
|
124
|
+
y.isTotalsDirty,
|
|
125
|
+
y.lineItems,
|
|
126
|
+
y.tax,
|
|
127
|
+
y.totalOverride,
|
|
128
|
+
y.values,
|
|
129
|
+
O,
|
|
130
|
+
I,
|
|
131
|
+
J,
|
|
132
|
+
L,
|
|
133
|
+
q
|
|
134
|
+
]), ue = _(async () => {
|
|
135
|
+
I && (await K.mutateAsync({ path: { payable_id: I } }), B(!1));
|
|
136
|
+
}, [K, I]);
|
|
137
|
+
return {
|
|
138
|
+
saveDraft: _(async () => {
|
|
139
|
+
if (!U.current && Q()) {
|
|
140
|
+
U.current = !0, H("draft");
|
|
141
|
+
try {
|
|
142
|
+
let t = await E?.({ allowIncompleteVendor: !0 });
|
|
143
|
+
if (t && !t.ok) return;
|
|
144
|
+
let n = await $(t?.counterpartBankAccountId, t?.counterpartId, t?.counterpartRawData);
|
|
145
|
+
y.setErrors(void 0), D?.(n), A?.(n);
|
|
146
|
+
let r = await k?.();
|
|
147
|
+
return e.success(r === "draft" ? N.submittedDemoted : N.draftSaved), n;
|
|
148
|
+
} catch (e) {
|
|
149
|
+
y.setSaveFailureMessage(S(e) ? N.discountTaxBlockedByLineItems : N.saveFailed), W();
|
|
150
|
+
return;
|
|
151
|
+
} finally {
|
|
152
|
+
H(void 0), U.current = !1;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
}, [
|
|
156
|
+
y,
|
|
157
|
+
Q,
|
|
158
|
+
N.discountTaxBlockedByLineItems,
|
|
159
|
+
N.draftSaved,
|
|
160
|
+
N.saveFailed,
|
|
161
|
+
N.submittedDemoted,
|
|
162
|
+
A,
|
|
163
|
+
D,
|
|
164
|
+
k,
|
|
165
|
+
E,
|
|
166
|
+
$,
|
|
167
|
+
W
|
|
168
|
+
]),
|
|
169
|
+
finalize: _(async () => {
|
|
170
|
+
if (U.current) return;
|
|
171
|
+
let t = d(y.lineItems, N), n = u(y.values, N), r = Z(), i = c(y.total, N), a = y.isTotalsDirty ? ee(y.totalOverride, N) : void 0, o = r || i || a ? {
|
|
172
|
+
...a,
|
|
173
|
+
...i,
|
|
174
|
+
...r
|
|
175
|
+
} : void 0, { formErrors: l, lineItemErrors: f } = s(y.values, b ?? (x ? re : void 0), y.lineItems, N), p = ae(f, t);
|
|
176
|
+
y.setLineItemErrors(p), y.setTotalsErrors(o);
|
|
177
|
+
let m = {
|
|
178
|
+
...l,
|
|
179
|
+
...n
|
|
180
|
+
};
|
|
181
|
+
if (y.setErrors(Object.keys(m).length ? m : void 0), t && e.error(N.lineItemsNeedAttention), p || o || Object.keys(m).length) {
|
|
182
|
+
m.vendor && w?.(), W();
|
|
183
|
+
return;
|
|
184
|
+
}
|
|
185
|
+
U.current = !0, H("finalize");
|
|
186
|
+
try {
|
|
187
|
+
let t;
|
|
188
|
+
try {
|
|
189
|
+
let e = await E?.();
|
|
190
|
+
if (e && !e.ok) return;
|
|
191
|
+
t = await $(e?.counterpartBankAccountId, e?.counterpartId);
|
|
192
|
+
} catch (e) {
|
|
193
|
+
y.setSaveFailureMessage(S(e) ? N.discountTaxBlockedByLineItems : N.saveFailed), W();
|
|
194
|
+
return;
|
|
195
|
+
}
|
|
196
|
+
D?.(t);
|
|
197
|
+
try {
|
|
198
|
+
let n = await Y.mutateAsync({ path: { payable_id: t } });
|
|
199
|
+
if (n.validation_errors.length) {
|
|
200
|
+
let e = C(n.validation_errors, N);
|
|
201
|
+
y.setErrors(e.formErrors), y.setTotalsErrors(e.totalsErrors), W();
|
|
202
|
+
return;
|
|
203
|
+
}
|
|
204
|
+
await X.mutateAsync({ path: { payable_id: t } }), y.setErrors(void 0), j?.(t), e.success(N.billFinalized);
|
|
205
|
+
} catch (e) {
|
|
206
|
+
ie(e) ? y.setErrors({ vendor: N.vendorResolutionFailed }) : y.setSaveFailureMessage(N.finalizeFailed), W();
|
|
207
|
+
}
|
|
208
|
+
} finally {
|
|
209
|
+
H(void 0), U.current = !1;
|
|
210
|
+
}
|
|
211
|
+
}, [
|
|
212
|
+
b,
|
|
213
|
+
x,
|
|
214
|
+
y,
|
|
215
|
+
N,
|
|
216
|
+
j,
|
|
217
|
+
D,
|
|
218
|
+
w,
|
|
219
|
+
E,
|
|
220
|
+
$,
|
|
221
|
+
W,
|
|
222
|
+
X,
|
|
223
|
+
Z,
|
|
224
|
+
Y
|
|
225
|
+
]),
|
|
226
|
+
payableId: I,
|
|
227
|
+
isSavingDraft: V === "draft",
|
|
228
|
+
isFinalizing: V === "finalize",
|
|
229
|
+
stagedFile: L,
|
|
230
|
+
stageFile: R,
|
|
231
|
+
clearStagedFile: oe,
|
|
232
|
+
scrollToErrorToken: ce,
|
|
233
|
+
isFileDeletionPending: z,
|
|
234
|
+
requestFileDeletion: se,
|
|
235
|
+
detachFileNow: ue,
|
|
236
|
+
isDeletingFile: K.isPending,
|
|
237
|
+
hasFileDeletionFailed: K.isError
|
|
238
|
+
};
|
|
81
239
|
}
|
|
82
240
|
//#endregion
|
|
83
|
-
export {
|
|
241
|
+
export { C as mapValidationErrorsToForm, w as useBillCreateController };
|
|
@@ -1,241 +1,47 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
"use client";
|
|
5
|
-
import { toast as e } from "../../../../../../packages/shared-ui-shadcn/dist/index.js";
|
|
6
|
-
import { extractApiErrorMessage as t } from "../../../../shared/util/dist/lib/apiErrors.js";
|
|
7
|
-
import "../../../../shared/util/dist/index.js";
|
|
8
|
-
import "../../../../shared/ui/dist/index.js";
|
|
9
|
-
import { BILL_CREATE_MESSAGE_LABELS_EN as n } from "./index29.js";
|
|
10
|
-
import { encodeFileToBase64 as r } from "./index35.js";
|
|
11
|
-
import { mapBillFormToPayload as i, mapLineItemsToPayload as a, mapPayableAmountFieldsToPayload as o } from "./index36.js";
|
|
12
|
-
import { validateBillCompleteness as s, validateBillTotalIsPayable as c, validateBillTotals as l, validateBillValues as u, validateLineItems as d, validateStoredAmountDue as ee } from "./index37.js";
|
|
13
|
-
import { useReplacePayableLineItemsMutation as f } from "../../data-access/dist/index4.js";
|
|
14
|
-
import { useCreatePayableMutation as p } from "../../data-access/dist/index8.js";
|
|
15
|
-
import { useDeletePayableFileMutation as m } from "../../data-access/dist/index9.js";
|
|
16
|
-
import { useSubmitPayableForApprovalMutation as h } from "../../data-access/dist/index14.js";
|
|
17
|
-
import { useUpdatePayableMutation as g } from "../../data-access/dist/index15.js";
|
|
18
|
-
import { useValidatePayableMutation as te } from "../../data-access/dist/index16.js";
|
|
19
|
-
import "../../data-access/dist/index.js";
|
|
20
|
-
import { useCallback as _, useRef as ne, useState as v } from "react";
|
|
1
|
+
import { resolveLineItemAmountMinorUnits as e } from "../../../util/dist/lib/resolveLineItemAmount.js";
|
|
2
|
+
import { resolveLineItemQuantity as t } from "../../../util/dist/lib/resolveLineItemQuantity.js";
|
|
3
|
+
import "../../../util/dist/index.js";
|
|
21
4
|
//#region ../../libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index38.js
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
5
|
+
function n() {
|
|
6
|
+
return {
|
|
7
|
+
id: crypto.randomUUID(),
|
|
8
|
+
description: "",
|
|
9
|
+
glCode: "",
|
|
10
|
+
quantity: "1",
|
|
11
|
+
price: "",
|
|
12
|
+
amount: ""
|
|
13
|
+
};
|
|
31
14
|
}
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
return !!t(e)?.includes("line_items_enabled");
|
|
15
|
+
function r(e) {
|
|
16
|
+
return typeof e == "number" ? (e / 100).toFixed(2) : "";
|
|
35
17
|
}
|
|
36
|
-
function
|
|
37
|
-
return
|
|
18
|
+
function i(e) {
|
|
19
|
+
return typeof e == "string" ? e : "";
|
|
38
20
|
}
|
|
39
|
-
function
|
|
40
|
-
|
|
41
|
-
for (let n of e) {
|
|
42
|
-
let e = n.loc[0] ?? t.unknownValidationField, o = y[e], s = b[e], c = x(n) ? t.requiredField : n.msg;
|
|
43
|
-
o ? r[o] = c : s ? i[s] = c : a.push(t.unmappedValidationError(e, c));
|
|
44
|
-
}
|
|
45
|
-
return a.length && (r.form = a.join(" ")), {
|
|
46
|
-
formErrors: r,
|
|
47
|
-
totalsErrors: Object.keys(i).length ? i : void 0
|
|
48
|
-
};
|
|
49
|
-
}
|
|
50
|
-
function ae(e, t) {
|
|
51
|
-
if (!e && !t) return;
|
|
52
|
-
let n = {}, r = /* @__PURE__ */ new Set([...Object.keys(e ?? {}), ...Object.keys(t ?? {})]);
|
|
53
|
-
for (let i of r) n[i] = {
|
|
54
|
-
...e?.[i],
|
|
55
|
-
...t?.[i]
|
|
56
|
-
};
|
|
57
|
-
return n;
|
|
21
|
+
function a(e) {
|
|
22
|
+
return e.total_amount ?? e.amount_due ?? void 0;
|
|
58
23
|
}
|
|
59
|
-
function
|
|
60
|
-
let
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
base64EncodedFile: await r(L),
|
|
74
|
-
fileName: L.name
|
|
75
|
-
} : void 0, c = y.isTotalsDirty ? {
|
|
76
|
-
discount: y.discount,
|
|
77
|
-
tax: y.tax,
|
|
78
|
-
total: y.totalOverride
|
|
79
|
-
} : void 0, l = i({
|
|
80
|
-
values: y.values,
|
|
81
|
-
initialLineItems: I ? void 0 : y.lineItems,
|
|
82
|
-
counterpartId: t ?? b,
|
|
83
|
-
clearCounterpart: T,
|
|
84
|
-
counterpartBankAccountId: e,
|
|
85
|
-
currentTotals: {
|
|
86
|
-
discount: y.discount,
|
|
87
|
-
tax: y.tax,
|
|
88
|
-
total: y.totalOverride
|
|
89
|
-
},
|
|
90
|
-
lineItems: y.lineItems,
|
|
91
|
-
editedTotals: c,
|
|
92
|
-
document: s
|
|
93
|
-
}), u = n ? {
|
|
94
|
-
...l,
|
|
95
|
-
counterpart_raw_data: n
|
|
96
|
-
} : l, d = I;
|
|
97
|
-
if (d ? await q.mutateAsync({
|
|
98
|
-
path: { payable_id: d },
|
|
99
|
-
body: u
|
|
100
|
-
}) : (d = (await G.mutateAsync({ body: u }))?.id, d && (F(d), O?.(d), s && R(void 0))), !d) throw Error("Payable was created without an id");
|
|
101
|
-
if (z) {
|
|
102
|
-
try {
|
|
103
|
-
await K.mutateAsync({ path: { payable_id: d } });
|
|
104
|
-
} catch {}
|
|
105
|
-
B(!1);
|
|
106
|
-
}
|
|
107
|
-
return await J.mutateAsync({
|
|
108
|
-
path: { payable_id: d },
|
|
109
|
-
body: { data: a(y.lineItems) }
|
|
110
|
-
}), c && await q.mutateAsync({
|
|
111
|
-
path: { payable_id: d },
|
|
112
|
-
body: o({
|
|
113
|
-
lineItems: y.lineItems,
|
|
114
|
-
editedTotals: c
|
|
115
|
-
})
|
|
116
|
-
}), d;
|
|
117
|
-
}, [
|
|
118
|
-
b,
|
|
119
|
-
T,
|
|
120
|
-
G,
|
|
121
|
-
K,
|
|
122
|
-
z,
|
|
123
|
-
y.discount,
|
|
124
|
-
y.isTotalsDirty,
|
|
125
|
-
y.lineItems,
|
|
126
|
-
y.tax,
|
|
127
|
-
y.totalOverride,
|
|
128
|
-
y.values,
|
|
129
|
-
O,
|
|
130
|
-
I,
|
|
131
|
-
J,
|
|
132
|
-
L,
|
|
133
|
-
q
|
|
134
|
-
]), ue = _(async () => {
|
|
135
|
-
I && (await K.mutateAsync({ path: { payable_id: I } }), B(!1));
|
|
136
|
-
}, [K, I]);
|
|
24
|
+
function o({ payable: o, lineItems: s }) {
|
|
25
|
+
let c = {
|
|
26
|
+
invoiceNumber: o.document_id ?? "",
|
|
27
|
+
invoiceDate: o.issued_at ?? "",
|
|
28
|
+
dueDate: o.due_date ?? "",
|
|
29
|
+
poNumber: i(o.purchase_order_number)
|
|
30
|
+
}, l = s.map((n) => ({
|
|
31
|
+
id: n.id,
|
|
32
|
+
description: n.name ?? "",
|
|
33
|
+
glCode: n.ledger_account_id ?? "",
|
|
34
|
+
quantity: String(t(n)),
|
|
35
|
+
price: r(n.unit_price),
|
|
36
|
+
amount: r(e(n))
|
|
37
|
+
})), u = a(o);
|
|
137
38
|
return {
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
if (t && !t.ok) return;
|
|
144
|
-
let n = await $(t?.counterpartBankAccountId, t?.counterpartId, t?.counterpartRawData);
|
|
145
|
-
y.setErrors(void 0), D?.(n), A?.(n);
|
|
146
|
-
let r = await k?.();
|
|
147
|
-
return e.success(r === "draft" ? N.submittedDemoted : N.draftSaved), n;
|
|
148
|
-
} catch (e) {
|
|
149
|
-
y.setSaveFailureMessage(S(e) ? N.discountTaxBlockedByLineItems : N.saveFailed), W();
|
|
150
|
-
return;
|
|
151
|
-
} finally {
|
|
152
|
-
H(void 0), U.current = !1;
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
}, [
|
|
156
|
-
y,
|
|
157
|
-
Q,
|
|
158
|
-
N.discountTaxBlockedByLineItems,
|
|
159
|
-
N.draftSaved,
|
|
160
|
-
N.saveFailed,
|
|
161
|
-
N.submittedDemoted,
|
|
162
|
-
A,
|
|
163
|
-
D,
|
|
164
|
-
k,
|
|
165
|
-
E,
|
|
166
|
-
$,
|
|
167
|
-
W
|
|
168
|
-
]),
|
|
169
|
-
finalize: _(async () => {
|
|
170
|
-
if (U.current) return;
|
|
171
|
-
let t = d(y.lineItems, N), n = u(y.values, N), r = Z(), i = c(y.total, N), a = y.isTotalsDirty ? ee(y.totalOverride, N) : void 0, o = r || i || a ? {
|
|
172
|
-
...a,
|
|
173
|
-
...i,
|
|
174
|
-
...r
|
|
175
|
-
} : void 0, { formErrors: l, lineItemErrors: f } = s(y.values, b ?? (x ? re : void 0), y.lineItems, N), p = ae(f, t);
|
|
176
|
-
y.setLineItemErrors(p), y.setTotalsErrors(o);
|
|
177
|
-
let m = {
|
|
178
|
-
...l,
|
|
179
|
-
...n
|
|
180
|
-
};
|
|
181
|
-
if (y.setErrors(Object.keys(m).length ? m : void 0), t && e.error(N.lineItemsNeedAttention), p || o || Object.keys(m).length) {
|
|
182
|
-
m.vendor && w?.(), W();
|
|
183
|
-
return;
|
|
184
|
-
}
|
|
185
|
-
U.current = !0, H("finalize");
|
|
186
|
-
try {
|
|
187
|
-
let t;
|
|
188
|
-
try {
|
|
189
|
-
let e = await E?.();
|
|
190
|
-
if (e && !e.ok) return;
|
|
191
|
-
t = await $(e?.counterpartBankAccountId, e?.counterpartId);
|
|
192
|
-
} catch (e) {
|
|
193
|
-
y.setSaveFailureMessage(S(e) ? N.discountTaxBlockedByLineItems : N.saveFailed), W();
|
|
194
|
-
return;
|
|
195
|
-
}
|
|
196
|
-
D?.(t);
|
|
197
|
-
try {
|
|
198
|
-
let n = await Y.mutateAsync({ path: { payable_id: t } });
|
|
199
|
-
if (n.validation_errors.length) {
|
|
200
|
-
let e = C(n.validation_errors, N);
|
|
201
|
-
y.setErrors(e.formErrors), y.setTotalsErrors(e.totalsErrors), W();
|
|
202
|
-
return;
|
|
203
|
-
}
|
|
204
|
-
await X.mutateAsync({ path: { payable_id: t } }), y.setErrors(void 0), j?.(t), e.success(N.billFinalized);
|
|
205
|
-
} catch (e) {
|
|
206
|
-
ie(e) ? y.setErrors({ vendor: N.vendorResolutionFailed }) : y.setSaveFailureMessage(N.finalizeFailed), W();
|
|
207
|
-
}
|
|
208
|
-
} finally {
|
|
209
|
-
H(void 0), U.current = !1;
|
|
210
|
-
}
|
|
211
|
-
}, [
|
|
212
|
-
b,
|
|
213
|
-
x,
|
|
214
|
-
y,
|
|
215
|
-
N,
|
|
216
|
-
j,
|
|
217
|
-
D,
|
|
218
|
-
w,
|
|
219
|
-
E,
|
|
220
|
-
$,
|
|
221
|
-
W,
|
|
222
|
-
X,
|
|
223
|
-
Z,
|
|
224
|
-
Y
|
|
225
|
-
]),
|
|
226
|
-
payableId: I,
|
|
227
|
-
isSavingDraft: V === "draft",
|
|
228
|
-
isFinalizing: V === "finalize",
|
|
229
|
-
stagedFile: L,
|
|
230
|
-
stageFile: R,
|
|
231
|
-
clearStagedFile: oe,
|
|
232
|
-
scrollToErrorToken: ce,
|
|
233
|
-
isFileDeletionPending: z,
|
|
234
|
-
requestFileDeletion: se,
|
|
235
|
-
detachFileNow: ue,
|
|
236
|
-
isDeletingFile: K.isPending,
|
|
237
|
-
hasFileDeletionFailed: K.isError
|
|
39
|
+
values: c,
|
|
40
|
+
lineItems: l.length ? l : [n()],
|
|
41
|
+
discount: r(o.discount),
|
|
42
|
+
tax: r(o.tax_amount),
|
|
43
|
+
total: u ? r(u) : ""
|
|
238
44
|
};
|
|
239
45
|
}
|
|
240
46
|
//#endregion
|
|
241
|
-
export {
|
|
47
|
+
export { n as emptyLineItem, o as mapPayableToBillForm };
|