@tesouro/embedded-components-react 0.5.75 → 0.5.77

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 (88) hide show
  1. package/dist/index.css +0 -8
  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/feature/dist/index.js +8 -8
  5. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index45.js +140 -7
  6. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index46.js +46 -140
  7. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index47.js +114 -47
  8. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index48.js +182 -111
  9. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index49.js +75 -164
  10. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index50.js +31 -76
  11. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index51.js +89 -23
  12. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index52.js +405 -65
  13. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index53.js +12 -381
  14. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index54.js +84 -12
  15. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index55.js +54 -79
  16. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index56.js +223 -54
  17. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index57.js +37 -223
  18. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index58.js +245 -37
  19. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index59.js +21 -252
  20. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index60.js +575 -21
  21. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index61.js +4 -572
  22. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index62.js +44 -4
  23. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index63.js +247 -38
  24. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index64.js +3 -234
  25. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index65.js +4 -3
  26. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index66.js +44 -2
  27. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index67.js +1 -46
  28. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index68.js +8 -1
  29. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index69.js +11 -6
  30. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index70.js +127 -11
  31. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index71.js +3 -129
  32. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index72.js +127 -3
  33. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index73.js +8 -124
  34. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index74.js +7 -8
  35. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index75.js +47 -8
  36. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index76.js +18 -44
  37. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index77.js +28 -20
  38. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index78.js +82 -27
  39. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index79.js +47 -83
  40. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index80.js +250 -47
  41. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index81.js +123 -241
  42. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index82.js +211 -126
  43. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index83.js +3 -219
  44. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index84.js +7 -4
  45. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index85.js +98 -5
  46. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index86.js +1 -100
  47. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index87.js +26 -0
  48. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index.js +10 -10
  49. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index30.js +2 -72
  50. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index31.js +12 -269
  51. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index33.js +2 -19
  52. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index34.js +16 -50
  53. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index36.js +97 -15
  54. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index37.js +76 -47
  55. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index38.js +277 -2
  56. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index39.js +2 -35
  57. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index40.js +16 -369
  58. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index41.js +56 -2
  59. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index42.js +2 -23
  60. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index43.js +15 -93
  61. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index44.js +50 -2
  62. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index45.js +1 -31
  63. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index46.js +32 -49
  64. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index47.js +374 -2
  65. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index48.js +1 -55
  66. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index49.js +20 -10
  67. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index50.js +87 -188
  68. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index51.js +1 -1
  69. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index52.js +30 -2
  70. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index53.js +48 -37
  71. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index55.js +47 -10
  72. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index56.js +10 -85
  73. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index57.js +197 -2
  74. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index58.js +2 -4
  75. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index59.js +2 -14
  76. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index60.js +41 -2
  77. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index61.js +2 -4
  78. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index62.js +14 -17
  79. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index63.js +88 -2
  80. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index64.js +1 -94
  81. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index65.js +167 -161
  82. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index82.js +5 -5
  83. package/dist/libs/tesouro-embedded-components-react/shared/feature/dist/lib/analytics/build-info.js +1 -1
  84. package/dist/libs/tesouro-embedded-components-react/shared/util/dist/lib/auditHistory/buildPayableAuditHistory.js +5 -1
  85. package/dist/libs/tesouro-embedded-components-react/widget-suite/feature/dist/index8.js +1 -1
  86. package/dist/packages/shared-ui-shadcn/dist/index.js +1391 -1369
  87. package/package.json +1 -1
  88. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index88.js +0 -27
