@tesouro/embedded-components-react 0.2.333 → 0.2.336

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. package/dist/index.js +1 -1
  2. package/dist/lib/BillPayWidget.js +1 -1
  3. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index.js +6 -6
  4. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index26.js +0 -1
  5. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index27.js +42 -30
  6. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index31.js +12 -46
  7. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index32.js +46 -30
  8. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index33.js +26 -149
  9. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index34.js +159 -31
  10. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index35.js +32 -98
  11. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index36.js +102 -10
  12. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index37.js +10 -212
  13. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index38.js +221 -4
  14. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index39.js +4 -29
  15. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index40.js +27 -80
  16. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index41.js +75 -125
  17. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index42.js +132 -3
  18. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index43.js +3 -4
  19. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index44.js +2 -43
  20. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index45.js +45 -1
  21. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index46.js +1 -8
  22. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index47.js +6 -9
  23. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index48.js +9 -92
  24. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index49.js +94 -3
  25. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index50.js +3 -110
  26. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index51.js +107 -8
  27. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index52.js +8 -37
  28. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index53.js +37 -5
  29. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index54.js +6 -89
  30. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index55.js +83 -154
  31. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index56.js +161 -4
  32. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index57.js +5 -8
  33. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index58.js +6 -113
  34. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index59.js +115 -1
  35. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index60.js +0 -24
  36. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index61.js +25 -0
  37. package/dist/libs/tesouro-embedded-components-react/shared/feature/dist/lib/analytics/build-info.js +1 -1
  38. package/dist/libs/tesouro-embedded-components-react/widget-suite/feature/dist/index7.js +1 -1
  39. package/package.json +1 -1
@@ -1,38 +1,166 @@
1
+ "use client";
2
+ "use client";
3
+ "use client";
4
+ "use client";
5
+ import { toast as e } from "../../../../../packages/shared-ui-shadcn/dist/index.js";
6
+ import "../../../shared/ui/dist/index.js";
7
+ import { useReplacePayableLineItemsMutation as t } from "../../data-access/dist/index7.js";
8
+ import { useCreatePayableMutation as n, useSubmitPayableForApprovalMutation as r, useUpdatePayableMutation as i, useValidatePayableMutation as a } from "../../data-access/dist/index10.js";
9
+ import "../../data-access/dist/index.js";
10
+ import { BILL_CREATE_MESSAGE_LABELS_EN as o } from "./index26.js";
11
+ import { encodeFileToBase64 as s } from "./index31.js";
12
+ import { mapBillFormToPayload as c, mapLineItemsToPayload as l } from "./index32.js";
13
+ import { validateBillCompleteness as u, validateBillTotals as d, validateLineItems as f } from "./index33.js";
14
+ import { useCallback as p, useRef as m, useState as h } from "react";
1
15
  //#region ../../libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index34.js
