@tesouro/embedded-components-react 0.5.230 → 0.5.231

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 (104) hide show
  1. package/dist/index.css +10 -0
  2. package/dist/index.d.ts +22 -21
  3. package/dist/index.js +2 -2
  4. package/dist/lib/ExpenseManagementWidget.d.ts +22 -21
  5. package/dist/lib/ExpenseManagementWidget.js +1 -1
  6. package/dist/lib/UploadReceiptWidget.d.ts +2 -2
  7. package/dist/lib/UploadReceiptWidget.js +2 -2
  8. package/dist/lib/WidgetSuite.d.ts +17 -15
  9. package/dist/libs/tesouro-embedded-components-react/expense-management-widget/approval-policies/feature/dist/index.js +3 -0
  10. package/dist/libs/tesouro-embedded-components-react/expense-management-widget/approval-policies/feature/dist/index2.js +5 -0
  11. package/dist/libs/tesouro-embedded-components-react/expense-management-widget/{feature/dist/index24.js → approval-policies/feature/dist/index3.js} +7 -7
  12. package/dist/libs/tesouro-embedded-components-react/expense-management-widget/{feature/dist/index25.js → approval-policies/feature/dist/index4.js} +1 -1
  13. package/dist/libs/tesouro-embedded-components-react/expense-management-widget/{feature/dist/index26.js → approval-policies/feature/dist/index5.js} +1 -1
  14. package/dist/libs/tesouro-embedded-components-react/expense-management-widget/{feature/dist/index27.js → approval-policies/feature/dist/index6.js} +53 -53
  15. package/dist/libs/tesouro-embedded-components-react/expense-management-widget/approval-policies/ui/dist/index.js +8 -0
  16. package/dist/libs/tesouro-embedded-components-react/expense-management-widget/{ui/dist/lib/ExpenseApprovalPoliciesWidget/lib/types.js → approval-policies/ui/dist/index2.js} +1 -1
  17. package/dist/libs/tesouro-embedded-components-react/expense-management-widget/{ui/dist/lib/ExpenseApprovalPoliciesWidget/lib/labels.js → approval-policies/ui/dist/index3.js} +1 -1
  18. package/dist/libs/tesouro-embedded-components-react/expense-management-widget/{ui/dist/lib/ExpenseApprovalPoliciesWidget/lib/conditionLabel.js → approval-policies/ui/dist/index4.js} +1 -1
  19. package/dist/libs/tesouro-embedded-components-react/expense-management-widget/{ui/dist/lib/ExpenseApprovalPoliciesWidget/lib/EmptyApprovalRules.js → approval-policies/ui/dist/index5.js} +3 -3
  20. package/dist/libs/tesouro-embedded-components-react/expense-management-widget/{ui/dist/lib/ExpenseApprovalPoliciesWidget/lib/ApprovalRuleCard.js → approval-policies/ui/dist/index6.js} +5 -5
  21. package/dist/libs/tesouro-embedded-components-react/expense-management-widget/{ui/dist/lib/ExpenseApprovalPoliciesWidget/lib/ApprovalRuleForm.js → approval-policies/ui/dist/index7.js} +4 -4
  22. package/dist/libs/tesouro-embedded-components-react/expense-management-widget/{ui/dist/lib/ExpenseApprovalPoliciesWidget/lib/ExpenseApprovalsPage.js → approval-policies/ui/dist/index8.js} +7 -7
  23. package/dist/libs/tesouro-embedded-components-react/expense-management-widget/data-access/dist/index.js +18 -19
  24. package/dist/libs/tesouro-embedded-components-react/expense-management-widget/data-access/dist/invalidation.js +2 -0
  25. package/dist/libs/tesouro-embedded-components-react/expense-management-widget/data-access/dist/{index20.js → lib/invalidateTransactionViews.js} +4 -4
  26. package/dist/libs/tesouro-embedded-components-react/expense-management-widget/data-access/dist/{index10.js → lib/queryKeys.js} +4 -4
  27. package/dist/libs/tesouro-embedded-components-react/expense-management-widget/data-access/dist/{index5.js → lib/useEntityUsersByIdsQuery.js} +6 -6
  28. package/dist/libs/tesouro-embedded-components-react/expense-management-widget/data-access/dist/{index8.js → lib/useExpenseHistoryQuery.js} +6 -6
  29. package/dist/libs/tesouro-embedded-components-react/expense-management-widget/data-access/dist/{index7.js → lib/useExpenseLedgerAccountsQuery.js} +3 -3
  30. package/dist/libs/tesouro-embedded-components-react/expense-management-widget/data-access/dist/{index17.js → lib/useExpenseReceiptsCountQuery.js} +5 -5
  31. package/dist/libs/tesouro-embedded-components-react/expense-management-widget/data-access/dist/{index16.js → lib/useExpenseTransactionIdsQuery.js} +2 -2
  32. package/dist/libs/tesouro-embedded-components-react/expense-management-widget/data-access/dist/{index15.js → lib/useExpenseTransactionsCountQuery.js} +5 -5
  33. package/dist/libs/tesouro-embedded-components-react/expense-management-widget/data-access/dist/{index19.js → lib/useGetApprovalRequestsQuery.js} +5 -5
  34. package/dist/libs/tesouro-embedded-components-react/expense-management-widget/data-access/dist/{index9.js → lib/useGetTransactionQuery.js} +5 -5
  35. package/dist/libs/tesouro-embedded-components-react/expense-management-widget/data-access/dist/{index3.js → lib/useGetTransactionsQuery.js} +5 -5
  36. package/dist/libs/tesouro-embedded-components-react/expense-management-widget/data-access/dist/lib/useHasDirectReportsQuery.js +34 -0
  37. package/dist/libs/tesouro-embedded-components-react/expense-management-widget/data-access/dist/{index4.js → lib/useOrganizationDepartmentsQuery.js} +6 -6
  38. package/dist/libs/tesouro-embedded-components-react/expense-management-widget/data-access/dist/{index6.js → lib/useOrganizationLocationsQuery.js} +6 -6
  39. package/dist/libs/tesouro-embedded-components-react/expense-management-widget/data-access/dist/{index11.js → lib/usePatchReceiptMutation.js} +7 -7
  40. package/dist/libs/tesouro-embedded-components-react/expense-management-widget/data-access/dist/{index14.js → lib/useTrackReceiptMatching.js} +7 -7
  41. package/dist/libs/tesouro-embedded-components-react/expense-management-widget/data-access/dist/{index21.js → lib/useTransactionReviewMutations.js} +6 -6
  42. package/dist/libs/tesouro-embedded-components-react/expense-management-widget/data-access/dist/{index18.js → lib/useTransactionValidationsQuery.js} +5 -5
  43. package/dist/libs/tesouro-embedded-components-react/expense-management-widget/data-access/dist/{index13.js → lib/useUploadReceiptMutation.js} +7 -7
  44. package/dist/libs/tesouro-embedded-components-react/expense-management-widget/feature/dist/index.js +10 -10
  45. package/dist/libs/tesouro-embedded-components-react/expense-management-widget/feature/dist/index10.js +77 -160
  46. package/dist/libs/tesouro-embedded-components-react/expense-management-widget/feature/dist/index11.js +356 -63
  47. package/dist/libs/tesouro-embedded-components-react/expense-management-widget/feature/dist/index12.js +36 -71
  48. package/dist/libs/tesouro-embedded-components-react/expense-management-widget/feature/dist/index13.js +130 -344
  49. package/dist/libs/tesouro-embedded-components-react/expense-management-widget/feature/dist/index14.js +223 -36
  50. package/dist/libs/tesouro-embedded-components-react/expense-management-widget/feature/dist/index15.js +192 -137
  51. package/dist/libs/tesouro-embedded-components-react/expense-management-widget/feature/dist/index16.js +11 -227
  52. package/dist/libs/tesouro-embedded-components-react/expense-management-widget/feature/dist/index17.js +81 -186
  53. package/dist/libs/tesouro-embedded-components-react/expense-management-widget/feature/dist/index18.js +37 -11
  54. package/dist/libs/tesouro-embedded-components-react/expense-management-widget/feature/dist/index19.js +309 -82
  55. package/dist/libs/tesouro-embedded-components-react/expense-management-widget/feature/dist/index2.js +30 -87
  56. package/dist/libs/tesouro-embedded-components-react/expense-management-widget/feature/dist/index20.js +1 -39
  57. package/dist/libs/tesouro-embedded-components-react/expense-management-widget/feature/dist/index3.js +3 -2
  58. package/dist/libs/tesouro-embedded-components-react/expense-management-widget/feature/dist/index5.js +23 -257
  59. package/dist/libs/tesouro-embedded-components-react/expense-management-widget/feature/dist/index6.js +18 -2
  60. package/dist/libs/tesouro-embedded-components-react/expense-management-widget/feature/dist/index7.js +160 -59
  61. package/dist/libs/tesouro-embedded-components-react/expense-management-widget/feature/dist/index8.js +62 -28
  62. package/dist/libs/tesouro-embedded-components-react/expense-management-widget/feature/dist/index9.js +28 -18
  63. package/dist/libs/tesouro-embedded-components-react/expense-management-widget/receipt-match/data-access/dist/index.js +3 -0
  64. package/dist/libs/tesouro-embedded-components-react/expense-management-widget/{data-access → receipt-match/data-access}/dist/index2.js +5 -5
  65. package/dist/libs/tesouro-embedded-components-react/expense-management-widget/receipt-match/data-access/dist/index3.js +40 -0
  66. package/dist/libs/tesouro-embedded-components-react/expense-management-widget/receipt-match/feature/dist/index.js +2 -0
  67. package/dist/libs/tesouro-embedded-components-react/expense-management-widget/receipt-match/feature/dist/index2.js +256 -0
  68. package/dist/libs/tesouro-embedded-components-react/expense-management-widget/receipt-match/feature/dist/index3.js +5 -0
  69. package/dist/libs/tesouro-embedded-components-react/expense-management-widget/receipt-match/feature/dist/index4.js +65 -0
  70. package/dist/libs/tesouro-embedded-components-react/expense-management-widget/receipt-match/ui/dist/index.js +8 -0
  71. package/dist/libs/tesouro-embedded-components-react/expense-management-widget/{ui/dist/lib/ReceiptMatchWidget/lib/labels.js → receipt-match/ui/dist/index2.js} +1 -1
  72. package/dist/libs/tesouro-embedded-components-react/expense-management-widget/{ui/dist/lib/ReceiptMatchWidget/lib/ReceiptInboxItem.js → receipt-match/ui/dist/index3.js} +3 -3
  73. package/dist/libs/tesouro-embedded-components-react/expense-management-widget/{ui/dist/lib/ReceiptMatchWidget/lib/ReceiptInboxStep.js → receipt-match/ui/dist/index4.js} +6 -6
  74. package/dist/libs/tesouro-embedded-components-react/expense-management-widget/{ui/dist/lib/ReceiptMatchWidget/lib/TransactionsMatchStep.js → receipt-match/ui/dist/index5.js} +27 -27
  75. package/dist/libs/tesouro-embedded-components-react/expense-management-widget/{ui/dist/lib/ReceiptMatchWidget/lib/MatchConfirmationStep.js → receipt-match/ui/dist/index6.js} +3 -3
  76. package/dist/libs/tesouro-embedded-components-react/expense-management-widget/{ui/dist/lib/ReceiptMatchWidget/lib/ReceiptMatchSidebar.js → receipt-match/ui/dist/index7.js} +6 -6
  77. package/dist/libs/tesouro-embedded-components-react/expense-management-widget/{ui/dist/lib/ReceiptMatchWidget/lib/ReceiptMatchLauncher.js → receipt-match/ui/dist/index8.js} +1 -1
  78. package/dist/libs/tesouro-embedded-components-react/expense-management-widget/ui/dist/index.js +9 -28
  79. package/dist/libs/tesouro-embedded-components-react/expense-management-widget/ui/dist/lib/ExpenseStatusBadge/ExpenseStatusBadge.js +7 -12
  80. package/dist/libs/tesouro-embedded-components-react/expense-management-widget/ui/dist/lib/ExpenseStatusBadge/badgeTones.js +1 -7
  81. package/dist/libs/tesouro-embedded-components-react/expense-management-widget/ui/dist/lib/ExpensesScreen/ExpensesScreen.js +61 -55
  82. package/dist/libs/tesouro-embedded-components-react/expense-management-widget/ui/dist/lib/ExpensesScreen/labels.js +2 -1
  83. package/dist/libs/tesouro-embedded-components-react/expense-management-widget/ui/dist/lib/ExpensesTransactionsTable/ExpensesTransactionsTable.js +42 -44
  84. package/dist/libs/tesouro-embedded-components-react/expense-management-widget/ui/dist/lib/FileViewer/FileViewer.js +6 -6
  85. package/dist/libs/tesouro-embedded-components-react/expense-management-widget/ui/dist/lib/TransactionDetails/TransactionDetails.js +137 -138
  86. package/dist/libs/tesouro-embedded-components-react/expense-management-widget/ui/dist/lib/TransactionDetailsActions/TransactionDetailsActions.js +82 -80
  87. package/dist/libs/tesouro-embedded-components-react/expense-management-widget/{ui → util}/dist/lib/isPdf.js +1 -1
  88. package/dist/libs/tesouro-embedded-components-react/expense-management-widget/util/dist/lib/widgetName.js +4 -0
  89. package/dist/libs/tesouro-embedded-components-react/settings-widget/feature/dist/index5.js +1 -1
  90. package/dist/libs/tesouro-embedded-components-react/shared/feature/dist/lib/analytics/build-info.js +1 -1
  91. package/dist/libs/tesouro-embedded-components-react/shared/util/dist/lib/formatTimestampDate.js +13 -0
  92. package/dist/libs/tesouro-embedded-components-react/upload-receipt-widget/feature/dist/index.js +4 -0
  93. package/dist/libs/tesouro-embedded-components-react/upload-receipt-widget/feature/dist/index2.js +91 -0
  94. package/dist/libs/tesouro-embedded-components-react/upload-receipt-widget/ui/dist/index.js +4 -0
  95. package/dist/libs/tesouro-embedded-components-react/{expense-management-widget/ui/dist/lib/UploadReceiptWidget/labels.js → upload-receipt-widget/ui/dist/index2.js} +1 -1
  96. package/dist/libs/tesouro-embedded-components-react/{expense-management-widget/ui/dist/lib/UploadReceiptWidget/UploadReceiptButton.js → upload-receipt-widget/ui/dist/index3.js} +3 -3
  97. package/dist/libs/tesouro-embedded-components-react/{expense-management-widget/ui/dist/lib/UploadReceiptWidget/UploadReceiptModal.js → upload-receipt-widget/ui/dist/index4.js} +3 -3
  98. package/dist/libs/tesouro-embedded-components-react/widget-suite/feature/dist/index11.js +1 -1
  99. package/package.json +1 -1
  100. package/dist/libs/tesouro-embedded-components-react/expense-management-widget/data-access/dist/index12.js +0 -39
  101. package/dist/libs/tesouro-embedded-components-react/expense-management-widget/feature/dist/index21.js +0 -297
  102. package/dist/libs/tesouro-embedded-components-react/expense-management-widget/feature/dist/index22.js +0 -1
  103. package/dist/libs/tesouro-embedded-components-react/expense-management-widget/feature/dist/index23.js +0 -4
  104. package/dist/libs/tesouro-embedded-components-react/expense-management-widget/ui/dist/lib/ExpenseStatusBadge/labels.js +0 -13
