@tesouro/embedded-components-react 0.5.201 → 0.5.202

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 (45) hide show
  1. package/dist/index.d.ts +16 -0
  2. package/dist/index.js +1 -1
  3. package/dist/lib/ReceivablesWidget.d.ts +16 -0
  4. package/dist/lib/ReceivablesWidget.js +1 -1
  5. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index.js +6 -6
  6. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index2.js +24 -18
  7. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index4.js +65 -2
  8. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index.js +1 -1
  9. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index10.js +188 -45
  10. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index11.js +30 -265
  11. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index12.js +144 -64
  12. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index13.js +47 -109
  13. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index14.js +293 -216
  14. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index15.js +75 -0
  15. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index16.js +114 -0
  16. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index17.js +237 -0
  17. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index4.js +14 -1
  18. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index5.js +28 -243
  19. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index6.js +212 -375
  20. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index7.js +64 -62
  21. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index8.js +409 -187
  22. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index9.js +73 -40
  23. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index.js +10 -9
  24. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index10.js +0 -9
  25. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index11.js +4 -1
  26. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index12.js +10 -263
  27. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index13.js +1 -72
  28. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index14.js +241 -398
  29. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index15.js +66 -100
  30. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index16.js +406 -76
  31. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index17.js +92 -330
  32. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index18.js +93 -0
  33. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index19.js +344 -0
  34. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index2.js +6 -1
  35. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index4.js +157 -20
  36. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index5.js +24 -1
  37. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index6.js +1 -3
  38. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index7.js +3 -18
  39. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index8.js +2 -0
  40. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index9.js +18 -4
  41. package/dist/libs/tesouro-embedded-components-react/shared/data-access/dist/index.js +37 -37
  42. package/dist/libs/tesouro-embedded-components-react/shared/data-access/dist/lib/rest/@tanstack/react-query.gen.js +54 -54
  43. package/dist/libs/tesouro-embedded-components-react/shared/data-access/dist/lib/rest/sdk.gen.js +115 -94
  44. package/dist/libs/tesouro-embedded-components-react/shared/feature/dist/lib/analytics/build-info.js +1 -1
  45. package/package.json +1 -1
package/dist/index.d.ts CHANGED
@@ -4935,6 +4935,11 @@ interface ReceivableFormSheetLabels {
4935
4935
  closingNoteLabel: string;
4936
4936
  closingNotePlaceholder: string;
4937
4937
  closingNoteDescription: string;
4938
+ attachmentsHeading: string;
4939
+ attachmentsDescription: string;
4940
+ attachmentsDropPrompt: string;
4941
+ attachmentsBrowseLink: string;
4942
+ attachmentsFormatsHint: string;
4938
4943
  }
