@tesouro/embedded-components-react 0.2.327 → 0.2.328

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 (133) hide show
  1. package/dist/index.css +3 -0
  2. package/dist/index.d.ts +59 -59
  3. package/dist/index.js +1 -1
  4. package/dist/lib/BillPayWidget.js +1 -1
  5. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/data-access/dist/index.js +10 -10
  6. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/data-access/dist/index10.js +119 -33
  7. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/data-access/dist/index4.js +50 -21
  8. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/data-access/dist/index5.js +39 -17
  9. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/data-access/dist/index8.js +1 -1
  10. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/data-access/dist/index9.js +17 -12
  11. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index.js +10 -10
  12. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index10.js +2 -2
  13. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index12.js +45 -17
  14. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index13.js +4 -21
  15. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index14.js +9 -24
  16. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index15.js +42 -9
  17. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index16.js +25 -50
  18. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index17.js +49 -5
  19. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index18.js +91 -63
  20. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index19.js +20 -49
  21. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index20.js +52 -7
  22. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index21.js +5 -35
  23. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index22.js +67 -113
  24. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index23.js +46 -53
  25. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index24.js +80 -205
  26. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index25.js +32 -192
  27. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index26.js +117 -62
  28. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index27.js +54 -45
  29. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index28.js +205 -31
  30. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index29.js +184 -143
  31. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index30.js +63 -33
  32. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index31.js +46 -100
  33. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index32.js +32 -7
  34. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index33.js +146 -182
  35. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index34.js +38 -4
  36. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index35.js +102 -24
  37. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index36.js +10 -80
  38. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index37.js +200 -78
  39. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index38.js +2 -1
  40. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index39.js +27 -2
  41. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index40.js +78 -41
  42. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index41.js +132 -1
  43. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index42.js +3 -53
  44. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index43.js +2 -9
  45. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index44.js +43 -16
  46. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index45.js +1 -8
  47. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index46.js +50 -77
  48. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index47.js +8 -145
  49. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index48.js +18 -5
  50. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index49.js +6 -6
  51. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index50.js +78 -7
  52. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index51.js +138 -75
  53. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index52.js +2 -0
  54. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index53.js +6 -6
  55. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index54.js +7 -113
  56. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index55.js +85 -1
  57. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index56.js +2 -24
  58. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index57.js +8 -0
  59. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index58.js +115 -0
  60. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index59.js +1 -0
  61. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index60.js +25 -0
  62. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index7.js +2 -2
  63. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index.js +33 -25
  64. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index12.js +13 -12
  65. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index13.js +58 -13
  66. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index14.js +2 -24
  67. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index15.js +22 -2
  68. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index16.js +23 -31
  69. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index17.js +1 -262
  70. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index18.js +15 -2
  71. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index19.js +23 -6
  72. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index20.js +2 -49
  73. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index21.js +41 -1
  74. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index22.js +271 -20
  75. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index23.js +2 -286
  76. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index24.js +9 -2
  77. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index25.js +47 -14
  78. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index26.js +2 -120
  79. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index27.js +22 -2
  80. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index28.js +284 -8
  81. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index29.js +2 -96
  82. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index30.js +16 -2
  83. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index31.js +118 -11
  84. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index32.js +1 -57
  85. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index33.js +10 -2
  86. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index34.js +93 -51
  87. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index35.js +1 -138
  88. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index36.js +12 -1
  89. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index37.js +56 -5
  90. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index38.js +2 -44
  91. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index39.js +53 -1
  92. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index40.js +137 -2
  93. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index41.js +2 -16
  94. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index42.js +7 -2
  95. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index43.js +42 -59
  96. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index44.js +2 -238
  97. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index45.js +2 -202
  98. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index46.js +61 -8
  99. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index47.js +2 -8
  100. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index48.js +2 -91
  101. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index49.js +16 -0
  102. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index50.js +1 -1
  103. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index51.js +67 -4
  104. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index52.js +248 -25
  105. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index53.js +204 -2
  106. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index54.js +6 -3
  107. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index55.js +6 -32
  108. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index56.js +93 -2
  109. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index58.js +1 -105
  110. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index59.js +7 -2
  111. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index60.js +28 -16
  112. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index61.js +2 -10
  113. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index62.js +4 -167
  114. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index63.js +34 -2
  115. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index64.js +2 -14
  116. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index65.js +10 -87
  117. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index66.js +105 -1
  118. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index67.js +2 -0
  119. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index68.js +18 -0
  120. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index69.js +10 -0
  121. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index70.js +170 -0
  122. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index71.js +2 -0
  123. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index72.js +14 -0
  124. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index73.js +89 -0
  125. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index74.js +2 -0
  126. package/dist/libs/tesouro-embedded-components-react/shared/approval-policy/data-access/dist/lib/approvalPoliciesApi.js +20 -20
  127. package/dist/libs/tesouro-embedded-components-react/shared/approval-policy/feature/dist/index.js +4 -4
  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/sdk.gen.js +142 -102
  130. package/dist/libs/tesouro-embedded-components-react/shared/feature/dist/lib/analytics/build-info.js +1 -1
  131. package/dist/libs/tesouro-embedded-components-react/widget-suite/feature/dist/index7.js +1 -1
  132. package/package.json +1 -1
  133. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index57.js +0 -12
