@tesouro/embedded-components-react 0.5.205 → 0.5.207

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 (59) hide show
  1. package/README.md +1 -1
  2. package/dist/index.d.ts +51 -4
  3. package/dist/index.js +1 -1
  4. package/dist/lib/ReceivablesWidget.d.ts +51 -4
  5. package/dist/lib/ReceivablesWidget.js +1 -1
  6. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index.js +2 -2
  7. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index10.js +84 -2
  8. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index2.js +31 -25
  9. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index.js +1 -1
  10. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index10.js +109 -193
  11. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index11.js +154 -37
  12. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index12.js +193 -135
  13. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index13.js +37 -58
  14. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index14.js +140 -86
  15. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index15.js +42 -47
  16. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index16.js +58 -313
  17. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index17.js +91 -65
  18. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index18.js +108 -102
  19. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index19.js +48 -249
  20. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index20.js +365 -0
  21. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index21.js +75 -0
  22. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index22.js +115 -0
  23. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index23.js +285 -0
  24. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index5.js +1 -1
  25. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index8.js +93 -407
  26. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index9.js +430 -86
  27. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index.js +17 -12
  28. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index10.js +92 -16
  29. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index11.js +3 -1
  30. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index12.js +24 -4
  31. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index13.js +0 -10
  32. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index14.js +2 -0
  33. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index15.js +3 -264
  34. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index16.js +16 -70
  35. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index17.js +1 -424
  36. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index18.js +4 -106
  37. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index19.js +12 -93
  38. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index2.js +5 -179
  39. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index20.js +1 -344
  40. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index21.js +264 -0
  41. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index22.js +72 -0
  42. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index23.js +402 -0
  43. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index24.js +106 -0
  44. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index25.js +249 -0
  45. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index26.js +93 -0
  46. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index27.js +344 -0
  47. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index3.js +195 -32
  48. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index4.js +29 -202
  49. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index5.js +183 -137
  50. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index6.js +157 -20
  51. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index7.js +16 -1
  52. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index8.js +25 -3
  53. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index9.js +4 -3
  54. package/dist/libs/tesouro-embedded-components-react/shared/counterpart-management/feature/dist/index.js +11 -11
  55. package/dist/libs/tesouro-embedded-components-react/shared/data-access/dist/index.js +38 -38
  56. package/dist/libs/tesouro-embedded-components-react/shared/data-access/dist/lib/rest/@tanstack/react-query.gen.js +220 -198
  57. package/dist/libs/tesouro-embedded-components-react/shared/data-access/dist/lib/rest/sdk.gen.js +124 -84
  58. package/dist/libs/tesouro-embedded-components-react/shared/feature/dist/lib/analytics/build-info.js +1 -1
  59. package/package.json +1 -1
@@ -2,100 +2,154 @@
2
2
  "use client";
3
3
  "use client";
4
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 "../../../shared/ui/dist/index.js";
8
- import { useWidgetConfig as n } from "../../../shared/feature/dist/lib/WidgetProvider/hooks.js";
9
- import "../../../shared/feature/dist/index.js";
10
- import { useCreateEntityBankAccountMutation as r, usePaymentAccountsQuery as i } from "../../data-access/dist/index3.js";
5
+ import { toFileArray as e, validateAttachmentFile as t } from "./index7.js";
6
+ import { useDeleteReceivableAttachmentMutation as n, useUploadReceivableAttachmentMutation as r } from "../../data-access/dist/index4.js";
11
7
  import "../../data-access/dist/index.js";
12
- import { EMPTY_BANK_ACCOUNT_FORM_VALUES as a, bankAccountFormToPayload as o, buildBankAccountSectionView as s, buildPaymentAccountOptions as c, getBankAccountPermissions as l, validateBankAccountForm as u } from "./index13.js";
13
- import { useCallback as d, useEffect as f, useMemo as p, useRef as m, useState as h } from "react";
8
+ import { useCallback as i, useEffect as a, useRef as o, useState as s } from "react";
14
9
  //#region ../../libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index14.js
