@tesouro/embedded-components-react 0.5.67 → 0.5.68

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