@tesouro/embedded-components-react 0.5.214 → 0.5.215

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 (74) hide show
  1. package/dist/index.d.ts +88 -1
  2. package/dist/index.js +1 -1
  3. package/dist/lib/ReceivablesWidget.d.ts +88 -1
  4. package/dist/lib/ReceivablesWidget.js +1 -1
  5. package/dist/libs/shared/util-validation/dist/index5.js +7 -0
  6. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index.js +7 -7
  7. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index10.js +63 -67
  8. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index11.js +160 -1
  9. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index12.js +6 -0
  10. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index2.js +32 -25
  11. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index6.js +25 -200
  12. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index7.js +175 -1
  13. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index8.js +1 -101
  14. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index9.js +92 -71
  15. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index.js +1 -1
  16. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index10.js +44 -100
  17. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index11.js +93 -421
  18. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index12.js +442 -112
  19. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index13.js +166 -157
  20. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index14.js +150 -204
  21. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index15.js +202 -31
  22. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index16.js +32 -145
  23. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index17.js +145 -37
  24. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index18.js +44 -58
  25. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index19.js +113 -87
  26. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index20.js +58 -116
  27. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index21.js +83 -357
  28. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index22.js +111 -65
  29. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index23.js +449 -99
  30. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index24.js +68 -281
  31. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index25.js +115 -0
  32. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index26.js +314 -0
  33. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index5.js +1 -1
  34. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index6.js +34 -23
  35. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index8.js +444 -92
  36. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index9.js +113 -52
  37. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index.js +18 -14
  38. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index10.js +2 -92
  39. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index11.js +95 -3
  40. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index12.js +3 -24
  41. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index13.js +24 -1
  42. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index14.js +1 -3
  43. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index15.js +1 -1
  44. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index16.js +3 -18
  45. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index17.js +18 -1
  46. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index18.js +0 -3
  47. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index19.js +0 -8
  48. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index20.js +11 -0
  49. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index21.js +1 -264
  50. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index22.js +258 -42
  51. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index23.js +38 -62
  52. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index24.js +61 -463
  53. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index25.js +457 -89
  54. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index26.js +91 -234
  55. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index27.js +89 -82
  56. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index28.js +22 -338
  57. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index29.js +236 -0
  58. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index3.js +26 -204
  59. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index30.js +3 -0
  60. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index31.js +249 -0
  61. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index32.js +93 -0
  62. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index33.js +344 -0
  63. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index4.js +208 -32
  64. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index5.js +29 -202
  65. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index6.js +183 -137
  66. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index7.js +157 -12
  67. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index8.js +10 -19
  68. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index9.js +23 -2
  69. package/dist/libs/tesouro-embedded-components-react/shared/data-access/dist/index.js +40 -40
  70. package/dist/libs/tesouro-embedded-components-react/shared/data-access/dist/lib/rest/@tanstack/react-query.gen.js +167 -156
  71. package/dist/libs/tesouro-embedded-components-react/shared/data-access/dist/lib/rest/sdk.gen.js +66 -34
  72. package/dist/libs/tesouro-embedded-components-react/shared/feature/dist/lib/analytics/build-info.js +1 -1
  73. package/dist/packages/shared-ui-shadcn/dist/index.js +13 -13
  74. package/package.json +1 -1
@@ -2,374 +2,100 @@
2
2
  "use client";
3
3
  "use client";
4
4
  "use client";
5
- import { getStateOptions as e } from "../../../shared/util/dist/lib/usStates.js";
5
+ import { toast as e } from "../../../../../packages/shared-ui-shadcn/dist/index.js";
6
6
  import { extractApiErrorMessage as t } from "../../../shared/util/dist/lib/apiErrors.js";
