@tesouro/embedded-components-react 0.5.280 → 0.5.282

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