@tesouro/embedded-components-react 0.5.292 → 0.5.294

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 (48) hide show
  1. package/README.md +1 -1
  2. package/dist/index.d.ts +26 -1
  3. package/dist/lib/CounterpartsWidget.d.ts +2 -0
  4. package/dist/lib/CounterpartsWidgetPublic.d.ts +2 -0
  5. package/dist/lib/CustomersWidget.d.ts +2 -0
  6. package/dist/lib/ReceivablesWidget.d.ts +26 -1
  7. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index.js +4 -4
  8. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index11.js +3 -2
  9. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index14.js +5 -88
  10. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index15.js +70 -173
  11. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index16.js +210 -17
  12. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index17.js +29 -0
  13. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/ReceivablesWidget.js +6 -7
  14. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/details.js +142 -141
  15. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/helpers.js +84 -54
  16. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/labels.js +21 -3
  17. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/paymentTerms.js +27 -27
  18. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/recurrence.js +2 -1
  19. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/reminders.js +1 -1
  20. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/totals.js +13 -10
  21. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/useReceivableActions.js +84 -80
  22. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/useReceivableActionsModal.js +1 -1
  23. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/useReceivableDetails.js +32 -30
  24. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/useReceivableForm.js +417 -414
  25. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/useReceivableIssuePreflight.js +1 -1
  26. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/useReceivableReminders.js +1 -1
  27. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/useReceivableStatusCards.js +1 -1
  28. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/useReceivablesTable.js +83 -66
  29. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/useReceivablesWidget.js +133 -129
  30. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/useSendReceivableWithPaymentLink.js +26 -22
  31. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/useUtcDayStart.js +16 -0
  32. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index13.js +0 -1
  33. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index15.js +20 -22
  34. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index23.js +2 -2
  35. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index40.js +1 -1
  36. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index44.js +91 -85
  37. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index45.js +1 -0
  38. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index51.js +119 -88
  39. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index53.js +19 -16
  40. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index57.js +130 -96
  41. package/dist/libs/tesouro-embedded-components-react/shared/counterpart-management/feature/dist/lib/helpers.js +24 -8
  42. package/dist/libs/tesouro-embedded-components-react/shared/counterpart-management/feature/dist/lib/labels.js +2 -0
  43. package/dist/libs/tesouro-embedded-components-react/shared/counterpart-management/feature/dist/lib/useCounterpartForm.js +101 -98
  44. package/dist/libs/tesouro-embedded-components-react/shared/counterpart-management/ui/dist/index9.js +34 -20
  45. package/dist/libs/tesouro-embedded-components-react/shared/feature/dist/lib/analytics/build-info.js +1 -1
  46. package/dist/libs/tesouro-embedded-components-react/shared/product-catalog/ui/dist/index6.js +4 -3
  47. package/dist/packages/shared-ui-shadcn/dist/index.js +15 -10
  48. package/package.json +1 -1
@@ -9,60 +9,60 @@ import { getCounterpartEmail as n } from "../../../../../shared/counterpart-mana
9
9
  import "../../../../../shared/counterpart-management/feature/dist/index.js";
10
10
  import { useAcceptReceivableMutation as r, useCancelReceivableMutation as i, useCloneReceivableMutation as a, useDeclineReceivableMutation as o, useDeleteReceivableMutation as s, useIssueReceivableMutation as c } from "../../../../data-access/dist/index11.js";
11
11
  import { useMarkReceivablePaidMutation as l, useMarkReceivableUncollectibleMutation as u } from "../../../../data-access/dist/index13.js";
12
- import { useCancelRecurrenceMutation as ee, usePauseRecurrenceMutation as te, useResumeRecurrenceMutation as ne } from "../../../../data-access/dist/index15.js";
12
+ import { useCancelRecurrenceMutation as ee, usePauseRecurrenceMutation as d, useResumeRecurrenceMutation as te } from "../../../../data-access/dist/index16.js";
13
13
  import "../../../../data-access/dist/index.js";
