@tesouro/embedded-components-react 0.5.169 → 0.5.170
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 +39 -17
- package/dist/index.js +1 -1
- package/dist/lib/BillPayWidget.js +1 -1
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/data-access/dist/index.js +11 -11
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/data-access/dist/index17.js +95 -80
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/data-access/dist/index7.js +37 -11
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index.js +13 -15
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index10.js +56 -67
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index11.js +4 -43
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index12.js +6 -115
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index13.js +202 -63
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index14.js +2 -4
- 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/index19.js +84 -4
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index20.js +3 -84
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index21.js +5 -4
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index22.js +4 -5
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index23.js +32 -3
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index24.js +36 -30
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index25.js +167 -35
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index26.js +40 -164
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index27.js +1 -49
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index28.js +50 -1
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index29.js +11 -45
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index30.js +8 -13
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index31.js +14 -8
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index32.js +59 -7
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index33.js +8 -64
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index34.js +24 -8
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index35.js +150 -18
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index36.js +9 -152
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index37.js +25 -9
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index38.js +19 -21
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index39.js +32 -14
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index40.js +14 -39
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index41.js +8 -16
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index42.js +4 -8
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index43.js +98 -4
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index44.js +68 -83
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index45.js +3 -83
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index46.js +143 -3
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index47.js +44 -143
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index48.js +114 -45
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index49.js +189 -111
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index5.js +13 -0
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index50.js +72 -186
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index51.js +31 -76
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index52.js +89 -32
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index53.js +406 -83
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index54.js +12 -411
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index55.js +84 -12
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index56.js +67 -72
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index57.js +222 -73
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index58.js +37 -223
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index59.js +245 -37
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index6.js +5 -23
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index60.js +23 -252
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index61.js +626 -21
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index62.js +4 -586
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index63.js +45 -4
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index64.js +256 -41
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index65.js +3 -263
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index66.js +4 -3
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index67.js +44 -2
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index68.js +1 -46
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index69.js +8 -1
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index7.js +22 -57
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index70.js +11 -6
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index71.js +130 -11
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index72.js +3 -132
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index73.js +6 -3
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index74.js +129 -3
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index75.js +8 -124
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index76.js +7 -8
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index77.js +82 -8
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index78.js +19 -48
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index79.js +20 -21
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index8.js +14 -6
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index80.js +28 -19
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index81.js +82 -27
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index82.js +47 -83
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index83.js +260 -47
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index84.js +24 -251
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index85.js +382 -25
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index86.js +294 -144
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index87.js +4 -223
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index88.js +7 -4
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index89.js +112 -5
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index9.js +37 -5
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index90.js +1 -114
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index91.js +26 -0
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index.js +18 -21
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index100.js +126 -10
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index101.js +1 -105
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index102.js +33 -2
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index103.js +7 -28
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index104.js +126 -73
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index105.js +1 -1
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index106.js +11 -30
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index107.js +106 -8
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index108.js +2 -181
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index109.js +10 -2
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index110.js +50 -12
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index111.js +2 -108
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index38.js +6 -0
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index46.js +8 -4
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index73.js +8 -1
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index74.js +154 -23
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index83.js +1 -0
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index84.js +343 -250
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index90.js +5 -123
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index91.js +28 -26
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index92.js +2 -94
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index93.js +7 -2
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index94.js +32 -5
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index95.js +2 -30
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index96.js +12 -2
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index97.js +104 -5
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index98.js +2 -34
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index99.js +31 -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/index8.js +1 -1
- package/dist/packages/shared-ui-shadcn/dist/index.js +2458 -2284
- package/package.json +2 -1
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index92.js +0 -27
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index112.js +0 -2
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index113.js +0 -10
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index114.js +0 -52
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index115.js +0 -2
|
@@ -1,415 +1,16 @@
|
|
|
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 { hasAnyScope as t } from "../../../shared/data-access/dist/lib/hasAnyScope.js";
|
|
7
|
-
import { Scope as n } from "../../../shared/data-access/dist/lib/scopes.js";
|
|
8
|
-
import "../../../shared/data-access/dist/index.js";
|
|
9
|
-
import "../../../shared/ui/dist/index.js";
|
|
10
|
-
import { useWidgetConfig as r } from "../../../shared/feature/dist/lib/WidgetProvider/hooks.js";
|
|
11
|
-
import "../../../shared/feature/dist/index.js";
|
|
12
|
-
import { useCounterpartsQuery as i } from "../../../shared/counterpart-management/data-access/dist/index3.js";
|
|
13
|
-
import { useCreateCounterpartBankAccountMutation as ee, useUpdateCounterpartBankAccountMutation as a } from "../../../shared/counterpart-management/data-access/dist/index5.js";
|
|
14
|
-
import { usePayableSuggestionsQuery as o } from "../../data-access/dist/index18.js";
|
|
15
|
-
import "../../data-access/dist/index.js";
|
|
16
|
-
import { COUNTERPART_MESSAGE_LABELS_EN as te } from "../../../shared/counterpart-management/feature/dist/lib/labels.js";
|
|
17
|
-
import { counterpartFormBankAccountToCreatePayload as ne, counterpartFormBankAccountToUpdatePayload as re, getAchInstructions as ie, getCounterpartEmail as s, getCounterpartName as c, getPayableAchInstructions as ae, isAchCompatibleBankAccount as l, resolveCounterpartBankAccountWrite as oe, validateAchFormValues as se } from "../../../shared/counterpart-management/feature/dist/lib/helpers.js";
|
|
18
|
-
import { useCounterpartDetails as ce } from "../../../shared/counterpart-management/feature/dist/lib/useCounterpartDetails.js";
|
|
19
|
-
import { useCounterpartForm as le } from "../../../shared/counterpart-management/feature/dist/lib/useCounterpartForm.js";
|
|
20
|
-
import "../../../shared/counterpart-management/feature/dist/index.js";
|
|
21
|
-
import { VENDOR_SECTION_PROPS_LABELS_EN as ue } from "./index50.js";
|
|
22
|
-
import { buildVendorPrefill as de } from "./index52.js";
|
|
23
|
-
import { VendorInlineForm as fe } from "./index53.js";
|
|
24
|
-
import { useCallback as u, useEffect as d, useMemo as f, useRef as p, useState as m } from "react";
|
|
25
|
-
import { jsx as pe } from "react/jsx-runtime";
|
|
26
1
|
//#region ../../libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index54.js
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
routingNumber: e.routing_number ?? "",
|
|
36
|
-
accountNumber: e.account_number ?? ""
|
|
37
|
-
};
|
|
38
|
-
}
|
|
39
|
-
function g(e, t) {
|
|
40
|
-
return e.accountHolderName.trim() === t.accountHolderName.trim() && e.routingNumber.trim() === t.routingNumber.trim() && e.accountNumber.trim() === t.accountNumber.trim();
|
|
41
|
-
}
|
|
42
|
-
function _e(e, t) {
|
|
43
|
-
return e?.find((e) => e.id === t && l(e)) ?? ie(e);
|
|
44
|
-
}
|
|
45
|
-
function _({ payableId: ie, counterpartId: l, payableCounterpartId: _, payableCounterpartBankAccountId: ve, isVendorKnown: ye = !0, onCounterpartChange: be, requiredError: xe, extractedVendor: v, readOnly: y = !1, canEditVendor: b = !0, canEditPaymentInstructions: Se = !0, canAddPaymentInstructions: Ce = !0, confirmDiscard: x = (e) => e(), labels: we }) {
|
|
46
|
-
let S = {
|
|
47
|
-
...ue,
|
|
48
|
-
...we
|
|
49
|
-
}, { initResponse: Te } = r(), Ee = t(Te?.scopes, [n.CounterpartReadOrg]), [C, De] = m(""), [w, Oe] = m(""), ke = p(w), [T, Ae] = m(), [je, Me] = m("none"), [Ne, Pe] = m(), [Fe, E] = m(!1), [D, O] = m(!1), [k, A] = m(h), Ie = p(k);
|
|
50
|
-
Ie.current = k;
|
|
51
|
-
let j = p(h), [Le, M] = m(), [Re, ze] = m(), Be = Re?.bankAccountId, N = p(void 0), Ve = p(l), [He, Ue] = m(!1), [We, Ge] = m(!1), P = p(void 0), Ke = (D || T === "create") && !g(k, j.current), F = u(() => {
|
|
52
|
-
O(!1), A(h), j.current = h, M(void 0);
|
|
53
|
-
}, []), I = u((e) => {
|
|
54
|
-
Ue(!0), be(e);
|
|
55
|
-
}, [be]), L = o(ie, { enabled: !y && !!ie && !l && !_ }).data?.suggested_counterpart?.id, qe = v?.name;
|
|
56
|
-
d(() => {
|
|
57
|
-
!y && !He && !l && !_ && L && I(L);
|
|
58
|
-
}, [
|
|
59
|
-
l,
|
|
60
|
-
_,
|
|
61
|
-
y,
|
|
62
|
-
He,
|
|
63
|
-
L,
|
|
64
|
-
I
|
|
65
|
-
]), d(() => {
|
|
66
|
-
Ve.current !== l && (Ve.current = l, F(), ze((e) => e?.counterpartId === l ? e : void 0));
|
|
67
|
-
}, [l, F]), d(() => {
|
|
68
|
-
let e = setTimeout(() => {
|
|
69
|
-
Oe(C.trim());
|
|
70
|
-
}, he);
|
|
71
|
-
return () => clearTimeout(e);
|
|
72
|
-
}, [C]);
|
|
73
|
-
let R = i({
|
|
74
|
-
sort: "counterpart_name",
|
|
75
|
-
order: "asc",
|
|
76
|
-
limit: me,
|
|
77
|
-
counterpart_name__icontains: w || void 0,
|
|
78
|
-
is_vendor: !0,
|
|
79
|
-
enabled: !y && (T === "edit" || !T && !l) && ye && Ee
|
|
80
|
-
});
|
|
81
|
-
d(() => {
|
|
82
|
-
R.isPlaceholderData || (ke.current = w);
|
|
83
|
-
}, [w, R.isPlaceholderData]);
|
|
84
|
-
let Je = R.isPlaceholderData && ke.current !== w, z = ce({
|
|
85
|
-
selectedId: l,
|
|
86
|
-
enabled: Ee
|
|
87
|
-
}), Ye = ee(), Xe = a(), B = le({
|
|
88
|
-
view: je,
|
|
89
|
-
setView: Me,
|
|
90
|
-
selectedId: Ne,
|
|
91
|
-
setSelectedId: Pe,
|
|
92
|
-
messages: te,
|
|
93
|
-
counterpartType: "vendor",
|
|
94
|
-
counterpart: z.counterpart,
|
|
95
|
-
primaryAddress: z.primaryAddress,
|
|
96
|
-
includeBankAccount: !1
|
|
97
|
-
}), { openCreate: Ze, openEdit: Qe, close: $e, setValues: V, submit: et } = B, H = f(() => de(v), [v]), U = H?.bankAccount, W = f(() => {
|
|
98
|
-
let e = z.counterpart;
|
|
99
|
-
if (!e) return;
|
|
100
|
-
if (z.isBankAccountsLoading) return {
|
|
101
|
-
name: c(e),
|
|
102
|
-
email: s(e),
|
|
103
|
-
methodLabel: S.paymentMethodLoading,
|
|
104
|
-
hasPaymentInstructions: !1
|
|
105
|
-
};
|
|
106
|
-
if (z.isBankAccountsError) return {
|
|
107
|
-
name: c(e),
|
|
108
|
-
email: s(e),
|
|
109
|
-
methodLabel: S.paymentMethodUnavailable,
|
|
110
|
-
hasPaymentInstructions: !1
|
|
111
|
-
};
|
|
112
|
-
let t = ae(z.bankAccounts);
|
|
113
|
-
return {
|
|
114
|
-
name: c(e),
|
|
115
|
-
email: s(e),
|
|
116
|
-
methodLabel: t ? S.paymentInstructionsValue(t.account_number?.slice(-4) ?? "") : S.noMethod,
|
|
117
|
-
hasPaymentInstructions: !!t
|
|
118
|
-
};
|
|
119
|
-
}, [
|
|
120
|
-
z.bankAccounts,
|
|
121
|
-
z.counterpart,
|
|
122
|
-
z.isBankAccountsError,
|
|
123
|
-
z.isBankAccountsLoading,
|
|
124
|
-
S
|
|
125
|
-
]), G = f(() => {
|
|
126
|
-
let e = qe?.trim();
|
|
127
|
-
if (!e || l || T) return;
|
|
128
|
-
let t = U?.accountNumber;
|
|
129
|
-
return {
|
|
130
|
-
name: e,
|
|
131
|
-
email: v?.email ?? "",
|
|
132
|
-
description: S.pendingVendorDescription,
|
|
133
|
-
methodLabel: t ? S.paymentInstructionsValue(t.slice(-4)) : "",
|
|
134
|
-
hasPaymentInstructions: !!t
|
|
135
|
-
};
|
|
136
|
-
}, [
|
|
137
|
-
l,
|
|
138
|
-
U?.accountNumber,
|
|
139
|
-
v?.email,
|
|
140
|
-
qe,
|
|
141
|
-
T,
|
|
142
|
-
S.paymentInstructionsValue,
|
|
143
|
-
S.pendingVendorDescription
|
|
144
|
-
]), K = l === _ ? ve : void 0, q = f(() => _e(z.bankAccounts, K), [z.bankAccounts, K]), tt = f(() => ae(z.bankAccounts)?.id, [z.bankAccounts]), nt = !z.counterpart || z.isLoading || z.isFetching || z.isError || z.isBankAccountsLoading || z.isBankAccountsFetching || z.isBankAccountsError, rt = nt || z.isAddressesLoading || z.isAddressesFetching || z.isAddressesError, it = b && !nt && z.isAddressesError ? { onRetry: z.refetchAddresses } : void 0, J = u(() => {
|
|
145
|
-
$e(), Ae(void 0), E(!1), N.current = void 0;
|
|
146
|
-
}, [$e]), at = u((e) => {
|
|
147
|
-
if (E(!1), N.current = void 0, e === "edit") Pe(l), Qe();
|
|
148
|
-
else {
|
|
149
|
-
Ze();
|
|
150
|
-
let e = C.trim();
|
|
151
|
-
V((t) => ({
|
|
152
|
-
...t,
|
|
153
|
-
entityType: "organization",
|
|
154
|
-
legalName: e || H?.legalName || t.legalName,
|
|
155
|
-
email: H?.email || t.email,
|
|
156
|
-
phone: H?.phone || t.phone,
|
|
157
|
-
address: H?.address ?? t.address
|
|
158
|
-
})), A(U ?? h), M(void 0), j.current = h;
|
|
159
|
-
}
|
|
160
|
-
Ae(e);
|
|
161
|
-
}, [
|
|
162
|
-
l,
|
|
163
|
-
U,
|
|
164
|
-
Ze,
|
|
165
|
-
Qe,
|
|
166
|
-
C,
|
|
167
|
-
V,
|
|
168
|
-
H
|
|
169
|
-
]), Y = u(() => {
|
|
170
|
-
let e = q ? ge(q) : h;
|
|
171
|
-
j.current = e, A(e), M(void 0), O(!0);
|
|
172
|
-
}, [q]), ot = u((e) => {
|
|
173
|
-
A((t) => ({
|
|
174
|
-
...t,
|
|
175
|
-
...e
|
|
176
|
-
})), M(void 0);
|
|
177
|
-
}, []), st = u(() => {
|
|
178
|
-
Ke ? x(F) : F();
|
|
179
|
-
}, [
|
|
180
|
-
F,
|
|
181
|
-
x,
|
|
182
|
-
Ke
|
|
183
|
-
]), X = u(() => {
|
|
184
|
-
J(), F();
|
|
185
|
-
}, [F, J]), Z = Fe || Ke, Q = u((e) => {
|
|
186
|
-
let t = () => {
|
|
187
|
-
X(), e();
|
|
188
|
-
};
|
|
189
|
-
Z ? x(t) : t();
|
|
190
|
-
}, [
|
|
191
|
-
x,
|
|
192
|
-
X,
|
|
193
|
-
Z
|
|
194
|
-
]), ct = u(() => {
|
|
195
|
-
Z ? x(X) : X();
|
|
196
|
-
}, [
|
|
197
|
-
x,
|
|
198
|
-
X,
|
|
199
|
-
Z
|
|
200
|
-
]), lt = u(async (t) => {
|
|
201
|
-
let n = l, r = !1, i = Ie.current;
|
|
202
|
-
if (!g(i, j.current)) {
|
|
203
|
-
let e = se(i);
|
|
204
|
-
if (Object.keys(e).length > 0) return M(e), T !== "create" && O(!0), { ok: !1 };
|
|
205
|
-
}
|
|
206
|
-
if (T === "edit" && rt) return { ok: !1 };
|
|
207
|
-
if (T) {
|
|
208
|
-
if (T === "create" && N.current) n = N.current;
|
|
209
|
-
else {
|
|
210
|
-
let e = await et();
|
|
211
|
-
if (!e.ok) return { ok: !1 };
|
|
212
|
-
T === "create" ? (n = e.counterpartId, N.current = n) : n = e.counterpartId ?? n;
|
|
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;
|
|
213
10
|
}
|
|
214
|
-
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
let ee = z.isBankAccountsLoading || z.isBankAccountsFetching || z.isBankAccountsError;
|
|
218
|
-
if (g(i, j.current)) {
|
|
219
|
-
let e = Be ?? K;
|
|
220
|
-
return e ? (t && (O(!1), T && J()), r && I(n), {
|
|
221
|
-
ok: !0,
|
|
222
|
-
counterpartId: n,
|
|
223
|
-
counterpartBankAccountId: e
|
|
224
|
-
}) : r ? (t && J(), I(n), {
|
|
225
|
-
ok: !0,
|
|
226
|
-
counterpartId: n
|
|
227
|
-
}) : ee ? { ok: !1 } : (t && (O(!1), T && J()), {
|
|
228
|
-
ok: !0,
|
|
229
|
-
counterpartId: n,
|
|
230
|
-
counterpartBankAccountId: tt
|
|
231
|
-
});
|
|
232
|
-
}
|
|
233
|
-
if (ee) return { ok: !1 };
|
|
234
|
-
M(void 0);
|
|
235
|
-
let a = oe(z.bankAccounts, Be ?? q?.id), o;
|
|
236
|
-
try {
|
|
237
|
-
a.kind === "update" ? (await Xe.mutateAsync({
|
|
238
|
-
path: {
|
|
239
|
-
counterpart_id: n,
|
|
240
|
-
bank_account_id: a.bankAccountId
|
|
241
|
-
},
|
|
242
|
-
body: re(i, { includeAchDefaults: a.includeAchDefaults })
|
|
243
|
-
}), o = a.bankAccountId) : o = (await Ye.mutateAsync({
|
|
244
|
-
path: { counterpart_id: n },
|
|
245
|
-
body: ne(i, { isDefaultForCurrency: a.isDefaultForCurrency })
|
|
246
|
-
}))?.id;
|
|
247
|
-
} catch {
|
|
248
|
-
return e.error(S.bankAccountSaveFailed), {
|
|
249
|
-
ok: !1,
|
|
250
|
-
counterpartId: n
|
|
251
|
-
};
|
|
252
|
-
}
|
|
253
|
-
return j.current = i, ze(o ? {
|
|
254
|
-
counterpartId: n,
|
|
255
|
-
bankAccountId: o
|
|
256
|
-
} : void 0), t && (O(!1), T && J()), r && I(n), {
|
|
257
|
-
ok: !0,
|
|
258
|
-
counterpartId: n,
|
|
259
|
-
counterpartBankAccountId: o
|
|
260
|
-
};
|
|
261
|
-
}, [
|
|
262
|
-
J,
|
|
263
|
-
l,
|
|
264
|
-
Ye,
|
|
265
|
-
z.bankAccounts,
|
|
266
|
-
z.isBankAccountsError,
|
|
267
|
-
z.isBankAccountsFetching,
|
|
268
|
-
z.isBankAccountsLoading,
|
|
269
|
-
T,
|
|
270
|
-
rt,
|
|
271
|
-
K,
|
|
272
|
-
tt,
|
|
273
|
-
I,
|
|
274
|
-
q,
|
|
275
|
-
et,
|
|
276
|
-
Xe,
|
|
277
|
-
Be
|
|
278
|
-
]), ut = u((e) => {
|
|
279
|
-
if (P.current) return P.current;
|
|
280
|
-
let t = e?.closeOnSuccess ?? !0, n = (async () => {
|
|
281
|
-
Ge(!0);
|
|
282
|
-
try {
|
|
283
|
-
return await lt(t);
|
|
284
|
-
} finally {
|
|
285
|
-
P.current = void 0, Ge(!1);
|
|
286
|
-
}
|
|
287
|
-
})();
|
|
288
|
-
return P.current = n, n;
|
|
289
|
-
}, [lt]), dt = u(() => {
|
|
290
|
-
O(!1), T && J();
|
|
291
|
-
}, [T, J]), ft = f(() => (R.data?.data ?? []).map((e) => ({
|
|
292
|
-
name: c(e),
|
|
293
|
-
email: s(e),
|
|
294
|
-
onSelect: () => {
|
|
295
|
-
Q(() => I(e.id));
|
|
296
|
-
}
|
|
297
|
-
})), [
|
|
298
|
-
R.data,
|
|
299
|
-
Q,
|
|
300
|
-
I
|
|
301
|
-
]), pt = u((e) => {
|
|
302
|
-
E(!0), V((t) => e.entityType === "individual" && t.entityType !== "individual" ? {
|
|
303
|
-
...t,
|
|
304
|
-
...e,
|
|
305
|
-
firstName: t.firstName || t.legalName,
|
|
306
|
-
legalName: t.legalName
|
|
307
|
-
} : e.entityType === "organization" && t.entityType !== "organization" ? {
|
|
308
|
-
...t,
|
|
309
|
-
...e,
|
|
310
|
-
legalName: t.legalName || [t.firstName, t.lastName].filter(Boolean).join(" ")
|
|
311
|
-
} : {
|
|
312
|
-
...t,
|
|
313
|
-
...e
|
|
314
|
-
});
|
|
315
|
-
}, [V]), mt = u((e) => {
|
|
316
|
-
E(!0), V((t) => ({
|
|
317
|
-
...t,
|
|
318
|
-
address: {
|
|
319
|
-
...t.address,
|
|
320
|
-
...e
|
|
321
|
-
}
|
|
322
|
-
}));
|
|
323
|
-
}, [V]), ht = {
|
|
324
|
-
query: C,
|
|
325
|
-
onQueryChange: De,
|
|
326
|
-
isLoading: !ye || !Te || !!l && z.isLoading || R.isLoading || R.isFetching && Je,
|
|
327
|
-
onAddVendor: () => {
|
|
328
|
-
Q(() => at("create"));
|
|
329
|
-
},
|
|
330
|
-
results: ft
|
|
331
|
-
}, gt = Ce && (T === "create" || !nt) ? {
|
|
332
|
-
isOpen: D,
|
|
333
|
-
values: k,
|
|
334
|
-
errors: Le,
|
|
335
|
-
onOpen: Y,
|
|
336
|
-
onCancel: st,
|
|
337
|
-
onChange: ot
|
|
338
|
-
} : void 0, _t = T !== "create" && gt ? {
|
|
339
|
-
...gt,
|
|
340
|
-
onOpen: T === "edit" ? () => Q(Y) : gt.onOpen,
|
|
341
|
-
canEditExisting: Se
|
|
342
|
-
} : void 0, vt = B.isSubmitting || Ye.isPending || Xe.isPending, $ = {
|
|
343
|
-
prepareVendorForSave: ut,
|
|
344
|
-
isVendorSavePending: We || vt,
|
|
345
|
-
hasUnsavedVendorChanges: Z,
|
|
346
|
-
isPendingVendor: !!G,
|
|
347
|
-
isEditingPayTo: !!T || D,
|
|
348
|
-
activePayToOperation: T ? "vendor" : D ? W?.hasPaymentInstructions ? "existingInstructions" : "missingInstructions" : void 0,
|
|
349
|
-
discardPayToEdits: X,
|
|
350
|
-
finalizePayToSave: dt,
|
|
351
|
-
openPaymentInstructions: Y,
|
|
352
|
-
paymentInstructions: _t,
|
|
353
|
-
detailsWarning: it
|
|
354
|
-
}, yt = T === "create" && Ce ? {
|
|
355
|
-
values: k,
|
|
356
|
-
errors: Le,
|
|
357
|
-
onChange: ot,
|
|
358
|
-
isExtracted: !!(U && g(k, U))
|
|
359
|
-
} : void 0;
|
|
360
|
-
if (T) return {
|
|
361
|
-
mode: "creating",
|
|
362
|
-
summary: W,
|
|
363
|
-
newVendorForm: /* @__PURE__ */ pe(fe, {
|
|
364
|
-
mode: T,
|
|
365
|
-
values: B.values,
|
|
366
|
-
errors: B.errors,
|
|
367
|
-
onChange: pt,
|
|
368
|
-
onAddressChange: mt,
|
|
369
|
-
sectionsToExpand: B.sectionsToExpand,
|
|
370
|
-
onAddressExpand: B.expandAddress,
|
|
371
|
-
onCancel: ct,
|
|
372
|
-
onSave: ut,
|
|
373
|
-
isSaving: vt,
|
|
374
|
-
search: T === "edit" && !y ? ht : void 0,
|
|
375
|
-
paymentInstructions: yt
|
|
376
|
-
}),
|
|
377
|
-
...$
|
|
378
|
-
};
|
|
379
|
-
if (W) return {
|
|
380
|
-
mode: "resolved",
|
|
381
|
-
summary: W,
|
|
382
|
-
onEdit: b && !rt ? () => Q(() => at("edit")) : void 0,
|
|
383
|
-
...$
|
|
384
|
-
};
|
|
385
|
-
if (G) {
|
|
386
|
-
let e = () => Q(() => {
|
|
387
|
-
Ue(!0), at("create");
|
|
388
|
-
});
|
|
389
|
-
return {
|
|
390
|
-
mode: "resolved",
|
|
391
|
-
summary: G,
|
|
392
|
-
onEdit: b ? e : void 0,
|
|
393
|
-
error: xe,
|
|
394
|
-
...$,
|
|
395
|
-
showPaymentInstructions: !0,
|
|
396
|
-
paymentInstructions: b && Ce ? {
|
|
397
|
-
isOpen: !1,
|
|
398
|
-
values: k,
|
|
399
|
-
errors: Le,
|
|
400
|
-
onOpen: e,
|
|
401
|
-
onChange: ot,
|
|
402
|
-
onCancel: st,
|
|
403
|
-
canEditExisting: !0
|
|
404
|
-
} : void 0
|
|
405
|
-
};
|
|
406
|
-
}
|
|
407
|
-
return {
|
|
408
|
-
mode: "selecting",
|
|
409
|
-
error: R.isError ? S.searchFailed : z.isError ? S.vendorDetailsFailed : xe,
|
|
410
|
-
search: ht,
|
|
411
|
-
...$
|
|
412
|
-
};
|
|
11
|
+
t(e.slice(e.indexOf(",") + 1));
|
|
12
|
+
}, r.readAsDataURL(e);
|
|
13
|
+
});
|
|
413
14
|
}
|
|
414
15
|
//#endregion
|
|
415
|
-
export {
|
|
16
|
+
export { e as encodeFileToBase64 };
|
|
@@ -1,16 +1,88 @@
|
|
|
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/index55.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
|
+
let t = n(e);
|
|
26
|
+
return t === null ? e : c(t);
|
|
27
|
+
}
|
|
28
|
+
function c(e) {
|
|
29
|
+
return (e / 100).toFixed(2);
|
|
30
|
+
}
|
|
31
|
+
function l({ values: e, initialLineItems: r, counterpartId: i, clearCounterpart: a, counterpartBankAccountId: o, editedTotals: s, currentTotals: c, lineItems: l, document: f, includeBlankPoNumber: p = !0 }) {
|
|
32
|
+
let m = { currency: t };
|
|
33
|
+
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);
|
|
34
|
+
let h = e.poNumber.trim();
|
|
35
|
+
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) {
|
|
36
|
+
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;
|
|
37
|
+
e !== void 0 && (m.subtotal = e), m.discount = r, m.tax_amount = t, m.total_amount = i;
|
|
38
|
+
} else if (r && !("total_amount" in m)) {
|
|
39
|
+
let e = u(r, {
|
|
40
|
+
tax: s?.tax,
|
|
41
|
+
discount: s?.discount
|
|
42
|
+
});
|
|
43
|
+
e !== void 0 && (m.total_amount = e);
|
|
44
|
+
}
|
|
45
|
+
return m;
|
|
46
|
+
}
|
|
47
|
+
function u(e, { tax: t, discount: r }) {
|
|
48
|
+
let i = d(e);
|
|
49
|
+
if (i !== void 0) return i + (t ? n(t) ?? 0 : 0) - (r ? n(r) ?? 0 : 0);
|
|
50
|
+
}
|
|
51
|
+
function d(e) {
|
|
52
|
+
let t = !1, r = e.reduce((e, r) => {
|
|
53
|
+
if (!i(r)) return e;
|
|
54
|
+
let a = n(r.amount);
|
|
55
|
+
return a === null ? e : (t = !0, e + a);
|
|
56
|
+
}, 0);
|
|
57
|
+
if (t) return r;
|
|
58
|
+
}
|
|
59
|
+
function f({ lineItems: e, editedTotals: t }) {
|
|
60
|
+
let r = d(e), i = n(t.tax) ?? 0, a = n(t.discount) ?? 0, o = {
|
|
61
|
+
discount: a,
|
|
62
|
+
tax_amount: i
|
|
63
|
+
};
|
|
64
|
+
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;
|
|
65
|
+
}
|
|
66
|
+
function p(e) {
|
|
67
|
+
return e.filter(i).map((e) => {
|
|
68
|
+
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;
|
|
69
|
+
return {
|
|
70
|
+
name: e.description,
|
|
71
|
+
quantity: i,
|
|
72
|
+
unit_price: a,
|
|
73
|
+
tax: 0,
|
|
74
|
+
subtotal: s,
|
|
75
|
+
tax_amount: 0,
|
|
76
|
+
total: s,
|
|
77
|
+
...e.glCode ? { ledger_account_id: e.glCode } : {}
|
|
78
|
+
};
|
|
13
79
|
});
|
|
14
80
|
}
|
|
81
|
+
function m(e, t) {
|
|
82
|
+
return c(Math.round(o(e) * a(t)));
|
|
83
|
+
}
|
|
84
|
+
function h(e, t, n) {
|
|
85
|
+
return c(e.reduce((e, t) => e + a(t.amount), 0) + a(t) - a(n));
|
|
86
|
+
}
|
|
15
87
|
//#endregion
|
|
16
|
-
export {
|
|
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 };
|
|
@@ -1,88 +1,83 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import "
|
|
1
|
+
import { BILL_CREATE_MESSAGE_LABELS_EN as e } from "./index49.js";
|
|
2
|
+
import { isPersistableLineItem as t, parseMoneyToMinorUnits as n, parseQuantity as r } from "./index55.js";
|
|
3
3
|
//#region ../../libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index56.js
|
|
4
|
-
var
|
|
5
|
-
function
|
|
6
|
-
|
|
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());
|
|
7
8
|
}
|
|
8
|
-
function
|
|
9
|
-
let
|
|
10
|
-
|
|
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);
|
|
9
|
+
function d() {
|
|
10
|
+
let e = new Date(u());
|
|
11
|
+
return e.setUTCFullYear(e.getUTCFullYear() - o), e;
|
|
16
12
|
}
|
|
17
|
-
function
|
|
18
|
-
|
|
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;
|
|
19
18
|
}
|
|
20
|
-
function
|
|
21
|
-
let t =
|
|
22
|
-
|
|
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;
|
|
23
24
|
}
|
|
24
|
-
function
|
|
25
|
-
let
|
|
26
|
-
return t
|
|
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;
|
|
27
28
|
}
|
|
28
|
-
function
|
|
29
|
-
|
|
29
|
+
function h(e) {
|
|
30
|
+
let t = e.trim();
|
|
31
|
+
return !t || n(t) !== null ? !0 : i.test(t) ? Number(t.replaceAll(",", "")) === 0 : !1;
|
|
30
32
|
}
|
|
31
|
-
function
|
|
32
|
-
let
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
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;
|
|
37
|
-
e !== void 0 && (m.subtotal = e), m.discount = r, m.tax_amount = t, m.total_amount = i;
|
|
38
|
-
} else if (r && !("total_amount" in m)) {
|
|
39
|
-
let e = u(r, {
|
|
40
|
-
tax: s?.tax,
|
|
41
|
-
discount: s?.discount
|
|
42
|
-
});
|
|
43
|
-
e !== void 0 && (m.total_amount = e);
|
|
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);
|
|
44
38
|
}
|
|
45
|
-
return
|
|
39
|
+
return Object.keys(a).length ? a : void 0;
|
|
46
40
|
}
|
|
47
|
-
function
|
|
48
|
-
let
|
|
49
|
-
|
|
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
|
|
54
|
+
};
|
|
50
55
|
}
|
|
51
|
-
function
|
|
52
|
-
let t =
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
}, 0);
|
|
57
|
-
if (t) return r;
|
|
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;
|
|
58
61
|
}
|
|
59
|
-
function
|
|
60
|
-
|
|
61
|
-
discount: a,
|
|
62
|
-
tax_amount: i
|
|
63
|
-
};
|
|
64
|
-
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;
|
|
62
|
+
function y(e, t) {
|
|
63
|
+
if (n(e) === null) return v(e) ? t.totalNotGreaterThanZero : t.unreadableTotal;
|
|
65
64
|
}
|
|
66
|
-
function
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
return {
|
|
70
|
-
name: e.description,
|
|
71
|
-
quantity: i,
|
|
72
|
-
unit_price: a,
|
|
73
|
-
tax: 0,
|
|
74
|
-
subtotal: s,
|
|
75
|
-
tax_amount: 0,
|
|
76
|
-
total: s,
|
|
77
|
-
...e.glCode ? { ledger_account_id: e.glCode } : {}
|
|
78
|
-
};
|
|
79
|
-
});
|
|
65
|
+
function b(t, n = e) {
|
|
66
|
+
let r = y(t, n);
|
|
67
|
+
return r ? { total: r } : void 0;
|
|
80
68
|
}
|
|
81
|
-
function
|
|
82
|
-
|
|
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 };
|
|
83
73
|
}
|
|
84
|
-
function
|
|
85
|
-
|
|
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;
|
|
86
81
|
}
|
|
87
82
|
//#endregion
|
|
88
|
-
export { h as
|
|
83
|
+
export { h as isReadableMoneyOrZero, _ as validateBillCompleteness, b as validateBillTotalIsPayable, S as validateBillTotals, m as validateBillValues, g as validateLineItems, x as validateStoredAmountDue };
|