7
- import { COUNTERPART_MESSAGE_LABELS_EN as n } from "../../../shared/counterpart-management/feature/dist/lib/labels.js";
8
- import { useCounterpartAddressesQuery as r } from "../../../shared/counterpart-management/data-access/dist/index7.js";
9
- import { useCounterpartForm as i } from "../../../shared/counterpart-management/feature/dist/lib/useCounterpartForm.js";
10
- import "../../../shared/counterpart-management/feature/dist/index.js";
11
- import "../../ui/dist/index9.js";
12
- import "../../ui/dist/index.js";
13
- import { buildLineItemControls as ee, commitLineItemField as te, commitTaxRateInput as ne, convertPriceInput as re, createLineItem as ie, getCurrencySymbol as ae, lineItemFromProduct as oe, reconcileMeasureUnits as se, sanitizeLineItemPatch as ce, sanitizeTaxRateInput as le, stepLineItemQuantity as ue, stripBlankLineItems as de, summarizeLineItemErrors as fe, toSheetLineItem as pe, validateLineItems as me } from "./index6.js";
14
- import { buildReceivableAttachmentsView as he } from "./index7.js";
15
- import { convertDiscountInput as ge, decorateDiscountInput as _e, discountInputToMinorUnits as ve, sanitizeDiscountInput as ye } from "./index9.js";
16
- import { buildFormTotalsView as be, calculateFormTotals as xe, validateDiscount as Se, validateInvoiceTotals as Ce } from "./index10.js";
17
- import { createEmptyReceivableFormValues as a, hasReceivableFormErrors as we, receivableFormValuesToCreatePayload as Te, receivableFormValuesToLineItemChanges as Ee, receivableFormValuesToUpdatePayload as De, receivableToFormValues as Oe, validateReceivableForm as ke } from "./index11.js";
18
- import { shouldShowRemindersInitially as Ae } from "./index13.js";
19
- import { useCreateReceivableMutation as je, useUpdateReceivableMutation as Me } from "../../data-access/dist/index6.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";
20
11
  import "../../data-access/dist/index.js";
21
- import { useReceivableAttachmentUploads as Ne } from "./index16.js";
22
- import { useReceivablePaymentTerms as Pe } from "./index17.js";
23
- import { useReceivableBankAccount as Fe } from "./index19.js";
24
- import { useReceivableReminders as Ie } from "./index20.js";
25
- import { getCurrencyOptions as Le } from "../../../shared/product-catalog/feature/dist/lib/helpers.js";
26
- import { useMeasureUnitsQuery as Re } from "../../../shared/product-catalog/data-access/dist/index9.js";
27
- import { useMeasureUnits as ze } from "../../../shared/product-catalog/feature/dist/lib/useMeasureUnits.js";
28
- import "../../../shared/product-catalog/feature/dist/index.js";
29
- import { useCallback as o, useEffect as Be, useMemo as s, useRef as c, useState as l } from "react";
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 "./index20.js";
13
+ import { useCallback as d, useEffect as f, useMemo as p, useRef as m, useState as h } from "react";
30
14
  //#region ../../libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index21.js