@@ -2,156 +2,197 @@
2
2
  "use client";
3
3
  "use client";
4
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 { useReplacePayableLineItemsMutation as t } from "../../data-access/dist/index7.js";
8
- import { useCreatePayableMutation as n, useSubmitPayableForApprovalMutation as r, useUpdatePayableMutation as i, useValidatePayableMutation as a } from "../../data-access/dist/index10.js";
5
+ import { maskAccountNumber as e } from "./index5.js";
6
+ import { usePayableSuggestionsQuery as t } from "../../data-access/dist/index14.js";
9
7
  import "../../data-access/dist/index.js";
10
- import { BILL_CREATE_MESSAGE_LABELS_EN as o } from "./index22.js";
11
- import { mapBillFormToPayload as s, mapLineItemsToPayload as c } from "./index27.js";
12
- import { validateBillCompleteness as l, validateBillTotals as u, validateLineItems as d } from "./index28.js";
13
- import { useCallback as f, useRef as p, useState as m } from "react";
8
+ import { VENDOR_SECTION_PROPS_LABELS_EN as n } from "./index26.js";
9
+ import { counterpartFormBankAccountToCreatePayload as ee, counterpartFormBankAccountToUpdatePayload as r, getAchInstructions as i, getCounterpartEmail as a, getCounterpartName as o, getPayableAchInstructions as s, hasAchFormValues as c, resolveCounterpartBankAccountWrite as te, validateAchFormValues as ne } from "../../../shared/counterpart-management/feature/dist/lib/helpers.js";
10
+ import { useCounterpartsQuery as re } from "../../../shared/counterpart-management/data-access/dist/index3.js";
11
+ import { useCreateCounterpartBankAccountMutation as ie, useUpdateCounterpartBankAccountMutation as l } from "../../../shared/counterpart-management/data-access/dist/index5.js";
12
+ import { useCounterpartDetails as ae } from "../../../shared/counterpart-management/feature/dist/lib/useCounterpartDetails.js";
13
+ import "../../../shared/counterpart-management/feature/dist/index.js";
14
+ import { VendorInlineForm as oe } from "./index28.js";
15
+ import { useCallback as u, useEffect as d, useMemo as f, useRef as p, useState as m } from "react";
16
+ import { jsx as h } from "react/jsx-runtime";
14
17
  //#region ../../libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index29.js
