@tesouro/embedded-components-react 0.2.337 → 0.2.339

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 (66) hide show
  1. package/dist/index.css +4 -0
  2. package/dist/index.js +1 -1
  3. package/dist/lib/BillPayWidget.js +1 -1
  4. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/data-access/dist/index.js +5 -5
  5. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/data-access/dist/index10.js +103 -58
  6. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/data-access/dist/index4.js +74 -37
  7. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index.js +8 -8
  8. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index17.js +25 -20
  9. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index18.js +64 -48
  10. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index19.js +4 -3
  11. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index20.js +40 -50
  12. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index21.js +51 -5
  13. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index22.js +5 -71
  14. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index23.js +71 -48
  15. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index24.js +46 -77
  16. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index25.js +78 -33
  17. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index26.js +33 -117
  18. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index27.js +138 -67
  19. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index28.js +63 -200
  20. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index29.js +194 -184
  21. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index30.js +180 -50
  22. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index31.js +64 -12
  23. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index32.js +12 -46
  24. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index33.js +46 -30
  25. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index34.js +26 -158
  26. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index35.js +159 -31
  27. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index36.js +32 -98
  28. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index37.js +102 -11
  29. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index38.js +13 -224
  30. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index39.js +243 -4
  31. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index40.js +4 -29
  32. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index41.js +27 -80
  33. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index42.js +76 -126
  34. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index43.js +137 -3
  35. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index44.js +3 -4
  36. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index45.js +2 -43
  37. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index46.js +45 -1
  38. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index47.js +1 -8
  39. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index48.js +6 -9
  40. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index49.js +9 -92
  41. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index50.js +94 -3
  42. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index51.js +3 -9
  43. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index52.js +7 -20
  44. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index53.js +14 -51
  45. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index54.js +59 -3
  46. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index55.js +3 -110
  47. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index56.js +107 -8
  48. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index57.js +8 -40
  49. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index58.js +40 -5
  50. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index59.js +6 -98
  51. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index60.js +91 -171
  52. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index61.js +179 -4
  53. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index62.js +5 -8
  54. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index63.js +6 -113
  55. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index64.js +115 -1
  56. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index65.js +0 -24
  57. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index66.js +25 -0
  58. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index34.js +2 -0
  59. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index35.js +14 -11
  60. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index52.js +1 -0
  61. package/dist/libs/tesouro-embedded-components-react/shared/data-access/dist/index.js +26 -26
  62. package/dist/libs/tesouro-embedded-components-react/shared/data-access/dist/lib/clientRegistry.js +11 -2
  63. package/dist/libs/tesouro-embedded-components-react/shared/data-access/dist/lib/rest/sdk.gen.js +94 -74
  64. package/dist/libs/tesouro-embedded-components-react/shared/feature/dist/lib/analytics/build-info.js +1 -1
  65. package/dist/libs/tesouro-embedded-components-react/widget-suite/feature/dist/index7.js +1 -1
  66. 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 "./index27.js";
11
+ import { encodeFileToBase64 as s } from "./index32.js";
12
+ import { mapBillFormToPayload as c, mapLineItemsToPayload as l } from "./index33.js";
13
+ import { validateBillCompleteness as u, validateBillTotals as d, validateLineItems as f } from "./index34.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/index35.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 "./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";
8
1
  //#region ../../libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index36.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,13 +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 "./index33.js";
6
+ import { emptyLineItem as r, mapPayableToBillForm as i } from "./index36.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/index37.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
- duplicateNotice: "bill-pay-bill-create-duplicate-notice",
8
- decisionDialog: "bill-pay-bill-decision-dialog",
9
- decisionConfirm: "bill-pay-bill-decision-confirm",
10
- decisionReason: "bill-pay-bill-decision-reason"
11
- };
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
+ }
12
103
  //#endregion
13
- export { e as billCreateTestIds };
104
+ export { u as useBillForm };
@@ -1,226 +1,15 @@
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 n } from "./index3.js";
14
- import { BillCreateScreen as ie } from "../../ui/dist/index41.js";
15
- import { BillDecisionDialog as r } from "../../ui/dist/index47.js";
16
- import { BillDuplicateNotice as ae } from "../../ui/dist/index57.js";
17
- import { ExtractionNotice as oe } from "../../ui/dist/index70.js";
18
- import "../../ui/dist/index.js";
19
- import { usePayableHistoryQuery as se } from "../../data-access/dist/index6.js";
20
- import { useAllPayableLineItemsQuery as ce } from "../../data-access/dist/index7.js";
21
- import { usePayableQuery as le } from "../../data-access/dist/index13.js";
22
- import "../../data-access/dist/index.js";
23
- import { PayBillFlow as ue } from "./index10.js";
24
- import "./index11.js";
25
- import { mergeBillCreateScreenCopy as de } from "./index26.js";
26
- import { useBillCreateController as fe } from "./index34.js";
27
- import { useBillForm as pe } from "./index36.js";
28
- import { useApprovalPolicyCardView as me } from "./index15.js";
29
- import { useCurrentApprovalRequestId as i } from "./index16.js";
30
- import { usePayableDetailActions as he } from "./index18.js";
31
- import { useScheduledPayment as ge } from "./index19.js";
32
- import { buildBillDetailView as _e } from "./index22.js";
33
- import { buildBillHistory as ve } from "./index23.js";
34
- import { SourceDocumentContainer as ye } from "./index27.js";
35
- import { useVendorSectionProps as be } from "./index29.js";
36
- import { usePaymentInstructionsForm as xe } from "./index30.js";
37
- import { billCreateTestIds as a } from "./index37.js";
38
- import { useCallback as o, useEffect as Se, useMemo as s, useRef as Ce, useState as c } from "react";
39
- import { Fragment as l, jsx as u, jsxs as d } from "react/jsx-runtime";
40
1
  //#region ../../libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index38.js