@@ -1,23 +1,577 @@
1
+ "use client";
2
+ "use client";
3
+ "use client";
4
+ "use client";
5
+ import { toast as e } from "../../../../../packages/shared-ui-shadcn/dist/index.js";
6
+ import { hasAnyScope as t } from "../../../shared/data-access/dist/lib/hasAnyScope.js";
7
+ import { Scope as n } from "../../../shared/data-access/dist/lib/scopes.js";
8
+ import { useAllLedgerAccountsQuery as r } from "../../../shared/data-access/dist/lib/reference-data/useLedgerAccountsQuery.js";
9
+ import "../../../shared/data-access/dist/index.js";
10
+ import "../../../shared/ui/dist/index.js";
11
+ import { formatCalendarDate as ee } from "../../../shared/util/dist/lib/formatCalendarDate.js";
12
+ import { buildPayableAuditHistory as te, hasUnattributedAuditRows as ne } from "../../../shared/util/dist/lib/auditHistory/buildPayableAuditHistory.js";
13
+ import { useWidgetConfig as re } from "../../../shared/feature/dist/lib/WidgetProvider/hooks.js";
14
+ import { useOrganizationUserNames as ie } from "../../../shared/feature/dist/lib/user/useOrganizationUserNames.js";
15
+ import "../../../shared/feature/dist/index.js";
16
+ import { usePayableApprovalRequestsQuery as ae } from "../../data-access/dist/index8.js";
17
+ import { usePayableHistoryQuery as oe } from "../../data-access/dist/index9.js";
18
+ import { useAllPayableLineItemsQuery as se } from "../../data-access/dist/index10.js";
19
+ import { useUpdatePayableMutation as ce } from "../../data-access/dist/index13.js";
20
+ import { usePayableQuery as le } from "../../data-access/dist/index17.js";
21
+ import "../../data-access/dist/index.js";
22
+ import { hasUnpaidBalance as ue } from "./index7.js";
23
+ import { resolveVendor as de } from "./index8.js";
24
+ import { BillCreateScreen as fe } from "../../ui/dist/index57.js";
25
+ import { BillDecisionDialog as pe } from "../../ui/dist/index63.js";
26
+ import { DiscardChangesDialog as me } from "../../ui/dist/index67.js";
27
+ import { BillDuplicateNotice as he } from "../../ui/dist/index72.js";
28
+ import { BillRejectedBanner as ge } from "../../ui/dist/index75.js";
29
+ import { ExtractionNotice as _e } from "../../ui/dist/index93.js";
30
+ import { MarkAsPaidDialog as ve } from "../../ui/dist/index102.js";
31
+ import { UnsavedBillDialog as ye } from "../../ui/dist/index112.js";
32
+ import "../../ui/dist/index.js";
33
+ import { usePayableDuplicateReview as be } from "./index13.js";
34
+ import "./index14.js";
35
+ import { isEditablePayableStatus as xe } from "./index19.js";
36
+ import { canOverrideApprovalPolicy as Se, canReadCounterpartBankAccounts as Ce } from "./index20.js";
37
+ import { resolveAmountDueMinorUnits as we } from "./index21.js";
38
+ import { usePayableAchInstructions as Te } from "../../../shared/counterpart-management/feature/dist/lib/usePayableAchInstructions.js";
39
+ import "../../../shared/counterpart-management/feature/dist/index.js";
40
+ import { PayBillFlow as Ee } from "./index27.js";
41
+ import "./index28.js";
42
+ import { useMarkAsPaidFlow as De } from "./index17.js";
43
+ import "./index18.js";
44
+ import { BILL_CREATE_MESSAGE_LABELS_EN as Oe, mergeBillCreateScreenCopy as ke } from "./index48.js";
45
+ import { useBillCreateController as Ae } from "./index56.js";
46
+ import { useBillForm as je } from "./index58.js";
47
+ import { buildPaymentHistory as Me } from "./index3.js";
48
+ import { currentApprovalRound as Ne } from "./index4.js";
49
+ import { usePayableApprovalRoundStart as Pe } from "./index32.js";
50
+ import { useApprovalPolicyCardView as Fe } from "./index33.js";
51
+ import { resolveBillRejectionNotice as Ie } from "./index34.js";
52
+ import { useCurrentApprovalRequestId as Le } from "./index35.js";
53
+ import { usePayableDetailActions as Re } from "./index36.js";
54
+ import { useScheduledPayment as ze } from "./index37.js";
55
+ import { useDraftDelete as Be } from "./index38.js";
56
+ import { buildBillDetailView as Ve } from "./index43.js";
57
+ import { resolveEditorDismissal as He } from "./index44.js";
58
+ import { SourceDocumentContainer as Ue } from "./index49.js";
59
+ import { useVendorSectionProps as We } from "./index52.js";
60
+ import { billCreateTestIds as i } from "./index59.js";
61
+ import { cloneElement as Ge, isValidElement as Ke, useCallback as a, useEffect as qe, useMemo as o, useRef as Je, useState as s } from "react";
62
+ import { Fragment as Ye, jsx as c, jsxs as Xe } from "react/jsx-runtime";
63
+ import { Trash2Icon as Ze } from "lucide-react";
1
64
  //#region ../../libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index60.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
