@tesouro/embedded-components-react 0.2.264 → 0.2.267
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 +8 -6
- package/dist/experimental/WidgetSuite.d.ts +93 -2
- package/dist/experimental/WidgetSuite.js +5 -5
- package/dist/experimental/index.d.ts +93 -2
- package/dist/experimental/index.js +5 -5
- package/dist/index.css +45 -9
- package/dist/index.d.ts +29 -9
- package/dist/index.js +2 -2
- package/dist/lib/AcceptDisclosuresWidget.d.ts +17 -5
- package/dist/lib/AcceptDisclosuresWidget.js +1 -1
- package/dist/lib/BillPayWidget.js +1 -1
- package/dist/lib/WidgetProvider.d.ts +12 -4
- package/dist/libs/tesouro-embedded-components-react/accept-disclosures-widget/data-access/dist/index2.js +3 -3
- package/dist/libs/tesouro-embedded-components-react/accept-disclosures-widget/feature/dist/index3.js +1 -1
- package/dist/libs/tesouro-embedded-components-react/accept-disclosures-widget/feature/dist/index4.js +36 -34
- package/dist/libs/tesouro-embedded-components-react/accept-disclosures-widget/ui/dist/index.js +2 -2
- package/dist/libs/tesouro-embedded-components-react/accept-disclosures-widget/ui/dist/{index3.js → lib/AcceptDisclosuresWidget/AcceptDisclosuresWidget.js} +3 -3
- package/dist/libs/tesouro-embedded-components-react/accept-disclosures-widget/ui/dist/{index2.js → lib/AcceptDisclosuresWidget/labels.js} +1 -1
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index.js +6 -6
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index10.js +99 -7
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index11.js +7 -97
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index12.js +99 -4
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index13.js +4 -4
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index14.js +2 -41
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index15.js +43 -1
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index16.js +1 -50
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index17.js +48 -6
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index18.js +9 -5
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index19.js +8 -91
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index2.js +6 -2
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index20.js +7 -3
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index21.js +100 -6
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index22.js +3 -9
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index23.js +6 -83
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index24.js +9 -3
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index25.js +83 -6
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index26.js +2 -111
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index27.js +8 -1
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index28.js +103 -16
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index29.js +1 -0
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index30.js +25 -0
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index6.js +37 -27
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index7.js +15 -116
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index8.js +126 -31
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index9.js +32 -69
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index12.js +0 -3
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index13.js +34 -69
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index15.js +4 -0
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index16.js +261 -181
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index28.js +32 -33
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index7.js +2 -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/widget-suite/feature/dist/index.js +5 -5
- package/dist/libs/tesouro-embedded-components-react/widget-suite/feature/dist/index3.js +4 -15
- package/dist/libs/tesouro-embedded-components-react/widget-suite/feature/dist/index4.js +26 -91
- package/dist/libs/tesouro-embedded-components-react/widget-suite/feature/dist/index5.js +87 -74
- package/dist/libs/tesouro-embedded-components-react/widget-suite/feature/dist/index6.js +142 -0
- package/dist/libs/tesouro-embedded-components-react/widget-suite/ui/dist/index2.js +1 -0
- package/dist/libs/tesouro-embedded-components-react/widget-suite/ui/dist/index3.js +49 -33
- package/package.json +1 -1
|
@@ -1,112 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
"use client";
|
|
3
|
-
"use client";
|
|
4
|
-
"use client";
|
|
5
|
-
import { hasAnyScope as e } from "../../../shared/data-access/dist/lib/hasAnyScope.js";
|
|
6
|
-
import { Scope as t } from "../../../shared/data-access/dist/lib/scopes.js";
|
|
7
|
-
import "../../../shared/data-access/dist/index.js";
|
|
8
|
-
import { EmbeddedToaster as n } from "../../../shared/ui/dist/lib/EmbeddedToaster.js";
|
|
9
|
-
import "../../../shared/ui/dist/index.js";
|
|
10
|
-
import { useAnalyticsTrack as r } from "../../../shared/feature/dist/lib/analytics/hooks.js";
|
|
11
|
-
import { WidgetProvider as i } from "../../../shared/feature/dist/lib/WidgetProvider/WidgetProvider.js";
|
|
12
|
-
import { useWidgetConfig as a } from "../../../shared/feature/dist/lib/WidgetProvider/hooks.js";
|
|
13
|
-
import "../../../shared/feature/dist/index.js";
|
|
14
|
-
import { BillPayWidgetUi as o } from "../../ui/dist/index31.js";
|
|
15
|
-
import { BillUploadStatusTray as s } from "../../ui/dist/index41.js";
|
|
16
|
-
import "../../ui/dist/index.js";
|
|
17
|
-
import { billsTabTestIds as c } from "./index18.js";
|
|
18
|
-
import { BillsTab as l } from "./index19.js";
|
|
19
|
-
import "./index20.js";
|
|
20
|
-
import { useBillUploadQueue as u } from "./index23.js";
|
|
1
|
+
import "./index23.js";
|
|
21
2
|
import "./index24.js";
|
|
22
|
-
import
|
|
23
|
-
import { DEFAULT_TABS_LABELS as p } from "./index25.js";
|
|
24
|
-
import { ApprovalPoliciesSettings as m } from "../../../shared/approval-policy/feature/dist/lib/ApprovalPoliciesSettings.js";
|
|
25
|
-
import "../../../shared/approval-policy/feature/dist/index.js";
|
|
26
|
-
import { CounterpartsWidget as h } from "../../../counterparts-widget/feature/dist/index8.js";
|
|
27
|
-
import "../../../counterparts-widget/feature/dist/index.js";
|
|
28
|
-
import { useCallback as g, useEffect as _, useState as v } from "react";
|
|
29
|
-
import { Fragment as y, jsx as b, jsxs as x } from "react/jsx-runtime";
|
|
30
|
-
//#region ../../libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index26.js
|
|
31
|
-
var S = {
|
|
32
|
-
Bills: "bills",
|
|
33
|
-
Vendors: "vendors",
|
|
34
|
-
Settings: "settings"
|
|
35
|
-
}, C = [
|
|
36
|
-
S.Bills,
|
|
37
|
-
S.Vendors,
|
|
38
|
-
S.Settings
|
|
39
|
-
];
|
|
40
|
-
function w({ labels: i, tabsLabels: f, approvalPolicyLabels: w, approvalPolicyComponentLabels: T, vendorLabels: E }) {
|
|
41
|
-
let D = r();
|
|
42
|
-
_(() => {
|
|
43
|
-
D(d.Mounted);
|
|
44
|
-
}, [D]);
|
|
45
|
-
let O = {
|
|
46
|
-
...p,
|
|
47
|
-
...f
|
|
48
|
-
}, { initResponse: k } = a(), A = e(k?.scopes, [t.ApprovalPolicyWriteOrg]), j = !k || A, [M, N] = v(S.Bills), [P, F] = v(), I = g((e) => {
|
|
49
|
-
N(S.Bills), F(e);
|
|
50
|
-
}, []), L = u({ onOpenBill: I }), R = [{
|
|
51
|
-
id: S.Bills,
|
|
52
|
-
label: O.bills,
|
|
53
|
-
content: /* @__PURE__ */ b(l, {
|
|
54
|
-
onEnqueueFiles: L.enqueue,
|
|
55
|
-
openPayableId: P,
|
|
56
|
-
onOpenPayableHandled: () => F(void 0)
|
|
57
|
-
})
|
|
58
|
-
}, {
|
|
59
|
-
id: S.Vendors,
|
|
60
|
-
label: O.vendors,
|
|
61
|
-
content: /* @__PURE__ */ b(h, {
|
|
62
|
-
...E,
|
|
63
|
-
counterpartType: "vendor",
|
|
64
|
-
showTitle: !1,
|
|
65
|
-
onViewAllDocuments: () => N(S.Bills)
|
|
66
|
-
})
|
|
67
|
-
}];
|
|
68
|
-
j && R.push({
|
|
69
|
-
id: S.Settings,
|
|
70
|
-
label: O.settings,
|
|
71
|
-
content: /* @__PURE__ */ b(m, {
|
|
72
|
-
labels: w,
|
|
73
|
-
componentLabels: T
|
|
74
|
-
})
|
|
75
|
-
});
|
|
76
|
-
let z = R.some((e) => e.id === M) ? M : C.find((e) => R.some((t) => t.id === e)) ?? R[0]?.id ?? "";
|
|
77
|
-
return /* @__PURE__ */ x(y, { children: [
|
|
78
|
-
/* @__PURE__ */ b(n, {}),
|
|
79
|
-
/* @__PURE__ */ b(o, {
|
|
80
|
-
labels: i,
|
|
81
|
-
tabs: R,
|
|
82
|
-
selectedTabId: z,
|
|
83
|
-
onTabChange: N
|
|
84
|
-
}),
|
|
85
|
-
L.isVisible ? /* @__PURE__ */ b(s, {
|
|
86
|
-
sections: L.sections,
|
|
87
|
-
summaryLabel: L.summaryLabel,
|
|
88
|
-
collapsed: L.collapsed,
|
|
89
|
-
onToggleCollapsed: L.onToggleCollapsed,
|
|
90
|
-
onClose: L.onClose,
|
|
91
|
-
testId: c.uploadTray
|
|
92
|
-
}) : null
|
|
93
|
-
] });
|
|
94
|
-
}
|
|
95
|
-
function T({ baseUrl: e, widgetToken: t, organizationId: n, configClient: r, linkComponent: a, implementation: o, uiFramework: s, errorFallback: c, onError: l, analytics: u, ...d }) {
|
|
96
|
-
return /* @__PURE__ */ b(i, {
|
|
97
|
-
widgetName: f,
|
|
98
|
-
baseUrl: e,
|
|
99
|
-
widgetToken: t,
|
|
100
|
-
organizationId: n,
|
|
101
|
-
configClient: r,
|
|
102
|
-
linkComponent: a,
|
|
103
|
-
implementation: o,
|
|
104
|
-
uiFramework: s,
|
|
105
|
-
errorFallback: c,
|
|
106
|
-
onError: l,
|
|
107
|
-
analytics: u,
|
|
108
|
-
children: /* @__PURE__ */ b(w, { ...d })
|
|
109
|
-
});
|
|
110
|
-
}
|
|
111
|
-
//#endregion
|
|
112
|
-
export { T as BillPayWidgetNative, T as default };
|
|
3
|
+
import "./index25.js";
|
|
@@ -2,24 +2,111 @@
|
|
|
2
2
|
"use client";
|
|
3
3
|
"use client";
|
|
4
4
|
"use client";
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
5
|
+
import { hasAnyScope as e } from "../../../shared/data-access/dist/lib/hasAnyScope.js";
|
|
6
|
+
import { Scope as t } from "../../../shared/data-access/dist/lib/scopes.js";
|
|
7
|
+
import "../../../shared/data-access/dist/index.js";
|
|
8
|
+
import { EmbeddedToaster as n } from "../../../shared/ui/dist/lib/EmbeddedToaster.js";
|
|
9
|
+
import "../../../shared/ui/dist/index.js";
|
|
10
|
+
import { useAnalyticsTrack as r } from "../../../shared/feature/dist/lib/analytics/hooks.js";
|
|
11
|
+
import { WidgetProvider as i } from "../../../shared/feature/dist/lib/WidgetProvider/WidgetProvider.js";
|
|
12
|
+
import { useWidgetConfig as a } from "../../../shared/feature/dist/lib/WidgetProvider/hooks.js";
|
|
7
13
|
import "../../../shared/feature/dist/index.js";
|
|
8
|
-
import {
|
|
9
|
-
import "
|
|
10
|
-
import
|
|
11
|
-
import "./
|
|
12
|
-
import {
|
|
14
|
+
import { BillPayWidgetUi as o } from "../../ui/dist/index31.js";
|
|
15
|
+
import { BillUploadStatusTray as s } from "../../ui/dist/index41.js";
|
|
16
|
+
import "../../ui/dist/index.js";
|
|
17
|
+
import { billsTabTestIds as c } from "./index20.js";
|
|
18
|
+
import { BillsTab as l } from "./index21.js";
|
|
19
|
+
import "./index22.js";
|
|
20
|
+
import { useBillUploadQueue as u } from "./index25.js";
|
|
21
|
+
import "./index26.js";
|
|
22
|
+
import { BillPayWidgetAnalyticsEvent as d, WIDGET_NAME as f } from "./index14.js";
|
|
23
|
+
import { DEFAULT_TABS_LABELS as p } from "./index27.js";
|
|
24
|
+
import { ApprovalPoliciesSettings as m } from "../../../shared/approval-policy/feature/dist/lib/ApprovalPoliciesSettings.js";
|
|
25
|
+
import "../../../shared/approval-policy/feature/dist/index.js";
|
|
26
|
+
import { CounterpartsWidget as h } from "../../../counterparts-widget/feature/dist/index8.js";
|
|
27
|
+
import "../../../counterparts-widget/feature/dist/index.js";
|
|
28
|
+
import { useCallback as g, useEffect as _, useState as v } from "react";
|
|
29
|
+
import { Fragment as y, jsx as b, jsxs as x } from "react/jsx-runtime";
|
|
13
30
|
//#region ../../libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index28.js
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
31
|
+
var S = {
|
|
32
|
+
Bills: "bills",
|
|
33
|
+
Vendors: "vendors",
|
|
34
|
+
Settings: "settings"
|
|
35
|
+
}, C = [
|
|
36
|
+
S.Bills,
|
|
37
|
+
S.Vendors,
|
|
38
|
+
S.Settings
|
|
39
|
+
];
|
|
40
|
+
function w({ labels: i, tabsLabels: f, approvalPolicyLabels: w, approvalPolicyComponentLabels: T, vendorLabels: E }) {
|
|
41
|
+
let D = r();
|
|
42
|
+
_(() => {
|
|
43
|
+
D(d.Mounted);
|
|
44
|
+
}, [D]);
|
|
45
|
+
let O = {
|
|
46
|
+
...p,
|
|
47
|
+
...f
|
|
48
|
+
}, { initResponse: k } = a(), A = e(k?.scopes, [t.ApprovalPolicyWriteOrg]), j = !k || A, [M, N] = v(S.Bills), [P, F] = v(), I = g((e) => {
|
|
49
|
+
N(S.Bills), F(e);
|
|
50
|
+
}, []), L = u({ onOpenBill: I }), R = [{
|
|
51
|
+
id: S.Bills,
|
|
52
|
+
label: O.bills,
|
|
53
|
+
content: /* @__PURE__ */ b(l, {
|
|
54
|
+
onEnqueueFiles: L.enqueue,
|
|
55
|
+
openPayableId: P,
|
|
56
|
+
onOpenPayableHandled: () => F(void 0)
|
|
57
|
+
})
|
|
58
|
+
}, {
|
|
59
|
+
id: S.Vendors,
|
|
60
|
+
label: O.vendors,
|
|
61
|
+
content: /* @__PURE__ */ b(h, {
|
|
62
|
+
...E,
|
|
63
|
+
counterpartType: "vendor",
|
|
64
|
+
showTitle: !1,
|
|
65
|
+
onViewAllDocuments: () => N(S.Bills)
|
|
66
|
+
})
|
|
67
|
+
}];
|
|
68
|
+
j && R.push({
|
|
69
|
+
id: S.Settings,
|
|
70
|
+
label: O.settings,
|
|
71
|
+
content: /* @__PURE__ */ b(m, {
|
|
72
|
+
labels: w,
|
|
73
|
+
componentLabels: T
|
|
74
|
+
})
|
|
75
|
+
});
|
|
76
|
+
let z = R.some((e) => e.id === M) ? M : C.find((e) => R.some((t) => t.id === e)) ?? R[0]?.id ?? "";
|
|
77
|
+
return /* @__PURE__ */ x(y, { children: [
|
|
78
|
+
/* @__PURE__ */ b(n, {}),
|
|
79
|
+
/* @__PURE__ */ b(o, {
|
|
80
|
+
labels: i,
|
|
81
|
+
tabs: R,
|
|
82
|
+
selectedTabId: z,
|
|
83
|
+
onTabChange: N
|
|
84
|
+
}),
|
|
85
|
+
L.isVisible ? /* @__PURE__ */ b(s, {
|
|
86
|
+
sections: L.sections,
|
|
87
|
+
summaryLabel: L.summaryLabel,
|
|
88
|
+
collapsed: L.collapsed,
|
|
89
|
+
onToggleCollapsed: L.onToggleCollapsed,
|
|
90
|
+
onClose: L.onClose,
|
|
91
|
+
testId: c.uploadTray
|
|
92
|
+
}) : null
|
|
93
|
+
] });
|
|
94
|
+
}
|
|
95
|
+
function T({ baseUrl: e, widgetToken: t, organizationId: n, configClient: r, linkComponent: a, implementation: o, uiFramework: s, errorFallback: c, onError: l, analytics: u, ...d }) {
|
|
96
|
+
return /* @__PURE__ */ b(i, {
|
|
97
|
+
widgetName: f,
|
|
98
|
+
baseUrl: e,
|
|
99
|
+
widgetToken: t,
|
|
100
|
+
organizationId: n,
|
|
101
|
+
configClient: r,
|
|
102
|
+
linkComponent: a,
|
|
103
|
+
implementation: o,
|
|
104
|
+
uiFramework: s,
|
|
105
|
+
errorFallback: c,
|
|
106
|
+
onError: l,
|
|
107
|
+
analytics: u,
|
|
108
|
+
children: /* @__PURE__ */ b(w, { ...d })
|
|
22
109
|
});
|
|
23
110
|
}
|
|
24
111
|
//#endregion
|
|
25
|
-
export {
|
|
112
|
+
export { T as BillPayWidgetNative, T as default };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import "./index28.js";
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
"use client";
|
|
3
|
+
"use client";
|
|
4
|
+
"use client";
|
|
5
|
+
import { Implementation as e } from "../../../shared/feature/dist/lib/WidgetProvider/types.js";
|
|
6
|
+
import { useWidgetConfig as t } from "../../../shared/feature/dist/lib/WidgetProvider/hooks.js";
|
|
7
|
+
import "../../../shared/feature/dist/index.js";
|
|
8
|
+
import { BillPayWidgetMonite as n } from "./index15.js";
|
|
9
|
+
import "./index16.js";
|
|
10
|
+
import { BillPayWidgetNative as r } from "./index28.js";
|
|
11
|
+
import "./index29.js";
|
|
12
|
+
import { jsx as i } from "react/jsx-runtime";
|
|
13
|
+
//#region ../../libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index30.js
|
|
14
|
+
function a({ implementation: a, ...o }) {
|
|
15
|
+
let s = t().implementation, c = a ?? s ?? e.Monite;
|
|
16
|
+
return c === e.Native ? /* @__PURE__ */ i(r, {
|
|
17
|
+
implementation: c,
|
|
18
|
+
...o
|
|
19
|
+
}) : /* @__PURE__ */ i(n, {
|
|
20
|
+
implementation: c,
|
|
21
|
+
...o
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
//#endregion
|
|
25
|
+
export { a as BillPayWidget, a as default };
|
|
@@ -1,40 +1,50 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { parseDecimalAmountToMinorUnits as t } from "../../../shared/util/dist/lib/parseDecimalAmountToMinorUnits.js";
|
|
1
|
+
import { parseDecimalAmountToMinorUnits as e } from "../../../shared/util/dist/lib/parseDecimalAmountToMinorUnits.js";
|
|
3
2
|
import "../../data-access/dist/index.js";
|
|
4
3
|
//#region ../../libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index6.js
|
|
5
|
-
var
|
|
4
|
+
var t = "USD";
|
|
5
|
+
function n(n) {
|
|
6
|
+
return e(n, t);
|
|
7
|
+
}
|
|
6
8
|
function r(e) {
|
|
7
|
-
|
|
9
|
+
let t = e.trim();
|
|
10
|
+
if (!t) return null;
|
|
11
|
+
let n = Number(t);
|
|
12
|
+
return Number.isFinite(n) && n > 0 ? n : null;
|
|
8
13
|
}
|
|
9
14
|
function i(e) {
|
|
15
|
+
return !!(e.description.trim() || n(e.price) !== null || n(e.amount) !== null);
|
|
16
|
+
}
|
|
17
|
+
function a(e) {
|
|
18
|
+
return n(e) ?? 0;
|
|
19
|
+
}
|
|
20
|
+
function o(e) {
|
|
10
21
|
let t = Number.parseFloat(e);
|
|
11
22
|
return Number.isFinite(t) ? t : 0;
|
|
12
23
|
}
|
|
13
|
-
function
|
|
14
|
-
|
|
15
|
-
return r && (i.counterpart_id = r), e.invoiceNumber && (i.document_id = e.invoiceNumber), e.invoiceDate && (i.issued_at = e.invoiceDate), e.dueDate && (i.due_date = e.dueDate), t?.term_final && t.name && (i.payment_terms = {
|
|
16
|
-
name: t.name,
|
|
17
|
-
...t.description ? { description: t.description } : {},
|
|
18
|
-
...t.term_1 ? { term_1: t.term_1 } : {},
|
|
19
|
-
...t.term_2 ? { term_2: t.term_2 } : {},
|
|
20
|
-
term_final: t.term_final
|
|
21
|
-
}), i;
|
|
24
|
+
function s(e) {
|
|
25
|
+
return (e / 100).toFixed(2);
|
|
22
26
|
}
|
|
23
|
-
function
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
27
|
+
function c({ values: e, counterpartId: r, editedTotals: i }) {
|
|
28
|
+
let a = { currency: t };
|
|
29
|
+
return r && (a.counterpart_id = r), e.invoiceNumber && (a.document_id = e.invoiceNumber), e.invoiceDate && (a.issued_at = e.invoiceDate), e.dueDate && (a.due_date = e.dueDate), i && (a.discount = n(i.discount) ?? 0, a.tax_amount = n(i.tax) ?? 0, i.total !== void 0 && (a.total_amount = n(i.total) ?? 0)), a;
|
|
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
|
+
...t !== null && t !== o ? { subtotal: t } : {},
|
|
39
|
+
...e.glCode ? { ledger_account_id: e.glCode } : {}
|
|
40
|
+
};
|
|
41
|
+
});
|
|
30
42
|
}
|
|
31
|
-
function
|
|
32
|
-
|
|
33
|
-
return e(o / 100, { currencyCode: n });
|
|
43
|
+
function u(e, t) {
|
|
44
|
+
return s(Math.round(o(e) * a(t)));
|
|
34
45
|
}
|
|
35
|
-
function
|
|
36
|
-
|
|
37
|
-
return e(a / 100, { currencyCode: n });
|
|
46
|
+
function d(e, t, n) {
|
|
47
|
+
return s(e.reduce((e, t) => e + a(t.amount), 0) + a(t) - a(n));
|
|
38
48
|
}
|
|
39
49
|
//#endregion
|
|
40
|
-
export {
|
|
50
|
+
export { d as calculateTotal, u as displayLineAmount, i as isPersistableLineItem, c as mapBillFormToPayload, l as mapLineItemsToPayload, n as parseMoneyToMinorUnits, r as parseQuantity };
|
|
@@ -1,122 +1,21 @@
|
|
|
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 { BILL_CREATE_MESSAGE_LABELS_EN as t } from "./index2.js";
|
|
8
|
-
import { useReplacePayableLineItemsMutation as n } from "../../data-access/dist/index6.js";
|
|
9
|
-
import { useCreatePayableMutation as r, useSubmitPayableForApprovalMutation as i, useUpdatePayableMutation as a, useValidatePayableMutation as o } from "../../data-access/dist/index7.js";
|
|
10
|
-
import "../../data-access/dist/index.js";
|
|
11
|
-
import { mapBillFormToPayload as s, mapLineItemsToPayload as c } from "./index6.js";
|
|
12
|
-
import { useCallback as l, useRef as u, useState as d } from "react";
|
|
1
|
+
import { BILL_CREATE_MESSAGE_LABELS_EN as e } from "./index2.js";
|
|
2
|
+
import { parseMoneyToMinorUnits as t, parseQuantity as n } from "./index6.js";
|
|
13
3
|
//#region ../../libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index7.js
|
|
14
|
-
var
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
payment_terms: "paymentTerms"
|
|
19
|
-
};
|
|
20
|
-
function p(e) {
|
|
21
|
-
return e.type === "type_error.none.not_allowed" || e.msg === "none is not an allowed value";
|
|
4
|
+
var r = /^(?:\d{1,3}(?:,\d{3})+(?:\.\d+)?|\d+(?:\.\d+)?|\.\d+)$/;
|
|
5
|
+
function i(e) {
|
|
6
|
+
let n = e.trim();
|
|
7
|
+
return !n || t(n) !== null ? !0 : r.test(n) ? Number(n.replaceAll(",", "")) === 0 : !1;
|
|
22
8
|
}
|
|
23
|
-
function
|
|
24
|
-
let
|
|
25
|
-
for (let
|
|
26
|
-
let
|
|
27
|
-
|
|
9
|
+
function a(r, i = e) {
|
|
10
|
+
let a = {};
|
|
11
|
+
for (let e of r) {
|
|
12
|
+
let r = t(e.price), o = t(e.amount), s = {};
|
|
13
|
+
e.price.trim() && r === null && (s.price = i.unreadableMoney), e.amount.trim() && o === null && (s.amount = i.unreadableMoney), (r !== null || o !== null) && n(e.quantity) === null && (s.quantity = i.unusableQuantity), Object.keys(s).length && (a[e.id] = s);
|
|
28
14
|
}
|
|
29
|
-
return
|
|
15
|
+
return Object.keys(a).length ? a : void 0;
|
|
30
16
|
}
|
|
31
|
-
function
|
|
32
|
-
|
|
33
|
-
...t,
|
|
34
|
-
...x
|
|
35
|
-
}, [C, w] = d(), T = f ?? C, [E, D] = d(), O = u(!1), k = r(), A = a(), j = n(), M = o(), N = i(), P = l(async () => {
|
|
36
|
-
let e = s({
|
|
37
|
-
values: p.values,
|
|
38
|
-
paymentTerm: h,
|
|
39
|
-
counterpartId: g
|
|
40
|
-
}), t = T;
|
|
41
|
-
if (t ? await A.mutateAsync({
|
|
42
|
-
path: { payable_id: t },
|
|
43
|
-
body: e
|
|
44
|
-
}) : (t = (await k.mutateAsync({ body: e }))?.id, t && (w(t), v?.(t))), !t) throw Error("Payable was created without an id");
|
|
45
|
-
return await j.mutateAsync({
|
|
46
|
-
path: { payable_id: t },
|
|
47
|
-
body: { data: c(p.lineItems) }
|
|
48
|
-
}), t;
|
|
49
|
-
}, [
|
|
50
|
-
g,
|
|
51
|
-
k,
|
|
52
|
-
p.lineItems,
|
|
53
|
-
p.values,
|
|
54
|
-
v,
|
|
55
|
-
h,
|
|
56
|
-
T,
|
|
57
|
-
j,
|
|
58
|
-
A
|
|
59
|
-
]);
|
|
60
|
-
return {
|
|
61
|
-
saveDraft: l(async () => {
|
|
62
|
-
if (!O.current) {
|
|
63
|
-
O.current = !0, D("draft");
|
|
64
|
-
try {
|
|
65
|
-
let t = await P();
|
|
66
|
-
p.setErrors(void 0), _?.(t), y?.(t), e.success(S.draftSaved);
|
|
67
|
-
} catch {
|
|
68
|
-
p.setErrors({ form: S.saveFailed });
|
|
69
|
-
} finally {
|
|
70
|
-
D(void 0), O.current = !1;
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
}, [
|
|
74
|
-
p,
|
|
75
|
-
S.draftSaved,
|
|
76
|
-
S.saveFailed,
|
|
77
|
-
y,
|
|
78
|
-
_,
|
|
79
|
-
P
|
|
80
|
-
]),
|
|
81
|
-
finalize: l(async () => {
|
|
82
|
-
if (!O.current) {
|
|
83
|
-
O.current = !0, D("finalize");
|
|
84
|
-
try {
|
|
85
|
-
let t;
|
|
86
|
-
try {
|
|
87
|
-
t = await P();
|
|
88
|
-
} catch {
|
|
89
|
-
p.setErrors({ form: S.saveFailed });
|
|
90
|
-
return;
|
|
91
|
-
}
|
|
92
|
-
_?.(t);
|
|
93
|
-
try {
|
|
94
|
-
let n = await M.mutateAsync({ path: { payable_id: t } });
|
|
95
|
-
if (n.validation_errors.length) {
|
|
96
|
-
p.setErrors(m(n.validation_errors, S));
|
|
97
|
-
return;
|
|
98
|
-
}
|
|
99
|
-
await N.mutateAsync({ path: { payable_id: t } }), p.setErrors(void 0), b?.(t), e.success(S.billFinalized);
|
|
100
|
-
} catch {
|
|
101
|
-
p.setErrors({ form: S.finalizeFailed });
|
|
102
|
-
}
|
|
103
|
-
} finally {
|
|
104
|
-
D(void 0), O.current = !1;
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
}, [
|
|
108
|
-
p,
|
|
109
|
-
S,
|
|
110
|
-
b,
|
|
111
|
-
_,
|
|
112
|
-
P,
|
|
113
|
-
N,
|
|
114
|
-
M
|
|
115
|
-
]),
|
|
116
|
-
payableId: T,
|
|
117
|
-
isSavingDraft: E === "draft",
|
|
118
|
-
isFinalizing: E === "finalize"
|
|
119
|
-
};
|
|
17
|
+
function o(t, n, r, a = e) {
|
|
18
|
+
return !i(t) || !i(n) || r !== void 0 && (!r.trim() || !i(r)) ? { form: a.totalsNeedAttention } : void 0;
|
|
120
19
|
}
|
|
121
20
|
//#endregion
|
|
122
|
-
export {
|
|
21
|
+
export { o as validateBillTotals, a as validateLineItems };
|
|
@@ -1,39 +1,134 @@
|
|
|
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 { BILL_CREATE_MESSAGE_LABELS_EN as t } from "./index2.js";
|
|
8
|
+
import { useReplacePayableLineItemsMutation as n } from "../../data-access/dist/index6.js";
|
|
9
|
+
import { useCreatePayableMutation as r, useSubmitPayableForApprovalMutation as i, useUpdatePayableMutation as a, useValidatePayableMutation as o } from "../../data-access/dist/index7.js";
|
|
2
10
|
import "../../data-access/dist/index.js";
|
|
11
|
+
import { mapBillFormToPayload as s, mapLineItemsToPayload as c } from "./index6.js";
|
|
12
|
+
import { validateBillTotals as l, validateLineItems as u } from "./index7.js";
|
|
13
|
+
import { useCallback as d, useRef as f, useState as p } from "react";
|
|
3
14
|
//#region ../../libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index8.js
|
|
4
|
-
var
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
price: "",
|
|
12
|
-
amount: ""
|
|
13
|
-
};
|
|
15
|
+
var m = {
|
|
16
|
+
document_id: "invoiceNumber",
|
|
17
|
+
issued_at: "invoiceDate",
|
|
18
|
+
due_date: "dueDate"
|
|
19
|
+
};
|
|
20
|
+
function h(e) {
|
|
21
|
+
return e.type === "type_error.none.not_allowed" || e.msg === "none is not an allowed value";
|
|
14
22
|
}
|
|
15
|
-
function
|
|
16
|
-
|
|
23
|
+
function g(e, n = t) {
|
|
24
|
+
let r = {}, i = [];
|
|
25
|
+
for (let t of e) {
|
|
26
|
+
let e = t.loc[0] ?? n.unknownValidationField, a = m[e], o = h(t) ? n.requiredField : t.msg;
|
|
27
|
+
a ? r[a] = o : i.push(n.unmappedValidationError(e, o));
|
|
28
|
+
}
|
|
29
|
+
return i.length && (r.form = i.join(" ")), r;
|
|
17
30
|
}
|
|
18
|
-
function
|
|
19
|
-
let
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
},
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
31
|
+
function _({ payableId: m, form: h, counterpartId: _, onSaved: v, onPayableCreated: y, onDraftSaved: b, onFinalized: x, labels: S }) {
|
|
32
|
+
let C = {
|
|
33
|
+
...t,
|
|
34
|
+
...S
|
|
35
|
+
}, [w, T] = p(), E = m ?? w, [D, O] = p(), k = f(!1), A = r(), j = a(), M = n(), N = o(), P = i(), F = d(() => {
|
|
36
|
+
let e = u(h.lineItems, C), t = l(h.discount, h.tax, h.totalOverride, C);
|
|
37
|
+
return h.setLineItemErrors(e), !e && !t || (h.setErrors(e ? { form: C.lineItemsNeedAttention } : t), !1);
|
|
38
|
+
}, [h, C]), I = d(async () => {
|
|
39
|
+
let e = s({
|
|
40
|
+
values: h.values,
|
|
41
|
+
counterpartId: _,
|
|
42
|
+
editedTotals: h.isTotalsDirty ? {
|
|
43
|
+
discount: h.discount,
|
|
44
|
+
tax: h.tax,
|
|
45
|
+
total: h.totalOverride
|
|
46
|
+
} : void 0
|
|
47
|
+
}), t = E;
|
|
48
|
+
if (t ? await j.mutateAsync({
|
|
49
|
+
path: { payable_id: t },
|
|
50
|
+
body: e
|
|
51
|
+
}) : (t = (await A.mutateAsync({ body: e }))?.id, t && (T(t), y?.(t))), !t) throw Error("Payable was created without an id");
|
|
52
|
+
return await M.mutateAsync({
|
|
53
|
+
path: { payable_id: t },
|
|
54
|
+
body: { data: c(h.lineItems) }
|
|
55
|
+
}), t;
|
|
56
|
+
}, [
|
|
57
|
+
_,
|
|
58
|
+
A,
|
|
59
|
+
h.discount,
|
|
60
|
+
h.isTotalsDirty,
|
|
61
|
+
h.lineItems,
|
|
62
|
+
h.tax,
|
|
63
|
+
h.totalOverride,
|
|
64
|
+
h.values,
|
|
65
|
+
y,
|
|
66
|
+
E,
|
|
67
|
+
M,
|
|
68
|
+
j
|
|
69
|
+
]);
|
|
33
70
|
return {
|
|
34
|
-
|
|
35
|
-
|
|
71
|
+
saveDraft: d(async () => {
|
|
72
|
+
if (!k.current && F()) {
|
|
73
|
+
k.current = !0, O("draft");
|
|
74
|
+
try {
|
|
75
|
+
let t = await I();
|
|
76
|
+
h.setErrors(void 0), v?.(t), b?.(t), e.success(C.draftSaved);
|
|
77
|
+
} catch {
|
|
78
|
+
h.setErrors({ form: C.saveFailed });
|
|
79
|
+
} finally {
|
|
80
|
+
O(void 0), k.current = !1;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}, [
|
|
84
|
+
h,
|
|
85
|
+
F,
|
|
86
|
+
C.draftSaved,
|
|
87
|
+
C.saveFailed,
|
|
88
|
+
b,
|
|
89
|
+
v,
|
|
90
|
+
I
|
|
91
|
+
]),
|
|
92
|
+
finalize: d(async () => {
|
|
93
|
+
if (!k.current && F()) {
|
|
94
|
+
k.current = !0, O("finalize");
|
|
95
|
+
try {
|
|
96
|
+
let t;
|
|
97
|
+
try {
|
|
98
|
+
t = await I();
|
|
99
|
+
} catch {
|
|
100
|
+
h.setErrors({ form: C.saveFailed });
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
v?.(t);
|
|
104
|
+
try {
|
|
105
|
+
let n = await N.mutateAsync({ path: { payable_id: t } });
|
|
106
|
+
if (n.validation_errors.length) {
|
|
107
|
+
h.setErrors(g(n.validation_errors, C));
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
await P.mutateAsync({ path: { payable_id: t } }), h.setErrors(void 0), x?.(t), e.success(C.billFinalized);
|
|
111
|
+
} catch {
|
|
112
|
+
h.setErrors({ form: C.finalizeFailed });
|
|
113
|
+
}
|
|
114
|
+
} finally {
|
|
115
|
+
O(void 0), k.current = !1;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
}, [
|
|
119
|
+
h,
|
|
120
|
+
F,
|
|
121
|
+
C,
|
|
122
|
+
x,
|
|
123
|
+
v,
|
|
124
|
+
I,
|
|
125
|
+
P,
|
|
126
|
+
N
|
|
127
|
+
]),
|
|
128
|
+
payableId: E,
|
|
129
|
+
isSavingDraft: D === "draft",
|
|
130
|
+
isFinalizing: D === "finalize"
|
|
36
131
|
};
|
|
37
132
|
}
|
|
38
133
|
//#endregion
|
|
39
|
-
export {
|
|
134
|
+
export { g as mapValidationErrorsToForm, _ as useBillCreateController };
|