@tesouro/embedded-components-react 0.2.332 → 0.2.336
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.css +3 -0
- package/dist/index.js +1 -1
- package/dist/lib/BillPayWidget.js +1 -1
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index.js +6 -6
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index10.js +2 -2
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index26.js +0 -1
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index27.js +43 -31
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index31.js +12 -46
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index32.js +46 -30
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index33.js +26 -149
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index34.js +159 -31
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index35.js +32 -98
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index36.js +102 -10
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index37.js +10 -212
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index38.js +221 -4
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index39.js +4 -29
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index40.js +27 -80
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index41.js +75 -125
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index42.js +132 -3
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index43.js +3 -4
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index44.js +2 -43
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index45.js +45 -1
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index46.js +1 -8
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index47.js +6 -9
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index48.js +9 -92
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index49.js +94 -3
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index50.js +3 -53
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index51.js +107 -8
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index52.js +9 -16
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index53.js +37 -5
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index54.js +6 -78
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index55.js +83 -144
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index56.js +161 -4
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index57.js +5 -8
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index58.js +6 -113
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index59.js +115 -1
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index60.js +0 -24
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index61.js +25 -0
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index7.js +2 -2
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index.js +16 -15
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index51.js +4 -0
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index53.js +12 -204
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index54.js +254 -8
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index55.js +6 -4
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index56.js +6 -91
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index57.js +93 -0
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index59.js +2 -7
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index60.js +5 -28
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index61.js +30 -2
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index62.js +2 -7
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index63.js +5 -32
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index64.js +34 -2
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index65.js +2 -12
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index66.js +10 -104
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index67.js +105 -1
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index68.js +2 -18
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index69.js +14 -6
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index70.js +7 -167
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index71.js +170 -2
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index72.js +2 -14
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index73.js +11 -86
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index74.js +89 -2
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index75.js +2 -0
- 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/index7.js +1 -1
- package/dist/packages/shared-ui-shadcn/dist/index.js +1274 -1266
- package/package.json +1 -1
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index58.js +0 -2
package/dist/index.css
CHANGED
package/dist/index.js
CHANGED
|
@@ -16,7 +16,7 @@ import "./lib/AcceptDisclosuresWidget.js";
|
|
|
16
16
|
import { BankAccountsWidget as C } from "./libs/tesouro-embedded-components-react/bank-accounts-widget/feature/dist/index8.js";
|
|
17
17
|
import "./lib/BankAccountsWidget.js";
|
|
18
18
|
import { CounterpartsWidget as w } from "./libs/tesouro-embedded-components-react/counterparts-widget/feature/dist/index8.js";
|
|
19
|
-
import { BillPayWidget as T } from "./libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/
|
|
19
|
+
import { BillPayWidget as T } from "./libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index61.js";
|
|
20
20
|
import "./lib/BillPayWidget.js";
|
|
21
21
|
import { CardDetailsWidget as E } from "./libs/tesouro-embedded-components-react/card-details-widget/feature/dist/index6.js";
|
|
22
22
|
import { CardFormatValue as D } from "./libs/tesouro-embedded-components-react/create-card-widget/feature/dist/index3.js";
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { BillPayWidget as e } from "../libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/
|
|
1
|
+
import { BillPayWidget as e } from "../libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index61.js";
|
|
2
2
|
import "../libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index.js";
|
|
3
3
|
export { e as BillPayWidget };
|
|
@@ -2,23 +2,23 @@ import "./index10.js";
|
|
|
2
2
|
import "./index11.js";
|
|
3
3
|
import "./index20.js";
|
|
4
4
|
import "./index26.js";
|
|
5
|
-
import "./
|
|
6
|
-
import "./
|
|
7
|
-
import "./index37.js";
|
|
5
|
+
import "./index34.js";
|
|
6
|
+
import "./index36.js";
|
|
8
7
|
import "./index38.js";
|
|
9
8
|
import "./index39.js";
|
|
10
9
|
import "./index40.js";
|
|
11
10
|
import "./index41.js";
|
|
12
11
|
import "./index42.js";
|
|
13
|
-
import "./
|
|
12
|
+
import "./index43.js";
|
|
14
13
|
import "./index47.js";
|
|
15
14
|
import "./index48.js";
|
|
16
15
|
import "./index49.js";
|
|
17
16
|
import "./index50.js";
|
|
18
|
-
import "./
|
|
17
|
+
import "./index51.js";
|
|
19
18
|
import "./index53.js";
|
|
20
19
|
import "./index54.js";
|
|
21
20
|
import "./index55.js";
|
|
22
21
|
import "./index56.js";
|
|
23
|
-
import
|
|
22
|
+
import "./index57.js";
|
|
23
|
+
import { BillPayWidget as e } from "./index61.js";
|
|
24
24
|
export { e as BillPayWidget };
|
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
import { resolveAmountDueMinorUnits as e } from "./index2.js";
|
|
6
6
|
import { resolveVendor as t } from "./index3.js";
|
|
7
7
|
import { payBillFlowTestIds as n } from "./index4.js";
|
|
8
|
-
import { ReviewTransactionDialog as r } from "../../ui/dist/
|
|
9
|
-
import { SchedulePaymentDialog as i } from "../../ui/dist/
|
|
8
|
+
import { ReviewTransactionDialog as r } from "../../ui/dist/index67.js";
|
|
9
|
+
import { SchedulePaymentDialog as i } from "../../ui/dist/index71.js";
|
|
10
10
|
import "../../ui/dist/index.js";
|
|
11
11
|
import { usePayBillFlow as a } from "./index9.js";
|
|
12
12
|
import { useImperativeHandle as o } from "react";
|
|
@@ -27,7 +27,6 @@ var s = {
|
|
|
27
27
|
vendorDetailsFailed: "We could not load this vendor. Try again."
|
|
28
28
|
}, l = {
|
|
29
29
|
attachFailed: "We could not attach that file. Try again.",
|
|
30
|
-
saveBeforeAttaching: "Save this bill before attaching a document.",
|
|
31
30
|
noDocument: "No document attached to this bill.",
|
|
32
31
|
preview: o
|
|
33
32
|
}, u = {
|
|
@@ -2,58 +2,70 @@
|
|
|
2
2
|
"use client";
|
|
3
3
|
"use client";
|
|
4
4
|
"use client";
|
|
5
|
-
import { SourceDocumentPanel as e } from "../../ui/dist/
|
|
5
|
+
import { SourceDocumentPanel as e } from "../../ui/dist/index74.js";
|
|
6
6
|
import "../../ui/dist/index.js";
|
|
7
7
|
import { useAttachPayableFileMutation as t, useDeletePayableFileMutation as n } from "../../data-access/dist/index10.js";
|
|
8
8
|
import "../../data-access/dist/index.js";
|
|
9
9
|
import { createSourceDocumentPreview as r } from "./index25.js";
|
|
10
10
|
import { SOURCE_DOCUMENT_CONTAINER_LABELS_EN as i } from "./index26.js";
|
|
11
|
-
import {
|
|
11
|
+
import { useEffect as a, useState as o } from "react";
|
|
12
|
+
import { jsx as s } from "react/jsx-runtime";
|
|
12
13
|
//#region ../../libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index27.js
|
|
13
|
-
function
|
|
14
|
-
let
|
|
14
|
+
function c(e) {
|
|
15
|
+
let [t, n] = o();
|
|
16
|
+
return a(() => {
|
|
17
|
+
if (!e) {
|
|
18
|
+
n(void 0);
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
let t = URL.createObjectURL(e);
|
|
22
|
+
return n(t), () => URL.revokeObjectURL(t);
|
|
23
|
+
}, [e]), t;
|
|
24
|
+
}
|
|
25
|
+
function l({ payableId: a, file: o, isDocumentPending: l, pendingFileName: u, readOnly: d, staging: f, labels: p }) {
|
|
26
|
+
let { stagedFile: m, onFileStaged: h, onClearStagedFile: g, isSaving: _ } = f ?? {}, v = {
|
|
15
27
|
...i,
|
|
16
|
-
...
|
|
28
|
+
...p,
|
|
17
29
|
preview: {
|
|
18
30
|
...i.preview,
|
|
19
|
-
...
|
|
31
|
+
...p?.preview
|
|
20
32
|
}
|
|
21
|
-
},
|
|
22
|
-
if (!
|
|
33
|
+
}, y = t(), b = n(), x = c(m), S = !!(o || m);
|
|
34
|
+
if (!S && (l || y.isPending)) return /* @__PURE__ */ s(e, {
|
|
23
35
|
mode: "loading",
|
|
24
|
-
fileName:
|
|
25
|
-
});
|
|
26
|
-
if (!s && u) return /* @__PURE__ */ a("div", {
|
|
27
|
-
className: "ttw:rounded-lg ttw:border ttw:border-border ttw:bg-card ttw:p-4 ttw:text-sm ttw:text-muted-foreground",
|
|
28
|
-
children: f.noDocument
|
|
36
|
+
fileName: u
|
|
29
37
|
});
|
|
30
|
-
if (!
|
|
38
|
+
if (!S && d) return /* @__PURE__ */ s("div", {
|
|
31
39
|
className: "ttw:rounded-lg ttw:border ttw:border-border ttw:bg-card ttw:p-4 ttw:text-sm ttw:text-muted-foreground",
|
|
32
|
-
children:
|
|
40
|
+
children: v.noDocument
|
|
33
41
|
});
|
|
34
|
-
if (!
|
|
42
|
+
if (!S) return /* @__PURE__ */ s(e, {
|
|
35
43
|
mode: "upload",
|
|
36
|
-
uploadStatus:
|
|
37
|
-
uploadErrorMessage:
|
|
44
|
+
uploadStatus: y.isPending ? "uploading" : "idle",
|
|
45
|
+
uploadErrorMessage: y.isError ? v.attachFailed : void 0,
|
|
38
46
|
onFilesSelected: (e) => {
|
|
39
47
|
let [t] = e;
|
|
40
|
-
|
|
41
|
-
path: { payable_id:
|
|
48
|
+
t && (a ? y.mutate({
|
|
49
|
+
path: { payable_id: a },
|
|
42
50
|
file: t
|
|
43
|
-
});
|
|
51
|
+
}) : h?.(t));
|
|
44
52
|
}
|
|
45
53
|
});
|
|
46
|
-
let
|
|
47
|
-
|
|
54
|
+
let C = o?.name ?? m?.name ?? "", w = r(o || {
|
|
55
|
+
name: C,
|
|
56
|
+
url: x ?? "",
|
|
57
|
+
mimetype: m?.type ?? ""
|
|
58
|
+
}, v.preview);
|
|
59
|
+
return /* @__PURE__ */ s(e, {
|
|
48
60
|
mode: "document",
|
|
49
|
-
fileName:
|
|
50
|
-
preview:
|
|
51
|
-
onDownload: () => window.open(
|
|
52
|
-
onDelete: o &&
|
|
53
|
-
path: { file_id:
|
|
54
|
-
payableId:
|
|
55
|
-
}) : void 0
|
|
61
|
+
fileName: C,
|
|
62
|
+
preview: w,
|
|
63
|
+
onDownload: o ? () => window.open(o.url, "_blank", "noopener,noreferrer") : void 0,
|
|
64
|
+
onDelete: d ? void 0 : o && a ? () => b.mutate({
|
|
65
|
+
path: { file_id: o.id },
|
|
66
|
+
payableId: a
|
|
67
|
+
}) : _ ? void 0 : g
|
|
56
68
|
});
|
|
57
69
|
}
|
|
58
70
|
//#endregion
|
|
59
|
-
export {
|
|
71
|
+
export { l as SourceDocumentContainer, l as default };
|
|
@@ -1,50 +1,16 @@
|
|
|
1
|
-
import { parseDecimalAmountToMinorUnits as e } from "../../../shared/util/dist/lib/parseDecimalAmountToMinorUnits.js";
|
|
2
|
-
import "../../data-access/dist/index.js";
|
|
3
1
|
//#region ../../libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index31.js
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
return !!(e.description.trim() || e.glCode.trim() || n(e.price) !== null || n(e.amount) !== null);
|
|
16
|
-
}
|
|
17
|
-
function a(e) {
|
|
18
|
-
return n(e) ?? 0;
|
|
19
|
-
}
|
|
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, editedTotals: a }) {
|
|
28
|
-
let o = { currency: t };
|
|
29
|
-
return r ? o.counterpart_id = r : i && (o.counterpart_id = null), e.invoiceNumber && (o.document_id = e.invoiceNumber), e.invoiceDate && (o.issued_at = e.invoiceDate), e.dueDate && (o.due_date = e.dueDate), a && (o.discount = n(a.discount) ?? 0, o.tax_amount = n(a.tax) ?? 0, a.total !== void 0 && (o.total_amount = n(a.total) ?? 0)), o;
|
|
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
|
-
};
|
|
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);
|
|
41
13
|
});
|
|
42
14
|
}
|
|
43
|
-
function u(e, t) {
|
|
44
|
-
return s(Math.round(o(e) * a(t)));
|
|
45
|
-
}
|
|
46
|
-
function d(e, t, n) {
|
|
47
|
-
return s(e.reduce((e, t) => e + a(t.amount), 0) + a(t) - a(n));
|
|
48
|
-
}
|
|
49
15
|
//#endregion
|
|
50
|
-
export {
|
|
16
|
+
export { e as encodeFileToBase64 };
|
|
@@ -1,34 +1,50 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
1
|
+
import { parseDecimalAmountToMinorUnits as e } from "../../../shared/util/dist/lib/parseDecimalAmountToMinorUnits.js";
|
|
2
|
+
import "../../data-access/dist/index.js";
|
|
3
3
|
//#region ../../libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index32.js
|
|
4
|
-
var
|
|
5
|
-
function
|
|
4
|
+
var t = "USD";
|
|
5
|
+
function n(n) {
|
|
6
|
+
return e(n, t);
|
|
7
|
+
}
|
|
8
|
+
function r(e) {
|
|
6
9
|
let t = e.trim();
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
return
|
|
16
|
-
}
|
|
17
|
-
function
|
|
18
|
-
let
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
10
|
+
if (!t) return null;
|
|
11
|
+
let n = Number(t);
|
|
12
|
+
return Number.isFinite(n) && n > 0 ? n : null;
|
|
13
|
+
}
|
|
14
|
+
function i(e) {
|
|
15
|
+
return !!(e.description.trim() || e.glCode.trim() || n(e.price) !== null || n(e.amount) !== null);
|
|
16
|
+
}
|
|
17
|
+
function a(e) {
|
|
18
|
+
return n(e) ?? 0;
|
|
19
|
+
}
|
|
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, editedTotals: a, document: o }) {
|
|
28
|
+
let s = { currency: t };
|
|
29
|
+
return r ? s.counterpart_id = r : i && (s.counterpart_id = null), e.invoiceNumber && (s.document_id = e.invoiceNumber), e.invoiceDate && (s.issued_at = e.invoiceDate), e.dueDate && (s.due_date = e.dueDate), o && (s.base64_encoded_file = o.base64EncodedFile, s.file_name = o.fileName), a && (s.discount = n(a.discount) ?? 0, s.tax_amount = n(a.tax) ?? 0, a.total !== void 0 && (s.total_amount = n(a.total) ?? 0)), s;
|
|
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
|
+
});
|
|
42
|
+
}
|
|
43
|
+
function u(e, t) {
|
|
44
|
+
return s(Math.round(o(e) * a(t)));
|
|
45
|
+
}
|
|
46
|
+
function d(e, t, n) {
|
|
47
|
+
return s(e.reduce((e, t) => e + a(t.amount), 0) + a(t) - a(n));
|
|
32
48
|
}
|
|
33
49
|
//#endregion
|
|
34
|
-
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,157 +1,34 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
"use client";
|
|
4
|
-
"use client";
|
|
5
|
-
import { toast as e } from "../../../../../packages/shared-ui-shadcn/dist/index.js";
|
|
6
|
-
import "../../../shared/ui/dist/index.js";
|
|
7
|
-
import { useReplacePayableLineItemsMutation as t } from "../../data-access/dist/index7.js";
|
|
8
|
-
import { useCreatePayableMutation as n, useSubmitPayableForApprovalMutation as r, useUpdatePayableMutation as i, useValidatePayableMutation as a } from "../../data-access/dist/index10.js";
|
|
9
|
-
import "../../data-access/dist/index.js";
|
|
10
|
-
import { BILL_CREATE_MESSAGE_LABELS_EN as o } from "./index26.js";
|
|
11
|
-
import { mapBillFormToPayload as s, mapLineItemsToPayload as c } from "./index31.js";
|
|
12
|
-
import { validateBillCompleteness as l, validateBillTotals as u, validateLineItems as d } from "./index32.js";
|
|
13
|
-
import { useCallback as f, useRef as p, useState as m } from "react";
|
|
1
|
+
import { BILL_CREATE_MESSAGE_LABELS_EN as e } from "./index26.js";
|
|
2
|
+
import { isPersistableLineItem as t, parseMoneyToMinorUnits as n, parseQuantity as r } from "./index32.js";
|
|
14
3
|
//#region ../../libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index33.js
|
|
15
|
-
var
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
counterpart_id: "vendor"
|
|
20
|
-
};
|
|
21
|
-
function g(e) {
|
|
22
|
-
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;
|
|
23
8
|
}
|
|
24
|
-
function
|
|
25
|
-
let
|
|
26
|
-
for (let
|
|
27
|
-
let
|
|
28
|
-
|
|
9
|
+
function o(t, i = e) {
|
|
10
|
+
let a = {};
|
|
11
|
+
for (let e of t) {
|
|
12
|
+
let t = n(e.price), o = n(e.amount), s = {};
|
|
13
|
+
e.price.trim() && t === null && (s.price = i.unreadableMoney), e.amount.trim() && o === null && (s.amount = i.unreadableMoney), (t !== null || o !== null) && r(e.quantity) === null && (s.quantity = i.unusableQuantity), Object.keys(s).length && (a[e.id] = s);
|
|
29
14
|
}
|
|
30
|
-
return
|
|
15
|
+
return Object.keys(a).length ? a : void 0;
|
|
31
16
|
}
|
|
32
|
-
function
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
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
|
|
38
28
|
};
|
|
39
|
-
return n;
|
|
40
29
|
}
|
|
41
|
-
function
|
|
42
|
-
|
|
43
|
-
...o,
|
|
44
|
-
...E
|
|
45
|
-
}, [O, k] = m(), A = h ?? O, [j, M] = m(), N = p(!1), P = n(), F = i(), I = t(), L = a(), R = r(), z = f(() => {
|
|
46
|
-
let t = d(g.lineItems, D), n = u(g.discount, g.tax, g.totalOverride, D);
|
|
47
|
-
return g.setLineItemErrors(t), !t && !n || (t ? (g.setErrors(void 0), e.error(D.lineItemsNeedAttention)) : g.setErrors(n), !1);
|
|
48
|
-
}, [g, D]), B = f(async () => {
|
|
49
|
-
let e = s({
|
|
50
|
-
values: g.values,
|
|
51
|
-
counterpartId: y,
|
|
52
|
-
clearCounterpart: b,
|
|
53
|
-
editedTotals: g.isTotalsDirty ? {
|
|
54
|
-
discount: g.discount,
|
|
55
|
-
tax: g.tax,
|
|
56
|
-
total: g.totalOverride
|
|
57
|
-
} : void 0
|
|
58
|
-
}), t = A;
|
|
59
|
-
if (t ? await F.mutateAsync({
|
|
60
|
-
path: { payable_id: t },
|
|
61
|
-
body: e
|
|
62
|
-
}) : (t = (await P.mutateAsync({ body: e }))?.id, t && (k(t), C?.(t))), !t) throw Error("Payable was created without an id");
|
|
63
|
-
return await I.mutateAsync({
|
|
64
|
-
path: { payable_id: t },
|
|
65
|
-
body: { data: c(g.lineItems) }
|
|
66
|
-
}), t;
|
|
67
|
-
}, [
|
|
68
|
-
y,
|
|
69
|
-
b,
|
|
70
|
-
P,
|
|
71
|
-
g.discount,
|
|
72
|
-
g.isTotalsDirty,
|
|
73
|
-
g.lineItems,
|
|
74
|
-
g.tax,
|
|
75
|
-
g.totalOverride,
|
|
76
|
-
g.values,
|
|
77
|
-
C,
|
|
78
|
-
A,
|
|
79
|
-
I,
|
|
80
|
-
F
|
|
81
|
-
]);
|
|
82
|
-
return {
|
|
83
|
-
saveDraft: f(async () => {
|
|
84
|
-
if (!N.current && z()) {
|
|
85
|
-
N.current = !0, M("draft");
|
|
86
|
-
try {
|
|
87
|
-
if (await x?.() === !1) return;
|
|
88
|
-
let t = await B();
|
|
89
|
-
g.setErrors(void 0), S?.(t), w?.(t), e.success(D.draftSaved);
|
|
90
|
-
} catch {
|
|
91
|
-
g.setErrors({ form: D.saveFailed });
|
|
92
|
-
} finally {
|
|
93
|
-
M(void 0), N.current = !1;
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
}, [
|
|
97
|
-
g,
|
|
98
|
-
z,
|
|
99
|
-
D.draftSaved,
|
|
100
|
-
D.saveFailed,
|
|
101
|
-
w,
|
|
102
|
-
S,
|
|
103
|
-
x,
|
|
104
|
-
B
|
|
105
|
-
]),
|
|
106
|
-
finalize: f(async () => {
|
|
107
|
-
if (N.current) return;
|
|
108
|
-
let t = d(g.lineItems, D), n = u(g.discount, g.tax, g.totalOverride, D), { formErrors: r, lineItemErrors: i } = l(g.values, y, g.lineItems, D), a = v(i, t);
|
|
109
|
-
g.setLineItemErrors(a);
|
|
110
|
-
let o = {
|
|
111
|
-
...r,
|
|
112
|
-
...n
|
|
113
|
-
};
|
|
114
|
-
if (g.setErrors(Object.keys(o).length ? o : void 0), t && e.error(D.lineItemsNeedAttention), !(a || Object.keys(o).length)) {
|
|
115
|
-
N.current = !0, M("finalize");
|
|
116
|
-
try {
|
|
117
|
-
let t;
|
|
118
|
-
try {
|
|
119
|
-
if (await x?.() === !1) return;
|
|
120
|
-
t = await B();
|
|
121
|
-
} catch {
|
|
122
|
-
g.setErrors({ form: D.saveFailed });
|
|
123
|
-
return;
|
|
124
|
-
}
|
|
125
|
-
S?.(t);
|
|
126
|
-
try {
|
|
127
|
-
let n = await L.mutateAsync({ path: { payable_id: t } });
|
|
128
|
-
if (n.validation_errors.length) {
|
|
129
|
-
g.setErrors(_(n.validation_errors, D));
|
|
130
|
-
return;
|
|
131
|
-
}
|
|
132
|
-
await R.mutateAsync({ path: { payable_id: t } }), g.setErrors(void 0), T?.(t), e.success(D.billFinalized);
|
|
133
|
-
} catch {
|
|
134
|
-
g.setErrors({ form: D.finalizeFailed });
|
|
135
|
-
}
|
|
136
|
-
} finally {
|
|
137
|
-
M(void 0), N.current = !1;
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
}, [
|
|
141
|
-
y,
|
|
142
|
-
g,
|
|
143
|
-
D,
|
|
144
|
-
T,
|
|
145
|
-
S,
|
|
146
|
-
x,
|
|
147
|
-
B,
|
|
148
|
-
R,
|
|
149
|
-
L
|
|
150
|
-
]),
|
|
151
|
-
payableId: A,
|
|
152
|
-
isSavingDraft: j === "draft",
|
|
153
|
-
isFinalizing: j === "finalize"
|
|
154
|
-
};
|
|
30
|
+
function c(t, r, i, o = e) {
|
|
31
|
+
return !a(t) || !a(r) || i !== void 0 && n(i) === null ? { form: o.totalsNeedAttention } : void 0;
|
|
155
32
|
}
|
|
156
33
|
//#endregion
|
|
157
|
-
export {
|
|
34
|
+
export { s as validateBillCompleteness, c as validateBillTotals, o as validateLineItems };
|