@tesouro/embedded-components-react 0.11.179 → 0.11.180
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/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/data-access/dist/index.js +24 -23
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/data-access/dist/index10.js +16 -18
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/data-access/dist/index11.js +3 -3
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/data-access/dist/index12.js +5 -7
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/data-access/dist/index13.js +2 -2
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/data-access/dist/index14.js +4 -3
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/data-access/dist/index15.js +13 -27
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/data-access/dist/index16.js +34 -19
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/data-access/dist/index17.js +23 -16
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/data-access/dist/index18.js +26 -12
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/data-access/dist/index19.js +12 -57
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/data-access/dist/index2.js +34 -85
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/data-access/dist/index20.js +48 -29
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/data-access/dist/index21.js +36 -20
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/data-access/dist/index22.js +20 -18
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/data-access/dist/index23.js +14 -37
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/data-access/dist/index24.js +31 -14
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/data-access/dist/index25.js +26 -2
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/data-access/dist/index26.js +2 -0
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/data-access/dist/index3.js +90 -20
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/data-access/dist/index4.js +30 -8
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/data-access/dist/index5.js +8 -74
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/data-access/dist/index6.js +60 -19
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/data-access/dist/index7.js +6 -5
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/data-access/dist/index8.js +12 -17
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/data-access/dist/index9.js +20 -12
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index.js +7 -7
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index10.js +17 -36
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index11.js +42 -54
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index12.js +89 -6
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index13.js +5 -21
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index14.js +15 -92
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index15.js +103 -10
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index16.js +10 -9
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index17.js +8 -7
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index18.js +7 -9
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index19.js +11 -29
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index20.js +24 -24
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index21.js +22 -14
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index22.js +14 -137
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index23.js +139 -13
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index24.js +12 -18
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index25.js +15 -32
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index26.js +39 -108
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index27.js +96 -80
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index28.js +94 -3
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index29.js +4 -57
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index30.js +56 -116
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index31.js +114 -197
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index32.js +194 -75
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index33.js +75 -67
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index34.js +69 -111
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index35.js +108 -459
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index36.js +450 -102
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index37.js +117 -9
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index38.js +8 -85
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index39.js +73 -67
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index4.js +1 -1
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index40.js +71 -246
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index41.js +251 -40
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index42.js +38 -237
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index43.js +244 -21
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index44.js +21 -529
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index45.js +530 -4
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index46.js +4 -44
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index47.js +41 -242
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index48.js +245 -3
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index49.js +3 -5
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index50.js +4 -63
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index51.js +64 -1
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index52.js +1 -0
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index9.js +6 -18
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/ui/dist/index3.js +7 -3
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/data-access/dist/lib/invalidatePayableQueries/approvalDecisionQueries.js +22 -19
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/data-access/dist/lib/invalidatePayableQueries/invalidatePayableQueries.js +20 -20
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/data-access/dist/lib/queryKeys.js +32 -21
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/lib/BillPayWidget/BillsTab.js +1 -1
- package/dist/libs/tesouro-embedded-components-react/shared/approval-policy/feature/dist/index.js +4 -4
- package/dist/libs/tesouro-embedded-components-react/shared/data-access/dist/index.js +42 -42
- package/dist/libs/tesouro-embedded-components-react/shared/data-access/dist/lib/rest/@tanstack/react-query.gen.js +237 -215
- package/dist/libs/tesouro-embedded-components-react/shared/data-access/dist/lib/rest/sdk.gen.js +151 -135
- package/dist/libs/tesouro-embedded-components-react/shared/feature/dist/lib/analytics/build-info.js +1 -1
- package/package.json +1 -1
|
@@ -1,88 +1,11 @@
|
|
|
1
|
-
import { parseDecimalAmountToMinorUnits as e } from "../../../../shared/util/dist/lib/parseDecimalAmountToMinorUnits.js";
|
|
2
|
-
import "../../../../shared/util/dist/index.js";
|
|
3
|
-
import "../../../util/dist/index.js";
|
|
4
1
|
// ../../libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index38.js
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
let n = Number(t);
|
|
13
|
-
return Number.isFinite(n) && n > 0 ? n : null;
|
|
14
|
-
}
|
|
15
|
-
function i(e) {
|
|
16
|
-
return !!(e.description.trim() || e.glCode.trim() || n(e.price) !== null || n(e.amount) !== null);
|
|
17
|
-
}
|
|
18
|
-
function a(e) {
|
|
19
|
-
return n(e) ?? 0;
|
|
20
|
-
}
|
|
21
|
-
function o(e) {
|
|
22
|
-
let t = Number.parseFloat(e);
|
|
23
|
-
return Number.isFinite(t) ? t : 0;
|
|
24
|
-
}
|
|
25
|
-
function s(e) {
|
|
26
|
-
let t = n(e);
|
|
27
|
-
return t === null ? e : c(t);
|
|
28
|
-
}
|
|
29
|
-
function c(e) {
|
|
30
|
-
return (e / 100).toFixed(2);
|
|
31
|
-
}
|
|
32
|
-
function l({ values: e, initialLineItems: r, counterpartId: i, clearCounterpart: a, counterpartBankAccountId: o, editedTotals: s, currentTotals: c, lineItems: l, document: f, includeBlankPoNumber: p = !0 }) {
|
|
33
|
-
let m = { currency: t };
|
|
34
|
-
i ? m.counterpart_id = i : a && (m.counterpart_id = null), i ? m.counterpart_bank_account_id = o ?? null : a && (m.counterpart_bank_account_id = null), e.invoiceNumber && (m.document_id = e.invoiceNumber), e.invoiceDate && (m.issued_at = e.invoiceDate), e.dueDate && (m.due_date = e.dueDate);
|
|
35
|
-
let h = e.poNumber.trim();
|
|
36
|
-
if ((h || p) && (m.purchase_order_number = h || null), f && (m.base64_encoded_file = f.base64EncodedFile, m.file_name = f.fileName), s && (m.discount = n(s.discount) ?? 0, m.tax_amount = n(s.tax) ?? 0, s.total !== void 0 && (m.total_amount = n(s.total) ?? 0)), c && l) {
|
|
37
|
-
let e = d(l), t = n(c.tax) ?? 0, r = n(c.discount) ?? 0, i = c.total === void 0 ? (e ?? 0) - r + t : n(c.total) ?? 0;
|
|
38
|
-
e !== void 0 && (m.subtotal = e), m.discount = r, m.tax_amount = t, m.total_amount = i;
|
|
39
|
-
} else if (r && !("total_amount" in m)) {
|
|
40
|
-
let e = u(r, {
|
|
41
|
-
tax: s?.tax,
|
|
42
|
-
discount: s?.discount
|
|
43
|
-
});
|
|
44
|
-
e !== void 0 && (m.total_amount = e);
|
|
45
|
-
}
|
|
46
|
-
return m;
|
|
47
|
-
}
|
|
48
|
-
function u(e, { tax: t, discount: r }) {
|
|
49
|
-
let i = d(e);
|
|
50
|
-
if (i !== void 0) return i + (t ? n(t) ?? 0 : 0) - (r ? n(r) ?? 0 : 0);
|
|
51
|
-
}
|
|
52
|
-
function d(e) {
|
|
53
|
-
let t = !1, r = e.reduce((e, r) => {
|
|
54
|
-
if (!i(r)) return e;
|
|
55
|
-
let a = n(r.amount);
|
|
56
|
-
return a === null ? e : (t = !0, e + a);
|
|
57
|
-
}, 0);
|
|
58
|
-
if (t) return r;
|
|
59
|
-
}
|
|
60
|
-
function f({ lineItems: e, editedTotals: t }) {
|
|
61
|
-
let r = d(e), i = n(t.tax) ?? 0, a = n(t.discount) ?? 0, o = {
|
|
62
|
-
discount: a,
|
|
63
|
-
tax_amount: i
|
|
64
|
-
};
|
|
65
|
-
return r !== void 0 && (o.subtotal = r), t.total === void 0 ? r !== void 0 && (o.total_amount = r - a + i) : o.total_amount = n(t.total) ?? 0, o;
|
|
66
|
-
}
|
|
67
|
-
function p(e) {
|
|
68
|
-
return e.filter(i).map((e) => {
|
|
69
|
-
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), s = t ?? o;
|
|
70
|
-
return {
|
|
71
|
-
name: e.description,
|
|
72
|
-
quantity: i,
|
|
73
|
-
unit_price: a,
|
|
74
|
-
tax: 0,
|
|
75
|
-
subtotal: s,
|
|
76
|
-
tax_amount: 0,
|
|
77
|
-
total: s,
|
|
78
|
-
...e.glCode ? { ledger_account_id: e.glCode } : {}
|
|
79
|
-
};
|
|
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
|
+
typeof e == "string" ? t(e.slice(e.indexOf(",") + 1)) : n(/* @__PURE__ */ Error("Failed to read file as a data URL"));
|
|
8
|
+
}, r.readAsDataURL(e);
|
|
80
9
|
});
|
|
81
10
|
}
|
|
82
|
-
|
|
83
|
-
return c(Math.round(o(e) * a(t)));
|
|
84
|
-
}
|
|
85
|
-
function h(e, t, n) {
|
|
86
|
-
return c(e.reduce((e, t) => e + a(t.amount), 0) + a(t) - a(n));
|
|
87
|
-
}
|
|
88
|
-
export { h as calculateTotal, m as displayLineAmount, i as isPersistableLineItem, l as mapBillFormToPayload, p as mapLineItemsToPayload, f as mapPayableAmountFieldsToPayload, s as normalizeMoneyOnBlur, n as parseMoneyToMinorUnits, r as parseQuantity };
|
|
11
|
+
export { e as encodeFileToBase64 };
|
|
@@ -1,82 +1,88 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
1
|
+
import { parseDecimalAmountToMinorUnits as e } from "../../../../shared/util/dist/lib/parseDecimalAmountToMinorUnits.js";
|
|
2
|
+
import "../../../../shared/util/dist/index.js";
|
|
3
|
+
import "../../../util/dist/index.js";
|
|
3
4
|
// ../../libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index39.js
|
|
4
|
-
var
|
|
5
|
-
function
|
|
6
|
-
|
|
7
|
-
return Date.UTC(e.getFullYear(), e.getMonth(), e.getDate());
|
|
5
|
+
var t = "USD";
|
|
6
|
+
function n(n) {
|
|
7
|
+
return e(n, t);
|
|
8
8
|
}
|
|
9
|
-
function
|
|
10
|
-
let
|
|
11
|
-
|
|
9
|
+
function r(e) {
|
|
10
|
+
let t = e.trim();
|
|
11
|
+
if (!t) return null;
|
|
12
|
+
let n = Number(t);
|
|
13
|
+
return Number.isFinite(n) && n > 0 ? n : null;
|
|
12
14
|
}
|
|
13
|
-
function
|
|
14
|
-
|
|
15
|
-
if (Number.isNaN(t.getTime())) return !1;
|
|
16
|
-
let n = new Date(u() + c * l);
|
|
17
|
-
return t < d() || t > n;
|
|
15
|
+
function i(e) {
|
|
16
|
+
return !!(e.description.trim() || e.glCode.trim() || n(e.price) !== null || n(e.amount) !== null);
|
|
18
17
|
}
|
|
19
|
-
function
|
|
20
|
-
|
|
21
|
-
if (Number.isNaN(t.getTime())) return !1;
|
|
22
|
-
let n = new Date(u());
|
|
23
|
-
return n.setUTCFullYear(n.getUTCFullYear() + s), t < d() || t > n;
|
|
18
|
+
function a(e) {
|
|
19
|
+
return n(e) ?? 0;
|
|
24
20
|
}
|
|
25
|
-
function
|
|
26
|
-
let
|
|
27
|
-
return
|
|
21
|
+
function o(e) {
|
|
22
|
+
let t = Number.parseFloat(e);
|
|
23
|
+
return Number.isFinite(t) ? t : 0;
|
|
28
24
|
}
|
|
29
|
-
function
|
|
30
|
-
let t = e
|
|
31
|
-
return
|
|
25
|
+
function s(e) {
|
|
26
|
+
let t = n(e);
|
|
27
|
+
return t === null ? e : c(t);
|
|
32
28
|
}
|
|
33
|
-
function
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
29
|
+
function c(e) {
|
|
30
|
+
return (e / 100).toFixed(2);
|
|
31
|
+
}
|
|
32
|
+
function l({ values: e, initialLineItems: r, counterpartId: i, clearCounterpart: a, counterpartBankAccountId: o, editedTotals: s, currentTotals: c, lineItems: l, document: f, includeBlankPoNumber: p = !0 }) {
|
|
33
|
+
let m = { currency: t };
|
|
34
|
+
i ? m.counterpart_id = i : a && (m.counterpart_id = null), i ? m.counterpart_bank_account_id = o ?? null : a && (m.counterpart_bank_account_id = null), e.invoiceNumber && (m.document_id = e.invoiceNumber), e.invoiceDate && (m.issued_at = e.invoiceDate), e.dueDate && (m.due_date = e.dueDate);
|
|
35
|
+
let h = e.poNumber.trim();
|
|
36
|
+
if ((h || p) && (m.purchase_order_number = h || null), f && (m.base64_encoded_file = f.base64EncodedFile, m.file_name = f.fileName), s && (m.discount = n(s.discount) ?? 0, m.tax_amount = n(s.tax) ?? 0, s.total !== void 0 && (m.total_amount = n(s.total) ?? 0)), c && l) {
|
|
37
|
+
let e = d(l), t = n(c.tax) ?? 0, r = n(c.discount) ?? 0, i = c.total === void 0 ? (e ?? 0) - r + t : n(c.total) ?? 0;
|
|
38
|
+
e !== void 0 && (m.subtotal = e), m.discount = r, m.tax_amount = t, m.total_amount = i;
|
|
39
|
+
} else if (r && !("total_amount" in m)) {
|
|
40
|
+
let e = u(r, {
|
|
41
|
+
tax: s?.tax,
|
|
42
|
+
discount: s?.discount
|
|
43
|
+
});
|
|
44
|
+
e !== void 0 && (m.total_amount = e);
|
|
38
45
|
}
|
|
39
|
-
return
|
|
46
|
+
return m;
|
|
40
47
|
}
|
|
41
|
-
function
|
|
42
|
-
let
|
|
43
|
-
|
|
44
|
-
let l = i.invoiceDate.trim(), u = i.dueDate.trim();
|
|
45
|
-
l ? f(l) && (c.invoiceDate = s.implausibleInvoiceDate) : c.invoiceDate = s.requiredField, u ? p(u) ? c.dueDate = s.implausibleDueDate : l && u < l && (c.dueDate = s.dueBeforeInvoiceDate) : c.dueDate = s.requiredField;
|
|
46
|
-
let d = {};
|
|
47
|
-
return o.forEach((e, i) => {
|
|
48
|
-
if (i > 0 && !t(e)) return;
|
|
49
|
-
let a = {};
|
|
50
|
-
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 && (d[e.id] = a);
|
|
51
|
-
}), {
|
|
52
|
-
formErrors: Object.keys(c).length ? c : void 0,
|
|
53
|
-
lineItemErrors: Object.keys(d).length ? d : void 0
|
|
54
|
-
};
|
|
48
|
+
function u(e, { tax: t, discount: r }) {
|
|
49
|
+
let i = d(e);
|
|
50
|
+
if (i !== void 0) return i + (t ? n(t) ?? 0 : 0) - (r ? n(r) ?? 0 : 0);
|
|
55
51
|
}
|
|
56
|
-
function
|
|
57
|
-
let t = e.
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
52
|
+
function d(e) {
|
|
53
|
+
let t = !1, r = e.reduce((e, r) => {
|
|
54
|
+
if (!i(r)) return e;
|
|
55
|
+
let a = n(r.amount);
|
|
56
|
+
return a === null ? e : (t = !0, e + a);
|
|
57
|
+
}, 0);
|
|
58
|
+
if (t) return r;
|
|
61
59
|
}
|
|
62
|
-
function
|
|
63
|
-
|
|
60
|
+
function f({ lineItems: e, editedTotals: t }) {
|
|
61
|
+
let r = d(e), i = n(t.tax) ?? 0, a = n(t.discount) ?? 0, o = {
|
|
62
|
+
discount: a,
|
|
63
|
+
tax_amount: i
|
|
64
|
+
};
|
|
65
|
+
return r !== void 0 && (o.subtotal = r), t.total === void 0 ? r !== void 0 && (o.total_amount = r - a + i) : o.total_amount = n(t.total) ?? 0, o;
|
|
64
66
|
}
|
|
65
|
-
function
|
|
66
|
-
|
|
67
|
-
|
|
67
|
+
function p(e) {
|
|
68
|
+
return e.filter(i).map((e) => {
|
|
69
|
+
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), s = t ?? o;
|
|
70
|
+
return {
|
|
71
|
+
name: e.description,
|
|
72
|
+
quantity: i,
|
|
73
|
+
unit_price: a,
|
|
74
|
+
tax: 0,
|
|
75
|
+
subtotal: s,
|
|
76
|
+
tax_amount: 0,
|
|
77
|
+
total: s,
|
|
78
|
+
...e.glCode ? { ledger_account_id: e.glCode } : {}
|
|
79
|
+
};
|
|
80
|
+
});
|
|
68
81
|
}
|
|
69
|
-
function
|
|
70
|
-
|
|
71
|
-
let i = n(t);
|
|
72
|
-
if (i !== null) return i > 0 ? void 0 : { total: r.totalNotGreaterThanZero };
|
|
82
|
+
function m(e, t) {
|
|
83
|
+
return c(Math.round(o(e) * a(t)));
|
|
73
84
|
}
|
|
74
|
-
function
|
|
75
|
-
|
|
76
|
-
if (h(t) || (a.discount = i.unreadableDiscount), h(n) || (a.tax = i.unreadableTax), r !== void 0) {
|
|
77
|
-
let e = y(r, i);
|
|
78
|
-
e && (a.total = e);
|
|
79
|
-
}
|
|
80
|
-
return Object.keys(a).length ? a : void 0;
|
|
85
|
+
function h(e, t, n) {
|
|
86
|
+
return c(e.reduce((e, t) => e + a(t.amount), 0) + a(t) - a(n));
|
|
81
87
|
}
|
|
82
|
-
export { h as
|
|
88
|
+
export { h as calculateTotal, m as displayLineAmount, i as isPersistableLineItem, l as mapBillFormToPayload, p as mapLineItemsToPayload, f as mapPayableAmountFieldsToPayload, s as normalizeMoneyOnBlur, n as parseMoneyToMinorUnits, r as parseQuantity };
|
|
@@ -18,7 +18,7 @@ import "../../../util/dist/index.js";
|
|
|
18
18
|
import { derivePayableStatus as d } from "../../../../shared/document-status/util/dist/lib/derivePayableStatus.js";
|
|
19
19
|
import { useApplyDuplicateVerdictsMutation as f } from "../../../data-access/dist/lib/useApplyDuplicateVerdictsMutation.js";
|
|
20
20
|
import "../../../data-access/dist/index.js";
|
|
21
|
-
import { usePayablesByIdsQueries as p } from "../../data-access/dist/
|
|
21
|
+
import { usePayablesByIdsQueries as p } from "../../data-access/dist/index25.js";
|
|
22
22
|
import "../../data-access/dist/index.js";
|
|
23
23
|
import { DUPLICATE_BILLS_LABELS_EN as m } from "./index3.js";
|
|
24
24
|
import { useCallback as h, useMemo as g, useState as _ } from "react";
|
|
@@ -1,257 +1,82 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
"use client";
|
|
4
|
-
"use client";
|
|
5
|
-
import { toast as e } from "../../../../../../node_modules/sonner/dist/index.js";
|
|
6
|
-
import { extractApiErrorMessage as t } from "../../../../shared/util/dist/lib/apiErrors.js";
|
|
7
|
-
import "../../../../shared/util/dist/index.js";
|
|
8
|
-
import { isApiConflictError as n } from "../../../../shared/data-access/dist/lib/isApiConflictError.js";
|
|
9
|
-
import { isApiUnprocessableError as r } from "../../../../shared/data-access/dist/lib/isApiUnprocessableError.js";
|
|
10
|
-
import "../../../../shared/data-access/dist/index.js";
|
|
11
|
-
import "../../../../shared/ui/dist/index.js";
|
|
12
|
-
import { BILL_CREATE_MESSAGE_LABELS_EN as i } from "./index31.js";
|
|
13
|
-
import { encodeFileToBase64 as a } from "./index37.js";
|
|
14
|
-
import { mapBillFormToPayload as o, mapLineItemsToPayload as s, mapPayableAmountFieldsToPayload as c } from "./index38.js";
|
|
15
|
-
import { validateBillCompleteness as l, validateBillTotalIsPayable as u, validateBillTotals as d, validateBillValues as f, validateLineItems as p, validateStoredAmountDue as ee } from "./index39.js";
|
|
16
|
-
import { useReplacePayableLineItemsMutation as m } from "../../data-access/dist/index5.js";
|
|
17
|
-
import { useCreatePayableMutation as h } from "../../data-access/dist/index9.js";
|
|
18
|
-
import { useDeletePayableFileMutation as g } from "../../data-access/dist/index10.js";
|
|
19
|
-
import { useSubmitPayableForApprovalMutation as te } from "../../data-access/dist/index15.js";
|
|
20
|
-
import { useUpdatePayableMutation as ne } from "../../data-access/dist/index16.js";
|
|
21
|
-
import { useValidatePayableMutation as re } from "../../data-access/dist/index17.js";
|
|
22
|
-
import "../../data-access/dist/index.js";
|
|
23
|
-
import { useCallback as _, useRef as v, useState as y } from "react";
|
|
1
|
+
import { BILL_CREATE_MESSAGE_LABELS_EN as e } from "./index32.js";
|
|
2
|
+
import { isPersistableLineItem as t, parseMoneyToMinorUnits as n, parseQuantity as r } from "./index39.js";
|
|
24
3
|
// ../../libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index40.js
|
|
25
|
-
var
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
counterpart_id: "vendor",
|
|
30
|
-
purchase_order_number: "poNumber"
|
|
31
|
-
}, x = { tax_amount: "tax" };
|
|
32
|
-
function S(e) {
|
|
33
|
-
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+)$/, a = 255, o = 10, s = 5, c = 30, l = 864e5;
|
|
5
|
+
function u() {
|
|
6
|
+
let e = /* @__PURE__ */ new Date();
|
|
7
|
+
return Date.UTC(e.getFullYear(), e.getMonth(), e.getDate());
|
|
34
8
|
}
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
return
|
|
9
|
+
function d() {
|
|
10
|
+
let e = new Date(u());
|
|
11
|
+
return e.setUTCFullYear(e.getUTCFullYear() - o), e;
|
|
38
12
|
}
|
|
39
|
-
function
|
|
40
|
-
|
|
13
|
+
function f(e) {
|
|
14
|
+
let t = new Date(e);
|
|
15
|
+
if (Number.isNaN(t.getTime())) return !1;
|
|
16
|
+
let n = new Date(u() + c * l);
|
|
17
|
+
return t < d() || t > n;
|
|
41
18
|
}
|
|
42
|
-
function
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
19
|
+
function p(e) {
|
|
20
|
+
let t = new Date(e);
|
|
21
|
+
if (Number.isNaN(t.getTime())) return !1;
|
|
22
|
+
let n = new Date(u());
|
|
23
|
+
return n.setUTCFullYear(n.getUTCFullYear() + s), t < d() || t > n;
|
|
46
24
|
}
|
|
47
|
-
function
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
return n ? t.saveRejected(n) : t.saveFailed;
|
|
25
|
+
function m(t, n = e) {
|
|
26
|
+
let r = {};
|
|
27
|
+
return t.poNumber.length > a && (r.poNumber = n.poNumberTooLong), Object.keys(r).length ? r : void 0;
|
|
51
28
|
}
|
|
52
|
-
function
|
|
53
|
-
let
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
29
|
+
function h(e) {
|
|
30
|
+
let t = e.trim();
|
|
31
|
+
return !t || n(t) !== null ? !0 : i.test(t) ? Number(t.replaceAll(",", "")) === 0 : !1;
|
|
32
|
+
}
|
|
33
|
+
function g(t, i = e) {
|
|
34
|
+
let a = {};
|
|
35
|
+
for (let e of t) {
|
|
36
|
+
let t = n(e.price), o = n(e.amount), s = {};
|
|
37
|
+
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);
|
|
57
38
|
}
|
|
58
|
-
return a.length
|
|
59
|
-
formErrors: n,
|
|
60
|
-
totalsErrors: Object.keys(r).length ? r : void 0
|
|
61
|
-
};
|
|
39
|
+
return Object.keys(a).length ? a : void 0;
|
|
62
40
|
}
|
|
63
|
-
function
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
41
|
+
function _(i, a, o, s = e) {
|
|
42
|
+
let c = {};
|
|
43
|
+
a || (c.vendor = s.requiredField), i.invoiceNumber.trim() || (c.invoiceNumber = s.requiredField);
|
|
44
|
+
let l = i.invoiceDate.trim(), u = i.dueDate.trim();
|
|
45
|
+
l ? f(l) && (c.invoiceDate = s.implausibleInvoiceDate) : c.invoiceDate = s.requiredField, u ? p(u) ? c.dueDate = s.implausibleDueDate : l && u < l && (c.dueDate = s.dueBeforeInvoiceDate) : c.dueDate = s.requiredField;
|
|
46
|
+
let d = {};
|
|
47
|
+
return o.forEach((e, i) => {
|
|
48
|
+
if (i > 0 && !t(e)) return;
|
|
49
|
+
let a = {};
|
|
50
|
+
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 && (d[e.id] = a);
|
|
51
|
+
}), {
|
|
52
|
+
formErrors: Object.keys(c).length ? c : void 0,
|
|
53
|
+
lineItemErrors: Object.keys(d).length ? d : void 0
|
|
69
54
|
};
|
|
70
|
-
return n;
|
|
71
55
|
}
|
|
72
|
-
function
|
|
73
|
-
let
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
counterpartBankAccountId: e,
|
|
98
|
-
currentTotals: {
|
|
99
|
-
discount: n.discount,
|
|
100
|
-
tax: n.tax,
|
|
101
|
-
total: n.totalOverride
|
|
102
|
-
},
|
|
103
|
-
lineItems: n.lineItems,
|
|
104
|
-
editedTotals: u,
|
|
105
|
-
document: l
|
|
106
|
-
}), f = i ? {
|
|
107
|
-
...d,
|
|
108
|
-
counterpart_raw_data: i
|
|
109
|
-
} : d, p = I;
|
|
110
|
-
if (p ? await q.mutateAsync({
|
|
111
|
-
path: { payable_id: p },
|
|
112
|
-
body: f
|
|
113
|
-
}) : (p = (await G.mutateAsync({ body: f }))?.id, p && (F(p), O?.(p), l && R(void 0))), !p) throw Error("Payable was created without an id");
|
|
114
|
-
if (z) {
|
|
115
|
-
try {
|
|
116
|
-
await K.mutateAsync({ path: { payable_id: p } });
|
|
117
|
-
} catch {}
|
|
118
|
-
B(!1);
|
|
119
|
-
}
|
|
120
|
-
return await J.mutateAsync({
|
|
121
|
-
path: { payable_id: p },
|
|
122
|
-
body: { data: s(n.lineItems) }
|
|
123
|
-
}), u && await q.mutateAsync({
|
|
124
|
-
path: { payable_id: p },
|
|
125
|
-
body: c({
|
|
126
|
-
lineItems: n.lineItems,
|
|
127
|
-
editedTotals: u
|
|
128
|
-
})
|
|
129
|
-
}), p;
|
|
130
|
-
}, [
|
|
131
|
-
r,
|
|
132
|
-
S,
|
|
133
|
-
G,
|
|
134
|
-
K,
|
|
135
|
-
z,
|
|
136
|
-
n.discount,
|
|
137
|
-
n.isTotalsDirty,
|
|
138
|
-
n.lineItems,
|
|
139
|
-
n.tax,
|
|
140
|
-
n.totalOverride,
|
|
141
|
-
n.values,
|
|
142
|
-
O,
|
|
143
|
-
I,
|
|
144
|
-
J,
|
|
145
|
-
L,
|
|
146
|
-
q
|
|
147
|
-
]), ue = _(async () => {
|
|
148
|
-
I && (await K.mutateAsync({ path: { payable_id: I } }), B(!1));
|
|
149
|
-
}, [K, I]);
|
|
150
|
-
return {
|
|
151
|
-
saveDraft: _(async () => {
|
|
152
|
-
if (!U.current && Q()) {
|
|
153
|
-
U.current = !0, H("draft");
|
|
154
|
-
try {
|
|
155
|
-
let t = await C?.({ allowIncompleteVendor: !0 });
|
|
156
|
-
if (t && !t.ok) return;
|
|
157
|
-
let r = await $(t?.counterpartBankAccountId, t?.counterpartId, t?.counterpartRawData);
|
|
158
|
-
n.setErrors(void 0), T?.(r), A?.(r);
|
|
159
|
-
let i = await k?.();
|
|
160
|
-
return e.success(i === "draft" ? N.submittedDemoted : N.draftSaved), r;
|
|
161
|
-
} catch (e) {
|
|
162
|
-
n.setSaveFailureMessage(E(e, {
|
|
163
|
-
discountTaxBlockedByLineItems: N.discountTaxBlockedByLineItems,
|
|
164
|
-
saveFailed: N.saveFailed,
|
|
165
|
-
saveRejected: N.saveRejected
|
|
166
|
-
})), W();
|
|
167
|
-
return;
|
|
168
|
-
} finally {
|
|
169
|
-
H(void 0), U.current = !1;
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
}, [
|
|
173
|
-
n,
|
|
174
|
-
Q,
|
|
175
|
-
N.discountTaxBlockedByLineItems,
|
|
176
|
-
N.draftSaved,
|
|
177
|
-
N.saveFailed,
|
|
178
|
-
N.saveRejected,
|
|
179
|
-
N.submittedDemoted,
|
|
180
|
-
A,
|
|
181
|
-
T,
|
|
182
|
-
k,
|
|
183
|
-
C,
|
|
184
|
-
$,
|
|
185
|
-
W
|
|
186
|
-
]),
|
|
187
|
-
finalize: _(async () => {
|
|
188
|
-
if (U.current) return;
|
|
189
|
-
let t = p(n.lineItems, N), i = f(n.values, N), a = Z(), o = u(n.total, N), s = n.isTotalsDirty ? ee(n.totalOverride, N) : void 0, c = a || o || s ? {
|
|
190
|
-
...s,
|
|
191
|
-
...o,
|
|
192
|
-
...a
|
|
193
|
-
} : void 0, { formErrors: d, lineItemErrors: m } = l(n.values, r ?? (b ? ie : void 0), n.lineItems, N), h = ae(m, t);
|
|
194
|
-
n.setLineItemErrors(h), n.setTotalsErrors(c);
|
|
195
|
-
let g = {
|
|
196
|
-
...d,
|
|
197
|
-
...i
|
|
198
|
-
};
|
|
199
|
-
if (n.setErrors(Object.keys(g).length ? g : void 0), t && e.error(N.lineItemsNeedAttention), h || c || Object.keys(g).length) g.vendor && x?.(), W();
|
|
200
|
-
else {
|
|
201
|
-
U.current = !0, H("finalize");
|
|
202
|
-
try {
|
|
203
|
-
let t;
|
|
204
|
-
try {
|
|
205
|
-
let e = await C?.();
|
|
206
|
-
if (e && !e.ok) return;
|
|
207
|
-
t = await $(e?.counterpartBankAccountId, e?.counterpartId);
|
|
208
|
-
} catch (e) {
|
|
209
|
-
n.setSaveFailureMessage(E(e, N)), W();
|
|
210
|
-
return;
|
|
211
|
-
}
|
|
212
|
-
T?.(t);
|
|
213
|
-
try {
|
|
214
|
-
let r = await Y.mutateAsync({ path: { payable_id: t } });
|
|
215
|
-
if (r.validation_errors.length) {
|
|
216
|
-
let e = D(r.validation_errors, N);
|
|
217
|
-
n.setErrors(e.formErrors), n.setTotalsErrors(e.totalsErrors), W();
|
|
218
|
-
return;
|
|
219
|
-
}
|
|
220
|
-
await X.mutateAsync({ path: { payable_id: t } }), n.setErrors(void 0), j?.(t), e.success(N.billFinalized);
|
|
221
|
-
} catch (e) {
|
|
222
|
-
w(e) ? n.setErrors({ vendor: N.vendorResolutionFailed }) : n.setSaveFailureMessage(N.finalizeFailed), W();
|
|
223
|
-
}
|
|
224
|
-
} finally {
|
|
225
|
-
H(void 0), U.current = !1;
|
|
226
|
-
}
|
|
227
|
-
}
|
|
228
|
-
}, [
|
|
229
|
-
r,
|
|
230
|
-
b,
|
|
231
|
-
n,
|
|
232
|
-
N,
|
|
233
|
-
j,
|
|
234
|
-
T,
|
|
235
|
-
x,
|
|
236
|
-
C,
|
|
237
|
-
$,
|
|
238
|
-
W,
|
|
239
|
-
X,
|
|
240
|
-
Z,
|
|
241
|
-
Y
|
|
242
|
-
]),
|
|
243
|
-
payableId: I,
|
|
244
|
-
isSavingDraft: V === "draft",
|
|
245
|
-
isFinalizing: V === "finalize",
|
|
246
|
-
stagedFile: L,
|
|
247
|
-
stageFile: R,
|
|
248
|
-
clearStagedFile: oe,
|
|
249
|
-
scrollToErrorToken: ce,
|
|
250
|
-
isFileDeletionPending: z,
|
|
251
|
-
requestFileDeletion: se,
|
|
252
|
-
detachFileNow: ue,
|
|
253
|
-
isDeletingFile: K.isPending,
|
|
254
|
-
hasFileDeletionFailed: K.isError
|
|
255
|
-
};
|
|
56
|
+
function v(e) {
|
|
57
|
+
let t = e.trim();
|
|
58
|
+
if (!t) return !0;
|
|
59
|
+
let n = t.startsWith("-") ? t.slice(1) : t;
|
|
60
|
+
return i.test(n) ? Number(t.replaceAll(",", "")) <= 0 : !1;
|
|
61
|
+
}
|
|
62
|
+
function y(e, t) {
|
|
63
|
+
if (n(e) === null) return v(e) ? t.totalNotGreaterThanZero : t.unreadableTotal;
|
|
64
|
+
}
|
|
65
|
+
function b(t, n = e) {
|
|
66
|
+
let r = y(t, n);
|
|
67
|
+
return r ? { total: r } : void 0;
|
|
68
|
+
}
|
|
69
|
+
function x(t, r = e) {
|
|
70
|
+
if (t === void 0) return;
|
|
71
|
+
let i = n(t);
|
|
72
|
+
if (i !== null) return i > 0 ? void 0 : { total: r.totalNotGreaterThanZero };
|
|
73
|
+
}
|
|
74
|
+
function S(t, n, r, i = e) {
|
|
75
|
+
let a = {};
|
|
76
|
+
if (h(t) || (a.discount = i.unreadableDiscount), h(n) || (a.tax = i.unreadableTax), r !== void 0) {
|
|
77
|
+
let e = y(r, i);
|
|
78
|
+
e && (a.total = e);
|
|
79
|
+
}
|
|
80
|
+
return Object.keys(a).length ? a : void 0;
|
|
256
81
|
}
|
|
257
|
-
export {
|
|
82
|
+
export { h as isReadableMoneyOrZero, _ as validateBillCompleteness, b as validateBillTotalIsPayable, S as validateBillTotals, m as validateBillValues, g as validateLineItems, x as validateStoredAmountDue };
|