@tesouro/embedded-components-react 0.11.129 → 0.11.131

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 (59) hide show
  1. package/dist/fixtures/index.d.ts +4 -4
  2. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/data-access/dist/index.js +5 -4
  3. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/data-access/dist/index21.js +20 -17
  4. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/data-access/dist/index22.js +14 -37
  5. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/data-access/dist/index23.js +31 -14
  6. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/data-access/dist/index24.js +26 -2
  7. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/data-access/dist/index25.js +2 -0
  8. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index.js +7 -7
  9. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index10.js +35 -12
  10. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index11.js +57 -65
  11. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index12.js +6 -11
  12. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index13.js +20 -8
  13. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index14.js +97 -7
  14. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index15.js +10 -10
  15. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index16.js +10 -29
  16. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index17.js +7 -27
  17. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index18.js +8 -18
  18. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index19.js +24 -139
  19. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index20.js +24 -13
  20. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index21.js +14 -17
  21. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index22.js +130 -27
  22. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index23.js +17 -100
  23. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index24.js +21 -82
  24. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index25.js +41 -3
  25. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index26.js +98 -53
  26. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index27.js +82 -113
  27. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index28.js +3 -193
  28. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index29.js +57 -81
  29. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index30.js +110 -66
  30. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index31.js +190 -111
  31. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index32.js +71 -456
  32. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index33.js +69 -114
  33. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index34.js +113 -8
  34. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index35.js +458 -79
  35. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index36.js +116 -79
  36. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index37.js +10 -256
  37. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index38.js +78 -36
  38. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index39.js +73 -236
  39. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index4.js +1 -1
  40. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index40.js +256 -21
  41. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index41.js +43 -516
  42. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index42.js +245 -4
  43. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index43.js +20 -40
  44. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index44.js +497 -211
  45. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index45.js +3 -2
  46. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index46.js +40 -3
  47. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index47.js +235 -57
  48. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index48.js +2 -0
  49. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index49.js +5 -0
  50. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index50.js +64 -0
  51. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index51.js +1 -0
  52. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index6.js +4 -47
  53. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index7.js +13 -4
  54. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index8.js +8 -13
  55. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index9.js +18 -9
  56. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/ui/dist/index3.js +44 -34
  57. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/lib/BillPayWidget/BillsTab.js +1 -1
  58. package/dist/libs/tesouro-embedded-components-react/shared/feature/dist/lib/analytics/build-info.js +1 -1
  59. package/package.json +1 -1
@@ -1,519 +1,46 @@
1
- "use client";
2
- "use client";
3
- "use client";
4
- "use client";
5
- import { formatCalendarDate as e } from "../../../../shared/util/dist/lib/formatCalendarDate.js";
6
- import "../../../../shared/util/dist/index.js";
7
- import { hasAnyScope as t } from "../../../../shared/data-access/dist/lib/hasAnyScope.js";
8
- import { Scope as n } from "../../../../shared/data-access/dist/lib/scopes.js";
9
- import { useAllLedgerAccountsQuery as ee } from "../../../../shared/data-access/dist/lib/reference-data/useLedgerAccountsQuery.js";
10
- import "../../../../shared/data-access/dist/index.js";
11
- import { useWidgetConfig as te } from "../../../../shared/feature/dist/lib/WidgetProvider/hooks.js";
12
- import { useOrganizationUserNames as ne } from "../../../../shared/feature/dist/lib/user/useOrganizationUserNames.js";
13
- import "../../../../shared/feature/dist/index.js";
14
- import { isEditablePayableStatus as re } from "../../../util/dist/lib/isEditablePayableStatus.js";
15
- import { resolveVendor as ie } from "../../../util/dist/lib/resolveVendor.js";
1
+ import { resolveLineItemAmountMinorUnits as e } from "../../../util/dist/lib/resolveLineItemAmount.js";
2
+ import { resolveLineItemQuantity as t } from "../../../util/dist/lib/resolveLineItemQuantity.js";
16
3
  import "../../../util/dist/index.js";