14
- import { formatMoney as d, isReceivableReadyToIssue as f } from "./helpers.js";
15
- import { getIssueReminderBlocker as p, hasSelectedReminder as m } from "./reminders.js";
16
- import { useReceivableIssuePreflight as re } from "./useReceivableIssuePreflight.js";
17
- import { useReceivablePaymentRecord as ie } from "./useReceivablePaymentRecord.js";
18
- import { useCallback as h, useEffect as g, useState as _ } from "react";
14
+ import { formatMoney as f, isReceivableReadyToIssue as p } from "./helpers.js";
15
+ import { getIssueReminderBlocker as m, hasSelectedReminder as h } from "./reminders.js";
16
+ import { useReceivableIssuePreflight as ne } from "./useReceivableIssuePreflight.js";
17
+ import { useReceivablePaymentRecord as re } from "./useReceivablePaymentRecord.js";
18
+ import { useCallback as g, useEffect as ie, useState as _ } from "react";
19
19
  //#region ../../libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/useReceivableActions.js
20
- function v({ selectedReceivable: d, selectedRecurrence: v, messages: b, onCreated: x, onDeleted: S, onCompleteBeforeIssue: C, onIssuedForSend: w, onResend: T }) {
21
- let E = c(), D = i(), O = a(), k = r(), A = o(), j = s(), M = l(), N = u(), P = te(), F = ne(), I = ee(), [L, R] = _(), [se, z] = _(), [B, V] = _(""), H = ie({ messages: b }), U = H.open, W = P.mutate, G = O.mutate, K = F.mutate, q = d?.type === "invoice" && d.status === "draft" ? d : void 0, J = d?.type === "invoice" && d.status !== "draft" ? d : void 0, [Y, X] = _(), Z = Y?.issueCheck ?? (q ? y(q) : void 0), Q = E.mutate, $ = re({
20
+ function v({ selectedReceivable: f, selectedRecurrence: v, messages: x, onCreated: S, onDeleted: C, onCompleteBeforeIssue: w, onIssuedForSend: T, onResend: E }) {
21
+ let D = c(), O = i(), k = a(), A = r(), j = o(), M = s(), N = l(), P = u(), F = d(), I = te(), L = ee(), [R, z] = _(), [B, V] = _(""), H = re({ messages: x }), U = H.open, W = F.mutate, G = k.mutate, K = I.mutate, q = f?.type === "invoice" && f.status === "draft" ? f : void 0, J = f?.type === "invoice" && f.status !== "draft" ? f : void 0, [Y, X] = _(), Z = Y?.issueCheck ?? (q ? b(q) : void 0), Q = D.mutate, $ = ne({
22
22
  counterpartId: Z?.counterpartId ?? J?.counterpart_id,
23
23
  billingAddressId: Z?.billingAddressId,
24
24
  billingCountry: Z?.billingCountry,
25
25
  checkRequiredFields: !!Z
26
26
  });
27
- g(() => {
27
+ ie(() => {
28
28
  if (!Y || $.isLoading) return;
29
29
  X(void 0);
30
- let t = Y.issueCheck ? $.isTaxIdMissing ? b.issueTaxIdRequired : Y.issueCheck.hasReminder ? p($.counterpart, b) : void 0 : void 0;
30
+ let t = Y.issueCheck ? $.isTaxIdMissing ? x.issueTaxIdRequired : Y.issueCheck.hasReminder ? m($.counterpart, x) : void 0 : void 0;
31
31
  if (t) {
32
32
  e.error(t);
33
33
  return;
34
34
  }
35
35
  Q({ path: { receivable_id: Y.id } }, {
36
- onSuccess: () => e.success(b.issueSucceeded),
37
- onError: () => e.error(b.issueFailed)
36
+ onSuccess: () => e.success(x.issueSucceeded),
37
+ onError: (e) => y(e, x)
38
38
  });
39
39
  }, [
40
40
  Q,
41
- b,
41
+ x,
42
42
  Y,
43
43
  $.counterpart,
44
44
  $.isLoading,
45
45
  $.isTaxIdMissing
46
46
  ]);
47
- let ce = h((r, i, a) => {
47
+ let se = g((r, i, a) => {
48
48
  let o = "documentLabel" in i ? i.documentLabel : i.title, s = {
49
49
  id: i.id,
50
50
  type: i.type,
51
51
  title: o,
52
52
  action: r
53
- }, c = a === void 0 ? d : a ?? void 0;
53
+ }, c = a === void 0 ? f : a ?? void 0;
54
54
  if (r === "send") {
55
55
  if (c?.type !== "invoice" || $.isCounterpartLoading) return;
56
56
  if ($.isCounterpartError) {
57
- e.error(b.genericError);
57
+ e.error(x.genericError);
58
58
  return;
59
59
  }
60
60
  let t = $.counterpart?.id === c.counterpart_id ? $.counterpart : void 0;
61
61
  if (!t || !n(t)) {
62
- e.error(b.sendNoEmail);
62
+ e.error(x.sendNoEmail);
63
63
  return;
64
64
  }
65
- T?.(c.id, c.counterpart_id);
65
+ E?.(c.id, c.counterpart_id);
66
66
  return;
67
67
  }
68
68
  if (r === "issueAndSend") {
@@ -70,36 +70,36 @@ function v({ selectedReceivable: d, selectedRecurrence: v, messages: b, onCreate
70
70
  let t = c;
71
71
  if ($.isLoading) return;
72
72
  if ($.isCounterpartError) {
73
- e.error(b.genericError);
73
+ e.error(x.genericError);
74
74
  return;
75
75
  }
76
76
  if (!$.counterpart || !n($.counterpart)) {
77
- e.error(b.sendNoEmail);
77
+ e.error(x.sendNoEmail);
78
78
  return;
79
79
  }
80
- if (C && !f(t, b)) {
81
- C(t, "issueAndSend");
80
+ if (w && !p(t, x)) {
81
+ w(t, "issueAndSend");
82
82
  return;
83
83
  }
84
- let r = $.isTaxIdMissing ? b.issueTaxIdRequired : m(t) ? p($.counterpart, b) : void 0;
84
+ let r = $.isTaxIdMissing ? x.issueTaxIdRequired : h(t) ? m($.counterpart, x) : void 0;
85
85
  if (r) {
86
86
  e.error(r);
87
87
  return;
88
88
  }
89
89
  Q({ path: { receivable_id: t.id } }, {
90
90
  onSuccess: () => {
91
- e.success(b.issueSucceeded), w?.(t.id, t.counterpart_id);
91
+ e.success(x.issueSucceeded), T?.(t.id, t.counterpart_id);
92
92
  },
93
- onError: () => e.error(b.issueFailed)
93
+ onError: (e) => y(e, x)
94
94
  });
95
95
  return;
96
96
  }
97
97
  if (r === "clone") {
98
98
  G({ path: { receivable_id: i.id } }, {
99
99
  onSuccess: (t) => {
100
- t?.id && x?.(t.id, t.type), e.success(b.cloneSuccess);
100
+ t?.id && S?.(t.id, t.type), e.success(x.cloneSuccess);
101
101
  },
102
- onError: (n) => e.error(t(n) ?? b.cloneError)
102
+ onError: (n) => e.error(t(n) ?? x.cloneError)
103
103
  });
104
104
  return;
105
105
  }
@@ -111,17 +111,17 @@ function v({ selectedReceivable: d, selectedRecurrence: v, messages: b, onCreate
111
111
  path: { recurrence_id: l },
112
112
  receivableId: i.id
113
113
  }, {
114
- onSuccess: () => e.success(n ? b.recurrencePaused : b.recurrenceResumed),
115
- onError: (n) => e.error(t(n) ?? b.genericError)
114
+ onSuccess: () => e.success(n ? x.recurrencePaused : x.recurrenceResumed),
115
+ onError: (n) => e.error(t(n) ?? x.genericError)
116
116
  });
117
117
  return;
118
118
  }
119
119
  if (r === "cancelRecurrence") {
120
120
  if (!l || c?.type !== "invoice") return;
121
- z(void 0), R({
121
+ z({
122
122
  ...s,
123
123
  recurrenceId: l,
124
- description: ae(c, v, b)
124
+ description: ae(c, v, x)
125
125
  });
126
126
  return;
127
127
  }
@@ -130,26 +130,26 @@ function v({ selectedReceivable: d, selectedRecurrence: v, messages: b, onCreate
130
130
  return;
131
131
  }
132
132
  let u = r === "issue" && c?.type === "invoice" ? c : void 0;
133
- if (u && C && !f(u, b)) {
134
- C(u, "issue");
133
+ if (u && w && !p(u, x)) {
134
+ w(u, "issue");
135
135
  return;
136
136
  }
137
137
  if (r === "issue") {
138
138
  X({
139
139
  id: i.id,
140
- issueCheck: u ? y(u) : void 0
140
+ issueCheck: u ? b(u) : void 0
141
141
  });
142
142
  return;
143
143
  }
144
- z(void 0), V(""), R(s);
144
+ V(""), z(s);
145
145
  }, [
146
146
  G,
147
147
  Q,
148
- b,
149
- C,
150
148
  x,
151
149
  w,
150
+ S,
152
151
  T,
152
+ E,
153
153
  U,
154
154
  $.counterpart,
155
155
  $.isCounterpartError,
@@ -158,71 +158,73 @@ function v({ selectedReceivable: d, selectedRecurrence: v, messages: b, onCreate
158
158
  $.isTaxIdMissing,
159
159
  W,
160
160
  K,
161
- d,
161
+ f,
162
162
  v
163
- ]), le = h(() => {
164
- R(void 0), z(void 0);
165
- }, []), ue = h(async () => {
166
- if (!L) return;
167
- let n = { receivable_id: L.id };
168
- if (L.action === "cancelRecurrence") {
169
- if (!L.recurrenceId) return;
163
+ ]), ce = g(() => {
164
+ z(void 0);
165
+ }, []), le = g(async () => {
166
+ if (!R) return;
167
+ let n = { receivable_id: R.id };
168
+ if (R.action === "cancelRecurrence") {
169
+ if (!R.recurrenceId) return;
170
170
  try {
171
- await I.mutateAsync({
172
- path: { recurrence_id: L.recurrenceId },
173
- receivableId: L.id
174
- }), e.success(b.recurrenceCanceled), R(void 0);
171
+ await L.mutateAsync({
172
+ path: { recurrence_id: R.recurrenceId },
173
+ receivableId: R.id
174
+ }), e.success(x.recurrenceCanceled), z(void 0);
175
175
  } catch (n) {
176
- e.error(t(n) ?? b.genericError);
176
+ e.error(t(n) ?? x.genericError);
177
177
  }
178
178
  return;
179
179
  }
180
180
  try {
181
- L.action === "cancel" ? await D.mutateAsync({ path: n }) : L.action === "accept" ? await k.mutateAsync({ path: n }) : L.action === "decline" ? await A.mutateAsync({ path: n }) : L.action === "delete" ? (await j.mutateAsync({ path: n }), S?.(L.id)) : L.action === "markPaid" ? await M.mutateAsync({
181
+ R.action === "cancel" ? (await O.mutateAsync({ path: n }), e.success(x.cancelSucceeded)) : R.action === "accept" ? await A.mutateAsync({ path: n }) : R.action === "decline" ? await j.mutateAsync({ path: n }) : R.action === "delete" ? (await M.mutateAsync({ path: n }), e.success(x.deleteSucceeded), C?.(R.id)) : R.action === "markPaid" ? await N.mutateAsync({
182
182
  path: n,
183
183
  body: { paid_at: (/* @__PURE__ */ new Date()).toISOString() }
184
- }) : L.action === "markUncollectible" && await N.mutateAsync({
184
+ }) : R.action === "markUncollectible" && (await P.mutateAsync({
185
185
  path: n,
186
186
  body: { comment: B.trim() || void 0 }
187
- }), R(void 0), z(void 0);
188
- } catch (e) {
189
- z(t(e) ?? b.genericError);
187
+ }), e.success(x.markUncollectibleSucceeded)), z(void 0);
188
+ } catch (n) {
189
+ e.error(t(n) ?? x.unrecognizedError);
190
190
  }
191
191
  }, [
192
- k,
192
+ A,
193
193
  B,
194
+ R,
195
+ O,
194
196
  L,
195
- D,
196
- I,
197
- A,
198
197
  j,
199
198
  M,
200
- b,
201
- S,
202
- N
199
+ N,
200
+ x,
201
+ C,
202
+ P
203
203
  ]);
204
204
  return {
205
- actionTarget: L,
206
- actionDialog: L ? oe(L, b) : void 0,
207
- actionError: se,
208
- actionComment: L?.action === "markUncollectible" ? B : void 0,
205
+ actionTarget: R,
206
+ actionDialog: R ? oe(R, x) : void 0,
207
+ actionComment: R?.action === "markUncollectible" ? B : void 0,
209
208
  setActionComment: V,
210
- actionInProgress: E.isPending || D.isPending || k.isPending || A.isPending || j.isPending || M.isPending || N.isPending || I.isPending,
209
+ actionInProgress: D.isPending || O.isPending || A.isPending || j.isPending || M.isPending || N.isPending || P.isPending || L.isPending,
211
210
  pendingActions: [
212
- ...P.isPending ? ["pauseRecurrence"] : [],
213
- ...F.isPending ? ["resumeRecurrence"] : [],
214
- ...O.isPending ? ["clone"] : [],
215
- ...E.isPending || Y || q && $.isLoading ? ["issue", "issueAndSend"] : [],
211
+ ...F.isPending ? ["pauseRecurrence"] : [],
212
+ ...I.isPending ? ["resumeRecurrence"] : [],
213
+ ...k.isPending ? ["clone"] : [],
214
+ ...D.isPending || Y || q && $.isLoading ? ["issue", "issueAndSend"] : [],
216
215
  ...J && $.isCounterpartLoading ? ["send"] : []
217
216
  ],
218
- openAction: ce,
219
- closeAction: le,
220
- confirmAction: ue,
217
+ openAction: se,
218
+ closeAction: ce,
219
+ confirmAction: le,
221
220
  payment: H
222
221
  };
223
222
  }
223
+ function y(n, r) {
224
+ e.error(t(n) ?? r.unrecognizedError), e.error(r.issueFailed);
225
+ }
224
226
  function ae(e, t, n) {
225
- let r = (t?.iterations ?? []).filter((e) => e.status === "pending").length, i = d({
227
+ let r = (t?.iterations ?? []).filter((e) => e.status === "pending").length, i = f({
226
228
  amount: e.total_amount_with_credit_notes * r,
227
229
  currency: e.currency,
228
230
  fallback: ""
@@ -232,22 +234,23 @@ function ae(e, t, n) {
232
234
  n.cancelRecurrenceFutureIterations,
233
235
  n.cancelRecurrenceTotal.replace("{count}", String(r)).replace("{invoices}", r === 1 ? n.cancelRecurrenceInvoice : n.cancelRecurrenceInvoices).replace("{amount}", i),
234
236
  n.cancelRecurrenceIrreversible
235
- ].join("\n");
237
+ ];
236
238
  }
237
- function y(e) {
239
+ function b(e) {
238
240
  return {
239
241
  counterpartId: e.counterpart_id,
240
242
  billingAddressId: e.counterpart_billing_address?.id ?? void 0,
241
243
  billingCountry: e.counterpart_billing_address?.country,
242
- hasReminder: m(e)
244
+ hasReminder: h(e)
243
245
  };
244
246
  }
245
247
  function oe({ action: e, description: t, title: n }, r) {
246
248
  return e === "cancelRecurrence" ? {
247
249
  title: r.cancelRecurrenceTitle,
248
- description: t ?? "",
250
+ description: t ?? [],
249
251
  confirmLabel: r.cancelRecurrenceConfirm,
250
252
  cancelLabel: r.cancelRecurrenceClose,
253
+ cancelVariant: "outline",
251
254
  destructive: !0
252
255
  } : e === "accept" ? {
253
256
  title: r.acceptTitle,
@@ -266,9 +269,10 @@ function oe({ action: e, description: t, title: n }, r) {
266
269
  cancelVariant: "outline",
267
270
  destructive: !0
268
271
  } : e === "delete" ? {
269
- title: r.deleteTitle,
272
+ title: n && n !== r.untitledDocument ? r.deleteNumberedTitle.replace("{number}", n) : r.deleteTitle,
270
273
  description: r.deleteDescription,
271
274
  confirmLabel: r.deleteConfirm,
275
+ cancelVariant: "outline",
272
276
  destructive: !0
273
277
  } : e === "markPaid" ? {
274
278
  title: r.markPaidTitle,
@@ -7,7 +7,7 @@ import "../../../../../shared/ui/dist/index.js";
7
7
  import { getCounterpartEmail as t, getCounterpartName as n } from "../../../../../shared/counterpart-management/feature/dist/lib/helpers.js";
8
8
  import { useCounterpartQuery as r } from "../../../../../shared/counterpart-management/data-access/dist/index3.js";
9
9
  import "../../../../../shared/counterpart-management/feature/dist/index.js";
10
- import { useReceivableQuery as i } from "../../../../data-access/dist/index14.js";
10
+ import { useReceivableQuery as i } from "../../../../data-access/dist/index15.js";
11
11
  import "../../../../data-access/dist/index.js";
12
12
  import { useCreateProductMutation as a } from "../../../../../shared/product-catalog/data-access/dist/index6.js";
13
13
  import { useMeasureUnits as o } from "../../../../../shared/product-catalog/feature/dist/lib/useMeasureUnits.js";
@@ -14,8 +14,8 @@ import "../../../../ui/dist/index.js";
14
14
  import { useAllReceivableHistoryQuery as ee } from "../../../../data-access/dist/index4.js";
15
15
  import { usePaymentAccountsQuery as o } from "../../../../data-access/dist/index6.js";
16
16
  import { useReceivablePaymentRecordsQuery as s } from "../../../../data-access/dist/index12.js";
17
- import { useReceivablePdfLinkQuery as te, useReceivableQuery as ne, useReceivablesByIdQueries as re } from "../../../../data-access/dist/index14.js";
18
- import { useOverdueRemindersQuery as ie, usePaymentRemindersQuery as c, useRecurrenceQuery as l } from "../../../../data-access/dist/index15.js";
17
+ import { useReceivablePdfLinkQuery as te, useReceivableQuery as ne, useReceivablesByIdQueries as re } from "../../../../data-access/dist/index15.js";
18
+ import { useOverdueRemindersQuery as ie, usePaymentRemindersQuery as c, useRecurrenceQuery as l } from "../../../../data-access/dist/index16.js";
19
19
  import "../../../../data-access/dist/index.js";
20
20
  import { canRecordPayments as u } from "./paymentRecord.js";
21
21
  import { buildReceivableAuditHistoryLabels as ae } from "./auditHistory/labels.js";
@@ -25,13 +25,13 @@ import { useMemo as d, useState as f } from "react";
25
25
  //#region ../../libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/useReceivableDetails.js
26
26
  var p = [a.attachments];
27
27
  function m({ selectedReceivableId: m, enabled: h = !0, canWrite: g = !0, messages: _, statusLabels: v, auditHistoryLabels: y, onOpenReceivable: b, onOpenCustomer: x }) {
28
- let { initResponse: S } = r(), C = d(() => oe(S?.scopes), [S?.scopes]), w = u(S?.scopes), T = ne(m, { enabled: h }), E = T.data, D = E?.type === "invoice" ? E : void 0, le = te(m, { enabled: h && !!D }), ue = c({ enabled: h && !!D?.payment_reminder_id }), O = ie({ enabled: h && !!D?.overdue_reminder_id }), k = o({
28
+ let { initResponse: S } = r(), C = d(() => oe(S?.scopes), [S?.scopes]), w = u(S?.scopes), T = ne(m, { enabled: h }), E = T.data, D = E?.type === "invoice" ? E : void 0, le = te(m, { enabled: h && !!D }), ue = c({ enabled: h && !!D?.payment_reminder_id }), de = ie({ enabled: h && !!D?.overdue_reminder_id }), O = o({
29
29
  enabled: h && !!D,
30
30
  canReadEmbedded: C.canReadEmbedded,
31
31
  canReadExternal: C.canReadExternal
32
- }), A = l(h ? D?.recurrence_id : void 0), j = A.data, M = s(D?.id, { enabled: h }), N = ee(D?.id, { enabled: h && !!D }), P = d(() => D?.status === "recurring" ? (j?.iterations ?? []).flatMap((e) => e.issued_invoice_id ? [e.issued_invoice_id] : []) : [], [D?.status, j?.iterations]), F = re(P, { enabled: h }), I = d(() => new Map(F.filter((e) => !!e).map((e) => [e.id, e])), [F]), [L, R] = f(p), [z, B] = f(m);
33
- z !== m && (B(m), R(p));
34
- let V = L.includes(a.auditHistory), H = d(() => N.data?.data ?? [], [N.data]), U = H.some((e) => e.recorded_by === "user" && !!e.entity_user_id), W = t(S?.scopes, [n.UserReadOrg]), { userNames: G, isError: K } = i({ enabled: h && V && W && U }), q = d(() => ({
32
+ }), k = l(h ? D?.recurrence_id : void 0), A = k.data, j = s(D?.id, { enabled: h }), M = ee(D?.id, { enabled: h && !!D }), N = d(() => D?.status === "recurring" ? (A?.iterations ?? []).flatMap((e) => e.issued_invoice_id ? [e.issued_invoice_id] : []) : [], [D?.status, A?.iterations]), P = re(N, { enabled: h }), F = d(() => new Map(P.filter((e) => !!e).map((e) => [e.id, e])), [P]), [I, L] = f(p), [R, z] = f(m);
33
+ R !== m && (z(m), L(p));
34
+ let B = I.includes(a.auditHistory), V = d(() => M.data?.data ?? [], [M.data]), H = V.some((e) => e.event_type === "mail_sent"), U = V.some((e) => e.recorded_by === "user" && !!e.entity_user_id), W = t(S?.scopes, [n.UserReadOrg]), { userNames: G, isError: K } = i({ enabled: h && B && W && U }), q = d(() => ({
35
35
  ...ae(_, v),
36
36
  ...y
37
37
  }), [
@@ -39,7 +39,7 @@ function m({ selectedReceivableId: m, enabled: h = !0, canWrite: g = !0, message
39
39
  v,
40
40
  y
41
41
  ]), J = d(() => {
42
- let t = D ? e(H, G, q, {
42
+ let t = D ? e(V, G, q, {
43
43
  documentType: "invoice",
44
44
  currency: D.currency,
45
45
  documentNumber: D.document_id,
@@ -47,37 +47,38 @@ function m({ selectedReceivableId: m, enabled: h = !0, canWrite: g = !0, message
47
47
  }) : [];
48
48
  return {
49
49
  rows: t,
50
- countLabel: N.data && !N.isLoading && !N.isError ? String(t.length) : void 0,
51
- isLoading: N.isLoading,
52
- isError: N.isError,
50
+ countLabel: M.data && !M.isLoading && !M.isError ? String(t.length) : void 0,
51
+ isLoading: M.isLoading,
52
+ isError: M.isError,
53
53
  showNamesError: W && K && U
54
54
  };
55
55
  }, [
56
56
  D,
57
- H,
57
+ V,
58
58
  G,
59
59
  q,
60
- N.data,
61
- N.isLoading,
62
- N.isError,
60
+ M.data,
61
+ M.isLoading,
62
+ M.isError,
63
63
  W,
64
64
  K,
65
65
  U
66
- ]), Y = ue.data?.data.find((e) => e.id === D?.payment_reminder_id), X = O.data?.data.find((e) => e.id === D?.overdue_reminder_id), Z = k.paymentAccounts.find((e) => e.id === D?.bank_account_id), Q = le.data?.file_url || void 0, de = d(() => ce({
66
+ ]), Y = ue.data?.data.find((e) => e.id === D?.payment_reminder_id), X = de.data?.data.find((e) => e.id === D?.overdue_reminder_id), Z = O.paymentAccounts.find((e) => e.id === D?.bank_account_id), Q = le.data?.file_url || void 0, fe = d(() => ce({
67
67
  receivable: E,
68
68
  pdfUrl: Q,
69
69
  paymentReminder: Y,
70
70
  overdueReminder: X,
71
71
  depositAccount: Z,
72
- isAccountListIncomplete: k.isIncomplete,
73
- recurrence: j,
74
- paymentRecords: M.data?.data,
75
- isLoadingPaymentRecords: M.isLoading,
76
- iterationInvoices: I,
72
+ isAccountListIncomplete: O.isIncomplete,
73
+ recurrence: A,
74
+ paymentRecords: j.data?.data,
75
+ isLoadingPaymentRecords: j.isLoading,
76
+ iterationInvoices: F,
77
77
  auditHistory: J,
78
78
  statusLabels: v,
79
79
  messages: _,
80
80
  canRecordPayment: w,
81
+ hasBeenSent: H,
81
82
  canWrite: g,
82
83
  onOpenReceivable: b,
83
84
  onOpenCustomer: x
@@ -87,31 +88,32 @@ function m({ selectedReceivableId: m, enabled: h = !0, canWrite: g = !0, message
87
88
  Y,
88
89
  X,
89
90
  Z,
90
- k.isIncomplete,
91
- j,
92
- M.data,
93
- M.isLoading,
94
- I,
91
+ O.isIncomplete,
92
+ A,
93
+ j.data,
94
+ j.isLoading,
95
+ F,
95
96
  J,
96
97
  v,
97
98
  _,
98
99
  w,
100
+ H,
99
101
  g,
100
102
  b,
101
103
  x
102
- ]), $ = T.isLoading || A.isLoading;
104
+ ]), $ = T.isLoading || k.isLoading;
103
105
  return {
104
106
  receivable: E,
105
- recurrence: j,
106
- detailsView: de,
107
+ recurrence: A,
108
+ detailsView: fe,
107
109
  messageView: d(() => $ ? void 0 : se(E, m ?? "", _), [
108
110
  $,
109
111
  E,
110
112
  m,
111
113
  _
112
114
  ]),
113
- openSections: L,
114
- setOpenSections: R,
115
+ openSections: I,
116
+ setOpenSections: L,
115
117
  isLoading: $
116
118
  };
117
119
  }