@tesouro/embedded-components-react 0.3.63 → 0.4.1

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 (82) hide show
  1. package/README.md +1 -70
  2. package/dist/index.d.ts +67 -832
  3. package/dist/index.js +18 -34
  4. package/dist/lib/BillPayWidget.js +1 -1
  5. package/dist/lib/SettingsWidget.d.ts +53 -7
  6. package/dist/lib/SettingsWidget.js +4 -2
  7. package/dist/lib/WidgetSuite.d.ts +38 -0
  8. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index.js +8 -8
  9. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index28.js +8 -14
  10. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index29.js +7 -57
  11. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index30.js +56 -16
  12. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index31.js +18 -126
  13. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index32.js +126 -14
  14. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index33.js +22 -4
  15. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index34.js +4 -41
  16. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index35.js +40 -4
  17. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index36.js +5 -73
  18. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index37.js +72 -48
  19. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index38.js +47 -91
  20. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index39.js +91 -33
  21. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index40.js +33 -167
  22. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index41.js +167 -75
  23. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index42.js +75 -21
  24. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index43.js +23 -210
  25. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index44.js +199 -203
  26. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index45.js +198 -89
  27. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index46.js +105 -13
  28. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index47.js +12 -47
  29. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index48.js +47 -31
  30. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index49.js +27 -198
  31. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index50.js +198 -30
  32. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index51.js +30 -234
  33. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index52.js +240 -18
  34. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index53.js +18 -341
  35. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index54.js +343 -4
  36. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index55.js +4 -33
  37. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index56.js +31 -83
  38. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index57.js +78 -163
  39. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index58.js +170 -3
  40. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index59.js +3 -4
  41. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index60.js +2 -44
  42. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index61.js +46 -1
  43. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index62.js +1 -8
  44. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index63.js +6 -9
  45. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index64.js +9 -92
  46. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index65.js +94 -3
  47. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index66.js +3 -128
  48. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index67.js +125 -8
  49. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index68.js +8 -7
  50. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index69.js +8 -46
  51. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index70.js +43 -18
  52. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index71.js +20 -28
  53. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index72.js +27 -82
  54. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index73.js +83 -47
  55. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index74.js +47 -250
  56. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index75.js +239 -101
  57. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index76.js +107 -202
  58. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index77.js +209 -3
  59. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index78.js +4 -8
  60. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index79.js +6 -113
  61. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index80.js +115 -1
  62. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index81.js +0 -24
  63. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index82.js +25 -0
  64. package/dist/libs/tesouro-embedded-components-react/gl-code-table-widget/feature/dist/index.js +3 -3
  65. package/dist/libs/tesouro-embedded-components-react/gl-code-table-widget/ui/dist/index.js +5 -5
  66. package/dist/libs/tesouro-embedded-components-react/help-widget/feature/dist/index.js +4 -2
  67. package/dist/libs/tesouro-embedded-components-react/help-widget/ui/shadcn/dist/index.js +4 -4
  68. package/dist/libs/tesouro-embedded-components-react/help-widget/ui/shadcn/dist/index4.js +2 -3
  69. package/dist/libs/tesouro-embedded-components-react/settings-widget/feature/dist/index6.js +35 -32
  70. package/dist/libs/tesouro-embedded-components-react/shared/feature/dist/lib/analytics/build-info.js +1 -1
  71. package/dist/libs/tesouro-embedded-components-react/widget-suite/feature/dist/index8.js +1 -1
  72. package/package.json +1 -1
  73. package/dist/lib/ChartOfAccountsWidget.d.ts +0 -958
  74. package/dist/lib/ChartOfAccountsWidget.js +0 -9
  75. package/dist/lib/HelpWidget.d.ts +0 -739
  76. package/dist/lib/HelpWidget.js +0 -6
  77. package/dist/lib/ProfileWidget.d.ts +0 -672
  78. package/dist/lib/ProfileWidget.js +0 -3
  79. package/dist/lib/TagsWidget.d.ts +0 -719
  80. package/dist/lib/TagsWidget.js +0 -3
  81. package/dist/lib/TeamWidget.d.ts +0 -878
  82. package/dist/lib/TeamWidget.js +0 -3
@@ -2,24 +2,136 @@
2
2
  "use client";
