@tesouro/embedded-components-react 0.3.22 → 0.3.24

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 (94) 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/data-access/dist/index10.js +10 -10
  4. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index.js +15 -15
  5. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index10.js +31 -32
  6. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index11.js +42 -1
  7. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index12.js +158 -43
  8. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index13.js +33 -4
  9. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index14.js +1 -16
  10. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index15.js +45 -12
  11. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index16.js +4 -64
  12. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index17.js +13 -26
  13. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index18.js +14 -62
  14. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index19.js +56 -123
  15. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index2.js +18 -3
  16. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index20.js +15 -10
  17. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index21.js +61 -40
  18. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index22.js +130 -50
  19. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index23.js +20 -4
  20. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index24.js +38 -69
  21. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index25.js +48 -46
  22. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index26.js +5 -93
  23. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index27.js +71 -34
  24. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index28.js +48 -139
  25. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index29.js +91 -66
  26. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index3.js +22 -5
  27. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index30.js +34 -22
  28. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index31.js +146 -210
  29. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index32.js +72 -209
  30. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index33.js +21 -103
  31. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index34.js +209 -12
  32. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index35.js +211 -44
  33. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index36.js +104 -30
  34. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index37.js +12 -165
  35. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index38.js +47 -35
  36. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index39.js +29 -99
  37. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index4.js +64 -5
  38. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index40.js +181 -12
  39. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index41.js +34 -243
  40. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index42.js +104 -4
  41. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index43.js +12 -27
  42. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index44.js +267 -81
  43. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index45.js +4 -145
  44. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index46.js +33 -3
  45. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index47.js +82 -2
  46. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index48.js +155 -37
  47. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index49.js +2 -0
  48. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index5.js +2 -6
  49. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index50.js +2 -6
  50. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index51.js +43 -9
  51. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index52.js +1 -94
  52. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index53.js +8 -3
  53. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index54.js +7 -5
  54. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index55.js +85 -13
  55. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index56.js +3 -59
  56. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index57.js +9 -3
  57. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index58.js +19 -120
  58. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index59.js +56 -8
  59. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index6.js +3 -32
  60. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index60.js +3 -46
  61. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index61.js +116 -15
  62. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index62.js +8 -28
  63. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index63.js +43 -83
  64. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index64.js +19 -47
  65. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index65.js +27 -249
  66. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index66.js +82 -109
  67. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index67.js +47 -206
  68. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index68.js +253 -4
  69. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index69.js +111 -6
  70. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index7.js +6 -39
  71. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index70.js +197 -102
  72. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index71.js +3 -0
  73. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index72.js +6 -23
  74. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index73.js +114 -0
  75. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index74.js +1 -0
  76. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index75.js +25 -0
  77. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index8.js +5 -24
  78. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index9.js +3 -162
  79. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index.js +9 -6
  80. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index82.js +10 -11
  81. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index83.js +123 -8
  82. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index84.js +2 -170
  83. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index85.js +18 -2
  84. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index86.js +7 -11
  85. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index87.js +163 -82
  86. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index88.js +1 -1
  87. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index89.js +14 -0
  88. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index90.js +108 -0
  89. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index91.js +2 -0
  90. package/dist/libs/tesouro-embedded-components-react/shared/data-access/dist/index.js +2 -2
  91. package/dist/libs/tesouro-embedded-components-react/shared/data-access/dist/lib/rest/sdk.gen.js +27 -27
  92. package/dist/libs/tesouro-embedded-components-react/shared/feature/dist/lib/analytics/build-info.js +1 -1
  93. package/dist/libs/tesouro-embedded-components-react/widget-suite/feature/dist/index7.js +1 -1
  94. package/package.json +1 -1
@@ -1,15 +1,184 @@
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, useDeletePayableFileMutation as r, useSubmitPayableForApprovalMutation as i, useUpdatePayableMutation as a, useValidatePayableMutation as o } from "../../data-access/dist/index10.js";
9
+ import "../../data-access/dist/index.js";
10
+ import { BILL_CREATE_MESSAGE_LABELS_EN as s } from "./index31.js";
11
+ import { encodeFileToBase64 as c } from "./index37.js";
12
+ import { mapBillFormToPayload as l, mapLineItemsToPayload as u } from "./index38.js";
13
+ import { validateBillCompleteness as d, validateBillTotals as f, validateLineItems as p } from "./index39.js";
14
+ import { useCallback as m, useRef as h, useState as g } from "react";
1
15
  //#region ../../libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index40.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