2
- function e() {
3
- return {
4
- id: crypto.randomUUID(),
5
- description: "",
6
- glCode: "",
7
- quantity: "1",
8
- price: "",
9
- amount: ""
10
- };
16
+ var g = {
17
+ document_id: "invoiceNumber",
18
+ issued_at: "invoiceDate",
19
+ due_date: "dueDate",
20
+ counterpart_id: "vendor"
21
+ };
22
+ function _(e) {
23
+ return e.type === "type_error.none.not_allowed" || e.msg === "none is not an allowed value";
11
24
  }
12
- function t(e) {
13
- return typeof e == "number" ? (e / 100).toFixed(2) : "";
25
+ function v(e, t = o) {
26
+ let n = {}, r = [];
27
+ for (let i of e) {
28
+ let e = i.loc[0] ?? t.unknownValidationField, a = g[e], o = _(i) ? t.requiredField : i.msg;
29
+ a ? n[a] = o : r.push(t.unmappedValidationError(e, o));
30
+ }
31
+ return r.length && (n.form = r.join(" ")), n;
32
+ }
33
+ function y(e, t) {
34
+ if (!e && !t) return;
35
+ let n = {}, r = /* @__PURE__ */ new Set([...Object.keys(e ?? {}), ...Object.keys(t ?? {})]);
36
+ for (let i of r) n[i] = {
37
+ ...e?.[i],
38
+ ...t?.[i]
39
+ };
40
+ return n;
14
41
  }
15
- function n({ payable: n, lineItems: r }) {
16
- let i = {
17
- invoiceNumber: n.document_id ?? "",
18
- invoiceDate: n.issued_at ?? "",
19
- dueDate: n.due_date ?? "",
20
- poNumber: ""
21
- }, a = r.map((e) => ({
22
- id: e.id,
23
- description: e.name ?? "",
24
- glCode: e.ledger_account_id ?? "",
25
- quantity: e.quantity == null ? "" : String(e.quantity),
26
- price: t(e.unit_price),
27
- amount: t(e.subtotal)
28
- }));
42
+ function b({ payableId: g, form: _, counterpartId: b, clearCounterpart: x, prepareVendorForSave: S, onSaved: C, onPayableCreated: w, onDraftSaved: T, onFinalized: E, labels: D }) {
43
+ let O = {
44
+ ...o,
45
+ ...D
46
+ }, [k, A] = h(), j = g ?? k, [M, N] = h(), P = p(() => N(void 0), []), [F, I] = h(), L = m(!1), R = n(), z = i(), B = t(), V = a(), H = r(), U = p(() => {
47
+ let t = f(_.lineItems, O), n = d(_.discount, _.tax, _.totalOverride, O);
48
+ return _.setLineItemErrors(t), !t && !n || (t ? (_.setErrors(void 0), e.error(O.lineItemsNeedAttention)) : _.setErrors(n), !1);
49
+ }, [_, O]), W = p(async () => {
50
+ let e = !j && M ? {
51
+ base64EncodedFile: await s(M),
52
+ fileName: M.name
53
+ } : void 0, t = c({
54
+ values: _.values,
55
+ counterpartId: b,
56
+ clearCounterpart: x,
57
+ editedTotals: _.isTotalsDirty ? {
58
+ discount: _.discount,
59
+ tax: _.tax,
60
+ total: _.totalOverride
61
+ } : void 0,
62
+ document: e
63
+ }), n = j;
64
+ if (n ? await z.mutateAsync({
65
+ path: { payable_id: n },
66
+ body: t
67
+ }) : (n = (await R.mutateAsync({ body: t }))?.id, n && (A(n), w?.(n), e && N(void 0))), !n) throw Error("Payable was created without an id");
68
+ return await B.mutateAsync({
69
+ path: { payable_id: n },
70
+ body: { data: l(_.lineItems) }
71
+ }), n;
72
+ }, [
73
+ b,
74
+ x,
75
+ R,
76
+ _.discount,
77
+ _.isTotalsDirty,
78
+ _.lineItems,
79
+ _.tax,
80
+ _.totalOverride,
81
+ _.values,
82
+ w,
83
+ j,
84
+ B,
85
+ M,
86
+ z
87
+ ]);
29
88
  return {
30
- values: i,
31
- lineItems: a.length ? a : [e()],
32
- discount: t(n.discount),
33
- tax: t(n.tax_amount),
34
- total: t(n.total_amount)
89
+ saveDraft: p(async () => {
90
+ if (!L.current && U()) {
91
+ L.current = !0, I("draft");
92
+ try {
93
+ if (await S?.() === !1) return;
94
+ let t = await W();
95
+ _.setErrors(void 0), C?.(t), T?.(t), e.success(O.draftSaved);
96
+ } catch {
97
+ _.setErrors({ form: O.saveFailed });
98
+ } finally {
99
+ I(void 0), L.current = !1;
100
+ }
101
+ }
102
+ }, [
103
+ _,
104
+ U,
105
+ O.draftSaved,
106
+ O.saveFailed,
107
+ T,
108
+ C,
109
+ S,
110
+ W
111
+ ]),
112
+ finalize: p(async () => {
113
+ if (L.current) return;
114
+ let t = f(_.lineItems, O), n = d(_.discount, _.tax, _.totalOverride, O), { formErrors: r, lineItemErrors: i } = u(_.values, b, _.lineItems, O), a = y(i, t);
115
+ _.setLineItemErrors(a);
116
+ let o = {
117
+ ...r,
118
+ ...n
119
+ };
120
+ if (_.setErrors(Object.keys(o).length ? o : void 0), t && e.error(O.lineItemsNeedAttention), !(a || Object.keys(o).length)) {
121
+ L.current = !0, I("finalize");
122
+ try {
123
+ let t;
124
+ try {
125
+ if (await S?.() === !1) return;
126
+ t = await W();
127
+ } catch {
128
+ _.setErrors({ form: O.saveFailed });
129
+ return;
130
+ }
131
+ C?.(t);
132
+ try {
133
+ let n = await V.mutateAsync({ path: { payable_id: t } });
134
+ if (n.validation_errors.length) {
135
+ _.setErrors(v(n.validation_errors, O));
136
+ return;
137
+ }
138
+ await H.mutateAsync({ path: { payable_id: t } }), _.setErrors(void 0), E?.(t), e.success(O.billFinalized);
139
+ } catch {
140
+ _.setErrors({ form: O.finalizeFailed });
141
+ }
142
+ } finally {
143
+ I(void 0), L.current = !1;
144
+ }
145
+ }
146
+ }, [
147
+ b,
148
+ _,
149
+ O,
150
+ E,
151
+ C,
152
+ S,
153
+ W,
154
+ H,
155
+ V
156
+ ]),
157
+ payableId: j,
158
+ isSavingDraft: F === "draft",
159
+ isFinalizing: F === "finalize",
160
+ stagedFile: M,
161
+ stageFile: N,
162
+ clearStagedFile: P
35
163
  };
36
164
  }
37
165
  //#endregion
38
- export { e as emptyLineItem, n as mapPayableToBillForm };
166
+ export { v as mapValidationErrorsToForm, b as useBillCreateController };
@@ -1,104 +1,38 @@
1
- "use client";
2
- "use client";
3
- "use client";
4
- "use client";
5
- import { calculateTotal as e, displayLineAmount as t, parseMoneyToMinorUnits as n } from "./index31.js";
6
- import { emptyLineItem as r, mapPayableToBillForm as i } from "./index34.js";
7
- import { useCallback as a, useEffect as o, useMemo as s, useState as c } from "react";
8
1
  //#region ../../libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index35.js
9
- function l(e, r, i) {
10
- return n(r) === null ? i : t(e, r);
2
+ function e() {
3
+ return {
4
+ id: crypto.randomUUID(),
5
+ description: "",
6
+ glCode: "",
7
+ quantity: "1",
8
+ price: "",
9
+ amount: ""
10
+ };
11
+ }
12
+ function t(e) {
13
+ return typeof e == "number" ? (e / 100).toFixed(2) : "";
11
14
  }
12
- function u({ payable: t, lineItems: n } = {}) {
13
- let u = s(() => i({
14
- payable: t ?? {},
15
- lineItems: n ?? []
16
- }), [t, n]), [d, f] = c(u.values), [p, m] = c(u.lineItems), [h, g] = c(u.discount), [_, v] = c(u.tax), [y, b] = c(u.total || void 0), [x, S] = c(), [C, w] = c(), [T, E] = c(!1), [D, O] = c(!1), [k, A] = c(!1);
17
- o(() => {
18
- T || f(u.values);
19
- }, [u]), o(() => {
20
- D || m(u.lineItems);
21
- }, [u]), o(() => {
22
- k || (g(u.discount), v(u.tax), b(u.total || void 0));
23
- }, [u]);
24
- let j = a((e) => {
25
- f((t) => ({
26
- ...t,
27
- ...e
28
- })), E(!0);
29
- }, []), M = a((e) => {
30
- w((t) => {
31
- if (!t?.[e]) return t;
32
- let n = { ...t };
33
- return delete n[e], Object.keys(n).length ? n : void 0;
34
- });
35
- }, []), N = a((e, t) => {
36
- M(e), m((n) => n.map((n) => {
37
- if (n.id !== e) return n;
38
- let r = {
39
- ...n,
40
- ...t
41
- };
42
- return "amount" in t ? r : {
43
- ...r,
44
- amount: l(r.quantity, r.price, r.amount)
45
- };
46
- })), O(!0), b(void 0);
47
- }, [M]), P = a((e, t) => {
48
- M(e), m((n) => n.map((n) => {
49
- if (n.id !== e) return n;
50
- let r = Number.parseFloat(n.quantity), i = String(Math.max(1, (Number.isFinite(r) ? r : 1) + t));
51
- return {
52
- ...n,
53
- quantity: i,
54
- amount: l(i, n.price, n.amount)
55
- };
56
- })), O(!0), b(void 0);
57
- }, [M]), F = a((e) => {
58
- M(e), m((t) => t.length <= 1 ? t : t.filter((t) => t.id !== e)), O(!0), b(void 0);
59
- }, [M]), I = a(() => {
60
- m((e) => [...e, r()]), O(!0), b(void 0);
61
- }, []), L = a((e) => {
62
- g(e), A(!0), b(void 0);
63
- }, []), R = a((e) => {
64
- v(e), A(!0), b(void 0);
65
- }, []), z = a((e) => {
66
- b(e), A(!0);
67
- }, []), B = s(() => p.map((e) => ({
68
- ...e,
69
- onChange: (t) => N(e.id, t),
70
- onQuantityStep: (t) => P(e.id, t),
71
- onRemove: () => F(e.id)
72
- })), [
73
- p,
74
- N,
75
- F,
76
- P
77
- ]), V = s(() => e(p, _, h), [
78
- p,
79
- _,
80
- h
81
- ]);
15
+ function n({ payable: n, lineItems: r }) {
16
+ let i = {
17
+ invoiceNumber: n.document_id ?? "",
18
+ invoiceDate: n.issued_at ?? "",
19
+ dueDate: n.due_date ?? "",
20
+ poNumber: ""
21
+ }, a = r.map((e) => ({
22
+ id: e.id,
23
+ description: e.name ?? "",
24
+ glCode: e.ledger_account_id ?? "",
25
+ quantity: e.quantity == null ? "" : String(e.quantity),
26
+ price: t(e.unit_price),
27
+ amount: t(e.subtotal)
28
+ }));
82
29
  return {
83
- values: d,
84
- errors: x,
85
- setErrors: S,
86
- lineItemErrors: C,
87
- setLineItemErrors: w,
88
- onChange: j,
89
- lineItems: p,
90
- lineItemRows: B,
91
- discount: h,
92
- onDiscountChange: L,
93
- tax: _,
94
- onTaxChange: R,
95
- total: y ?? V,
96
- totalOverride: y,
97
- onTotalChange: z,
98
- onAddLineItem: I,
99
- isTotalsDirty: k,
100
- isDirty: T || D || k
30
+ values: i,
31
+ lineItems: a.length ? a : [e()],
32
+ discount: t(n.discount),
33
+ tax: t(n.tax_amount),
34
+ total: t(n.total_amount)
101
35
  };
102
36
  }
103
37
  //#endregion
104
- export { u as useBillForm };
38
+ export { e as emptyLineItem, n as mapPayableToBillForm };
@@ -1,12 +1,104 @@
1
+ "use client";
2
+ "use client";
3
+ "use client";
4
+ "use client";
5
+ import { calculateTotal as e, displayLineAmount as t, parseMoneyToMinorUnits as n } from "./index32.js";
6
+ import { emptyLineItem as r, mapPayableToBillForm as i } from "./index35.js";
7
+ import { useCallback as a, useEffect as o, useMemo as s, useState as c } from "react";
1
8
  //#region ../../libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index36.js
2
- var e = {
3
- dialog: "bill-pay-bill-create-dialog",
4
- vendorSection: "bill-pay-bill-create-vendor",
5
- lineItems: "bill-pay-bill-create-line-items",
6
- documentPanel: "bill-pay-bill-create-document",
7
- decisionDialog: "bill-pay-bill-decision-dialog",
8
- decisionConfirm: "bill-pay-bill-decision-confirm",
9
- decisionReason: "bill-pay-bill-decision-reason"
10
- };
9
+ function l(e, r, i) {
10
+ return n(r) === null ? i : t(e, r);
11
+ }
12
+ function u({ payable: t, lineItems: n } = {}) {
13
+ let u = s(() => i({
14
+ payable: t ?? {},
15
+ lineItems: n ?? []
16
+ }), [t, n]), [d, f] = c(u.values), [p, m] = c(u.lineItems), [h, g] = c(u.discount), [_, v] = c(u.tax), [y, b] = c(u.total || void 0), [x, S] = c(), [C, w] = c(), [T, E] = c(!1), [D, O] = c(!1), [k, A] = c(!1);
17
+ o(() => {
18
+ T || f(u.values);
19
+ }, [u]), o(() => {
20
+ D || m(u.lineItems);
21
+ }, [u]), o(() => {
22
+ k || (g(u.discount), v(u.tax), b(u.total || void 0));
23
+ }, [u]);
24
+ let j = a((e) => {
25
+ f((t) => ({
26
+ ...t,
27
+ ...e
28
+ })), E(!0);
29
+ }, []), M = a((e) => {
30
+ w((t) => {
31
+ if (!t?.[e]) return t;
32
+ let n = { ...t };
33
+ return delete n[e], Object.keys(n).length ? n : void 0;
34
+ });
35
+ }, []), N = a((e, t) => {
36
+ M(e), m((n) => n.map((n) => {
37
+ if (n.id !== e) return n;
38
+ let r = {
39
+ ...n,
40
+ ...t
41
+ };
42
+ return "amount" in t ? r : {
43
+ ...r,
44
+ amount: l(r.quantity, r.price, r.amount)
45
+ };
46
+ })), O(!0), b(void 0);
47
+ }, [M]), P = a((e, t) => {
48
+ M(e), m((n) => n.map((n) => {
49
+ if (n.id !== e) return n;
50
+ let r = Number.parseFloat(n.quantity), i = String(Math.max(1, (Number.isFinite(r) ? r : 1) + t));
51
+ return {
52
+ ...n,
53
+ quantity: i,
54
+ amount: l(i, n.price, n.amount)
55
+ };
56
+ })), O(!0), b(void 0);
57
+ }, [M]), F = a((e) => {
58
+ M(e), m((t) => t.length <= 1 ? t : t.filter((t) => t.id !== e)), O(!0), b(void 0);
59
+ }, [M]), I = a(() => {
60
+ m((e) => [...e, r()]), O(!0), b(void 0);
61
+ }, []), L = a((e) => {
62
+ g(e), A(!0), b(void 0);
63
+ }, []), R = a((e) => {
64
+ v(e), A(!0), b(void 0);
65
+ }, []), z = a((e) => {
66
+ b(e), A(!0);
67
+ }, []), B = s(() => p.map((e) => ({
68
+ ...e,
69
+ onChange: (t) => N(e.id, t),
70
+ onQuantityStep: (t) => P(e.id, t),
71
+ onRemove: () => F(e.id)
72
+ })), [
73
+ p,
74
+ N,
75
+ F,
76
+ P
77
+ ]), V = s(() => e(p, _, h), [
78
+ p,
79
+ _,
80
+ h
81
+ ]);
82
+ return {
83
+ values: d,
84
+ errors: x,
85
+ setErrors: S,
86
+ lineItemErrors: C,
87
+ setLineItemErrors: w,
88
+ onChange: j,
89
+ lineItems: p,
90
+ lineItemRows: B,
91
+ discount: h,
92
+ onDiscountChange: L,
93
+ tax: _,
94
+ onTaxChange: R,
95
+ total: y ?? V,
96
+ totalOverride: y,
97
+ onTotalChange: z,
98
+ onAddLineItem: I,
99
+ isTotalsDirty: k,
100
+ isDirty: T || D || k
101
+ };
102
+ }
11
103
  //#endregion
12
- export { e as billCreateTestIds };
104
+ export { u as useBillForm };
@@ -1,214 +1,12 @@
1
- "use client";
2
- "use client";
3
- "use client";
4
- "use client";
5
- import { hasAnyScope as e } from "../../../shared/data-access/dist/lib/hasAnyScope.js";
6
- import { Scope as t } from "../../../shared/data-access/dist/lib/scopes.js";
7
- import { useAllLedgerAccountsQuery as ee } from "../../../shared/data-access/dist/lib/reference-data/useLedgerAccountsQuery.js";
8
- import { useAllOrganizationUsersQuery as te } from "../../../shared/data-access/dist/lib/user/useAllOrganizationUsersQuery.js";
9
- import "../../../shared/data-access/dist/index.js";
10
- import { formatCalendarDate as ne } from "../../../shared/util/dist/lib/formatCalendarDate.js";
11
- import { useWidgetConfig as re } from "../../../shared/feature/dist/lib/WidgetProvider/hooks.js";
12
- import "../../../shared/feature/dist/index.js";
13
- import { resolveVendor as ie } from "./index3.js";
14
- import { BillCreateScreen as ae } from "../../ui/dist/index40.js";
15
- import { BillDecisionDialog as oe } from "../../ui/dist/index46.js";
16
- import { ExtractionNotice as se } from "../../ui/dist/index61.js";
17
- import "../../ui/dist/index.js";
18
- import { usePayableHistoryQuery as ce } from "../../data-access/dist/index6.js";
19
- import { useAllPayableLineItemsQuery as le } from "../../data-access/dist/index7.js";
20
- import { usePayableQuery as ue } from "../../data-access/dist/index13.js";
21
- import "../../data-access/dist/index.js";
22
- import { PayBillFlow as de } from "./index10.js";
23
- import "./index11.js";
24
- import { mergeBillCreateScreenCopy as fe } from "./index26.js";
25
- import { useBillCreateController as pe } from "./index33.js";
26
- import { useBillForm as n } from "./index35.js";
27
- import { useApprovalPolicyCardView as r } from "./index15.js";
28
- import { useCurrentApprovalRequestId as i } from "./index16.js";
29
- import { usePayableDetailActions as a } from "./index18.js";
30
- import { useScheduledPayment as o } from "./index19.js";
31
- import { buildBillDetailView as s } from "./index22.js";
32
- import { buildBillHistory as me } from "./index23.js";
33
- import { SourceDocumentContainer as he } from "./index27.js";
34
- import { useVendorSectionProps as ge } from "./index29.js";
35
- import { usePaymentInstructionsForm as _e } from "./index30.js";
36
- import { billCreateTestIds as c } from "./index36.js";
37
- import { useCallback as l, useEffect as ve, useMemo as u, useRef as ye, useState as d } from "react";
38
- import { Fragment as be, jsx as f, jsxs as xe } from "react/jsx-runtime";
39
1
  //#region ../../libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index37.js
40
- function Se(e) {
41
- return !!(e?.bank_account?.account_holder_name && e.bank_account.routing_number && e.bank_account.account_number);
42
- }
43
- function p({ open: p, onOpenChange: m, payableId: h, readOnly: g = !1, copy: _, poweredByBankName: Ce }) {
44
- let v = u(() => fe(_), [_]), [y, b] = d(), [x, S] = d(!1), [C, w] = d(!1), [T, E] = d(), D = h ?? T, O = ue(D, { pollWhileOcrProcessing: !0 }), k = le(D), A = ee(), j = O.data, M = n({
45
- payable: j,
46
- lineItems: k.lineItems
47
- }), N = j?.counterpart_id;
48
- ve(() => {
49
- x || N && (b(N), S(!0));
50
- }, [x, N]);
51
- let we = l((e) => {
52
- S(!0), b(e);
53
- }, []), P = ge({
54
- payableId: g ? void 0 : D,
55
- counterpartId: g ? void 0 : y,
56
- payableCounterpartId: N,
57
- onCounterpartChange: we,
58
- requiredError: M.errors?.vendor
59
- }), F = pe({
60
- payableId: h,
61
- form: M,
62
- counterpartId: y,
63
- clearCounterpart: !!(D && x) && !y,
64
- prepareVendorForSave: P.savePaymentInstructions,
65
- onPayableCreated: E,
66
- onSaved: E,
67
- onDraftSaved: () => m(!1),
68
- onFinalized: () => m(!1)
69
- }), I = !!(F.isSavingDraft || F.isFinalizing), L = g ? D : void 0, R = i({
70
- payableId: L,
71
- status: j?.status
72
- }), z = ye(null), B = o({
73
- payableId: D,
74
- scheduledPaymentDate: j?.scheduled_payment_date,
75
- enabled: g
76
- }), V = ie(j), H = _e({
77
- payableId: L,
78
- counterpartId: g ? N : void 0,
79
- saveErrorMessage: v.detail.paymentInstructionsSaveError
80
- }), { initResponse: U } = re(), W = e(U?.scopes, [t.CounterpartWriteOrg]) && e(U?.scopes, [t.PayableWriteOrg]), { actions: Te, decisionDialog: Ee } = a({
81
- payableId: L,
82
- status: j?.status,
83
- currentApprovalRequestId: R.id,
84
- isPolicyApprover: R.isPolicyApprover,
85
- hasWaitingRequest: R.hasWaitingRequest,
86
- hasScheduledPayment: B.hasScheduledPayment,
87
- isScheduledPaymentUnknown: B.isResolving,
88
- labels: v.actions,
89
- onPayBillSelect: () => Se(V) || !W ? z.current?.open() : H.open()
90
- }), G = u(() => (A.data?.data ?? []).map((e) => ({
91
- value: e.id,
92
- label: [e.nominal_code, e.name].filter(Boolean).join(" — ")
93
- })), [A.data]), K = ce(L), q = e(U?.scopes, [t.UserReadOrg]), J = te({ enabled: g && q }), Y = u(() => me(K.data?.data ?? [], J.data?.data ?? [], v.history), [
94
- K.data,
95
- J.data,
96
- v.history
97
- ]), X = r({
98
- payableId: L,
99
- approvalPolicyId: j?.approval_policy_id,
100
- enabled: g,
101
- copy: v.approvalPolicyCopy
102
- }), De = u(() => g && j ? s({
103
- payable: j,
104
- lineItems: k.lineItems,
105
- glCodeOptions: G,
106
- history: Y,
107
- approvalPolicy: X.view,
108
- labels: v.detail
109
- }) : void 0, [
110
- X.view,
111
- v.detail,
112
- G,
113
- Y,
114
- k.lineItems,
115
- j,
116
- g
117
- ]), Z = j?.source_of_payable_data === "ocr", Q = V?.name, Oe = g ? Q ? v.viewTitle(Q) : v.readOnlyTitle : Z && Q ? v.extractedTitle(Q) : v.newTitle, ke = g && j?.created_at ? v.addedOn(ne(j.created_at.slice(0, 10))) : void 0, $ = l(() => {
118
- let e = M.isDirty || P.hasUnsavedVendorChanges;
119
- !g && e && !window.confirm(v.discardConfirm) || m(!1);
120
- }, [
121
- v.discardConfirm,
122
- M.isDirty,
123
- m,
124
- g,
125
- P.hasUnsavedVendorChanges
126
- ]), Ae = l((e) => {
127
- if (!I) return e ? m(!0) : $();
128
- }, [
129
- $,
130
- I,
131
- m
132
- ]);
133
- return /* @__PURE__ */ xe(be, { children: [
134
- /* @__PURE__ */ f(ae, {
135
- open: p,
136
- onOpenChange: Ae,
137
- title: Oe,
138
- subtitle: ke,
139
- notice: !g && Z && !C ? /* @__PURE__ */ f(se, { onDismiss: () => w(!0) }) : void 0,
140
- vendor: {
141
- ...P,
142
- testId: c.vendorSection
143
- },
144
- values: M.values,
145
- errors: M.errors,
146
- onChange: M.onChange,
147
- lineItems: {
148
- items: M.lineItemRows,
149
- glCodeOptions: G,
150
- discount: M.discount,
151
- onDiscountChange: M.onDiscountChange,
152
- tax: M.tax,
153
- onTaxChange: M.onTaxChange,
154
- total: M.total,
155
- onTotalChange: M.onTotalChange,
156
- onAddLineItem: M.onAddLineItem,
157
- errors: M.lineItemErrors,
158
- testId: c.lineItems
159
- },
160
- documentPanel: /* @__PURE__ */ f(he, {
161
- payableId: D,
162
- readOnly: g,
163
- isDocumentPending: !!D && !j?.file && (O.isLoading || j?.ocr_status === "processing"),
164
- file: j?.file ? {
165
- id: j.file.id,
166
- name: j.file.name,
167
- url: j.file.url,
168
- mimetype: j.file.mimetype
169
- } : void 0
170
- }),
171
- readOnly: g,
172
- detail: g ? {
173
- view: De,
174
- actions: Te,
175
- scheduledSummary: B.hasScheduledPayment && B.scheduledDateLabel ? v.scheduledSummary(B.scheduledDateLabel) : void 0,
176
- paymentInstructionsForm: N && W ? {
177
- isOpen: H.isOpen,
178
- values: H.values,
179
- errors: H.errors,
180
- isSaving: H.isSaving,
181
- onOpen: H.open,
182
- onCancel: H.close,
183
- onChange: H.onChange,
184
- onSave: H.save
185
- } : void 0,
186
- isLoading: O.isLoading || k.isResolving || A.isResolving,
187
- isError: O.isError || k.isError || A.isError
188
- } : void 0,
189
- isLineItemsLoading: k.isResolving,
190
- isSaving: I,
191
- isSavingDraft: F.isSavingDraft,
192
- isFinalizing: F.isFinalizing,
193
- onCancel: $,
194
- onSaveDraft: F.saveDraft,
195
- onFinalize: F.finalize,
196
- testId: c.dialog
197
- }),
198
- /* @__PURE__ */ f(oe, {
199
- ...Ee,
200
- labels: { cancelButton: v.actions.decisionDialog.cancelButton },
201
- testId: c.decisionDialog,
202
- confirmTestId: c.decisionConfirm,
203
- reasonTestId: c.decisionReason
204
- }),
205
- g && j ? /* @__PURE__ */ f(de, {
206
- ref: z,
207
- payable: j,
208
- poweredByBankName: Ce,
209
- labels: v.payBill
210
- }) : null
211
- ] });
212
- }
2
+ var e = {
3
+ dialog: "bill-pay-bill-create-dialog",
4
+ vendorSection: "bill-pay-bill-create-vendor",
5
+ lineItems: "bill-pay-bill-create-line-items",
6
+ documentPanel: "bill-pay-bill-create-document",
7
+ decisionDialog: "bill-pay-bill-decision-dialog",
8
+ decisionConfirm: "bill-pay-bill-decision-confirm",
9
+ decisionReason: "bill-pay-bill-decision-reason"
10
+ };
213
11
  //#endregion
214
- export { p as BillCreateDialog, p as default };
12
+ export { e as billCreateTestIds };