@tesouro/embedded-components-react 0.2.327 → 0.2.329

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,192 +2,156 @@
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 { useAllLedgerAccountsQuery as ee } from "../../../shared/data-access/dist/lib/reference-data/useLedgerAccountsQuery.js";
8
- import { useAllOrganizationUsersQuery as te } from "../../../shared/data-access/dist/lib/user/useAllOrganizationUsersQuery.js";
9
- import "../../../shared/data-access/dist/index.js";
10
- import { formatCalendarDate as ne } from "../../../shared/util/dist/lib/formatCalendarDate.js";
11
- import { useWidgetConfig as re } from "../../../shared/feature/dist/lib/WidgetProvider/hooks.js";
12
- import "../../../shared/feature/dist/index.js";
13
- import { resolveVendor as ie } from "./index3.js";
14
- import { BillCreateScreen as ae } from "../../ui/dist/index35.js";
15
- import { ExtractionNotice as oe } from "../../ui/dist/index52.js";
16
- import "../../ui/dist/index.js";
17
- import { usePayableHistoryQuery as se } from "../../data-access/dist/index6.js";
18
- import { useAllPayableLineItemsQuery as ce } from "../../data-access/dist/index7.js";
19
- import { usePayableQuery as le } from "../../data-access/dist/index13.js";
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";
20
9
  import "../../data-access/dist/index.js";
21
- import { PayBillFlow as ue } from "./index10.js";
22
- import "./index11.js";
23
- import { mergeBillCreateScreenCopy as de } from "./index22.js";
24
- import { useBillCreateController as fe } from "./index29.js";
25
- import { useBillForm as pe } from "./index31.js";
26
- import { useCurrentApprovalRequestId as n } from "./index12.js";
27
- import { usePayableDetailActions as r } from "./index14.js";
28
- import { useScheduledPayment as i } from "./index15.js";
29
- import { buildBillDetailView as a } from "./index18.js";
30
- import { buildBillHistory as o } from "./index19.js";
31
- import { SourceDocumentContainer as s } from "./index23.js";
32
- import { useVendorSectionProps as c } from "./index25.js";
33
- import { usePaymentInstructionsForm as l } from "./index26.js";
34
- import { billCreateTestIds as u } from "./index32.js";
35
- import { useCallback as d, useEffect as me, useMemo as f, useRef as he, useState as p } from "react";
36
- import { Fragment as ge, jsx as m, jsxs as _e } from "react/jsx-runtime";
10
+ import { BILL_CREATE_MESSAGE_LABELS_EN as o } from "./index26.js";
11
+ import { mapBillFormToPayload as s, mapLineItemsToPayload as c } from "./index31.js";
12
+ import { validateBillCompleteness as l, validateBillTotals as u, validateLineItems as d } from "./index32.js";
13
+ import { useCallback as f, useRef as p, useState as m } from "react";
37
14
  //#region ../../libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index33.js
38
- function ve(e) {
39
- return !!(e?.bank_account?.account_holder_name && e.bank_account.routing_number && e.bank_account.account_number);
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";
40
23
  }