4939
4944
  interface ReceivableDetailsSheetLabels {
4940
4945
  hiddenDescription: string;
@@ -5061,6 +5066,17 @@ interface ReceivableMessageLabels {
5061
5066
  markUncollectibleTitle: string;
5062
5067
  markUncollectibleDescription: string;
5063
5068
  markUncollectibleConfirm: string;
5069
+ attachmentsEmailCaption: string;
5070
+ attachmentsRecurringEmailCaption: string;
5071
+ attachmentIncludeInEmail: string;
5072
+ attachmentRemove: string;
5073
+ attachmentUploading: string;
5074
+ attachmentUploadFailed: string;
5075
+ attachmentTooLarge: string;
5076
+ attachmentUnsupportedType: string;
5077
+ attachmentsCountLimit: string;
5078
+ attachmentIncludedInEmail: string;
5079
+ attachmentNotIncludedInEmail: string;
5064
5080
  }
5065
5081
 
5066
5082
  interface ReceivablesWidgetOwnProps {
package/dist/index.js CHANGED
@@ -27,7 +27,7 @@ import { InsightsWidget as L } from "./libs/tesouro-embedded-components-react/in
27
27
  import { UploadReceiptWidget as R } from "./libs/tesouro-embedded-components-react/expense-management-widget/feature/dist/index2.js";
28
28
  import { ExpenseManagementWidget as z } from "./libs/tesouro-embedded-components-react/expense-management-widget/feature/dist/index21.js";
29
29
  import { InvoicingWidget as B } from "./libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index3.js";
30
- import { ReceivablesWidget as V } from "./libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index14.js";
30
+ import { ReceivablesWidget as V } from "./libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index17.js";
31
31
  import { SettingsSection as H } from "./libs/tesouro-embedded-components-react/settings-widget/feature/dist/index4.js";
32
32
  import { HELP_FAQ_EN as U } from "./libs/tesouro-embedded-components-react/settings-widget/help/ui/contract/dist/index3.js";
33
33
  import { SettingsWidget as W } from "./libs/tesouro-embedded-components-react/settings-widget/feature/dist/index6.js";
@@ -979,6 +979,11 @@ interface ReceivableFormSheetLabels {
979
979
  closingNoteLabel: string;
980
980
  closingNotePlaceholder: string;
981
981
  closingNoteDescription: string;
982
+ attachmentsHeading: string;
983
+ attachmentsDescription: string;
984
+ attachmentsDropPrompt: string;
985
+ attachmentsBrowseLink: string;
986
+ attachmentsFormatsHint: string;
982
987
  }
983
988
  interface ReceivableDetailsSheetLabels {
984
989
  hiddenDescription: string;
@@ -1105,6 +1110,17 @@ interface ReceivableMessageLabels {
1105
1110
  markUncollectibleTitle: string;
1106
1111
  markUncollectibleDescription: string;
1107
1112
  markUncollectibleConfirm: string;
1113
+ attachmentsEmailCaption: string;
1114
+ attachmentsRecurringEmailCaption: string;
1115
+ attachmentIncludeInEmail: string;
1116
+ attachmentRemove: string;
1117
+ attachmentUploading: string;
1118
+ attachmentUploadFailed: string;
1119
+ attachmentTooLarge: string;
1120
+ attachmentUnsupportedType: string;
1121
+ attachmentsCountLimit: string;
1122
+ attachmentIncludedInEmail: string;
1123
+ attachmentNotIncludedInEmail: string;
1108
1124
  }
1109
1125
 
1110
1126
  interface ReceivablesWidgetOwnProps {
@@ -1,3 +1,3 @@
1
- import { ReceivablesWidget as e } from "../libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index14.js";
1
+ import { ReceivablesWidget as e } from "../libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index17.js";
2
2
  import "../libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index.js";
3
3
  export { e as ReceivablesWidget };
@@ -2,12 +2,12 @@ import { usePaymentTermsQuery as e } from "../../../shared/data-access/dist/lib/
2
2
  import "../../../shared/data-access/dist/index.js";
3
3
  import "./index2.js";
4
4
  import "./index3.js";
5
- import "./index4.js";
6
- import { useSendReceivableEmailMutation as t } from "./index5.js";
7
- import { useAcceptReceivableMutation as n, useCancelReceivableMutation as r, useCloneReceivableMutation as i, useCreateReceivableMutation as a, useDeclineReceivableMutation as o, useDeleteReceivableMutation as s, useIssueReceivableMutation as c, useUpdateReceivableMutation as l } from "./index6.js";
5
+ import { useDeleteReceivableAttachmentMutation as t, useUploadReceivableAttachmentMutation as n } from "./index4.js";
6
+ import { useSendReceivableEmailMutation as r } from "./index5.js";
7
+ import { useAcceptReceivableMutation as i, useCancelReceivableMutation as a, useCloneReceivableMutation as o, useCreateReceivableMutation as s, useDeclineReceivableMutation as c, useDeleteReceivableMutation as l, useIssueReceivableMutation as u, useUpdateReceivableMutation as d } from "./index6.js";
8
8
  import "./index7.js";
9
- import { useMarkReceivablePaidMutation as u, useMarkReceivablePartiallyPaidMutation as d, useMarkReceivableUncollectibleMutation as f } from "./index8.js";
10
- import { useReceivableHistoryQuery as p, useReceivableMailsQuery as m, useReceivablePdfLinkQuery as h, useReceivableQuery as g, useReceivablesQuery as _ } from "./index9.js";
9
+ import { useMarkReceivablePaidMutation as f, useMarkReceivablePartiallyPaidMutation as p, useMarkReceivableUncollectibleMutation as m } from "./index8.js";
10
+ import { useReceivableHistoryQuery as h, useReceivableMailsQuery as g, useReceivablePdfLinkQuery as _, useReceivableQuery as v, useReceivablesQuery as y } from "./index9.js";
11
11
  import "./index10.js";
12
12
  import "./index11.js";
13
- export { n as useAcceptReceivableMutation, r as useCancelReceivableMutation, i as useCloneReceivableMutation, a as useCreateReceivableMutation, o as useDeclineReceivableMutation, s as useDeleteReceivableMutation, c as useIssueReceivableMutation, u as useMarkReceivablePaidMutation, d as useMarkReceivablePartiallyPaidMutation, f as useMarkReceivableUncollectibleMutation, e as usePaymentTermsQuery, p as useReceivableHistoryQuery, m as useReceivableMailsQuery, h as useReceivablePdfLinkQuery, g as useReceivableQuery, _ as useReceivablesQuery, t as useSendReceivableEmailMutation, l as useUpdateReceivableMutation };
13
+ export { i as useAcceptReceivableMutation, a as useCancelReceivableMutation, o as useCloneReceivableMutation, s as useCreateReceivableMutation, c as useDeclineReceivableMutation, t as useDeleteReceivableAttachmentMutation, l as useDeleteReceivableMutation, u as useIssueReceivableMutation, f as useMarkReceivablePaidMutation, p as useMarkReceivablePartiallyPaidMutation, m as useMarkReceivableUncollectibleMutation, e as usePaymentTermsQuery, h as useReceivableHistoryQuery, g as useReceivableMailsQuery, _ as useReceivablePdfLinkQuery, v as useReceivableQuery, y as useReceivablesQuery, r as useSendReceivableEmailMutation, d as useUpdateReceivableMutation, n as useUploadReceivableAttachmentMutation };
@@ -1,42 +1,48 @@
1
- import { getAnalyticsReceivablesQueryKey as e, getPaymentRecordsQueryKey as t, getReceivablesIdHistoryQueryKey as n, getReceivablesIdMailsQueryKey as r, getReceivablesIdPdfLinkQueryKey as i, getReceivablesIdQueryKey as a, getReceivablesQueryKey as o } from "../../../shared/data-access/dist/lib/rest/@tanstack/react-query.gen.js";
2
- import { organizationHeaders as s } from "../../../shared/data-access/dist/lib/organizationHeaders.js";
1
+ import { getAnalyticsReceivablesQueryKey as e, getFilesQueryKey as t, getPaymentRecordsQueryKey as n, getReceivablesIdHistoryQueryKey as r, getReceivablesIdMailsQueryKey as i, getReceivablesIdPdfLinkQueryKey as a, getReceivablesIdQueryKey as o, getReceivablesQueryKey as s } from "../../../shared/data-access/dist/lib/rest/@tanstack/react-query.gen.js";
2
+ import { organizationHeaders as c } from "../../../shared/data-access/dist/lib/organizationHeaders.js";
3
3
  import "../../../shared/data-access/dist/index.js";
4
4
  //#region ../../libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index2.js
5
- var c = ({ client: e, organizationId: t }) => {
6
- let [n] = o({
5
+ var l = ({ client: e, organizationId: t }) => {
6
+ let [n] = s({
7
7
  client: e,
8
- headers: s(t)
8
+ headers: c(t)
9
9
  }), r = { ...n };
10
10
  return delete r.query, [r];
11
- }, l = ({ client: e, organizationId: t, receivableId: n }) => a({
11
+ }, u = ({ client: e, organizationId: t, receivableId: n }) => o({
12
12
  client: e,
13
- headers: s(t),
13
+ headers: c(t),
14
14
  path: { receivable_id: n }
15
- }), u = ({ client: e, organizationId: t, receivableId: r }) => n({
16
- client: e,
17
- headers: s(t),
18
- path: { receivable_id: r }
19
15
  }), d = ({ client: e, organizationId: t, receivableId: n }) => r({
20
16
  client: e,
21
- headers: s(t),
17
+ headers: c(t),
22
18
  path: { receivable_id: n }
23
19
  }), f = ({ client: e, organizationId: t, receivableId: n }) => i({
24
20
  client: e,
25
- headers: s(t),
21
+ headers: c(t),
22
+ path: { receivable_id: n }
23
+ }), p = ({ client: e, organizationId: t, receivableId: n }) => a({
24
+ client: e,
25
+ headers: c(t),
26
26
  path: { receivable_id: n }
27
- }), p = ({ client: e, organizationId: n }) => {
27
+ }), m = ({ client: e, organizationId: n }) => {
28
28
  let [r] = t({
29
29
  client: e,
30
- headers: s(n)
30
+ headers: c(n)
31
+ }), i = { ...r };
32
+ return delete i.query, [i];
33
+ }, h = ({ client: e, organizationId: t }) => {
34
+ let [r] = n({
35
+ client: e,
36
+ headers: c(t)
31
37
  }), i = { ...r };
32
38
  return delete i.query, [i];
33
- }, m = ({ client: t, organizationId: n }) => {
39
+ }, g = ({ client: t, organizationId: n }) => {
34
40
  let [r] = e({
35
41
  client: t,
36
- headers: s(n),
42
+ headers: c(n),
37
43
  query: {}
38
44
  }), i = { ...r };
39
45
  return delete i.query, [i];
40
46
  };
41
47
  //#endregion
42
- export { p as paymentRecordsInvalidationKey, u as receivableHistoryInvalidationKey, l as receivableInvalidationKey, d as receivableMailsInvalidationKey, f as receivablePdfInvalidationKey, m as receivablesAnalyticsInvalidationKey, c as receivablesInvalidationKey };
48
+ export { h as paymentRecordsInvalidationKey, m as receivableAttachmentsInvalidationKey, d as receivableHistoryInvalidationKey, u as receivableInvalidationKey, f as receivableMailsInvalidationKey, p as receivablePdfInvalidationKey, g as receivablesAnalyticsInvalidationKey, l as receivablesInvalidationKey };
@@ -2,6 +2,69 @@
2
2
  "use client";
3
3
  "use client";
4
4
  "use client";
5
+ import { deleteFilesId as e, postFiles as t } from "../../../shared/data-access/dist/lib/rest/sdk.gen.js";
6
+ import { invalidateAllClients as n } from "../../../shared/data-access/dist/lib/clientRegistry.js";
7
+ import { useEmbedApi as r } from "../../../shared/data-access/dist/lib/EmbedApiContext.js";
8
+ import { organizationHeaders as i } from "../../../shared/data-access/dist/lib/organizationHeaders.js";
5
9
  import "../../../shared/data-access/dist/index.js";
6
- import "./index2.js";
7
- import "@tanstack/react-query";
10
+ import { receivableAttachmentsInvalidationKey as a, receivableInvalidationKey as o } from "./index2.js";
11
+ import { useMutation as s } from "@tanstack/react-query";
12
+ //#region ../../libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index4.js
13
+ var c = "attachments";
14
+ async function l({ client: e, organizationId: t, receivableId: r }) {
15
+ let i = [a({
16
+ client: e,
17
+ organizationId: t
18
+ }), ...r ? [o({
19
+ client: e,
20
+ organizationId: t,
21
+ receivableId: r
22
+ })] : []];
23
+ await Promise.all(i.map((e) => n(e)));
24
+ }
25
+ function u() {
26
+ let { client: e, organizationId: n } = r();
27
+ return s({
28
+ mutationFn: async ({ file: r }) => {
29
+ let { data: a } = await t({
30
+ client: e,
31
+ headers: i(n),
32
+ body: {
33
+ file: r,
34
+ file_type: c
35
+ },
36
+ throwOnError: !0
37
+ });
38
+ return a;
39
+ },
40
+ onSuccess: async (t, r) => {
41
+ await l({
42
+ client: e,
43
+ organizationId: n,
44
+ receivableId: r.receivableId
45
+ });
46
+ }
47
+ });
48
+ }
49
+ function d() {
50
+ let { client: t, organizationId: n } = r();
51
+ return s({
52
+ mutationFn: async ({ path: r }) => {
53
+ await e({
54
+ client: t,
55
+ headers: i(n),
56
+ path: r,
57
+ throwOnError: !0
58
+ });
59
+ },
60
+ onSuccess: async (e, r) => {
61
+ await l({
62
+ client: t,
63
+ organizationId: n,
64
+ receivableId: r.receivableId
65
+ });
66
+ }
67
+ });
68
+ }
69
+ //#endregion
70
+ export { d as useDeleteReceivableAttachmentMutation, u as useUploadReceivableAttachmentMutation };
@@ -1,3 +1,3 @@
1
1
  import { InvoicingWidget as e } from "./index3.js";
2
- import { ReceivablesWidget as t } from "./index14.js";
2
+ import { ReceivablesWidget as t } from "./index17.js";
3
3
  export { e as InvoicingWidget, t as ReceivablesWidget };
@@ -1,52 +1,195 @@
1
- import { parseQuantity as e, priceInputToMinorUnits as t } from "./index5.js";
1
+ "use client";
2
+ "use client";
3
+ "use client";
4
+ "use client";
5
+ import { extractApiErrorMessage as e } from "../../../shared/util/dist/lib/apiErrors.js";
6
+ import { defaultPaymentValues as t, defaultSendValues as n, fromMajorUnits as r, hasPaymentErrors as i, hasSendErrors as a, splitEmailList as o, validatePaymentValues as s, validateSendValues as c } from "./index8.js";
7
+ import { useSendReceivableEmailMutation as l } from "../../data-access/dist/index5.js";
8
+ import { useAcceptReceivableMutation as ee, useCancelReceivableMutation as te, useCloneReceivableMutation as u, useDeclineReceivableMutation as d, useDeleteReceivableMutation as f, useIssueReceivableMutation as p } from "../../data-access/dist/index6.js";
9
+ import { useMarkReceivablePaidMutation as m, useMarkReceivablePartiallyPaidMutation as h, useMarkReceivableUncollectibleMutation as g } from "../../data-access/dist/index8.js";
10
+ import "../../data-access/dist/index.js";
11
+ import { useCallback as _, useState as v } from "react";
2
12
  //#region ../../libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index10.js
3
- var n = 1e4;
4
- function r({ lineItems: n, currency: r, taxRate: i }) {
5
- let a = i ? i / 100 : 0, o = 0, s = 0;
6
- for (let i of n) {
7
- let n = Math.round(t(i.price, r) * e(i.quantity));
8
- i.taxable ? o += n : s += n;
9
- }
13
+ function y({ selectedReceivable: y, messages: x, onCreated: S, onDeleted: C }) {
14
+ let w = p(), T = te(), E = u(), D = ee(), O = d(), k = f(), A = l(), j = m(), M = h(), N = g(), [P, F] = v(), [I, L] = v(), [R, z] = v(), [B, V] = v(() => n(void 0, x)), [H, U] = v({}), [W, G] = v(), [K, q] = v(() => t()), [J, Y] = v({}), X = _((e, r, i) => {
15
+ let a = "documentLabel" in r ? r.documentLabel : r.title, o = {
16
+ id: r.id,
17
+ type: r.type,
18
+ title: a,
19
+ action: e
20
+ }, s = i === void 0 ? y : i ?? void 0;
21
+ if (e === "send") {
22
+ z(o), V(n(s, x)), U({});
23
+ return;
24
+ }
25
+ if (e === "recordPayment") {
26
+ G({
27
+ ...o,
28
+ currency: s?.currency
29
+ }), q(t()), Y({});
30
+ return;
31
+ }
32
+ L(void 0), F(o);
33
+ }, [x, y]), Z = _(() => {
34
+ F(void 0), L(void 0);
35
+ }, []), Q = _(() => {
36
+ z(void 0), U({});
37
+ }, []), $ = _(() => {
38
+ G(void 0), Y({});
39
+ }, []), ne = _(async () => {
40
+ if (!P) return;
41
+ let t = { receivable_id: P.id };
42
+ try {
43
+ if (P.action === "issue") await w.mutateAsync({ path: t });
44
+ else if (P.action === "cancel") await T.mutateAsync({ path: t });
45
+ else if (P.action === "clone") {
46
+ let e = await E.mutateAsync({ path: t });
47
+ e?.id && S?.(e.id, e.type);
48
+ } else P.action === "accept" ? await D.mutateAsync({ path: t }) : P.action === "decline" ? await O.mutateAsync({ path: t }) : P.action === "delete" ? (await k.mutateAsync({ path: t }), C?.(P.id)) : P.action === "markPaid" ? await j.mutateAsync({
49
+ path: t,
50
+ body: { paid_at: (/* @__PURE__ */ new Date()).toISOString() }
51
+ }) : P.action === "markUncollectible" && await N.mutateAsync({ path: t });
52
+ F(void 0), L(void 0);
53
+ } catch (t) {
54
+ L(e(t) ?? x.genericError);
55
+ }
56
+ }, [
57
+ D,
58
+ P,
59
+ T,
60
+ E,
61
+ O,
62
+ k,
63
+ w,
64
+ j,
65
+ x.genericError,
66
+ S,
67
+ C,
68
+ N
69
+ ]), re = _(async () => {
70
+ if (!R) return;
71
+ let t = c(B, x);
72
+ if (a(t)) {
73
+ U(t);
74
+ return;
75
+ }
76
+ try {
77
+ await A.mutateAsync({
78
+ path: { receivable_id: R.id },
79
+ body: {
80
+ body_text: B.body,
81
+ subject_text: B.subject,
82
+ recipients: {
83
+ to: o(B.to),
84
+ cc: o(B.cc),
85
+ bcc: o(B.bcc)
86
+ }
87
+ }
88
+ }), Q();
89
+ } catch (t) {
90
+ U({ form: e(t) ?? x.genericError });
91
+ }
92
+ }, [
93
+ Q,
94
+ x,
95
+ A,
96
+ R,
97
+ B
98
+ ]), ie = _(async () => {
99
+ if (!W) return;
100
+ let t = s(K, x, W.currency);
101
+ if (i(t)) {
102
+ Y(t);
103
+ return;
104
+ }
105
+ try {
106
+ let e = { receivable_id: W.id }, t = K.paidAt ? new Date(K.paidAt).toISOString() : void 0;
107
+ K.mode === "full" ? await j.mutateAsync({
108
+ path: e,
109
+ body: {
110
+ comment: K.comment || void 0,
111
+ paid_at: t
112
+ }
113
+ }) : await M.mutateAsync({
114
+ path: e,
115
+ body: {
116
+ amount_paid: r(K.amountPaid, W.currency) ?? 0,
117
+ comment: K.comment || void 0
118
+ }
119
+ }), $();
120
+ } catch (t) {
121
+ Y({ form: e(t) ?? x.genericError });
122
+ }
123
+ }, [
124
+ $,
125
+ j,
126
+ x,
127
+ M,
128
+ W,
129
+ K
130
+ ]);
10
131
  return {
11
- taxableItemsSubtotal: o,
12
- nonTaxableItemsSubtotal: s,
13
- subtotal: o + s,
14
- rate: a
132
+ actionTarget: P,
133
+ actionDialog: P ? b(P.action, x) : void 0,
134
+ actionError: I,
135
+ actionInProgress: w.isPending || T.isPending || E.isPending || D.isPending || O.isPending || k.isPending || j.isPending || N.isPending,
136
+ openAction: X,
137
+ closeAction: Z,
138
+ confirmAction: ne,
139
+ sendOpen: !!R,
140
+ sendValues: B,
141
+ sendErrors: H,
142
+ sendInProgress: A.isPending,
143
+ setSendValues: V,
144
+ closeSend: Q,
145
+ submitSend: re,
146
+ paymentOpen: !!W,
147
+ paymentValues: K,
148
+ paymentErrors: J,
149
+ paymentInProgress: j.isPending || M.isPending,
150
+ setPaymentValues: q,
151
+ closePayment: $,
152
+ submitPayment: ie
15
153
  };
16
154
  }
17
- function i({ discount: e, subtotal: t }) {
18
- if (!e) return 0;
19
- let r = e.value ?? (e.type === "amount" ? e.amount : Math.round(t * e.amount / n));
20
- return Math.min(Math.max(r, 0), t);
21
- }
22
- function a({ taxableItemsSubtotal: e, nonTaxableItemsSubtotal: t, discountAmount: n }) {
23
- let r = e + t, i = r > 0 ? Math.round(e / r * n) : 0;
24
- return {
25
- taxableSubtotal: e - i,
26
- nonTaxableSubtotal: t - (n - i)
27
- };
28
- }
29
- function o({ lineItems: e, currency: t, taxRate: n, discount: o }) {
30
- let s = r({
31
- lineItems: e,
32
- currency: t,
33
- taxRate: n
34
- }), c = i({
35
- discount: o,
36
- subtotal: s.subtotal
37
- }), { taxableSubtotal: l, nonTaxableSubtotal: u } = a({
38
- ...s,
39
- discountAmount: c
40
- }), d = s.rate ? Math.round(l * s.rate) : 0, f = s.subtotal - c;
41
- return {
42
- ...s,
43
- discountAmount: c,
44
- discountedSubtotal: f,
45
- taxableSubtotal: l,
46
- nonTaxableSubtotal: u,
47
- totalTaxes: d,
48
- total: f + d
155
+ function b(e, t) {
156
+ return e === "issue" ? {
157
+ title: t.issueTitle,
158
+ description: t.issueDescription,
159
+ confirmLabel: t.issueConfirm
160
+ } : e === "accept" ? {
161
+ title: t.acceptTitle,
162
+ description: t.acceptDescription,
163
+ confirmLabel: t.acceptConfirm
164
+ } : e === "decline" ? {
165
+ title: t.declineTitle,
166
+ description: t.declineDescription,
167
+ confirmLabel: t.declineConfirm,
168
+ destructive: !0
169
+ } : e === "cancel" ? {
170
+ title: t.cancelTitle,
171
+ description: t.cancelDescription,
172
+ confirmLabel: t.cancelConfirm,
173
+ destructive: !0
174
+ } : e === "clone" ? {
175
+ title: t.cloneTitle,
176
+ description: t.cloneDescription,
177
+ confirmLabel: t.cloneConfirm
178
+ } : e === "delete" ? {
179
+ title: t.deleteTitle,
180
+ description: t.deleteDescription,
181
+ confirmLabel: t.deleteConfirm,
182
+ destructive: !0
183
+ } : e === "markPaid" ? {
184
+ title: t.markPaidTitle,
185
+ description: t.markPaidDescription,
186
+ confirmLabel: t.markPaidConfirm
187
+ } : {
188
+ title: t.markUncollectibleTitle,
189
+ description: t.markUncollectibleDescription,
190
+ confirmLabel: t.markUncollectibleConfirm,
191
+ destructive: !0
49
192
  };
50
193
  }
51
194
  //#endregion
52
- export { a as allocateDiscount, o as calculateInvoiceTotals, r as calculateItemsSubtotals, i as resolveDiscountAmount };
195
+ export { y as useReceivableActions };