- deleteDraftDialog: "bill-pay-bill-delete-draft-dialog",
12
- deleteDraftConfirm: "bill-pay-bill-delete-draft-confirm"
16
+ var _ = {
17
+ document_id: "invoiceNumber",
18
+ issued_at: "invoiceDate",
19
+ due_date: "dueDate",
20
+ counterpart_id: "vendor"
13
21
  };
22
+ function v(e) {
23
+ return e.type === "type_error.none.not_allowed" || e.msg === "none is not an allowed value";
24
+ }
25
+ function y(e, t = s) {
26
+ let n = {}, r = [];
27
+ for (let i of e) {
28
+ let e = i.loc[0] ?? t.unknownValidationField, a = _[e], o = v(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 b(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;
41
+ }
42
+ function x({ payableId: _, form: v, counterpartId: x, clearCounterpart: S, prepareVendorForSave: C, onSaved: w, onPayableCreated: T, onDraftSaved: E, onFinalized: D, labels: O }) {
43
+ let k = {
44
+ ...s,
45
+ ...O
46
+ }, [A, j] = g(), M = _ ?? A, [N, P] = g(), F = m(() => P(void 0), []), [I, L] = g(!1), R = m(() => L(!0), []), [z, B] = g(), V = h(!1), H = n(), U = r(), W = a(), G = t(), K = o(), q = i(), J = m(() => {
47
+ let t = p(v.lineItems, k), n = f(v.discount, v.tax, v.totalOverride, k);
48
+ return v.setLineItemErrors(t), !t && !n || (t ? (v.setErrors(void 0), e.error(k.lineItemsNeedAttention)) : v.setErrors(n), !1);
49
+ }, [v, k]), Y = m(async (e) => {
50
+ let t = !M && N ? {
51
+ base64EncodedFile: await c(N),
52
+ fileName: N.name
53
+ } : void 0, n = l({
54
+ values: v.values,
55
+ counterpartId: x,
56
+ clearCounterpart: S,
57
+ counterpartBankAccountId: e,
58
+ editedTotals: v.isTotalsDirty ? {
59
+ discount: v.discount,
60
+ tax: v.tax,
61
+ total: v.totalOverride
62
+ } : void 0,
63
+ document: t
64
+ }), r = M;
65
+ if (r ? await W.mutateAsync({
66
+ path: { payable_id: r },
67
+ body: n
68
+ }) : (r = (await H.mutateAsync({ body: n }))?.id, r && (j(r), T?.(r), t && P(void 0))), !r) throw Error("Payable was created without an id");
69
+ if (I) {
70
+ try {
71
+ await U.mutateAsync({ path: { payable_id: r } });
72
+ } catch {}
73
+ L(!1);
74
+ }
75
+ return await G.mutateAsync({
76
+ path: { payable_id: r },
77
+ body: { data: u(v.lineItems) }
78
+ }), r;
79
+ }, [
80
+ x,
81
+ S,
82
+ H,
83
+ U,
84
+ I,
85
+ v.discount,
86
+ v.isTotalsDirty,
87
+ v.lineItems,
88
+ v.tax,
89
+ v.totalOverride,
90
+ v.values,
91
+ T,
92
+ M,
93
+ G,
94
+ N,
95
+ W
96
+ ]), X = m(async () => {
97
+ M && (await U.mutateAsync({ path: { payable_id: M } }), L(!1));
98
+ }, [U, M]);
99
+ return {
100
+ saveDraft: m(async () => {
101
+ if (!V.current && J()) {
102
+ V.current = !0, B("draft");
103
+ try {
104
+ let t = await C?.();
105
+ if (t && !t.ok) return;
106
+ let n = await Y(t?.counterpartBankAccountId);
107
+ v.setErrors(void 0), w?.(n), E?.(n), e.success(k.draftSaved);
108
+ } catch {
109
+ v.setErrors({ form: k.saveFailed });
110
+ } finally {
111
+ B(void 0), V.current = !1;
112
+ }
113
+ }
114
+ }, [
115
+ v,
116
+ J,
117
+ k.draftSaved,
118
+ k.saveFailed,
119
+ E,
120
+ w,
121
+ C,
122
+ Y
123
+ ]),
124
+ finalize: m(async () => {
125
+ if (V.current) return;
126
+ let t = p(v.lineItems, k), n = f(v.discount, v.tax, v.totalOverride, k), { formErrors: r, lineItemErrors: i } = d(v.values, x, v.lineItems, k), a = b(i, t);
127
+ v.setLineItemErrors(a);
128
+ let o = {
129
+ ...r,
130
+ ...n
131
+ };
132
+ if (v.setErrors(Object.keys(o).length ? o : void 0), t && e.error(k.lineItemsNeedAttention), !(a || Object.keys(o).length)) {
133
+ V.current = !0, B("finalize");
134
+ try {
135
+ let t;
136
+ try {
137
+ let e = await C?.();
138
+ if (e && !e.ok) return;
139
+ t = await Y(e?.counterpartBankAccountId);
140
+ } catch {
141
+ v.setErrors({ form: k.saveFailed });
142
+ return;
143
+ }
144
+ w?.(t);
145
+ try {
146
+ let n = await K.mutateAsync({ path: { payable_id: t } });
147
+ if (n.validation_errors.length) {
148
+ v.setErrors(y(n.validation_errors, k));
149
+ return;
150
+ }
151
+ await q.mutateAsync({ path: { payable_id: t } }), v.setErrors(void 0), D?.(t), e.success(k.billFinalized);
152
+ } catch {
153
+ v.setErrors({ form: k.finalizeFailed });
154
+ }
155
+ } finally {
156
+ B(void 0), V.current = !1;
157
+ }
158
+ }
159
+ }, [
160
+ x,
161
+ v,
162
+ k,
163
+ D,
164
+ w,
165
+ C,
166
+ Y,
167
+ q,
168
+ K
169
+ ]),
170
+ payableId: M,
171
+ isSavingDraft: z === "draft",
172
+ isFinalizing: z === "finalize",
173
+ stagedFile: N,
174
+ stageFile: P,
175
+ clearStagedFile: F,
176
+ isFileDeletionPending: I,
177
+ requestFileDeletion: R,
178
+ detachFileNow: X,
179
+ isDeletingFile: U.isPending,
180
+ hasFileDeletionFailed: U.isError
181
+ };
182
+ }
14
183
  //#endregion
15
- export { e as billCreateTestIds };
184
+ export { y as mapValidationErrorsToForm, x as useBillCreateController };
@@ -1,247 +1,38 @@
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/index41.js";
15
- import { BillDecisionDialog as n } from "../../ui/dist/index47.js";
16
- import { BillDuplicateNotice as oe } from "../../ui/dist/index57.js";
17
- import { ExtractionNotice as se } from "../../ui/dist/index74.js";
18
- import "../../ui/dist/index.js";
19
- import { usePayableHistoryQuery as ce } from "../../data-access/dist/index6.js";
20
- import { useAllPayableLineItemsQuery as le } from "../../data-access/dist/index7.js";
21
- import { usePayableQuery as ue } from "../../data-access/dist/index13.js";
22
- import "../../data-access/dist/index.js";
23
- import { PayBillFlow as de } from "./index10.js";
24
- import "./index11.js";
25
- import { mergeBillCreateScreenCopy as fe } from "./index28.js";
26
- import { useBillCreateController as pe } from "./index37.js";
27
- import { useBillForm as me } from "./index39.js";
28
- import { useApprovalPolicyCardView as he } from "./index16.js";
29
- import { useCurrentApprovalRequestId as ge } from "./index17.js";
30
- import { usePayableDetailActions as _e } from "./index19.js";
31
- import { useScheduledPayment as r } from "./index20.js";
32
- import { useDraftDelete as ve } from "./index21.js";
33
- import { buildBillDetailView as ye } from "./index24.js";
34
- import { buildBillHistory as be } from "./index25.js";
35
- import { SourceDocumentContainer as xe } from "./index29.js";
36
- import { useVendorSectionProps as Se } from "./index32.js";
37
- import { usePaymentInstructionsForm as Ce } from "./index33.js";
38
- import { billCreateTestIds as i } from "./index40.js";
39
- import { useCallback as a, useEffect as we, useMemo as o, useRef as Te, useState as s } from "react";
40
- import { Fragment as c, jsx as l, jsxs as u } from "react/jsx-runtime";
41
1
  //#region ../../libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index41.js
42
- function Ee(e) {
43
- return !!(e?.bank_account?.account_holder_name && e.bank_account.routing_number && e.bank_account.account_number);
2
+ function e() {
3
+ return {
4
+ id: crypto.randomUUID(),
5
+ description: "",
6
+ glCode: "",
7
+ quantity: "1",
8
+ price: "",
9
+ amount: ""
10
+ };
44
11
  }
45
- function d({ open: d, onOpenChange: f, payableId: p, readOnly: m = !1, copy: h, poweredByBankName: De, isPossibleDuplicate: Oe }) {
46
- let g = o(() => fe(h), [h]), [_, v] = s(), [y, b] = s(!1), [ke, x] = s(!1), [Ae, S] = s(!1), [C, w] = s(), T = p ?? C, E = ue(T, { pollWhileOcrProcessing: !0 }), D = le(T), O = ee(), k = E.data, A = me({
47
- payable: k,
48
- lineItems: D.lineItems
49
- }), j = k?.counterpart_id;
50
- we(() => {
51
- y || j && (v(j), b(!0));
52
- }, [y, j]);
53
- let je = a((e) => {
54
- b(!0), v(e);
55
- }, []), M = Se({
56
- payableId: m ? void 0 : T,
57
- counterpartId: m ? void 0 : _,
58
- payableCounterpartId: j,
59
- onCounterpartChange: je,
60
- requiredError: A.errors?.vendor,
61
- payableCounterpartBankAccountId: k?.counterpart_bank_account_id ?? void 0,
62
- extractedVendor: k?.counterpart_raw_data ?? void 0
63
- }), N = pe({
64
- payableId: p,
65
- form: A,
66
- counterpartId: _,
67
- clearCounterpart: !!(T && y) && !_,
68
- prepareVendorForSave: M.savePaymentInstructions,
69
- onPayableCreated: w,
70
- onSaved: w,
71
- onDraftSaved: () => f(!1),
72
- onFinalized: () => f(!1)
73
- }), P = !!(N.isSavingDraft || N.isFinalizing), F = m ? T : void 0, I = ge({
74
- payableId: F,
75
- status: k?.status
76
- }), L = Te(null), R = r({
77
- payableId: T,
78
- scheduledPaymentDate: k?.scheduled_payment_date,
79
- enabled: m
80
- }), z = ie(k), B = Ce({
81
- payableId: F,
82
- counterpartId: m ? j : void 0,
83
- saveErrorMessage: g.detail.paymentInstructionsSaveError,
84
- linkErrorMessage: g.detail.paymentInstructionsLinkError
85
- }), { initResponse: V } = re(), H = e(V?.scopes, [t.CounterpartWriteOrg]) && e(V?.scopes, [t.PayableWriteOrg]), U = he({
86
- payableId: F,
87
- approvalPolicyId: k?.approval_policy_id,
88
- enabled: m,
89
- copy: g.approvalPolicyCopy
90
- }), { actions: Me, decisionDialog: Ne } = _e({
91
- payableId: F,
92
- status: k?.status,
93
- currentApprovalRequestId: I.id,
94
- isPolicyApprover: I.isPolicyApprover,
95
- hasWaitingRequest: I.hasWaitingRequest,
96
- hasScheduledPayment: R.hasScheduledPayment,
97
- scheduledPaymentRecordId: R.scheduledPaymentRecordId,
98
- isScheduledPaymentUnknown: R.isResolving,
99
- pendingApprovers: U.pendingApprovers,
100
- labels: g.actions,
101
- onPayBillSelect: () => Ee(z) || !H ? L.current?.open() : B.open()
102
- }), W = ve({
103
- payableId: T,
104
- status: k?.status,
105
- enabled: !m,
106
- labels: g.deleteDraft,
107
- onDeleted: () => f(!1)
108
- }), G = o(() => (O.data?.data ?? []).map((e) => ({
109
- value: e.id,
110
- label: [e.nominal_code, e.name].filter(Boolean).join(" — ")
111
- })), [O.data]), K = ce(F), Pe = e(V?.scopes, [t.UserReadOrg]), q = te({ enabled: m && Pe }), J = o(() => be(K.data?.data ?? [], q.data?.data ?? [], g.history), [
112
- K.data,
113
- q.data,
114
- g.history
115
- ]), Fe = o(() => m && k ? ye({
116
- payable: k,
117
- lineItems: D.lineItems,
118
- glCodeOptions: G,
119
- history: J,
120
- approvalPolicy: U.view,
121
- labels: g.detail,
122
- hasScheduledPayment: R.hasScheduledPayment
123
- }) : void 0, [
124
- R.hasScheduledPayment,
125
- U.view,
126
- g.detail,
127
- G,
128
- J,
129
- D.lineItems,
130
- k,
131
- m
132
- ]), Y = k?.source_of_payable_data === "ocr", X = z?.name, Ie = m ? X ? g.viewTitle(X) : g.readOnlyTitle : Y && X ? g.extractedTitle(X) : g.newTitle, Le = m && k?.created_at ? g.addedOn(ne(k.created_at.slice(0, 10))) : void 0, Z = a(() => {
133
- let e = A.isDirty || M.hasUnsavedVendorChanges || !!N.stagedFile;
134
- !m && e && !window.confirm(g.discardConfirm) || f(!1);
135
- }, [
136
- N.stagedFile,
137
- g.discardConfirm,
138
- A.isDirty,
139
- f,
140
- m,
141
- M.hasUnsavedVendorChanges
142
- ]), Re = a((e) => {
143
- if (!P) return e ? f(!0) : Z();
144
- }, [
145
- Z,
146
- P,
147
- f
148
- ]), Q = !!Oe && !Ae, $ = !m && Y && !ke, ze = Q || $ ? /* @__PURE__ */ u(c, { children: [Q ? /* @__PURE__ */ l(oe, {
149
- onNotADuplicate: m ? void 0 : () => S(!0),
150
- onRemoveBill: m ? void 0 : () => S(!0),
151
- testId: i.duplicateNotice
152
- }) : null, $ ? /* @__PURE__ */ l(se, { onDismiss: () => x(!0) }) : null] }) : void 0;
153
- return /* @__PURE__ */ u(c, { children: [
154
- /* @__PURE__ */ l(ae, {
155
- open: d,
156
- onOpenChange: Re,
157
- title: Ie,
158
- subtitle: Le,
159
- notice: ze,
160
- vendor: {
161
- ...M,
162
- testId: i.vendorSection
163
- },
164
- values: A.values,
165
- errors: A.errors,
166
- onChange: A.onChange,
167
- lineItems: {
168
- items: A.lineItemRows,
169
- glCodeOptions: G,
170
- discount: A.discount,
171
- onDiscountChange: A.onDiscountChange,
172
- tax: A.tax,
173
- onTaxChange: A.onTaxChange,
174
- total: A.total,
175
- onTotalChange: A.onTotalChange,
176
- onAddLineItem: A.onAddLineItem,
177
- errors: A.lineItemErrors,
178
- testId: i.lineItems
179
- },
180
- documentPanel: /* @__PURE__ */ l(xe, {
181
- payableId: T,
182
- readOnly: m,
183
- isDocumentPending: !!T && !k?.file && (E.isLoading || k?.ocr_status === "processing"),
184
- file: k?.file ? {
185
- id: k.file.id,
186
- name: k.file.name,
187
- url: k.file.url,
188
- mimetype: k.file.mimetype
189
- } : void 0,
190
- staging: {
191
- stagedFile: N.stagedFile,
192
- onFileStaged: N.stageFile,
193
- onClearStagedFile: N.clearStagedFile,
194
- isSaving: P
195
- }
196
- }),
197
- menuItems: W.menuItems,
198
- readOnly: m,
199
- detail: m ? {
200
- view: Fe,
201
- actions: Me,
202
- scheduledSummary: R.hasScheduledPayment && R.scheduledDateLabel ? g.scheduledSummary(R.scheduledDateLabel) : void 0,
203
- paymentInstructionsForm: j && H ? {
204
- isOpen: B.isOpen,
205
- values: B.values,
206
- errors: B.errors,
207
- isSaving: B.isSaving,
208
- onOpen: B.open,
209
- onCancel: B.close,
210
- onChange: B.onChange,
211
- onSave: B.save
212
- } : void 0,
213
- isLoading: E.isLoading || D.isResolving || O.isResolving,
214
- isError: E.isError || D.isError || O.isError
215
- } : void 0,
216
- isLineItemsLoading: D.isResolving,
217
- isSaving: P,
218
- isSavingDraft: N.isSavingDraft,
219
- isFinalizing: N.isFinalizing,
220
- onCancel: Z,
221
- onSaveDraft: N.saveDraft,
222
- onFinalize: N.finalize,
223
- testId: i.dialog
224
- }),
225
- /* @__PURE__ */ l(n, {
226
- ...Ne,
227
- labels: { cancelButton: g.actions.decisionDialog.cancelButton },
228
- testId: i.decisionDialog,
229
- confirmTestId: i.decisionConfirm,
230
- reasonTestId: i.decisionReason
231
- }),
232
- /* @__PURE__ */ l(n, {
233
- ...W.dialog,
234
- labels: { cancelButton: g.actions.decisionDialog.cancelButton },
235
- testId: i.deleteDraftDialog,
236
- confirmTestId: i.deleteDraftConfirm
237
- }),
238
- m && k ? /* @__PURE__ */ l(de, {
239
- ref: L,
240
- payable: k,
241
- poweredByBankName: De,
242
- labels: g.payBill
243
- }) : null
244
- ] });
12
+ function t(e) {
13
+ return typeof e == "number" ? (e / 100).toFixed(2) : "";
14
+ }
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
+ }));
29
+ 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)
35
+ };
245
36
  }