41
- function h({ open: h, onOpenChange: g, payableId: _, readOnly: v = !1, copy: y, poweredByBankName: ye }) {
42
- let b = f(() => de(y), [y]), [x, S] = p(), [C, w] = p(!1), [T, E] = p(!1), [D, O] = p(), k = _ ?? D, A = le(k, { pollWhileOcrProcessing: !0 }), j = ce(k), M = ee(), N = A.data, P = pe({
43
- payable: N,
44
- lineItems: j.lineItems
45
- }), F = N?.counterpart_id;
46
- me(() => {
47
- C || F && (S(F), w(!0));
48
- }, [C, F]);
49
- let be = d((e) => {
50
- w(!0), S(e);
51
- }, []), I = c({
52
- payableId: v ? void 0 : k,
53
- counterpartId: v ? void 0 : x,
54
- payableCounterpartId: F,
55
- onCounterpartChange: be,
56
- requiredError: P.errors?.vendor
57
- }), L = fe({
58
- payableId: _,
59
- form: P,
60
- counterpartId: x,
61
- clearCounterpart: !!(k && C) && !x,
62
- prepareVendorForSave: I.savePaymentInstructions,
63
- onPayableCreated: O,
64
- onSaved: O,
65
- onDraftSaved: () => g(!1),
66
- onFinalized: () => g(!1)
67
- }), R = !!(L.isSavingDraft || L.isFinalizing), z = v ? k : void 0, xe = n({
68
- payableId: z,
69
- status: N?.status
70
- }), B = he(null), V = i({
71
- payableId: k,
72
- scheduledPaymentDate: N?.scheduled_payment_date,
73
- enabled: v
74
- }), H = ie(N), U = l({
75
- payableId: z,
76
- counterpartId: v ? F : void 0,
77
- saveErrorMessage: b.detail.paymentInstructionsSaveError
78
- }), { initResponse: W } = re(), G = e(W?.scopes, [t.CounterpartWriteOrg]) && e(W?.scopes, [t.PayableWriteOrg]), { actions: Se } = r({
79
- payableId: z,
80
- status: N?.status,
81
- currentApprovalRequestId: xe.id,
82
- hasScheduledPayment: V.hasScheduledPayment,
83
- isScheduledPaymentUnknown: V.isResolving,
84
- labels: b.actions,
85
- onPayBillSelect: () => ve(H) || !G ? B.current?.open() : U.open()
86
- }), K = f(() => (M.data?.data ?? []).map((e) => ({
87
- value: e.id,
88
- label: [e.nominal_code, e.name].filter(Boolean).join(" — ")
89
- })), [M.data]), q = se(z), Ce = e(W?.scopes, [t.UserReadOrg]), J = te({ enabled: v && Ce }), Y = f(() => o(q.data?.data ?? [], J.data?.data ?? [], b.history), [
90
- q.data,
91
- J.data,
92
- b.history
93
- ]), we = f(() => v && N ? a({
94
- payable: N,
95
- lineItems: j.lineItems,
96
- glCodeOptions: K,
97
- history: Y,
98
- labels: b.detail
99
- }) : void 0, [
100
- b.detail,
101
- K,
102
- Y,
103
- j.lineItems,
104
- N,
105
- v
106
- ]), X = N?.source_of_payable_data === "ocr", Z = H?.name, Q = v ? Z ? b.viewTitle(Z) : b.readOnlyTitle : X && Z ? b.extractedTitle(Z) : b.newTitle, Te = v && N?.created_at ? b.addedOn(ne(N.created_at.slice(0, 10))) : void 0, $ = d(() => {
107
- let e = P.isDirty || I.hasUnsavedVendorChanges;
108
- !v && e && !window.confirm(b.discardConfirm) || g(!1);
109
- }, [
110
- b.discardConfirm,
111
- P.isDirty,
112
- g,
113
- v,
114
- I.hasUnsavedVendorChanges
115
- ]), Ee = d((e) => {
116
- if (!R) return e ? g(!0) : $();
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;
117
67
  }, [
118
- $,
119
- R,
120
- g
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
121
81
  ]);
122
- return /* @__PURE__ */ _e(ge, { children: [/* @__PURE__ */ m(ae, {
123
- open: h,
124
- onOpenChange: Ee,
125
- title: Q,
126
- subtitle: Te,
127
- notice: !v && X && !T ? /* @__PURE__ */ m(oe, { onDismiss: () => E(!0) }) : void 0,
128
- vendor: {
129
- ...I,
130
- testId: u.vendorSection
131
- },
132
- values: P.values,
133
- errors: P.errors,
134
- onChange: P.onChange,
135
- lineItems: {
136
- items: P.lineItemRows,
137
- glCodeOptions: K,
138
- discount: P.discount,
139
- onDiscountChange: P.onDiscountChange,
140
- tax: P.tax,
141
- onTaxChange: P.onTaxChange,
142
- total: P.total,
143
- onTotalChange: P.onTotalChange,
144
- onAddLineItem: P.onAddLineItem,
145
- errors: P.lineItemErrors,
146
- testId: u.lineItems
147
- },
148
- documentPanel: /* @__PURE__ */ m(s, {
149
- payableId: k,
150
- readOnly: v,
151
- isDocumentPending: !!k && !N?.file && (A.isLoading || N?.ocr_status === "processing"),
152
- file: N?.file ? {
153
- id: N.file.id,
154
- name: N.file.name,
155
- url: N.file.url,
156
- mimetype: N.file.mimetype
157
- } : void 0
158
- }),
159
- readOnly: v,
160
- detail: v ? {
161
- view: we,
162
- actions: Se,
163
- scheduledSummary: V.hasScheduledPayment && V.scheduledDateLabel ? b.scheduledSummary(V.scheduledDateLabel) : void 0,
164
- paymentInstructionsForm: F && G ? {
165
- isOpen: U.isOpen,
166
- values: U.values,
167
- errors: U.errors,
168
- isSaving: U.isSaving,
169
- onOpen: U.open,
170
- onCancel: U.close,
171
- onChange: U.onChange,
172
- onSave: U.save
173
- } : void 0,
174
- isLoading: A.isLoading || j.isResolving || M.isResolving,
175
- isError: A.isError || j.isError || M.isError
176
- } : void 0,
177
- isLineItemsLoading: j.isResolving,
178
- isSaving: R,
179
- isSavingDraft: L.isSavingDraft,
180
- isFinalizing: L.isFinalizing,
181
- onCancel: $,
182
- onSaveDraft: L.saveDraft,
183
- onFinalize: L.finalize,
184
- testId: u.dialog
185
- }), v && N ? /* @__PURE__ */ m(ue, {
186
- ref: B,
187
- payable: N,
188
- poweredByBankName: ye,
189
- labels: b.payBill
190
- }) : null] });
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
+ };
191
155
  }
