@tesouro/embedded-components-react 0.5.303 → 0.5.305

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 (52) hide show
  1. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index.js +9 -9
  2. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index12.js +7 -7
  3. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index13.js +10 -9
  4. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index14.js +8 -7
  5. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index15.js +7 -8
  6. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index16.js +8 -28
  7. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index17.js +24 -157
  8. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index18.js +20 -13
  9. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index19.js +13 -34
  10. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index20.js +153 -89
  11. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index21.js +17 -83
  12. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index22.js +23 -3
  13. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index23.js +42 -55
  14. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index24.js +93 -107
  15. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index25.js +77 -185
  16. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index26.js +3 -80
  17. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index27.js +55 -72
  18. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index28.js +111 -113
  19. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index29.js +184 -463
  20. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index3.js +14 -4
  21. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index30.js +78 -11
  22. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index31.js +61 -74
  23. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index32.js +115 -80
  24. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index33.js +449 -216
  25. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index34.js +116 -42
  26. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index35.js +11 -249
  27. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index36.js +85 -23
  28. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index37.js +80 -648
  29. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index38.js +240 -4
  30. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index39.js +44 -40
  31. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index4.js +38 -15
  32. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index40.js +242 -240
  33. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index41.js +25 -3
  34. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index42.js +538 -3
  35. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index43.js +3 -66
  36. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index44.js +42 -1
  37. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index45.js +239 -0
  38. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index46.js +3 -0
  39. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index47.js +5 -0
  40. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index48.js +67 -0
  41. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index49.js +1 -0
  42. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index5.js +227 -38
  43. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index6.js +82 -224
  44. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index7.js +45 -82
  45. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index8.js +4 -47
  46. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index9.js +1 -1
  47. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/ui/dist/index.js +2 -2
  48. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/ui/dist/index29.js +1 -1
  49. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/ui/dist/index31.js +2 -2
  50. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/lib/BillPayWidgetNative/BillsTab.js +6 -6
  51. package/dist/libs/tesouro-embedded-components-react/shared/feature/dist/lib/analytics/build-info.js +1 -1
  52. package/package.json +1 -1
