@tesouro/embedded-components-react 0.5.273 → 0.5.275

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 (34) hide show
  1. package/README.md +1 -1
  2. package/dist/index.d.ts +1 -0
  3. package/dist/lib/ReceivablesWidget.d.ts +1 -0
  4. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index.js +10 -9
  5. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index10.js +173 -44
  6. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index11.js +42 -94
  7. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index12.js +91 -76
  8. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index13.js +67 -173
  9. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index14.js +186 -17
  10. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index15.js +27 -0
  11. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index6.js +16 -62
  12. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index7.js +66 -28
  13. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index8.js +28 -34
  14. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index9.js +24 -168
  15. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/ReceivablesWidget.js +18 -17
  16. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/details.js +9 -9
  17. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/labels.js +1 -0
  18. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/preview.js +47 -44
  19. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/useReceivableActions.js +125 -122
  20. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/useReceivableActionsModal.js +50 -47
  21. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/useReceivableAttachmentUploads.js +1 -1
  22. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/useReceivableDetails.js +3 -3
  23. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/useReceivableForm.js +2 -2
  24. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/useReceivableIssuePreflight.js +1 -1
  25. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/useReceivablePaymentRecord.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 +51 -51
  29. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/useReceivablesWidget.js +123 -119
  30. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/useSendReceivableWithPaymentLink.js +54 -0
  31. package/dist/libs/tesouro-embedded-components-react/shared/data-access/dist/index.js +41 -41
  32. package/dist/libs/tesouro-embedded-components-react/shared/data-access/dist/lib/rest/sdk.gen.js +83 -71
  33. package/dist/libs/tesouro-embedded-components-react/shared/feature/dist/lib/analytics/build-info.js +1 -1
  34. package/package.json +1 -1
@@ -8,19 +8,22 @@ import { differenceInCalendarDays as d, parseISO as f } from "date-fns";
8
8
  //#region ../../libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/preview.js
9
9
  var p = "US", m = 100;
10
10
  function h(e) {
11
- return (e ?? []).some(({ status: e, direction: t }) => e === "active" && t === "receive");
11
+ return (e ?? []).filter(({ status: e, direction: t }) => e === "active" && t === "receive");
12
12
  }
13
13
  function g(e) {
14
- return e?.invoice?.display_organization_bank_account ?? e?.display_organization_bank_account ?? !0;
14
+ return h(e).length > 0;
15
15
  }
16
16
  function _(e) {
17
+ return e?.invoice?.display_organization_bank_account ?? e?.display_organization_bank_account ?? !0;
18
+ }
19
+ function v(e) {
17
20
  try {
18
21
  return new Intl.DisplayNames(void 0, { type: "region" }).of(e) ?? e;
19
22
  } catch {
20
23
  return e;
21
24
  }
22
25
  }