192
156
  //#endregion
193
- export { h as BillCreateDialog, h as default };
157
+ export { _ as mapValidationErrorsToForm, y as useBillCreateController };
@@ -1,4 +1,38 @@
1
- import "./index22.js";
2
- import "./index29.js";
3
- import "./index31.js";
4
- import "./index33.js";
1
+ //#region ../../libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index34.js
2
+ function e() {
3
+ 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)
35
+ };
36
+ }
37
+ //#endregion
38
+ export { e as emptyLineItem, n as mapPayableToBillForm };
@@ -1,26 +1,104 @@
1
- import { BILL_DETAILS_SHEET_LABELS_EN as e } from "../../ui/dist/index43.js";
2
- import "../../ui/dist/index.js";
3
- import { BILL_DETAIL_ACTIONS_LABELS_EN as t, SCHEDULED_SUMMARY_LABEL_EN as n } from "./index20.js";
1
+ "use client";
2
+ "use client";
3
+ "use client";
4
+ "use client";
5
+ import { calculateTotal as e, displayLineAmount as t, parseMoneyToMinorUnits as n } from "./index31.js";
6
+ import { emptyLineItem as r, mapPayableToBillForm as i } from "./index34.js";
7
+ import { useCallback as a, useEffect as o, useMemo as s, useState as c } from "react";
4
8
  //#region ../../libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index35.js
5
- var r = {
6
- subtitle: "Accounts payable",
7
- vendorRow: "Vendor",
8
- bankAccountRow: "ACH bank account",
9
- bankAccountValue: (e) => `Account ending in ${e}`,
10
- invoiceNumberRow: "Number",
11
- issueDateRow: "Issue date",
12
- dueDateRow: "Due date",
13
- poNumberRow: "PO number",
14
- notProvided: "Not provided",
15
- glCodeMissing: "GL code not specified",
16
- quantityValue: (e, t) => `${e} x ${t}`,
17
- subtotalRow: "Subtotal",
18
- discountsRow: "Discounts",
19
- taxRow: "Tax",
20
- totalRow: "Total",
21
- actionError: t.actionError,
22
- scheduledSummary: n,
23
- sheet: e
24
- };
9
+ function l(e, r, i) {
10
+ return n(r) === null ? i : t(e, r);
11
+ }
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
+ };
102
+ }
25
103
  //#endregion
