@tesouro/embedded-components-react 0.4.31 → 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/README.md +17 -47
- package/dist/index.d.ts +2 -27
- package/dist/index.js +21 -27
- package/dist/lib/BillPayWidget.js +1 -1
- package/dist/lib/ExpenseManagementWidget.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/expense-management-widget/feature/dist/index.js +3 -3
- package/dist/libs/tesouro-embedded-components-react/expense-management-widget/feature/dist/index10.js +74 -1
- package/dist/libs/tesouro-embedded-components-react/expense-management-widget/feature/dist/index11.js +11 -247
- package/dist/libs/tesouro-embedded-components-react/expense-management-widget/feature/dist/index12.js +2 -2
- package/dist/libs/tesouro-embedded-components-react/expense-management-widget/feature/dist/index13.js +34 -57
- package/dist/libs/tesouro-embedded-components-react/expense-management-widget/feature/dist/index14.js +1 -0
- package/dist/libs/tesouro-embedded-components-react/expense-management-widget/feature/dist/index8.js +253 -2
- package/dist/libs/tesouro-embedded-components-react/expense-management-widget/feature/dist/index9.js +2 -48
- package/dist/libs/tesouro-embedded-components-react/expense-management-widget/ui/dist/index.js +2 -1
- package/dist/libs/tesouro-embedded-components-react/expense-management-widget/ui/dist/lib/ReceiptMatchWidget/lib/ReceiptMatchLauncher.js +28 -0
- package/dist/libs/tesouro-embedded-components-react/expense-management-widget/ui/dist/lib/ReceiptMatchWidget/lib/labels.js +4 -1
- 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
- package/dist/lib/ExpenseApprovalPoliciesWidget.d.ts +0 -639
- package/dist/lib/ExpenseApprovalPoliciesWidget.js +0 -3
- package/dist/lib/ExpenseRequirementsWidget.d.ts +0 -639
- package/dist/lib/ExpenseRequirementsWidget.js +0 -3
- package/dist/lib/ReceiptMatchWidget.d.ts +0 -640
- package/dist/lib/ReceiptMatchWidget.js +0 -3
|
@@ -1,51 +1,124 @@
|
|
|
1
|
-
|
|
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 { useUpdatePayableMutation as t } from "../../data-access/dist/index13.js";
|
|
8
|
+
import { useCounterpartBankAccountsQuery as n, useCreateCounterpartBankAccountMutation as r } from "../../../shared/counterpart-management/data-access/dist/index5.js";
|
|
9
|
+
import { useUpdatePayableCounterpartBankAccountMutation as i } from "../../data-access/dist/index14.js";
|
|
2
10
|
import "../../data-access/dist/index.js";
|
|
11
|
+
import { counterpartFormBankAccountToCreatePayload as a, counterpartFormBankAccountToUpdatePayload as o, getAchInstructions as s, isAchCompatibleBankAccount as c, resolveCounterpartBankAccountWrite as l, validateAchFormValues as u } from "../../../shared/counterpart-management/feature/dist/lib/helpers.js";
|
|
12
|
+
import "../../../shared/counterpart-management/feature/dist/index.js";
|
|
13
|
+
import { useCallback as d, useEffect as f, useRef as p, useState as m } from "react";
|
|
3
14
|
//#region ../../libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index53.js
|
|
4
|
-
var
|
|
5
|
-
|
|
6
|
-
|
|
15
|
+
var h = {
|
|
16
|
+
accountHolderName: "",
|
|
17
|
+
routingNumber: "",
|
|
18
|
+
accountNumber: ""
|
|
19
|
+
};
|
|
20
|
+
function g(e, t) {
|
|
21
|
+
return e?.find((e) => e.id === t && c(e)) ?? s(e);
|
|
7
22
|
}
|
|
8
|
-
function
|
|
9
|
-
let
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
23
|
+
function _({ payableId: c, counterpartId: _, currentBankAccountId: v, canReadCounterpartBankAccounts: y = !0, saveErrorMessage: b, linkErrorMessage: x }) {
|
|
24
|
+
let [S, C] = m(!1), [w, T] = m(h), [E, D] = m(), O = n(_, { enabled: y }), k = O.data?.data, A = r(), j = i(), M = t(), N = p(void 0), P = p(!1);
|
|
25
|
+
f(() => {
|
|
26
|
+
N.current = void 0;
|
|
27
|
+
}, [_, c]);
|
|
28
|
+
let F = d(() => {
|
|
29
|
+
if (S) return;
|
|
30
|
+
let e = O.isFetching ? void 0 : g(k, v);
|
|
31
|
+
T(e ? {
|
|
32
|
+
accountHolderName: e.account_holder_name ?? "",
|
|
33
|
+
routingNumber: e.routing_number ?? "",
|
|
34
|
+
accountNumber: e.account_number ?? ""
|
|
35
|
+
} : h), N.current = e?.id ?? N.current, P.current = !O.isFetching, D(void 0), C(!0);
|
|
36
|
+
}, [
|
|
37
|
+
k,
|
|
38
|
+
O.isFetching,
|
|
39
|
+
v,
|
|
40
|
+
S
|
|
41
|
+
]);
|
|
42
|
+
f(() => {
|
|
43
|
+
if (!S || P.current || O.isFetching) return;
|
|
44
|
+
P.current = !0;
|
|
45
|
+
let e = g(k, v);
|
|
46
|
+
e && (T((t) => t.accountHolderName === "" && t.routingNumber === "" && t.accountNumber === "" ? {
|
|
47
|
+
accountHolderName: e.account_holder_name ?? "",
|
|
48
|
+
routingNumber: e.routing_number ?? "",
|
|
49
|
+
accountNumber: e.account_number ?? ""
|
|
50
|
+
} : t), N.current = e.id);
|
|
51
|
+
}, [
|
|
52
|
+
S,
|
|
53
|
+
O.isFetching,
|
|
54
|
+
k,
|
|
55
|
+
v,
|
|
56
|
+
y
|
|
57
|
+
]);
|
|
58
|
+
let I = d(() => {
|
|
59
|
+
C(!1);
|
|
60
|
+
}, []), L = d((e) => {
|
|
61
|
+
T((t) => ({
|
|
62
|
+
...t,
|
|
63
|
+
...e
|
|
64
|
+
}));
|
|
65
|
+
}, []), R = d(async () => {
|
|
66
|
+
if (!c || !_) return !1;
|
|
67
|
+
let t = u(w);
|
|
68
|
+
if (Object.keys(t).length > 0) return D(t), !1;
|
|
69
|
+
if (D(void 0), !y || O.isFetching || O.isError) return e.error(b), !1;
|
|
70
|
+
let n = N.current;
|
|
71
|
+
try {
|
|
72
|
+
let e = l(k, n ?? s(k)?.id);
|
|
73
|
+
e.kind === "update" ? (await j.mutateAsync({
|
|
74
|
+
path: {
|
|
75
|
+
counterpart_id: _,
|
|
76
|
+
bank_account_id: e.bankAccountId
|
|
77
|
+
},
|
|
78
|
+
body: o(w, { includeAchDefaults: e.includeAchDefaults }),
|
|
79
|
+
payableId: c,
|
|
80
|
+
makeDefault: e.includeAchDefaults || !k?.find((t) => t.id === e.bankAccountId)?.is_default_for_currency
|
|
81
|
+
}), n = e.bankAccountId) : n = (await A.mutateAsync({
|
|
82
|
+
path: { counterpart_id: _ },
|
|
83
|
+
body: a(w, { isDefaultForCurrency: e.isDefaultForCurrency })
|
|
84
|
+
}))?.id, N.current = n;
|
|
85
|
+
} catch {
|
|
86
|
+
return e.error(b), !1;
|
|
87
|
+
}
|
|
88
|
+
if (n !== v) try {
|
|
89
|
+
await M.mutateAsync({
|
|
90
|
+
path: { payable_id: c },
|
|
91
|
+
body: { counterpart_bank_account_id: n }
|
|
92
|
+
});
|
|
93
|
+
} catch {
|
|
94
|
+
return e.error(x), !1;
|
|
95
|
+
}
|
|
96
|
+
return C(!1), !0;
|
|
97
|
+
}, [
|
|
98
|
+
k,
|
|
99
|
+
O.isError,
|
|
100
|
+
O.isFetching,
|
|
101
|
+
y,
|
|
102
|
+
_,
|
|
103
|
+
A,
|
|
104
|
+
v,
|
|
105
|
+
x,
|
|
106
|
+
c,
|
|
107
|
+
b,
|
|
108
|
+
j,
|
|
109
|
+
M,
|
|
110
|
+
w
|
|
111
|
+
]);
|
|
112
|
+
return {
|
|
113
|
+
isOpen: S,
|
|
114
|
+
values: w,
|
|
115
|
+
errors: E,
|
|
116
|
+
isSaving: A.isPending || j.isPending || M.isPending,
|
|
117
|
+
open: F,
|
|
118
|
+
close: I,
|
|
119
|
+
onChange: L,
|
|
120
|
+
save: R
|
|
121
|
+
};
|
|
49
122
|
}
|
|
50
123
|
//#endregion
|
|
51
|
-
export {
|
|
124
|
+
export { _ as usePaymentInstructionsForm };
|
|
@@ -1,35 +1,16 @@
|
|
|
1
|
-
import { BILL_CREATE_MESSAGE_LABELS_EN as e } from "./index46.js";
|
|
2
|
-
import { isPersistableLineItem as t, parseMoneyToMinorUnits as n, parseQuantity as r } from "./index53.js";
|
|
3
1
|
//#region ../../libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index54.js
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
}
|
|
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
|
|
28
|
-
};
|
|
29
|
-
}
|
|
30
|
-
function c(t, r, i, o = e) {
|
|
31
|
-
let s = {};
|
|
32
|
-
return a(t) || (s.discount = o.unreadableDiscount), a(r) || (s.tax = o.unreadableTax), i !== void 0 && n(i) === null && (s.total = o.unreadableTotal), Object.keys(s).length ? s : void 0;
|
|
2
|
+
function e(e) {
|
|
3
|
+
return new Promise((t, n) => {
|
|
4
|
+
let r = new FileReader();
|
|
5
|
+
r.onerror = () => n(r.error ?? /* @__PURE__ */ Error("Failed to read file")), r.onload = () => {
|
|
6
|
+
let e = r.result;
|
|
7
|
+
if (typeof e != "string") {
|
|
8
|
+
n(/* @__PURE__ */ Error("Failed to read file as a data URL"));
|
|
9
|
+
return;
|
|
10
|
+
}
|
|
11
|
+
t(e.slice(e.indexOf(",") + 1));
|
|
12
|
+
}, r.readAsDataURL(e);
|
|
13
|
+
});
|
|
33
14
|
}
|
|
34
15
|
//#endregion
|
|
35
|
-
export {
|
|
16
|
+
export { e as encodeFileToBase64 };
|
|
@@ -1,206 +1,51 @@
|
|
|
1
|
-
|
|
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 { 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";
|
|
1
|
+
import { parseDecimalAmountToMinorUnits as e } from "../../../shared/util/dist/lib/parseDecimalAmountToMinorUnits.js";
|
|
10
2
|
import "../../data-access/dist/index.js";
|
|
11
|
-
import { BILL_CREATE_MESSAGE_LABELS_EN as c } from "./index46.js";
|
|
12
|
-
import { encodeFileToBase64 as ee } from "./index52.js";
|
|
13
|
-
import { mapBillFormToPayload as l, mapLineItemsToPayload as u } from "./index53.js";
|
|
14
|
-
import { validateBillCompleteness as d, validateBillTotals as f, validateLineItems as p } from "./index54.js";
|
|
15
|
-
import { useCallback as m, useRef as h, useState as g } from "react";
|
|
16
3
|
//#region ../../libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index55.js
|
|
17
|
-
var
|
|
18
|
-
|
|
19
|
-
|
|
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";
|
|
4
|
+
var t = "USD";
|
|
5
|
+
function n(n) {
|
|
6
|
+
return e(n, t);
|
|
25
7
|
}
|
|
26
|
-
function
|
|
27
|
-
|
|
8
|
+
function r(e) {
|
|
9
|
+
let t = e.trim();
|
|
10
|
+
if (!t) return null;
|
|
11
|
+
let n = Number(t);
|
|
12
|
+
return Number.isFinite(n) && n > 0 ? n : null;
|
|
28
13
|
}
|
|
29
|
-
function
|
|
30
|
-
|
|
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
|
-
};
|
|
14
|
+
function i(e) {
|
|
15
|
+
return !!(e.description.trim() || e.glCode.trim() || n(e.price) !== null || n(e.amount) !== null);
|
|
39
16
|
}
|
|
40
|
-
function
|
|
41
|
-
|
|
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]
|
|
46
|
-
};
|
|
47
|
-
return n;
|
|
17
|
+
function a(e) {
|
|
18
|
+
return n(e) ?? 0;
|
|
48
19
|
}
|
|
49
|
-
function
|
|
50
|
-
let
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
let t =
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
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);
|
|
86
|
-
}
|
|
87
|
-
return await J.mutateAsync({
|
|
88
|
-
path: { payable_id: r },
|
|
89
|
-
body: { data: u(_.lineItems) }
|
|
90
|
-
}), r;
|
|
91
|
-
}, [
|
|
92
|
-
v,
|
|
93
|
-
y,
|
|
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]);
|
|
111
|
-
return {
|
|
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
|
|
203
|
-
};
|
|
20
|
+
function o(e) {
|
|
21
|
+
let t = Number.parseFloat(e);
|
|
22
|
+
return Number.isFinite(t) ? t : 0;
|
|
23
|
+
}
|
|
24
|
+
function s(e) {
|
|
25
|
+
return (e / 100).toFixed(2);
|
|
26
|
+
}
|
|
27
|
+
function c({ values: e, counterpartId: r, clearCounterpart: i, counterpartBankAccountId: a, editedTotals: o, document: s }) {
|
|
28
|
+
let c = { currency: t };
|
|
29
|
+
return r ? c.counterpart_id = r : i && (c.counterpart_id = null), r ? c.counterpart_bank_account_id = a ?? null : i && (c.counterpart_bank_account_id = null), e.invoiceNumber && (c.document_id = e.invoiceNumber), e.invoiceDate && (c.issued_at = e.invoiceDate), e.dueDate && (c.due_date = e.dueDate), s && (c.base64_encoded_file = s.base64EncodedFile, c.file_name = s.fileName), o && (c.discount = n(o.discount) ?? 0, c.tax_amount = n(o.tax) ?? 0, o.total !== void 0 && (c.total_amount = n(o.total) ?? 0)), c;
|
|
30
|
+
}
|
|
31
|
+
function l(e) {
|
|
32
|
+
return e.filter(i).map((e) => {
|
|
33
|
+
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);
|
|
34
|
+
return {
|
|
35
|
+
name: e.description,
|
|
36
|
+
quantity: i,
|
|
37
|
+
unit_price: a,
|
|
38
|
+
tax: 0,
|
|
39
|
+
...t !== null && t !== o ? { subtotal: t } : {},
|
|
40
|
+
...e.glCode ? { ledger_account_id: e.glCode } : {}
|
|
41
|
+
};
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
function u(e, t) {
|
|
45
|
+
return s(Math.round(o(e) * a(t)));
|
|
46
|
+
}
|
|
47
|
+
function d(e, t, n) {
|
|
48
|
+
return s(e.reduce((e, t) => e + a(t.amount), 0) + a(t) - a(n));
|
|
204
49
|
}
|
|
205
50
|
//#endregion
|
|
206
|
-
export {
|
|
51
|
+
export { d as calculateTotal, u as displayLineAmount, i as isPersistableLineItem, c as mapBillFormToPayload, l as mapLineItemsToPayload, n as parseMoneyToMinorUnits, r as parseQuantity };
|
|
@@ -1,38 +1,35 @@
|
|
|
1
|
+
import { BILL_CREATE_MESSAGE_LABELS_EN as e } from "./index48.js";
|
|
2
|
+
import { isPersistableLineItem as t, parseMoneyToMinorUnits as n, parseQuantity as r } from "./index55.js";
|
|
1
3
|
//#region ../../libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index56.js
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
glCode: "",
|
|
7
|
-
quantity: "1",
|
|
8
|
-
price: "",
|
|
9
|
-
amount: ""
|
|
10
|
-
};
|
|
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;
|
|
11
8
|
}
|
|
12
|
-
function t
|
|
13
|
-
|
|
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), r(e.quantity) === null && (e.quantity.trim() || t !== null || o !== null) && (s.quantity = i.unusableQuantity), Object.keys(s).length && (a[e.id] = s);
|
|
14
|
+
}
|
|
15
|
+
return Object.keys(a).length ? a : void 0;
|
|
14
16
|
}
|
|
15
|
-
function
|
|
16
|
-
let
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
price: t(e.unit_price),
|
|
27
|
-
amount: t(e.subtotal)
|
|
28
|
-
})), o = n.amount_due ?? (n.total_amount == null ? void 0 : n.total_amount - (n.discount ?? 0));
|
|
29
|
-
return {
|
|
30
|
-
values: i,
|
|
31
|
-
lineItems: a.length ? a : [e()],
|
|
32
|
-
discount: t(n.discount),
|
|
33
|
-
tax: t(n.tax_amount),
|
|
34
|
-
total: o ? t(o) : ""
|
|
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
|
|
35
28
|
};
|
|
36
29
|
}
|
|
30
|
+
function c(t, r, i, o = e) {
|
|
31
|
+
let s = {};
|
|
32
|
+
return a(t) || (s.discount = o.unreadableDiscount), a(r) || (s.tax = o.unreadableTax), i !== void 0 && n(i) === null && (s.total = o.unreadableTotal), Object.keys(s).length ? s : void 0;
|
|
33
|
+
}
|
|
37
34
|
//#endregion
|
|
38
|
-
export {
|
|
35
|
+
export { a as isReadableMoneyOrZero, s as validateBillCompleteness, c as validateBillTotals, o as validateLineItems };
|