@@ -1,651 +1,83 @@
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";
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";
1
+ import { BILL_CREATE_MESSAGE_LABELS_EN as e } from "./index29.js";
2
+ import { isPersistableLineItem as t, parseMoneyToMinorUnits as n, parseQuantity as r } from "./index36.js";
62
3
  //#region ../../libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index37.js
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
- onVendorIncomplete: F.revealIncompleteVendor,
223
- clearCounterpart: wt,
224
- prepareVendorForSave: F.prepareVendorForSave,
225
- onPayableCreated: pt,
226
- onSaved: pt,
227
- onDraftSaved: () => f(!1),
228
- onFinalized: () => f(!1),
229
- readSavedStatus: D ? Tt : void 0
230
- }), At = !!(V.isSavingDraft || V.isFinalizing || F.isVendorSavePending), H = p ? b : void 0, U = Ne({
231
- payableId: H,
232
- status: T?.status
233
- }), jt = Ge(null), [Mt, Nt] = u(!1), Pt = se(T), W = Be({
234
- counterpartId: p ? A : void 0,
235
- currency: T?.currency,
236
- currentBankAccountId: p ? T?.counterpart_bank_account_id ?? void 0 : void 0,
237
- enabled: N && p
238
- }), G = ke({
239
- payableId: H,
240
- approvalPolicyId: T?.approval_policy_id,
241
- enabled: p,
242
- copy: g.approvalPolicyCopy
243
- }), Ft = Ee({
244
- status: T?.status,
245
- scopes: C?.scopes,
246
- arePendingApproversUnknown: G.isLoading,
247
- hasApprovalPolicy: !!T?.approval_policy_id,
248
- hasWaitingRequest: U.hasWaitingRequest
249
- }), It = Ae({
250
- isCapabilityUnknown: U.isLoading || G.isLoading,
251
- canApproveNow: !!U.id,
252
- canOverridePolicy: Ft,
253
- status: T?.status,
254
- hasApprovalPolicy: !!T?.approval_policy_id,
255
- pendingApproverNames: G.pendingApprovers.flatMap((e) => e.names),
256
- labels: g
257
- }), Lt = p || D ? b : void 0, Rt = p ? $e : void 0, K = c((e) => {
258
- let t = () => {
259
- F.discardPayToEdits(), e?.();
260
- };
261
- F.hasUnsavedVendorChanges ? y(t) : t();
262
- }, [y, F]), { actions: zt, decisionDialog: Bt, isActionPending: Vt } = Pe({
263
- payableId: Lt,
264
- status: T?.status,
265
- currentApprovalRequestId: U.id,
266
- arePendingApproversUnknown: G.isLoading,
267
- hasScheduledPayment: j.hasScheduledPayment,
268
- scheduledPaymentIntentId: j.scheduledPaymentIntentId,
269
- isScheduledPaymentUnknown: j.isResolving,
270
- isPayabilityUnknown: W.isLoading,
271
- hasApprovalPolicy: !!T?.approval_policy_id,
272
- hasWaitingRequest: U.hasWaitingRequest,
273
- pendingApprovers: G.pendingApprovers,
274
- labels: g.actions,
275
- isMarkAsPaidPending: Mt,
276
- onMarkAsPaidSelect: () => jt.current?.openMarkAsPaid(),
277
- onPayBillSelect: () => K(() => jt.current?.openPayBill()),
278
- onEditSelect: Rt,
279
- onActionSucceeded: (e) => {
280
- if (e === "reopen") {
281
- Rt?.();
282
- return;
283
- }
284
- D && f(!1);
285
- }
286
- }), Ht = Ie({
287
- payableId: b,
288
- status: T?.status,
289
- enabled: !p,
290
- labels: g.deleteDraft,
291
- onDeleted: () => f(!1)
292
- }), 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) => ({
293
- id: e.id,
294
- label: e.label,
295
- onSelect: e.onSelect,
296
- disabled: e.disabled,
297
- icon: e.icon,
298
- sectionHeading: e.sectionHeading
299
- })) : []], [
300
- zt.menu,
301
- Ht.menuItems,
302
- D,
303
- p,
304
- Kt,
305
- qt
306
- ]), q = l(() => (w.data?.data ?? []).map((e) => ({
307
- value: e.id,
308
- label: [e.nominal_code, e.name].filter(Boolean).join(" — ")
309
- })), [w.data]), J;
310
- mt && (ht ? w.isError ? J = g.lineItemsGlCodeUnavailable.loadError : !w.isResolving && q.length === 0 && (J = g.lineItemsGlCodeUnavailable.empty) : J = g.lineItemsGlCodeUnavailable.noAccess);
311
- 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), [
312
- Y.data,
313
- X,
314
- g.history
315
- ]), an = en && tn && r(Y.data?.data ?? [], rn, X), on = Oe({
316
- payableId: b,
317
- enabled: $t
318
- }), sn = ge(b, { enabled: $t }), cn = l(() => we(sn.data?.data, on.roundStartedAt), [sn.data, on.roundStartedAt]), Z = l(() => Me({
319
- payableStatus: T?.status,
320
- approvalRequests: cn,
321
- userNames: X,
322
- payableUpdatedAt: T?.updated_at,
323
- labels: g.detail
324
- }), [
325
- T?.status,
326
- T?.updated_at,
327
- cn,
328
- X,
329
- g.detail
330
- ]), ln = l(() => Ce({
331
- records: j.paymentRecords,
332
- events: Y.data?.data ?? [],
333
- currencyCode: T?.currency,
334
- labels: g.detail
335
- }), [
336
- j.paymentRecords,
337
- Y.data,
338
- T?.currency,
339
- g.detail
340
- ]), un = l(() => {
341
- if (!p || !T) return;
342
- let e = Le({
343
- payable: T,
344
- lineItems: S.lineItems,
345
- glCodeOptions: q,
346
- glCodeRosterAvailable: Xt,
347
- history: rn,
348
- paymentHistory: ln,
349
- approvalPolicy: G.view,
350
- labels: g.detail,
351
- hasScheduledPayment: j.hasScheduledPayment,
352
- rejection: Z,
353
- payableAchInstructions: W.achInstructions,
354
- payableAchInstructionsReadable: N && !W.isError
355
- });
356
- return F.mode === "resolved" && F.summary ? {
357
- ...e,
358
- payTo: F.summary
359
- } : e;
360
- }, [
361
- j.hasScheduledPayment,
362
- G.view,
363
- N,
364
- g.detail,
365
- q,
366
- Xt,
367
- rn,
368
- S.lineItems,
369
- T,
370
- W.achInstructions,
371
- W.isError,
372
- ln,
373
- p,
374
- Z,
375
- F.mode,
376
- F.summary
377
- ]), 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(() => {
378
- if (p && F.isEditingPayTo) {
379
- K(() => f(!1));
380
- return;
381
- }
382
- let e = k.isDirty || F.hasUnsavedVendorChanges || !!V.stagedFile || V.isFileDeletionPending;
383
- switch (Re({
384
- isUnsavedPromptOpen: lt,
385
- isLocked: O,
386
- isDirty: e
387
- })) {
388
- case "dismiss-prompt":
389
- v(!1);
390
- return;
391
- case "prompt":
392
- v(!0);
393
- return;
394
- default: f(!1);
395
- }
396
- }, [
397
- V.isFileDeletionPending,
398
- V.stagedFile,
399
- k.isDirty,
400
- O,
401
- lt,
402
- K,
403
- f,
404
- p,
405
- F.hasUnsavedVendorChanges,
406
- F.isEditingPayTo
407
- ]), hn = c((e, t) => {
408
- if (!h) return;
409
- let n = () => h(e, t);
410
- if (p && F.isEditingPayTo) {
411
- K(n);
412
- return;
413
- }
414
- let r = k.isDirty || F.hasUnsavedVendorChanges || !!V.stagedFile || V.isFileDeletionPending;
415
- !O && r ? y(n) : n();
416
- }, [
417
- y,
418
- V.isFileDeletionPending,
419
- V.stagedFile,
420
- k.isDirty,
421
- O,
422
- K,
423
- h,
424
- p,
425
- F.hasUnsavedVendorChanges,
426
- F.isEditingPayTo
427
- ]), gn = c(() => {
428
- if (F.isEditingPayTo) {
429
- K(Qe);
430
- return;
431
- }
432
- Qe?.();
433
- }, [
434
- K,
435
- Qe,
436
- F.isEditingPayTo
437
- ]), _n = c(() => {
438
- v(!1), f(!1);
439
- }, [f]), vn = Gt || F.mode === "creating", yn = c(async () => {
440
- if (vn) return;
441
- let e = await V.saveDraft();
442
- v(!1), e && f(!1);
443
- }, [
444
- V,
445
- vn,
446
- f
447
- ]), $ = Te({
448
- payable: T,
449
- onOpenPayable: h ? hn : void 0,
450
- onRemoved: () => f(!1),
451
- canManage: yt
452
- }), bn = c((e) => {
453
- if (!(Ut || $.isBusy)) return e ? f(!0) : mn();
454
- }, [
455
- $.isBusy,
456
- Ut,
457
- mn,
458
- f
459
- ]), xn = $.isPossibleDuplicate, Sn = !p && dn && !st, Cn = !p && !!Z, wn = Cn || xn || Sn ? /* @__PURE__ */ qe(Ke, { children: [
460
- Cn && Z ? /* @__PURE__ */ d(ue, {
461
- ...Z,
462
- labels: g.rejectedBanner
463
- }) : null,
464
- xn ? /* @__PURE__ */ d(le, {
465
- onNotADuplicate: $.onNotADuplicate,
466
- onRemoveBill: $.onRemoveBill,
467
- isActionDisabled: $.isBusy,
468
- rows: $.rows,
469
- collapsedRowCount: $.collapsedRowCount,
470
- showMoreLabel: $.showMoreLabel,
471
- labels: $.removeBillLabel ? { removeBillButton: $.removeBillLabel } : void 0,
472
- testId: s.duplicateNotice
473
- }) : null,
474
- Sn ? /* @__PURE__ */ d(fe, {
475
- onDismiss: () => ct(!0),
476
- labels: m?.extractionNotice
477
- }) : null
478
- ] }) : void 0;
479
- return /* @__PURE__ */ qe(Ke, { children: [
480
- /* @__PURE__ */ d(ce, {
481
- open: Ye,
482
- onOpenChange: bn,
483
- title: fn,
484
- subtitle: pn,
485
- notice: wn,
486
- vendor: {
487
- ...B,
488
- testId: s.vendorSection
489
- },
490
- values: k.values,
491
- errors: k.errors,
492
- onChange: k.onChange,
493
- lineItems: {
494
- items: k.lineItemRows,
495
- glCodeOptions: q,
496
- glCodeDisabled: Yt,
497
- glCodeUnavailableMessage: J,
498
- discount: k.discount,
499
- onDiscountChange: k.onDiscountChange,
500
- onDiscountBlur: k.onDiscountBlur,
501
- tax: k.tax,
502
- onTaxChange: k.onTaxChange,
503
- onTaxBlur: k.onTaxBlur,
504
- total: k.total,
505
- onTotalChange: k.onTotalChange,
506
- onTotalBlur: k.onTotalBlur,
507
- onAddLineItem: k.onAddLineItem,
508
- errors: k.lineItemErrors,
509
- totalsErrors: k.totalsErrors,
510
- testId: s.lineItems
511
- },
512
- documentPanel: /* @__PURE__ */ d(ze, {
513
- payableId: b,
514
- readOnly: O,
515
- isDocumentPending: !!b && !T?.file && (x.isLoading || T?.ocr_status === "processing"),
516
- file: T?.file ? {
517
- id: T.file.id,
518
- name: T.file.name,
519
- url: T.file.url,
520
- mimetype: T.file.mimetype
521
- } : void 0,
522
- staging: {
523
- stagedFile: V.stagedFile,
524
- onFileStaged: V.stageFile,
525
- onClearStagedFile: V.clearStagedFile,
526
- isSaving: At
527
- },
528
- deletion: {
529
- isPending: V.isFileDeletionPending,
530
- onRequest: V.requestFileDeletion,
531
- onDetachNow: V.detachFileNow,
532
- isDeleting: V.isDeletingFile,
533
- hasFailed: V.hasFileDeletionFailed
534
- },
535
- labels: m?.sourceDocument
536
- }),
537
- menuItems: Jt,
538
- readOnly: O,
539
- detail: p ? {
540
- view: un,
541
- actions: zt,
542
- scheduledSummary: M ? g.scheduledSummary(M.label) : void 0,
543
- scheduledSummaryDate: M?.absoluteLabel,
544
- scheduledStatusLabel: M ? g.scheduledStatusBadge(M.label) : void 0,
545
- ...It,
546
- payTo: {
547
- onEdit: B.mode === "resolved" ? B.onEdit : void 0,
548
- paymentInstructions: T?.status === "paid" || T?.status === "canceled" ? void 0 : je(B.paymentInstructionsEditor, !!un?.payTo.hasPaymentInstructions),
549
- detailsWarning: B.detailsWarning,
550
- editForm: B.mode === "creating" ? B.newVendorForm : void 0
551
- },
552
- isLoading: Kt,
553
- isError: qt,
554
- paymentHistoryError: j.isError || Y.isError,
555
- paymentHistoryLoading: j.isResolving || Y.isLoading,
556
- historyError: Y.isError,
557
- historyLoading: Y.isLoading || nn,
558
- historyNamesError: an
559
- } : void 0,
560
- isLineItemsLoading: Gt,
561
- isSaving: Ut || R,
562
- isSavingDraft: V.isSavingDraft,
563
- isSubmitting: V.isFinalizing,
564
- onCancel: mn,
565
- onCollapse: p ? gn : void 0,
566
- onSaveDraft: V.saveDraft,
567
- onFinalize: V.finalize,
568
- scrollToErrorToken: V.scrollToErrorToken,
569
- showSubmit: !O && E,
570
- testId: s.dialog,
571
- labels: m?.screen
572
- }),
573
- /* @__PURE__ */ d(pe, {
574
- open: lt,
575
- onSaveDraft: yn,
576
- onDiscard: _n,
577
- onCancel: () => v(!1),
578
- isSaving: V.isSavingDraft,
579
- isSaveDraftDisabled: vn,
580
- labels: g.unsavedChanges,
581
- testId: s.unsavedDialog,
582
- saveDraftTestId: s.unsavedSaveDraft,
583
- discardTestId: s.unsavedDiscard,
584
- closeTestId: s.unsavedClose
585
- }),
586
- /* @__PURE__ */ d(de, {
587
- open: !!ut,
588
- onDiscard: () => {
589
- let e = ut;
590
- dt(void 0), e?.();
591
- },
592
- onKeepEditing: () => dt(void 0),
593
- labels: g.discardChanges,
594
- testId: s.discardDialog,
595
- discardTestId: s.discardConfirm
596
- }),
597
- /* @__PURE__ */ d(o, {
598
- ...Bt,
599
- labels: { cancelButton: g.actions.decisionDialog.cancelButton },
600
- testId: s.decisionDialog,
601
- confirmTestId: s.decisionConfirm,
602
- reasonTestId: s.decisionReason
603
- }),
604
- /* @__PURE__ */ d(o, {
605
- ...Ht.dialog,
606
- labels: { cancelButton: g.actions.decisionDialog.cancelButton },
607
- testId: s.deleteDraftDialog,
608
- confirmTestId: s.deleteDraftConfirm
609
- }),
610
- /* @__PURE__ */ d(o, {
611
- open: $.removeConfirmation.open,
612
- copy: $.removeConfirmation.copy,
613
- onConfirm: $.removeConfirmation.onConfirm,
614
- onCancel: $.removeConfirmation.onCancel,
615
- isPending: $.removeConfirmation.isPending,
616
- confirmIcon: /* @__PURE__ */ d(Je, {}),
617
- labels: { cancelButton: $.removeConfirmation.cancelButtonLabel },
618
- testId: s.duplicateRemoveDialog,
619
- confirmTestId: s.duplicateRemoveConfirm
620
- }),
621
- /* @__PURE__ */ d(o, {
622
- open: $.cancelRowConfirmation.open,
623
- copy: $.cancelRowConfirmation.copy,
624
- onConfirm: $.cancelRowConfirmation.onConfirm,
625
- onCancel: $.cancelRowConfirmation.onCancel,
626
- isPending: $.cancelRowConfirmation.isPending,
627
- labels: { cancelButton: $.cancelRowConfirmation.cancelButtonLabel },
628
- testId: s.duplicateCancelRowDialog,
629
- confirmTestId: s.duplicateCancelRowConfirm
630
- }),
631
- /* @__PURE__ */ d(o, {
632
- open: $.keepRowConfirmation.open,
633
- copy: $.keepRowConfirmation.copy,
634
- onConfirm: $.keepRowConfirmation.onConfirm,
635
- onCancel: $.keepRowConfirmation.onCancel,
636
- isPending: $.keepRowConfirmation.isPending,
637
- labels: { cancelButton: $.keepRowConfirmation.cancelButtonLabel }
638
- }),
639
- et?.({
640
- ref: jt,
641
- payable: T,
642
- payableId: H,
643
- isPayBillEnabled: p,
644
- hasScheduledPayment: j.hasScheduledPayment,
645
- onMissingAchInstructions: bt ? F.openPaymentInstructions : void 0,
646
- onMarkAsPaidPendingChange: Nt
647
- })
648
- ] });
4
+ var i = /^(?:\d{1,3}(?:,\d{3})+(?:\.\d+)?|\d+(?:\.\d+)?|\.\d+)$/, a = 255, o = 10, s = 5, c = 30, l = 864e5;
5
+ function u() {
6
+ let e = /* @__PURE__ */ new Date();
7
+ return Date.UTC(e.getFullYear(), e.getMonth(), e.getDate());
8
+ }
9
+ function d() {
10
+ let e = new Date(u());
11
+ return e.setUTCFullYear(e.getUTCFullYear() - o), e;
12
+ }
13
+ function f(e) {
14
+ let t = new Date(e);
15
+ if (Number.isNaN(t.getTime())) return !1;
16
+ let n = new Date(u() + c * l);
17
+ return t < d() || t > n;
18
+ }
19
+ function p(e) {
20
+ let t = new Date(e);
21
+ if (Number.isNaN(t.getTime())) return !1;
22
+ let n = new Date(u());
23
+ return n.setUTCFullYear(n.getUTCFullYear() + s), t < d() || t > n;
24
+ }
25
+ function m(t, n = e) {
26
+ let r = {};
27
+ return t.poNumber.length > a && (r.poNumber = n.poNumberTooLong), Object.keys(r).length ? r : void 0;
28
+ }
29
+ function h(e) {
30
+ let t = e.trim();
31
+ return !t || n(t) !== null ? !0 : i.test(t) ? Number(t.replaceAll(",", "")) === 0 : !1;
32
+ }
33
+ function g(t, i = e) {
34
+ let a = {};
35
+ for (let e of t) {
36
+ let t = n(e.price), o = n(e.amount), s = {};
37
+ e.price.trim() && t === null && (s.price = i.unreadableMoney), e.amount.trim() && o === null && (s.amount = i.unreadableMoney), r(e.quantity) === null && (e.quantity.trim() || t !== null || o !== null) && (s.quantity = i.unusableQuantity), Object.keys(s).length && (a[e.id] = s);
38
+ }
39
+ return Object.keys(a).length ? a : void 0;
40
+ }
41
+ function _(i, a, o, s = e) {
42
+ let c = {};
43
+ a || (c.vendor = s.requiredField), i.invoiceNumber.trim() || (c.invoiceNumber = s.requiredField);
44
+ let l = i.invoiceDate.trim(), u = i.dueDate.trim();
45
+ l ? f(l) && (c.invoiceDate = s.implausibleInvoiceDate) : c.invoiceDate = s.requiredField, u ? p(u) ? c.dueDate = s.implausibleDueDate : l && u < l && (c.dueDate = s.dueBeforeInvoiceDate) : c.dueDate = s.requiredField;
46
+ let d = {};
47
+ return o.forEach((e, i) => {
48
+ if (i > 0 && !t(e)) return;
49
+ let a = {};
50
+ e.description.trim() || (a.description = s.requiredField), r(e.quantity) === null && (a.quantity = s.requiredField), n(e.price) === null && n(e.amount) === null && (a.price = s.requiredField, a.amount = s.requiredField), Object.keys(a).length && (d[e.id] = a);
51
+ }), {
52
+ formErrors: Object.keys(c).length ? c : void 0,
53
+ lineItemErrors: Object.keys(d).length ? d : void 0
54
+ };
55
+ }
56
+ function v(e) {
57
+ let t = e.trim();
58
+ if (!t) return !0;
59
+ let n = t.startsWith("-") ? t.slice(1) : t;
60
+ return i.test(n) ? Number(t.replaceAll(",", "")) <= 0 : !1;
61
+ }
62
+ function y(e, t) {
63
+ if (n(e) === null) return v(e) ? t.totalNotGreaterThanZero : t.unreadableTotal;
64
+ }
65
+ function b(t, n = e) {
66
+ let r = y(t, n);
67
+ return r ? { total: r } : void 0;
68
+ }
69
+ function x(t, r = e) {
70
+ if (t === void 0) return;
71
+ let i = n(t);
72
+ if (i !== null) return i > 0 ? void 0 : { total: r.totalNotGreaterThanZero };
73
+ }
74
+ function S(t, n, r, i = e) {
75
+ let a = {};
76
+ if (h(t) || (a.discount = i.unreadableDiscount), h(n) || (a.tax = i.unreadableTax), r !== void 0) {
77
+ let e = y(r, i);
78
+ e && (a.total = e);
79
+ }
80
+ return Object.keys(a).length ? a : void 0;
649
81
  }
650
82
  //#endregion
651
- export { Ye as BillCreateDialog, Ye as default };
83
+ export { h as isReadableMoneyOrZero, _ as validateBillCompleteness, b as validateBillTotalIsPayable, S as validateBillTotals, m as validateBillValues, g as validateLineItems, x as validateStoredAmountDue };