23
- function v({ address: e, issuerCountry: t, formatCountry: n = _ }) {
26
+ function y({ address: e, issuerCountry: t, formatCountry: n = v }) {
24
27
  if (!e) return [];
25
28
  let r = [e.city, e.state].filter(Boolean).join(", "), i = e.country === p && t === p;
26
29
  return [
@@ -29,65 +32,65 @@ function v({ address: e, issuerCountry: t, formatCountry: n = _ }) {
29
32
  e.country && !i ? n(e.country) : ""
30
33
  ].filter(Boolean);
31
34
  }
32
- var y = { kind: "pending" }, b = (e) => ({
35
+ var b = { kind: "pending" }, x = (e) => ({
33
36
  kind: "text",
34
37
  lines: e
35
38
  });
36
- function x(e, t) {
39
+ function S(e, t) {
37
40
  return e.previewNetDays.replace("{days}", String(t));
38
41
  }
39
- function S(e, t) {
42
+ function C(e, t) {
40
43
  let n = e.previewEarlyPaymentDays.replace("{days}", String(t.number_of_days));
41
44
  return t.discount ? `${n}, ${e.previewEarlyPaymentDiscount.replace("{rate}", String(t.discount / m))}` : n;
42
45
  }
43
- function C({ paymentTermsId: e, paymentTermsCustomDate: t, paymentTerms: n, issueDate: r, messages: i }) {
46
+ function w({ paymentTermsId: e, paymentTermsCustomDate: t, paymentTerms: n, issueDate: r, messages: i }) {
44
47
  let a = {
45
- dueDate: y,
46
- paymentTerms: y
48
+ dueDate: b,
49
+ paymentTerms: b
47
50
  };
48
51
  if (e === "custom") {
49
52
  if (!t) return a;
50
53
  let e = f(t), n = Math.max(0, d(e, r));
51
54
  return {
52
- dueDate: b([s(e)]),
53
- paymentTerms: b([x(i, n)])
55
+ dueDate: x([s(e)]),
56
+ paymentTerms: x([S(i, n)])
54
57
  };
55
58
  }
56
59
  if (e === "receipt_due") return {
57
- dueDate: b([s(r)]),
58
- paymentTerms: b([i.previewDueOnReceipt])
60
+ dueDate: x([s(r)]),
61
+ paymentTerms: x([i.previewDueOnReceipt])
59
62
  };
60
63
  let o = n?.find((t) => t.id === e);
61
64
  if (!o) return a;
62
65
  let c = l(o, r), u = [
63
- o.term_1 && S(i, o.term_1),
64
- o.term_2 && S(i, o.term_2),
65
- o.term_final && x(i, o.term_final.number_of_days)
66
+ o.term_1 && C(i, o.term_1),
67
+ o.term_2 && C(i, o.term_2),
68
+ o.term_final && S(i, o.term_final.number_of_days)
66
69
  ].filter((e) => !!e);
67
70
  return {
68
- dueDate: c ? b([s(c)]) : y,
69
- paymentTerms: u.length > 0 ? b(u) : y
71
+ dueDate: c ? x([s(c)]) : b,
72
+ paymentTerms: u.length > 0 ? x(u) : b
70
73
  };
71
74
  }
72
- function w(e, t) {
75
+ function T(e, t) {
73
76
  return t ? e.previewTaxId.replace("{taxId}", t) : void 0;
74
77
  }
75
- function T(e) {
78
+ function E(e) {
76
79
  return e.length > 0 ? e : void 0;
77
80
  }
78
- function E(e, t) {
81
+ function D(e, t) {
79
82
  return e ? {
80
83
  name: e.type === "organization" ? e.organization.legal_name : void 0,
81
- addressLines: T(v({
84
+ addressLines: E(y({
82
85
  address: e.address,
83
86
  issuerCountry: e.address?.country
84
87
  })),
85
- taxIdLine: w(t, e.tax_id),
88
+ taxIdLine: T(t, e.tax_id),
86
89
  email: e.email ?? void 0,
87
90
  phone: e.phone ?? void 0
88
91
  } : {};
89
92
  }
90
- function D(e) {
93
+ function O(e) {
91
94
  let t = "organization" in e ? e.organization : e.individual;
92
95
  return {
93
96
  name: "organization" in e ? e.organization.legal_name : [e.individual.first_name, e.individual.last_name].filter(Boolean).join(" "),
@@ -95,22 +98,22 @@ function D(e) {
95
98
  phone: t.phone
96
99
  };
97
100
  }
98
- function O({ counterpart: e, billingAddress: t, issuerCountry: n, messages: r }) {
101
+ function k({ counterpart: e, billingAddress: t, issuerCountry: n, messages: r }) {
99
102
  if (!e) return { kind: "pending" };
100
- let { name: i, email: a, phone: o } = D(e);
103
+ let { name: i, email: a, phone: o } = O(e);
101
104
  return i ? {
102
105
  kind: "party",
103
106
  name: i,
104
- addressLines: T(v({
107
+ addressLines: E(y({
105
108
  address: t,
106
109
  issuerCountry: n
107
110
  })),
108
- taxIdLine: w(r, e.tax_id),
111
+ taxIdLine: T(r, e.tax_id),
109
112
  email: a || void 0,
110
113
  phone: o || void 0
111
114
  } : { kind: "pending" };
112
115
  }
113
- function k({ lineItems: e, currency: n, unitNamesById: r, messages: o }) {
116
+ function A({ lineItems: e, currency: n, unitNamesById: r, messages: o }) {
114
117
  return e.filter((e) => !t(e)).map((e) => {
115
118
  let t = a(e.price, n), s = i(e.quantity), c = r[e.measureUnitId] || e.measureUnitName;
116
119
  return {
@@ -132,19 +135,19 @@ function k({ lineItems: e, currency: n, unitNamesById: r, messages: o }) {
132
135
  };
133
136
  });
134
137
  }
135
- function A(t, n) {
138
+ function j(t, n) {
136
139
  return n ? new Intl.NumberFormat(void 0, {
137
140
  style: "currency",
138
141
  currency: n,
139
142
  currencySign: "accounting"
140
143
  }).format(-t / 10 ** e(n)) : "";
141
144
  }
142
- function j(e, i) {
145
+ function M(e, i) {
143
146
  if (!e.taxRate) return i.previewTax;
144
147
  let a = o(e.taxRate), s = n(e.taxRate, e.savedTaxRate);
145
148
  return new Set(e.lineItems.filter((e) => e.taxable && !t(e)).map((e) => r(e, a, s))).size > 1 ? i.previewTax : i.previewTaxWithRate.replace("{rate}", String(a / m));
146
149
  }
147
- function M({ totals: e, currency: t, taxLabel: n, messages: r }) {
150
+ function N({ totals: e, currency: t, taxLabel: n, messages: r }) {
148
151
  let i = (e) => u({
149
152
  amount: e,
150
153
  currency: t,
@@ -157,7 +160,7 @@ function M({ totals: e, currency: t, taxLabel: n, messages: r }) {
157
160
  return a && c.push({
158
161
  id: "discount",
159
162
  label: r.previewDiscount,
160
- value: A(e.discountAmount, t)
163
+ value: j(e.discountAmount, t)
161
164
  }), s && (o || a) && c.push({
162
165
  id: "nonTaxableSubtotal",
163
166
  label: r.previewNonTaxableSubtotal,
@@ -180,7 +183,7 @@ function M({ totals: e, currency: t, taxLabel: n, messages: r }) {
180
183
  }
181
184
  };
182
185
  }
183
- function N({ bankDetails: e, canReceivePayments: t, messages: n }) {
186
+ function P({ bankDetails: e, canReceivePayments: t, messages: n }) {
184
187
  let r = e ? [
185
188
  [n.previewAccountHolderName, e.accountHolderName],
186
189
  [n.previewRoutingNumber, e.routingNumber],
@@ -191,13 +194,13 @@ function N({ bankDetails: e, canReceivePayments: t, messages: n }) {
191
194
  bankLines: r
192
195
  };
193
196
  }
194
- function P({ values: e, totals: t, entity: n, counterpart: r, billingAddress: i, paymentTerms: a, unitNamesById: o, bankDetails: l, canReceivePayments: u = !1, messages: d, today: f = /* @__PURE__ */ new Date() }) {
195
- let p = k({
197
+ function F({ values: e, totals: t, entity: n, counterpart: r, billingAddress: i, paymentTerms: a, unitNamesById: o, bankDetails: l, canReceivePayments: u = !1, messages: d, today: f = /* @__PURE__ */ new Date() }) {
198
+ let p = A({
196
199
  lineItems: e.lineItems,
197
200
  currency: e.currency,
198
201
  unitNamesById: o,
199
202
  messages: d
200
- }), m = n?.logo?.url, h = E(n, d), g = c(e.issueDate, f);
203
+ }), m = n?.logo?.url, h = D(n, d), g = c(e.issueDate, f);
201
204
  return {
202
205
  issuer: h,
203
206
  logo: m ? {
@@ -205,15 +208,15 @@ function P({ values: e, totals: t, entity: n, counterpart: r, billingAddress: i,
205
208
  src: m,
206
209
  alt: h.name ? d.previewLogoAlt.replace("{name}", h.name) : d.previewLogoAltNoName
207
210
  } : { kind: "placeholder" },
208
- billTo: O({
211
+ billTo: k({
209
212
  counterpart: r,
210
213
  billingAddress: i,
211
214
  issuerCountry: n?.address?.country,
212
215
  messages: d
213
216
  }),
214
- invoiceNumber: y,
217
+ invoiceNumber: b,
215
218
  issueDate: s(g),
216
- ...C({
219
+ ...w({
217
220
  paymentTermsId: e.paymentTermsId,
218
221
  paymentTermsCustomDate: e.paymentTermsCustomDate,
219
222
  paymentTerms: a,
@@ -226,14 +229,14 @@ function P({ values: e, totals: t, entity: n, counterpart: r, billingAddress: i,
226
229
  kind: "rows",
227
230
  rows: p
228
231
  } : { kind: "empty" },
229
- totals: p.length > 0 ? M({
232
+ totals: p.length > 0 ? N({
230
233
  totals: t,
231
234
  currency: e.currency,
232
- taxLabel: j(e, d),
235
+ taxLabel: M(e, d),
233
236
  messages: d
234
237
  }) : void 0,
235
238
  closingNote: e.closingNote || void 0,
236
- payment: N({
239
+ payment: P({
237
240
  bankDetails: l,
238
241
  canReceivePayments: u,
239
242
  messages: d
@@ -241,4 +244,4 @@ function P({ values: e, totals: t, entity: n, counterpart: r, billingAddress: i,
241
244
  };
242
245
  }
243
246
  //#endregion
244
- export { v as buildPreviewAddressLines, C as buildPreviewPaymentTerms, P as buildReceivablePreviewView, g as displaysBankAccount, _ as formatCountryName, A as formatDeduction, h as hasReceivePaymentMethod };
247
+ export { y as buildPreviewAddressLines, w as buildPreviewPaymentTerms, F as buildReceivablePreviewView, _ as displaysBankAccount, v as formatCountryName, j as formatDeduction, h as getReceivePaymentMethods, g as hasReceivePaymentMethod };
@@ -7,241 +7,244 @@ import { extractApiErrorMessage as t } from "../../../../../shared/util/dist/lib
7
7
  import "../../../../../shared/ui/dist/index.js";
8
8
  import { getCounterpartEmail as n } from "../../../../../shared/counterpart-management/feature/dist/lib/helpers.js";
9
9
  import "../../../../../shared/counterpart-management/feature/dist/index.js";
10
- import { defaultSendValues as r, formatMoney as i, hasSendErrors as a, isReceivableReadyToIssue as ee, splitEmailList as o, validateSendValues as s } from "./helpers.js";
11
- import { getIssueReminderBlocker as c, hasSelectedReminder as l } from "./reminders.js";
12
- import { useSendReceivableEmailMutation as u } from "../../../../data-access/dist/index8.js";
13
- import { useAcceptReceivableMutation as d, useCancelReceivableMutation as f, useCloneReceivableMutation as p, useDeclineReceivableMutation as m, useDeleteReceivableMutation as te, useIssueReceivableMutation as ne } from "../../../../data-access/dist/index9.js";
14
- import { useMarkReceivablePaidMutation as re, useMarkReceivableUncollectibleMutation as ie } from "../../../../data-access/dist/index11.js";
15
- import { useCancelRecurrenceMutation as ae, usePauseRecurrenceMutation as oe, useResumeRecurrenceMutation as se } from "../../../../data-access/dist/index13.js";
10
+ import { defaultSendValues as r, formatMoney as i, hasSendErrors as a, isReceivableReadyToIssue as o, splitEmailList as s, validateSendValues as c } from "./helpers.js";
11
+ import { getIssueReminderBlocker as ee, hasSelectedReminder as l } from "./reminders.js";
12
+ import { useAcceptReceivableMutation as te, useCancelReceivableMutation as u, useCloneReceivableMutation as d, useDeclineReceivableMutation as f, useDeleteReceivableMutation as p, useIssueReceivableMutation as ne } from "../../../../data-access/dist/index10.js";
13
+ import { useMarkReceivablePaidMutation as re, useMarkReceivableUncollectibleMutation as ie } from "../../../../data-access/dist/index12.js";
14
+ import { useCancelRecurrenceMutation as ae, usePauseRecurrenceMutation as oe, useResumeRecurrenceMutation as se } from "../../../../data-access/dist/index14.js";
16
15
  import "../../../../data-access/dist/index.js";
17
16
  import { useReceivableIssuePreflight as ce } from "./useReceivableIssuePreflight.js";
18
17
  import { useReceivablePaymentRecord as le } from "./useReceivablePaymentRecord.js";
19
- import { useCallback as h, useEffect as ue, useState as g } from "react";
18
+ import { useSendReceivableWithPaymentLink as ue } from "./useSendReceivableWithPaymentLink.js";
19
+ import { useCallback as m, useEffect as de, useState as h } from "react";
20
20
  //#region ../../libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/useReceivableActions.js
21
- function _({ selectedReceivable: i, selectedRecurrence: _, messages: y, onCreated: b, onDeleted: x, onCompleteBeforeIssue: S, onIssuedForSend: C }) {
22
- let w = ne(), T = f(), E = p(), D = d(), O = m(), k = te(), A = u(), j = re(), M = ie(), pe = oe(), N = se(), P = ae(), [F, I] = g(), [me, L] = g(), [R, z] = g(""), [B, V] = g(), [H, U] = g(() => r(void 0, y)), [he, W] = g({}), G = le({ messages: y }), K = G.open, q = pe.mutate, ge = E.mutate, _e = N.mutate, J = i?.type === "invoice" && i.status === "draft" ? i : void 0, [Y, ve] = g(), X = Y?.issueCheck ?? (J ? v(J) : void 0), Z = w.mutate, Q = ce({
21
+ function g({ selectedReceivable: i, selectedRecurrence: g, messages: v, onCreated: y, onDeleted: b, onCompleteBeforeIssue: x, onIssuedForSend: S }) {
22
+ let C = ne(), w = u(), T = d(), E = te(), D = f(), O = p(), k = re(), A = ie(), j = oe(), M = se(), N = ae(), [P, F] = h(), [me, I] = h(), [L, R] = h(""), [z, B] = h(), [V, H] = h(() => r(void 0, v)), [he, U] = h({}), { send: W, isPending: ge } = ue({
23
+ messages: v,
24
+ documentType: z?.type
25
+ }), G = le({ messages: v }), K = G.open, q = j.mutate, _e = T.mutate, ve = M.mutate, J = i?.type === "invoice" && i.status === "draft" ? i : void 0, [Y, ye] = h(), X = Y?.issueCheck ?? (J ? _(J) : void 0), Z = C.mutate, Q = ce({
23
26
  counterpartId: X?.counterpartId,
24
27
  billingAddressId: X?.billingAddressId,
25
28
  billingCountry: X?.billingCountry
26
29
  });
27
- ue(() => {
30
+ de(() => {
28
31
  if (!Y || Q.isLoading) return;
29
- ve(void 0);
30
- let t = Y.issueCheck ? Q.isTaxIdMissing ? y.issueTaxIdRequired : Y.issueCheck.hasReminder ? c(Q.counterpart, y) : void 0 : void 0;
32
+ ye(void 0);
33
+ let t = Y.issueCheck ? Q.isTaxIdMissing ? v.issueTaxIdRequired : Y.issueCheck.hasReminder ? ee(Q.counterpart, v) : void 0 : void 0;
31
34
  if (t) {
32
35
  e.error(t);
33
36
  return;
34
37
  }
35
38
  Z({ path: { receivable_id: Y.id } }, {
36
- onSuccess: () => e.success(y.issueSucceeded),
37
- onError: () => e.error(y.issueFailed)
39
+ onSuccess: () => e.success(v.issueSucceeded),
40
+ onError: () => e.error(v.issueFailed)
38
41
  });
39
42
  }, [
40
43
  Z,
41
- y,
44
+ v,
42
45
  Y,
43
46
  Q.counterpart,
44
47
  Q.isLoading,
45
48
  Q.isTaxIdMissing
46
49
  ]);
47
- let ye = h((a, o, s) => {
48
- let u = "documentLabel" in o ? o.documentLabel : o.title, d = {
49
- id: o.id,
50
- type: o.type,
51
- title: u,
50
+ let be = m((a, s, c) => {
51
+ let te = "documentLabel" in s ? s.documentLabel : s.title, u = {
52
+ id: s.id,
53
+ type: s.type,
54
+ title: te,
52
55
  action: a
53
- }, f = s === void 0 ? i : s ?? void 0;
56
+ }, d = c === void 0 ? i : c ?? void 0;
54
57
  if (a === "send") {
55
- V(d), U(r(f, y)), W({});
58
+ B(u), H(r(d, v)), U({});
56
59
  return;
57
60
  }
58
61
  if (a === "issueAndSend") {
59
- if (f?.type !== "invoice") return;
60
- let t = f;
62
+ if (d?.type !== "invoice") return;
63
+ let t = d;
61
64
  if (Q.isLoading) return;
62
65
  if (!Q.counterpart || !n(Q.counterpart)) {
63
- e.error(y.issueAndSendNoEmail);
66
+ e.error(v.issueAndSendNoEmail);
64
67
  return;
65
68
  }
66
- if (S && !ee(t, y)) {
67
- S(t, "issueAndSend");
69
+ if (x && !o(t, v)) {
70
+ x(t, "issueAndSend");
68
71
  return;
69
72
  }
70
- let r = Q.isTaxIdMissing ? y.issueTaxIdRequired : l(t) ? c(Q.counterpart, y) : void 0;
73
+ let r = Q.isTaxIdMissing ? v.issueTaxIdRequired : l(t) ? ee(Q.counterpart, v) : void 0;
71
74
  if (r) {
72
75
  e.error(r);
73
76
  return;
74
77
  }
75
78
  Z({ path: { receivable_id: t.id } }, {
76
79
  onSuccess: () => {
77
- e.success(y.issueSucceeded), C?.(t.id, t.counterpart_id);
80
+ e.success(v.issueSucceeded), S?.(t.id, t.counterpart_id);
78
81
  },
79
- onError: () => e.error(y.issueFailed)
82
+ onError: () => e.error(v.issueFailed)
80
83
  });
81
84
  return;
82
85
  }
83
86
  if (a === "clone") {
84
- ge({ path: { receivable_id: o.id } }, {
87
+ _e({ path: { receivable_id: s.id } }, {
85
88
  onSuccess: (t) => {
86
- t?.id && b?.(t.id, t.type), e.success(y.cloneSuccess);
89
+ t?.id && y?.(t.id, t.type), e.success(v.cloneSuccess);
87
90
  },
88
- onError: (n) => e.error(t(n) ?? y.cloneError)
91
+ onError: (n) => e.error(t(n) ?? v.cloneError)
89
92
  });
90
93
  return;
91
94
  }
92
- let p = f?.type === "invoice" ? f.recurrence_id ?? void 0 : void 0;
95
+ let f = d?.type === "invoice" ? d.recurrence_id ?? void 0 : void 0;
93
96
  if (a === "pauseRecurrence" || a === "resumeRecurrence") {
94
- if (!p) return;
97
+ if (!f) return;
95
98
  let n = a === "pauseRecurrence";
96
- (n ? q : _e)({
97
- path: { recurrence_id: p },
98
- receivableId: o.id
99
+ (n ? q : ve)({
100
+ path: { recurrence_id: f },
101
+ receivableId: s.id
99
102
  }, {
100
- onSuccess: () => e.success(n ? y.recurrencePaused : y.recurrenceResumed),
101
- onError: (n) => e.error(t(n) ?? y.genericError)
103
+ onSuccess: () => e.success(n ? v.recurrencePaused : v.recurrenceResumed),
104
+ onError: (n) => e.error(t(n) ?? v.genericError)
102
105
  });
103
106
  return;
104
107
  }
105
108
  if (a === "cancelRecurrence") {
106
- if (!p || f?.type !== "invoice") return;
107
- L(void 0), I({
108
- ...d,
109
- recurrenceId: p,
110
- description: de(f, _, y)
109
+ if (!f || d?.type !== "invoice") return;
110
+ I(void 0), F({
111
+ ...u,
112
+ recurrenceId: f,
113
+ description: fe(d, g, v)
111
114
  });
112
115
  return;
113
116
  }
114
117
  if (a === "recordPayment") {
115
- f?.type === "invoice" && K(f);
118
+ d?.type === "invoice" && K(d);
116
119
  return;
117
120
  }
118
- let m = a === "issue" && f?.type === "invoice" ? f : void 0;
119
- if (m && S && !ee(m, y)) {
120
- S(m, "issue");
121
+ let p = a === "issue" && d?.type === "invoice" ? d : void 0;
122
+ if (p && x && !o(p, v)) {
123
+ x(p, "issue");
121
124
  return;
122
125
  }
123
126
  if (a === "issue") {
124
- ve({
125
- id: o.id,
126
- issueCheck: m ? v(m) : void 0
127
+ ye({
128
+ id: s.id,
129
+ issueCheck: p ? _(p) : void 0
127
130
  });
128
131
  return;
129
132
  }
130
- L(void 0), z(""), I(d);
133
+ I(void 0), R(""), F(u);
131
134
  }, [
132
- ge,
135
+ _e,
133
136
  Z,
137
+ v,
138
+ x,
134
139
  y,
135
140
  S,
136
- b,
137
- C,
138
141
  K,
139
142
  Q.counterpart,
140
143
  Q.isLoading,
141
144
  Q.isTaxIdMissing,
142
145
  q,
143
- _e,
146
+ ve,
144
147
  i,
145
- _
146
- ]), be = h(() => {
147
- I(void 0), L(void 0);
148
- }, []), $ = h(() => {
149
- V(void 0), W({});
150
- }, []), xe = h(async () => {
151
- if (!F) return;
152
- let n = { receivable_id: F.id };
153
- if (F.action === "cancelRecurrence") {
154
- if (!F.recurrenceId) return;
148
+ g
149
+ ]), xe = m(() => {
150
+ F(void 0), I(void 0);
151
+ }, []), $ = m(() => {
152
+ B(void 0), U({});
153
+ }, []), Se = m(async () => {
154
+ if (!P) return;
155
+ let n = { receivable_id: P.id };
156
+ if (P.action === "cancelRecurrence") {
157
+ if (!P.recurrenceId) return;
155
158
  try {
156
- await P.mutateAsync({
157
- path: { recurrence_id: F.recurrenceId },
158
- receivableId: F.id
159
- }), e.success(y.recurrenceCanceled), I(void 0);
159
+ await N.mutateAsync({
160
+ path: { recurrence_id: P.recurrenceId },
161
+ receivableId: P.id
162
+ }), e.success(v.recurrenceCanceled), F(void 0);
160
163
  } catch (n) {
161
- e.error(t(n) ?? y.genericError);
164
+ e.error(t(n) ?? v.genericError);
162
165
  }
163
166
  return;
164
167
  }
165
168
  try {
166
- F.action === "cancel" ? await T.mutateAsync({ path: n }) : F.action === "accept" ? await D.mutateAsync({ path: n }) : F.action === "decline" ? await O.mutateAsync({ path: n }) : F.action === "delete" ? (await k.mutateAsync({ path: n }), x?.(F.id)) : F.action === "markPaid" ? await j.mutateAsync({
169
+ P.action === "cancel" ? await w.mutateAsync({ path: n }) : P.action === "accept" ? await E.mutateAsync({ path: n }) : P.action === "decline" ? await D.mutateAsync({ path: n }) : P.action === "delete" ? (await O.mutateAsync({ path: n }), b?.(P.id)) : P.action === "markPaid" ? await k.mutateAsync({
167
170
  path: n,
168
171
  body: { paid_at: (/* @__PURE__ */ new Date()).toISOString() }
169
- }) : F.action === "markUncollectible" && await M.mutateAsync({
172
+ }) : P.action === "markUncollectible" && await A.mutateAsync({
170
173
  path: n,
171
- body: { comment: R.trim() || void 0 }
172
- }), I(void 0), L(void 0);
174
+ body: { comment: L.trim() || void 0 }
175
+ }), F(void 0), I(void 0);
173
176
  } catch (e) {
174
- L(t(e) ?? y.genericError);
177
+ I(t(e) ?? v.genericError);
175
178
  }
176
179
  }, [
177
- D,
178
- R,
179
- F,
180
- T,
180
+ E,
181
+ L,
181
182
  P,
183
+ w,
184
+ N,
185
+ D,
182
186
  O,
183
187
  k,
184
- j,
185
- y,
186
- x,
187
- M
188
- ]), Se = h(async () => {
189
- if (!B) return;
190
- let e = s(H, y);
188
+ v,
189
+ b,
190
+ A
191
+ ]), Ce = m(async () => {
192
+ if (!z) return;
193
+ let e = c(V, v);
191
194
  if (a(e)) {
192
- W(e);
195
+ U(e);
193
196
  return;
194
197
  }
195
198
  try {
196
- await A.mutateAsync({
197
- path: { receivable_id: B.id },
199
+ await W({
200
+ path: { receivable_id: z.id },
198
201
  body: {
199
- body_text: H.body,
200
- subject_text: H.subject,
202
+ body_text: V.body,
203
+ subject_text: V.subject,
201
204
  recipients: {
202
- to: o(H.to),
203
- cc: o(H.cc),
204
- bcc: o(H.bcc)
205
+ to: s(V.to),
206
+ cc: s(V.cc),
207
+ bcc: s(V.bcc)
205
208
  }
206
209
  }
207
210
  }), $();
208
211
  } catch (e) {
209
- W({ form: t(e) ?? y.genericError });
212
+ U({ form: t(e) ?? v.genericError });
210
213
  }
211
214
  }, [
212
215
  $,
213
- y,
214
- A,
215
- B,
216
- H
216
+ v,
217
+ W,
218
+ z,
219
+ V
217
220
  ]);
218
221
  return {
219
- actionTarget: F,
220
- actionDialog: F ? fe(F, y) : void 0,
222
+ actionTarget: P,
223
+ actionDialog: P ? pe(P, v) : void 0,
221
224
  actionError: me,
222
- actionComment: F?.action === "markUncollectible" ? R : void 0,
223
- setActionComment: z,
224
- actionInProgress: w.isPending || T.isPending || D.isPending || O.isPending || k.isPending || j.isPending || M.isPending || P.isPending,
225
+ actionComment: P?.action === "markUncollectible" ? L : void 0,
226
+ setActionComment: R,
227
+ actionInProgress: C.isPending || w.isPending || E.isPending || D.isPending || O.isPending || k.isPending || A.isPending || N.isPending,
225
228
  pendingActions: [
226
- ...pe.isPending ? ["pauseRecurrence"] : [],
227
- ...N.isPending ? ["resumeRecurrence"] : [],
228
- ...E.isPending ? ["clone"] : [],
229
- ...w.isPending || Y || J && Q.isLoading ? ["issue", "issueAndSend"] : []
229
+ ...j.isPending ? ["pauseRecurrence"] : [],
230
+ ...M.isPending ? ["resumeRecurrence"] : [],
231
+ ...T.isPending ? ["clone"] : [],
232
+ ...C.isPending || Y || J && Q.isLoading ? ["issue", "issueAndSend"] : []
230
233
  ],
231
- openAction: ye,
232
- closeAction: be,
233
- confirmAction: xe,
234
- sendOpen: !!B,
235
- sendValues: H,
234
+ openAction: be,
235
+ closeAction: xe,
236
+ confirmAction: Se,
237
+ sendOpen: !!z,
238
+ sendValues: V,
236
239
  sendErrors: he,
237
- sendInProgress: A.isPending,
238
- setSendValues: U,
240
+ sendInProgress: ge,
241
+ setSendValues: H,
239
242
  closeSend: $,
240
- submitSend: Se,
243
+ submitSend: Ce,
241
244
  payment: G
242
245
  };
243
246
  }
244
- function de(e, t, n) {
247
+ function fe(e, t, n) {
245
248
  let r = (t?.iterations ?? []).filter((e) => e.status === "pending").length, a = i({
246
249
  amount: e.total_amount_with_credit_notes * r,
247
250
  currency: e.currency,
@@ -254,7 +257,7 @@ function de(e, t, n) {
254
257
  n.cancelRecurrenceIrreversible
255
258
  ].join("\n");
256
259
  }
257
- function v(e) {
260
+ function _(e) {
258
261
  return {
259
262
  counterpartId: e.counterpart_id,
260
263
  billingAddressId: e.counterpart_billing_address?.id ?? void 0,
@@ -262,7 +265,7 @@ function v(e) {
262
265
  hasReminder: l(e)
263
266
  };
264
267
  }
265
- function fe({ action: e, description: t, title: n }, r) {
268
+ function pe({ action: e, description: t, title: n }, r) {
266
269
  return e === "cancelRecurrence" ? {
267
270
  title: r.cancelRecurrenceTitle,
268
271
  description: t ?? "",
@@ -302,4 +305,4 @@ function fe({ action: e, description: t, title: n }, r) {
302
305
  };
303
306
  }
304
307
  //#endregion
305
- export { _ as useReceivableActions };
308
+ export { g as useReceivableActions };