@tesouro/embedded-components-react 0.5.204 → 0.5.205
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.
- package/README.md +15 -14
- package/dist/index.d.ts +38 -0
- package/dist/index.js +1 -1
- package/dist/lib/ReceivablesWidget.d.ts +38 -0
- package/dist/lib/ReceivablesWidget.js +1 -1
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index.js +7 -7
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index2.js +26 -23
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index3.js +79 -2
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index.js +1 -1
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index13.js +53 -42
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index14.js +81 -283
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index15.js +47 -70
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index16.js +303 -99
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index17.js +68 -230
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index18.js +115 -0
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index19.js +253 -0
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index5.js +1 -1
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index8.js +34 -19
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index9.js +14 -0
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index.js +10 -9
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index10.js +18 -1
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index11.js +0 -3
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index12.js +0 -7
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index13.js +10 -0
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index14.js +1 -264
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index15.js +259 -67
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index16.js +61 -412
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index17.js +407 -89
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index18.js +73 -60
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index19.js +80 -331
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index2.js +20 -0
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index20.js +344 -0
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index4.js +183 -137
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index5.js +157 -20
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index6.js +24 -1
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index7.js +1 -3
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index8.js +1 -1
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index9.js +3 -18
- package/dist/libs/tesouro-embedded-components-react/shared/data-access/dist/index.js +38 -38
- package/dist/libs/tesouro-embedded-components-react/shared/data-access/dist/lib/rest/@tanstack/react-query.gen.js +213 -202
- package/dist/libs/tesouro-embedded-components-react/shared/data-access/dist/lib/rest/sdk.gen.js +136 -116
- package/dist/libs/tesouro-embedded-components-react/shared/feature/dist/lib/analytics/build-info.js +1 -1
- package/dist/packages/shared-ui-shadcn/dist/index.js +1763 -1749
- package/package.json +1 -1
package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index14.js
CHANGED
|
@@ -2,302 +2,100 @@
|
|
|
2
2
|
"use client";
|
|
3
3
|
"use client";
|
|
4
4
|
"use client";
|
|
5
|
-
import {
|
|
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
|
|
8
|
-
import {
|
|
9
|
-
import
|
|
10
|
-
import {
|
|
11
|
-
import "../../../shared/counterpart-management/feature/dist/index.js";
|
|
12
|
-
import { buildLineItemControls as ee, commitLineItemField as te, commitTaxRateInput as ne, convertPriceInput as re, createLineItem as o, getCurrencySymbol as ie, isBlankLineItem 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";
|
|
13
|
-
import { buildReceivableAttachmentsView as he } from "./index7.js";
|
|
14
|
-
import { createEmptyReceivableFormValues as s, getPaymentTermOptions as ge, hasReceivableFormErrors as _e, receivableFormValuesToCreatePayload as ve, receivableFormValuesToLineItemChanges as ye, receivableFormValuesToUpdatePayload as be, receivableToFormValues as xe, validateReceivableForm as Se } from "./index8.js";
|
|
15
|
-
import { useCreateReceivableMutation as c, useUpdateReceivableMutation as Ce } 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";
|
|
16
11
|
import "../../data-access/dist/index.js";
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
19
|
-
import { getCurrencyOptions as Ee } from "../../../shared/product-catalog/feature/dist/lib/helpers.js";
|
|
20
|
-
import { useMeasureUnitsQuery as De } from "../../../shared/product-catalog/data-access/dist/index9.js";
|
|
21
|
-
import { useMeasureUnits as l } from "../../../shared/product-catalog/feature/dist/lib/useMeasureUnits.js";
|
|
22
|
-
import "../../../shared/product-catalog/feature/dist/index.js";
|
|
23
|
-
import { useCallback as u, useEffect as d, useMemo as f, useRef as p, useState as m } 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 "./index13.js";
|
|
13
|
+
import { useCallback as d, useEffect as f, useMemo as p, useRef as m, useState as h } from "react";
|
|
24
14
|
//#region ../../libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index14.js
|
|
25
|
-
function
|
|
26
|
-
let
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
attachments: e(t.attachments)
|
|
33
|
-
}));
|
|
34
|
-
}, []), W = we({
|
|
35
|
-
attachments: k.attachments,
|
|
36
|
-
setAttachments: Ne,
|
|
37
|
-
receivableId: D
|
|
38
|
-
}), { reset: G, discardUploads: K, commitRemovals: q } = W, Pe = k.type === "invoice" ? he({
|
|
39
|
-
attachments: k.attachments,
|
|
40
|
-
pendingUploads: W.pendingUploads,
|
|
41
|
-
isCountLimitReached: W.isCountLimitReached,
|
|
42
|
-
isRecurring: !1,
|
|
43
|
-
messages: h
|
|
44
|
-
}) : void 0, Fe = u((e) => {
|
|
45
|
-
A((t) => ({
|
|
46
|
-
...t,
|
|
47
|
-
customerId: e ?? ""
|
|
48
|
-
}));
|
|
49
|
-
}, []), J = a({
|
|
50
|
-
view: M,
|
|
51
|
-
setView: ke,
|
|
52
|
-
selectedId: k.customerId || void 0,
|
|
53
|
-
setSelectedId: Fe,
|
|
54
|
-
messages: je,
|
|
55
|
-
counterpartType: "customer",
|
|
56
|
-
counterpart: void 0,
|
|
57
|
-
primaryAddress: Me
|
|
58
|
-
}), Y = u(() => {
|
|
59
|
-
b.current = [], L(void 0), E("create"), O(void 0), A(s()), j({}), z(!1), G();
|
|
60
|
-
}, [G]), Ie = u((e = "invoice") => {
|
|
61
|
-
b.current = [], L(void 0), E("create"), O(void 0), A({
|
|
62
|
-
...s(),
|
|
63
|
-
type: e
|
|
64
|
-
}), j({}), G(), z(!1), w(!0);
|
|
65
|
-
}, [G]), Le = u((e) => {
|
|
66
|
-
e.type !== "credit_note" && (b.current = e.line_items, x.current = e.currency, L(void 0), E("edit"), O(e.id), A(xe(e, F)), j({}), z(!1), G(), w(!0));
|
|
67
|
-
}, [G, F]);
|
|
68
|
-
d(() => {
|
|
69
|
-
F?.length && A((e) => {
|
|
70
|
-
let t = se(e.lineItems, F);
|
|
71
|
-
return t === e.lineItems ? e : {
|
|
72
|
-
...e,
|
|
73
|
-
lineItems: t
|
|
74
|
-
};
|
|
75
|
-
});
|
|
76
|
-
}, [F]);
|
|
77
|
-
let X = W.isUploading, Re = u(() => {
|
|
78
|
-
X || (K(), w(!1), j({}));
|
|
79
|
-
}, [K, X]), ze = u((e) => {
|
|
80
|
-
let t = e.taxRate === void 0 ? e : {
|
|
81
|
-
...e,
|
|
82
|
-
taxRate: le(e.taxRate)
|
|
83
|
-
}, { currency: n, type: r } = t;
|
|
84
|
-
if (r !== void 0 && r !== "invoice" && K(), n === void 0) {
|
|
85
|
-
A((e) => ({
|
|
86
|
-
...e,
|
|
87
|
-
...t
|
|
88
|
-
}));
|
|
89
|
-
return;
|
|
90
|
-
}
|
|
91
|
-
B.current = !0, A((e) => e.currency === n ? {
|
|
92
|
-
...e,
|
|
93
|
-
...t
|
|
94
|
-
} : {
|
|
95
|
-
...e,
|
|
96
|
-
...t,
|
|
97
|
-
lineItems: e.lineItems.map((t) => ({
|
|
98
|
-
...t,
|
|
99
|
-
price: re(t.price, e.currency, n)
|
|
100
|
-
}))
|
|
101
|
-
});
|
|
102
|
-
}, [K]), Be = u(() => {
|
|
103
|
-
A((e) => {
|
|
104
|
-
let t = ne(e.taxRate);
|
|
105
|
-
return t === e.taxRate ? e : {
|
|
106
|
-
...e,
|
|
107
|
-
taxRate: t
|
|
108
|
-
};
|
|
109
|
-
});
|
|
110
|
-
}, []), Z = u((e, t) => {
|
|
111
|
-
let n = me(e, {
|
|
112
|
-
currency: t,
|
|
113
|
-
messages: h
|
|
114
|
-
});
|
|
115
|
-
j((e) => ({
|
|
116
|
-
...e,
|
|
117
|
-
lineItems: n,
|
|
118
|
-
lineItemsSummary: fe(n)
|
|
119
|
-
}));
|
|
120
|
-
}, [h]), Q = u((e, { validate: t }) => {
|
|
121
|
-
t && (B.current = !0), A((t) => ({
|
|
122
|
-
...t,
|
|
123
|
-
lineItems: e(t.lineItems)
|
|
124
|
-
}));
|
|
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({});
|
|
125
22
|
}, []);
|
|
126
|
-
|
|
127
|
-
|
|
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
|
|
29
|
+
});
|
|
128
30
|
}, [
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
31
|
+
T,
|
|
32
|
+
b,
|
|
33
|
+
g,
|
|
34
|
+
C
|
|
132
35
|
]);
|
|
133
|
-
let
|
|
134
|
-
let
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
} : t), { validate: R });
|
|
139
|
-
}, [Q, R]), He = u((e, t) => {
|
|
140
|
-
Q((n) => n.map((n) => n.id === e ? {
|
|
141
|
-
...n,
|
|
142
|
-
...oe({
|
|
143
|
-
product: t,
|
|
144
|
-
currency: k.currency,
|
|
145
|
-
unitNamesById: I
|
|
146
|
-
})
|
|
147
|
-
} : n), { validate: !0 });
|
|
148
|
-
}, [
|
|
149
|
-
Q,
|
|
150
|
-
I,
|
|
151
|
-
k.currency
|
|
152
|
-
]), $ = u((e, t) => {
|
|
153
|
-
t && Q((n) => t.kind === "remove" ? n.filter((t) => t.id !== e) : n.map((n) => n.id === e ? {
|
|
154
|
-
...n,
|
|
155
|
-
...t.patch
|
|
156
|
-
} : n), { validate: !0 });
|
|
157
|
-
}, [Q]), Ue = u((e, t) => {
|
|
158
|
-
let n = k.lineItems.find((t) => t.id === e);
|
|
159
|
-
n && $(e, te({
|
|
160
|
-
lineItem: n,
|
|
161
|
-
field: t,
|
|
162
|
-
rowCount: k.lineItems.length,
|
|
163
|
-
currency: k.currency
|
|
164
|
-
}));
|
|
165
|
-
}, [
|
|
166
|
-
$,
|
|
167
|
-
k.currency,
|
|
168
|
-
k.lineItems
|
|
169
|
-
]), We = u((e, t) => {
|
|
170
|
-
let n = k.lineItems.find((t) => t.id === e);
|
|
171
|
-
n && $(e, ue({
|
|
172
|
-
lineItem: n,
|
|
173
|
-
step: t,
|
|
174
|
-
rowCount: k.lineItems.length
|
|
175
|
-
}));
|
|
176
|
-
}, [$, k.lineItems]), Ge = u(() => {
|
|
177
|
-
let e = o(k.currency);
|
|
178
|
-
L(e.id), A((t) => ({
|
|
179
|
-
...t,
|
|
180
|
-
lineItems: [...t.lineItems, e]
|
|
181
|
-
}));
|
|
182
|
-
}, [k.currency]), Ke = u((e) => {
|
|
183
|
-
Q((t) => t.length <= 1 ? t : t.filter((t) => t.id !== e), { validate: !0 });
|
|
184
|
-
}, [Q]), qe = u(async () => {
|
|
185
|
-
if (X) return;
|
|
186
|
-
if (P.isLoading) {
|
|
187
|
-
j({ form: h.lineItemsLoading });
|
|
188
|
-
return;
|
|
189
|
-
}
|
|
190
|
-
let e = de(k.lineItems), n = e.length === k.lineItems.length ? k : {
|
|
191
|
-
...k,
|
|
192
|
-
lineItems: e
|
|
193
|
-
};
|
|
194
|
-
n !== k && A(n);
|
|
195
|
-
let r = Se({
|
|
196
|
-
values: n,
|
|
197
|
-
billingAddressId: U,
|
|
198
|
-
messages: h
|
|
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
|
|
199
41
|
});
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
originalLineItems: b.current,
|
|
216
|
-
originalCurrency: x.current,
|
|
217
|
-
unitNamesById: I,
|
|
218
|
-
units: F
|
|
219
|
-
})
|
|
220
|
-
})
|
|
221
|
-
}), q(), w(!1), Y();
|
|
222
|
-
return;
|
|
223
|
-
}
|
|
224
|
-
let e = await v.mutateAsync({ body: ve({
|
|
225
|
-
values: n,
|
|
226
|
-
billingAddressId: U ?? "",
|
|
227
|
-
unitNamesById: I
|
|
228
|
-
}) });
|
|
229
|
-
w(!1), Y(), e?.id && _?.(e.id, e.type);
|
|
230
|
-
} catch (e) {
|
|
231
|
-
j({ form: t(e) ?? h.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);
|
|
232
57
|
}
|
|
233
58
|
}, [
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
v,
|
|
237
|
-
D,
|
|
238
|
-
X,
|
|
239
|
-
h,
|
|
240
|
-
T,
|
|
241
|
-
_,
|
|
242
|
-
Y,
|
|
243
|
-
F,
|
|
244
|
-
I,
|
|
245
|
-
P.isLoading,
|
|
59
|
+
E,
|
|
60
|
+
k,
|
|
246
61
|
y,
|
|
247
|
-
|
|
248
|
-
]),
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
lineItems: k.lineItems.filter((e) => !ae(e)),
|
|
253
|
-
currency: k.currency,
|
|
254
|
-
taxRate: Number(k.taxRate) || void 0
|
|
62
|
+
b
|
|
63
|
+
]), B = p(() => c({
|
|
64
|
+
accounts: C,
|
|
65
|
+
embeddedBankName: v,
|
|
66
|
+
messages: y
|
|
255
67
|
}), [
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
68
|
+
v,
|
|
69
|
+
y,
|
|
70
|
+
C
|
|
259
71
|
]);
|
|
260
72
|
return {
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
totals: Xe,
|
|
287
|
-
currencySymbol: ie(k.currency),
|
|
288
|
-
isSubmitting: v.isPending || y.isPending,
|
|
289
|
-
currencyOptions: Ee(k.currency),
|
|
290
|
-
paymentTermsOptions: ge(S.data?.data),
|
|
291
|
-
openCreate: Ie,
|
|
292
|
-
openEdit: Le,
|
|
293
|
-
close: Re,
|
|
294
|
-
submit: qe,
|
|
295
|
-
units: N,
|
|
296
|
-
counterpartView: M,
|
|
297
|
-
counterpartForm: J,
|
|
298
|
-
stateOptions: V,
|
|
299
|
-
openCounterpartCreate: J.openCreate
|
|
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
|
|
300
98
|
};
|
|
301
99
|
}
|
|
302
100
|
//#endregion
|
|
303
|
-
export {
|
|
101
|
+
export { g as useReceivableBankAccount };
|
package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index15.js
CHANGED
|
@@ -1,75 +1,52 @@
|
|
|
1
|
-
|
|
2
|
-
"use client";
|
|
3
|
-
"use client";
|
|
4
|
-
"use client";
|
|
5
|
-
import { buildReceivableRows as e, statusFilterOptions as t, typeForTab as n } from "./index8.js";
|
|
6
|
-
import { useReceivablesQuery as r } from "../../data-access/dist/index9.js";
|
|
7
|
-
import "../../data-access/dist/index.js";
|
|
8
|
-
import { useCallback as i, useEffect as a, useMemo as o, useState as s } from "react";
|
|
1
|
+
import { parseQuantity as e, priceInputToMinorUnits as t } from "./index6.js";
|
|
9
2
|
//#region ../../libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index15.js
|
|
10
|
-
var
|
|
11
|
-
function
|
|
12
|
-
let
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
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]);
|
|
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
|
+
}
|
|
44
10
|
return {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
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
|
|
64
49
|
};
|
|
65
50
|
}
|
|
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
51
|
//#endregion
|
|
75
|
-
export {
|
|
52
|
+
export { a as allocateDiscount, o as calculateInvoiceTotals, r as calculateItemsSubtotals, i as resolveDiscountAmount };
|