@tesouro/embedded-components-react 0.2.318 → 0.2.320

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 (135) hide show
  1. package/README.md +5 -4
  2. package/dist/index.css +9 -0
  3. package/dist/index.d.ts +4 -1
  4. package/dist/index.js +1 -1
  5. package/dist/lib/BillPayWidget.d.ts +4 -1
  6. package/dist/lib/BillPayWidget.js +1 -1
  7. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/data-access/dist/index.js +10 -7
  8. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/data-access/dist/index10.js +170 -32
  9. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/data-access/dist/index11.js +13 -32
  10. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/data-access/dist/index12.js +30 -0
  11. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/data-access/dist/index13.js +50 -0
  12. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/data-access/dist/index14.js +36 -0
  13. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/data-access/dist/index3.js +11 -8
  14. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/data-access/dist/index4.js +33 -16
  15. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/data-access/dist/index5.js +47 -2
  16. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/data-access/dist/index6.js +18 -63
  17. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/data-access/dist/index7.js +40 -131
  18. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/data-access/dist/index8.js +48 -11
  19. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/data-access/dist/index9.js +30 -20
  20. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index.js +18 -16
  21. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index10.js +29 -97
  22. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index11.js +1 -9
  23. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index12.js +13 -109
  24. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index13.js +24 -4
  25. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index14.js +30 -21
  26. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index15.js +19 -46
  27. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index16.js +49 -76
  28. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index17.js +4 -45
  29. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index18.js +73 -3
  30. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index19.js +50 -2
  31. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index2.js +4 -50
  32. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index20.js +7 -43
  33. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index21.js +38 -1
  34. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index22.js +115 -31
  35. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index23.js +56 -8
  36. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index24.js +206 -16
  37. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index25.js +195 -5
  38. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index26.js +58 -64
  39. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index27.js +46 -139
  40. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index28.js +34 -5
  41. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index29.js +155 -6
  42. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index3.js +3 -60
  43. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index30.js +36 -7
  44. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index31.js +92 -73
  45. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index32.js +9 -3
  46. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index33.js +191 -6
  47. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index34.js +4 -114
  48. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index35.js +26 -1
  49. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index36.js +78 -21
  50. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index37.js +92 -0
  51. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index38.js +3 -0
  52. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index39.js +4 -0
  53. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index4.js +5 -206
  54. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index40.js +45 -0
  55. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index41.js +1 -0
  56. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index42.js +53 -0
  57. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index43.js +11 -0
  58. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index44.js +18 -0
  59. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index45.js +8 -0
  60. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index46.js +79 -0
  61. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index47.js +148 -0
  62. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index48.js +5 -0
  63. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index49.js +8 -0
  64. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index5.js +3 -197
  65. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index50.js +9 -0
  66. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index51.js +85 -0
  67. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index52.js +3 -0
  68. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index53.js +8 -0
  69. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index54.js +115 -0
  70. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index55.js +1 -0
  71. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index56.js +25 -0
  72. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index6.js +30 -41
  73. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index7.js +38 -30
  74. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index8.js +20 -151
  75. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index9.js +158 -31
  76. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index.js +29 -17
  77. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index12.js +13 -7
  78. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index13.js +13 -47
  79. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index14.js +24 -2
  80. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index15.js +2 -22
  81. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index16.js +31 -283
  82. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index17.js +261 -1
  83. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index18.js +2 -16
  84. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index19.js +7 -118
  85. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index20.js +49 -2
  86. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index21.js +2 -10
  87. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index22.js +20 -94
  88. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index23.js +286 -2
  89. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index24.js +1 -12
  90. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index25.js +14 -56
  91. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index26.js +120 -2
  92. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index27.js +1 -19
  93. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index28.js +8 -157
  94. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index29.js +96 -2
  95. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index30.js +2 -7
  96. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index31.js +11 -42
  97. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index32.js +57 -1
  98. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index33.js +2 -14
  99. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index34.js +50 -20
  100. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index35.js +138 -1
  101. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index36.js +1 -54
  102. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index37.js +5 -227
  103. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index38.js +37 -188
  104. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index39.js +2 -10
  105. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index40.js +55 -5
  106. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index41.js +229 -84
  107. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index42.js +195 -0
  108. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index43.js +10 -2
  109. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index44.js +4 -3
  110. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index45.js +88 -25
  111. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index47.js +2 -14
  112. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index48.js +5 -87
  113. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index49.js +30 -2
  114. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index50.js +2 -0
  115. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index51.js +7 -0
  116. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index52.js +34 -0
  117. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index53.js +2 -0
  118. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index54.js +12 -0
  119. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index55.js +106 -0
  120. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index56.js +2 -0
  121. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index57.js +18 -0
  122. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index58.js +10 -0
  123. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index59.js +170 -0
  124. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index60.js +2 -0
  125. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index61.js +14 -0
  126. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index62.js +89 -0
  127. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index63.js +2 -0
  128. package/dist/libs/tesouro-embedded-components-react/shared/data-access/dist/index.js +21 -21
  129. package/dist/libs/tesouro-embedded-components-react/shared/data-access/dist/lib/rest/@tanstack/react-query.gen.js +189 -156
  130. package/dist/libs/tesouro-embedded-components-react/shared/data-access/dist/lib/rest/sdk.gen.js +157 -97
  131. package/dist/libs/tesouro-embedded-components-react/shared/feature/dist/index.js +10 -10
  132. package/dist/libs/tesouro-embedded-components-react/shared/feature/dist/lib/analytics/build-info.js +1 -1
  133. package/dist/libs/tesouro-embedded-components-react/widget-suite/feature/dist/index7.js +1 -1
  134. package/package.json +1 -1
  135. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index46.js +0 -2