31
- function u({ messages: u, counterpartMessageLabels: d, embeddedBankName: Ve, onCreated: He }) {
32
- let f = je(), p = Me(), m = c([]), h = c(""), [g, _] = l(!1), [v, y] = l("create"), [b, x] = l(), [S, C] = l(() => a()), [Ue, w] = l({}), [We, Ge] = l("none"), T = ze(), E = Re(), D = E.data?.data, { unitNamesById: O } = T, [Ke, k] = l(), [A, j] = l(!1), M = c(!1), N = c(!1), P = c(!1), F = c({
33
- lines: !1,
34
- discount: !1
35
- }), [I, L] = l(!1), qe = s(() => e(), []), Je = s(() => ({
36
- ...n,
37
- ...d
38
- }), [d]), Ye = r(S.customerId), Xe = Ye.data?.data?.[0], R = Ye.data?.data?.[0]?.id, Ze = o((e) => {
39
- C((t) => ({
40
- ...t,
41
- attachments: e(t.attachments)
42
- }));
43
- }, []), z = Ne({
44
- attachments: S.attachments,
45
- setAttachments: Ze,
46
- receivableId: b
47
- }), { reset: B, discardUploads: V, commitRemovals: Qe } = z, $e = S.type === "invoice" ? he({
48
- attachments: S.attachments,
49
- pendingUploads: z.pendingUploads,
50
- isCountLimitReached: z.isCountLimitReached,
51
- isRecurring: !1,
52
- messages: u
53
- }) : void 0, et = o((e) => {
54
- C((t) => ({
55
- ...t,
56
- customerId: e ?? ""
57
- }));
58
- }, []), H = i({
59
- view: We,
60
- setView: Ge,
61
- selectedId: S.customerId || void 0,
62
- setSelectedId: et,
63
- messages: Je,
64
- counterpartType: "customer",
65
- counterpart: void 0,
66
- primaryAddress: Xe
67
- }), tt = o((e) => C((t) => {
68
- let n = e({
69
- paymentTermsId: t.paymentTermsId,
70
- paymentTermsCustomDate: t.paymentTermsCustomDate
71
- });
72
- return {
73
- ...t,
74
- ...n,
75
- ...n.paymentTermsId === "receipt_due" ? { paymentReminderId: "" } : {}
76
- };
77
- }), []), U = Pe({
78
- paymentTermsId: S.paymentTermsId,
79
- paymentTermsCustomDate: S.paymentTermsCustomDate,
80
- messages: u,
81
- onChange: tt
82
- }), W = U.reset, nt = o((e) => C((t) => ({
83
- ...t,
84
- ...e
85
- })), []), G = Fe({
86
- open: g,
87
- bankAccountId: S.bankAccountId,
88
- embeddedBankName: Ve,
89
- messages: u,
90
- onSelect: nt
91
- }), K = G.reset, rt = o((e) => C((t) => ({
92
- ...t,
93
- ...e
94
- })), []), q = f.isPending || p.isPending, it = Ie({
95
- open: g,
96
- isInvoice: S.type === "invoice",
97
- disabled: q,
98
- paymentTermsId: S.paymentTermsId,
99
- paymentTermsCustomDate: S.paymentTermsCustomDate,
100
- paymentReminderId: S.paymentReminderId,
101
- overdueReminderId: S.overdueReminderId,
102
- messages: u,
103
- onSelect: rt
104
- }), J = it.reset, Y = o(() => {
105
- m.current = [], k(void 0), y("create"), x(void 0), C(a()), w({}), j(!1), L(!1), F.current = {
106
- lines: !1,
107
- discount: !1
108
- }, B();
109
- }, [B]), at = o((e = "invoice") => {
110
- W(), K();
111
- let t = {
112
- ...a(),
113
- type: e
114
- };
115
- J(Ae(t)), m.current = [], k(void 0), y("create"), x(void 0), C(t), w({}), B(), j(!1), L(!1), F.current = {
116
- lines: !1,
117
- discount: !1
118
- }, _(!0);
119
- }, [
120
- B,
121
- W,
122
- K,
123
- J
124
- ]), ot = o((e) => {
125
- if (e.type === "credit_note") return;
126
- W(), K();
127
- let t = Oe(e, D);
128
- J(Ae(t)), m.current = e.line_items, h.current = e.currency, k(void 0), y("edit"), x(e.id), C(t), w({}), j(!1), L(!1), F.current = {
129
- lines: !1,
130
- discount: !1
131
- }, B(), _(!0);
132
- }, [
133
- B,
134
- W,
135
- K,
136
- J,
137
- D
138
- ]);
139
- Be(() => {
140
- D?.length && C((e) => {
141
- let t = se(e.lineItems, D);
142
- return t === e.lineItems ? e : {
143
- ...e,
144
- lineItems: t
145
- };
146
- });
147
- }, [D]);
148
- let X = z.isUploading, st = o(() => {
149
- X || (V(), _(!1), w({}));
150
- }, [V, X]), ct = o((e) => {
151
- let t = { ...e };
152
- t.taxRate !== void 0 && (t.taxRate = le(t.taxRate), P.current = !0), t.type !== void 0 && t.type !== "invoice" && V(), t.discount !== void 0 && A && (N.current = !0), t.discountType !== void 0 && (N.current = !0), t.currency !== void 0 && (M.current = !0), C((e) => {
153
- let n = {
154
- ...e,
155
- ...t
156
- };
157
- return t.discount !== void 0 && (n.discount = ye(t.discount, n.discountType, n.currency)), n.currency !== e.currency && (n.lineItems = e.lineItems.map((t) => ({
158
- ...t,
159
- price: re(t.price, e.currency, n.currency)
160
- }))), (n.currency !== e.currency || n.discountType !== e.discountType) && (n.discount = ge({
161
- value: n.discount,
162
- type: n.discountType,
163
- currency: n.currency
164
- })), n;
165
- });
166
- }, [V, A]), lt = o(() => L(!0), []), ut = o(() => {
167
- L(!1), N.current = !0, C((e) => ({
168
- ...e,
169
- discount: ge({
170
- value: e.discount,
171
- type: e.discountType,
172
- currency: e.currency
173
- })
174
- }));
175
- }, []), dt = o(() => {
176
- P.current = !0, C((e) => {
177
- let t = ne(e.taxRate);
178
- return t === e.taxRate ? e : {
179
- ...e,
180
- taxRate: t
181
- };
182
- });
183
- }, []), Z = o((e, { validate: t }) => {
184
- t && (M.current = !0), C((t) => ({
185
- ...t,
186
- lineItems: e(t.lineItems)
187
- }));
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({});
188
22
  }, []);
189
- Be(() => {
190
- let e = M.current, t = N.current;
191
- if (!e && !t && !P.current) return;
192
- M.current = !1, N.current = !1, P.current = !1, e && (F.current.lines = !0), t && (F.current.discount = !0);
193
- let n = e ? me(S.lineItems, {
194
- currency: S.currency,
195
- messages: u
196
- }) : void 0;
197
- w((t) => {
198
- let r = { ...t };
199
- return F.current.lines && (r.lineItems = e ? n : t.lineItems, r.lineItemsSummary = fe(r.lineItems, Ce(S, u))), F.current.discount && (r.discount = Se(S, u)), r;
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
200
29
  });
201
- }, [u, S]);
202
- let ft = o((e, t) => {
203
- let { unit: n, ...r } = t, i = ce(r);
204
- i.name !== void 0 && (i.productId = ""), n !== void 0 && (i.measureUnitId = n, i.measureUnitName = ""), i.taxable !== void 0 && (P.current = !0), Z((t) => t.map((t) => t.id === e ? {
205
- ...t,
206
- ...i
207
- } : t), { validate: A });
208
- }, [Z, A]), pt = o((e, t) => {
209
- Z((n) => n.map((n) => n.id === e ? {
210
- ...n,
211
- ...oe({
212
- product: t,
213
- currency: S.currency,
214
- unitNamesById: O
215
- })
216
- } : n), { validate: !0 });
217
- }, [
218
- Z,
219
- O,
220
- S.currency
221
- ]), Q = o((e, t) => {
222
- t && Z((n) => t.kind === "remove" ? n.filter((t) => t.id !== e) : n.map((n) => n.id === e ? {
223
- ...n,
224
- ...t.patch
225
- } : n), { validate: !0 });
226
- }, [Z]), mt = o((e, t) => {
227
- let n = S.lineItems.find((t) => t.id === e);
228
- n && Q(e, te({
229
- lineItem: n,
230
- field: t,
231
- rowCount: S.lineItems.length,
232
- currency: S.currency
233
- }));
234
30
  }, [
235
- Q,
236
- S.currency,
237
- S.lineItems
238
- ]), ht = o((e, t) => {
239
- let n = S.lineItems.find((t) => t.id === e);
240
- n && Q(e, ue({
241
- lineItem: n,
242
- step: t,
243
- rowCount: S.lineItems.length
244
- }));
245
- }, [Q, S.lineItems]), gt = o(() => {
246
- let e = ie(S.currency);
247
- k(e.id), C((t) => ({
248
- ...t,
249
- lineItems: [...t.lineItems, e]
250
- }));
251
- }, [S.currency]), _t = o((e) => {
252
- Z((t) => t.length <= 1 ? t : t.filter((t) => t.id !== e), { validate: !0 });
253
- }, [Z]), vt = o(async () => {
254
- if (X) return;
255
- if (E.isLoading) {
256
- w({ form: u.lineItemsLoading });
257
- return;
258
- }
259
- let e = de(S.lineItems), n = e.length === S.lineItems.length ? S : {
260
- ...S,
261
- lineItems: e
262
- };
263
- n !== S && C(n);
264
- let r = ke({
265
- values: n,
266
- billingAddressId: R,
267
- messages: u
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
268
41
  });
269
- if (we(r)) {
270
- w(r), j(!0), F.current = {
271
- lines: !0,
272
- discount: !0
273
- };
274
- return;
275
- }
276
- w({});
277
- try {
278
- if (v === "edit" && b) {
279
- let e = { receivable_id: b };
280
- await p.mutateAsync({
281
- path: e,
282
- body: De({
283
- values: n,
284
- billingAddressId: R ?? "",
285
- lineItemChanges: Ee({
286
- values: n,
287
- originalLineItems: m.current,
288
- originalCurrency: h.current,
289
- unitNamesById: O,
290
- units: D
291
- })
292
- })
293
- }), Qe(), _(!1), Y();
294
- return;
295
- }
296
- let e = await f.mutateAsync({ body: Te({
297
- values: n,
298
- billingAddressId: R ?? "",
299
- unitNamesById: O
300
- }) });
301
- _(!1), Y(), e?.id && He?.(e.id, e.type);
302
- } catch (e) {
303
- w({ form: t(e) ?? u.genericError });
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);
304
57
  }
305
58
  }, [
306
- R,
307
- Qe,
308
- f,
309
- b,
310
- X,
311
- u,
59
+ E,
60
+ k,
61
+ y,
62
+ b
63
+ ]), B = p(() => c({
64
+ accounts: C,
65
+ embeddedBankName: v,
66
+ messages: y
67
+ }), [
312
68
  v,
313
- He,
314
- Y,
315
- D,
316
- O,
317
- E.isLoading,
318
- p,
319
- S
320
- ]), yt = s(() => ({
321
- ...S,
322
- discount: I ? S.discount : _e(ve(S.discount, S.discountType, S.currency), S.discountType, S.currency),
323
- lineItems: S.lineItems.map(pe)
324
- }), [I, S]), bt = s(() => ee(S.lineItems), [S.lineItems]), $ = s(() => xe(S), [S]), xt = s(() => be($, S.currency), [$, S.currency]);
69
+ y,
70
+ C
71
+ ]);
325
72
  return {
326
- open: g,
327
- setOpen: _,
328
- mode: v,
329
- values: S,
330
- sheetValues: yt,
331
- errors: Ue,
332
- setValues: C,
333
- updateValues: ct,
334
- commitTaxRate: dt,
335
- focusDiscount: lt,
336
- commitDiscount: ut,
337
- updateLineItem: ft,
338
- selectProduct: pt,
339
- commitLineItem: mt,
340
- stepLineItem: ht,
341
- addLineItem: gt,
342
- removeLineItem: _t,
343
- attachmentsView: $e,
344
- attachmentsUploading: z.isUploading,
345
- saveDisabled: E.isLoading || z.isUploading,
346
- selectAttachmentFiles: z.selectFiles,
347
- setAttachmentIncludeInEmail: z.setIncludeInEmail,
348
- removeAttachment: z.remove,
349
- autoFocusLineItemId: Ke,
350
- lineItemUnitOptions: T.unitOptions,
351
- lineItemsLoading: E.isLoading,
352
- lineItemControls: bt,
353
- totals: $,
354
- totalsView: xt,
355
- currencySymbol: ae(S.currency),
356
- isSubmitting: q,
357
- currencyOptions: Le(S.currency),
358
- paymentTerms: U,
359
- showBillingSection: S.type === "invoice" || v === "edit",
360
- showDueDateField: S.type === "quote",
361
- openCreate: at,
362
- openEdit: ot,
363
- close: st,
364
- submit: vt,
365
- units: T,
366
- counterpartView: We,
367
- counterpartForm: H,
368
- stateOptions: qe,
369
- openCounterpartCreate: H.openCreate,
370
- bankAccount: G,
371
- reminders: it
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
372
98
  };
