@tesouro/embedded-components-react 0.5.251 → 0.5.254

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 (67) hide show
  1. package/dist/index.d.ts +95 -79
  2. package/dist/lib/ReceivablesWidget.d.ts +25 -9
  3. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index24.js +4 -1
  4. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index27.js +214 -209
  5. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index35.js +162 -145
  6. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/ui/dist/index14.js +2 -2
  7. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/ui/dist/index15.js +2 -2
  8. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/ui/dist/index31.js +1 -1
  9. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/ui/dist/index33.js +2 -2
  10. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/ui/dist/index34.js +3 -3
  11. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/ui/dist/index37.js +2 -2
  12. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/ui/dist/index48.js +1 -1
  13. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/ui/dist/index49.js +1 -1
  14. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/ui/dist/index5.js +2 -2
  15. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bills-list/feature/dist/index17.js +32 -23
  16. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bills-list/ui/dist/index18.js +2 -2
  17. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bills-list/ui/dist/index2.js +1 -1
  18. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bills-list/ui/dist/index20.js +5 -5
  19. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bills-list/ui/dist/index3.js +1 -1
  20. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/lib/BillPayWidgetNative/BillPayWidgetNative.js +48 -48
  21. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/lib/BillPayWidgetNative/BillsTab.js +32 -24
  22. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/lib/BillPayWidgetNative/labels.js +2 -2
  23. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/pay-bill/ui/dist/index5.js +1 -1
  24. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/pay-bill/ui/dist/index6.js +1 -1
  25. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index.js +19 -21
  26. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index10.js +38 -51
  27. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index12.js +12 -2
  28. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index13.js +11 -39
  29. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index14.js +18 -2
  30. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index15.js +2 -14
  31. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index16.js +9 -16
  32. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index17.js +78 -2
  33. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index19.js +2 -78
  34. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index20.js +29 -0
  35. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index21.js +4 -2
  36. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index22.js +26 -25
  37. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index23.js +2 -4
  38. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index24.js +5 -28
  39. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index25.js +34 -2
  40. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index26.js +2 -7
  41. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index6.js +16 -11
  42. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index7.js +54 -2
  43. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index8.js +1 -0
  44. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index9.js +2 -16
  45. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index.js +2 -2
  46. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index10.js +16 -17
  47. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/ReceivablesWidget.js +15 -11
  48. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/details.js +89 -88
  49. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/helpers.js +55 -74
  50. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/labels.js +8 -1
  51. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/paymentRecord.js +71 -0
  52. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/useReceivableActions.js +123 -164
  53. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/useReceivableDetails.js +40 -37
  54. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/useReceivablePaymentRecord.js +91 -0
  55. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/useReceivablesTable.js +83 -78
  56. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/useReceivablesWidget.js +7 -3
  57. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/mocks/receivables.js +2 -1
  58. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index13.js +15 -8
  59. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index39.js +206 -89
  60. package/dist/libs/tesouro-embedded-components-react/shared/data-access/dist/index.js +2 -2
  61. package/dist/libs/tesouro-embedded-components-react/shared/data-access/dist/lib/rest/sdk.gen.js +38 -38
  62. package/dist/libs/tesouro-embedded-components-react/shared/feature/dist/lib/analytics/build-info.js +1 -1
  63. package/dist/packages/shared-ui-shadcn/dist/index.js +8 -7
  64. package/package.json +1 -1
  65. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index18.js +0 -11
  66. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index27.js +0 -34
  67. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index28.js +0 -2
@@ -5,249 +5,208 @@
5
5
  import { toast as e } from "../../../../../../../packages/shared-ui-shadcn/dist/index.js";
6
6
  import { extractApiErrorMessage as t } from "../../../../../shared/util/dist/lib/apiErrors.js";
7
7
  import "../../../../../shared/ui/dist/index.js";