15
- var h = {
16
- document_id: "invoiceNumber",
17
- issued_at: "invoiceDate",
18
- due_date: "dueDate",
19
- counterpart_id: "vendor"
18
+ var se = 10, ce = 300, g = {
19
+ accountHolderName: "",
20
+ routingNumber: "",
21
+ accountNumber: ""
20
22
  };
21
- function g(e) {
22
- return e.type === "type_error.none.not_allowed" || e.msg === "none is not an allowed value";
23
- }
24
- function _(e, t = o) {
25
- let n = {}, r = [];
26
- for (let i of e) {
27
- let e = i.loc[0] ?? t.unknownValidationField, a = h[e], o = g(i) ? t.requiredField : i.msg;
28
- a ? n[a] = o : r.push(t.unmappedValidationError(e, o));
29
- }
30
- return r.length && (n.form = r.join(" ")), n;
31
- }
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;
40
- }
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
- ...o,
44
- ...E
45
- }, [O, k] = m(), A = h ?? O, [j, M] = m(), N = p(!1), P = n(), F = i(), I = t(), L = a(), R = r(), 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;
23
+ function _({ payableId: _, counterpartId: v, payableCounterpartId: y, onCounterpartChange: b, requiredError: x, labels: S }) {
24
+ let C = {
25
+ ...n,
26
+ ...S
27
+ }, [w, T] = m(""), [E, D] = m(""), [O, k] = m(), [le, A] = m(!1), [j, M] = m(g), N = p(j);
28
+ N.current = j;
29
+ let [ue, P] = m(!1), F = c(j) || ue, [I, L] = m(), [R, z] = m(), B = p(v), [V, H] = m(!1), U = u(() => {
30
+ A(!1), M(g), L(void 0), z(void 0);
31
+ }, []), W = u((e) => {
32
+ H(!0), b(e);
33
+ }, [b]), G = t(_, { enabled: !!_ && !v && !y }).data?.suggested_counterpart?.id;
34
+ d(() => {
35
+ !V && !v && !y && G && W(G);
67
36
  }, [
37
+ v,
68
38
  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;
39
+ V,
40
+ G,
41
+ W
42
+ ]), d(() => {
43
+ B.current !== v && (B.current = v, U());
44
+ }, [v, U]), d(() => {
45
+ let e = setTimeout(() => {
46
+ D(w.trim());
47
+ }, ce);
48
+ return () => clearTimeout(e);
49
+ }, [w]);
50
+ let K = re({
51
+ sort: "counterpart_name",
52
+ order: "asc",
53
+ limit: se,
54
+ counterpart_name__icontains: E || void 0,
55
+ is_vendor: !0,
56
+ enabled: !!E
57
+ }), q = ae({ selectedId: v }), J = ie(), Y = l(), X = f(() => {
58
+ let t = q.counterpart;
59
+ if (!t) return;
60
+ if (q.isBankAccountsLoading) return {
61
+ name: o(t),
62
+ email: a(t),
63
+ methodLabel: C.paymentMethodLoading,
64
+ fields: []
65
+ };
66
+ if (q.isBankAccountsError) return {
67
+ name: o(t),
68
+ email: a(t),
69
+ methodLabel: C.paymentMethodUnavailable,
70
+ fields: []
71
+ };
72
+ let n = s(q.bankAccounts);
73
+ return {
74
+ name: o(t),
75
+ email: a(t),
76
+ methodLabel: n ? C.achMethod : C.noMethod,
77
+ fields: n ? [
78
+ {
79
+ label: C.accountHolder,
80
+ value: n.account_holder_name ?? ""
81
+ },
82
+ {
83
+ label: C.routingNumber,
84
+ value: n.routing_number ?? ""
85
+ },
86
+ {
87
+ label: C.accountNumber,
88
+ value: n.account_number ?? "",
89
+ maskedValue: n.account_number ? e(n.account_number) : ""
94
90
  }
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;
91
+ ] : []
92
+ };
93
+ }, [
94
+ q.bankAccounts,
95
+ q.counterpart,
96
+ q.isBankAccountsError,
97
+ q.isBankAccountsLoading,
98
+ C
99
+ ]), Z = f(() => i(q.bankAccounts), [q.bankAccounts]), Q = u(async () => {
100
+ let e = N.current;
101
+ if (!v || !c(e)) return !0;
102
+ if (q.isBankAccountsLoading || q.isBankAccountsError) return !1;
103
+ let t = ne(e);
104
+ if (Object.keys(t).length > 0) return L(t), A(!0), !1;
105
+ L(void 0);
106
+ let n = te(q.bankAccounts, R ?? Z?.id);
107
+ if (n.kind === "update") return await Y.mutateAsync({
108
+ path: {
109
+ counterpart_id: v,
110
+ bank_account_id: n.bankAccountId
111
+ },
112
+ body: r(e, { includeAchDefaults: n.includeAchDefaults })
113
+ }), z(n.bankAccountId), !0;
114
+ let i = await J.mutateAsync({
115
+ path: { counterpart_id: v },
116
+ body: ee(e)
117
+ });
118
+ return z(i?.id), !0;
119
+ }, [
120
+ Z,
121
+ v,
122
+ J,
123
+ q.bankAccounts,
124
+ q.isBankAccountsError,
125
+ q.isBankAccountsLoading,
126
+ R,
127
+ Y
128
+ ]), de = f(() => (K.data?.data ?? []).map((e) => ({
129
+ name: o(e),
130
+ email: a(e),
131
+ onSelect: () => W(e.id)
132
+ })), [K.data, W]), $ = u(() => {
133
+ k(void 0), P(!1);
134
+ }, []), fe = u((e) => {
135
+ k(void 0), P(!1), W(e);
136
+ }, [W]);
137
+ if (O) return {
138
+ mode: "creating",
139
+ newVendorForm: /* @__PURE__ */ h(oe, {
140
+ mode: O,
141
+ counterpart: O === "edit" ? q.counterpart : void 0,
142
+ primaryAddress: O === "edit" ? q.primaryAddress : void 0,
143
+ bankAccounts: O === "edit" ? q.bankAccounts : void 0,
144
+ isBankAccountsLoading: O === "edit" ? q.isBankAccountsLoading : void 0,
145
+ isBankAccountsError: O === "edit" ? q.isBankAccountsError : void 0,
146
+ initialName: O === "create" ? w : void 0,
147
+ onSaved: fe,
148
+ onCancel: $,
149
+ onDirtyChange: P
150
+ }),
151
+ onClear: $,
152
+ hasUnsavedVendorChanges: F
153
+ };
154
+ if (X) {
155
+ let e = q.isBankAccountsLoading || q.isBankAccountsError;
156
+ return {
157
+ mode: "resolved",
158
+ summary: X,
159
+ onEdit: e ? void 0 : () => k("edit"),
160
+ onClear: () => W(void 0),
161
+ paymentInstructions: e ? void 0 : {
162
+ isOpen: le,
163
+ values: j,
164
+ errors: I,
165
+ onOpen: () => {
166
+ A(!0), Z && (M({
167
+ accountHolderName: Z.account_holder_name ?? "",
168
+ routingNumber: Z.routing_number ?? "",
169
+ accountNumber: Z.account_number ?? ""
170
+ }), z(Z.id));
171
+ },
172
+ onChange: (e) => {
173
+ M((t) => ({
174
+ ...t,
175
+ ...e
176
+ })), L(void 0);
138
177
  }
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"
178
+ },
179
+ savePaymentInstructions: Q,
180
+ hasUnsavedVendorChanges: F
181
+ };
182
+ }
183
+ return {
184
+ mode: "selecting",
185
+ error: K.isError ? C.searchFailed : q.isError ? C.vendorDetailsFailed : x,
186
+ search: {
187
+ query: w,
188
+ onQueryChange: T,
189
+ isLoading: K.isLoading,
190
+ onAddVendor: () => k("create"),
191
+ results: de
192
+ },
193
+ savePaymentInstructions: Q,
194
+ hasUnsavedVendorChanges: F
154
195
  };
155
196
  }
