@tesouro/embedded-components-react 0.5.157 → 0.5.159

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