8
- import { defaultPaymentValues as n, defaultSendValues as r, formatMoney as i, fromMajorUnits as a, hasPaymentErrors as o, hasSendErrors as s, isReceivableReadyToIssue as ee, splitEmailList as c, validatePaymentValues as l, validateSendValues as u } from "./helpers.js";
9
- import { getIssueReminderBlocker as d, hasSelectedReminder as te } from "./reminders.js";
10
- import { useSendReceivableEmailMutation as f } from "../../../../data-access/dist/index7.js";
11
- import { useAcceptReceivableMutation as ne, useCancelReceivableMutation as re, useCloneReceivableMutation as ie, useDeclineReceivableMutation as ae, useDeleteReceivableMutation as oe, useIssueReceivableMutation as se } from "../../../../data-access/dist/index8.js";
12
- import { useMarkReceivablePaidMutation as ce, useMarkReceivablePartiallyPaidMutation as le, useMarkReceivableUncollectibleMutation as ue } from "../../../../data-access/dist/index10.js";
13
- import { useCancelRecurrenceMutation as de, usePauseRecurrenceMutation as fe, useResumeRecurrenceMutation as pe } from "../../../../data-access/dist/index12.js";
8
+ import { defaultSendValues as n, formatMoney as r, hasSendErrors as i, isReceivableReadyToIssue as a, splitEmailList as o, validateSendValues as s } from "./helpers.js";
9
+ import { getIssueReminderBlocker as c, hasSelectedReminder as ee } from "./reminders.js";
10
+ import { useSendReceivableEmailMutation as l } from "../../../../data-access/dist/index7.js";
11
+ import { useAcceptReceivableMutation as u, useCancelReceivableMutation as d, useCloneReceivableMutation as f, useDeclineReceivableMutation as te, useDeleteReceivableMutation as ne, useIssueReceivableMutation as p } from "../../../../data-access/dist/index8.js";
12
+ import { useMarkReceivablePaidMutation as re, useMarkReceivableUncollectibleMutation as ie } from "../../../../data-access/dist/index10.js";
13
+ import { useCancelRecurrenceMutation as ae, usePauseRecurrenceMutation as m, useResumeRecurrenceMutation as oe } from "../../../../data-access/dist/index12.js";
14
14
  import "../../../../data-access/dist/index.js";
15
- import { useReceivableIssuePreflight as me } from "./useReceivableIssuePreflight.js";
16
- import { useCallback as p, useState as m } from "react";
15
+ import { useReceivableIssuePreflight as h } from "./useReceivableIssuePreflight.js";
16
+ import { useReceivablePaymentRecord as g } from "./useReceivablePaymentRecord.js";
17
+ import { useCallback as _, useState as v } from "react";
17
18
  //#region ../../libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/useReceivableActions.js