- duplicateRemoveDialog: "bill-pay-bill-create-duplicate-remove-dialog",
9
- duplicateRemoveConfirm: "bill-pay-bill-create-duplicate-remove-confirm",
10
- decisionDialog: "bill-pay-bill-decision-dialog",
11
- decisionConfirm: "bill-pay-bill-decision-confirm",
12
- decisionReason: "bill-pay-bill-decision-reason",
13
- deleteDraftDialog: "bill-pay-bill-delete-draft-dialog",
14
- deleteDraftConfirm: "bill-pay-bill-delete-draft-confirm",
15
- unsavedDialog: "bill-pay-bill-unsaved-dialog",
16
- unsavedSaveDraft: "bill-pay-bill-unsaved-save-draft",
17
- unsavedDiscard: "bill-pay-bill-unsaved-discard",
18
- unsavedClose: "bill-pay-bill-unsaved-close",
19
- discardDialog: "bill-pay-bill-discard-dialog",
20
- discardConfirm: "bill-pay-bill-discard-confirm"
21
- };
65
+ function Qe(e) {
66
+ let t = [...new Set(e)];
67
+ return t.length > 0 ? t : void 0;
68
+ }
69
+ function l({ open: l, onOpenChange: u, payableId: $e, readOnly: d = !1, copy: et, onCollapse: f, onEdit: tt, poweredByBankName: nt }) {
70
+ let p = o(() => ke(et), [et]), [m, rt] = s(), [h, it] = s(!1), [at, ot] = s(!1), [g, _] = s(!1), [st, v] = s(), ct = a((e) => {
71
+ v(() => e);
72
+ }, []), [lt, ut] = s(), y = $e ?? lt, b = le(y, { pollWhileOcrProcessing: !0 }), x = se(y), { initResponse: S } = re(), dt = !!S, ft = t(S?.scopes, [n.AccountingConfigReadOrg]), C = r({ enabled: ft }), w = b.data, T = !y || !!w, E = !d && T && !!y && w?.status !== "draft", pt = !d && !!w && !xe(w?.status), D = d || pt, O = je({
73
+ payable: w,
74
+ lineItems: x.lineItems
75
+ }), k = w?.counterpart_id;
76
+ qe(() => {
77
+ h || k && (rt(k), it(!0));
78
+ }, [h, k]);
79
+ let mt = a((e) => {
80
+ it(!0), rt(e);
81
+ }, []), A = ze({
82
+ payableId: y,
83
+ scheduledPaymentDate: w?.scheduled_payment_date,
84
+ enabled: d || E
85
+ }), j = Ce(S?.scopes), ht = t(S?.scopes, [n.PayableWriteOrg]), M = t(S?.scopes, [n.CounterpartWriteOrg]) && ht, N = M && ue(w?.status) && !A.hasScheduledPayment && !A.isResolving, gt = N && j, _t = N || M && w?.status === "rejected", vt = !d && T && (!y || w?.status === "draft") && !A.hasScheduledPayment && !A.isResolving, P = We({
86
+ payableId: y,
87
+ counterpartId: d ? k : m,
88
+ payableCounterpartId: k,
89
+ isVendorKnown: d ? !!w : T,
90
+ onCounterpartChange: mt,
91
+ requiredError: O.errors?.vendor,
92
+ payableCounterpartBankAccountId: w?.counterpart_bank_account_id ?? void 0,
93
+ extractedVendor: w?.counterpart_raw_data ?? void 0,
94
+ readOnly: d,
95
+ canEditVendor: !d || gt,
96
+ canEditPaymentInstructions: !d || N,
97
+ canAddPaymentInstructions: !d || _t,
98
+ confirmDiscard: ct
99
+ }), F = P.activePayToOperation === "missingInstructions" ? vt || _t : P.activePayToOperation === "existingInstructions" ? vt || N : P.activePayToOperation === "vendor" && d ? gt : !1, yt = !!(y && h) && !m, I = b.refetch, bt = a(async () => {
100
+ let { data: e } = await I();
101
+ return e?.status ?? void 0;
102
+ }, [I]), xt = ce(), [L, St] = s(!1), R = Je(void 0), Ct = a(async () => {
103
+ if (R.current) return R.current;
104
+ let t = (async () => {
105
+ if (F) {
106
+ St(!0);
107
+ try {
108
+ let t;
109
+ try {
110
+ t = await P.prepareVendorForSave({ closeOnSuccess: !1 });
111
+ } catch {
112
+ e.error(p.detail.paymentInstructionsSaveError);
113
+ return;
114
+ }
115
+ if (!t.ok) return;
116
+ if (!y) {
117
+ P.finalizePayToSave();
118
+ return;
119
+ }
120
+ let n = t.counterpartId && t.counterpartId !== w?.counterpart_id ? t.counterpartId : void 0, r = t.counterpartBankAccountId && t.counterpartBankAccountId !== w?.counterpart_bank_account_id ? t.counterpartBankAccountId : void 0;
121
+ if (n || r) {
122
+ let t = {
123
+ path: { payable_id: y },
124
+ body: {
125
+ ...n ? { counterpart_id: n } : {},
126
+ ...r ? { counterpart_bank_account_id: r } : {}
127
+ }
128
+ };
129
+ try {
130
+ await xt.mutateAsync(t);
131
+ } catch {
132
+ try {
133
+ await xt.mutateAsync(t);
134
+ } catch {
135
+ e.error(p.detail.paymentInstructionsLinkError);
136
+ return;
137
+ }
138
+ }
139
+ P.finalizePayToSave();
140
+ return;
141
+ }
142
+ P.finalizePayToSave(), await I();
143
+ } finally {
144
+ St(!1);
145
+ }
146
+ }
147
+ })();
148
+ R.current = t;
149
+ try {
150
+ await t;
151
+ } finally {
152
+ R.current = void 0;
153
+ }
154
+ }, [
155
+ F,
156
+ p.detail.paymentInstructionsLinkError,
157
+ p.detail.paymentInstructionsSaveError,
158
+ xt,
159
+ w?.counterpart_bank_account_id,
160
+ w?.counterpart_id,
161
+ y,
162
+ I,
163
+ P
164
+ ]), z = o(() => F ? P.mode === "creating" && Ke(P.newVendorForm) ? {
165
+ ...P,
166
+ newVendorForm: Ge(P.newVendorForm, {
167
+ onSave: Ct,
168
+ isSaving: L
169
+ })
170
+ } : P.mode === "resolved" && P.paymentInstructions ? {
171
+ ...P,
172
+ paymentInstructions: {
173
+ ...P.paymentInstructions,
174
+ onSave: Ct,
175
+ isSaving: L
176
+ }
177
+ } : P : P, [
178
+ F,
179
+ L,
180
+ Ct,
181
+ P
182
+ ]);
183
+ qe(() => {
184
+ d && P.isEditingPayTo && !F && P.discardPayToEdits();
185
+ }, [
186
+ F,
187
+ d,
188
+ P.discardPayToEdits,
189
+ P.isEditingPayTo
190
+ ]);
191
+ let wt = o(() => E ? { draftSaved: Oe.submittedSaved } : void 0, [E]), B = Ae({
192
+ payableId: $e,
193
+ form: O,
194
+ labels: wt,
195
+ counterpartId: m,
196
+ isVendorPending: P.mode === "creating" || P.isPendingVendor,
197
+ clearCounterpart: yt,
198
+ prepareVendorForSave: P.prepareVendorForSave,
199
+ onPayableCreated: ut,
200
+ onSaved: ut,
201
+ onDraftSaved: () => u(!1),
202
+ onFinalized: () => u(!1),
203
+ readSavedStatus: E ? bt : void 0
204
+ }), Tt = !!(B.isSavingDraft || B.isFinalizing || P.isVendorSavePending), V = d ? y : void 0, H = Le({
205
+ payableId: V,
206
+ status: w?.status
207
+ }), Et = Je(null), Dt = de(w), U = Te({
208
+ counterpartId: d ? k : void 0,
209
+ currency: w?.currency,
210
+ currentBankAccountId: d ? w?.counterpart_bank_account_id ?? void 0 : void 0,
211
+ enabled: j && d
212
+ }), Ot = De({
213
+ payableId: V,
214
+ amountDueMinorUnits: we(w) ?? 0,
215
+ amountToPayMinorUnits: w?.amount_to_pay ?? void 0,
216
+ currencyCode: w?.currency ?? void 0,
217
+ dueDate: w?.due_date,
218
+ hasScheduledPayment: A.hasScheduledPayment,
219
+ labels: p.markAsPaid
220
+ }), W = Fe({
221
+ payableId: V,
222
+ approvalPolicyId: w?.approval_policy_id,
223
+ enabled: d,
224
+ copy: p.approvalPolicyCopy
225
+ }), kt = Se({
226
+ status: w?.status,
227
+ scopes: S?.scopes,
228
+ arePendingApproversUnknown: W.isLoading,
229
+ hasApprovalPolicy: !!w?.approval_policy_id,
230
+ hasWaitingRequest: H.hasWaitingRequest
231
+ }), At = !!H.id, jt = H.isLoading || W.isLoading, Mt = o(() => Qe(W.pendingApprovers.flatMap((e) => e.names)), [W.pendingApprovers]), Nt = d || E ? y : void 0, Pt = d ? tt : void 0, G = a((e) => {
232
+ let t = () => {
233
+ P.discardPayToEdits(), e?.();
234
+ };
235
+ P.hasUnsavedVendorChanges ? ct(t) : t();
236
+ }, [ct, P]), { actions: Ft, decisionDialog: It, isActionPending: Lt } = Re({
237
+ payableId: Nt,
238
+ status: w?.status,
239
+ currentApprovalRequestId: H.id,
240
+ arePendingApproversUnknown: W.isLoading,
241
+ hasScheduledPayment: A.hasScheduledPayment,
242
+ scheduledPaymentIntentId: A.scheduledPaymentIntentId,
243
+ isScheduledPaymentUnknown: A.isResolving,
244
+ isPayabilityUnknown: U.isLoading,
245
+ hasApprovalPolicy: !!w?.approval_policy_id,
246
+ hasWaitingRequest: H.hasWaitingRequest,
247
+ pendingApprovers: W.pendingApprovers,
248
+ labels: p.actions,
249
+ isMarkAsPaidPending: Ot.isPending,
250
+ onMarkAsPaidSelect: Ot.open,
251
+ onPayBillSelect: () => G(() => Et.current?.open()),
252
+ onEditSelect: Pt,
253
+ onActionSucceeded: (e) => {
254
+ if (e === "reopen") {
255
+ Pt?.();
256
+ return;
257
+ }
258
+ E && u(!1);
259
+ }
260
+ }), Rt = Be({
261
+ payableId: y,
262
+ status: w?.status,
263
+ enabled: !d,
264
+ labels: p.deleteDraft,
265
+ onDeleted: () => u(!1)
266
+ }), zt = Tt || Lt, Bt = w?.ocr_status === "processing", Vt = b.isLoading || x.isResolving || Bt, Ht = b.isLoading || x.isResolving || C.isResolving || U.isLoading, Ut = b.isError || x.isError || C.isError, Wt = o(() => [...Rt.menuItems, ...E || d && !Ht && !Ut ? Ft.menu.map((e) => ({
267
+ id: e.id,
268
+ label: e.label,
269
+ onSelect: e.onSelect,
270
+ disabled: e.disabled,
271
+ icon: e.icon,
272
+ sectionHeading: e.sectionHeading
273
+ })) : []], [
274
+ Ft.menu,
275
+ Rt.menuItems,
276
+ E,
277
+ d,
278
+ Ht,
279
+ Ut
280
+ ]), K = o(() => (C.data?.data ?? []).map((e) => ({
281
+ value: e.id,
282
+ label: [e.nominal_code, e.name].filter(Boolean).join(" — ")
283
+ })), [C.data]), q;
284
+ dt && (ft ? C.isError ? q = p.lineItemsGlCodeUnavailable.loadError : !C.isResolving && K.length === 0 && (q = p.lineItemsGlCodeUnavailable.empty) : q = p.lineItemsGlCodeUnavailable.noAccess);
285
+ let Gt = !dt || !!q || C.isResolving, Kt = ft && !C.isResolving && !C.isError, J = oe(V), qt = w?.status === "rejected" || !d && E, Jt = t(S?.scopes, [n.ApprovalRequestReadOrg]), Yt = qt && Jt, Xt = t(S?.scopes, [n.UserReadOrg]), { userNames: Y, isError: Zt, isResolving: Qt } = ie({ enabled: (d || qt) && Xt }), $t = o(() => te(J.data?.data ?? [], Y, p.history), [
286
+ J.data,
287
+ Y,
288
+ p.history
289
+ ]), en = Xt && Zt && ne(J.data?.data ?? [], $t, Y), tn = Pe({
290
+ payableId: y,
291
+ enabled: Yt
292
+ }), nn = ae(y, { enabled: Yt }), rn = o(() => Ne(nn.data?.data, tn.roundStartedAt), [nn.data, tn.roundStartedAt]), X = o(() => Ie({
293
+ payableStatus: w?.status,
294
+ approvalRequests: rn,
295
+ userNames: Y,
296
+ payableUpdatedAt: w?.updated_at,
297
+ labels: p.detail
298
+ }), [
299
+ w?.status,
300
+ w?.updated_at,
301
+ rn,
302
+ Y,
303
+ p.detail
304
+ ]), an = o(() => Me({
305
+ records: A.paymentRecords,
306
+ events: J.data?.data ?? [],
307
+ currencyCode: w?.currency,
308
+ labels: p.detail
309
+ }), [
310
+ A.paymentRecords,
311
+ J.data,
312
+ w?.currency,
313
+ p.detail
314
+ ]), on = o(() => {
315
+ if (!d || !w) return;
316
+ let e = Ve({
317
+ payable: w,
318
+ lineItems: x.lineItems,
319
+ glCodeOptions: K,
320
+ glCodeRosterAvailable: Kt,
321
+ history: $t,
322
+ paymentHistory: an,
323
+ approvalPolicy: W.view,
324
+ labels: p.detail,
325
+ hasScheduledPayment: A.hasScheduledPayment,
326
+ rejection: X,
327
+ payableAchInstructions: U.achInstructions,
328
+ payableAchInstructionsReadable: j && !U.isError
329
+ });
330
+ return P.mode === "resolved" && P.summary ? {
331
+ ...e,
332
+ payTo: P.summary
333
+ } : e;
334
+ }, [
335
+ A.hasScheduledPayment,
336
+ W.view,
337
+ j,
338
+ p.detail,
339
+ K,
340
+ Kt,
341
+ $t,
342
+ x.lineItems,
343
+ w,
344
+ U.achInstructions,
345
+ U.isError,
346
+ an,
347
+ d,
348
+ X,
349
+ P.mode,
350
+ P.summary
351
+ ]), sn = w?.source_of_payable_data === "ocr", Z = Dt?.name, cn = d ? Z ? p.viewTitle(Z) : p.readOnlyTitle : Z && (sn || E) ? p.extractedTitle(Z) : p.newTitle, ln = d && w?.created_at ? p.addedOn(ee(w.created_at.slice(0, 10))) : void 0, un = a(() => {
352
+ if (d && P.isEditingPayTo) {
353
+ G(() => u(!1));
354
+ return;
355
+ }
356
+ let e = O.isDirty || P.hasUnsavedVendorChanges || !!B.stagedFile || B.isFileDeletionPending;
357
+ switch (He({
358
+ isUnsavedPromptOpen: g,
359
+ isLocked: D,
360
+ isDirty: e
361
+ })) {
362
+ case "dismiss-prompt":
363
+ _(!1);
364
+ return;
365
+ case "prompt":
366
+ _(!0);
367
+ return;
368
+ default: u(!1);
369
+ }
370
+ }, [
371
+ B.isFileDeletionPending,
372
+ B.stagedFile,
373
+ O.isDirty,
374
+ D,
375
+ g,
376
+ G,
377
+ u,
378
+ d,
379
+ P.hasUnsavedVendorChanges,
380
+ P.isEditingPayTo
381
+ ]), dn = a(() => {
382
+ if (P.isEditingPayTo) {
383
+ G(f);
384
+ return;
385
+ }
386
+ f?.();
387
+ }, [
388
+ G,
389
+ f,
390
+ P.isEditingPayTo
391
+ ]), fn = a(() => {
392
+ _(!1), u(!1);
393
+ }, [u]), Q = Vt || P.mode === "creating", pn = a(async () => {
394
+ if (Q) return;
395
+ let e = await B.saveDraft();
396
+ _(!1), e && u(!1);
397
+ }, [
398
+ B,
399
+ Q,
400
+ u
401
+ ]), $ = be({
402
+ payable: w,
403
+ onRemoved: () => u(!1),
404
+ canManage: ht
405
+ }), mn = a((e) => {
406
+ if (!(zt || $.isBusy)) return e ? u(!0) : un();
407
+ }, [
408
+ $.isBusy,
409
+ zt,
410
+ un,
411
+ u
412
+ ]), hn = $.isPossibleDuplicate, gn = !d && sn && !at, _n = !d && !!X, vn = _n || hn || gn ? /* @__PURE__ */ Xe(Ye, { children: [
413
+ _n && X ? /* @__PURE__ */ c(ge, {
414
+ ...X,
415
+ labels: p.rejectedBanner
416
+ }) : null,
417
+ hn ? /* @__PURE__ */ c(he, {
418
+ onNotADuplicate: $.onNotADuplicate,
419
+ onRemoveBill: $.onRemoveBill,
420
+ isActionDisabled: $.isBusy,
421
+ labels: $.removeBillLabel ? { removeBillButton: $.removeBillLabel } : void 0,
422
+ testId: i.duplicateNotice
423
+ }) : null,
424
+ gn ? /* @__PURE__ */ c(_e, { onDismiss: () => ot(!0) }) : null
425
+ ] }) : void 0;
426
+ return /* @__PURE__ */ Xe(Ye, { children: [
427
+ /* @__PURE__ */ c(fe, {
428
+ open: l,
429
+ onOpenChange: mn,
430
+ title: cn,
431
+ subtitle: ln,
432
+ notice: vn,
433
+ vendor: {
434
+ ...z,
435
+ testId: i.vendorSection
436
+ },
437
+ values: O.values,
438
+ errors: O.errors,
439
+ onChange: O.onChange,
440
+ lineItems: {
441
+ items: O.lineItemRows,
442
+ glCodeOptions: K,
443
+ glCodeDisabled: Gt,
444
+ glCodeUnavailableMessage: q,
445
+ discount: O.discount,
446
+ onDiscountChange: O.onDiscountChange,
447
+ onDiscountBlur: O.onDiscountBlur,
448
+ tax: O.tax,
449
+ onTaxChange: O.onTaxChange,
450
+ onTaxBlur: O.onTaxBlur,
451
+ total: O.total,
452
+ onTotalChange: O.onTotalChange,
453
+ onTotalBlur: O.onTotalBlur,
454
+ onAddLineItem: O.onAddLineItem,
455
+ errors: O.lineItemErrors,
456
+ totalsErrors: O.totalsErrors,
457
+ testId: i.lineItems
458
+ },
459
+ documentPanel: /* @__PURE__ */ c(Ue, {
460
+ payableId: y,
461
+ readOnly: D,
462
+ isDocumentPending: !!y && !w?.file && (b.isLoading || w?.ocr_status === "processing"),
463
+ file: w?.file ? {
464
+ id: w.file.id,
465
+ name: w.file.name,
466
+ url: w.file.url,
467
+ mimetype: w.file.mimetype
468
+ } : void 0,
469
+ staging: {
470
+ stagedFile: B.stagedFile,
471
+ onFileStaged: B.stageFile,
472
+ onClearStagedFile: B.clearStagedFile,
473
+ isSaving: Tt
474
+ },
475
+ deletion: {
476
+ isPending: B.isFileDeletionPending,
477
+ onRequest: B.requestFileDeletion,
478
+ onDetachNow: B.detachFileNow,
479
+ isDeleting: B.isDeletingFile,
480
+ hasFailed: B.hasFileDeletionFailed
481
+ }
482
+ }),
483
+ menuItems: Wt,
484
+ readOnly: D,
485
+ detail: d ? {
486
+ view: on,
487
+ actions: Ft,
488
+ scheduledSummary: A.hasScheduledPayment && A.scheduledDateLabel ? p.scheduledSummary(A.scheduledDateLabel) : void 0,
489
+ scheduledStatusLabel: A.hasScheduledPayment && A.scheduledDateLabel ? p.scheduledStatusBadge(A.scheduledDateLabel) : void 0,
490
+ showApprovalOverrideNotice: !jt && kt,
491
+ awaitingApprovalNotice: !jt && !At && !kt && w?.status === "approve_in_progress" && w?.approval_policy_id ? Mt ? p.awaitingApprovalNotice(Mt) : p.awaitingApprovalUnknownNotice : void 0,
492
+ payTo: {
493
+ onEdit: z.mode === "resolved" ? z.onEdit : void 0,
494
+ paymentInstructions: z.paymentInstructions,
495
+ editForm: z.mode === "creating" ? z.newVendorForm : void 0
496
+ },
497
+ hideMissingPaymentInstructions: w?.status === "paid" || w?.status === "canceled",
498
+ isLoading: Ht,
499
+ isError: Ut,
500
+ paymentHistoryError: A.isError || J.isError,
501
+ paymentHistoryLoading: A.isResolving || J.isLoading,
502
+ historyError: J.isError,
503
+ historyLoading: J.isLoading || Qt,
504
+ historyNamesError: en
505
+ } : void 0,
506
+ isLineItemsLoading: Vt,
507
+ isSaving: zt || L,
508
+ isSavingDraft: B.isSavingDraft,
509
+ isSubmitting: B.isFinalizing,
510
+ onCancel: un,
511
+ onCollapse: d ? dn : void 0,
512
+ onSaveDraft: B.saveDraft,
513
+ onFinalize: B.finalize,
514
+ scrollToErrorToken: B.scrollToErrorToken,
515
+ showSubmit: !D && T,
516
+ testId: i.dialog
517
+ }),
518
+ /* @__PURE__ */ c(ye, {
519
+ open: g,
520
+ onSaveDraft: pn,
521
+ onDiscard: fn,
522
+ onCancel: () => _(!1),
523
+ isSaving: B.isSavingDraft,
524
+ isSaveDraftDisabled: Q,
525
+ labels: p.unsavedChanges,
526
+ testId: i.unsavedDialog,
527
+ saveDraftTestId: i.unsavedSaveDraft,
528
+ discardTestId: i.unsavedDiscard,
529
+ closeTestId: i.unsavedClose
530
+ }),
531
+ /* @__PURE__ */ c(me, {
532
+ open: !!st,
533
+ onDiscard: () => {
534
+ let e = st;
535
+ v(void 0), e?.();
536
+ },
537
+ onKeepEditing: () => v(void 0),
538
+ labels: p.discardChanges,
539
+ testId: i.discardDialog,
540
+ discardTestId: i.discardConfirm
541
+ }),
542
+ /* @__PURE__ */ c(pe, {
543
+ ...It,
544
+ labels: { cancelButton: p.actions.decisionDialog.cancelButton },
545
+ testId: i.decisionDialog,
546
+ confirmTestId: i.decisionConfirm,
547
+ reasonTestId: i.decisionReason
548
+ }),
549
+ /* @__PURE__ */ c(pe, {
550
+ ...Rt.dialog,
551
+ labels: { cancelButton: p.actions.decisionDialog.cancelButton },
552
+ testId: i.deleteDraftDialog,
553
+ confirmTestId: i.deleteDraftConfirm
554
+ }),
555
+ /* @__PURE__ */ c(pe, {
556
+ open: $.removeConfirmation.open,
557
+ copy: $.removeConfirmation.copy,
558
+ onConfirm: $.removeConfirmation.onConfirm,
559
+ onCancel: $.removeConfirmation.onCancel,
560
+ isPending: $.removeConfirmation.isPending,
561
+ confirmIcon: /* @__PURE__ */ c(Ze, {}),
562
+ labels: { cancelButton: $.removeConfirmation.cancelButtonLabel },
563
+ testId: i.duplicateRemoveDialog,
564
+ confirmTestId: i.duplicateRemoveConfirm
565
+ }),
566
+ /* @__PURE__ */ c(ve, { ...Ot.dialogProps }),
567
+ d && w ? /* @__PURE__ */ c(Ee, {
568
+ ref: Et,
569
+ payable: w,
570
+ onMissingAchInstructions: M ? P.openPaymentInstructions : void 0,
571
+ poweredByBankName: nt,
572
+ labels: p.payBill
573
+ }) : null
574
+ ] });
575
+ }
22
576
  //#endregion
23
- export { e as billCreateTestIds };
577
+ export { l as BillCreateDialog, l as default };