@tesouro/embedded-components-react 0.5.16 → 0.5.18

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.
@@ -15,29 +15,23 @@ import { useMutation as s } from "@tanstack/react-query";
15
15
  function c() {
16
16
  let { client: c, organizationId: l } = t();
17
17
  return s({
18
- mutationFn: async ({ path: t, body: a, makeDefault: s }) => {
19
- let { data: u } = await r({
18
+ mutationFn: async ({ path: e, body: t, makeDefault: a }) => {
19
+ let { data: o } = await r({
20
20
  client: c,
21
21
  headers: n(l),
22
- path: t,
23
- body: a,
22
+ path: e,
23
+ body: t,
24
24
  throwOnError: !0
25
25
  });
26
- if (s) try {
26
+ if (a) try {
27
27
  await i({
28
28
  client: c,
29
29
  headers: n(l),
30
- path: t,
30
+ path: e,
31
31
  throwOnError: !0
32
32
  });
33
- } catch (n) {
34
- throw await e(o({
35
- client: c,
36
- organizationId: l,
37
- counterpartId: t.counterpart_id
38
- })), n;
39
- }
40
- return u;
33
+ } catch {}
34
+ return o;
41
35
  },
42
36
  onSuccess: async (t, n) => {
43
37
  await Promise.all([e(o({
@@ -21,6 +21,7 @@ function p({ ref: p, payable: m, onMissingAchInstructions: h, poweredByBankName:
21
21
  let v = t(m), { initResponse: y } = e(), b = i(y?.scopes), { achInstructions: x, isLoading: S, isError: C } = c({
22
22
  counterpartId: m.counterpart_id,
23
23
  currency: m.currency,
24
+ currentBankAccountId: m.counterpart_bank_account_id,
24
25
  enabled: b
25
26
  }), w = s({
26
27
  payableId: m.id,
@@ -4,49 +4,49 @@ import { resolveVendor as n, resolveVendorName as r } from "./index8.js";
4
4
  import { formatBillMoney as i } from "./index2.js";
5
5
  import { resolveLineItemAmountMinorUnits as a } from "./index40.js";
6
6
  //#region ../../libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index41.js
7
- function o({ payable: o, lineItems: c, ledgerAccounts: l, labels: u, hasScheduledPayment: d, now: f, rejection: p }) {
8
- let m = o.currency, h = (e) => i(e, m), g = t({
7
+ function o({ payable: o, lineItems: c, ledgerAccounts: l, labels: u, hasScheduledPayment: d, now: f, rejection: p, achInstructions: m, achInstructionsReadable: h = !1 }) {
8
+ let g = o.currency, _ = (e) => i(e, g), v = t({
9
9
  apiStatus: o.status,
10
10
  dueDate: o.due_date,
11
11
  scheduledPaymentDate: o.scheduled_payment_date,
12
12
  hasScheduledPayment: d,
13
13
  now: f
14
- }), _ = n(o), v = r(o), y = e(o.issued_at) || u.notProvided, b = e(o.due_date) || u.notProvided, x = [{
14
+ }), y = n(o), b = r(o), x = e(o.issued_at) || u.notProvided, S = e(o.due_date) || u.notProvided, C = [{
15
15
  label: u.vendorRow,
16
- value: v || u.notProvided,
17
- secondaryValue: _?.email ?? void 0
18
- }], S = _?.bank_account?.account_number;
19
- S && x.push({
16
+ value: b || u.notProvided,
17
+ secondaryValue: y?.email ?? void 0
18
+ }], w = h ? m?.account_number : void 0;
19
+ w && C.push({
20
20
  label: u.bankAccountRow,
21
- value: u.bankAccountValue(S.slice(-4))
21
+ value: u.bankAccountValue(w.slice(-4))
22
22
  });
23
- let C = [
23
+ let T = [
24
24
  {
25
25
  label: u.invoiceNumberRow,
26
26
  value: o.document_id || u.notProvided
27
27
  },
28
28
  {
29
29
  label: u.issueDateRow,
30
- value: y
30
+ value: x
31
31
  },
32
32
  {
33
33
  label: u.dueDateRow,
34
- value: b
34
+ value: S
35
35
  },
36
36
  {
37
37
  label: u.poNumberRow,
38
38
  value: u.notProvided
39
39
  }
40
- ], w = new Map(l.map((e) => [e.id, [e.nominal_code, e.name].filter(Boolean).join(" — ")])), T = c.map((e) => {
41
- let t = h(e.unit_price);
40
+ ], E = new Map(l.map((e) => [e.id, [e.nominal_code, e.name].filter(Boolean).join(" — ")])), D = c.map((e) => {
41
+ let t = _(e.unit_price);
42
42
  return {
43
43
  id: e.id,
44
44
  description: e.name ?? e.description ?? "",
45
- glCodeLabel: (e.ledger_account_id ? w.get(e.ledger_account_id) : void 0) || u.glCodeMissing,
45
+ glCodeLabel: (e.ledger_account_id ? E.get(e.ledger_account_id) : void 0) || u.glCodeMissing,
46
46
  quantityLabel: e.quantity != null && t ? u.quantityValue(String(e.quantity), t) : "",
47
- amountLabel: h(a(e)) ?? ""
47
+ amountLabel: _(a(e)) ?? ""
48
48
  };
49
- }), E = [
49
+ }), O = [
50
50
  {
51
51
  label: u.subtotalRow,
52
52
  value: o.subtotal
@@ -61,29 +61,29 @@ function o({ payable: o, lineItems: c, ledgerAccounts: l, labels: u, hasSchedule
61
61
  }
62
62
  ].map(({ label: e, value: t }) => ({
63
63
  label: e,
64
- value: h(t)
65
- })).filter((e) => !!e.value), D = h(o.total_amount);
66
- D && E.push({
64
+ value: _(t)
65
+ })).filter((e) => !!e.value), k = _(o.total_amount);
66
+ k && O.push({
67
67
  label: u.totalRow,
68
- value: D,
68
+ value: k,
69
69
  emphasis: !0
70
70
  });
71
- let O = s(o);
71
+ let A = s(o);
72
72
  return {
73
- title: v,
73
+ title: b,
74
74
  subtitle: u.subtitle,
75
- status: g.status,
76
- statusTone: g.tone,
77
- amountDueLabel: h(o.amount_due) ?? h(o.total_amount) ?? "",
78
- amountPaidLabel: O ? h(o.amount_paid) : void 0,
79
- paidOnLabel: O ? u.paidOnLabel(O) : void 0,
80
- invoiceDateLabel: y,
81
- dueDateLabel: b,
82
- dueDateTone: g.isOverdue ? "danger" : "default",
83
- payToItems: x,
84
- invoiceItems: C,
85
- lineItems: T,
86
- totals: E,
75
+ status: v.status,
76
+ statusTone: v.tone,
77
+ amountDueLabel: _(o.amount_due) ?? _(o.total_amount) ?? "",
78
+ amountPaidLabel: A ? _(o.amount_paid) : void 0,
79
+ paidOnLabel: A ? u.paidOnLabel(A) : void 0,
80
+ invoiceDateLabel: x,
81
+ dueDateLabel: S,
82
+ dueDateTone: v.isOverdue ? "danger" : "default",
83
+ payToItems: C,
84
+ invoiceItems: T,
85
+ lineItems: D,
86
+ totals: O,
87
87
  rejection: p
88
88
  };
89
89
  }
@@ -13,7 +13,7 @@ function c({ payable: c, lineItems: l, glCodeOptions: u, glCodeRosterAvailable:
13
13
  dueDate: c.due_date,
14
14
  scheduledPaymentDate: c.scheduled_payment_date,
15
15
  hasScheduledPayment: g
16
- }), S = n(c), C = y ? v : S?.bank_account, w = C?.account_number, T = !!(C?.account_holder_name && C.routing_number && C.account_number), E = e(c.issued_at) || h.notProvided, D = e(c.due_date) || h.notProvided, O = new Map(u.map((e) => [e.value, e.label])), k = [
16
+ }), S = n(c), C = y ? v : void 0, w = C?.account_number, T = !!(C?.account_holder_name && C.routing_number && C.account_number), E = e(c.issued_at) || h.notProvided, D = e(c.due_date) || h.notProvided, O = new Map(u.map((e) => [e.value, e.label])), k = [
17
17
  {
18
18
  label: h.subtotalRow,
19
19
  minorUnits: c.subtotal
@@ -4,121 +4,126 @@
4
4
  "use client";
5
5
  import { toast as e } from "../../../../../packages/shared-ui-shadcn/dist/index.js";
6
6
  import "../../../shared/ui/dist/index.js";
7
- import { useUpdatePayableMutation as t } from "../../data-access/dist/index13.js";
8
- import { useCounterpartBankAccountsQuery as n, useCreateCounterpartBankAccountMutation as r } from "../../../shared/counterpart-management/data-access/dist/index5.js";
9
- import { useUpdatePayableCounterpartBankAccountMutation as i } from "../../data-access/dist/index14.js";
7
+ import { extractApiErrorMessage as t } from "../../../shared/util/dist/lib/apiErrors.js";
8
+ import { useUpdatePayableMutation as n } from "../../data-access/dist/index13.js";
9
+ import { useCounterpartBankAccountsQuery as r, useCreateCounterpartBankAccountMutation as i } from "../../../shared/counterpart-management/data-access/dist/index5.js";
10
+ import { useUpdatePayableCounterpartBankAccountMutation as a } from "../../data-access/dist/index14.js";
10
11
  import "../../data-access/dist/index.js";
11
- import { counterpartFormBankAccountToCreatePayload as a, counterpartFormBankAccountToUpdatePayload as o, getAchInstructions as s, isAchCompatibleBankAccount as c, resolveCounterpartBankAccountWrite as l, validateAchFormValues as u } from "../../../shared/counterpart-management/feature/dist/lib/helpers.js";
12
+ import { counterpartFormBankAccountToCreatePayload as o, counterpartFormBankAccountToUpdatePayload as s, getAchInstructions as c, isAchCompatibleBankAccount as l, resolveCounterpartBankAccountWrite as u, validateAchFormValues as d } from "../../../shared/counterpart-management/feature/dist/lib/helpers.js";
12
13
  import "../../../shared/counterpart-management/feature/dist/index.js";
13
- import { useCallback as d, useEffect as f, useRef as p, useState as m } from "react";
14
+ import { useCallback as f, useEffect as p, useRef as m, useState as h } from "react";
14
15
  //#region ../../libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index52.js
15
- var h = {
16
+ function g(e, n) {
17
+ let r = t(n);
18
+ return r ? `${e} ${r}` : e;
19
+ }
20
+ var _ = {
16
21
  accountHolderName: "",
17
22
  routingNumber: "",
18
23
  accountNumber: ""
19
24
  };
20
- function g(e, t) {
21
- return e?.find((e) => e.id === t && c(e)) ?? s(e);
25
+ function v(e, t) {
26
+ return e?.find((e) => e.id === t && l(e)) ?? c(e);
22
27
  }
23
- function _({ payableId: c, counterpartId: _, currentBankAccountId: v, canReadCounterpartBankAccounts: y = !0, saveErrorMessage: b, linkErrorMessage: x }) {
24
- let [S, C] = m(!1), [w, T] = m(h), [E, D] = m(), O = n(_, { enabled: y }), k = O.data?.data, A = r(), j = i(), M = t(), N = p(void 0), P = p(!1);
25
- f(() => {
26
- N.current = void 0;
27
- }, [_, c]);
28
- let F = d(() => {
29
- if (S) return;
30
- let e = O.isFetching ? void 0 : g(k, v);
31
- T(e ? {
28
+ function y({ payableId: t, counterpartId: l, currentBankAccountId: y, canReadCounterpartBankAccounts: b = !0, saveErrorMessage: x, linkErrorMessage: S }) {
29
+ let [C, w] = h(!1), [T, E] = h(_), [D, O] = h(), k = r(l, { enabled: b }), A = k.data?.data, j = i(), M = a(), N = n(), P = m(void 0), F = m(!1);
30
+ p(() => {
31
+ P.current = void 0;
32
+ }, [l, t]);
33
+ let I = f(() => {
34
+ if (C) return;
35
+ let e = k.isFetching ? void 0 : v(A, y);
36
+ E(e ? {
32
37
  accountHolderName: e.account_holder_name ?? "",
33
38
  routingNumber: e.routing_number ?? "",
34
39
  accountNumber: e.account_number ?? ""
35
- } : h), N.current = e?.id ?? N.current, P.current = !O.isFetching, D(void 0), C(!0);
40
+ } : _), P.current = e?.id ?? P.current, F.current = !k.isFetching, O(void 0), w(!0);
36
41
  }, [
37
- k,
38
- O.isFetching,
39
- v,
40
- S
42
+ A,
43
+ k.isFetching,
44
+ y,
45
+ C
41
46
  ]);
42
- f(() => {
43
- if (!S || P.current || O.isFetching) return;
44
- P.current = !0;
45
- let e = g(k, v);
46
- e && (T((t) => t.accountHolderName === "" && t.routingNumber === "" && t.accountNumber === "" ? {
47
+ p(() => {
48
+ if (!C || F.current || k.isFetching) return;
49
+ F.current = !0;
50
+ let e = v(A, y);
51
+ e && (E((t) => t.accountHolderName === "" && t.routingNumber === "" && t.accountNumber === "" ? {
47
52
  accountHolderName: e.account_holder_name ?? "",
48
53
  routingNumber: e.routing_number ?? "",
49
54
  accountNumber: e.account_number ?? ""
50
- } : t), N.current = e.id);
55
+ } : t), P.current = e.id);
51
56
  }, [
52
- S,
53
- O.isFetching,
54
- k,
55
- v,
56
- y
57
+ C,
58
+ k.isFetching,
59
+ A,
60
+ y,
61
+ b
57
62
  ]);
58
- let I = d(() => {
59
- C(!1);
60
- }, []), L = d((e) => {
61
- T((t) => ({
63
+ let L = f(() => {
64
+ w(!1);
65
+ }, []), R = f((e) => {
66
+ E((t) => ({
62
67
  ...t,
63
68
  ...e
64
69
  }));
65
- }, []), R = d(async () => {
66
- if (!c || !_) return !1;
67
- let t = u(w);
68
- if (Object.keys(t).length > 0) return D(t), !1;
69
- if (D(void 0), !y || O.isFetching || O.isError) return e.error(b), !1;
70
- let n = N.current;
70
+ }, []), z = f(async () => {
71
+ if (!t || !l) return !1;
72
+ let n = d(T);
73
+ if (Object.keys(n).length > 0) return O(n), !1;
74
+ if (O(void 0), !b || k.isFetching || k.isError) return e.error(x), !1;
75
+ let r = P.current;
71
76
  try {
72
- let e = l(k, n ?? s(k)?.id);
73
- e.kind === "update" ? (await j.mutateAsync({
77
+ let e = u(A, r ?? c(A)?.id);
78
+ e.kind === "update" ? (await M.mutateAsync({
74
79
  path: {
75
- counterpart_id: _,
80
+ counterpart_id: l,
76
81
  bank_account_id: e.bankAccountId
77
82
  },
78
- body: o(w, { includeAchDefaults: e.includeAchDefaults }),
79
- payableId: c,
80
- makeDefault: e.includeAchDefaults || !k?.find((t) => t.id === e.bankAccountId)?.is_default_for_currency
81
- }), n = e.bankAccountId) : n = (await A.mutateAsync({
82
- path: { counterpart_id: _ },
83
- body: a(w, { isDefaultForCurrency: e.isDefaultForCurrency })
84
- }))?.id, N.current = n;
85
- } catch {
86
- return e.error(b), !1;
83
+ body: s(T, { includeAchDefaults: e.includeAchDefaults }),
84
+ payableId: t,
85
+ makeDefault: e.includeAchDefaults || !A?.find((t) => t.id === e.bankAccountId)?.is_default_for_currency
86
+ }), r = e.bankAccountId) : r = (await j.mutateAsync({
87
+ path: { counterpart_id: l },
88
+ body: o(T, { isDefaultForCurrency: e.isDefaultForCurrency })
89
+ }))?.id, P.current = r;
90
+ } catch (t) {
91
+ return e.error(g(x, t)), !1;
87
92
  }
88
- if (n !== v) try {
89
- await M.mutateAsync({
90
- path: { payable_id: c },
91
- body: { counterpart_bank_account_id: n }
93
+ if (r !== y) try {
94
+ await N.mutateAsync({
95
+ path: { payable_id: t },
96
+ body: { counterpart_bank_account_id: r }
92
97
  });
93
- } catch {
94
- return e.error(x), !1;
98
+ } catch (t) {
99
+ return e.error(g(S, t)), !1;
95
100
  }
96
- return C(!1), !0;
101
+ return w(!1), !0;
97
102
  }, [
98
- k,
99
- O.isError,
100
- O.isFetching,
101
- y,
102
- _,
103
103
  A,
104
- v,
105
- x,
106
- c,
104
+ k.isError,
105
+ k.isFetching,
107
106
  b,
107
+ l,
108
108
  j,
109
+ y,
110
+ S,
111
+ t,
112
+ x,
109
113
  M,
110
- w
114
+ N,
115
+ T
111
116
  ]);
112
117
  return {
113
- isOpen: S,
114
- values: w,
115
- errors: E,
116
- isSaving: A.isPending || j.isPending || M.isPending,
117
- open: F,
118
- close: I,
119
- onChange: L,
120
- save: R
118
+ isOpen: C,
119
+ values: T,
120
+ errors: D,
121
+ isSaving: j.isPending || M.isPending || N.isPending,
122
+ open: I,
123
+ close: L,
124
+ onChange: R,
125
+ save: z
121
126
  };
122
127
  }
123
128
  //#endregion
124
- export { _ as usePaymentInstructionsForm };
129
+ export { y as usePaymentInstructionsForm };
@@ -10,219 +10,226 @@ import "../../../shared/data-access/dist/index.js";
10
10
  import { useWidgetConfig as ne } from "../../../shared/feature/dist/lib/WidgetProvider/hooks.js";
11
11
  import "../../../shared/feature/dist/index.js";
12
12
  import { usePayableApprovalRequestsQuery as re } from "../../data-access/dist/index8.js";
13
- import { usePayableHistoryQuery as n } from "../../data-access/dist/index9.js";
14
- import { useAllPayableLineItemsQuery as r } from "../../data-access/dist/index10.js";
15
- import { usePayableQuery as i } from "../../data-access/dist/index17.js";
13
+ import { usePayableHistoryQuery as ie } from "../../data-access/dist/index9.js";
14
+ import { useAllPayableLineItemsQuery as ae } from "../../data-access/dist/index10.js";
15
+ import { usePayableQuery as n } from "../../data-access/dist/index17.js";
16
16
  import "../../data-access/dist/index.js";
17
- import { BillDecisionDialog as a } from "../../ui/dist/index56.js";
18
- import { BillDetailsSheet as o } from "../../ui/dist/index65.js";
19
- import { BillDuplicateNotice as s } from "../../ui/dist/index69.js";
20
- import { MarkAsPaidDialog as c } from "../../ui/dist/index99.js";
17
+ import { BillDecisionDialog as r } from "../../ui/dist/index56.js";
18
+ import { BillDetailsSheet as i } from "../../ui/dist/index65.js";
19
+ import { BillDuplicateNotice as a } from "../../ui/dist/index69.js";
20
+ import { MarkAsPaidDialog as o } from "../../ui/dist/index99.js";
21
21
  import "../../ui/dist/index.js";
22
- import { usePayableDuplicateReview as l } from "./index13.js";
22
+ import { usePayableDuplicateReview as s } from "./index13.js";
23
23
  import "./index14.js";
24
- import { canOverrideApprovalPolicy as u, canReadCounterpartBankAccounts as d } from "./index20.js";
25
- import { resolveAmountDueMinorUnits as f } from "./index21.js";
26
- import { usePayableAchInstructions as p } from "../../../shared/counterpart-management/feature/dist/lib/usePayableAchInstructions.js";
24
+ import { canOverrideApprovalPolicy as c, canReadCounterpartBankAccounts as l } from "./index20.js";
25
+ import { resolveAmountDueMinorUnits as u } from "./index21.js";
26
+ import { usePayableAchInstructions as d } from "../../../shared/counterpart-management/feature/dist/lib/usePayableAchInstructions.js";
27
27
  import "../../../shared/counterpart-management/feature/dist/index.js";
28
- import { PayBillFlow as m } from "./index27.js";
28
+ import { PayBillFlow as f } from "./index27.js";
29
29
  import "./index28.js";
30
- import { mapPayableToBillDetails as h } from "./index41.js";
31
- import { mergeMarkAsPaidFlowLabels as g } from "./index15.js";
32
- import { useMarkAsPaidFlow as ie } from "./index17.js";
30
+ import { mapPayableToBillDetails as p } from "./index41.js";
31
+ import { mergeMarkAsPaidFlowLabels as m } from "./index15.js";
32
+ import { useMarkAsPaidFlow as oe } from "./index17.js";
33
33
  import "./index18.js";
34
- import { mergeDecisionDialogCopy as ae, mergePaymentHistoryMethodLabels as oe } from "./index45.js";
35
- import { buildPaymentHistory as se } from "./index3.js";
36
- import { currentApprovalRound as ce } from "./index4.js";
37
- import { usePayableApprovalRoundStart as le } from "./index32.js";
38
- import { useApprovalPolicyCardView as ue } from "./index33.js";
39
- import { resolveBillRejectionNotice as de } from "./index34.js";
40
- import { useCurrentApprovalRequestId as fe } from "./index35.js";
41
- import { usePayableDetailActions as pe } from "./index36.js";
42
- import { useScheduledPayment as me } from "./index37.js";
43
- import { BILL_DETAILS_LABELS_EN as _ } from "./index62.js";
44
- import { useMemo as v, useRef as he } from "react";
45
- import { Fragment as y, jsx as b, jsxs as x } from "react/jsx-runtime";
34
+ import { mergeDecisionDialogCopy as se, mergePaymentHistoryMethodLabels as ce } from "./index45.js";
35
+ import { buildPaymentHistory as le } from "./index3.js";
36
+ import { currentApprovalRound as ue } from "./index4.js";
37
+ import { usePayableApprovalRoundStart as de } from "./index32.js";
38
+ import { useApprovalPolicyCardView as fe } from "./index33.js";
39
+ import { resolveBillRejectionNotice as pe } from "./index34.js";
40
+ import { useCurrentApprovalRequestId as me } from "./index35.js";
41
+ import { usePayableDetailActions as he } from "./index36.js";
42
+ import { useScheduledPayment as ge } from "./index37.js";
43
+ import { BILL_DETAILS_LABELS_EN as h } from "./index62.js";
44
+ import { useMemo as g, useRef as _e } from "react";
45
+ import { Fragment as _, jsx as v, jsxs as y } from "react/jsx-runtime";
46
46
  //#region ../../libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index63.js
47
- function S({ open: S, onOpenChange: C, payableId: w, onClose: T, onExpand: E, onEdit: D, testId: O, labels: k, poweredByBankName: A }) {
48
- let j = v(() => ({
49
- ..._,
50
- ...k,
47
+ function b({ open: b, onOpenChange: x, payableId: S, onClose: C, onExpand: w, onEdit: T, testId: E, labels: D, poweredByBankName: O }) {
48
+ let k = g(() => ({
49
+ ...h,
50
+ ...D,
51
51
  sheet: {
52
- ..._.sheet,
53
- ...k?.sheet,
52
+ ...h.sheet,
53
+ ...D?.sheet,
54
54
  statusBadge: {
55
- ..._.sheet.statusBadge,
56
- ...k?.sheet?.statusBadge
55
+ ...h.sheet.statusBadge,
56
+ ...D?.sheet?.statusBadge
57
57
  },
58
58
  approvalPolicy: {
59
- ..._.sheet.approvalPolicy,
60
- ...k?.sheet?.approvalPolicy
59
+ ...h.sheet.approvalPolicy,
60
+ ...D?.sheet?.approvalPolicy
61
61
  },
62
62
  dueDate: {
63
- ..._.sheet.dueDate,
64
- ...k?.sheet?.dueDate
63
+ ...h.sheet.dueDate,
64
+ ...D?.sheet?.dueDate
65
65
  }
66
66
  },
67
- decisionDialog: ae(_.decisionDialog, k?.decisionDialog),
67
+ decisionDialog: se(h.decisionDialog, D?.decisionDialog),
68
68
  approvalPolicyCopy: {
69
- ..._.approvalPolicyCopy,
70
- ...k?.approvalPolicyCopy
69
+ ...h.approvalPolicyCopy,
70
+ ...D?.approvalPolicyCopy
71
71
  },
72
- markAsPaid: g(k?.markAsPaid),
72
+ markAsPaid: m(D?.markAsPaid),
73
73
  actionSuccess: {
74
- ..._.actionSuccess,
75
- ...k?.actionSuccess
74
+ ...h.actionSuccess,
75
+ ...D?.actionSuccess
76
76
  },
77
- paymentHistoryMethodLabels: oe(k?.paymentHistoryMethodLabels)
78
- }), [k]), M = i(w), N = r(w), P = ee(), { initResponse: F } = ne(), I = M.data, L = he(null), R = fe({
79
- payableId: w,
80
- status: I?.status
81
- }), z = I?.status === "rejected", ge = e(F?.scopes, [t.ApprovalRequestReadOrg]), B = z && ge, V = le({
82
- payableId: w,
83
- enabled: B
84
- }), H = re(w, { enabled: B }), _e = e(F?.scopes, [t.UserReadOrg]), U = te({ enabled: z && _e }), W = v(() => ce(H.data?.data, V.roundStartedAt), [H.data, V.roundStartedAt]), G = v(() => de({
85
- payableStatus: I?.status,
86
- approvalRequests: W,
87
- users: U.data?.data ?? [],
88
- payableUpdatedAt: I?.updated_at,
89
- labels: j
77
+ paymentHistoryMethodLabels: ce(D?.paymentHistoryMethodLabels)
78
+ }), [D]), A = n(S), j = ae(S), M = ee(), { initResponse: N } = ne(), P = A.data, F = _e(null), I = me({
79
+ payableId: S,
80
+ status: P?.status
81
+ }), L = P?.status === "rejected", ve = e(N?.scopes, [t.ApprovalRequestReadOrg]), R = L && ve, z = de({
82
+ payableId: S,
83
+ enabled: R
84
+ }), B = re(S, { enabled: R }), ye = e(N?.scopes, [t.UserReadOrg]), V = te({ enabled: L && ye }), H = g(() => ue(B.data?.data, z.roundStartedAt), [B.data, z.roundStartedAt]), U = g(() => pe({
85
+ payableStatus: P?.status,
86
+ approvalRequests: H,
87
+ users: V.data?.data ?? [],
88
+ payableUpdatedAt: P?.updated_at,
89
+ labels: k
90
90
  }), [
91
- I?.status,
92
- I?.updated_at,
93
- W,
94
- U.data,
95
- j
96
- ]), K = ue({
97
- payableId: w,
98
- approvalPolicyId: I?.approval_policy_id,
99
- copy: j.approvalPolicyCopy
100
- }), ve = u({
101
- status: I?.status,
102
- scopes: F?.scopes,
103
- arePendingApproversUnknown: K.isLoading,
104
- hasApprovalPolicy: !!I?.approval_policy_id,
105
- hasWaitingRequest: R.hasWaitingRequest
106
- }), q = me({
107
- payableId: w,
108
- scheduledPaymentDate: I?.scheduled_payment_date
109
- }), ye = p({
110
- counterpartId: I?.counterpart_id,
111
- currency: I?.currency,
112
- enabled: d(F?.scopes)
113
- }), J = ie({
114
- payableId: w,
115
- amountDueMinorUnits: f(I) ?? 0,
116
- amountToPayMinorUnits: I?.amount_to_pay ?? void 0,
117
- currencyCode: I?.currency ?? void 0,
118
- dueDate: I?.due_date,
119
- hasScheduledPayment: q.hasScheduledPayment,
120
- testId: O,
121
- labels: j.markAsPaid
122
- }), { actions: be, decisionDialog: xe } = pe({
123
- payableId: I ? w : void 0,
124
- status: I?.status,
125
- currentApprovalRequestId: R.id,
126
- hasScheduledPayment: q.hasScheduledPayment,
127
- scheduledPaymentIntentId: q.scheduledPaymentIntentId,
128
- isScheduledPaymentUnknown: q.isResolving,
129
- isPayabilityUnknown: ye.isLoading,
130
- hasApprovalPolicy: !!I?.approval_policy_id,
131
- hasWaitingRequest: R.hasWaitingRequest,
132
- pendingApprovers: K.pendingApprovers,
133
- arePendingApproversUnknown: K.isLoading,
91
+ P?.status,
92
+ P?.updated_at,
93
+ H,
94
+ V.data,
95
+ k
96
+ ]), W = fe({
97
+ payableId: S,
98
+ approvalPolicyId: P?.approval_policy_id,
99
+ copy: k.approvalPolicyCopy
100
+ }), be = c({
101
+ status: P?.status,
102
+ scopes: N?.scopes,
103
+ arePendingApproversUnknown: W.isLoading,
104
+ hasApprovalPolicy: !!P?.approval_policy_id,
105
+ hasWaitingRequest: I.hasWaitingRequest
106
+ }), G = ge({
107
+ payableId: S,
108
+ scheduledPaymentDate: P?.scheduled_payment_date
109
+ }), K = l(N?.scopes), q = d({
110
+ counterpartId: P?.counterpart_id,
111
+ currency: P?.currency,
112
+ currentBankAccountId: P?.counterpart_bank_account_id,
113
+ enabled: K
114
+ }), J = oe({
115
+ payableId: S,
116
+ amountDueMinorUnits: u(P) ?? 0,
117
+ amountToPayMinorUnits: P?.amount_to_pay ?? void 0,
118
+ currencyCode: P?.currency ?? void 0,
119
+ dueDate: P?.due_date,
120
+ hasScheduledPayment: G.hasScheduledPayment,
121
+ testId: E,
122
+ labels: k.markAsPaid
123
+ }), { actions: xe, decisionDialog: Se } = he({
124
+ payableId: P ? S : void 0,
125
+ status: P?.status,
126
+ currentApprovalRequestId: I.id,
127
+ hasScheduledPayment: G.hasScheduledPayment,
128
+ scheduledPaymentIntentId: G.scheduledPaymentIntentId,
129
+ isScheduledPaymentUnknown: G.isResolving,
130
+ isPayabilityUnknown: q.isLoading,
131
+ hasApprovalPolicy: !!P?.approval_policy_id,
132
+ hasWaitingRequest: I.hasWaitingRequest,
133
+ pendingApprovers: W.pendingApprovers,
134
+ arePendingApproversUnknown: W.isLoading,
134
135
  labels: {
135
- edit: j.sheet.editButton,
136
- payBill: j.sheet.payButton,
137
- markAsPaid: j.sheet.markAsPaidButton,
138
- reject: j.sheet.rejectButton,
139
- approve: j.sheet.approveButton,
140
- cancel: j.sheet.cancelButton,
141
- cancelScheduledPayment: j.sheet.cancelScheduledPaymentButton,
142
- reopen: j.sheet.reopenButton,
143
- forceApprove: j.sheet.forceApproveButton,
144
- forceReject: j.sheet.forceRejectButton,
145
- policyOverridesHeading: j.sheet.policyOverridesGroup,
146
- decisionDialog: j.decisionDialog,
147
- actionError: j.actionError,
148
- actionSuccess: j.actionSuccess
136
+ edit: k.sheet.editButton,
137
+ payBill: k.sheet.payButton,
138
+ markAsPaid: k.sheet.markAsPaidButton,
139
+ reject: k.sheet.rejectButton,
140
+ approve: k.sheet.approveButton,
141
+ cancel: k.sheet.cancelButton,
142
+ cancelScheduledPayment: k.sheet.cancelScheduledPaymentButton,
143
+ reopen: k.sheet.reopenButton,
144
+ forceApprove: k.sheet.forceApproveButton,
145
+ forceReject: k.sheet.forceRejectButton,
146
+ policyOverridesHeading: k.sheet.policyOverridesGroup,
147
+ decisionDialog: k.decisionDialog,
148
+ actionError: k.actionError,
149
+ actionSuccess: k.actionSuccess
149
150
  },
150
151
  isMarkAsPaidPending: J.isPending,
151
152
  onMarkAsPaidSelect: J.open,
152
- onPayBillSelect: () => L.current?.open(),
153
- onEditSelect: D,
153
+ onPayBillSelect: () => F.current?.open(),
154
+ onEditSelect: T,
154
155
  onActionSucceeded: (e) => {
155
- e === "reopen" && D?.();
156
+ e === "reopen" && T?.();
156
157
  }
157
- }), Y = q.hasScheduledPayment && q.scheduledDateLabel ? /* @__PURE__ */ b("p", {
158
+ }), Y = G.hasScheduledPayment && G.scheduledDateLabel ? /* @__PURE__ */ v("p", {
158
159
  className: "ttw:text-sm ttw:text-muted-foreground",
159
- children: j.scheduledSummary(q.scheduledDateLabel)
160
- }) : void 0, X = l({
161
- payable: I,
162
- canManage: e(F?.scopes, [t.PayableWriteOrg])
163
- }), Z = X.isPossibleDuplicate ? /* @__PURE__ */ b(s, {
160
+ children: k.scheduledSummary(G.scheduledDateLabel)
161
+ }) : void 0, X = s({
162
+ payable: P,
163
+ canManage: e(N?.scopes, [t.PayableWriteOrg])
164
+ }), Z = X.isPossibleDuplicate ? /* @__PURE__ */ v(a, {
164
165
  onNotADuplicate: X.onNotADuplicate,
165
166
  isActionDisabled: X.isBusy
166
- }) : void 0, Q = Z || Y ? /* @__PURE__ */ x(y, { children: [Z, Y] }) : void 0, $ = n(w), Se = v(() => se({
167
- records: q.paymentRecords,
168
- events: $.data?.data ?? [],
169
- currencyCode: I?.currency,
170
- labels: j
167
+ }) : void 0, Ce = Z || Y ? /* @__PURE__ */ y(_, { children: [Z, Y] }) : void 0, Q = ie(S), $ = g(() => le({
168
+ records: G.paymentRecords,
169
+ events: Q.data?.data ?? [],
170
+ currencyCode: P?.currency,
171
+ labels: k
171
172
  }), [
172
- q.paymentRecords,
173
- $.data,
174
- I?.currency,
175
- j
176
- ]), Ce = v(() => I ? h({
177
- payable: I,
178
- lineItems: N.lineItems,
179
- ledgerAccounts: P.data?.data ?? [],
180
- labels: j,
181
- hasScheduledPayment: q.hasScheduledPayment,
182
- rejection: G
173
+ G.paymentRecords,
174
+ Q.data,
175
+ P?.currency,
176
+ k
177
+ ]), we = g(() => P ? p({
178
+ payable: P,
179
+ lineItems: j.lineItems,
180
+ ledgerAccounts: M.data?.data ?? [],
181
+ labels: k,
182
+ hasScheduledPayment: G.hasScheduledPayment,
183
+ rejection: U,
184
+ achInstructions: q.achInstructions,
185
+ achInstructionsReadable: K && !q.isLoading && !q.isError
183
186
  }) : void 0, [
184
- I,
185
- N.lineItems,
186
- P.data,
187
- j,
188
- q.hasScheduledPayment,
189
- G
190
- ]), we = M.isLoading || N.isResolving || P.isResolving, Te = M.isError || N.isError || P.isError;
191
- return /* @__PURE__ */ x(y, { children: [
192
- /* @__PURE__ */ b(o, {
193
- open: S,
194
- onOpenChange: C,
195
- details: Ce,
196
- actions: be,
197
- approvalPolicy: K.view,
198
- showApprovalOverrideNotice: ve && !!I?.approval_policy_id,
199
- paymentHistory: Se,
200
- paymentHistoryError: q.isError || $.isError,
201
- paymentHistoryLoading: q.isResolving || $.isLoading,
202
- isLoading: we,
203
- isError: Te,
204
- notice: Q,
205
- onClose: T,
206
- onExpand: E,
207
- testId: O,
208
- labels: j.sheet
187
+ P,
188
+ j.lineItems,
189
+ M.data,
190
+ k,
191
+ G.hasScheduledPayment,
192
+ U,
193
+ q.achInstructions,
194
+ q.isError,
195
+ q.isLoading,
196
+ K
197
+ ]), Te = A.isLoading || j.isResolving || M.isResolving || q.isLoading, Ee = A.isError || j.isError || M.isError;
198
+ return /* @__PURE__ */ y(_, { children: [
199
+ /* @__PURE__ */ v(i, {
200
+ open: b,
201
+ onOpenChange: x,
202
+ details: we,
203
+ actions: xe,
204
+ approvalPolicy: W.view,
205
+ showApprovalOverrideNotice: be && !!P?.approval_policy_id,
206
+ paymentHistory: $,
207
+ paymentHistoryError: G.isError || Q.isError,
208
+ paymentHistoryLoading: G.isResolving || Q.isLoading,
209
+ isLoading: Te,
210
+ isError: Ee,
211
+ notice: Ce,
212
+ onClose: C,
213
+ onExpand: w,
214
+ testId: E,
215
+ labels: k.sheet
209
216
  }),
210
- /* @__PURE__ */ b(a, {
211
- ...xe,
212
- labels: { cancelButton: j.decisionDialog.cancelButton },
213
- testId: O ? `${O}-decision-dialog` : void 0,
214
- confirmTestId: O ? `${O}-decision-confirm` : void 0,
215
- reasonTestId: O ? `${O}-decision-reason` : void 0,
216
- reasonFieldId: O ? `${O}-decision-reason-field` : void 0
217
+ /* @__PURE__ */ v(r, {
218
+ ...Se,
219
+ labels: { cancelButton: k.decisionDialog.cancelButton },
220
+ testId: E ? `${E}-decision-dialog` : void 0,
221
+ confirmTestId: E ? `${E}-decision-confirm` : void 0,
222
+ reasonTestId: E ? `${E}-decision-reason` : void 0,
223
+ reasonFieldId: E ? `${E}-decision-reason-field` : void 0
217
224
  }),
218
- /* @__PURE__ */ b(c, { ...J.dialogProps }),
219
- I ? /* @__PURE__ */ b(m, {
220
- ref: L,
221
- payable: I,
222
- onMissingAchInstructions: E,
223
- poweredByBankName: A
225
+ /* @__PURE__ */ v(o, { ...J.dialogProps }),
226
+ P ? /* @__PURE__ */ v(f, {
227
+ ref: F,
228
+ payable: P,
229
+ onMissingAchInstructions: w,
230
+ poweredByBankName: O
224
231
  }) : null
225
232
  ] });
226
233
  }
227
234
  //#endregion
228
- export { S as BillDetailsContainer, S as default };
235
+ export { b as BillDetailsContainer, b as default };
@@ -130,7 +130,10 @@ function b(e) {
130
130
  return t.find((e) => e.is_default_for_currency) ?? t[0];
131
131
  }
132
132
  function x(e, t = "USD", n) {
133
- return n && (e ?? []).find((e) => e.id === n && R(e)) || (e ?? []).find((e) => e.currency === t && e.is_default_for_currency && !!e.account_holder_name && !!e.routing_number && !!e.account_number);
133
+ let r = n && (e ?? []).find((e) => e.id === n && R(e));
134
+ if (r) return r;
135
+ let i = (e ?? []).filter((e) => e.currency === t && !!e.account_holder_name && !!e.routing_number && !!e.account_number);
136
+ return i.find((e) => e.is_default_for_currency) ?? i[0];
134
137
  }
135
138
  function S(e, t = {}) {
136
139
  let n = e.line2.trim();
@@ -1,5 +1,5 @@
1
1
  //#region ../../libs/tesouro-embedded-components-react/shared/feature/dist/lib/analytics/build-info.js
2
- var e = "@tesouro/embedded-components-react", t = "0.5.16", n = "332a40715fcc23249d90357fdc0e34e34a99447a", r = Object.freeze({
2
+ var e = "@tesouro/embedded-components-react", t = "0.5.18", n = "6b276da3edb2bc3615d3cdad6a25d552880d25ec", r = Object.freeze({
3
3
  library_name: e,
4
4
  library_version: t,
5
5
  library_sha: n
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tesouro/embedded-components-react",
3
- "version": "0.5.16",
3
+ "version": "0.5.18",
4
4
  "license": "Apache-2.0",
5
5
  "type": "module",
6
6
  "packageDepSync": {