18
- function h({ selectedReceivable: i, selectedRecurrence: h, messages: g, onCreated: _, onDeleted: v, onCompleteBeforeIssue: y }) {
19
- let b = se(), x = re(), S = ie(), C = ne(), w = ae(), T = oe(), E = f(), D = ce(), O = le(), k = ue(), A = fe(), j = pe(), M = de(), [N, P] = m(), [_e, F] = m(), [I, L] = m(""), [R, z] = m(), [B, V] = m(() => r(void 0, g)), [ve, H] = m({}), [U, W] = m(), [G, K] = m(() => n()), [ye, q] = m({}), J = A.mutate, be = j.mutate, Y = N?.issueCheck, X = me({
20
- counterpartId: Y?.counterpartId,
21
- billingAddressId: Y?.billingAddressId,
22
- billingCountry: Y?.billingCountry
23
- }), Z = !!Y && X.isLoading, xe = p((a, o, s) => {
19
+ function y({ selectedReceivable: r, selectedRecurrence: y, messages: b, onCreated: x, onDeleted: S, onCompleteBeforeIssue: C }) {
20
+ let w = p(), T = d(), E = f(), D = u(), O = te(), k = ne(), A = l(), j = re(), M = ie(), N = m(), P = oe(), F = ae(), [I, L] = v(), [le, R] = v(), [z, B] = v(""), [V, H] = v(), [U, W] = v(() => n(void 0, b)), [ue, G] = v({}), K = g({ messages: b }), q = K.open, J = N.mutate, Y = P.mutate, X = I?.issueCheck, Z = h({
21
+ counterpartId: X?.counterpartId,
22
+ billingAddressId: X?.billingAddressId,
23
+ billingCountry: X?.billingCountry
24
+ }), Q = !!X && Z.isLoading, de = _((i, o, s) => {
24
25
  let c = "documentLabel" in o ? o.documentLabel : o.title, l = {
25
26
  id: o.id,
26
27
  type: o.type,
27
28
  title: c,
28
- action: a
29
- }, u = s === void 0 ? i : s ?? void 0;
30
- if (a === "send") {
31
- z(l), V(r(u, g)), H({});
29
+ action: i
30
+ }, u = s === void 0 ? r : s ?? void 0;
31
+ if (i === "send") {
32
+ H(l), W(n(u, b)), G({});
32
33
  return;
33
34
  }
34
35
  let d = u?.type === "invoice" ? u.recurrence_id ?? void 0 : void 0;
35
- if (a === "pauseRecurrence" || a === "resumeRecurrence") {
36
+ if (i === "pauseRecurrence" || i === "resumeRecurrence") {
36
37
  if (!d) return;
37
- let n = a === "pauseRecurrence";
38
- (n ? J : be)({
38
+ let n = i === "pauseRecurrence";
39
+ (n ? J : Y)({
39
40
  path: { recurrence_id: d },
40
41
  receivableId: o.id
41
42
  }, {
42
- onSuccess: () => e.success(n ? g.recurrencePaused : g.recurrenceResumed),
43
- onError: (n) => e.error(t(n) ?? g.genericError)
43
+ onSuccess: () => e.success(n ? b.recurrencePaused : b.recurrenceResumed),
44
+ onError: (n) => e.error(t(n) ?? b.genericError)
44
45
  });
45
46
  return;
46
47
  }
47
- if (a === "cancelRecurrence") {
48
+ if (i === "cancelRecurrence") {
48
49
  if (!d || u?.type !== "invoice") return;
49
- F(void 0), P({
50
+ R(void 0), L({
50
51
  ...l,
51
52
  recurrenceId: d,
52
- description: he(u, h, g)
53
+ description: se(u, y, b)
53
54
  });
54
55
  return;
55
56
  }
56
- if (a === "recordPayment") {
57
- W({
58
- ...l,
59
- currency: u?.currency
60
- }), K(n()), q({});
57
+ if (i === "recordPayment") {
58
+ u?.type === "invoice" && q(u);
61
59
  return;
62
60
  }
63
- let f = a === "issue" && u?.type === "invoice" ? u : void 0;
64
- if (f && y && !ee(f, g)) {
65
- y(f);
61
+ let f = i === "issue" && u?.type === "invoice" ? u : void 0;
62
+ if (f && C && !a(f, b)) {
63
+ C(f);
66
64
  return;
67
65
  }
68
- F(void 0), L(""), P({
66
+ R(void 0), B(""), L({
69
67
  ...l,
70
68
  issueCheck: f ? {
71
69
  counterpartId: f.counterpart_id,
72
70
  billingAddressId: f.counterpart_billing_address?.id ?? void 0,
73
71
  billingCountry: f.counterpart_billing_address?.country,
74
- hasReminder: te(f)
72
+ hasReminder: ee(f)
75
73
  } : void 0
76
74
  });
77
75
  }, [
78
- g,
79
- y,
76
+ b,
77
+ C,
78
+ q,
80
79
  J,
81
- be,
82
- i,
83
- h
84
- ]), Se = p(() => {
85
- P(void 0), F(void 0);
86
- }, []), Q = p(() => {
87
- z(void 0), H({});
88
- }, []), $ = p(() => {
89
- W(void 0), q({});
90
- }, []), Ce = p(async () => {
91
- if (!N) return;
92
- let n = { receivable_id: N.id };
93
- if (N.issueCheck) {
94
- if (Z) return;
95
- let t = X.isTaxIdMissing ? g.issueTaxIdRequired : N.issueCheck.hasReminder ? d(X.counterpart, g) : void 0;
80
+ Y,
81
+ r,
82
+ y
83
+ ]), fe = _(() => {
84
+ L(void 0), R(void 0);
85
+ }, []), $ = _(() => {
86
+ H(void 0), G({});
87
+ }, []), pe = _(async () => {
88
+ if (!I) return;
89
+ let n = { receivable_id: I.id };
90
+ if (I.issueCheck) {
91
+ if (Q) return;
92
+ let t = Z.isTaxIdMissing ? b.issueTaxIdRequired : I.issueCheck.hasReminder ? c(Z.counterpart, b) : void 0;
96
93
  if (t) {
97
- e.error(t), P(void 0);
94
+ e.error(t), L(void 0);
98
95
  return;
99
96
  }
100
97
  }
101
- if (N.action === "cancelRecurrence") {
102
- if (!N.recurrenceId) return;
98
+ if (I.action === "cancelRecurrence") {
99
+ if (!I.recurrenceId) return;
103
100
  try {
104
- await M.mutateAsync({
105
- path: { recurrence_id: N.recurrenceId },
106
- receivableId: N.id
107
- }), e.success(g.recurrenceCanceled), P(void 0);
101
+ await F.mutateAsync({
102
+ path: { recurrence_id: I.recurrenceId },
103
+ receivableId: I.id
104
+ }), e.success(b.recurrenceCanceled), L(void 0);
108
105
  } catch (n) {
109
- e.error(t(n) ?? g.genericError);
106
+ e.error(t(n) ?? b.genericError);
110
107
  }
111
108
  return;
112
109
  }
113
110
  try {
114
- if (N.action === "issue") await b.mutateAsync({ path: n });
115
- else if (N.action === "cancel") await x.mutateAsync({ path: n });
116
- else if (N.action === "clone") {
117
- let e = await S.mutateAsync({ path: n });
118
- e?.id && _?.(e.id, e.type);
119
- } else N.action === "accept" ? await C.mutateAsync({ path: n }) : N.action === "decline" ? await w.mutateAsync({ path: n }) : N.action === "delete" ? (await T.mutateAsync({ path: n }), v?.(N.id)) : N.action === "markPaid" ? await D.mutateAsync({
111
+ if (I.action === "issue") await w.mutateAsync({ path: n });
112
+ else if (I.action === "cancel") await T.mutateAsync({ path: n });
113
+ else if (I.action === "clone") {
114
+ let e = await E.mutateAsync({ path: n });
115
+ e?.id && x?.(e.id, e.type);
116
+ } else I.action === "accept" ? await D.mutateAsync({ path: n }) : I.action === "decline" ? await O.mutateAsync({ path: n }) : I.action === "delete" ? (await k.mutateAsync({ path: n }), S?.(I.id)) : I.action === "markPaid" ? await j.mutateAsync({
120
117
  path: n,
121
118
  body: { paid_at: (/* @__PURE__ */ new Date()).toISOString() }
122
- }) : N.action === "markUncollectible" && await k.mutateAsync({
119
+ }) : I.action === "markUncollectible" && await M.mutateAsync({
123
120
  path: n,
124
- body: { comment: I.trim() || void 0 }
121
+ body: { comment: z.trim() || void 0 }
125
122
  });
126
- P(void 0), F(void 0);
123
+ L(void 0), R(void 0);
127
124
  } catch (e) {
128
- F(t(e) ?? g.genericError);
125
+ R(t(e) ?? b.genericError);
129
126
  }
130
127
  }, [
131
- C,
128
+ D,
129
+ z,
132
130
  I,
133
- N,
134
- x,
135
- M,
136
- S,
137
- w,
138
131
  T,
139
- Z,
132
+ F,
133
+ E,
134
+ O,
135
+ k,
136
+ Q,
137
+ w,
138
+ j,
140
139
  b,
141
- D,
142
- g,
143
- _,
144
- v,
145
- X.counterpart,
146
- X.isTaxIdMissing,
147
- k
148
- ]), we = p(async () => {
149
- if (!R) return;
150
- let e = u(B, g);
151
- if (s(e)) {
152
- H(e);
140
+ x,
141
+ S,
142
+ Z.counterpart,
143
+ Z.isTaxIdMissing,
144
+ M
145
+ ]), me = _(async () => {
146
+ if (!V) return;
147
+ let e = s(U, b);
148
+ if (i(e)) {
149
+ G(e);
153
150
  return;
154
151
  }
155
152
  try {
156
- await E.mutateAsync({
157
- path: { receivable_id: R.id },
153
+ await A.mutateAsync({
154
+ path: { receivable_id: V.id },
158
155
  body: {
159
- body_text: B.body,
160
- subject_text: B.subject,
156
+ body_text: U.body,
157
+ subject_text: U.subject,
161
158
  recipients: {
162
- to: c(B.to),
163
- cc: c(B.cc),
164
- bcc: c(B.bcc)
159
+ to: o(U.to),
160
+ cc: o(U.cc),
161
+ bcc: o(U.bcc)
165
162
  }
166
163
  }
167
- }), Q();
168
- } catch (e) {
169
- H({ form: t(e) ?? g.genericError });
170
- }
171
- }, [
172
- Q,
173
- g,
174
- E,
175
- R,
176
- B
177
- ]), Te = p(async () => {
178
- if (!U) return;
179
- let e = l(G, g, U.currency);
180
- if (o(e)) {
181
- q(e);
182
- return;
183
- }
184
- try {
185
- let e = { receivable_id: U.id }, t = G.paidAt ? new Date(G.paidAt).toISOString() : void 0;
186
- G.mode === "full" ? await D.mutateAsync({
187
- path: e,
188
- body: {
189
- comment: G.comment || void 0,
190
- paid_at: t
191
- }
192
- }) : await O.mutateAsync({
193
- path: e,
194
- body: {
195
- amount_paid: a(G.amountPaid, U.currency) ?? 0,
196
- comment: G.comment || void 0
197
- }
198
164
  }), $();
199
165
  } catch (e) {
200
- q({ form: t(e) ?? g.genericError });
166
+ G({ form: t(e) ?? b.genericError });
201
167
  }
202
168
  }, [
203
169
  $,
204
- D,
205
- g,
206
- O,
207
- U,
208
- G
170
+ b,
171
+ A,
172
+ V,
173
+ U
209
174
  ]);
210
175
  return {
211
- actionTarget: N,
212
- actionDialog: N ? ge(N, g) : void 0,
213
- actionError: _e,
214
- actionComment: N?.action === "markUncollectible" ? I : void 0,
215
- setActionComment: L,
216
- actionInProgress: Z || b.isPending || x.isPending || S.isPending || C.isPending || w.isPending || T.isPending || D.isPending || k.isPending || M.isPending,
217
- pendingActions: [...A.isPending ? ["pauseRecurrence"] : [], ...j.isPending ? ["resumeRecurrence"] : []],
218
- openAction: xe,
219
- closeAction: Se,
220
- confirmAction: Ce,
221
- sendOpen: !!R,
222
- sendValues: B,
223
- sendErrors: ve,
224
- sendInProgress: E.isPending,
225
- setSendValues: V,
226
- closeSend: Q,
227
- submitSend: we,
228
- paymentOpen: !!U,
229
- paymentValues: G,
230
- paymentErrors: ye,
231
- paymentInProgress: D.isPending || O.isPending,
232
- setPaymentValues: K,
233
- closePayment: $,
234
- submitPayment: Te
176
+ actionTarget: I,
177
+ actionDialog: I ? ce(I, b) : void 0,
178
+ actionError: le,
179
+ actionComment: I?.action === "markUncollectible" ? z : void 0,
180
+ setActionComment: B,
181
+ actionInProgress: Q || w.isPending || T.isPending || E.isPending || D.isPending || O.isPending || k.isPending || j.isPending || M.isPending || F.isPending,
182
+ pendingActions: [...N.isPending ? ["pauseRecurrence"] : [], ...P.isPending ? ["resumeRecurrence"] : []],
183
+ openAction: de,
184
+ closeAction: fe,
185
+ confirmAction: pe,
186
+ sendOpen: !!V,
187
+ sendValues: U,
188
+ sendErrors: ue,
189
+ sendInProgress: A.isPending,
190
+ setSendValues: W,
191
+ closeSend: $,
192
+ submitSend: me,
193
+ payment: K
235
194
  };
236
195
  }
237
- function he(e, t, n) {
238
- let r = (t?.iterations ?? []).filter((e) => e.status === "pending").length, a = i({
239
- amount: e.total_amount_with_credit_notes * r,
196
+ function se(e, t, n) {
197
+ let i = (t?.iterations ?? []).filter((e) => e.status === "pending").length, a = r({
198
+ amount: e.total_amount_with_credit_notes * i,
240
199
  currency: e.currency,
241
200
  fallback: ""
242
201
  });
243
202
  return [
244
203
  n.cancelRecurrenceQuestion,
245
204
  n.cancelRecurrenceFutureIterations,
246
- n.cancelRecurrenceTotal.replace("{count}", String(r)).replace("{invoices}", r === 1 ? n.cancelRecurrenceInvoice : n.cancelRecurrenceInvoices).replace("{amount}", a),
205
+ n.cancelRecurrenceTotal.replace("{count}", String(i)).replace("{invoices}", i === 1 ? n.cancelRecurrenceInvoice : n.cancelRecurrenceInvoices).replace("{amount}", a),
247
206
  n.cancelRecurrenceIrreversible
248
207
  ].join("\n");
249
208
  }
250
- function ge({ action: e, description: t }, n) {
209
+ function ce({ action: e, description: t }, n) {
251
210
  return e === "cancelRecurrence" ? {
252
211
  title: n.cancelRecurrenceTitle,
253
212
  description: t ?? "",
@@ -293,4 +252,4 @@ function ge({ action: e, description: t }, n) {
293
252
  };
294
253
  }
295
254
  //#endregion
296
- export { h as useReceivableActions };
255
+ export { y as useReceivableActions };
@@ -4,40 +4,41 @@
4
4
  "use client";
5
5
  import { buildReceivableAuditHistory as e } from "../../../../../shared/util/dist/lib/auditHistory/buildReceivableAuditHistory.js";
6
6
  import { hasAnyScope as t } from "../../../../../shared/data-access/dist/lib/hasAnyScope.js";
7
- import { Scope as ee } from "../../../../../shared/data-access/dist/lib/scopes.js";
7
+ import { Scope as n } from "../../../../../shared/data-access/dist/lib/scopes.js";
8
8
  import "../../../../../shared/data-access/dist/index.js";
9
- import { useWidgetConfig as te } from "../../../../../shared/feature/dist/lib/WidgetProvider/hooks.js";
10
- import { useOrganizationUserNames as n } from "../../../../../shared/feature/dist/lib/user/useOrganizationUserNames.js";
9
+ import { useWidgetConfig as ee } from "../../../../../shared/feature/dist/lib/WidgetProvider/hooks.js";
10
+ import { useOrganizationUserNames as r } from "../../../../../shared/feature/dist/lib/user/useOrganizationUserNames.js";
11
11
  import "../../../../../shared/feature/dist/index.js";
12
- import { RECEIVABLE_DETAILS_SECTION as r } from "../../../../ui/dist/index25.js";
12
+ import { RECEIVABLE_DETAILS_SECTION as i } from "../../../../ui/dist/index25.js";
13
13
  import "../../../../ui/dist/index.js";
14
- import { useAllReceivableHistoryQuery as ne } from "../../../../data-access/dist/index3.js";
15
- import { usePaymentAccountsQuery as i } from "../../../../data-access/dist/index4.js";
16
- import { useReceivablePaymentRecordsQuery as a } from "../../../../data-access/dist/index9.js";
17
- import { useReceivablePdfLinkQuery as o, useReceivableQuery as s, useReceivablesByIdQueries as re } from "../../../../data-access/dist/index11.js";
18
- import { useOverdueRemindersQuery as ie, usePaymentRemindersQuery as c, useRecurrenceQuery as l } from "../../../../data-access/dist/index12.js";
14
+ import { useAllReceivableHistoryQuery as a } from "../../../../data-access/dist/index3.js";
15
+ import { usePaymentAccountsQuery as te } from "../../../../data-access/dist/index4.js";
16
+ import { useReceivablePaymentRecordsQuery as o } from "../../../../data-access/dist/index9.js";
17
+ import { useReceivablePdfLinkQuery as s, useReceivableQuery as ne, useReceivablesByIdQueries as re } from "../../../../data-access/dist/index11.js";
18
+ import { useOverdueRemindersQuery as c, usePaymentRemindersQuery as ie, useRecurrenceQuery as l } from "../../../../data-access/dist/index12.js";
19
19
  import "../../../../data-access/dist/index.js";
20
- import { buildReceivableAuditHistoryLabels as u } from "./auditHistory/labels.js";
21
- import { getBankAccountPermissions as d } from "./bankAccounts.js";
22
- import { buildReceivableDetailsView as f, buildUnsupportedDetailsView as p } from "./details.js";
23
- import { useMemo as m, useState as h } from "react";
20
+ import { canRecordPayments as u } from "./paymentRecord.js";
21
+ import { buildReceivableAuditHistoryLabels as d } from "./auditHistory/labels.js";
22
+ import { getBankAccountPermissions as f } from "./bankAccounts.js";
23
+ import { buildReceivableDetailsView as ae, buildUnsupportedDetailsView as oe } from "./details.js";
24
+ import { useMemo as p, useState as m } from "react";
24
25
  //#region ../../libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/useReceivableDetails.js
25
- var g = [r.attachments];
26
- function _({ selectedReceivableId: _, enabled: v = !0, canWrite: y = !0, messages: b, statusLabels: x, auditHistoryLabels: S, onOpenReceivable: C }) {
27
- let { initResponse: w } = te(), T = m(() => d(w?.scopes), [w?.scopes]), E = s(_, { enabled: v }), D = E.data, O = D?.type === "invoice" ? D : void 0, k = o(_, { enabled: v && !!O }), ae = c({ enabled: v && !!O?.payment_reminder_id }), oe = ie({ enabled: v && !!O?.overdue_reminder_id }), A = i({
28
- enabled: v && !!O,
29
- canReadEmbedded: T.canReadEmbedded,
30
- canReadExternal: T.canReadExternal
31
- }), j = l(v ? O?.recurrence_id : void 0), M = j.data, N = a(O?.id, { enabled: v }), P = ne(O?.id, { enabled: v && !!O }), F = m(() => O?.status === "recurring" ? (M?.iterations ?? []).flatMap((e) => e.issued_invoice_id ? [e.issued_invoice_id] : []) : [], [O?.status, M?.iterations]), I = re(F, { enabled: v }), L = m(() => new Map(I.filter((e) => !!e).map((e) => [e.id, e])), [I]), [R, z] = h(g), [B, V] = h(_);
32
- B !== _ && (V(_), z(g));
33
- let H = R.includes(r.auditHistory), U = m(() => P.data?.data ?? [], [P.data]), W = U.some((e) => e.recorded_by === "user" && !!e.entity_user_id), G = t(w?.scopes, [ee.UserReadOrg]), { userNames: K, isError: q } = n({ enabled: v && H && G && W }), J = m(() => ({
34
- ...u(b, x),
35
- ...S
26
+ var h = [i.attachments];
27
+ function g({ selectedReceivableId: g, enabled: _ = !0, canWrite: v = !0, messages: y, statusLabels: b, auditHistoryLabels: x, onOpenReceivable: S }) {
28
+ let { initResponse: C } = ee(), w = p(() => f(C?.scopes), [C?.scopes]), T = u(C?.scopes), E = ne(g, { enabled: _ }), D = E.data, O = D?.type === "invoice" ? D : void 0, k = s(g, { enabled: _ && !!O }), se = ie({ enabled: _ && !!O?.payment_reminder_id }), ce = c({ enabled: _ && !!O?.overdue_reminder_id }), A = te({
29
+ enabled: _ && !!O,
30
+ canReadEmbedded: w.canReadEmbedded,
31
+ canReadExternal: w.canReadExternal
32
+ }), j = l(_ ? O?.recurrence_id : void 0), M = j.data, N = o(O?.id, { enabled: _ }), P = a(O?.id, { enabled: _ && !!O }), F = p(() => O?.status === "recurring" ? (M?.iterations ?? []).flatMap((e) => e.issued_invoice_id ? [e.issued_invoice_id] : []) : [], [O?.status, M?.iterations]), I = re(F, { enabled: _ }), L = p(() => new Map(I.filter((e) => !!e).map((e) => [e.id, e])), [I]), [R, z] = m(h), [B, V] = m(g);
33
+ B !== g && (V(g), z(h));
34
+ let H = R.includes(i.auditHistory), U = p(() => P.data?.data ?? [], [P.data]), W = U.some((e) => e.recorded_by === "user" && !!e.entity_user_id), G = t(C?.scopes, [n.UserReadOrg]), { userNames: K, isError: q } = r({ enabled: _ && H && G && W }), J = p(() => ({
35
+ ...d(y, b),
36
+ ...x
36
37
  }), [
38
+ y,
37
39
  b,
38
- x,
39
- S
40
- ]), Y = m(() => {
40
+ x
41
+ ]), Y = p(() => {
41
42
  let t = O ? e(U, K, J, {
42
43
  documentType: "invoice",
43
44
  currency: O.currency,
@@ -62,11 +63,11 @@ function _({ selectedReceivableId: _, enabled: v = !0, canWrite: y = !0, message
62
63
  G,
63
64
  q,
64
65
  W
65
- ]), X = ae.data?.data.find((e) => e.id === O?.payment_reminder_id), Z = oe.data?.data.find((e) => e.id === O?.overdue_reminder_id), Q = A.paymentAccounts.find((e) => e.id === O?.bank_account_id), $ = k.data?.file_url || void 0;
66
+ ]), X = se.data?.data.find((e) => e.id === O?.payment_reminder_id), Z = ce.data?.data.find((e) => e.id === O?.overdue_reminder_id), Q = A.paymentAccounts.find((e) => e.id === O?.bank_account_id), $ = k.data?.file_url || void 0;
66
67
  return {
67
68
  receivable: D,
68
69
  recurrence: M,
69
- detailsView: m(() => f({
70
+ detailsView: p(() => ae({
70
71
  receivable: D,
71
72
  pdfUrl: $,
72
73
  paymentReminder: X,
@@ -78,10 +79,11 @@ function _({ selectedReceivableId: _, enabled: v = !0, canWrite: y = !0, message
78
79
  isLoadingPaymentRecords: N.isLoading,
79
80
  iterationInvoices: L,
80
81
  auditHistory: Y,
81
- statusLabels: x,
82
- messages: b,
83
- canWrite: y,
84
- onOpenReceivable: C
82
+ statusLabels: b,
83
+ messages: y,
84
+ canRecordPayment: T,
85
+ canWrite: v,
86
+ onOpenReceivable: S
85
87
  }), [
86
88
  D,
87
89
  $,
@@ -94,12 +96,13 @@ function _({ selectedReceivableId: _, enabled: v = !0, canWrite: y = !0, message
94
96
  N.isLoading,
95
97
  L,
96
98
  Y,
97
- x,
98
99
  b,
99
100
  y,
100
- C
101
+ T,
102
+ v,
103
+ S
101
104
  ]),
102
- unsupportedView: m(() => p(D, b), [D, b]),
105
+ unsupportedView: p(() => oe(D, y), [D, y]),
103
106
  openSections: R,
104
107
  setOpenSections: z,
105
108
  isLoading: E.isLoading || k.isLoading || j.isLoading,
@@ -107,4 +110,4 @@ function _({ selectedReceivableId: _, enabled: v = !0, canWrite: y = !0, message
107
110
  };
108
111
  }
109
112
  //#endregion
110
- export { _ as useReceivableDetails };
113
+ export { g as useReceivableDetails };
@@ -0,0 +1,91 @@
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 { extractApiErrorMessage as t } from "../../../../../shared/util/dist/lib/apiErrors.js";
7
+ import { useCurrentUserQuery as n } from "../../../../../shared/data-access/dist/lib/useCurrentUserQuery.js";
8
+ import "../../../../../shared/data-access/dist/index.js";
9
+ import "../../../../../shared/ui/dist/index.js";
10
+ import { useWidgetConfig as r } from "../../../../../shared/feature/dist/lib/WidgetProvider/hooks.js";
11
+ import "../../../../../shared/feature/dist/index.js";
12
+ import { getCurrencySymbol as i } from "./lineItems.js";
13
+ import { formatMoney as a } from "./helpers.js";
14
+ import { useCreateReceivablePaymentRecordMutation as o } from "../../../../data-access/dist/index10.js";
15
+ import "../../../../data-access/dist/index.js";
16
+ import { amountDueInputValue as s, buildPaymentRecordPayload as c, buildPaymentReviewView as l, defaultPaymentRecordValues as u, hasPaymentRecordErrors as d, validatePaymentRecordValues as f } from "./paymentRecord.js";
17
+ import { useCallback as p, useState as m } from "react";
18
+ //#region ../../libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/useReceivablePaymentRecord.js
19
+ function h({ messages: h }) {
20
+ let [g, _] = m(), [v, y] = m("form"), [b, x] = m(() => u()), [S, C] = m({}), [w, T] = m(!1), { initResponse: E } = r(), D = E?.userId ?? void 0, O = o(), k = n({ enabled: !!g }), A = p((e) => {
21
+ _(e), y("form"), x(u()), C({}), T(!1);
22
+ }, []), j = p(() => _(void 0), []), M = p((e) => {
23
+ let t = {
24
+ ...b,
25
+ ...e
26
+ };
27
+ x(t), w && C(f(t, h, g?.currency));
28
+ }, [
29
+ w,
30
+ g?.currency,
31
+ h,
32
+ b
33
+ ]), N = p(() => {
34
+ g && M({ amount: s(g) });
35
+ }, [M, g]), P = p(() => {
36
+ let e = f(b, h, g?.currency);
37
+ C(e), T(!0), d(e) || y("review");
38
+ }, [
39
+ g?.currency,
40
+ h,
41
+ b
42
+ ]), F = p(() => y("form"), []), I = p(() => {
43
+ g && O.mutate({ body: c({
44
+ invoice: g,
45
+ values: b,
46
+ entityUserId: D
47
+ }) }, {
48
+ onSuccess: () => {
49
+ e.success(h.paymentRecordCreated), _(void 0);
50
+ },
51
+ onError: (n) => {
52
+ e.error(h.paymentRecordCreateFailed.replace("{errorMessage}", t(n) ?? h.genericError));
53
+ }
54
+ });
55
+ }, [
56
+ O,
57
+ D,
58
+ g,
59
+ h,
60
+ b
61
+ ]);
62
+ return {
63
+ open: A,
64
+ isOpen: !!g,
65
+ step: v,
66
+ values: b,
67
+ errors: S,
68
+ currencySymbol: g ? i(g.currency) : "",
69
+ amountDueLabel: g ? a({
70
+ amount: g.amount_due,
71
+ currency: g.currency,
72
+ fallback: ""
73
+ }) : "",
74
+ review: g ? l({
75
+ invoice: g,
76
+ values: b,
77
+ user: k.data,
78
+ isUserLoading: k.isLoading,
79
+ messages: h
80
+ }) : void 0,
81
+ inProgress: O.isPending || v === "review" && k.isLoading,
82
+ change: M,
83
+ fillAmountDue: N,
84
+ save: P,
85
+ edit: F,
86
+ confirm: I,
87
+ close: j
88
+ };
89
+ }
90
+ //#endregion
91
+ export { h as useReceivablePaymentRecord };