156
197
  //#endregion
157
- export { _ as mapValidationErrorsToForm, y as useBillCreateController };
198
+ export { _ as useVendorSectionProps };
@@ -1,38 +1,68 @@
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 { useUpdatePayableMutation as t } from "../../data-access/dist/index10.js";
8
+ import "../../data-access/dist/index.js";
9
+ import { counterpartFormBankAccountToCreatePayload as n, validateAchFormValues as r } from "../../../shared/counterpart-management/feature/dist/lib/helpers.js";
10
+ import { useCreateCounterpartBankAccountMutation as i } from "../../../shared/counterpart-management/data-access/dist/index5.js";
11
+ import "../../../shared/counterpart-management/feature/dist/index.js";
12
+ import { useCallback as a, useRef as o, useState as s } from "react";
1
13
  //#region ../../libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index30.js
2
- function e() {
14
+ var c = {
15
+ accountHolderName: "",
16
+ routingNumber: "",
17
+ accountNumber: ""
18
+ };
19
+ function l({ payableId: l, counterpartId: u, saveErrorMessage: d }) {
20
+ let [f, p] = s(!1), [m, h] = s(c), [g, _] = s(), v = i(), y = t(), b = o(void 0), x = a(() => {
21
+ h(c), _(void 0), b.current = void 0, p(!0);
22
+ }, []), S = a(() => {
23
+ p(!1);
24
+ }, []), C = a((e) => {
25
+ h((t) => ({
26
+ ...t,
27
+ ...e
28
+ }));
29
+ }, []), w = a(async () => {
30
+ if (!l || !u) return !1;
31
+ let t = r(m);
32
+ if (Object.keys(t).length > 0) return _(t), !1;
33
+ try {
34
+ if (!b.current) {
35
+ let e = await v.mutateAsync({
36
+ path: { counterpart_id: u },
37
+ body: n(m)
38
+ });
39
+ b.current = e.id;
40
+ }
41
+ return await y.mutateAsync({
42
+ path: { payable_id: l },
43
+ body: { counterpart_bank_account_id: b.current }
44
+ }), b.current = void 0, p(!1), !0;
45
+ } catch {
46
+ return e.error(d), !1;
47
+ }
48
+ }, [
49
+ u,
50
+ v,
51
+ l,
52
+ d,
53
+ y,
54
+ m
55
+ ]);
3
56
  return {
4
- id: crypto.randomUUID(),
5
- description: "",
6
- glCode: "",
7
- quantity: "1",
8
- price: "",
9
- amount: ""
10
- };
11
- }
12
- function t(e) {
13
- return typeof e == "number" ? (e / 100).toFixed(2) : "";
14
- }
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
- }));
29
- 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)
57
+ isOpen: f,
58
+ values: m,
59
+ errors: g,
60
+ isSaving: v.isPending || y.isPending,
61
+ open: x,
62
+ close: S,
63
+ onChange: C,
64
+ save: w
35
65
  };