373
99
  }
374
100
  //#endregion
375
- export { u as useReceivableForm };
101
+ export { g as useReceivableBankAccount };
@@ -2,74 +2,120 @@
2
2
  "use client";
3
3
  "use client";
4
4
  "use client";
5
- import { buildReceivableRows as e, statusFilterOptions as t, typeForTab as n } from "./index11.js";
6
- import { useReceivablesQuery as r } from "../../data-access/dist/index9.js";
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 { usePaymentTermsQuery as n } from "../../../shared/data-access/dist/lib/reference-data/usePaymentTermsQuery.js";
8
+ import "../../../shared/ui/dist/index.js";
9
+ import { useWidgetConfig as r } from "../../../shared/feature/dist/lib/WidgetProvider/hooks.js";
10
+ import "../../../shared/feature/dist/index.js";
11
+ import { areOverdueTermsValid as i, buildOverdueReminderPayload as a, buildPaymentReminderPayload as o, buildRemindersView as s, canCreateReminders as c, getImpliedDueDate as l, isBeforeDueDaysValid as u, sanitizeReminderDays as d } from "./index14.js";
12
+ import { useCreateOverdueReminderMutation as f, useCreatePaymentReminderMutation as p, useOverdueRemindersQuery as m, usePaymentRemindersQuery as h } from "../../data-access/dist/index11.js";
7
13
  import "../../data-access/dist/index.js";
