@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
@@ -1,8 +1,157 @@
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 { 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";
9
+ 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";
1
14
  //#region ../../libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index29.js
2
- var e = (e) => [
3
- "bill-pay",
4
- "upload-queue",
5
- e ?? ""
6
- ];
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";
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;
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
+ };
155
+ }
7
156
  //#endregion
8
- export { e as billPayUploadQueueKey };
157
+ export { _ as mapValidationErrorsToForm, y as useBillCreateController };
@@ -1,63 +1,6 @@
1
- "use client";
2
- "use client";
3
- "use client";
4
- "use client";
5
- import { SOURCE_DOCUMENT_CONTAINER_LABELS_EN as e } from "./index2.js";
6
- import { useAttachPayableFileMutation as t, useDeletePayableFileMutation as n } from "../../data-access/dist/index7.js";
7
- import "../../data-access/dist/index.js";
8
- import { SourceDocumentPanel as r } from "../../ui/dist/index48.js";
9
- import "../../ui/dist/index.js";
10
- import { jsx as i } from "react/jsx-runtime";
11
1
  //#region ../../libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index3.js
12
- function a({ payableId: a, file: o, isDocumentPending: s, pendingFileName: c, readOnly: l, labels: u }) {
13
- let d = {
14
- ...e,
15
- ...u
16
- }, f = t(), p = n();
17
- if (!o && (s || f.isPending)) return /* @__PURE__ */ i(r, {
18
- mode: "loading",
19
- fileName: c
20
- });
21
- if (!o && l) return /* @__PURE__ */ i("div", {
22
- className: "ttw:rounded-lg ttw:border ttw:border-border ttw:bg-card ttw:p-4 ttw:text-sm ttw:text-muted-foreground",
23
- children: d.noDocument
24
- });
25
- if (!o && !a) return /* @__PURE__ */ i("div", {
26
- className: "ttw:rounded-lg ttw:border ttw:border-border ttw:bg-card ttw:p-4 ttw:text-sm ttw:text-muted-foreground",
27
- children: d.saveBeforeAttaching
28
- });
29
- if (!o) return /* @__PURE__ */ i(r, {
30
- mode: "upload",
31
- uploadStatus: f.isPending ? "uploading" : "idle",
32
- uploadErrorMessage: f.isError ? d.attachFailed : void 0,
33
- onFilesSelected: (e) => {
34
- let [t] = e;
35
- !t || !a || f.mutate({
36
- path: { payable_id: a },
37
- file: t
38
- });
39
- }
40
- });
41
- let m = o.mimetype === "application/pdf" ? /* @__PURE__ */ i("iframe", {
42
- src: `${o.url}#toolbar=0&navpanes=0`,
43
- title: o.name,
44
- referrerPolicy: "no-referrer",
45
- className: "ttw:h-full ttw:w-full ttw:border-0"
46
- }) : /* @__PURE__ */ i("img", {
47
- src: o.url,
48
- alt: o.name,
49
- className: "ttw:max-h-full ttw:max-w-full ttw:object-contain"
50
- });
51
- return /* @__PURE__ */ i(r, {
52
- mode: "document",
53
- fileName: o.name,
54
- preview: m,
55
- onDownload: () => window.open(o.url, "_blank", "noopener,noreferrer"),
56
- onDelete: a && !l ? () => p.mutate({
57
- path: { file_id: o.id },
58
- payableId: a
59
- }) : void 0
60
- });
2
+ function e(e) {
3
+ return e?.counterpart ?? e?.counterpart_raw_data ?? void 0;
61
4
  }
62
5
  //#endregion
63
- export { a as SourceDocumentContainer, a as default };
6
+ export { e as resolveVendor };
@@ -1,9 +1,38 @@
1
1
  //#region ../../libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index30.js
2
- var e = {
3
- uploadingSummary: (e) => `Uploading and scanning ${e} ${e === 1 ? "file" : "files"}`,
4
- completeSummary: (e) => `${e} ${e === 1 ? "upload" : "uploads"} complete`,
5
- readyCaption: (e) => `${e} new ${e === 1 ? "bill" : "bills"} ready`,
6
- failedCaption: (e) => `${e} failed to upload`
7
- };
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
+ }
8
37
  //#endregion
9
- export { e as BILL_UPLOAD_QUEUE_LABELS_EN };
38
+ export { e as emptyLineItem, n as mapPayableToBillForm };
@@ -2,84 +2,103 @@
2
2
  "use client";
3
3
  "use client";
4
4
  "use client";