41
- function we(e) {
42
- return !!(e?.bank_account?.account_holder_name && e.bank_account.routing_number && e.bank_account.account_number);
43
- }
44
- function f({ open: f, onOpenChange: p, payableId: m, readOnly: h = !1, copy: g, poweredByBankName: Te, isPossibleDuplicate: Ee }) {
45
- let _ = s(() => de(g), [g]), [v, y] = c(), [b, x] = c(!1), [De, Oe] = c(!1), [S, C] = c(!1), [w, T] = c(), E = m ?? w, D = le(E, { pollWhileOcrProcessing: !0 }), O = ce(E), k = ee(), A = D.data, j = pe({
46
- payable: A,
47
- lineItems: O.lineItems
48
- }), M = A?.counterpart_id;
49
- Se(() => {
50
- b || M && (y(M), x(!0));
51
- }, [b, M]);
52
- let ke = o((e) => {
53
- x(!0), y(e);
54
- }, []), N = be({
55
- payableId: h ? void 0 : E,
56
- counterpartId: h ? void 0 : v,
57
- payableCounterpartId: M,
58
- onCounterpartChange: ke,
59
- requiredError: j.errors?.vendor
60
- }), P = fe({
61
- payableId: m,
62
- form: j,
63
- counterpartId: v,
64
- clearCounterpart: !!(E && b) && !v,
65
- prepareVendorForSave: N.savePaymentInstructions,
66
- onPayableCreated: T,
67
- onSaved: T,
68
- onDraftSaved: () => p(!1),
69
- onFinalized: () => p(!1)
70
- }), F = !!(P.isSavingDraft || P.isFinalizing), I = h ? E : void 0, L = i({
71
- payableId: I,
72
- status: A?.status
73
- }), R = Ce(null), z = ge({
74
- payableId: E,
75
- scheduledPaymentDate: A?.scheduled_payment_date,
76
- enabled: h
77
- }), B = n(A), V = xe({
78
- payableId: I,
79
- counterpartId: h ? M : void 0,
80
- saveErrorMessage: _.detail.paymentInstructionsSaveError
81
- }), { initResponse: H } = re(), U = e(H?.scopes, [t.CounterpartWriteOrg]) && e(H?.scopes, [t.PayableWriteOrg]), { actions: Ae, decisionDialog: je } = he({
82
- payableId: I,
83
- status: A?.status,
84
- currentApprovalRequestId: L.id,
85
- isPolicyApprover: L.isPolicyApprover,
86
- hasWaitingRequest: L.hasWaitingRequest,
87
- hasScheduledPayment: z.hasScheduledPayment,
88
- isScheduledPaymentUnknown: z.isResolving,
89
- labels: _.actions,
90
- onPayBillSelect: () => we(B) || !U ? R.current?.open() : V.open()
91
- }), W = s(() => (k.data?.data ?? []).map((e) => ({
92
- value: e.id,
93
- label: [e.nominal_code, e.name].filter(Boolean).join(" — ")
94
- })), [k.data]), G = se(I), Me = e(H?.scopes, [t.UserReadOrg]), K = te({ enabled: h && Me }), q = s(() => ve(G.data?.data ?? [], K.data?.data ?? [], _.history), [
95
- G.data,
96
- K.data,
97
- _.history
98
- ]), J = me({
99
- payableId: I,
100
- approvalPolicyId: A?.approval_policy_id,
101
- enabled: h,
102
- copy: _.approvalPolicyCopy
103
- }), Ne = s(() => h && A ? _e({
104
- payable: A,
105
- lineItems: O.lineItems,
106
- glCodeOptions: W,
107
- history: q,
108
- approvalPolicy: J.view,
109
- labels: _.detail
110
- }) : void 0, [
111
- J.view,
112
- _.detail,
113
- W,
114
- q,
115
- O.lineItems,
116
- A,
117
- h
118
- ]), Y = A?.source_of_payable_data === "ocr", X = B?.name, Pe = h ? X ? _.viewTitle(X) : _.readOnlyTitle : Y && X ? _.extractedTitle(X) : _.newTitle, Fe = h && A?.created_at ? _.addedOn(ne(A.created_at.slice(0, 10))) : void 0, Z = o(() => {
119
- let e = j.isDirty || N.hasUnsavedVendorChanges || !!P.stagedFile;
120
- !h && e && !window.confirm(_.discardConfirm) || p(!1);
121
- }, [
122
- P.stagedFile,
123
- _.discardConfirm,
124
- j.isDirty,
125
- p,
126
- h,
127
- N.hasUnsavedVendorChanges
128
- ]), Ie = o((e) => {
129
- if (!F) return e ? p(!0) : Z();
130
- }, [
131
- Z,
132
- F,
133
- p
134
- ]), Q = !!Ee && !S, $ = !h && Y && !De, Le = Q || $ ? /* @__PURE__ */ d(l, { children: [Q ? /* @__PURE__ */ u(ae, {
135
- onNotADuplicate: h ? void 0 : () => C(!0),
136
- onRemoveBill: h ? void 0 : () => C(!0),
137
- testId: a.duplicateNotice
138
- }) : null, $ ? /* @__PURE__ */ u(oe, { onDismiss: () => Oe(!0) }) : null] }) : void 0;
139
- return /* @__PURE__ */ d(l, { children: [
140
- /* @__PURE__ */ u(ie, {
141
- open: f,
142
- onOpenChange: Ie,
143
- title: Pe,
144
- subtitle: Fe,
145
- notice: Le,
146
- vendor: {
147
- ...N,
148
- testId: a.vendorSection
149
- },
150
- values: j.values,
151
- errors: j.errors,
152
- onChange: j.onChange,
153
- lineItems: {
154
- items: j.lineItemRows,
155
- glCodeOptions: W,
156
- discount: j.discount,
157
- onDiscountChange: j.onDiscountChange,
158
- tax: j.tax,
159
- onTaxChange: j.onTaxChange,
160
- total: j.total,
161
- onTotalChange: j.onTotalChange,
162
- onAddLineItem: j.onAddLineItem,
163
- errors: j.lineItemErrors,
164
- testId: a.lineItems
165
- },
166
- documentPanel: /* @__PURE__ */ u(ye, {
167
- payableId: E,
168
- readOnly: h,
169
- isDocumentPending: !!E && !A?.file && (D.isLoading || A?.ocr_status === "processing"),
170
- file: A?.file ? {
171
- id: A.file.id,
172
- name: A.file.name,
173
- url: A.file.url,
174
- mimetype: A.file.mimetype
175
- } : void 0,
176
- staging: {
177
- stagedFile: P.stagedFile,
178
- onFileStaged: P.stageFile,
179
- onClearStagedFile: P.clearStagedFile,
180
- isSaving: F
181
- }
182
- }),
183
- readOnly: h,
184
- detail: h ? {
185
- view: Ne,
186
- actions: Ae,
187
- scheduledSummary: z.hasScheduledPayment && z.scheduledDateLabel ? _.scheduledSummary(z.scheduledDateLabel) : void 0,
188
- paymentInstructionsForm: M && U ? {
189
- isOpen: V.isOpen,
190
- values: V.values,
191
- errors: V.errors,
192
- isSaving: V.isSaving,
193
- onOpen: V.open,
194
- onCancel: V.close,
195
- onChange: V.onChange,
196
- onSave: V.save
197
- } : void 0,
198
- isLoading: D.isLoading || O.isResolving || k.isResolving,
199
- isError: D.isError || O.isError || k.isError
200
- } : void 0,
201
- isLineItemsLoading: O.isResolving,
202
- isSaving: F,
203
- isSavingDraft: P.isSavingDraft,
204
- isFinalizing: P.isFinalizing,
205
- onCancel: Z,
206
- onSaveDraft: P.saveDraft,
207
- onFinalize: P.finalize,
208
- testId: a.dialog
209
- }),
210
- /* @__PURE__ */ u(r, {
211
- ...je,
212
- labels: { cancelButton: _.actions.decisionDialog.cancelButton },
213
- testId: a.decisionDialog,
214
- confirmTestId: a.decisionConfirm,
215
- reasonTestId: a.decisionReason
216
- }),
217
- h && A ? /* @__PURE__ */ u(ue, {
218
- ref: R,
219
- payable: A,
220
- poweredByBankName: Te,
221
- labels: _.payBill
222
- }) : null
223
- ] });
224
- }
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
+ duplicateNotice: "bill-pay-bill-create-duplicate-notice",
8
+ decisionDialog: "bill-pay-bill-decision-dialog",
9
+ decisionConfirm: "bill-pay-bill-decision-confirm",
10
+ decisionReason: "bill-pay-bill-decision-reason",
11
+ deleteDraftDialog: "bill-pay-bill-delete-draft-dialog",
12
+ deleteDraftConfirm: "bill-pay-bill-delete-draft-confirm"
13
+ };
225
14
  //#endregion
226
- export { f as BillCreateDialog, f as default };
15
+ export { e as billCreateTestIds };