3
3
  "use client";
4
4
  "use client";
5
- import { hasAnyScope as e } from "../../../shared/data-access/dist/lib/hasAnyScope.js";
6
- import { Scope as t } from "../../../shared/data-access/dist/lib/scopes.js";
7
- import "../../../shared/data-access/dist/index.js";
8
- import { formatCalendarDate as n } from "../../../shared/util/dist/lib/formatCalendarDate.js";
9
- import { useWidgetConfig as r } from "../../../shared/feature/dist/lib/WidgetProvider/hooks.js";
5
+ import { toast as e } from "../../../../../packages/shared-ui-shadcn/dist/index.js";
6
+ import "../../../shared/ui/dist/index.js";
7
+ import { useWidgetConfig as t } from "../../../shared/feature/dist/lib/WidgetProvider/hooks.js";
10
8
  import "../../../shared/feature/dist/index.js";
11
- import { isLiveScheduledPaymentRecord as i } from "../../data-access/dist/index3.js";
12
- import { usePayablePaymentRecordsQuery as a } from "../../data-access/dist/index10.js";
9
+ import { useApprovePayableApprovalRequestMutation as n, useRejectPayableApprovalRequestMutation as r } from "../../data-access/dist/index7.js";
10
+ import { useCancelPayableMutation as i, useCancelScheduledPaymentMutation as a, useForceApprovePayableMutation as o, useForceRejectPayableMutation as s, useReopenPayableMutation as c } from "../../data-access/dist/index12.js";
13
11
  import "../../data-access/dist/index.js";
12
+ import { getBillDetailActions as l } from "./index16.js";
13
+ import { useState as u } from "react";
14
+ import { HandIcon as d } from "lucide-react";
14
15
  //#region ../../libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index32.js