5
- import { useEmbedApi as e } from "../../../shared/data-access/dist/lib/EmbedApiContext.js";
6
- import { useUploadPayableFromFileMutation as t } from "../../data-access/dist/index7.js";
7
- import { usePayableOcrQueries as n } from "../../data-access/dist/index9.js";
8
- import "../../data-access/dist/index.js";
9
- import { billPayUploadQueueKey as r } from "./index29.js";
10
- import { BILL_UPLOAD_QUEUE_LABELS_EN as i } from "./index30.js";
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";
11
7
  import { useCallback as a, useEffect as o, useMemo as s, useState as c } from "react";
12
- import { useQuery as l, useQueryClient as u } from "@tanstack/react-query";
13
8
  //#region ../../libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index31.js
14
- function d({ onOpenBill: d, labels: f } = {}) {
15
- let p = {
16
- ...i,
17
- ...f
18
- }, { organizationId: m } = e(), h = u(), g = s(() => r(m), [m]), _ = t(), [v, y] = c(!1), { data: b = [] } = l({
19
- queryKey: g,
20
- queryFn: () => h.getQueryData(g) ?? [],
21
- staleTime: Infinity,
22
- gcTime: Infinity,
23
- initialData: []
24
- }), x = a((e, t) => {
25
- h.setQueryData(g, (n) => (n ?? []).map((n) => n.localId === e ? {
26
- ...n,
27
- ...t
28
- } : n));
29
- }, [h, g]), S = a((e) => {
30
- y(!1);
31
- for (let t of e) {
32
- let e = crypto.randomUUID();
33
- h.setQueryData(g, (n) => [...n ?? [], {
34
- localId: e,
35
- fileName: t.name,
36
- status: "uploading"
37
- }]), _.mutateAsync({ file: t }).then((t) => x(e, { payableId: t?.id })).catch(() => x(e, { status: "failed" }));
38
- }
39
- }, [
40
- x,
41
- h,
42
- g,
43
- _
44
- ]), C = n({ payableIds: b.filter((e) => e.status === "uploading" && e.payableId).map((e) => e.payableId) });
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);
45
17
  o(() => {
46
- for (let { payableId: e, ocrStatus: t, isError: n } of C) {
47
- let r = b.find((t) => t.payableId === e && t.status === "uploading");
48
- r && (t === "success" ? x(r.localId, { status: "ready" }) : (n || t === "error" || t === "canceled") && x(r.localId, { status: "failed" }));
49
- }
50
- }, [
51
- b,
52
- C,
53
- x
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
54
81
  ]);
55
- let w = b.filter((e) => e.status === "uploading"), T = b.filter((e) => e.status === "ready"), E = b.filter((e) => e.status === "failed"), D = (e) => ({
56
- id: e.localId,
57
- fileName: e.fileName,
58
- status: e.status,
59
- onOpen: e.status === "ready" && e.payableId && d ? () => d(e.payableId) : void 0
60
- }), O = w.length ? [{
61
- id: "in-progress",
62
- items: b.map(D)
63
- }] : [...T.length ? [{
64
- id: "ready",
65
- caption: p.readyCaption(T.length),
66
- items: T.map(D)
67
- }] : [], ...E.length ? [{
68
- id: "failed",
69
- caption: p.failedCaption(E.length),
70
- items: E.map(D)
71
- }] : []], k = w.length ? p.uploadingSummary(b.length) : T.length ? p.completeSummary(T.length) : p.failedCaption(E.length), A = a(() => {
72
- h.setQueryData(g, []);
73
- }, [h, g]);
74
82
  return {
75
- enqueue: S,
76
- sections: O,
77
- summaryLabel: k,
78
- collapsed: v,
79
- onToggleCollapsed: a(() => y((e) => !e), []),
80
- onClose: A,
81
- isVisible: b.length > 0
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
82
101
  };
83
102
  }
84
103
  //#endregion
85
- export { d as useBillUploadQueue };
104
+ export { u as useBillForm };
@@ -1,3 +1,9 @@
1
- import "./index29.js";
2
- import "./index30.js";
3
- import "./index31.js";
1
+ //#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
+ };
8
+ //#endregion
9
+ export { e as billCreateTestIds };
@@ -1,8 +1,193 @@
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 { 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/index49.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";
20
+ 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";
1
37
  //#region ../../libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index33.js
2
- var e = {
3
- bills: "Bills",
4
- vendors: "Vendors",
5
- settings: "Settings"
6
- };
38
+ function ve(e) {
39
+ return !!(e?.bank_account?.account_holder_name && e.bank_account.routing_number && e.bank_account.account_number);
40
+ }
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) : $();
117
+ }, [
118
+ $,
119
+ R,
120
+ g
121
+ ]);
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] });
191
+ }
7
192
  //#endregion
8
- export { e as DEFAULT_TABS_LABELS };
193
+ export { h as BillCreateDialog, h as default };