@@ -0,0 +1,115 @@
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 { EmbeddedToaster as n } from "../../../shared/ui/dist/lib/EmbeddedToaster.js";
9
+ import "../../../shared/ui/dist/index.js";
10
+ import { useAnalyticsTrack as r } from "../../../shared/feature/dist/lib/analytics/hooks.js";
11
+ import { WidgetProvider as i } from "../../../shared/feature/dist/lib/WidgetProvider/WidgetProvider.js";
12
+ import { useWidgetConfig as a } from "../../../shared/feature/dist/lib/WidgetProvider/hooks.js";
13
+ import "../../../shared/feature/dist/index.js";
14
+ import { BillPayWidgetUi as o } from "../../ui/dist/index38.js";
15
+ import { BillUploadStatusTray as s } from "../../ui/dist/index45.js";
16
+ import "../../ui/dist/index.js";
17
+ import { billsTabTestIds as c } from "./index45.js";
18
+ import { BillsTab as l } from "./index47.js";
19
+ import "./index48.js";
20
+ import { useBillUploadQueue as u } from "./index51.js";
21
+ import "./index52.js";
22
+ import { BillPayWidgetAnalyticsEvent as d, WIDGET_NAME as f } from "./index39.js";
23
+ import { DEFAULT_TABS_LABELS as p } from "./index53.js";
24
+ import { ApprovalPoliciesSettings as m } from "../../../shared/approval-policy/feature/dist/lib/ApprovalPoliciesSettings.js";
25
+ import "../../../shared/approval-policy/feature/dist/index.js";
26
+ import { CounterpartsWidget as h } from "../../../counterparts-widget/feature/dist/index8.js";
27
+ import "../../../counterparts-widget/feature/dist/index.js";
28
+ import { useCallback as g, useEffect as _, useState as v } from "react";
29
+ import { Fragment as y, jsx as b, jsxs as x } from "react/jsx-runtime";
30
+ //#region ../../libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index54.js
31
+ var S = {
32
+ Bills: "bills",
33
+ Vendors: "vendors",
34
+ Settings: "settings"
35
+ }, C = [
36
+ S.Bills,
37
+ S.Vendors,
38
+ S.Settings
39
+ ];
40
+ function w({ labels: i, tabsLabels: f, approvalPolicyLabels: w, approvalPolicyComponentLabels: T, vendorLabels: E, poweredByBankName: D }) {
41
+ let O = r();
42
+ _(() => {
43
+ O(d.Mounted);
44
+ }, [O]);
45
+ let k = {
46
+ ...p,
47
+ ...f
48
+ }, { initResponse: A } = a(), j = e(A?.scopes, [t.ApprovalPolicyWriteOrg]), M = !A || j, [N, P] = v(S.Bills), [F, I] = v(), L = g((e) => {
49
+ P(S.Bills), I(e);
50
+ }, []), R = u({ onOpenBill: L }), z = [{
51
+ id: S.Bills,
52
+ label: k.bills,
53
+ content: /* @__PURE__ */ b(l, {
54
+ onEnqueueFiles: R.enqueue,
55
+ openPayableId: F,
56
+ onOpenPayableHandled: () => I(void 0),
57
+ poweredByBankName: D
58
+ })
59
+ }, {
60
+ id: S.Vendors,
61
+ label: k.vendors,
62
+ content: /* @__PURE__ */ b(h, {
63
+ ...E,
64
+ counterpartType: "vendor",
65
+ showTitle: !1,
66
+ onViewAllDocuments: () => P(S.Bills)
67
+ })
68
+ }];
69
+ M && z.push({
70
+ id: S.Settings,
71
+ label: k.settings,
72
+ content: /* @__PURE__ */ b(m, {
73
+ labels: w,
74
+ componentLabels: T
75
+ })
76
+ });
77
+ let B = z.some((e) => e.id === N) ? N : C.find((e) => z.some((t) => t.id === e)) ?? z[0]?.id ?? "";
78
+ return /* @__PURE__ */ x(y, { children: [
79
+ /* @__PURE__ */ b(n, {}),
80
+ /* @__PURE__ */ b(o, {
81
+ labels: i,
82
+ tabs: z,
83
+ selectedTabId: B,
84
+ onTabChange: P
85
+ }),
86
+ R.isVisible ? /* @__PURE__ */ b(s, {
87
+ sections: R.sections,
88
+ summaryLabel: R.summaryLabel,
89
+ collapsed: R.collapsed,
90
+ onToggleCollapsed: R.onToggleCollapsed,
91
+ onClose: R.onClose,
92
+ testId: c.uploadTray
93
+ }) : null
94
+ ] });
95
+ }
96
+ function T({ baseUrl: e, widgetToken: t, organizationId: n, configClient: r, gatewayRouting: a, linkComponent: o, implementation: s, uiFramework: c, errorFallback: l, onError: u, analytics: d, disclosuresAcceptance: p, ...m }) {
97
+ return /* @__PURE__ */ b(i, {
98
+ widgetName: f,
99
+ baseUrl: e,
100
+ widgetToken: t,
101
+ organizationId: n,
102
+ configClient: r,
103
+ gatewayRouting: a,
104
+ linkComponent: o,
105
+ implementation: s,
106
+ uiFramework: c,
107
+ errorFallback: l,
108
+ onError: u,
109
+ analytics: d,
110
+ disclosuresAcceptance: p,
111
+ children: /* @__PURE__ */ b(w, { ...m })
112
+ });
113
+ }
114
+ //#endregion
115
+ export { T as BillPayWidgetNative, T as default };
@@ -0,0 +1,25 @@
1
+ "use client";
2
+ "use client";
3
+ "use client";
4
+ "use client";
5
+ import { Implementation as e } from "../../../shared/feature/dist/lib/WidgetProvider/types.js";
6
+ import { useWidgetConfig as t } from "../../../shared/feature/dist/lib/WidgetProvider/hooks.js";
7
+ import "../../../shared/feature/dist/index.js";
8
+ import { BillPayWidgetMonite as n } from "./index40.js";
9
+ import "./index41.js";
10
+ import { BillPayWidgetNative as r } from "./index54.js";
11
+ import "./index55.js";
12
+ import { jsx as i } from "react/jsx-runtime";
13
+ //#region ../../libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index56.js
14
+ function a({ implementation: a, ...o }) {
15
+ let s = t().implementation, c = a ?? s ?? e.Monite;
16
+ return c === e.Native ? /* @__PURE__ */ i(r, {
17
+ implementation: c,
18
+ ...o
19
+ }) : /* @__PURE__ */ i(n, {
20
+ implementation: c,
21
+ ...o
22
+ });
23
+ }
24
+ //#endregion
25
+ export { a as BillPayWidget, a as default };
@@ -1,50 +1,39 @@
1
- import { parseDecimalAmountToMinorUnits as e } from "../../../shared/util/dist/lib/parseDecimalAmountToMinorUnits.js";
2
- import "../../data-access/dist/index.js";
1
+ import { coerceAmountValueToMinorUnits as e } from "../../../shared/util/dist/lib/coerceAmountValueToMinorUnits.js";
2
+ import { formatMoneyExact as t } from "../../../shared/util/dist/lib/formatMoneyExact.js";
3
3
  //#region ../../libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index6.js