246
37
  //#endregion
247
- export { d as BillCreateDialog, d as default };
38
+ export { e as emptyLineItem, n as mapPayableToBillForm };
@@ -1,4 +1,104 @@
1
- import "./index28.js";
2
- import "./index37.js";
3
- import "./index39.js";
4
- import "./index41.js";
1
+ "use client";
2
+ "use client";
3
+ "use client";
4
+ "use client";
5
+ import { calculateTotal as e, displayLineAmount as t, parseMoneyToMinorUnits as n } from "./index38.js";
6
+ import { emptyLineItem as r, mapPayableToBillForm as i } from "./index41.js";
7
+ import { useCallback as a, useEffect as o, useMemo as s, useState as c } from "react";
8
+ //#region ../../libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index42.js
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
+ }
103
+ //#endregion
104
+ export { u as useBillForm };
@@ -1,30 +1,15 @@
1
- import { BILL_DETAILS_SHEET_LABELS_EN as e } from "../../ui/dist/index52.js";
2
- import "../../ui/dist/index.js";
3
- import { APPROVAL_POLICY_RULE_COPY_EN as t } from "./index12.js";
4
- import { BILL_DETAIL_ACTIONS_LABELS_EN as n, SCHEDULED_SUMMARY_LABEL_EN as r } from "./index26.js";
5
1
  //#region ../../libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index43.js
6
- var i = {
7
- subtitle: "Accounts payable",
8
- vendorRow: "Vendor",
9
- bankAccountRow: "ACH bank account",
10
- bankAccountValue: (e) => `Account ending in ${e}`,
11
- invoiceNumberRow: "Number",
12
- issueDateRow: "Issue date",
13
- dueDateRow: "Due date",
14
- poNumberRow: "PO number",
15
- notProvided: "Not provided",
16
- glCodeMissing: "GL code not specified",
17
- quantityValue: (e, t) => `${e} x ${t}`,
18
- subtotalRow: "Subtotal",
19
- discountsRow: "Discounts",
20
- taxRow: "Tax",
21
- totalRow: "Total",
22
- actionError: n.actionError,
23
- actionSuccess: n.actionSuccess,
24
- scheduledSummary: r,
25
- sheet: e,
26
- decisionDialog: n.decisionDialog,
27
- approvalPolicyCopy: t
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"
28
13
  };
29
14
  //#endregion
30
- export { i as BILL_DETAILS_LABELS_EN };
15
+ export { e as billCreateTestIds };