26
- export { r as BILL_DETAILS_LABELS_EN };
104
+ export { u as useBillForm };
@@ -1,82 +1,12 @@
1
- import { formatCalendarDate as e } from "../../../shared/util/dist/lib/formatCalendarDate.js";
2
- import { resolveVendor as t, resolveVendorName as n } from "./index3.js";
3
- import { derivePayableStatus as r } from "./index16.js";
4
- import { formatBillMoney as i } from "./index17.js";
5
1
  //#region ../../libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index36.js
6
- function a({ payable: a, lineItems: o, ledgerAccounts: s, labels: c }) {
7
- let l = a.currency, u = (e) => i(e, l), d = r({
8
- apiStatus: a.status,
9
- dueDate: a.due_date,
10
- scheduledPaymentDate: a.scheduled_payment_date
11
- }), f = t(a), p = n(a), m = e(a.issued_at) || c.notProvided, h = e(a.due_date) || c.notProvided, g = [{
12
- label: c.vendorRow,
13
- value: p || c.notProvided,
14
- secondaryValue: f?.email ?? void 0
15
- }], _ = f?.bank_account?.account_number;
16
- _ && g.push({
17
- label: c.bankAccountRow,
18
- value: c.bankAccountValue(_.slice(-4))
19
- });
20
- let v = [
21
- {
22
- label: c.invoiceNumberRow,
23
- value: a.document_id || c.notProvided
24
- },
25
- {
26
- label: c.issueDateRow,
27
- value: m
28
- },
29
- {
30
- label: c.dueDateRow,
31
- value: h
32
- },
33
- {
34
- label: c.poNumberRow,
35
- value: c.notProvided
36
- }
37
- ], y = new Map(s.map((e) => [e.id, [e.nominal_code, e.name].filter(Boolean).join(" — ")])), b = o.map((e) => {
38
- let t = u(e.unit_price);
39
- return {
40
- id: e.id,
41
- description: e.name ?? e.description ?? "",
42
- glCodeLabel: (e.ledger_account_id ? y.get(e.ledger_account_id) : void 0) || c.glCodeMissing,
43
- quantityLabel: e.quantity != null && t ? c.quantityValue(String(e.quantity), t) : "",
44
- amountLabel: u(e.subtotal) ?? ""
45
- };
46
- }), x = [
47
- {
48
- label: c.subtotalRow,
49
- value: a.subtotal
50
- },
51
- {
52
- label: c.discountsRow,
53
- value: a.discount
54
- },
55
- {
56
- label: c.taxRow,
57
- value: a.tax_amount
58
- }
59
- ].map(({ label: e, value: t }) => ({
60
- label: e,
61
- value: u(t)
62
- })).filter((e) => !!e.value), S = u(a.total_amount);
63
- return S && x.push({
64
- label: c.totalRow,
65
- value: S,
66
- emphasis: !0
67
- }), {
68
- title: p,
69
- subtitle: c.subtitle,
70
- status: d.status,
71
- statusTone: d.tone,
72
- amountDueLabel: u(a.amount_due) ?? u(a.total_amount) ?? "",
73
- invoiceDateLabel: m,
74
- dueDateLabel: h,
75
- payToItems: g,
76
- invoiceItems: v,
77
- lineItems: b,
78
- totals: x
79
- };
80
- }
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
+ decisionDialog: "bill-pay-bill-decision-dialog",
8
+ decisionConfirm: "bill-pay-bill-decision-confirm",
9
+ decisionReason: "bill-pay-bill-decision-reason"
10
+ };
81
11
  //#endregion
82
- export { a as mapPayableToBillDetails };
12
+ export { e as billCreateTestIds };