8
- import { useCallback as i, useEffect as a, useMemo as o, useState as s } from "react";
14
+ import { useCallback as g, useMemo as _, useState as v } from "react";
9
15
  //#region ../../libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index22.js
10
- var c = [];
11
- function l({ activeTab: l, messages: d }) {
12
- let [f, p] = s([]), [m, h] = s(10), [g, _] = s(), [v, y] = s(""), [b, x] = s(""), [S, C] = s("all");
13
- a(() => {
14
- _(void 0), C("all");
15
- }, [l]), a(() => {
16
- let e = setTimeout(() => {
17
- x(v), _(void 0);
18
- }, 300);
19
- return () => clearTimeout(e);
20
- }, [v]);
21
- let w = f[0]?.id, T = w ? u[w] : void 0, E = f[0] ? f[0].desc ? "desc" : "asc" : void 0, D = r({
22
- type: n(l),
23
- limit: m,
24
- pagination_token: g,
25
- search_text: b || void 0,
26
- status: S === "all" ? void 0 : S,
27
- ...T ? {
28
- sort: T,
29
- order: E
30
- } : {}
31
- }), O = D.data?.data ?? c, k = o(() => new Map(O.map((e) => [e.id, e])), [O]), A = i((e) => k.get(e), [k]), j = o(() => e({
32
- receivables: O,
33
- messages: d
34
- }), [d, O]), M = !!b || S !== "all", N = i((e) => {
35
- let t = typeof e == "function" ? e(f) : e;
36
- p(t), _(void 0);
37
- }, [f]), P = i((e) => {
38
- h(e), _(void 0);
39
- }, []), F = i((e) => {
40
- C(e), _(void 0);
41
- }, []), I = i(() => _(D.data?.next_pagination_token ?? void 0), [D.data?.next_pagination_token]), L = i(() => _(D.data?.prev_pagination_token ?? void 0), [D.data?.prev_pagination_token]), R = i(() => {
42
- D.refetch();
43
- }, [D]);
16
+ var y = [""];
17
+ function b({ open: b, isInvoice: x, disabled: S, paymentTermsId: C, paymentTermsCustomDate: w, paymentReminderId: T, overdueReminderId: E, messages: D, onSelect: O }) {
18
+ let { initResponse: k } = r(), A = n().data?.data, j = _(() => c(k?.scopes), [k?.scopes]), [M, N] = v(!1), [P, F] = v(""), [I, L] = v(y), R = b && x && M, z = h({ enabled: R }), B = m({ enabled: R }), V = p(), H = f(), U = g((e) => {
19
+ N(e), F(""), L(y);
20
+ }, []), W = g((e) => {
21
+ e || (O({
22
+ paymentReminderId: "",
23
+ overdueReminderId: ""
24
+ }), F(""), L(y)), N(e);
25
+ }, [O]), G = g((e) => O({ paymentReminderId: e }), [O]), K = g((e) => O({ overdueReminderId: e }), [O]), q = g((e) => F(d(e)), []), J = g((e, t) => {
26
+ let n = d(t);
27
+ L((t) => t.map((t, r) => r === e ? n : t));
28
+ }, []), Y = g(() => {
29
+ L((e) => e.length < 3 ? [...e, ""] : e);
30
+ }, []), X = g(() => L(y), []), Z = g(() => l({
31
+ paymentTermsId: C,
32
+ paymentTermsCustomDate: w,
33
+ paymentTerms: A,
34
+ today: /* @__PURE__ */ new Date()
35
+ }), [
36
+ A,
37
+ w,
38
+ C
39
+ ]), Q = g(async () => {
40
+ if (u(P)) try {
41
+ let t = await V.mutateAsync({ body: o({
42
+ daysBefore: Number(P),
43
+ dueDate: Z(),
44
+ messages: D
45
+ }) });
46
+ F(""), O({ paymentReminderId: t.id }), e.success(D.reminderAdded);
47
+ } catch (n) {
48
+ e.error(t(n) ?? D.genericError);
49
+ }
50
+ }, [
51
+ P,
52
+ V,
53
+ Z,
54
+ D,
55
+ O
56
+ ]), $ = g(async () => {
57
+ if (i(I)) try {
58
+ let t = await H.mutateAsync({ body: a({
59
+ terms: I,
60
+ dueDate: Z(),
61
+ messages: D
62
+ }) });
63
+ L(y), O({ overdueReminderId: t.id }), e.success(D.reminderAdded);
64
+ } catch (n) {
65
+ e.error(t(n) ?? D.genericError);
66
+ }
67
+ }, [
68
+ H,
69
+ Z,
70
+ D,
71
+ O,
72
+ I
73
+ ]);
44
74
  return {
45
- rows: j,
46
- isLoading: D.isLoading,
47
- isError: D.isError,
48
- sorting: f,
49
- onSortingChange: N,
50
- pageSize: m,
51
- onPageSizeChange: P,
52
- hasNextPage: !!D.data?.next_pagination_token,
53
- hasPrevPage: !!D.data?.prev_pagination_token,
54
- onNextPage: I,
55
- onPrevPage: L,
56
- searchValue: v,
57
- onSearchChange: y,
58
- statusFilter: S,
59
- statusOptions: t(),
60
- onStatusFilterChange: F,
61
- isFiltering: M,
62
- onRetry: R,
63
- getReceivableById: A
75
+ view: _(() => x ? s({
76
+ showReminders: M,
77
+ paymentTermsId: C,
78
+ paymentTermsCustomDate: w,
79
+ paymentReminderId: T,
80
+ overdueReminderId: E,
81
+ paymentReminders: z.data?.data,
82
+ overdueReminders: B.data?.data,
83
+ canCreate: j,
84
+ disabled: S,
85
+ beforeDueInput: P,
86
+ overdueTerms: I,
87
+ isCreatingPaymentReminder: V.isPending,
88
+ isCreatingOverdueReminder: H.isPending,
89
+ today: /* @__PURE__ */ new Date(),
90
+ messages: D
91
+ }) : void 0, [
92
+ P,
93
+ j,
94
+ H.isPending,
95
+ V.isPending,
96
+ S,
97
+ x,
98
+ D,
99
+ E,
100
+ B.data?.data,
101
+ I,
102
+ T,
103
+ z.data?.data,
104
+ w,
105
+ C,
106
+ M
107
+ ]),
108
+ reset: U,
109
+ toggle: W,
110
+ selectPaymentReminder: G,
111
+ selectOverdueReminder: K,
112
+ changeBeforeDueInput: q,
113
+ saveBeforeDue: Q,
114
+ changeOverdueTerm: J,
115
+ addOverdueTerm: Y,
116
+ clearOverdueTerms: X,
117
+ saveOverdue: $
64
118
  };
65
119
  }
66
- var u = {
67
- documentLabel: "document_id",
68
- customerLabel: "counterpart_name",
69
- status: "status",
70
- issueDateLabel: "issue_date",
71
- dueDateLabel: "due_date",
72
- totalLabel: "total_amount"
73
- };
74
120
  //#endregion
75
- export { l as useReceivablesTable };
121
+ export { b as useReceivableReminders };