15
- function g({ open: g, bankAccountId: _, embeddedBankName: v, messages: y, onSelect: b }) {
16
- let { initResponse: x } = n(), S = p(() => l(x?.scopes), [x?.scopes]), { paymentAccounts: C, isLoading: w, isIncomplete: T } = i({
17
- enabled: g,
18
- canReadEmbedded: S.canReadEmbedded,
19
- canReadExternal: S.canReadExternal
20
- }), E = r(), [D, O] = h(!1), [k, A] = h(a), [j, M] = h({}), N = m(!1), P = d(() => {
21
- N.current = !1, O(!1), A(a), M({});
10
+ function c({ attachments: c, setAttachments: l, receivableId: u }) {
11
+ let { mutateAsync: d } = r(), { mutate: f } = n(), [p, m] = s([]), [h, g] = s(!1), _ = o(0), v = o(/* @__PURE__ */ new Set()), y = o(/* @__PURE__ */ new Set()), b = o(/* @__PURE__ */ new Set()), x = o(0), S = o(!1), C = o({
12
+ deleteFile: f,
13
+ receivableId: u
14
+ });
15
+ a(() => {
16
+ C.current = {
17
+ deleteFile: f,
18
+ receivableId: u
19
+ };
20
+ }, [f, u]), a(() => {
21
+ S.current = !1;
22
+ let e = y.current;
23
+ return () => {
24
+ S.current = !0;
25
+ let { deleteFile: t, receivableId: n } = C.current;
26
+ for (let r of e) t({
27
+ path: { file_id: r },
28
+ receivableId: n
29
+ });
30
+ e.clear();
31
+ };
22
32
  }, []);
23
- f(() => {
24
- if (!g || T || N.current || C.length !== 1) return;
25
- let [e] = C;
26
- N.current = !0, b({
27
- bankAccountId: e.id,
28
- bankAccountType: e.type
33
+ let w = i(async (e, t) => {
34
+ let n = x.current, r = () => S.current || x.current !== n;
35
+ try {
36
+ let n = await d({
37
+ file: t,
38
+ receivableId: u
39
+ });
40
+ if (r() || v.current.delete(e)) {
41
+ f({
42
+ path: { file_id: n.id },
43
+ receivableId: u
44
+ });
45
+ return;
46
+ }
47
+ y.current.add(n.id), m((t) => t.filter((t) => t.id !== e)), l((e) => [...e, {
48
+ id: n.id,
49
+ includeInEmail: !0,
50
+ name: n.name,
51
+ size: n.size
52
+ }]);
53
+ } catch {
54
+ let t = v.current.delete(e);
55
+ if (r() || t) return;
56
+ m((t) => t.map((t) => t.id === e ? {
57
+ ...t,
58
+ status: "upload_failed"
59
+ } : t));
60
+ }
61
+ }, [
62
+ f,
63
+ u,
64
+ l,
65
+ d
66
+ ]), T = i((n) => {
67
+ let r = e(n);
68
+ if (r.length === 0) return;
69
+ let i = p.filter((e) => e.status === "uploading").length, a = 10 - c.length - i, o = [], s = !1;
70
+ for (let e of r) {
71
+ _.current += 1;
72
+ let n = `pending-attachment-${_.current}`, r = t(e);
73
+ if (r) {
74
+ o.push({
75
+ id: n,
76
+ name: e.name,
77
+ status: r
78
+ });
79
+ continue;
80
+ }
81
+ if (a <= 0) {
82
+ s = !0;
83
+ continue;
84
+ }
85
+ --a, o.push({
86
+ id: n,
87
+ name: e.name,
88
+ status: "uploading"
89
+ }), w(n, e);
90
+ }
91
+ o.length > 0 && m((e) => [...e, ...o]), g(s);
92
+ }, [
93
+ c.length,
94
+ p,
95
+ w
96
+ ]), E = i((e, t) => {
97
+ l((n) => n.map((n) => n.id === e ? {
98
+ ...n,
99
+ includeInEmail: t
100
+ } : n));
101
+ }, [l]), D = i((e) => {
102
+ g(!1);
103
+ let t = p.find((t) => t.id === e);
104
+ if (t) {
105
+ t.status === "uploading" && v.current.add(e), m((t) => t.filter((t) => t.id !== e));
106
+ return;
107
+ }
108
+ if (l((t) => t.filter((t) => t.id !== e)), !y.current.delete(e)) {
109
+ b.current.add(e);
110
+ return;
111
+ }
112
+ f({
113
+ path: { file_id: e },
114
+ receivableId: u
29
115
  });
30
116
  }, [
31
- T,
32
- b,
33
- g,
34
- C
35
- ]);
36
- let F = d((e) => {
37
- let t = C.find((t) => t.id === e);
38
- t && b({
39
- bankAccountId: t.id,
40
- bankAccountType: t.type
117
+ f,
118
+ p,
119
+ u,
120
+ l
121
+ ]), O = i(() => {
122
+ x.current += 1, v.current.clear(), y.current.clear(), b.current.clear(), m([]), g(!1);
123
+ }, []), k = i(() => {
124
+ let e = new Set(y.current);
125
+ for (let t of e) f({
126
+ path: { file_id: t },
127
+ receivableId: u
41
128
  });
42
- }, [b, C]), I = d(() => O(!0), []), L = d(() => {
43
- O(!1), A(a), M({});
44
- }, []), R = d((e) => A((t) => ({
45
- ...t,
46
- ...e
47
- })), []), z = d(async () => {
48
- let n = u(k, y);
49
- if (M(n), !(Object.keys(n).length > 0)) try {
50
- let t = await E.mutateAsync({ body: o(k) });
51
- O(!1), A(a), b({
52
- bankAccountId: t.id,
53
- bankAccountType: "BANK_DETAILS"
54
- }), e.success(y.bankAccountCreated.replace("{name}", t.display_name ?? ""));
55
- } catch (n) {
56
- e.error(t(n) ?? y.bankAccountCreateFailed);
57
- }
129
+ l((t) => t.filter(({ id: t }) => !e.has(t))), O();
58
130
  }, [
59
- E,
60
- k,
61
- y,
62
- b
63
- ]), B = p(() => c({
64
- accounts: C,
65
- embeddedBankName: v,
66
- messages: y
67
- }), [
68
- v,
69
- y,
70
- C
71
- ]);
131
+ f,
132
+ u,
133
+ O,
134
+ l
135
+ ]), A = i(() => {
136
+ for (let e of b.current) f({
137
+ path: { file_id: e },
138
+ receivableId: u
139
+ });
140
+ b.current.clear();
141
+ }, [f, u]);
72
142
  return {
73
- view: p(() => s({
74
- options: B,
75
- isLoading: w,
76
- selectedId: _,
77
- isAddingAccount: D,
78
- canAddAccount: S.canAddAccount,
79
- formValues: k,
80
- formErrors: j,
81
- isSaving: E.isPending
82
- }), [
83
- _,
84
- E.isPending,
85
- j,
86
- k,
87
- D,
88
- w,
89
- B,
90
- S.canAddAccount
91
- ]),
92
- reset: P,
93
- selectAccount: F,
94
- openAddAccount: I,
95
- cancelAddAccount: L,
96
- updateAccountForm: R,
97
- saveAccount: z
143
+ pendingUploads: p,
144
+ isUploading: p.some((e) => e.status === "uploading"),
145
+ isCountLimitReached: h,
146
+ selectFiles: T,
147
+ setIncludeInEmail: E,
148
+ remove: D,
149
+ reset: O,
150
+ discardUploads: k,
151
+ commitRemovals: A
98
152
  };
99
153
  }
100
154
  //#endregion
101
- export { g as useReceivableBankAccount };
155
+ export { c as useReceivableAttachmentUploads };
@@ -1,52 +1,47 @@
1
- import { parseQuantity as e, priceInputToMinorUnits as t } from "./index6.js";
1
+ "use client";
2
+ "use client";
3
+ "use client";
4
+ "use client";
5
+ import { usePaymentTermsQuery as e } from "../../../shared/data-access/dist/lib/reference-data/usePaymentTermsQuery.js";
6
+ import { buildCustomDateCalendar as t, buildPaymentTermsView as n, closeCustomDatePickerFields as r, selectPaymentTermsFields as i, toCustomDateValue as a } from "./index8.js";
7
+ import "../../data-access/dist/index.js";
8
+ import { useCallback as o, useMemo as s, useState as c } from "react";
2
9
  //#region ../../libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index15.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
- }
10
+ function l({ paymentTermsId: l, paymentTermsCustomDate: u, messages: d, onChange: f }) {
11
+ let p = e(), [m, h] = c(!1);
10
12
  return {
11
- taxableItemsSubtotal: o,
12
- nonTaxableItemsSubtotal: s,
13
- subtotal: o + s,
14
- rate: a
15
- };
16
- }
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
13
+ view: s(() => n({
14
+ terms: p.data?.data,
15
+ isLoading: p.isLoading,
16
+ fields: {
17
+ paymentTermsId: l,
18
+ paymentTermsCustomDate: u
19
+ },
20
+ customDatePickerOpen: m,
21
+ messages: d
22
+ }), [
23
+ m,
24
+ d,
25
+ u,
26
+ l,
27
+ p.data?.data,
28
+ p.isLoading
29
+ ]),
30
+ calendar: s(() => t(u), [u]),
31
+ select: o((e) => {
32
+ f((t) => i(t, e)), h(!1);
33
+ }, [f]),
34
+ changeCustomDatePickerOpen: o((e) => {
35
+ h(e), e || f(r);
36
+ }, [f]),
37
+ selectCustomDate: o((e) => {
38
+ f((t) => r({
39
+ ...t,
40
+ paymentTermsCustomDate: a(e)
41
+ })), h(!1);
42
+ }, [f]),
43
+ reset: o(() => h(!1), [])
49
44
  };
50
45
  }
51
46
  //#endregion
52
- export { a as allocateDiscount, o as calculateInvoiceTotals, r as calculateItemsSubtotals, i as resolveDiscountAmount };
47
+ export { l as useReceivablePaymentTerms };