36
66
  }
37
67
  //#endregion
38
- export { e as emptyLineItem, n as mapPayableToBillForm };
68
+ export { l as usePaymentInstructionsForm };
@@ -1,104 +1,50 @@
1
- "use client";
2
- "use client";
3
- "use client";
4
- "use client";
5
- import { calculateTotal as e, displayLineAmount as t, parseMoneyToMinorUnits as n } from "./index27.js";
6
- import { emptyLineItem as r, mapPayableToBillForm as i } from "./index30.js";
7
- import { useCallback as a, useEffect as o, useMemo as s, useState as c } from "react";
1
+ import { parseDecimalAmountToMinorUnits as e } from "../../../shared/util/dist/lib/parseDecimalAmountToMinorUnits.js";
2
+ import "../../data-access/dist/index.js";
8
3
  //#region ../../libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index31.js
9
- function l(e, r, i) {
10
- return n(r) === null ? i : t(e, r);
4
+ var t = "USD";
5
+ function n(n) {
6
+ return e(n, t);
11
7
  }
12
- function u({ payable: t, lineItems: n } = {}) {
13
- let u = s(() => i({
14
- payable: t ?? {},
15
- lineItems: n ?? []
16
- }), [t, n]), [d, f] = c(u.values), [p, m] = c(u.lineItems), [h, g] = c(u.discount), [_, v] = c(u.tax), [y, b] = c(u.total || void 0), [x, S] = c(), [C, w] = c(), [T, E] = c(!1), [D, O] = c(!1), [k, A] = c(!1);
17
- o(() => {
18
- T || f(u.values);
19
- }, [u]), o(() => {
20
- D || m(u.lineItems);
21
- }, [u]), o(() => {
22
- k || (g(u.discount), v(u.tax), b(u.total || void 0));
23
- }, [u]);
24
- let j = a((e) => {
25
- f((t) => ({
26
- ...t,
27
- ...e
28
- })), E(!0);
29
- }, []), M = a((e) => {
30
- w((t) => {
31
- if (!t?.[e]) return t;
32
- let n = { ...t };
33
- return delete n[e], Object.keys(n).length ? n : void 0;
34
- });
35
- }, []), N = a((e, t) => {
36
- M(e), m((n) => n.map((n) => {
37
- if (n.id !== e) return n;
38
- let r = {
39
- ...n,
40
- ...t
41
- };
42
- return "amount" in t ? r : {
43
- ...r,
44
- amount: l(r.quantity, r.price, r.amount)
45
- };
46
- })), O(!0), b(void 0);
47
- }, [M]), P = a((e, t) => {
48
- M(e), m((n) => n.map((n) => {
49
- if (n.id !== e) return n;
50
- let r = Number.parseFloat(n.quantity), i = String(Math.max(1, (Number.isFinite(r) ? r : 1) + t));
51
- return {
52
- ...n,
53
- quantity: i,
54
- amount: l(i, n.price, n.amount)
55
- };
56
- })), O(!0), b(void 0);
57
- }, [M]), F = a((e) => {
58
- M(e), m((t) => t.length <= 1 ? t : t.filter((t) => t.id !== e)), O(!0), b(void 0);
59
- }, [M]), I = a(() => {
60
- m((e) => [...e, r()]), O(!0), b(void 0);
61
- }, []), L = a((e) => {
62
- g(e), A(!0), b(void 0);
63
- }, []), R = a((e) => {
64
- v(e), A(!0), b(void 0);
65
- }, []), z = a((e) => {
66
- b(e), A(!0);
67
- }, []), B = s(() => p.map((e) => ({
68
- ...e,
69
- onChange: (t) => N(e.id, t),
70
- onQuantityStep: (t) => P(e.id, t),
71
- onRemove: () => F(e.id)
72
- })), [
73
- p,
74
- N,
75
- F,
76
- P
77
- ]), V = s(() => e(p, _, h), [
78
- p,
79
- _,
80
- h
81
- ]);
82
- return {
83
- values: d,
84
- errors: x,
85
- setErrors: S,
86
- lineItemErrors: C,
87
- setLineItemErrors: w,
88
- onChange: j,
89
- lineItems: p,
90
- lineItemRows: B,
91
- discount: h,
92
- onDiscountChange: L,
93
- tax: _,
94
- onTaxChange: R,
95
- total: y ?? V,
96
- totalOverride: y,
97
- onTotalChange: z,
98
- onAddLineItem: I,
99
- isTotalsDirty: k,
100
- isDirty: T || D || k
101
- };
8
+ 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;
23
+ }
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);
34
+ 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 } : {}
40
+ };
41
+ });
42
+ }
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));
102
48
  }
103
49
  //#endregion
104
- export { u as useBillForm };
50
+ export { d as calculateTotal, u as displayLineAmount, i as isPersistableLineItem, c as mapBillFormToPayload, l as mapLineItemsToPayload, n as parseMoneyToMinorUnits, r as parseQuantity };
@@ -1,9 +1,34 @@
1
+ import { BILL_CREATE_MESSAGE_LABELS_EN as e } from "./index26.js";
2
+ import { isPersistableLineItem as t, parseMoneyToMinorUnits as n, parseQuantity as r } from "./index31.js";
1
3
  //#region ../../libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index32.js
2
- var e = {
3
- dialog: "bill-pay-bill-create-dialog",
4
- vendorSection: "bill-pay-bill-create-vendor",
5
- lineItems: "bill-pay-bill-create-line-items",
6
- documentPanel: "bill-pay-bill-create-document"
7
- };
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
28
+ };
29
+ }
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
+ }
8
33
  //#endregion
9
- export { e as billCreateTestIds };
34
+ export { s as validateBillCompleteness, c as validateBillTotals, o as validateLineItems };