15
- function o({ payableId: o, scheduledPaymentDate: s, enabled: c = !0 }) {
16
- let { initResponse: l } = r(), u = e(l?.scopes, [t.PaymentRecordReadOrg]), d = a(c ? o : void 0, { enabled: c && u }), f = d.paymentRecords.find(i), p = !!f || !!s, m = f?.planned_payment_date ?? (p ? s : void 0);
16
+ function f({ payableId: d, status: f, currentApprovalRequestId: m, isPolicyApprover: _, hasWaitingRequest: v, arePendingApproversUnknown: y, hasScheduledPayment: b, scheduledPaymentIntentId: x, isScheduledPaymentUnknown: S, labels: C, isMarkAsPaidPending: w, pendingApprovers: T, onPayBillSelect: E, onMarkAsPaidSelect: D, onActionSucceeded: O }) {
17
+ let { initResponse: k } = t(), A = r(), j = n(), M = i(), N = a(), P = c(), F = o(), I = s(), L = w || A.isPending || j.isPending || M.isPending || N.isPending || P.isPending || F.isPending || I.isPending, [R, z] = u(), B = R && (R.id !== "cancelScheduledPayment" || R.scheduledPaymentIntentId === x) ? R : void 0, V = d && f ? l({
18
+ status: f,
19
+ scopes: k?.scopes,
20
+ canDecideApprovalRequest: !!m,
21
+ isPolicyApprover: _,
22
+ hasWaitingRequest: v,
23
+ arePendingApproversUnknown: y,
24
+ hasScheduledPayment: b || S,
25
+ scheduledPaymentIntentId: x,
26
+ labels: C
27
+ }) : [], H = (t) => ({
28
+ onError: () => e.error(C.actionError),
29
+ onSuccess: () => {
30
+ e.success(C.actionSuccess[t]), O?.();
31
+ }
32
+ }), U = {
33
+ reject: {
34
+ isPending: A.isPending,
35
+ run: (e) => m && A.mutate({
36
+ path: { approval_request_id: m },
37
+ body: e ? { reject_reason: e } : void 0
38
+ }, H("reject"))
39
+ },
40
+ approve: {
41
+ isPending: j.isPending,
42
+ run: () => m && j.mutate({ path: { approval_request_id: m } }, H("approve"))
43
+ },
44
+ cancel: {
45
+ isPending: M.isPending,
46
+ run: () => d && M.mutate({ path: { payable_id: d } }, H("cancel"))
47
+ },
48
+ cancelScheduledPayment: {
49
+ isPending: N.isPending,
50
+ run: () => {
51
+ let e = B?.scheduledPaymentIntentId;
52
+ !d || !e || N.mutate({
53
+ path: { payment_intent_id: e },
54
+ payableId: d
55
+ }, H("cancelScheduledPayment"));
56
+ }
57
+ },
58
+ reopen: {
59
+ isPending: P.isPending,
60
+ run: () => d && P.mutate({ path: { payable_id: d } }, H("reopen"))
61
+ },
62
+ forceApprove: {
63
+ isPending: F.isPending,
64
+ run: () => d && F.mutate({ path: { payable_id: d } }, H("forceApprove"))
65
+ },
66
+ forceReject: {
67
+ isPending: I.isPending,
68
+ run: () => d && I.mutate({ path: { payable_id: d } }, H("forceReject"))
69
+ }
70
+ }, W = V.map((e) => ({
71
+ ...e,
72
+ disabled: L,
73
+ loading: e.id === "markAsPaid" ? w : U[e.id]?.isPending ?? !1,
74
+ onSelect: () => {
75
+ if (!(L || !d)) {
76
+ if (e.id === "payBill") {
77
+ E();
78
+ return;
79
+ }
80
+ if (e.id === "markAsPaid") {
81
+ D();
82
+ return;
83
+ }
84
+ if (h(e.id)) {
85
+ z({
86
+ id: e.id,
87
+ scheduledPaymentIntentId: x
88
+ });
89
+ return;
90
+ }
91
+ U[e.id]?.run();
92
+ }
93
+ }
94
+ }));
17
95
  return {
18
- hasScheduledPayment: p,
19
- isResolving: d.isResolving,
20
- scheduledDateLabel: m ? n(m) : void 0,
21
- scheduledPaymentIntentId: f?.payment_intent_id ?? void 0
96
+ isActionPending: L,
97
+ actions: {
98
+ row: W.filter((e) => e.surface === "row"),
99
+ menu: W.filter((e) => e.surface === "menu")
100
+ },
101
+ decisionDialog: {
102
+ open: !!B,
103
+ copy: B ? {
104
+ ...C.decisionDialog[B.id],
105
+ presentation: g(B.id) ? p : void 0,
106
+ pendingApprovers: g(B.id) ? T ?? [] : void 0
107
+ } : void 0,
108
+ isPending: B ? U[B.id]?.isPending ?? !1 : !1,
109
+ onCancel: () => {
110
+ L || z(void 0);
111
+ },
112
+ onConfirm: (e) => {
113
+ !B || L || (U[B.id]?.run(e), z(void 0));
114
+ }
115
+ }
22
116
  };
23
117
  }
118
+ var p = {
119
+ alignment: "center",
120
+ icon: d,
121
+ tone: "destructive",
122
+ actionWidth: "equal"
123
+ }, m = [
124
+ "reject",
125
+ "cancel",
126
+ "cancelScheduledPayment",
127
+ "forceApprove",
128
+ "forceReject"
129
+ ];
130
+ function h(e) {
131
+ return m.includes(e);
132
+ }
133
+ function g(e) {
134
+ return e === "forceApprove" || e === "forceReject";
135
+ }
24
136
  //#endregion
25
- export { o as useScheduledPayment };
137
+ export { f as usePayableDetailActions };
@@ -1,7 +1,25 @@
1
+ "use client";
2
+ "use client";
3
+ "use client";
4
+ "use client";
5
+ import { hasAnyScope as e } from "../../../shared/data-access/dist/lib/hasAnyScope.js";
6
+ import { Scope as t } from "../../../shared/data-access/dist/lib/scopes.js";
7
+ import "../../../shared/data-access/dist/index.js";
8
+ import { formatCalendarDate as n } from "../../../shared/util/dist/lib/formatCalendarDate.js";
9
+ import { useWidgetConfig as r } from "../../../shared/feature/dist/lib/WidgetProvider/hooks.js";
10
+ import "../../../shared/feature/dist/index.js";
11
+ import { isLiveScheduledPaymentRecord as i } from "../../data-access/dist/index3.js";
12
+ import { usePayablePaymentRecordsQuery as a } from "../../data-access/dist/index10.js";
13
+ import "../../data-access/dist/index.js";
1
14
  //#region ../../libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index33.js
2
- var e = /* @__PURE__ */ new Set(["draft", "new"]);
3
- function t(t) {
4
- return !!(t && e.has(t));
15
+ function o({ payableId: o, scheduledPaymentDate: s, enabled: c = !0 }) {
16
+ let { initResponse: l } = r(), u = e(l?.scopes, [t.PaymentRecordReadOrg]), d = a(c ? o : void 0, { enabled: c && u }), f = d.paymentRecords.find(i), p = !!f || !!s, m = f?.planned_payment_date ?? (p ? s : void 0);
17
+ return {
18
+ hasScheduledPayment: p,
19
+ isResolving: d.isResolving,
20
+ scheduledDateLabel: m ? n(m) : void 0,
21
+ scheduledPaymentIntentId: f?.payment_intent_id ?? void 0
22
+ };
5
23
  }
6
24
  //#endregion
7
- export { t as isEditablePayableStatus };
25
+ export { o as useScheduledPayment };
@@ -1,44 +1,7 @@
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 { hasAnyScope as t } from "../../../shared/data-access/dist/lib/hasAnyScope.js";
7
- import { Scope as n } from "../../../shared/data-access/dist/lib/scopes.js";
8
- import "../../../shared/data-access/dist/index.js";
9
- import "../../../shared/ui/dist/index.js";
10
- import { useWidgetConfig as r } from "../../../shared/feature/dist/lib/WidgetProvider/hooks.js";
11
- import "../../../shared/feature/dist/index.js";
12
- import { useDeletePayableMutation as i } from "../../data-access/dist/index12.js";
13
- import "../../data-access/dist/index.js";
14
- import { useState as a } from "react";
15
1
  //#region ../../libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index34.js
16
- function o({ payableId: o, status: s, enabled: c = !0, labels: l, onDeleted: u }) {
17
- let { initResponse: d } = r(), f = i(), [p, m] = a(!1), h = t(d?.scopes, [n.PayableWriteOrg]), g = !!(c && o && s === "draft" && h), _ = g ? [{
18
- id: "deleteDraft",
19
- label: l.menuItem,
20
- destructive: !0,
21
- onSelect: () => m(!0)
22
- }] : [], v = p && g;
23
- return {
24
- menuItems: _,
25
- dialog: {
26
- open: v,
27
- copy: v ? l.dialog : void 0,
28
- isPending: f.isPending,
29
- onCancel: () => {
30
- f.isPending || m(!1);
31
- },
32
- onConfirm: () => {
33
- !g || !o || f.isPending || f.mutate({ path: { payable_id: o } }, {
34
- onError: () => e.error(l.error),
35
- onSuccess: () => {
36
- m(!1), u();
37
- }
38
- });
39
- }
40
- }
41
- };
2
+ var e = /* @__PURE__ */ new Set(["draft", "new"]);
3
+ function t(t) {
4
+ return !!(t && e.has(t));
42
5
  }
43
6
  //#endregion
44
- export { o as useDraftDelete };
7
+ export { t as isEditablePayableStatus };
@@ -1,8 +1,44 @@
1
- import { formatMoneyExact as e } from "../../../shared/util/dist/lib/formatMoneyExact.js";
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 { hasAnyScope as t } from "../../../shared/data-access/dist/lib/hasAnyScope.js";
7
+ import { Scope as n } from "../../../shared/data-access/dist/lib/scopes.js";
8
+ import "../../../shared/data-access/dist/index.js";
9
+ import "../../../shared/ui/dist/index.js";
10
+ import { useWidgetConfig as r } from "../../../shared/feature/dist/lib/WidgetProvider/hooks.js";
11
+ import "../../../shared/feature/dist/index.js";
12
+ import { useDeletePayableMutation as i } from "../../data-access/dist/index12.js";
2
13
  import "../../data-access/dist/index.js";
14
+ import { useState as a } from "react";
3
15
  //#region ../../libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index35.js
4
- function t(t, n) {
5
- if (typeof t == "number") return e(t / 100, { currencyCode: n ?? "USD" });
16
+ function o({ payableId: o, status: s, enabled: c = !0, labels: l, onDeleted: u }) {
17
+ let { initResponse: d } = r(), f = i(), [p, m] = a(!1), h = t(d?.scopes, [n.PayableWriteOrg]), g = !!(c && o && s === "draft" && h), _ = g ? [{
18
+ id: "deleteDraft",
19
+ label: l.menuItem,
20
+ destructive: !0,
21
+ onSelect: () => m(!0)
22
+ }] : [], v = p && g;
23
+ return {
24
+ menuItems: _,
25
+ dialog: {
26
+ open: v,
27
+ copy: v ? l.dialog : void 0,
28
+ isPending: f.isPending,
29
+ onCancel: () => {
30
+ f.isPending || m(!1);
31
+ },
32
+ onConfirm: () => {
33
+ !g || !o || f.isPending || f.mutate({ path: { payable_id: o } }, {
34
+ onError: () => e.error(l.error),
35
+ onSuccess: () => {
36
+ m(!1), u();
37
+ }
38
+ });
39
+ }
40
+ }
41
+ };
6
42
  }
7
43
  //#endregion
8
- export { t as formatBillMoney };
44
+ export { o as useDraftDelete };
@@ -1,76 +1,8 @@
1
- import { formatCalendarDate as e } from "../../../shared/util/dist/lib/formatCalendarDate.js";
2
- import { derivePayableStatus as t } from "./index4.js";
3
- import { resolveVendor as n } from "./index5.js";
4
- import { resolveAmountDueMinorUnits as r } from "./index17.js";
5
- import { formatBillMoney as i } from "./index35.js";
1
+ import { formatMoneyExact as e } from "../../../shared/util/dist/lib/formatMoneyExact.js";
2
+ import "../../data-access/dist/index.js";
6
3
  //#region ../../libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index36.js
7
- function a({ payable: a, lineItems: o, glCodeOptions: s, glCodeRosterAvailable: c = !0, history: l, approvalPolicy: u, labels: d, hasScheduledPayment: f }) {
8
- let p = a.currency, m = t({
9
- apiStatus: a.status,
10
- dueDate: a.due_date,
11
- scheduledPaymentDate: a.scheduled_payment_date,
12
- hasScheduledPayment: f
13
- }), h = n(a), g = h?.bank_account?.account_number, _ = e(a.issued_at) || d.notProvided, v = e(a.due_date) || d.notProvided, y = new Map(s.map((e) => [e.value, e.label])), b = [
14
- {
15
- label: d.subtotalRow,
16
- minorUnits: a.subtotal
17
- },
18
- {
19
- label: d.discountRow,
20
- minorUnits: a.discount
21
- },
22
- {
23
- label: d.taxRow,
24
- minorUnits: a.tax_amount
25
- }
26
- ].map((e) => ({
27
- label: e.label,
28
- value: i(e.minorUnits, p)
29
- })).filter((e) => !!e.value), x = i(a.total_amount, p);
30
- return x && b.push({
31
- label: d.totalRow,
32
- value: x,
33
- emphasis: !0
34
- }), {
35
- amountDue: i(r(a), p) ?? "",
36
- invoiceDateLabel: _,
37
- dueDateLabel: v,
38
- dueDateTone: m.isOverdue ? "danger" : "default",
39
- status: m.status,
40
- statusTone: m.tone,
41
- payTo: {
42
- name: h?.name || d.notProvided,
43
- email: h?.email ?? void 0,
44
- paymentInstructionsLabel: g ? d.paymentInstructionsValue(g.slice(-4)) : void 0
45
- },
46
- invoiceFields: [
47
- {
48
- label: d.invoiceDateRow,
49
- value: _
50
- },
51
- {
52
- label: d.dueDateRow,
53
- value: v
54
- },
55
- {
56
- label: d.invoiceNumberRow,
57
- value: a.document_id || d.notProvided
58
- }
59
- ],
60
- lineItems: o.map((e) => {
61
- let t = i(e.unit_price, p);
62
- return {
63
- id: e.id,
64
- description: e.name ?? e.description ?? "",
65
- glCodeLabel: e.ledger_account_id ? y.get(e.ledger_account_id) ?? (c ? d.glCodeMissing : d.glCodeUnavailable) : d.glCodeMissing,
66
- qtyPriceLabel: e.quantity != null && t ? d.qtyPriceValue(String(e.quantity), t) : "",
67
- amount: i(e.subtotal, p) ?? ""
68
- };
69
- }),
70
- amountRows: b,
71
- approvalPolicy: u,
72
- history: l
73
- };
4
+ function t(t, n) {
5
+ if (typeof t == "number") return e(t / 100, { currencyCode: n ?? "USD" });
74
6
  }
75
7
  //#endregion
76
- export { a as buildBillDetailView };
8
+ export { t as formatBillMoney };
@@ -1,52 +1,76 @@
1
- import { derivePayableStatus as e } from "./index4.js";
2
- import { BILL_STATUS_BADGE_LABELS_EN as t } from "../../ui/dist/index18.js";
3
- import "../../ui/dist/index.js";
1
+ import { formatCalendarDate as e } from "../../../shared/util/dist/lib/formatCalendarDate.js";
2
+ import { derivePayableStatus as t } from "./index4.js";
3
+ import { resolveVendor as n } from "./index5.js";
4
+ import { resolveAmountDueMinorUnits as r } from "./index17.js";
5
+ import { formatBillMoney as i } from "./index36.js";
4
6
  //#region ../../libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index37.js
5
- var n = /* @__PURE__ */ new Set([
6
- "credit_note_linked",
7
- "credit_note_unlinked",
8
- "line_item_added",
9
- "line_item_updated",
10
- "line_item_removed",
11
- "deleted"
12
- ]);
13
- function r(n, r, i) {
14
- switch (n) {
15
- case "payable_created": return r?.source_of_payable_data === "ocr" ? i.billUploaded : i.billAdded;
16
- case "payable_updated": return i.billUpdated;
17
- case "file_attached": return i.attachmentAdded;
18
- case "submitted_for_approval": return i.submittedForApproval;
19
- case "approval_requested": return i.approvalRequested;
20
- case "approval_action": {
21
- let e = r?.action, t = r?.reject_reason;
22
- return e === "approve" ? i.approved : e === "reject" ? typeof t == "string" && t ? i.rejectedWithReason(t) : i.rejected : void 0;
7
+ function a({ payable: a, lineItems: o, glCodeOptions: s, glCodeRosterAvailable: c = !0, history: l, approvalPolicy: u, labels: d, hasScheduledPayment: f }) {
8
+ let p = a.currency, m = t({
9
+ apiStatus: a.status,
10
+ dueDate: a.due_date,
11
+ scheduledPaymentDate: a.scheduled_payment_date,
12
+ hasScheduledPayment: f
13
+ }), h = n(a), g = h?.bank_account?.account_number, _ = e(a.issued_at) || d.notProvided, v = e(a.due_date) || d.notProvided, y = new Map(s.map((e) => [e.value, e.label])), b = [
14
+ {
15
+ label: d.subtotalRow,
16
+ minorUnits: a.subtotal
17
+ },
18
+ {
19
+ label: d.discountRow,
20
+ minorUnits: a.discount
21
+ },
22
+ {
23
+ label: d.taxRow,
24
+ minorUnits: a.tax_amount
23
25
  }
24
- case "auto_approved": return i.autoApproved;
25
- case "reopened": return i.reopened;
26
- case "marked_as_paid": return i.markedAsPaid;
27
- case "marked_as_partially_paid": return i.markedAsPartiallyPaid;
28
- case "payment_reverted": return i.paymentReverted;
29
- case "status_changed": {
30
- let n = r?.new_status;
31
- if (typeof n != "string") return;
32
- let a = e({ apiStatus: n }).status;
33
- return i.statusChanged(t[a] ?? t.unknown);
34
- }
35
- default: return;
36
- }
37
- }
38
- function i(e, t, i) {
39
- let a = new Map(t.map((e) => [e.id, e.name]));
40
- return e.filter((e) => !n.has(e.event_type)).map((e) => {
41
- let t = r(e.event_type, e.event_data, i);
42
- if (!t) return;
43
- let n = e.entity_user_id ? a.get(e.entity_user_id) : void 0;
44
- return {
45
- id: e.id,
46
- dateLabel: i.dateLabel(e.timestamp),
47
- description: n ? i.byActor(t, n) : t
48
- };
49
- }).filter((e) => !!e);
26
+ ].map((e) => ({
27
+ label: e.label,
28
+ value: i(e.minorUnits, p)
29
+ })).filter((e) => !!e.value), x = i(a.total_amount, p);
30
+ return x && b.push({
31
+ label: d.totalRow,
32
+ value: x,
33
+ emphasis: !0
34
+ }), {
35
+ amountDue: i(r(a), p) ?? "",
36
+ invoiceDateLabel: _,
37
+ dueDateLabel: v,
38
+ dueDateTone: m.isOverdue ? "danger" : "default",
39
+ status: m.status,
40
+ statusTone: m.tone,
41
+ payTo: {
42
+ name: h?.name || d.notProvided,
43
+ email: h?.email ?? void 0,
44
+ paymentInstructionsLabel: g ? d.paymentInstructionsValue(g.slice(-4)) : void 0
45
+ },
46
+ invoiceFields: [
47
+ {
48
+ label: d.invoiceDateRow,
49
+ value: _
50
+ },
51
+ {
52
+ label: d.dueDateRow,
53
+ value: v
54
+ },
55
+ {
56
+ label: d.invoiceNumberRow,
57
+ value: a.document_id || d.notProvided
58
+ }
59
+ ],
60
+ lineItems: o.map((e) => {
61
+ let t = i(e.unit_price, p);
62
+ return {
63
+ id: e.id,
64
+ description: e.name ?? e.description ?? "",
65
+ glCodeLabel: e.ledger_account_id ? y.get(e.ledger_account_id) ?? (c ? d.glCodeMissing : d.glCodeUnavailable) : d.glCodeMissing,
66
+ qtyPriceLabel: e.quantity != null && t ? d.qtyPriceValue(String(e.quantity), t) : "",
67
+ amount: i(e.subtotal, p) ?? ""
68
+ };
69
+ }),
70
+ amountRows: b,
71
+ approvalPolicy: u,
72
+ history: l
73
+ };
50
74
  }
51
75
  //#endregion
52
- export { i as buildBillHistory };
76
+ export { a as buildBillDetailView };
@@ -1,96 +1,52 @@
1
+ import { derivePayableStatus as e } from "./index4.js";
2
+ import { BILL_STATUS_BADGE_LABELS_EN as t } from "../../ui/dist/index18.js";
3
+ import "../../ui/dist/index.js";
1
4
  //#region ../../libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index38.js
2
- var e = {
3
- payBill: "Pay bill",
4
- markAsPaid: "Mark as paid",
5
- reject: "Reject",
6
- approve: "Approve",
7
- cancel: "Cancel bill",
8
- cancelScheduledPayment: "Cancel scheduled payment",
9
- reopen: "Reopen bill",
10
- forceApprove: "Approve",
11
- forceReject: "Reject",
12
- policyOverridesHeading: "Policy overrides",
13
- decisionDialog: {
14
- reject: {
15
- title: "Reject this bill?",
16
- description: "The bill goes back as rejected and nobody else is asked to approve it.",
17
- confirmButton: "Reject bill",
18
- reason: {
19
- label: "Reason",
20
- placeholder: "Tell the submitter what needs to change",
21
- optionalHint: "Optional"
22
- }
23
- },
24
- cancel: {
25
- title: "Cancel this bill?",
26
- description: "Cancelling is permanent. The bill can't be reopened, edited, or paid afterwards.",
27
- confirmButton: "Cancel bill"
28
- },
29
- cancelScheduledPayment: {
30
- title: "Cancel this scheduled payment?",
31
- description: "The payment will not be sent. The bill stays ready to pay, so you can schedule it again for another date.",
32
- confirmButton: "Cancel payment"
33
- },
34
- forceApprove: {
35
- title: "Override approval policy?",
36
- description: "The below people haven't approved this bill yet. Approving now will bypass their required review. This will be recorded in the audit history and can't be undone.",
37
- confirmButton: "Override and approve"
38
- },
39
- forceReject: {
40
- title: "Override approval policy?",
41
- description: "The below people haven't approved this bill yet. Rejecting now will bypass their required review. This will be recorded in the audit history and can't be undone.",
42
- confirmButton: "Override and reject"
43
- },
44
- cancelButton: "Cancel"
45
- },
46
- actionError: "Couldn't update this bill. Try again.",
47
- actionSuccess: {
48
- approve: "Bill approved.",
49
- reject: "Bill rejected.",
50
- markAsPaid: "Bill marked as paid.",
51
- cancel: "Bill canceled.",
52
- cancelScheduledPayment: "Scheduled payment canceled.",
53
- reopen: "Bill reopened.",
54
- forceApprove: "Bill approved, overriding the approval policy.",
55
- forceReject: "Bill rejected, overriding the approval policy."
5
+ var n = /* @__PURE__ */ new Set([
6
+ "credit_note_linked",
7
+ "credit_note_unlinked",
8
+ "line_item_added",
9
+ "line_item_updated",
10
+ "line_item_removed",
11
+ "deleted"
12
+ ]);
13
+ function r(n, r, i) {
14
+ switch (n) {
15
+ case "payable_created": return r?.source_of_payable_data === "ocr" ? i.billUploaded : i.billAdded;
16
+ case "payable_updated": return i.billUpdated;
17
+ case "file_attached": return i.attachmentAdded;
18
+ case "submitted_for_approval": return i.submittedForApproval;
19
+ case "approval_requested": return i.approvalRequested;
20
+ case "approval_action": {
21
+ let e = r?.action, t = r?.reject_reason;
22
+ return e === "approve" ? i.approved : e === "reject" ? typeof t == "string" && t ? i.rejectedWithReason(t) : i.rejected : void 0;
23
+ }
24
+ case "auto_approved": return i.autoApproved;
25
+ case "reopened": return i.reopened;
26
+ case "marked_as_paid": return i.markedAsPaid;
27
+ case "marked_as_partially_paid": return i.markedAsPartiallyPaid;
28
+ case "payment_reverted": return i.paymentReverted;
29
+ case "status_changed": {
30
+ let n = r?.new_status;
31
+ if (typeof n != "string") return;
32
+ let a = e({ apiStatus: n }).status;
33
+ return i.statusChanged(t[a] ?? t.unknown);
34
+ }
35
+ default: return;
56
36
  }
57
- }, t = (e) => `Payment scheduled for ${e}`, n = [
58
- "reject",
59
- "cancel",
60
- "cancelScheduledPayment",
61
- "forceApprove",
62
- "forceReject"
63
- ];
64
- function r(e, t) {
65
- let n = e.reason ? {
66
- ...e.reason,
67
- ...t?.reason
68
- } : void 0, r = {
69
- ...e,
70
- ...t,
71
- reason: n
72
- };
73
- return n || delete r.reason, r;
74
37
  }
75
- function i(e, t) {
76
- let i = {
77
- ...e,
78
- ...t
79
- };
80
- for (let a of n) i[a] = r(e[a], t?.[a]);
81
- return i;
82
- }
83
- function a(t) {
84
- let n = e;
85
- return {
86
- ...n,
87
- ...t,
88
- decisionDialog: i(n.decisionDialog, t?.decisionDialog),
89
- actionSuccess: {
90
- ...n.actionSuccess,
91
- ...t?.actionSuccess
92
- }
93
- };
38
+ function i(e, t, i) {
39
+ let a = new Map(t.map((e) => [e.id, e.name]));
40
+ return e.filter((e) => !n.has(e.event_type)).map((e) => {
41
+ let t = r(e.event_type, e.event_data, i);
42
+ if (!t) return;
43
+ let n = e.entity_user_id ? a.get(e.entity_user_id) : void 0;
44
+ return {
45
+ id: e.id,
46
+ dateLabel: i.dateLabel(e.timestamp),
47
+ description: n ? i.byActor(t, n) : t
48
+ };
49
+ }).filter((e) => !!e);
94
50
  }
95
51
  //#endregion
96
- export { e as BILL_DETAIL_ACTIONS_LABELS_EN, t as SCHEDULED_SUMMARY_LABEL_EN, a as mergeBillDetailActionsLabels, i as mergeDecisionDialogCopy };
52
+ export { i as buildBillHistory };