@tesouro/embedded-components-react 0.5.28 → 0.5.31
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 +14 -13
- package/dist/index.css +15 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.js +1 -1
- package/dist/lib/BankAccountOnboardingWidget.d.ts +9 -0
- package/dist/lib/BillPayWidget.js +1 -1
- package/dist/libs/tesouro-embedded-components-react/bank-account-onboarding-widget/feature/dist/index18.js +155 -151
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/data-access/dist/index.js +5 -5
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/data-access/dist/index14.js +2 -44
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index.js +7 -7
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index12.js +1 -1
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index15.js +1 -1
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index25.js +2 -2
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index27.js +2 -2
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index43.js +52 -67
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index46.js +15 -12
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index48.js +57 -62
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index49.js +1 -1
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index51.js +68 -207
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index52.js +278 -175
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index53.js +13 -126
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index54.js +47 -12
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index55.js +53 -47
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index56.js +204 -49
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index57.js +32 -202
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index58.js +234 -32
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index59.js +21 -240
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index60.js +532 -19
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index61.js +4 -436
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index62.js +42 -4
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index63.js +230 -35
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index64.js +3 -233
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index65.js +4 -3
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index66.js +44 -2
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index67.js +1 -46
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index68.js +8 -1
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index69.js +11 -6
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index70.js +127 -11
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index71.js +3 -129
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index72.js +127 -3
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index73.js +8 -124
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index74.js +7 -8
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index75.js +46 -8
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index76.js +18 -43
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index77.js +28 -20
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index78.js +82 -27
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index79.js +47 -83
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index80.js +250 -47
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index81.js +122 -241
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index82.js +206 -126
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index83.js +3 -213
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index84.js +8 -4
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index85.js +113 -6
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index86.js +1 -115
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index87.js +24 -0
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index.js +39 -33
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index101.js +10 -11
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index102.js +123 -8
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index103.js +2 -170
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index104.js +18 -2
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index105.js +7 -11
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index106.js +158 -96
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index107.js +1 -1
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index108.js +11 -7
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index109.js +100 -44
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index111.js +10 -0
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index112.js +52 -0
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index113.js +2 -0
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index13.js +1 -1
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index26.js +20 -22
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index27.js +4 -9
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index28.js +103 -146
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index30.js +3 -2
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index31.js +93 -88
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index46.js +15 -16
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index48.js +1 -0
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index50.js +43 -29
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index65.js +55 -51
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index66.js +9 -2
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index67.js +33 -1
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index68.js +2 -8
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index69.js +2 -39
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index70.js +0 -1
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index71.js +6 -2
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index72.js +34 -31
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index74.js +2 -37
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index75.js +34 -10
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index76.js +2 -201
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index77.js +39 -3
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index78.js +3 -8
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index79.js +187 -350
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index80.js +3 -10
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index81.js +13 -5
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index82.js +356 -85
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index83.js +10 -0
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index84.js +9 -2
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index85.js +87 -119
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index87.js +2 -94
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index88.js +125 -2
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index89.js +25 -4
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index90.js +90 -26
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index92.js +3 -3
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index93.js +26 -30
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index95.js +4 -9
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index96.js +30 -102
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index98.js +9 -14
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index99.js +85 -104
- package/dist/libs/tesouro-embedded-components-react/shared/counterpart-management/data-access/dist/index.js +5 -5
- package/dist/libs/tesouro-embedded-components-react/shared/counterpart-management/feature/dist/index.js +17 -17
- package/dist/libs/tesouro-embedded-components-react/shared/counterpart-management/feature/dist/lib/useCounterpartDetails.js +4 -0
- package/dist/libs/tesouro-embedded-components-react/shared/counterpart-management/feature/dist/lib/useCounterpartForm.js +92 -87
- 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/ui/dist/lib/OnboardingShell/OnboardingShell.js +126 -105
- package/dist/libs/tesouro-embedded-components-react/shared/ui/dist/lib/OnboardingShell/OnboardingShellOverlayPortal.js +13 -6
- 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/bill-pay-widget/feature/dist/index88.js +0 -25
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index86.js +0 -28
|
@@ -1,16 +1,51 @@
|
|
|
1
|
+
import { parseDecimalAmountToMinorUnits as e } from "../../../shared/util/dist/lib/parseDecimalAmountToMinorUnits.js";
|
|
2
|
+
import "../../data-access/dist/index.js";
|
|
1
3
|
//#region ../../libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index54.js
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
4
|
+
var t = "USD";
|
|
5
|
+
function n(n) {
|
|
6
|
+
return e(n, t);
|
|
7
|
+
}
|
|
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;
|
|
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, 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
|
+
};
|
|
13
42
|
});
|
|
14
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));
|
|
49
|
+
}
|
|
15
50
|
//#endregion
|
|
16
|
-
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,51 +1,57 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import "
|
|
1
|
+
import { BILL_CREATE_MESSAGE_LABELS_EN as e } from "./index48.js";
|
|
2
|
+
import { isPersistableLineItem as t, parseMoneyToMinorUnits as n, parseQuantity as r } from "./index54.js";
|
|
3
3
|
//#region ../../libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index55.js
|
|
4
|
-
var
|
|
5
|
-
function n(n) {
|
|
6
|
-
return e(n, t);
|
|
7
|
-
}
|
|
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;
|
|
13
|
-
}
|
|
14
|
-
function i(e) {
|
|
15
|
-
return !!(e.description.trim() || e.glCode.trim() || n(e.price) !== null || n(e.amount) !== null);
|
|
16
|
-
}
|
|
4
|
+
var i = /^(?:\d{1,3}(?:,\d{3})+(?:\.\d+)?|\d+(?:\.\d+)?|\.\d+)$/;
|
|
17
5
|
function a(e) {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
return
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
6
|
+
let t = e.trim();
|
|
7
|
+
return !t || n(t) !== null ? !0 : i.test(t) ? Number(t.replaceAll(",", "")) === 0 : !1;
|
|
8
|
+
}
|
|
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;
|
|
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(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;
|
|
49
55
|
}
|
|
50
56
|
//#endregion
|
|
51
|
-
export {
|
|
57
|
+
export { a as isReadableMoneyOrZero, s as validateBillCompleteness, u as validateBillTotalIsPayable, f as validateBillTotals, o as validateLineItems, d as validateStoredAmountDue };
|
|
@@ -1,57 +1,212 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
"use client";
|
|
2
|
+
"use client";
|
|
3
|
+
"use client";
|
|
4
|
+
"use client";
|
|
5
|
+
import { toast as e } from "../../../../../packages/shared-ui-shadcn/dist/index.js";
|
|
6
|
+
import "../../../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 "./index53.js";
|
|
13
|
+
import { mapBillFormToPayload as ee, mapLineItemsToPayload as te } from "./index54.js";
|
|
14
|
+
import { validateBillCompleteness as u, validateBillTotalIsPayable as d, validateBillTotals as ne, validateLineItems as f, validateStoredAmountDue as p } from "./index55.js";
|
|
15
|
+
import { useCallback as m, useRef as h, useState as g } from "react";
|
|
3
16
|
//#region ../../libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index56.js
|
|
4
|
-
var
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
17
|
+
var _ = {
|
|
18
|
+
document_id: "invoiceNumber",
|
|
19
|
+
issued_at: "invoiceDate",
|
|
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";
|
|
8
25
|
}
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
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;
|
|
26
|
+
var b = "pending-vendor";
|
|
27
|
+
function x(e) {
|
|
28
|
+
return !!t(e)?.includes("line_items_enabled");
|
|
16
29
|
}
|
|
17
|
-
function
|
|
18
|
-
let
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
formErrors: Object.keys(c).length ? c : void 0,
|
|
27
|
-
lineItemErrors: Object.keys(l).length ? l : void 0
|
|
30
|
+
function S(e, t = c) {
|
|
31
|
+
let n = {}, r = {}, i = [];
|
|
32
|
+
for (let a of e) {
|
|
33
|
+
let e = a.loc[0] ?? t.unknownValidationField, o = _[e], s = v[e], c = y(a) ? t.requiredField : a.msg;
|
|
34
|
+
o ? n[o] = c : s ? r[s] = c : i.push(t.unmappedValidationError(e, c));
|
|
35
|
+
}
|
|
36
|
+
return i.length && (n.form = i.join(" ")), {
|
|
37
|
+
formErrors: n,
|
|
38
|
+
totalsErrors: Object.keys(r).length ? r : void 0
|
|
28
39
|
};
|
|
29
40
|
}
|
|
30
|
-
function
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
let
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
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 };
|
|
41
|
+
function re(e, t) {
|
|
42
|
+
if (!e && !t) return;
|
|
43
|
+
let n = {}, r = /* @__PURE__ */ new Set([...Object.keys(e ?? {}), ...Object.keys(t ?? {})]);
|
|
44
|
+
for (let i of r) n[i] = {
|
|
45
|
+
...e?.[i],
|
|
46
|
+
...t?.[i]
|
|
47
|
+
};
|
|
48
|
+
return n;
|
|
47
49
|
}
|
|
48
|
-
function
|
|
49
|
-
let
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
50
|
+
function C({ payableId: t, form: _, counterpartId: v, isVendorPending: y, clearCounterpart: C, prepareVendorForSave: w, onSaved: T, onPayableCreated: E, readSavedStatus: D, onDraftSaved: O, onFinalized: k, labels: A }) {
|
|
51
|
+
let j = {
|
|
52
|
+
...c,
|
|
53
|
+
...A
|
|
54
|
+
}, [M, N] = g(), P = t ?? M, [F, I] = g(), ie = m(() => I(void 0), []), [L, R] = g(!1), ae = m(() => R(!0), []), [z, B] = g(), V = h(!1), [H, U] = g(0), W = m(() => U((e) => e + 1), []), G = r(), K = i(), q = o(), J = n(), Y = s(), X = a(), Z = m(() => _.isTotalsDirty ? ne(_.discount, _.tax, _.totalOverride, j) : void 0, [_, j]), Q = m(() => {
|
|
55
|
+
let t = f(_.lineItems, j), n = Z();
|
|
56
|
+
return _.setLineItemErrors(t), _.setTotalsErrors(n), !t && !n || (_.setErrors(void 0), t && e.error(j.lineItemsNeedAttention), W(), !1);
|
|
57
|
+
}, [
|
|
58
|
+
_,
|
|
59
|
+
j,
|
|
60
|
+
W,
|
|
61
|
+
Z
|
|
62
|
+
]), $ = m(async (e, t) => {
|
|
63
|
+
let n = !P && F ? {
|
|
64
|
+
base64EncodedFile: await l(F),
|
|
65
|
+
fileName: F.name
|
|
66
|
+
} : void 0, r = ee({
|
|
67
|
+
values: _.values,
|
|
68
|
+
counterpartId: t ?? v,
|
|
69
|
+
clearCounterpart: C,
|
|
70
|
+
counterpartBankAccountId: e,
|
|
71
|
+
editedTotals: _.isTotalsDirty ? {
|
|
72
|
+
discount: _.discount,
|
|
73
|
+
tax: _.tax,
|
|
74
|
+
total: _.totalOverride
|
|
75
|
+
} : void 0,
|
|
76
|
+
document: n
|
|
77
|
+
}), i = P;
|
|
78
|
+
if (i ? await q.mutateAsync({
|
|
79
|
+
path: { payable_id: i },
|
|
80
|
+
body: r
|
|
81
|
+
}) : (i = (await G.mutateAsync({ body: r }))?.id, i && (N(i), E?.(i), n && I(void 0))), !i) throw Error("Payable was created without an id");
|
|
82
|
+
if (L) {
|
|
83
|
+
try {
|
|
84
|
+
await K.mutateAsync({ path: { payable_id: i } });
|
|
85
|
+
} catch {}
|
|
86
|
+
R(!1);
|
|
87
|
+
}
|
|
88
|
+
return await J.mutateAsync({
|
|
89
|
+
path: { payable_id: i },
|
|
90
|
+
body: { data: te(_.lineItems) }
|
|
91
|
+
}), i;
|
|
92
|
+
}, [
|
|
93
|
+
v,
|
|
94
|
+
C,
|
|
95
|
+
G,
|
|
96
|
+
K,
|
|
97
|
+
L,
|
|
98
|
+
_.discount,
|
|
99
|
+
_.isTotalsDirty,
|
|
100
|
+
_.lineItems,
|
|
101
|
+
_.tax,
|
|
102
|
+
_.totalOverride,
|
|
103
|
+
_.values,
|
|
104
|
+
E,
|
|
105
|
+
P,
|
|
106
|
+
J,
|
|
107
|
+
F,
|
|
108
|
+
q
|
|
109
|
+
]), oe = m(async () => {
|
|
110
|
+
P && (await K.mutateAsync({ path: { payable_id: P } }), R(!1));
|
|
111
|
+
}, [K, P]);
|
|
112
|
+
return {
|
|
113
|
+
saveDraft: m(async () => {
|
|
114
|
+
if (!V.current && Q()) {
|
|
115
|
+
V.current = !0, B("draft");
|
|
116
|
+
try {
|
|
117
|
+
let t = await w?.();
|
|
118
|
+
if (t && !t.ok) return;
|
|
119
|
+
let n = await $(t?.counterpartBankAccountId, t?.counterpartId);
|
|
120
|
+
_.setErrors(void 0), T?.(n), O?.(n);
|
|
121
|
+
let r = await D?.();
|
|
122
|
+
return e.success(r === "draft" ? j.submittedDemoted : j.draftSaved), n;
|
|
123
|
+
} catch (e) {
|
|
124
|
+
_.setSaveFailureMessage(x(e) ? j.discountTaxBlockedByLineItems : j.saveFailed), W();
|
|
125
|
+
return;
|
|
126
|
+
} finally {
|
|
127
|
+
B(void 0), V.current = !1;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
}, [
|
|
131
|
+
_,
|
|
132
|
+
Q,
|
|
133
|
+
j.discountTaxBlockedByLineItems,
|
|
134
|
+
j.draftSaved,
|
|
135
|
+
j.saveFailed,
|
|
136
|
+
j.submittedDemoted,
|
|
137
|
+
O,
|
|
138
|
+
T,
|
|
139
|
+
D,
|
|
140
|
+
w,
|
|
141
|
+
$,
|
|
142
|
+
W
|
|
143
|
+
]),
|
|
144
|
+
finalize: m(async () => {
|
|
145
|
+
if (V.current) return;
|
|
146
|
+
let t = f(_.lineItems, j), n = Z(), r = d(_.total, j), i = _.isTotalsDirty ? p(_.totalOverride, _.discount, j) : void 0, a = n || r || i ? {
|
|
147
|
+
...i,
|
|
148
|
+
...r,
|
|
149
|
+
...n
|
|
150
|
+
} : void 0, { formErrors: o, lineItemErrors: s } = u(_.values, v ?? (y ? b : void 0), _.lineItems, j), c = re(s, t);
|
|
151
|
+
_.setLineItemErrors(c), _.setTotalsErrors(a);
|
|
152
|
+
let l = o ?? {};
|
|
153
|
+
if (_.setErrors(Object.keys(l).length ? l : void 0), t && e.error(j.lineItemsNeedAttention), c || a || Object.keys(l).length) {
|
|
154
|
+
W();
|
|
155
|
+
return;
|
|
156
|
+
}
|
|
157
|
+
V.current = !0, B("finalize");
|
|
158
|
+
try {
|
|
159
|
+
let t;
|
|
160
|
+
try {
|
|
161
|
+
let e = await w?.();
|
|
162
|
+
if (e && !e.ok) return;
|
|
163
|
+
t = await $(e?.counterpartBankAccountId, e?.counterpartId);
|
|
164
|
+
} catch (e) {
|
|
165
|
+
_.setSaveFailureMessage(x(e) ? j.discountTaxBlockedByLineItems : j.saveFailed), W();
|
|
166
|
+
return;
|
|
167
|
+
}
|
|
168
|
+
T?.(t);
|
|
169
|
+
try {
|
|
170
|
+
let n = await Y.mutateAsync({ path: { payable_id: t } });
|
|
171
|
+
if (n.validation_errors.length) {
|
|
172
|
+
let e = S(n.validation_errors, j);
|
|
173
|
+
_.setErrors(e.formErrors), _.setTotalsErrors(e.totalsErrors), W();
|
|
174
|
+
return;
|
|
175
|
+
}
|
|
176
|
+
await X.mutateAsync({ path: { payable_id: t } }), _.setErrors(void 0), k?.(t), e.success(j.billFinalized);
|
|
177
|
+
} catch {
|
|
178
|
+
_.setSaveFailureMessage(j.finalizeFailed), W();
|
|
179
|
+
}
|
|
180
|
+
} finally {
|
|
181
|
+
B(void 0), V.current = !1;
|
|
182
|
+
}
|
|
183
|
+
}, [
|
|
184
|
+
v,
|
|
185
|
+
y,
|
|
186
|
+
_,
|
|
187
|
+
j,
|
|
188
|
+
k,
|
|
189
|
+
T,
|
|
190
|
+
w,
|
|
191
|
+
$,
|
|
192
|
+
W,
|
|
193
|
+
X,
|
|
194
|
+
Z,
|
|
195
|
+
Y
|
|
196
|
+
]),
|
|
197
|
+
payableId: P,
|
|
198
|
+
isSavingDraft: z === "draft",
|
|
199
|
+
isFinalizing: z === "finalize",
|
|
200
|
+
stagedFile: F,
|
|
201
|
+
stageFile: I,
|
|
202
|
+
clearStagedFile: ie,
|
|
203
|
+
scrollToErrorToken: H,
|
|
204
|
+
isFileDeletionPending: L,
|
|
205
|
+
requestFileDeletion: ae,
|
|
206
|
+
detachFileNow: oe,
|
|
207
|
+
isDeletingFile: K.isPending,
|
|
208
|
+
hasFileDeletionFailed: K.isError
|
|
209
|
+
};
|
|
55
210
|
}
|
|
56
211
|
//#endregion
|
|
57
|
-
export {
|
|
212
|
+
export { S as mapValidationErrorsToForm, C as useBillCreateController };
|