17
- import { formatGlCodeLabel as ae, resolveGlCodeAvailability as oe } from "./index12.js";
18
- import { hasUnpaidBalance as se } from "../../../../shared/document-status/util/dist/lib/derivePayableStatus.js";
19
- import { BillDecisionDialog as r } from "../../../ui/dist/index4.js";
20
- import "../../../ui/dist/index.js";
21
- import { BillDialogScreen as ce } from "../../ui/dist/index31.js";
22
- import { BillDuplicateNotice as le } from "../../ui/dist/index37.js";
23
- import { BillRejectedBanner as ue } from "../../ui/dist/index40.js";
24
- import { DiscardChangesDialog as de } from "../../ui/dist/index43.js";
25
- import { ExtractionNotice as fe } from "../../ui/dist/index46.js";
26
- import { UnsavedBillDialog as pe } from "../../ui/dist/index52.js";
27
- import "../../ui/dist/index.js";
28
- import { BILL_CREATE_MESSAGE_LABELS_EN as me, mergeBillDialogCopy as he } from "./index28.js";
29
- import { useAllPayableLineItemsQuery as ge } from "../../data-access/dist/index5.js";
30
- import { usePayableQuery as _e } from "../../data-access/dist/index22.js";
31
- import "../../data-access/dist/index.js";
32
- import { useBillCreateController as ve } from "./index37.js";
33
- import { useBillForm as ye } from "./index39.js";
34
- import { buildPaymentHistory as be } from "./index2.js";
35
- import { usePayableDuplicateReview as xe } from "./index4.js";
36
- import { canOverrideApprovalPolicy as Se, canReadCounterpartBankAccounts as Ce } from "./index5.js";
37
- import { useApprovalPolicyCardView as we } from "./index11.js";
38
- import { resolveApprovalNotices as Te } from "./index13.js";
39
- import { resolvePaymentInstructionsGestures as Ee } from "./index14.js";
40
- import { useBillRejectionNotice as De } from "./index16.js";
41
- import { useCurrentApprovalRequestId as Oe } from "./index17.js";
42
- import { usePayableAuditHistory as ke } from "./index18.js";
43
- import { usePayableDetailActions as Ae } from "./index19.js";
44
- import { useScheduledDateLabel as je } from "./index20.js";
45
- import { useScheduledPayment as Me } from "./index21.js";
46
- import { useDraftDelete as Ne } from "./index22.js";
47
- import { buildBillDetailView as Pe } from "./index24.js";
48
- import { resolveEditorDismissal as Fe } from "./index25.js";
49
- import { SourceDocumentContainer as Ie } from "./index29.js";
50
- import { usePayableAchInstructions as Le } from "../../../../shared/counterpart-management/feature/dist/lib/usePayableAchInstructions.js";
51
- import "../../../../shared/counterpart-management/feature/dist/index.js";
52
- import { useVendorSectionProps as Re } from "./index32.js";
53
- import { usePayToSave as ze } from "./index33.js";
54
- import { billDialogTestIds as i } from "./index40.js";
55
- import { useCallback as a, useEffect as Be, useMemo as o, useRef as Ve, useState as s } from "react";
56
- import { Fragment as He, jsx as c, jsxs as Ue } from "react/jsx-runtime";
57
- import { Trash2Icon as We } from "lucide-react";
58
4
  // ../../libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index41.js