4
- var t = "USD";
5
- function n(n) {
6
- return e(n, t);
7
- }
4
+ var n = {
5
+ unnamedSourceAccount: "Bank account",
6
+ availableBalancePrefix: (e) => `Available balance: ${e}`,
7
+ sufficientFunds: "Funds available",
8
+ futureInsufficientFunds: "Not enough funds right now. Add funds before the payment date.",
9
+ todayInsufficientFunds: "Not enough funds to pay today. Choose a different account or a later date."
10
+ };
8
11
  function r(e) {
9
- let t = e.trim();
10
- if (!t) return null;
11
- let n = Number(t);
12
- return Number.isFinite(n) && n > 0 ? n : null;
13
- }
14
- function i(e) {
15
- return !!(e.description.trim() || e.glCode.trim() || n(e.price) !== null || n(e.amount) !== null);
16
- }
17
- function a(e) {
18
- return n(e) ?? 0;
19
- }
20
- function o(e) {
21
- let t = Number.parseFloat(e);
22
- return Number.isFinite(t) ? t : 0;
12
+ return e.slice(-4);
23
13
  }
24
- function s(e) {
25
- return (e / 100).toFixed(2);
26
- }
27
- function c({ values: e, counterpartId: r, clearCounterpart: i, editedTotals: a }) {
28
- let o = { currency: t };
29
- return r ? o.counterpart_id = r : i && (o.counterpart_id = null), e.invoiceNumber && (o.document_id = e.invoiceNumber), e.invoiceDate && (o.issued_at = e.invoiceDate), e.dueDate && (o.due_date = e.dueDate), a && (o.discount = n(a.discount) ?? 0, o.tax_amount = n(a.tax) ?? 0, a.total !== void 0 && (o.total_amount = n(a.total) ?? 0)), o;
30
- }
31
- function l(e) {
32
- return e.filter(i).map((e) => {
33
- let t = n(e.amount), i = r(e.quantity) ?? 1, a = n(e.price) ?? (t === null ? 0 : Math.round(t / i)), o = Math.round(i * a);
14
+ function i(i, a = n) {
15
+ return i.filter((e) => e.status === "ACTIVE").map((n) => {
16
+ let i = e(n.balance.value), o = n.balance.currencyCode;
34
17
  return {
35
- name: e.description,
36
- quantity: i,
37
- unit_price: a,
38
- ...t !== null && t !== o ? { subtotal: t } : {},
39
- ...e.glCode ? { ledger_account_id: e.glCode } : {}
18
+ id: n.id,
19
+ primaryLabel: `${n.nickname || a.unnamedSourceAccount} - ${r(n.accountNumber)}`,
20
+ secondaryLabel: a.availableBalancePrefix(t(i / 100, { currencyCode: o })),
21
+ balanceMinorUnits: i
40
22
  };
41
23
  });
42
24
  }
43
- function u(e, t) {
44
- return s(Math.round(o(e) * a(t)));
45
- }
46
- function d(e, t, n) {
47
- return s(e.reduce((e, t) => e + a(t.amount), 0) + a(t) - a(n));
25
+ function a({ selectedAccount: e, amountDueMinorUnits: t, isToday: r, labels: i = n }) {
26
+ let a = e?.balanceMinorUnits;
27
+ return a === void 0 ? { state: "warning" } : a >= t ? {
28
+ state: "sufficient",
29
+ message: i.sufficientFunds
30
+ } : r ? {
31
+ state: "error",
32
+ message: i.todayInsufficientFunds
33
+ } : {
34
+ state: "warning",
35
+ message: i.futureInsufficientFunds
36
+ };
48
37
  }
49
38
  //#endregion
50
- export { d as calculateTotal, u as displayLineAmount, i as isPersistableLineItem, c as mapBillFormToPayload, l as mapLineItemsToPayload, n as parseMoneyToMinorUnits, r as parseQuantity };
39
+ export { n as SOURCE_ACCOUNT_LABELS_EN, a as deriveSourceAccountFunds, i as mapSourceAccountOptions };
@@ -1,34 +1,42 @@
1
- import { BILL_CREATE_MESSAGE_LABELS_EN as e } from "./index2.js";
2
- import { isPersistableLineItem as t, parseMoneyToMinorUnits as n, parseQuantity as r } from "./index6.js";
1
+ import { SOURCE_ACCOUNT_LABELS_EN as e } from "./index6.js";
2
+ import { REVIEW_TRANSACTION_DIALOG_LABELS_EN as t } from "../../ui/dist/index54.js";
3
+ import { SCHEDULE_PAYMENT_DIALOG_LABELS_EN as n } from "../../ui/dist/index57.js";
4
+ import "../../ui/dist/index.js";
3
5
  //#region ../../libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index7.js
4
- var i = /^(?:\d{1,3}(?:,\d{3})+(?:\.\d+)?|\d+(?:\.\d+)?|\.\d+)$/;
5
- function a(e) {
6
- let t = e.trim();
7
- return !t || n(t) !== null ? !0 : i.test(t) ? Number(t.replaceAll(",", "")) === 0 : !1;
8
- }
9
- function o(t, i = e) {
10
- let a = {};
11
- for (let e of t) {
12
- let t = n(e.price), o = n(e.amount), s = {};
13
- e.price.trim() && t === null && (s.price = i.unreadableMoney), e.amount.trim() && o === null && (s.amount = i.unreadableMoney), (t !== null || o !== null) && r(e.quantity) === null && (s.quantity = i.unusableQuantity), Object.keys(s).length && (a[e.id] = s);
14
- }
15
- return Object.keys(a).length ? a : void 0;
16
- }
17
- function s(i, a, o, s = e) {
18
- let c = {};
19
- a || (c.vendor = s.requiredField), i.invoiceNumber.trim() || (c.invoiceNumber = s.requiredField), i.invoiceDate.trim() || (c.invoiceDate = s.requiredField), i.dueDate.trim() || (c.dueDate = s.requiredField);
20
- let l = {};
21
- return o.forEach((e, i) => {
22
- if (i > 0 && !t(e)) return;
23
- let a = {};
24
- e.description.trim() || (a.description = s.requiredField), r(e.quantity) === null && (a.quantity = s.requiredField), n(e.price) === null && n(e.amount) === null && (a.price = s.requiredField, a.amount = s.requiredField), Object.keys(a).length && (l[e.id] = a);
25
- }), {
26
- formErrors: Object.keys(c).length ? c : void 0,
27
- lineItemErrors: Object.keys(l).length ? l : void 0
6
+ var r = {
7
+ amountDue: "Amount due",
8
+ paymentAmount: "Payment amount",
9
+ dueDateSuffix: (e) => `by ${e}`,
10
+ paymentDate: "Payment date",
11
+ sourceAccount: "Pay from",
12
+ accountHolder: "Account holder name",
13
+ routingNumber: "Routing number",
14
+ accountNumber: "Account number",
15
+ achMethod: "Pay by ACH bank transfer",
16
+ scheduledToast: "Payment scheduled",
17
+ submitError: "Couldn't schedule this payment. Try again.",
18
+ selectAccountError: "Select a source account.",
19
+ selectDateError: "Select a payment date.",
20
+ staleDateError: "That date has passed. Choose a new payment date.",
21
+ missingPaymentInstructionsError: "This vendor does not have ACH payment instructions on file.",
22
+ missingVendorName: "Not provided",
23
+ ...e,
24
+ scheduleDialog: n,
25
+ reviewDialog: t
26
+ };
27
+ function i(e) {
28
+ return {
29
+ ...r,
30
+ ...e,
31
+ scheduleDialog: {
32
+ ...r.scheduleDialog,
33
+ ...e?.scheduleDialog
34
+ },
35
+ reviewDialog: {
36
+ ...r.reviewDialog,
37
+ ...e?.reviewDialog
38
+ }
28
39
  };
29
40
  }
30
- function c(t, r, i, o = e) {
31
- return !a(t) || !a(r) || i !== void 0 && n(i) === null ? { form: o.totalsNeedAttention } : void 0;
32
- }
33
41
  //#endregion
34
- export { s as validateBillCompleteness, c as validateBillTotals, o as validateLineItems };
42
+ export { r as PAY_BILL_FLOW_LABELS_EN, i as mergePayBillFlowLabels };
@@ -1,157 +1,26 @@
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 "../../../shared/ui/dist/index.js";
7
- import { BILL_CREATE_MESSAGE_LABELS_EN as t } from "./index2.js";
8
- import { useReplacePayableLineItemsMutation as n } from "../../data-access/dist/index6.js";
9
- import { useCreatePayableMutation as r, useSubmitPayableForApprovalMutation as i, useUpdatePayableMutation as a, useValidatePayableMutation as o } from "../../data-access/dist/index7.js";
10
- import "../../data-access/dist/index.js";
11
- import { mapBillFormToPayload as s, mapLineItemsToPayload as c } from "./index6.js";
12
- import { validateBillCompleteness as l, validateBillTotals as u, validateLineItems as d } from "./index7.js";
13
- import { useCallback as f, useRef as p, useState as m } from "react";
14
1
  //#region ../../libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index8.js
15
- var h = {
16
- document_id: "invoiceNumber",
17
- issued_at: "invoiceDate",
18
- due_date: "dueDate",
19
- counterpart_id: "vendor"
20
- };
21
- function g(e) {
22
- return e.type === "type_error.none.not_allowed" || e.msg === "none is not an allowed value";
2
+ var e = new Intl.DateTimeFormat("en-CA", {
3
+ timeZone: "America/New_York",
4
+ year: "numeric",
5
+ month: "2-digit",
6
+ day: "2-digit"
7
+ });
8
+ function t(t = /* @__PURE__ */ new Date()) {
9
+ let n = e.formatToParts(t), r = Object.fromEntries(n.map((e) => [e.type, e.value]));
10
+ return `${r.year}-${r.month}-${r.day}`;
23
11
  }
24
- function _(e, n = t) {
25
- let r = {}, i = [];
26
- for (let t of e) {
27
- let e = t.loc[0] ?? n.unknownValidationField, a = h[e], o = g(t) ? n.requiredField : t.msg;
28
- a ? r[a] = o : i.push(n.unmappedValidationError(e, o));
29
- }
30
- return i.length && (r.form = i.join(" ")), r;
12
+ function n(e) {
13
+ return `${e.getFullYear()}-${String(e.getMonth() + 1).padStart(2, "0")}-${String(e.getDate()).padStart(2, "0")}`;
31
14
  }
32
- function v(e, t) {
33
- if (!e && !t) return;
34
- let n = {}, r = /* @__PURE__ */ new Set([...Object.keys(e ?? {}), ...Object.keys(t ?? {})]);
35
- for (let i of r) n[i] = {
36
- ...e?.[i],
37
- ...t?.[i]
38
- };
39
- return n;
15
+ function r(e, r = /* @__PURE__ */ new Date()) {
16
+ return n(e) === t(r);
40
17
  }
41
- function y({ payableId: h, form: g, counterpartId: y, clearCounterpart: b, prepareVendorForSave: x, onSaved: S, onPayableCreated: C, onDraftSaved: w, onFinalized: T, labels: E }) {
42
- let D = {
43
- ...t,
44
- ...E
45
- }, [O, k] = m(), A = h ?? O, [j, M] = m(), N = p(!1), P = r(), F = a(), I = n(), L = o(), R = i(), z = f(() => {
46
- let t = d(g.lineItems, D), n = u(g.discount, g.tax, g.totalOverride, D);
47
- return g.setLineItemErrors(t), !t && !n || (t ? (g.setErrors(void 0), e.error(D.lineItemsNeedAttention)) : g.setErrors(n), !1);
48
- }, [g, D]), B = f(async () => {
49
- let e = s({
50
- values: g.values,
51
- counterpartId: y,
52
- clearCounterpart: b,
53
- editedTotals: g.isTotalsDirty ? {
54
- discount: g.discount,
55
- tax: g.tax,
56
- total: g.totalOverride
57
- } : void 0
58
- }), t = A;
59
- if (t ? await F.mutateAsync({
60
- path: { payable_id: t },
61
- body: e
62
- }) : (t = (await P.mutateAsync({ body: e }))?.id, t && (k(t), C?.(t))), !t) throw Error("Payable was created without an id");
63
- return await I.mutateAsync({
64
- path: { payable_id: t },
65
- body: { data: c(g.lineItems) }
66
- }), t;
67
- }, [
68
- y,
69
- b,
70
- P,
71
- g.discount,
72
- g.isTotalsDirty,
73
- g.lineItems,
74
- g.tax,
75
- g.totalOverride,
76
- g.values,
77
- C,
78
- A,
79
- I,
80
- F
81
- ]);
82
- return {
83
- saveDraft: f(async () => {
84
- if (!N.current && z()) {
85
- N.current = !0, M("draft");
86
- try {
87
- if (await x?.() === !1) return;
88
- let t = await B();
89
- g.setErrors(void 0), S?.(t), w?.(t), e.success(D.draftSaved);
90
- } catch {
91
- g.setErrors({ form: D.saveFailed });
92
- } finally {
93
- M(void 0), N.current = !1;
94
- }
95
- }
96
- }, [
97
- g,
98
- z,
99
- D.draftSaved,
100
- D.saveFailed,
101
- w,
102
- S,
103
- x,
104
- B
105
- ]),
106
- finalize: f(async () => {
107
- if (N.current) return;
108
- let t = d(g.lineItems, D), n = u(g.discount, g.tax, g.totalOverride, D), { formErrors: r, lineItemErrors: i } = l(g.values, y, g.lineItems, D), a = v(i, t);
109
- g.setLineItemErrors(a);
110
- let o = {
111
- ...r,
112
- ...n
113
- };
114
- if (g.setErrors(Object.keys(o).length ? o : void 0), t && e.error(D.lineItemsNeedAttention), !(a || Object.keys(o).length)) {
115
- N.current = !0, M("finalize");
116
- try {
117
- let t;
118
- try {
119
- if (await x?.() === !1) return;
120
- t = await B();
121
- } catch {
122
- g.setErrors({ form: D.saveFailed });
123
- return;
124
- }
125
- S?.(t);
126
- try {
127
- let n = await L.mutateAsync({ path: { payable_id: t } });
128
- if (n.validation_errors.length) {
129
- g.setErrors(_(n.validation_errors, D));
130
- return;
131
- }
132
- await R.mutateAsync({ path: { payable_id: t } }), g.setErrors(void 0), T?.(t), e.success(D.billFinalized);
133
- } catch {
134
- g.setErrors({ form: D.finalizeFailed });
135
- }
136
- } finally {
137
- M(void 0), N.current = !1;
138
- }
139
- }
140
- }, [
141
- y,
142
- g,
143
- D,
144
- T,
145
- S,
146
- x,
147
- B,
148
- R,
149
- L
150
- ]),
151
- payableId: A,
152
- isSavingDraft: j === "draft",
153
- isFinalizing: j === "finalize"
154
- };
18
+ function i(e = /* @__PURE__ */ new Date()) {
19
+ let [n, r, i] = t(e).split("-").map(Number);
20
+ return new Date(n, r - 1, i);
21
+ }
22
+ function a(e, r = /* @__PURE__ */ new Date()) {
23
+ return n(e) < t(r);
155
24
  }
156
25
  //#endregion
157
- export { _ as mapValidationErrorsToForm, y as useBillCreateController };
26
+ export { n as dateToCalendarKey, i as getDefaultPaymentDate, t as getEasternDateKey, a as isPastEasternDate, r as isTodayInEastern };
@@ -1,38 +1,165 @@
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 { useAllBankAccountsQuery as t } from "../../../shared/data-access/dist/lib/bank-account/useAllBankAccountsQuery.js";
7
+ import "../../../shared/data-access/dist/index.js";
8
+ import "../../../shared/ui/dist/index.js";
9
+ import { useAnalyticsCaptureException as n } from "../../../shared/feature/dist/lib/analytics/hooks.js";
10
+ import { formatCalendarDate as r } from "../../../shared/util/dist/lib/formatCalendarDate.js";
11
+ import { formatMoneyExact as i } from "../../../shared/util/dist/lib/formatMoneyExact.js";
12
+ import { extractApiErrorMessage as a } from "../../../shared/util/dist/lib/apiErrors.js";
13
+ import "../../../shared/feature/dist/index.js";
14
+ import { maskAccountNumber as o } from "./index5.js";
15
+ import { deriveSourceAccountFunds as s, mapSourceAccountOptions as c } from "./index6.js";
16
+ import { mergePayBillFlowLabels as l } from "./index7.js";
17
+ import { dateToCalendarKey as u, getDefaultPaymentDate as d, isPastEasternDate as f, isTodayInEastern as p } from "./index8.js";
18
+ import { useSchedulePaymentMutation as m } from "../../data-access/dist/index9.js";
19
+ import "../../data-access/dist/index.js";
20
+ import { useMemo as h, useState as g } from "react";
1
21
  //#region ../../libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index9.js
2
- function e() {
3
- return {
4
- id: crypto.randomUUID(),
5
- description: "",
6
- glCode: "",
7
- quantity: "1",
8
- price: "",
9
- amount: ""
10
- };
22
+ function _(e) {
23
+ return !!(e?.account_holder_name && e.routing_number && e.account_number);
11
24
  }
12
- function t(e) {
13
- return typeof e == "number" ? (e / 100).toFixed(2) : "";
25
+ function v({ selectedDate: e, selectedAccount: t, amountDueMinorUnits: n, labels: r }) {
26
+ if (!e) return {
27
+ ok: !1,
28
+ error: r.selectDateError
29
+ };
30
+ if (f(e)) return {
31
+ ok: !1,
32
+ error: r.staleDateError
33
+ };
34
+ if (!t) return {
35
+ ok: !1,
36
+ error: r.selectAccountError
37
+ };
38
+ let i = s({
39
+ selectedAccount: t,
40
+ amountDueMinorUnits: n,
41
+ isToday: p(e),
42
+ labels: r
43
+ });
44
+ return i.state === "error" ? {
45
+ ok: !1,
46
+ error: i.message ?? r.todayInsufficientFunds
47
+ } : {
48
+ ok: !0,
49
+ date: e,
50
+ account: t
51
+ };
14
52
  }
15
- function n({ payable: n, lineItems: r }) {
16
- let i = {
17
- invoiceNumber: n.document_id ?? "",
18
- invoiceDate: n.issued_at ?? "",
19
- dueDate: n.due_date ?? "",
20
- poNumber: ""
21
- }, a = r.map((e) => ({
22
- id: e.id,
23
- description: e.name ?? "",
24
- glCode: e.ledger_account_id ?? "",
25
- quantity: e.quantity == null ? "" : String(e.quantity),
26
- price: t(e.unit_price),
27
- amount: t(e.subtotal)
28
- }));
53
+ function y({ payableId: f, amountDueMinorUnits: y, currencyCode: b = "USD", dueDate: x, vendorName: S, vendorEmail: C, vendorBankAccount: w, poweredByBankName: T, labels: E }) {
54
+ let D = h(() => l(E), [E]), O = S ?? D.missingVendorName, [k, A] = g(!1), [j, M] = g(!1), [N, P] = g(() => d()), [F, I] = g(), L = t({ enabled: k || j }), R = m(), z = n(), B = h(() => c(L.data?.data ?? [], D), [L.data?.data, D]), V = B.find((e) => e.id === F), H = N ? p(N) : !1, U = { before: d() }, W = s({
55
+ selectedAccount: V,
56
+ amountDueMinorUnits: y,
57
+ isToday: H,
58
+ labels: D
59
+ }), G = i(y / 100, { currencyCode: b }), K = N ? r(u(N)) : void 0, q = x ? D.dueDateSuffix(r(x)) : void 0, J = () => v({
60
+ selectedDate: N,
61
+ selectedAccount: V,
62
+ amountDueMinorUnits: y,
63
+ labels: D
64
+ }), Y = () => {
65
+ if (!_(w)) {
66
+ e.error(D.missingPaymentInstructionsError);
67
+ return;
68
+ }
69
+ A(!0);
70
+ }, X = () => {
71
+ M(!1), A(!1);
72
+ };
29
73
  return {
30
- values: i,
31
- lineItems: a.length ? a : [e()],
32
- discount: t(n.discount),
33
- tax: t(n.tax_amount),
34
- total: t(n.total_amount)
74
+ open: Y,
75
+ dialogProps: {
76
+ open: k,
77
+ onOpenChange: A,
78
+ amountDueLabel: D.amountDue,
79
+ amountDue: G,
80
+ dueDateSuffix: q,
81
+ paymentAmountLabel: D.paymentAmount,
82
+ paymentAmount: G,
83
+ selectedDate: N,
84
+ selectedDateLabel: K,
85
+ calendarDisabled: U,
86
+ isToday: H,
87
+ selectedAccountId: F,
88
+ accounts: B,
89
+ poweredByBankName: T,
90
+ funds: W,
91
+ isAccountsLoading: L.isLoading,
92
+ isAccountsError: L.isError,
93
+ isSubmitting: R.isPending,
94
+ onDateChange: P,
95
+ onAccountChange: I,
96
+ onReview: () => {
97
+ let t = J();
98
+ if (!t.ok) {
99
+ e.error(t.error);
100
+ return;
101
+ }
102
+ A(!1), M(!0);
103
+ },
104
+ onCancel: X,
105
+ labels: D.scheduleDialog
106
+ },
107
+ reviewProps: {
108
+ open: j,
109
+ onOpenChange: M,
110
+ amountLabel: D.paymentAmount,
111
+ amount: G,
112
+ rows: [{
113
+ label: D.sourceAccount,
114
+ value: V?.primaryLabel ?? ""
115
+ }, {
116
+ label: D.paymentDate,
117
+ value: K ?? ""
118
+ }],
119
+ payTo: {
120
+ name: O,
121
+ email: C,
122
+ methodLabel: D.achMethod,
123
+ fields: _(w) ? [
124
+ {
125
+ label: D.routingNumber,
126
+ value: w.routing_number
127
+ },
128
+ {
129
+ label: D.accountNumber,
130
+ value: w.account_number,
131
+ maskedValue: o(w.account_number)
132
+ },
133
+ {
134
+ label: D.accountHolder,
135
+ value: w.account_holder_name
136
+ }
137
+ ] : []
138
+ },
139
+ isSubmitting: R.isPending,
140
+ onBack: () => {
141
+ M(!1), A(!0);
142
+ },
143
+ onCancel: X,
144
+ onSubmit: async () => {
145
+ let t = J();
146
+ if (!t.ok) {
147
+ M(!1), e.error(t.error), A(!0);
148
+ return;
149
+ }
150
+ try {
151
+ await R.mutateAsync({
152
+ payableId: f,
153
+ paymentDate: u(t.date),
154
+ sourceBankAccountId: t.account.id
155
+ }), X(), e.success(D.scheduledToast);
156
+ } catch (t) {
157
+ z(t, { payable_id: f }), e.error(a(t) ?? D.submitError);
158
+ }
159
+ },
160
+ labels: D.reviewDialog
161
+ }
35
162
  };
36
163
  }
37
164
  //#endregion
38
- export { e as emptyLineItem, n as mapPayableToBillForm };
165
+ export { y as usePayBillFlow };