@tesouro/embedded-components-react 0.5.18 → 0.5.20
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 +22 -21
- package/dist/index.css +18 -0
- package/dist/index.d.ts +29 -6
- package/dist/index.js +1 -1
- package/dist/lib/BillPayWidget.js +1 -1
- package/dist/lib/CardDetailsWidget.d.ts +20 -2
- package/dist/lib/CreditCardsWidget.d.ts +29 -6
- package/dist/lib/DebitCardsWidget.d.ts +29 -6
- package/dist/lib/WidgetSuite.d.ts +29 -6
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/data-access/dist/index6.js +2 -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/index41.js +4 -91
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index42.js +78 -83
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index43.js +98 -3
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index44.js +3 -49
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index45.js +47 -136
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index46.js +136 -33
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index47.js +33 -187
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index48.js +188 -75
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index49.js +75 -21
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index50.js +22 -232
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index51.js +223 -210
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index52.js +202 -108
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index53.js +126 -13
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index54.js +12 -47
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index55.js +47 -53
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index56.js +49 -202
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index57.js +202 -31
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index58.js +32 -234
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index59.js +240 -19
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index60.js +19 -434
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index61.js +436 -4
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index62.js +4 -38
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index63.js +35 -231
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index64.js +235 -3
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index65.js +3 -4
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index66.js +2 -44
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index67.js +46 -1
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index68.js +1 -8
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index69.js +6 -10
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index70.js +10 -110
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index71.js +112 -3
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index72.js +3 -127
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index73.js +124 -8
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index74.js +8 -7
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index75.js +8 -46
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index76.js +43 -18
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index77.js +20 -28
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index78.js +27 -82
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index79.js +83 -47
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index80.js +47 -250
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index81.js +239 -104
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index82.js +110 -206
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index83.js +213 -3
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index84.js +4 -8
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index85.js +6 -113
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index86.js +115 -1
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index87.js +0 -24
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index88.js +25 -0
- package/dist/libs/tesouro-embedded-components-react/card-details-widget/feature/dist/index13.js +152 -149
- package/dist/libs/tesouro-embedded-components-react/card-details-widget/feature/dist/index3.js +8 -11
- package/dist/libs/tesouro-embedded-components-react/card-details-widget/feature/dist/index4.js +1 -1
- package/dist/libs/tesouro-embedded-components-react/card-details-widget/feature/dist/index6.js +2 -0
- package/dist/libs/tesouro-embedded-components-react/card-details-widget/feature/dist/index7.js +4 -4
- package/dist/libs/tesouro-embedded-components-react/card-details-widget/feature/dist/index9.js +81 -79
- package/dist/libs/tesouro-embedded-components-react/card-details-widget/ui/dist/lib/ActivateCardPanel/ActivateCardPanel.js +39 -38
- package/dist/libs/tesouro-embedded-components-react/card-details-widget/ui/dist/lib/CardDetailsPanel/AddressLine.js +23 -0
- package/dist/libs/tesouro-embedded-components-react/card-details-widget/ui/dist/lib/CardDetailsPanel/CardDetailsPanel.js +142 -118
- package/dist/libs/tesouro-embedded-components-react/card-details-widget/ui/dist/lib/CardDetailsPanel/CardFace.js +24 -14
- package/dist/libs/tesouro-embedded-components-react/card-details-widget/ui/dist/lib/CardDetailsPanel/labels.js +4 -1
- package/dist/libs/tesouro-embedded-components-react/cards-widget/feature/dist/index9.js +1 -0
- package/dist/libs/tesouro-embedded-components-react/create-card-widget/ui/dist/lib/CreateCardWidget/CardControls/PerTransactionMaximumControl.js +17 -16
- package/dist/libs/tesouro-embedded-components-react/create-card-widget/ui/dist/lib/CreateCardWidget/CardControls/SpendLimitControl.js +25 -24
- package/dist/libs/tesouro-embedded-components-react/create-card-widget/ui/dist/lib/CreateCardWidget/CardControls/limitDecimalPlaces.js +7 -0
- package/dist/libs/tesouro-embedded-components-react/create-card-widget/ui/dist/lib/CreateCardWidget/SetupView.js +1 -1
- package/dist/libs/tesouro-embedded-components-react/settings-widget/feature/dist/index6.js +2 -2
- package/dist/libs/tesouro-embedded-components-react/{team-widget → settings-widget/team}/data-access/dist/index.js +1 -1
- package/dist/libs/tesouro-embedded-components-react/{team-widget → settings-widget/team}/data-access/dist/index10.js +6 -6
- package/dist/libs/tesouro-embedded-components-react/settings-widget/team/data-access/dist/index11.js +3 -0
- package/dist/libs/tesouro-embedded-components-react/{team-widget → settings-widget/team}/data-access/dist/index12.js +7 -7
- package/dist/libs/tesouro-embedded-components-react/settings-widget/team/data-access/dist/index13.js +24 -0
- package/dist/libs/tesouro-embedded-components-react/{team-widget → settings-widget/team}/data-access/dist/index14.js +7 -7
- package/dist/libs/tesouro-embedded-components-react/{team-widget → settings-widget/team}/data-access/dist/index15.js +7 -7
- package/dist/libs/tesouro-embedded-components-react/{team-widget → settings-widget/team}/data-access/dist/index16.js +1 -1
- package/dist/libs/tesouro-embedded-components-react/{team-widget → settings-widget/team}/data-access/dist/index17.js +7 -7
- package/dist/libs/tesouro-embedded-components-react/{team-widget → settings-widget/team}/data-access/dist/index18.js +6 -6
- package/dist/libs/tesouro-embedded-components-react/{team-widget → settings-widget/team}/data-access/dist/index19.js +7 -7
- package/dist/libs/tesouro-embedded-components-react/settings-widget/team/data-access/dist/index2.js +10 -0
- package/dist/libs/tesouro-embedded-components-react/{team-widget → settings-widget/team}/data-access/dist/index20.js +1 -1
- package/dist/libs/tesouro-embedded-components-react/{team-widget → settings-widget/team}/data-access/dist/index21.js +7 -7
- package/dist/libs/tesouro-embedded-components-react/{team-widget → settings-widget/team}/data-access/dist/index22.js +6 -6
- package/dist/libs/tesouro-embedded-components-react/{team-widget → settings-widget/team}/data-access/dist/index23.js +7 -7
- package/dist/libs/tesouro-embedded-components-react/{team-widget → settings-widget/team}/data-access/dist/index3.js +4 -4
- package/dist/libs/tesouro-embedded-components-react/settings-widget/team/data-access/dist/index4.js +29 -0
- package/dist/libs/tesouro-embedded-components-react/settings-widget/team/data-access/dist/index5.js +10 -0
- package/dist/libs/tesouro-embedded-components-react/settings-widget/team/data-access/dist/index6.js +10 -0
- package/dist/libs/tesouro-embedded-components-react/{team-widget → settings-widget/team}/data-access/dist/index7.js +7 -7
- package/dist/libs/tesouro-embedded-components-react/{team-widget → settings-widget/team}/data-access/dist/index8.js +6 -6
- package/dist/libs/tesouro-embedded-components-react/{team-widget → settings-widget/team}/data-access/dist/index9.js +6 -6
- package/dist/libs/tesouro-embedded-components-react/{team-widget → settings-widget/team}/feature/dist/index10.js +1 -1
- package/dist/libs/tesouro-embedded-components-react/{team-widget → settings-widget/team}/feature/dist/index11.js +4 -4
- package/dist/libs/tesouro-embedded-components-react/{team-widget → settings-widget/team}/feature/dist/index12.js +9 -9
- package/dist/libs/tesouro-embedded-components-react/{team-widget → settings-widget/team}/feature/dist/index13.js +1 -1
- package/dist/libs/tesouro-embedded-components-react/{team-widget → settings-widget/team}/feature/dist/index14.js +6 -6
- package/dist/libs/tesouro-embedded-components-react/{team-widget → settings-widget/team}/feature/dist/index15.js +8 -8
- package/dist/libs/tesouro-embedded-components-react/{team-widget → settings-widget/team}/feature/dist/index16.js +5 -5
- package/dist/libs/tesouro-embedded-components-react/{team-widget → settings-widget/team}/feature/dist/index17.js +11 -11
- package/dist/libs/tesouro-embedded-components-react/settings-widget/team/feature/dist/index2.js +10 -0
- package/dist/libs/tesouro-embedded-components-react/{team-widget → settings-widget/team}/feature/dist/index3.js +1 -1
- package/dist/libs/tesouro-embedded-components-react/{team-widget → settings-widget/team}/feature/dist/index4.js +2 -2
- package/dist/libs/tesouro-embedded-components-react/{team-widget → settings-widget/team}/feature/dist/index5.js +1 -1
- package/dist/libs/tesouro-embedded-components-react/{team-widget → settings-widget/team}/feature/dist/index6.js +1 -1
- package/dist/libs/tesouro-embedded-components-react/{team-widget → settings-widget/team}/feature/dist/index7.js +3 -3
- package/dist/libs/tesouro-embedded-components-react/{team-widget → settings-widget/team}/feature/dist/index8.js +1 -1
- package/dist/libs/tesouro-embedded-components-react/{team-widget → settings-widget/team}/feature/dist/index9.js +1 -1
- package/dist/libs/tesouro-embedded-components-react/{team-widget → settings-widget/team}/ui/dist/index10.js +5 -5
- package/dist/libs/tesouro-embedded-components-react/{team-widget → settings-widget/team}/ui/dist/index11.js +1 -1
- package/dist/libs/tesouro-embedded-components-react/{team-widget → settings-widget/team}/ui/dist/index12.js +4 -4
- package/dist/libs/tesouro-embedded-components-react/{team-widget → settings-widget/team}/ui/dist/index13.js +1 -1
- package/dist/libs/tesouro-embedded-components-react/{team-widget → settings-widget/team}/ui/dist/index14.js +2 -2
- package/dist/libs/tesouro-embedded-components-react/{team-widget → settings-widget/team}/ui/dist/index15.js +4 -4
- package/dist/libs/tesouro-embedded-components-react/{team-widget → settings-widget/team}/ui/dist/index16.js +5 -5
- package/dist/libs/tesouro-embedded-components-react/{team-widget → settings-widget/team}/ui/dist/index17.js +4 -4
- package/dist/libs/tesouro-embedded-components-react/{team-widget → settings-widget/team}/ui/dist/index18.js +2 -2
- package/dist/libs/tesouro-embedded-components-react/{team-widget → settings-widget/team}/ui/dist/index2.js +1 -1
- package/dist/libs/tesouro-embedded-components-react/{team-widget → settings-widget/team}/ui/dist/index3.js +2 -2
- package/dist/libs/tesouro-embedded-components-react/{team-widget → settings-widget/team}/ui/dist/index4.js +2 -2
- package/dist/libs/tesouro-embedded-components-react/{team-widget → settings-widget/team}/ui/dist/index5.js +3 -3
- package/dist/libs/tesouro-embedded-components-react/{team-widget → settings-widget/team}/ui/dist/index6.js +1 -1
- package/dist/libs/tesouro-embedded-components-react/{team-widget → settings-widget/team}/ui/dist/index7.js +2 -2
- package/dist/libs/tesouro-embedded-components-react/{team-widget → settings-widget/team}/ui/dist/index8.js +4 -4
- package/dist/libs/tesouro-embedded-components-react/{team-widget → settings-widget/team}/ui/dist/index9.js +1 -1
- package/dist/libs/tesouro-embedded-components-react/shared/data-access/dist/lib/rest/zod.gen.js +12 -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/shared/feature/dist/lib/card/cardPresentation.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/libs/tesouro-embedded-components-react/team-widget/data-access/dist/index11.js +0 -3
- package/dist/libs/tesouro-embedded-components-react/team-widget/data-access/dist/index13.js +0 -24
- package/dist/libs/tesouro-embedded-components-react/team-widget/data-access/dist/index2.js +0 -10
- package/dist/libs/tesouro-embedded-components-react/team-widget/data-access/dist/index4.js +0 -29
- package/dist/libs/tesouro-embedded-components-react/team-widget/data-access/dist/index5.js +0 -10
- package/dist/libs/tesouro-embedded-components-react/team-widget/data-access/dist/index6.js +0 -10
- package/dist/libs/tesouro-embedded-components-react/team-widget/feature/dist/index2.js +0 -9
- /package/dist/libs/tesouro-embedded-components-react/{team-widget → settings-widget/team}/feature/dist/index.js +0 -0
- /package/dist/libs/tesouro-embedded-components-react/{team-widget → settings-widget/team}/ui/dist/index.js +0 -0
|
@@ -1,210 +1,57 @@
|
|
|
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 { 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 "./index47.js";
|
|
12
|
-
import { encodeFileToBase64 as l } from "./index53.js";
|
|
13
|
-
import { mapBillFormToPayload as u, mapLineItemsToPayload as d } from "./index54.js";
|
|
14
|
-
import { validateBillCompleteness as f, validateBillTotalIsPayable as p, validateBillTotals as m, validateLineItems as h, validateStoredAmountDue as ee } from "./index55.js";
|
|
15
|
-
import { useCallback as g, useRef as _, useState as v } from "react";
|
|
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";
|
|
16
3
|
//#region ../../libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index56.js
|
|
17
|
-
var
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
counterpart_id: "vendor"
|
|
22
|
-
}, b = { tax_amount: "tax" };
|
|
23
|
-
function x(e) {
|
|
24
|
-
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;
|
|
25
8
|
}
|
|
26
|
-
function
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
for (let a of e) {
|
|
32
|
-
let e = a.loc[0] ?? t.unknownValidationField, o = y[e], s = b[e], c = x(a) ? t.requiredField : a.msg;
|
|
33
|
-
o ? n[o] = c : s ? r[s] = c : i.push(t.unmappedValidationError(e, c));
|
|
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);
|
|
34
14
|
}
|
|
35
|
-
return
|
|
36
|
-
formErrors: n,
|
|
37
|
-
totalsErrors: Object.keys(r).length ? r : void 0
|
|
38
|
-
};
|
|
15
|
+
return Object.keys(a).length ? a : void 0;
|
|
39
16
|
}
|
|
40
|
-
function
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
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
|
|
46
28
|
};
|
|
47
|
-
return n;
|
|
48
29
|
}
|
|
49
|
-
function
|
|
50
|
-
let
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
} : void 0,
|
|
75
|
-
document: t
|
|
76
|
-
}), r = P;
|
|
77
|
-
if (r ? await q.mutateAsync({
|
|
78
|
-
path: { payable_id: r },
|
|
79
|
-
body: n
|
|
80
|
-
}) : (r = (await G.mutateAsync({ body: n }))?.id, r && (N(r), E?.(r), t && I(void 0))), !r) throw Error("Payable was created without an id");
|
|
81
|
-
if (R) {
|
|
82
|
-
try {
|
|
83
|
-
await K.mutateAsync({ path: { payable_id: r } });
|
|
84
|
-
} catch {}
|
|
85
|
-
z(!1);
|
|
86
|
-
}
|
|
87
|
-
return await J.mutateAsync({
|
|
88
|
-
path: { payable_id: r },
|
|
89
|
-
body: { data: d(y.lineItems) }
|
|
90
|
-
}), r;
|
|
91
|
-
}, [
|
|
92
|
-
b,
|
|
93
|
-
x,
|
|
94
|
-
G,
|
|
95
|
-
K,
|
|
96
|
-
R,
|
|
97
|
-
y.discount,
|
|
98
|
-
y.isTotalsDirty,
|
|
99
|
-
y.lineItems,
|
|
100
|
-
y.tax,
|
|
101
|
-
y.totalOverride,
|
|
102
|
-
y.values,
|
|
103
|
-
E,
|
|
104
|
-
P,
|
|
105
|
-
J,
|
|
106
|
-
F,
|
|
107
|
-
q
|
|
108
|
-
]), ie = g(async () => {
|
|
109
|
-
P && (await K.mutateAsync({ path: { payable_id: P } }), z(!1));
|
|
110
|
-
}, [K, P]);
|
|
111
|
-
return {
|
|
112
|
-
saveDraft: g(async () => {
|
|
113
|
-
if (!U.current && Q()) {
|
|
114
|
-
U.current = !0, H("draft");
|
|
115
|
-
try {
|
|
116
|
-
let t = await w?.();
|
|
117
|
-
if (t && !t.ok) return;
|
|
118
|
-
let n = await $(t?.counterpartBankAccountId);
|
|
119
|
-
y.setErrors(void 0), T?.(n), O?.(n);
|
|
120
|
-
let r = await D?.();
|
|
121
|
-
return e.success(r === "draft" ? j.submittedDemoted : j.draftSaved), n;
|
|
122
|
-
} catch (e) {
|
|
123
|
-
y.setSaveFailureMessage(S(e) ? j.discountTaxBlockedByLineItems : j.saveFailed), W();
|
|
124
|
-
return;
|
|
125
|
-
} finally {
|
|
126
|
-
H(void 0), U.current = !1;
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
}, [
|
|
130
|
-
y,
|
|
131
|
-
Q,
|
|
132
|
-
j.discountTaxBlockedByLineItems,
|
|
133
|
-
j.draftSaved,
|
|
134
|
-
j.saveFailed,
|
|
135
|
-
j.submittedDemoted,
|
|
136
|
-
O,
|
|
137
|
-
T,
|
|
138
|
-
D,
|
|
139
|
-
w,
|
|
140
|
-
$,
|
|
141
|
-
W
|
|
142
|
-
]),
|
|
143
|
-
finalize: g(async () => {
|
|
144
|
-
if (U.current) return;
|
|
145
|
-
let t = h(y.lineItems, j), n = Z(), r = p(y.total, j), i = y.isTotalsDirty ? ee(y.totalOverride, y.discount, j) : void 0, a = n || r || i ? {
|
|
146
|
-
...i,
|
|
147
|
-
...r,
|
|
148
|
-
...n
|
|
149
|
-
} : void 0, { formErrors: o, lineItemErrors: s } = f(y.values, b, y.lineItems, j), c = te(s, t);
|
|
150
|
-
y.setLineItemErrors(c), y.setTotalsErrors(a);
|
|
151
|
-
let l = o ?? {};
|
|
152
|
-
if (y.setErrors(Object.keys(l).length ? l : void 0), t && e.error(j.lineItemsNeedAttention), c || a || Object.keys(l).length) {
|
|
153
|
-
W();
|
|
154
|
-
return;
|
|
155
|
-
}
|
|
156
|
-
U.current = !0, H("finalize");
|
|
157
|
-
try {
|
|
158
|
-
let t;
|
|
159
|
-
try {
|
|
160
|
-
let e = await w?.();
|
|
161
|
-
if (e && !e.ok) return;
|
|
162
|
-
t = await $(e?.counterpartBankAccountId);
|
|
163
|
-
} catch (e) {
|
|
164
|
-
y.setSaveFailureMessage(S(e) ? j.discountTaxBlockedByLineItems : j.saveFailed), W();
|
|
165
|
-
return;
|
|
166
|
-
}
|
|
167
|
-
T?.(t);
|
|
168
|
-
try {
|
|
169
|
-
let n = await Y.mutateAsync({ path: { payable_id: t } });
|
|
170
|
-
if (n.validation_errors.length) {
|
|
171
|
-
let e = C(n.validation_errors, j);
|
|
172
|
-
y.setErrors(e.formErrors), y.setTotalsErrors(e.totalsErrors), W();
|
|
173
|
-
return;
|
|
174
|
-
}
|
|
175
|
-
await X.mutateAsync({ path: { payable_id: t } }), y.setErrors(void 0), k?.(t), e.success(j.billFinalized);
|
|
176
|
-
} catch {
|
|
177
|
-
y.setSaveFailureMessage(j.finalizeFailed), W();
|
|
178
|
-
}
|
|
179
|
-
} finally {
|
|
180
|
-
H(void 0), U.current = !1;
|
|
181
|
-
}
|
|
182
|
-
}, [
|
|
183
|
-
b,
|
|
184
|
-
y,
|
|
185
|
-
j,
|
|
186
|
-
k,
|
|
187
|
-
T,
|
|
188
|
-
w,
|
|
189
|
-
$,
|
|
190
|
-
W,
|
|
191
|
-
X,
|
|
192
|
-
Z,
|
|
193
|
-
Y
|
|
194
|
-
]),
|
|
195
|
-
payableId: P,
|
|
196
|
-
isSavingDraft: V === "draft",
|
|
197
|
-
isFinalizing: V === "finalize",
|
|
198
|
-
stagedFile: F,
|
|
199
|
-
stageFile: I,
|
|
200
|
-
clearStagedFile: L,
|
|
201
|
-
scrollToErrorToken: ne,
|
|
202
|
-
isFileDeletionPending: R,
|
|
203
|
-
requestFileDeletion: B,
|
|
204
|
-
detachFileNow: ie,
|
|
205
|
-
isDeletingFile: K.isPending,
|
|
206
|
-
hasFileDeletionFailed: K.isError
|
|
207
|
-
};
|
|
30
|
+
function c(e) {
|
|
31
|
+
let t = e.trim();
|
|
32
|
+
if (!t) return !0;
|
|
33
|
+
let n = t.startsWith("-") ? t.slice(1) : t;
|
|
34
|
+
return i.test(n) ? Number(t.replaceAll(",", "")) <= 0 : !1;
|
|
35
|
+
}
|
|
36
|
+
function l(e, t) {
|
|
37
|
+
if (n(e) === null) return c(e) ? t.totalNotGreaterThanZero : t.unreadableTotal;
|
|
38
|
+
}
|
|
39
|
+
function u(t, n = e) {
|
|
40
|
+
let r = l(t, n);
|
|
41
|
+
return r ? { total: r } : void 0;
|
|
42
|
+
}
|
|
43
|
+
function d(t, r, i = e) {
|
|
44
|
+
if (t === void 0) return;
|
|
45
|
+
let a = n(t);
|
|
46
|
+
if (a !== null) return a - (n(r) ?? 0) > 0 ? void 0 : { total: i.totalNotGreaterThanZero };
|
|
47
|
+
}
|
|
48
|
+
function f(t, n, r, i = e) {
|
|
49
|
+
let o = {};
|
|
50
|
+
if (a(t) || (o.discount = i.unreadableDiscount), a(n) || (o.tax = i.unreadableTax), r !== void 0) {
|
|
51
|
+
let e = l(r, i);
|
|
52
|
+
e && (o.total = e);
|
|
53
|
+
}
|
|
54
|
+
return Object.keys(o).length ? o : void 0;
|
|
208
55
|
}
|
|
209
56
|
//#endregion
|
|
210
|
-
export {
|
|
57
|
+
export { a as isReadableMoneyOrZero, s as validateBillCompleteness, u as validateBillTotalIsPayable, f as validateBillTotals, o as validateLineItems, d as validateStoredAmountDue };
|
|
@@ -1,39 +1,210 @@
|
|
|
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 { 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 l } from "./index54.js";
|
|
13
|
+
import { mapBillFormToPayload as u, mapLineItemsToPayload as d } from "./index55.js";
|
|
14
|
+
import { validateBillCompleteness as f, validateBillTotalIsPayable as p, validateBillTotals as m, validateLineItems as h, validateStoredAmountDue as ee } from "./index56.js";
|
|
15
|
+
import { useCallback as g, useRef as _, useState as v } from "react";
|
|
2
16
|
//#region ../../libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index57.js
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
17
|
+
var y = {
|
|
18
|
+
document_id: "invoiceNumber",
|
|
19
|
+
issued_at: "invoiceDate",
|
|
20
|
+
due_date: "dueDate",
|
|
21
|
+
counterpart_id: "vendor"
|
|
22
|
+
}, b = { tax_amount: "tax" };
|
|
23
|
+
function x(e) {
|
|
24
|
+
return e.type === "type_error.none.not_allowed" || e.msg === "none is not an allowed value";
|
|
25
|
+
}
|
|
26
|
+
function S(e) {
|
|
27
|
+
return !!t(e)?.includes("line_items_enabled");
|
|
28
|
+
}
|
|
29
|
+
function C(e, t = c) {
|
|
30
|
+
let n = {}, r = {}, i = [];
|
|
31
|
+
for (let a of e) {
|
|
32
|
+
let e = a.loc[0] ?? t.unknownValidationField, o = y[e], s = b[e], c = x(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
|
|
11
38
|
};
|
|
12
39
|
}
|
|
13
|
-
function
|
|
14
|
-
|
|
40
|
+
function te(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]
|
|
46
|
+
};
|
|
47
|
+
return n;
|
|
15
48
|
}
|
|
16
|
-
function
|
|
17
|
-
let
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
49
|
+
function w({ payableId: t, form: y, counterpartId: b, clearCounterpart: x, prepareVendorForSave: w, onSaved: T, onPayableCreated: E, readSavedStatus: D, onDraftSaved: O, onFinalized: k, labels: A }) {
|
|
50
|
+
let j = {
|
|
51
|
+
...c,
|
|
52
|
+
...A
|
|
53
|
+
}, [M, N] = v(), P = t ?? M, [F, I] = v(), L = g(() => I(void 0), []), [R, z] = v(!1), B = g(() => z(!0), []), [V, H] = v(), U = _(!1), [ne, re] = v(0), W = g(() => re((e) => e + 1), []), G = r(), K = i(), q = o(), J = n(), Y = s(), X = a(), Z = g(() => y.isTotalsDirty ? m(y.discount, y.tax, y.totalOverride, j) : void 0, [y, j]), Q = g(() => {
|
|
54
|
+
let t = h(y.lineItems, j), n = Z();
|
|
55
|
+
return y.setLineItemErrors(t), y.setTotalsErrors(n), !t && !n || (y.setErrors(void 0), t && e.error(j.lineItemsNeedAttention), W(), !1);
|
|
56
|
+
}, [
|
|
57
|
+
y,
|
|
58
|
+
j,
|
|
59
|
+
W,
|
|
60
|
+
Z
|
|
61
|
+
]), $ = g(async (e) => {
|
|
62
|
+
let t = !P && F ? {
|
|
63
|
+
base64EncodedFile: await l(F),
|
|
64
|
+
fileName: F.name
|
|
65
|
+
} : void 0, n = u({
|
|
66
|
+
values: y.values,
|
|
67
|
+
counterpartId: b,
|
|
68
|
+
clearCounterpart: x,
|
|
69
|
+
counterpartBankAccountId: e,
|
|
70
|
+
editedTotals: y.isTotalsDirty ? {
|
|
71
|
+
discount: y.discount,
|
|
72
|
+
tax: y.tax,
|
|
73
|
+
total: y.totalOverride
|
|
74
|
+
} : void 0,
|
|
75
|
+
document: t
|
|
76
|
+
}), r = P;
|
|
77
|
+
if (r ? await q.mutateAsync({
|
|
78
|
+
path: { payable_id: r },
|
|
79
|
+
body: n
|
|
80
|
+
}) : (r = (await G.mutateAsync({ body: n }))?.id, r && (N(r), E?.(r), t && I(void 0))), !r) throw Error("Payable was created without an id");
|
|
81
|
+
if (R) {
|
|
82
|
+
try {
|
|
83
|
+
await K.mutateAsync({ path: { payable_id: r } });
|
|
84
|
+
} catch {}
|
|
85
|
+
z(!1);
|
|
86
|
+
}
|
|
87
|
+
return await J.mutateAsync({
|
|
88
|
+
path: { payable_id: r },
|
|
89
|
+
body: { data: d(y.lineItems) }
|
|
90
|
+
}), r;
|
|
91
|
+
}, [
|
|
92
|
+
b,
|
|
93
|
+
x,
|
|
94
|
+
G,
|
|
95
|
+
K,
|
|
96
|
+
R,
|
|
97
|
+
y.discount,
|
|
98
|
+
y.isTotalsDirty,
|
|
99
|
+
y.lineItems,
|
|
100
|
+
y.tax,
|
|
101
|
+
y.totalOverride,
|
|
102
|
+
y.values,
|
|
103
|
+
E,
|
|
104
|
+
P,
|
|
105
|
+
J,
|
|
106
|
+
F,
|
|
107
|
+
q
|
|
108
|
+
]), ie = g(async () => {
|
|
109
|
+
P && (await K.mutateAsync({ path: { payable_id: P } }), z(!1));
|
|
110
|
+
}, [K, P]);
|
|
30
111
|
return {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
112
|
+
saveDraft: g(async () => {
|
|
113
|
+
if (!U.current && Q()) {
|
|
114
|
+
U.current = !0, H("draft");
|
|
115
|
+
try {
|
|
116
|
+
let t = await w?.();
|
|
117
|
+
if (t && !t.ok) return;
|
|
118
|
+
let n = await $(t?.counterpartBankAccountId);
|
|
119
|
+
y.setErrors(void 0), T?.(n), O?.(n);
|
|
120
|
+
let r = await D?.();
|
|
121
|
+
return e.success(r === "draft" ? j.submittedDemoted : j.draftSaved), n;
|
|
122
|
+
} catch (e) {
|
|
123
|
+
y.setSaveFailureMessage(S(e) ? j.discountTaxBlockedByLineItems : j.saveFailed), W();
|
|
124
|
+
return;
|
|
125
|
+
} finally {
|
|
126
|
+
H(void 0), U.current = !1;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
}, [
|
|
130
|
+
y,
|
|
131
|
+
Q,
|
|
132
|
+
j.discountTaxBlockedByLineItems,
|
|
133
|
+
j.draftSaved,
|
|
134
|
+
j.saveFailed,
|
|
135
|
+
j.submittedDemoted,
|
|
136
|
+
O,
|
|
137
|
+
T,
|
|
138
|
+
D,
|
|
139
|
+
w,
|
|
140
|
+
$,
|
|
141
|
+
W
|
|
142
|
+
]),
|
|
143
|
+
finalize: g(async () => {
|
|
144
|
+
if (U.current) return;
|
|
145
|
+
let t = h(y.lineItems, j), n = Z(), r = p(y.total, j), i = y.isTotalsDirty ? ee(y.totalOverride, y.discount, j) : void 0, a = n || r || i ? {
|
|
146
|
+
...i,
|
|
147
|
+
...r,
|
|
148
|
+
...n
|
|
149
|
+
} : void 0, { formErrors: o, lineItemErrors: s } = f(y.values, b, y.lineItems, j), c = te(s, t);
|
|
150
|
+
y.setLineItemErrors(c), y.setTotalsErrors(a);
|
|
151
|
+
let l = o ?? {};
|
|
152
|
+
if (y.setErrors(Object.keys(l).length ? l : void 0), t && e.error(j.lineItemsNeedAttention), c || a || Object.keys(l).length) {
|
|
153
|
+
W();
|
|
154
|
+
return;
|
|
155
|
+
}
|
|
156
|
+
U.current = !0, H("finalize");
|
|
157
|
+
try {
|
|
158
|
+
let t;
|
|
159
|
+
try {
|
|
160
|
+
let e = await w?.();
|
|
161
|
+
if (e && !e.ok) return;
|
|
162
|
+
t = await $(e?.counterpartBankAccountId);
|
|
163
|
+
} catch (e) {
|
|
164
|
+
y.setSaveFailureMessage(S(e) ? j.discountTaxBlockedByLineItems : j.saveFailed), W();
|
|
165
|
+
return;
|
|
166
|
+
}
|
|
167
|
+
T?.(t);
|
|
168
|
+
try {
|
|
169
|
+
let n = await Y.mutateAsync({ path: { payable_id: t } });
|
|
170
|
+
if (n.validation_errors.length) {
|
|
171
|
+
let e = C(n.validation_errors, j);
|
|
172
|
+
y.setErrors(e.formErrors), y.setTotalsErrors(e.totalsErrors), W();
|
|
173
|
+
return;
|
|
174
|
+
}
|
|
175
|
+
await X.mutateAsync({ path: { payable_id: t } }), y.setErrors(void 0), k?.(t), e.success(j.billFinalized);
|
|
176
|
+
} catch {
|
|
177
|
+
y.setSaveFailureMessage(j.finalizeFailed), W();
|
|
178
|
+
}
|
|
179
|
+
} finally {
|
|
180
|
+
H(void 0), U.current = !1;
|
|
181
|
+
}
|
|
182
|
+
}, [
|
|
183
|
+
b,
|
|
184
|
+
y,
|
|
185
|
+
j,
|
|
186
|
+
k,
|
|
187
|
+
T,
|
|
188
|
+
w,
|
|
189
|
+
$,
|
|
190
|
+
W,
|
|
191
|
+
X,
|
|
192
|
+
Z,
|
|
193
|
+
Y
|
|
194
|
+
]),
|
|
195
|
+
payableId: P,
|
|
196
|
+
isSavingDraft: V === "draft",
|
|
197
|
+
isFinalizing: V === "finalize",
|
|
198
|
+
stagedFile: F,
|
|
199
|
+
stageFile: I,
|
|
200
|
+
clearStagedFile: L,
|
|
201
|
+
scrollToErrorToken: ne,
|
|
202
|
+
isFileDeletionPending: R,
|
|
203
|
+
requestFileDeletion: B,
|
|
204
|
+
detachFileNow: ie,
|
|
205
|
+
isDeletingFile: K.isPending,
|
|
206
|
+
hasFileDeletionFailed: K.isError
|
|
36
207
|
};
|
|
37
208
|
}
|
|
38
209
|
//#endregion
|
|
39
|
-
export {
|
|
210
|
+
export { C as mapValidationErrorsToForm, w as useBillCreateController };
|