59
- function l({ open: l, onOpenChange: u, payableId: d, initialCounterpartId: Ge, readOnly: f = !1, copy: p, onCollapse: m, onEdit: Ke, onOpenBill: h, renderPaymentFlows: qe }) {
60
- let g = o(() => he(p), [p]), _ = p?.messages, v = o(() => ({
61
- ...me,
62
- ..._
63
- }), [_]), Je = d ? void 0 : Ge, [Ye, Xe] = s(Je), [y, Ze] = s(!!Je), [Qe, $e] = s(!1), [b, x] = s(!1), [et, tt] = s(), S = a((e) => {
64
- tt(() => e);
65
- }, []), [nt, rt] = s(), C = d ?? nt, w = _e(C, { pollWhileOcrProcessing: !0 }), T = ge(C), { initResponse: E } = te(), it = !!E, at = t(E?.scopes, [n.AccountingConfigReadOrg]), D = ee({ enabled: at }), O = w.data, k = !C || !!O, A = !f && k && !!C && O?.status !== "draft", ot = !f && !!O && !re(O?.status), j = f || ot, M = ye({
66
- payable: O,
67
- lineItems: T.lineItems,
68
- labels: v
69
- }), N = O?.counterpart_id ?? void 0;
70
- Be(() => {
71
- y || N && (Xe(N), Ze(!0));
72
- }, [y, N]);
73
- let st = a((e) => {
74
- Ze(!0), Xe(e);
75
- }, []), P = Me({
76
- payableId: C,
77
- scheduledPaymentDate: O?.scheduled_payment_date,
78
- enabled: f || A
79
- }), F = je({
80
- hasScheduledPayment: P.hasScheduledPayment,
81
- scheduledDate: P.scheduledDate,
82
- labels: g.scheduledRelativeDay
83
- }), I = Ce(E?.scopes), ct = t(E?.scopes, [n.PayableWriteOrg]), lt = t(E?.scopes, [n.CounterpartWriteOrg]) && ct, L = lt && se(O?.status) && !P.hasScheduledPayment && !P.isResolving, ut = L && I, dt = L || lt && O?.status === "rejected", ft = !f && k && (!C || O?.status === "draft") && !P.hasScheduledPayment && !P.isResolving, R = Re({
84
- payableId: C,
85
- counterpartId: f ? N : Ye,
86
- payableCounterpartId: N,
87
- isVendorKnown: f ? !!O : k,
88
- onCounterpartChange: st,
89
- requiredError: M.errors?.vendor,
90
- payableCounterpartBankAccountId: O?.counterpart_bank_account_id ?? void 0,
91
- extractedVendor: O?.counterpart_raw_data ?? void 0,
92
- readOnly: f,
93
- canEditVendor: !f || ut,
94
- canEditPaymentInstructions: !f || L,
95
- canAddPaymentInstructions: !f || dt,
96
- confirmDiscard: S,
97
- labels: p?.vendorSection
98
- }), pt = R.activePayToOperation === "missingInstructions" ? ft || dt : R.activePayToOperation === "existingInstructions" ? ft || L : R.activePayToOperation === "vendor" && f ? ut : !1, mt = !!(C && y) && !Ye, z = w.refetch, ht = a(async () => {
99
- let { data: e } = await z();
100
- return e?.status ?? void 0;
101
- }, [z]), { vendorWithInlineSave: B, isSavingPayToEdits: gt } = ze({
102
- vendor: R,
103
- payableId: C,
104
- linkedCounterpartId: O?.counterpart_id,
105
- linkedBankAccountId: O?.counterpart_bank_account_id,
106
- canSavePayToEdits: pt,
107
- readOnly: f,
108
- refreshPayable: z,
109
- labels: g.detail
110
- }), _t = o(() => A ? {
111
- ..._,
112
- draftSaved: v.submittedSaved
113
- } : _, [
114
- A,
115
- _,
116
- v.submittedSaved
117
- ]), V = ve({
118
- payableId: d,
119
- form: M,
120
- labels: _t,
121
- counterpartId: Ye,
122
- isVendorPending: R.mode === "creating" || R.isPendingVendor,
123
- onVendorIncomplete: R.revealIncompleteVendor,
124
- clearCounterpart: mt,
125
- prepareVendorForSave: R.prepareVendorForSave,
126
- onPayableCreated: rt,
127
- onSaved: rt,
128
- onDraftSaved: () => u(!1),
129
- onFinalized: () => u(!1),
130
- readSavedStatus: A ? ht : void 0
131
- }), vt = !!(V.isSavingDraft || V.isFinalizing || R.isVendorSavePending), H = f ? C : void 0, U = Oe({
132
- payableId: H,
133
- status: O?.status
134
- }), W = Ve(null), [yt, bt] = s(!1), xt = ie(O), G = Le({
135
- counterpartId: f ? N : void 0,
136
- currency: O?.currency,
137
- currentBankAccountId: f ? O?.counterpart_bank_account_id ?? void 0 : void 0,
138
- enabled: I && f
139
- }), K = we({
140
- payableId: H,
141
- approvalPolicyId: O?.approval_policy_id,
142
- enabled: f,
143
- copy: g.approvalPolicyCopy
144
- }), St = Se({
145
- status: O?.status,
146
- scopes: E?.scopes,
147
- arePendingApproversUnknown: K.isLoading,
148
- hasApprovalPolicy: !!O?.approval_policy_id,
149
- hasWaitingRequest: U.hasWaitingRequest
150
- }), Ct = Te({
151
- isCapabilityUnknown: U.isLoading || K.isLoading,
152
- canApproveNow: !!U.id,
153
- canOverridePolicy: St,
154
- status: O?.status,
155
- hasApprovalPolicy: !!O?.approval_policy_id,
156
- pendingApproverNames: K.pendingApprovers.flatMap((e) => e.names),
157
- labels: g
158
- }), wt = f || A ? C : void 0, Tt = f ? Ke : void 0, q = a((e) => {
159
- let t = () => {
160
- R.discardPayToEdits(), e?.();
161
- };
162
- R.hasUnsavedVendorChanges ? S(t) : t();
163
- }, [S, R]), { actions: Et, decisionDialog: Dt, isActionPending: Ot } = Ae({
164
- payableId: wt,
165
- status: O?.status,
166
- currentApprovalRequestId: U.id,
167
- arePendingApproversUnknown: K.isLoading,
168
- hasScheduledPayment: P.hasScheduledPayment,
169
- scheduledPaymentIntentId: P.scheduledPaymentIntentId,
170
- isScheduledPaymentUnknown: P.isResolving,
171
- isPayabilityUnknown: G.isLoading,
172
- hasApprovalPolicy: !!O?.approval_policy_id,
173
- hasWaitingRequest: U.hasWaitingRequest,
174
- pendingApprovers: K.pendingApprovers,
175
- labels: g.actions,
176
- isMarkAsPaidPending: yt,
177
- onMarkAsPaidSelect: () => W.current?.openMarkAsPaid(),
178
- onPayBillSelect: () => q(() => W.current?.openPayBill()),
179
- onEditSelect: Tt,
180
- onActionSucceeded: (e) => {
181
- e === "reopen" ? Tt?.() : A && u(!1);
182
- }
183
- }), kt = Ne({
184
- payableId: C,
185
- status: O?.status,
186
- enabled: !f,
187
- labels: g.deleteDraft,
188
- onDeleted: () => u(!1)
189
- }), At = vt || Ot, jt = O?.ocr_status === "processing", Mt = w.isLoading || T.isResolving || jt, Nt = w.isLoading || T.isResolving || D.isResolving || G.isLoading, Pt = w.isError || T.isError || D.isError, Ft = o(() => [...kt.menuItems, ...A || f && !Nt && !Pt ? Et.menu.map((e) => ({
190
- id: e.id,
191
- label: e.label,
192
- onSelect: e.onSelect,
193
- disabled: e.disabled,
194
- icon: e.icon,
195
- sectionHeading: e.sectionHeading
196
- })) : []], [
197
- Et.menu,
198
- kt.menuItems,
199
- A,
200
- f,
201
- Nt,
202
- Pt
203
- ]), J = o(() => (D.data?.data ?? []).map((e) => ({
204
- value: e.id,
205
- label: ae(e)
206
- })), [D.data]), { unavailableMessage: It, disabled: Lt, rosterAvailable: Rt } = oe({
207
- isInitResolved: it,
208
- canReadGlCodes: at,
209
- isResolving: D.isResolving,
210
- isError: D.isError,
211
- optionCount: J.length,
212
- labels: g.lineItemsGlCodeUnavailable
213
- }), zt = O?.status === "rejected" || !f && A, Bt = t(E?.scopes, [n.ApprovalRequestReadOrg]), Vt = zt && Bt, Ht = t(E?.scopes, [n.UserReadOrg]), { userNames: Ut, isError: Wt, isResolving: Gt } = ne({ enabled: (f || zt) && Ht }), { historyQuery: Y, rows: Kt, namesError: qt } = ke({
214
- payableId: H,
215
- userNames: Ut,
216
- isRosterError: Ht && Wt,
217
- labels: g.history
218
- }), X = De({
219
- payableId: C,
220
- payableStatus: O?.status,
221
- payableUpdatedAt: O?.updated_at,
222
- enabled: Vt,
223
- userNames: Ut,
224
- labels: g.detail
225
- }), Jt = o(() => be({
226
- records: P.paymentRecords,
227
- events: Y.data?.data ?? [],
228
- currencyCode: O?.currency,
229
- labels: g.detail
230
- }), [
231
- P.paymentRecords,
232
- Y.data,
233
- O?.currency,
234
- g.detail
235
- ]), Yt = o(() => {
236
- if (!f || !O) return;
237
- let e = Pe({
238
- payable: O,
239
- lineItems: T.lineItems,
240
- glCodeOptions: J,
241
- glCodeRosterAvailable: Rt,
242
- history: Kt,
243
- paymentHistory: Jt,
244
- approvalPolicy: K.view,
245
- labels: g.detail,
246
- hasScheduledPayment: P.hasScheduledPayment,
247
- rejection: X,
248
- payableAchInstructions: G.achInstructions,
249
- payableAchInstructionsReadable: I && !G.isError
250
- });
251
- return R.mode === "resolved" && R.summary ? {
252
- ...e,
253
- payTo: R.summary
254
- } : e;
255
- }, [
256
- P.hasScheduledPayment,
257
- K.view,
258
- I,
259
- g.detail,
260
- J,
261
- Rt,
262
- Kt,
263
- T.lineItems,
264
- O,
265
- G.achInstructions,
266
- G.isError,
267
- Jt,
268
- f,
269
- X,
270
- R.mode,
271
- R.summary
272
- ]), Xt = O?.source_of_payable_data === "ocr", Z = xt?.name, Zt = f ? Z ? g.viewTitle(Z) : g.readOnlyTitle : Z && (Xt || A) ? g.extractedTitle(Z) : g.newTitle, Qt = f && O?.created_at ? g.addedOn(e(O.created_at.slice(0, 10))) : void 0, Q = M.isDirty || R.hasUnsavedVendorChanges || !!V.stagedFile || V.isFileDeletionPending, $t = a(() => {
273
- if (f && R.isEditingPayTo) q(() => u(!1));
274
- else switch (Fe({
275
- isUnsavedPromptOpen: b,
276
- isLocked: j,
277
- isDirty: Q
278
- })) {
279
- case "dismiss-prompt":
280
- x(!1);
281
- return;
282
- case "prompt":
283
- x(!0);
284
- return;
285
- default: u(!1);
286
- }
287
- }, [
288
- Q,
289
- j,
290
- b,
291
- q,
292
- u,
293
- f,
294
- R.isEditingPayTo
295
- ]), en = a((e, t) => {
296
- if (!h) return;
297
- let n = () => h(e, t);
298
- f && R.isEditingPayTo ? q(n) : !j && Q ? S(n) : n();
299
- }, [
300
- S,
301
- Q,
302
- j,
303
- q,
304
- h,
305
- f,
306
- R.isEditingPayTo
307
- ]), tn = a(() => {
308
- R.isEditingPayTo ? q(m) : m?.();
309
- }, [
310
- q,
311
- m,
312
- R.isEditingPayTo
313
- ]), nn = a(() => {
314
- x(!1), u(!1);
315
- }, [u]), rn = Mt || R.mode === "creating", an = a(async () => {
316
- if (rn) return;
317
- let e = await V.saveDraft();
318
- x(!1), e && u(!1);
319
- }, [
320
- V,
321
- rn,
322
- u
323
- ]), $ = xe({
324
- payable: O,
325
- onOpenPayable: h ? en : void 0,
326
- onRemoved: () => u(!1),
327
- canManage: ct
328
- }), on = a((e) => {
329
- if (!(At || $.isBusy)) return e ? u(!0) : $t();
330
- }, [
331
- $.isBusy,
332
- At,
333
- $t,
334
- u
335
- ]), sn = $.isPossibleDuplicate, cn = !f && Xt && !Qe, ln = !f && !!X, un = ln || sn || cn ? /* @__PURE__ */ Ue(He, { children: [
336
- ln && X ? /* @__PURE__ */ c(ue, {
337
- ...X,
338
- labels: g.rejectedBanner
339
- }) : null,
340
- sn ? /* @__PURE__ */ c(le, {
341
- title: $.title,
342
- meta: $.meta,
343
- onNotADuplicate: $.onNotADuplicate,
344
- onRemoveBill: $.onRemoveBill,
345
- isActionDisabled: $.isBusy,
346
- rows: $.rows,
347
- isLoading: $.isLoadingRows,
348
- loadingRowCount: $.loadingRowCount,
349
- collapse: $.collapse,
350
- labels: $.removeBillLabel ? { removeBillButton: $.removeBillLabel } : void 0,
351
- testId: i.duplicateNotice
352
- }) : null,
353
- cn ? /* @__PURE__ */ c(fe, {
354
- onDismiss: () => $e(!0),
355
- labels: p?.extractionNotice
356
- }) : null
357
- ] }) : void 0;
358
- return /* @__PURE__ */ Ue(He, { children: [
359
- /* @__PURE__ */ c(ce, {
360
- open: l,
361
- onOpenChange: on,
362
- title: Zt,
363
- subtitle: Qt,
364
- notice: un,
365
- vendor: {
366
- ...B,
367
- testId: i.vendorSection
368
- },
369
- values: M.values,
370
- errors: M.errors,
371
- onChange: M.onChange,
372
- lineItems: {
373
- items: M.lineItemRows,
374
- glCodeOptions: J,
375
- glCodeDisabled: Lt,
376
- glCodeUnavailableMessage: It,
377
- discount: M.discount,
378
- onDiscountChange: M.onDiscountChange,
379
- onDiscountBlur: M.onDiscountBlur,
380
- tax: M.tax,
381
- onTaxChange: M.onTaxChange,
382
- onTaxBlur: M.onTaxBlur,
383
- total: M.total,
384
- onTotalChange: M.onTotalChange,
385
- onTotalBlur: M.onTotalBlur,
386
- onAddLineItem: M.onAddLineItem,
387
- errors: M.lineItemErrors,
388
- totalsErrors: M.totalsErrors,
389
- testId: i.lineItems
390
- },
391
- documentPanel: /* @__PURE__ */ c(Ie, {
392
- payableId: C,
393
- readOnly: j,
394
- isDocumentPending: !!C && !O?.file && (w.isLoading || O?.ocr_status === "processing"),
395
- file: O?.file ? {
396
- id: O.file.id,
397
- name: O.file.name,
398
- url: O.file.url,
399
- mimetype: O.file.mimetype
400
- } : void 0,
401
- staging: {
402
- stagedFile: V.stagedFile,
403
- onFileStaged: V.stageFile,
404
- onClearStagedFile: V.clearStagedFile,
405
- isSaving: vt
406
- },
407
- deletion: {
408
- isPending: V.isFileDeletionPending,
409
- onRequest: V.requestFileDeletion,
410
- onDetachNow: V.detachFileNow,
411
- isDeleting: V.isDeletingFile,
412
- hasFailed: V.hasFileDeletionFailed
413
- },
414
- labels: p?.sourceDocument
415
- }),
416
- menuItems: Ft,
417
- readOnly: j,
418
- detail: f ? {
419
- view: Yt,
420
- actions: Et,
421
- scheduledSummary: F ? g.scheduledSummary(F.label) : void 0,
422
- scheduledSummaryDate: F?.absoluteLabel,
423
- scheduledStatusLabel: F ? g.scheduledStatusBadge(F.label) : void 0,
424
- ...Ct,
425
- payTo: {
426
- onEdit: B.mode === "resolved" ? B.onEdit : void 0,
427
- paymentInstructions: O?.status === "paid" || O?.status === "canceled" ? void 0 : Ee(B.paymentInstructionsEditor, !!Yt?.payTo.hasPaymentInstructions),
428
- detailsWarning: B.detailsWarning,
429
- editForm: B.mode === "creating" ? B.newVendorForm : void 0
430
- },
431
- isLoading: Nt,
432
- isError: Pt,
433
- paymentHistoryError: P.isError || Y.isError,
434
- paymentHistoryLoading: P.isResolving || Y.isLoading,
435
- historyError: Y.isError,
436
- historyLoading: Y.isLoading || Gt,
437
- historyNamesError: qt
438
- } : void 0,
439
- isLineItemsLoading: Mt,
440
- isSaving: At || gt,
441
- isSavingDraft: V.isSavingDraft,
442
- isSubmitting: V.isFinalizing,
443
- onCancel: $t,
444
- onCollapse: f ? tn : void 0,
445
- onSaveDraft: V.saveDraft,
446
- onFinalize: V.finalize,
447
- scrollToErrorToken: V.scrollToErrorToken,
448
- showSubmit: !j && k,
449
- testId: i.dialog,
450
- labels: p?.screen
451
- }),
452
- /* @__PURE__ */ c(pe, {
453
- open: b,
454
- onSaveDraft: an,
455
- onDiscard: nn,
456
- onCancel: () => x(!1),
457
- isSaving: V.isSavingDraft,
458
- isSaveDraftDisabled: rn,
459
- labels: g.unsavedChanges,
460
- testId: i.unsavedDialog,
461
- saveDraftTestId: i.unsavedSaveDraft,
462
- discardTestId: i.unsavedDiscard,
463
- closeTestId: i.unsavedClose
464
- }),
465
- /* @__PURE__ */ c(de, {
466
- open: !!et,
467
- onDiscard: () => {
468
- let e = et;
469
- tt(void 0), e?.();
470
- },
471
- onKeepEditing: () => tt(void 0),
472
- labels: g.discardChanges,
473
- testId: i.discardDialog,
474
- discardTestId: i.discardConfirm
475
- }),
476
- /* @__PURE__ */ c(r, {
477
- ...Dt,
478
- labels: { cancelButton: g.actions.decisionDialog.cancelButton },
479
- testId: i.decisionDialog,
480
- confirmTestId: i.decisionConfirm,
481
- reasonTestId: i.decisionReason
482
- }),
483
- /* @__PURE__ */ c(r, {
484
- ...kt.dialog,
485
- labels: { cancelButton: g.actions.decisionDialog.cancelButton },
486
- testId: i.deleteDraftDialog,
487
- confirmTestId: i.deleteDraftConfirm
488
- }),
489
- /* @__PURE__ */ c(r, {
490
- open: $.removeConfirmation.open,
491
- copy: $.removeConfirmation.copy,
492
- onConfirm: $.removeConfirmation.onConfirm,
493
- onCancel: $.removeConfirmation.onCancel,
494
- isPending: $.removeConfirmation.isPending,
495
- confirmIcon: $.isRemoveBillDestructive ? /* @__PURE__ */ c(We, {}) : void 0,
496
- labels: { cancelButton: $.removeConfirmation.cancelButtonLabel },
497
- testId: i.duplicateRemoveDialog,
498
- confirmTestId: i.duplicateRemoveConfirm
499
- }),
500
- /* @__PURE__ */ c(r, {
501
- open: $.keepRowConfirmation.open,
502
- copy: $.keepRowConfirmation.copy,
503
- onConfirm: $.keepRowConfirmation.onConfirm,
504
- onCancel: $.keepRowConfirmation.onCancel,
505
- isPending: $.keepRowConfirmation.isPending,
506
- labels: { cancelButton: $.keepRowConfirmation.cancelButtonLabel }
507
- }),
508
- qe?.({
509
- ref: W,
510
- payable: O,
511
- payableId: H,
512
- isPayBillEnabled: f,
513
- hasScheduledPayment: P.hasScheduledPayment,
514
- onMissingAchInstructions: lt ? R.openPaymentInstructions : void 0,
515
- onMarkAsPaidPendingChange: bt
516
- })
517
- ] });
5
+ function n() {
6
+ return {
7
+ id: crypto.randomUUID(),
8
+ description: "",
9
+ glCode: "",
10
+ quantity: "1",
11
+ price: "",
12
+ amount: ""
13
+ };
518
14
  }
519
- export { l as BillDialog, l as default };
15
+ function r(e) {
16
+ return typeof e == "number" ? (e / 100).toFixed(2) : "";
17
+ }
18
+ function i(e) {
19
+ return typeof e == "string" ? e : "";
20
+ }
21
+ function a(e) {
22
+ return e.total_amount ?? e.amount_due ?? void 0;
23
+ }
24
+ function o({ payable: o, lineItems: s }) {
25
+ let c = {
26
+ invoiceNumber: o.document_id ?? "",
27
+ invoiceDate: o.issued_at ?? "",
28
+ dueDate: o.due_date ?? "",
29
+ poNumber: i(o.purchase_order_number)
30
+ }, l = s.map((n) => ({
31
+ id: n.id,
32
+ description: n.name ?? "",
33
+ glCode: n.ledger_account_id ?? "",
34
+ quantity: String(t(n)),
35
+ price: r(n.unit_price),
36
+ amount: r(e(n))
37
+ })), u = a(o);
38
+ return {
39
+ values: c,
40
+ lineItems: l.length ? l : [n()],
41
+ discount: r(o.discount),
42
+ tax: r(o.tax_amount),
43
+ total: u ? r(u) : ""
44
+ };
45
+ }
46
+ export { n as emptyLineItem, o as mapPayableToBillForm };