@@ -1,166 +1,83 @@
1
+ "use client";
2
+ "use client";
3
+ "use client";
4
+ "use client";
5
+ import { buildFooterActions as e } from "./index9.js";
6
+ import { TRANSACTION_DETAILS_ACTIONS_LABELS_EN as t } from "../../ui/dist/lib/TransactionDetailsActions/labels.js";
7
+ import { TransactionDetailsActions as n } from "../../ui/dist/lib/TransactionDetailsActions/TransactionDetailsActions.js";
8
+ import "../../ui/dist/index.js";
9
+ import { useApproveApprovalRequestMutation as r, useApproveTransactionMutation as i, useRejectApprovalRequestMutation as a, useRejectTransactionMutation as o, useReopenTransactionMutation as s, useSubmitTransactionMutation as c } from "../../data-access/dist/lib/useTransactionReviewMutations.js";
10
+ import "../../data-access/dist/index.js";
11
+ import { useState as l } from "react";
12
+ import { jsx as u } from "react/jsx-runtime";
1
13
  //#region ../../libs/tesouro-embedded-components-react/expense-management-widget/feature/dist/index10.js
2
- var e = /* @__PURE__ */ new Set(["approve", "approved"]), t = /* @__PURE__ */ new Set(["reject", "rejected"]);
3
- function n(e) {
4
- return typeof e == "string" && e ? e : void 0;
5
- }
6
- function r(e) {
7
- return !!(e && e !== "user");
8
- }
9
- function i(e, t) {
10
- return e.recorded_by === "system" || !e.entity_user_id ? void 0 : t.get(e.entity_user_id) || [e.entity_user_first_name, e.entity_user_last_name].filter(Boolean).join(" ") || void 0;
11
- }
12
- function a(e, t) {
13
- let r = n(e.no_receipt_reason);
14
- return r ? t.quotedReason(r) : e.bypass_receipt_validation ? t.submittedWithoutReceipt : void 0;
15
- }
16
- function o(e, t, r) {
17
- let i = d(e);
18
- if (!i) return;
19
- let a = t.approval_source === "force", o;
20
- o = i === "approved" ? a ? r.policyOverrideApproved : r.approved : a ? r.policyOverrideRejected : r.rejected;
21
- let s = n(t.reject_reason);
22
- return {
23
- title: o,
24
- meta: s ? r.quotedReason(s) : void 0
25
- };
26
- }
27
- function s(e, t) {
28
- let r = n(e.new_status);
29
- if (!r) return;
30
- let i = n(e.old_status), a = t.paymentStatusLabel(r);
31
- return i ? t.changedFromTo(t.paymentStatusLabel(i), a) : t.changedTo(a);
32
- }
33
- function c(e, t) {
34
- let i = e.event_data ?? {};
35
- switch (e.event_type) {
36
- case "expense_created": {
37
- let e = n(i.created_via);
38
- return {
39
- title: t.expenseCreated,
40
- meta: e ? e === "feed" ? t.createdFromFeed : t.createdManually : void 0
41
- };
42
- }
43
- case "expense_updated": return { title: t.expenseUpdated };
44
- case "status_changed": {
45
- let e = n(i.new_status);
46
- if (!e) return { title: t.statusUpdated };
47
- let r = t.statusLabel(e), a = n(i.reject_reason);
48
- return {
49
- title: t.statusUpdated,
50
- meta: a ? t.withReason(t.changedTo(r), a) : t.changedTo(r)
51
- };
52
- }
53
- case "submitted": return {
54
- title: t.submittedForApproval,
55
- meta: a(i, t)
56
- };
57
- case "approval_requested": return { title: t.approvalRequested };
58
- case "approval_action": return o(e, i, t);
59
- case "auto_approved": return {
60
- title: t.approvedAutomatically,
61
- titleActor: "none"
62
- };
63
- case "reopened": return { title: t.reopened };
64
- case "canceled": return { title: t.cancelled };
65
- case "deleted": return { title: t.deleted };
66
- case "receipt_matched": {
67
- let e = r(n(i.link_source));
68
- return {
69
- title: t.receiptMatched,
70
- meta: e ? t.matchedAutomatically : t.matchedManually,
71
- titleActor: e ? "none" : void 0
72
- };
14
+ function d({ transactionId: d, status: f, approvalRequestId: p, canUseApprovalRequestActions: m, canUseForceActions: h, canWrite: g, hasOnlyViewPermission: _, isDisabled: v, showNoReceiptField: y, isBulkMode: b, currentItem: x, totalItems: S, onCompleted: C, onClose: w, onPendingChange: T, labels: E }) {
15
+ let [D, O] = l(!1), [k, A] = l(""), [j, M] = l(!1), N = i(), P = o(), F = r(), I = a(), L = c(), R = s(), z = N.isPending || P.isPending || F.isPending || I.isPending || L.isPending || R.isPending, B = async (e) => {
16
+ M(!1), T?.(!0);
17
+ try {
18
+ await e(), C();
19
+ } catch {
20
+ M(!0);
21
+ } finally {
22
+ T?.(!1);
73
23
  }
74
- case "receipt_unlinked": return { title: t.receiptRemoved };
75
- case "auto_categorized": return {
76
- title: t.categorizedAutomatically,
77
- titleActor: "none"
78
- };
79
- case "payment_status_changed": return {
80
- title: t.paymentStatusUpdated,
81
- meta: s(i, t)
82
- };
83
- default: return;
84
- }
85
- }
86
- var l = (e, t) => e.at - t.at || e.id.localeCompare(t.id);
87
- function u(e) {
88
- return n((e.event_data ?? {}).acted_at);
89
- }
90
- function d(n) {
91
- let r = (n.event_data ?? {}).action;
92
- if (e.has(r)) return "approved";
93
- if (t.has(r)) return "rejected";
94
- }
95
- function f(e) {
96
- let t = /* @__PURE__ */ new Set(), r = /* @__PURE__ */ new Set();
97
- for (let t of e) {
98
- if (t.event_type !== "auto_approved") continue;
99
- let e = u(t);
100
- e && r.add(e);
101
- }
102
- let i = e.filter((e) => e.event_type === "reopened").map((e) => Date.parse(e.timestamp)).sort((e, t) => e - t), a = (e) => i.filter((t) => t <= e).length, o = [], s = [];
103
- for (let i of e) {
104
- let e = Date.parse(i.timestamp), c = a(e);
105
- if (i.event_type === "auto_approved") {
106
- o.push({
107
- id: i.id,
108
- outcome: "approved",
109
- at: e,
110
- round: c
111
- });
112
- continue;
113
- }
114
- if (i.event_type === "approval_action") {
115
- let n = d(i);
116
- if (!n) continue;
117
- let a = u(i);
118
- if (n === "approved" && !i.entity_user_id && a && r.has(a)) {
119
- t.add(i.id);
120
- continue;
121
- }
122
- o.push({
123
- id: i.id,
124
- outcome: n,
125
- at: e,
126
- round: c
127
- });
128
- continue;
129
- }
130
- if (i.event_type !== "status_changed") continue;
131
- let l = i.event_data ?? {};
132
- if (n(l.migrated_action)) continue;
133
- let f = n(l.new_status);
134
- (f === "approved" || f === "rejected") && s.push({
135
- id: i.id,
136
- outcome: f,
137
- at: e,
138
- round: c
24
+ }, V = y ? {
25
+ bypass_receipt_validation: !0,
26
+ no_receipt_reason: k
27
+ } : void 0, H = () => B(() => m && p ? F.mutateAsync({
28
+ transactionId: d,
29
+ approvalRequestId: p
30
+ }) : N.mutateAsync({ transactionId: d })), U = () => B(() => m && p ? I.mutateAsync({
31
+ transactionId: d,
32
+ approvalRequestId: p,
33
+ rejectReason: k
34
+ }) : P.mutateAsync({
35
+ transactionId: d,
36
+ rejectReason: k
37
+ })), W = () => B(() => L.mutateAsync({
38
+ transactionId: d,
39
+ body: V
40
+ })), G = () => B(async () => {
41
+ await R.mutateAsync({ transactionId: d }), await L.mutateAsync({
42
+ transactionId: d,
43
+ body: V
139
44
  });
140
- }
141
- o.sort(l), s.sort(l);
142
- for (let e of o) {
143
- let n = -1;
144
- for (let t = 0; t < s.length; t += 1) s[t].outcome === e.outcome && s[t].round === e.round && (n < 0 || Math.abs(s[t].at - e.at) < Math.abs(s[n].at - e.at)) && (n = t);
145
- n >= 0 && t.add(s.splice(n, 1)[0].id);
146
- }
147
- return t;
148
- }
149
- function p(e, t, n) {
150
- let r = f(e);
151
- return e.flatMap((e) => {
152
- if (r.has(e.id)) return [];
153
- let a = c(e, n);
154
- if (!a) return [];
155
- let o = a.titleActor === "none" ? void 0 : i(e, t);
156
- return [{
157
- id: e.id,
158
- dateLabel: n.dateLabel(e.timestamp),
159
- timeLabel: n.timeLabel(e.timestamp),
160
- title: o ? n.byActor(a.title, o) : a.title,
161
- meta: a.meta
162
- }];
45
+ }), K = e({
46
+ status: f,
47
+ canWrite: g,
48
+ canApprove: m || h,
49
+ hasOnlyViewPermission: _,
50
+ showReviewNextLabels: b && x < S,
51
+ labels: {
52
+ ...t,
53
+ ...E
54
+ },
55
+ onSubmit: W,
56
+ onReopen: G,
57
+ onApprove: H,
58
+ onReject: U,
59
+ onToggleRejectMode: () => {
60
+ O((e) => !e), A("");
61
+ }
62
+ });
63
+ return /* @__PURE__ */ u(n, {
64
+ actions: K,
65
+ onClose: w,
66
+ isLoading: z,
67
+ isRejectMode: D,
68
+ reasonValue: k,
69
+ onReasonChange: (e) => A(e.target.value),
70
+ isSubmitDisabled: z || v || y && !k,
71
+ isConfirmRejectionDisabled: z || !k,
72
+ showNoReceiptField: y,
73
+ showNoReceiptRequiredMarker: y,
74
+ isBulkMode: b,
75
+ currentItem: x,
76
+ totalItems: S,
77
+ percentComplete: S > 0 ? Math.round(x / S * 100) : 0,
78
+ hasActionError: j,
79
+ labels: E
163
80
  });
164
81
  }
165
82
  //#endregion
166
- export { p as buildExpenseAuditHistory };
83
+ export { d as TransactionDetailsActionsFeature, d as default };
@@ -1,67 +1,360 @@
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 { formatTimestampDate as t } from "../../../shared/util/dist/lib/formatTimestampDate.js";
7
+ import { formatMoneyExact as n } from "../../../shared/util/dist/lib/formatMoneyExact.js";
8
+ import { hasAnyScope as r } from "../../../shared/data-access/dist/lib/hasAnyScope.js";
9
+ import { Scope as i } from "../../../shared/data-access/dist/lib/scopes.js";
10
+ import "../../../shared/data-access/dist/index.js";
11
+ import "../../../shared/ui/dist/index.js";
12
+ import { useWidgetConfig as ee } from "../../../shared/feature/dist/lib/WidgetProvider/hooks.js";
13
+ import "../../../shared/feature/dist/index.js";
14
+ import { ApprovalPolicyObjectType as te } from "../../../shared/approval-policy/data-access/dist/lib/queryKeys.js";
15
+ import { useGetApprovalPoliciesQuery as ne } from "../../../shared/approval-policy/data-access/dist/lib/approvalPoliciesApi.js";
16
+ import "../../../shared/approval-policy/data-access/dist/index.js";
17
+ import { EXPENSE_STATUS_BADGE_LABELS_EN as re, resolveExpenseStatusBadge as ie, toExpenseDisplayStatus as ae } from "./index2.js";
18
+ import { TRANSACTION_DETAILS_FEATURE_LABELS_EN as oe } from "./index6.js";
19
+ import { TransactionDetails as se } from "../../ui/dist/lib/TransactionDetails/TransactionDetails.js";
20
+ import { DeleteReceiptDialog as ce } from "../../ui/dist/lib/TransactionDetails/DeleteReceiptDialog/DeleteReceiptDialog.js";
21
+ import "../../ui/dist/index.js";
22
+ import { useOrganizationDepartmentsQuery as le } from "../../data-access/dist/lib/useOrganizationDepartmentsQuery.js";
23
+ import { useEntityUsersByIdsQuery as ue } from "../../data-access/dist/lib/useEntityUsersByIdsQuery.js";
24
+ import { useOrganizationLocationsQuery as de } from "../../data-access/dist/lib/useOrganizationLocationsQuery.js";
25
+ import { useExpenseLedgerAccountsQuery as fe } from "../../data-access/dist/lib/useExpenseLedgerAccountsQuery.js";
26
+ import { useExpenseHistoryQuery as pe } from "../../data-access/dist/lib/useExpenseHistoryQuery.js";
27
+ import { useGetTransactionQuery as me } from "../../data-access/dist/lib/useGetTransactionQuery.js";
28
+ import { usePatchReceiptMutation as he } from "../../data-access/dist/lib/usePatchReceiptMutation.js";
29
+ import { useUploadReceiptMutation as ge } from "../../data-access/dist/lib/useUploadReceiptMutation.js";
30
+ import { useTransactionValidationsQuery as _e } from "../../data-access/dist/lib/useTransactionValidationsQuery.js";
31
+ import { useGetApprovalRequestsQuery as ve } from "../../data-access/dist/lib/useGetApprovalRequestsQuery.js";
32
+ import { useUpdateTransactionMutation as ye } from "../../data-access/dist/lib/useTransactionReviewMutations.js";
33
+ import "../../data-access/dist/index.js";
34
+ import { TransactionDetailsActionsFeature as be } from "./index10.js";
35
+ import { entityUserLabel as xe } from "./index4.js";
36
+ import { canApproveExpenses as Se, canWriteExpenses as Ce, isExpenseAdmin as we } from "./index5.js";
37
+ import { buildExpenseAuditHistory as Te } from "./index7.js";
38
+ import { EXPENSE_AUDIT_HISTORY_LABELS_EN as Ee } from "./index8.js";
39
+ import { ReceiptMatchWidget as De } from "../../receipt-match/feature/dist/index4.js";
40
+ import "../../receipt-match/feature/dist/index.js";
41
+ import { useMemo as Oe, useRef as ke, useState as a } from "react";
42
+ import { Fragment as Ae, jsx as o, jsxs as je } from "react/jsx-runtime";
1
43
  //#region ../../libs/tesouro-embedded-components-react/expense-management-widget/feature/dist/index11.js
2
- var e = {
3
- new: "New",
4
- approve_in_progress: "In review",
5
- approved: "Approved",
6
- rejected: "Rejected",
7
- canceled: "Canceled",
8
- deleted: "Deleted"
9
- }, t = {
10
- created: "Created",
11
- processing: "Processing",
12
- succeeded: "Succeeded",
13
- declined: "Declined",
14
- refunded: "Refunded",
15
- failed: "Failed"
16
- }, n = (e, t) => Object.hasOwn(e, t) ? e[t] : "Unknown";
17
- function r(e) {
18
- let t = new Date(e);
19
- return Number.isNaN(t.getTime()) ? e : t.toLocaleDateString("en-US", {
20
- month: "short",
21
- day: "numeric",
22
- year: "numeric"
23
- });
44
+ var Me = "—", Ne = /* @__PURE__ */ new Map(), s = "__none__";
45
+ function c(e) {
46
+ return e === s ? null : e;
24
47
  }
25
- function i(e) {
26
- let t = new Date(e);
27
- return Number.isNaN(t.getTime()) ? "" : t.toLocaleTimeString("en-US", {
28
- hour: "numeric",
29
- minute: "2-digit",
30
- timeZoneName: "short"
31
- });
48
+ function l(e) {
49
+ return !!(e && e !== "user");
50
+ }
51
+ function Pe(e) {
52
+ if (!e || typeof e != "object" || !("all" in e)) return {};
53
+ let t = e.all, n, r;
54
+ for (let e of t ?? []) {
55
+ if (!e || typeof e != "object" || !("operator" in e)) continue;
56
+ let t = e;
57
+ if (t.left_operand?.name !== "transaction.amount") continue;
58
+ let i = Number(t.right_operand);
59
+ Number.isFinite(i) && (t.operator === ">=" && (n = i), (t.operator === "<" || t.operator === "<=") && (r = i));
60
+ }
61
+ return {
62
+ greaterThanCents: n,
63
+ lessThanCents: r
64
+ };
65
+ }
66
+ function Fe(e) {
67
+ for (let t of e ?? []) {
68
+ let e = t.event_data;
69
+ if (!e || typeof e != "object") continue;
70
+ let n = e, r = [t.entity_user_first_name, t.entity_user_last_name].filter((e) => !!e?.trim()).join(" ") || void 0;
71
+ if (t.event_type === "approval_action") {
72
+ let e = n.approval_source === "policy" && !n.approval_request_id, t = n.approval_source;
73
+ return {
74
+ source: e ? "auto" : typeof t == "string" ? t : void 0,
75
+ approverName: r
76
+ };
77
+ }
78
+ if (t.event_type === "status_changed" && n.approval_source != null) {
79
+ let e = n.approval_source;
80
+ return {
81
+ source: typeof e == "string" ? e : void 0,
82
+ approverName: r
83
+ };
84
+ }
85
+ }
86
+ return {};
87
+ }
88
+ function Ie(e) {
89
+ return e && "required_approval_count" in e && typeof e.required_approval_count == "number" ? e.required_approval_count : 0;
90
+ }
91
+ function Le(e) {
92
+ for (let t of e ?? []) {
93
+ if (t.event_type !== "approval_action") continue;
94
+ let e = t.event_data;
95
+ if (!e || typeof e != "object" || !("approval_policy_name" in e)) continue;
96
+ let n = e.approval_policy_name;
97
+ if (typeof n == "string" && n) return n;
98
+ }
99
+ }
100
+ var Re = ".pdf,.png,.jpg,.jpeg,.gif,.svg";
101
+ function u(e, t, n) {
102
+ let r = e.find((e) => e.field === t);
103
+ return r != null && (r.amount_threshold == null || n >= r.amount_threshold);
104
+ }
105
+ function d({ open: d, onClose: ze, selectedTransactionId: Be, actionItemIds: Ve, cardholderByUserId: f, labels: He, detailsLabels: Ue, cardLabels: We, actionsLabels: Ge, statusBadgeLabels: Ke, fileViewerLabels: qe }) {
106
+ let p = {
107
+ ...oe,
108
+ ...He
109
+ }, [m, h] = a(0), [Je, Ye] = a(!1), [Xe, g] = a(null), [Ze, _] = a(null), [Qe, v] = a(null), [$e, y] = a(!1), [et, b] = a(null), tt = ke(null), x = Ve ?? [], nt = x.length > 1, S = x.length > 0 ? x[m] ?? "" : Be ?? "", { initResponse: rt } = ee(), it = rt?.userId ?? "", C = rt?.scopes, w = we(C), T = Ce(C), at = Se(C), ot = r(C, [i.ApprovalRequestUpdateOrg]), st = !T && !ot && !at, E = me({ transactionId: d ? S : void 0 }), D = E.data, O = D?.applied_policy_id || void 0, k = ne({
110
+ objectType: te.Transaction,
111
+ enabled: d && !!O
112
+ }).data?.data?.find((e) => e.id === O), A = ve({ transactionId: d ? S : void 0 }), j = A.latestRequest, M = _e({ enabled: d }), N = ye(), ct = ge(), P = he(), lt = le({ enabled: d && w }), ut = de({ enabled: d && w }), dt = fe({ enabled: d && w }), F = pe({
113
+ transactionId: d ? S : void 0,
114
+ enabled: d
115
+ }), I = ae(D?.expense_status), L = ie(I, !!D?.has_validation_errors, {
116
+ ...re,
117
+ ...Ke
118
+ }), R = D?.merchant_amount ?? 0, z = D?.description ?? "", B = Xe?.transactionId === S ? Xe.value : z, V = u(M.requiredFields, "description", R), H = u(M.requiredFields, "receipt_id", R), U = D?.receipt_file_url ?? "", ft = j?.caller_is_policy_approver ?? !1, pt = !!(it && j?.approved_by?.includes(it)), mt = ft && !pt, ht = at && !ft, gt = w || I === "new" || I === "rejected", _t = D?.payment_method, W = _t?.type === "card" ? _t.details : null, vt = W ? p.cardLabel(W.card_type === "debit" ? p.debitCard : p.creditCard, W.last4 ?? "") : Me, G = D?.entity_user_id ?? "", yt = Oe(() => G ? [G] : [], [G]), bt = ue({
119
+ ids: yt,
120
+ enabled: d && yt.length > 0
121
+ }).data?.data?.find((e) => e.id === G), xt = bt ? xe(bt) : f?.get(G) ?? Me, St = !!S && (E.isPending || A.isPending || M.isPending), Ct = () => {
122
+ if (nt && m < x.length - 1) {
123
+ h((e) => e + 1);
124
+ return;
125
+ }
126
+ K();
127
+ }, K = () => {
128
+ h(0), g(null), _(null), v(null), b(null), ze();
129
+ }, q = T && gt, J = Ze?.transactionId === S && Ze.value, Y = D?.receipt_id, wt = D?.ledger_account_id || s, X = D?.department_id || s, Tt = D?.location_id || s, Z = et?.transactionId === S ? et : {
130
+ transactionId: S,
131
+ glCategory: wt,
132
+ department: X,
133
+ location: Tt
134
+ }, Et = [{
135
+ value: s,
136
+ label: p.glCategoryUncategorized
137
+ }, ...(dt.data?.data ?? []).map((e) => ({
138
+ value: e.id,
139
+ label: e.name ?? ""
140
+ }))], Dt = [{
141
+ value: s,
142
+ label: p.accountingNone
143
+ }, ...(lt.data?.data ?? []).map((e) => ({
144
+ value: e.id,
145
+ label: e.name
146
+ }))], Ot = [{
147
+ value: s,
148
+ label: p.accountingNone
149
+ }, ...(ut.data?.data ?? []).map((e) => ({
150
+ value: e.id,
151
+ label: e.name
152
+ }))], kt = Oe(() => {
153
+ let e = (F.data?.data ?? []).map((e) => ({
154
+ id: e.id,
155
+ event_type: e.event_type,
156
+ event_data: e.event_data,
157
+ timestamp: e.timestamp,
158
+ entity_user_id: e.entity_user_id,
159
+ entity_user_first_name: e.entity_user_first_name,
160
+ entity_user_last_name: e.entity_user_last_name,
161
+ recorded_by: e.recorded_by
162
+ }));
163
+ return Te(e, f ?? Ne, Ee);
164
+ }, [F.data, f]), At = async (t) => {
165
+ try {
166
+ let e = await ct.mutateAsync({ body: { file: t } });
167
+ if (!e.id) throw Error("Receipt upload returned no id");
168
+ await P.mutateAsync({
169
+ path: { receipt_id: e.id },
170
+ body: { transaction_id: S }
171
+ }), _({
172
+ transactionId: S,
173
+ value: !1
174
+ });
175
+ } catch {
176
+ e.error(p.receiptUploadFailed);
177
+ }
178
+ }, jt = async () => {
179
+ if (Y) try {
180
+ await P.mutateAsync({
181
+ path: { receipt_id: Y },
182
+ body: { transaction_id: null },
183
+ previousTransactionId: S
184
+ });
185
+ } catch {
186
+ e.error(p.receiptDeleteFailed);
187
+ } finally {
188
+ y(!1);
189
+ }
190
+ }, Q = Pe(k?.trigger), Mt = Q.greaterThanCents == null ? void 0 : n(Q.greaterThanCents / 100, {
191
+ currencyCode: D?.merchant_currency,
192
+ includeSpaceAfterCurrencySymbol: !1
193
+ }), Nt = Q.lessThanCents == null ? void 0 : n(Q.lessThanCents / 100, {
194
+ currencyCode: D?.merchant_currency,
195
+ includeSpaceAfterCurrencySymbol: !1
196
+ }), Pt = I === "approved" || I === "rejected" ? F.data?.data : void 0, Ft = Le(Pt), $ = Fe(Pt), It = Ie(j), Lt = I === "approved" && ($.source ? $.source === "auto" : It === 0), Rt = I === "approved" && ($.source ? $.source !== "auto" : It > 0), zt = Ft ?? (Mt || Nt ? void 0 : k?.name);
197
+ return /* @__PURE__ */ je(Ae, { children: [
198
+ /* @__PURE__ */ o("input", {
199
+ ref: tt,
200
+ type: "file",
201
+ accept: Re,
202
+ className: "ttw:hidden",
203
+ "aria-hidden": !0,
204
+ tabIndex: -1,
205
+ onChange: (e) => {
206
+ let t = e.target.files?.[0];
207
+ e.target.value = "", t && At(t);
208
+ }
209
+ }),
210
+ /* @__PURE__ */ o(se, {
211
+ open: d,
212
+ onClose: K,
213
+ transactionId: S,
214
+ transactionDate: t(D?.started_at, { month: "long" }),
215
+ statusLabel: L.label,
216
+ statusTone: L.tone,
217
+ isRejected: I === "rejected",
218
+ isPendingReview: I === "approve_in_progress",
219
+ amount: n(Math.abs(R) / 100, {
220
+ currencyCode: D?.merchant_currency,
221
+ includeSpaceAfterCurrencySymbol: !1
222
+ }),
223
+ merchant: D?.merchant_name ?? "",
224
+ receiptUrl: U,
225
+ isLoading: St,
226
+ isError: E.isError,
227
+ isClosingDisabled: Je,
228
+ cardLabel: vt,
229
+ cardName: W ? p.travelCard : void 0,
230
+ cardholder: xt,
231
+ showCardholder: !!G,
232
+ showPhysicalPill: !!W,
233
+ isDescriptionRequired: V,
234
+ isReceiptRequired: H,
235
+ isReceiptAutoMatched: D?.source_of_data?.receipt_id === "automatched",
236
+ isReceiptActionDisabled: !q && !U,
237
+ receiptButtonLabel: U ? p.receiptAttached : J ? p.receiptSubmitWithout : q ? p.receiptAttach : p.receiptMissing,
238
+ receiptButtonIcon: U ? "receipt" : J ? "send" : "paperclip",
239
+ receiptButtonVariant: U ? "ghost" : "outline",
240
+ showNoReceiptWarning: H && !U && J,
241
+ onUploadClick: q && !U ? () => tt.current?.click() : void 0,
242
+ onFileDrop: q && !U ? (e) => void At(e) : void 0,
243
+ onOpenReceiptInbox: q && !U ? () => v(S) : void 0,
244
+ onSubmitWithoutReceipt: q && !U ? () => _({
245
+ transactionId: S,
246
+ value: !0
247
+ }) : void 0,
248
+ onDeleteReceiptClick: q && Y ? () => y(!0) : void 0,
249
+ isUploading: ct.isPending || P.isPending,
250
+ descriptionValue: B,
251
+ initialDescriptionValue: z,
252
+ onDescriptionChange: (e) => g({
253
+ transactionId: S,
254
+ value: e.target.value
255
+ }),
256
+ onSaveDescription: () => {
257
+ N.mutateAsync({
258
+ transactionId: S,
259
+ body: { description: B || null }
260
+ }).then(() => g(null)).catch(() => {
261
+ e.error(p.memoSaveFailed);
262
+ });
263
+ },
264
+ onCancelDescription: () => g(null),
265
+ isSavingDescription: N.isPending,
266
+ isMemoEditable: T && gt,
267
+ memoBadgeLabel: D?.source_of_data?.description === "generated" ? p.memoAiAssigned : void 0,
268
+ showApprovalCard: I !== "new",
269
+ isAutoApproved: Lt,
270
+ isManuallyApproved: Rt,
271
+ approverName: $.approverName,
272
+ rejectionReason: D?.reject_reason ?? void 0,
273
+ hasAppliedPolicy: !!O,
274
+ greaterThanValue: Mt,
275
+ lessThanValue: Nt,
276
+ ruleLabel: zt,
277
+ showAccountingCard: w,
278
+ glCategory: Z.glCategory,
279
+ initialGlCategory: wt,
280
+ glCategoryOptions: Et,
281
+ onGlCategoryChange: (e) => b({
282
+ ...Z,
283
+ glCategory: e
284
+ }),
285
+ department: Z.department,
286
+ initialDepartment: X,
287
+ departmentOptions: Dt,
288
+ onDepartmentChange: (e) => b({
289
+ ...Z,
290
+ department: e
291
+ }),
292
+ location: Z.location,
293
+ initialLocation: Tt,
294
+ locationOptions: Ot,
295
+ onLocationChange: (e) => b({
296
+ ...Z,
297
+ location: e
298
+ }),
299
+ onSaveAccounting: () => {
300
+ N.mutateAsync({
301
+ transactionId: S,
302
+ body: {
303
+ ledger_account_id: c(Z.glCategory),
304
+ department_id: c(Z.department),
305
+ location_id: c(Z.location)
306
+ }
307
+ }).then(() => b(null)).catch(() => {
308
+ e.error(p.accountingSaveFailed);
309
+ });
310
+ },
311
+ onCancelAccounting: () => b(null),
312
+ isSavingAccounting: N.isPending,
313
+ glCategoryHighlight: l(D?.source_of_data?.ledger_account_id),
314
+ departmentHighlight: l(D?.source_of_data?.department_id),
315
+ locationHighlight: l(D?.source_of_data?.location_id),
316
+ showAuditHistoryCard: !0,
317
+ auditHistoryRows: kt,
318
+ isLoadingAuditHistory: F.isPending,
319
+ isAuditHistoryError: F.isError,
320
+ labels: Ue,
321
+ cardLabels: We,
322
+ fileViewerLabels: qe,
323
+ children: D && !E.isError ? /* @__PURE__ */ o(be, {
324
+ transactionId: S,
325
+ status: I,
326
+ approvalRequestId: j?.id,
327
+ canUseApprovalRequestActions: mt,
328
+ canUseForceActions: ht,
329
+ canWrite: T,
330
+ hasOnlyViewPermission: st,
331
+ isDisabled: V && !z,
332
+ showNoReceiptField: H && !U && I !== "approved",
333
+ isBulkMode: nt,
334
+ currentItem: m + 1,
335
+ totalItems: x.length,
336
+ onCompleted: Ct,
337
+ onClose: K,
338
+ onPendingChange: Ye,
339
+ labels: Ge
340
+ }, S) : null
341
+ }),
342
+ Qe && /* @__PURE__ */ o(De, {
343
+ isOpen: !0,
344
+ targetTransactionId: Qe,
345
+ onClose: () => v(null),
346
+ onSingleTransactionUpdate: () => {
347
+ E.refetch();
348
+ }
349
+ }),
350
+ /* @__PURE__ */ o(ce, {
351
+ open: $e,
352
+ onOpenChange: y,
353
+ isRemoving: P.isPending,
354
+ onConfirm: () => void jt(),
355
+ onCancel: () => y(!1)
356
+ })
357
+ ] });
32
358
  }
33
- var a = {
34
- dateLabel: r,
35
- timeLabel: i,
36
- byActor: (e, t) => `${e} by ${t}`,
37
- statusLabel: (t) => n(e, t),
38
- paymentStatusLabel: (e) => n(t, e),
39
- expenseCreated: "Expense created",
40
- createdFromFeed: "Imported from the card feed",
41
- createdManually: "Data entered manually",
42
- expenseUpdated: "Expense details updated",
43
- statusUpdated: "Status updated",
44
- changedTo: (e) => `Changed to ${e}`,
45
- submittedForApproval: "Submitted for approval",
46
- submittedWithoutReceipt: "Submitted without a receipt",
47
- approvalRequested: "Approval requested",
48
- approved: "Approved",
49
- rejected: "Rejected",
50
- policyOverrideApproved: "Policy override: Approved",
51
- policyOverrideRejected: "Policy override: Rejected",
52
- approvedAutomatically: "Auto-approved",
53
- withReason: (e, t) => `${e}: "${t}"`,
54
- quotedReason: (e) => `"${e}"`,
55
- reopened: "Re-opened",
56
- cancelled: "Canceled",
57
- deleted: "Deleted",
58
- receiptMatched: "Receipt matched",
59
- matchedAutomatically: "Matched automatically",
60
- matchedManually: "Matched manually",
61
- receiptRemoved: "Receipt unlinked",
62
- categorizedAutomatically: "Categorized automatically",
63
- paymentStatusUpdated: "Payment status updated",
64
- changedFromTo: (e, t) => `Changed from ${e} to ${t}`
65
- };
66
359
  //#endregion
67
- export { a as EXPENSE_AUDIT_HISTORY_LABELS_EN };
360
+ export { d as TransactionDetailsFeature, d as default };