@tesouro/embedded-components-react 0.5.200 → 0.5.201
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/dist/index.d.ts +4 -0
- package/dist/index.js +1 -1
- package/dist/lib/ReceivablesWidget.d.ts +4 -0
- package/dist/lib/ReceivablesWidget.js +1 -1
- 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/index10.js +47 -250
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index11.js +267 -65
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index12.js +66 -105
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index13.js +103 -214
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index14.js +226 -0
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index5.js +67 -37
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index6.js +83 -79
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index14.js +207 -172
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index2.js +4 -0
- package/dist/libs/tesouro-embedded-components-react/shared/feature/dist/lib/analytics/build-info.js +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -4915,6 +4915,10 @@ interface ReceivableFormSheetLabels {
|
|
|
4915
4915
|
unitNone: string;
|
|
4916
4916
|
manageUnitsOption: string;
|
|
4917
4917
|
priceLabel: string;
|
|
4918
|
+
taxableLabel: string;
|
|
4919
|
+
taxRateLabel: string;
|
|
4920
|
+
taxRatePlaceholder: string;
|
|
4921
|
+
taxRateSuffix: string;
|
|
4918
4922
|
decreaseQuantityButton: string;
|
|
4919
4923
|
increaseQuantityButton: string;
|
|
4920
4924
|
addLineItemButton: string;
|
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/
|
|
30
|
+
import { ReceivablesWidget as V } from "./libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index14.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";
|
|
@@ -959,6 +959,10 @@ interface ReceivableFormSheetLabels {
|
|
|
959
959
|
unitNone: string;
|
|
960
960
|
manageUnitsOption: string;
|
|
961
961
|
priceLabel: string;
|
|
962
|
+
taxableLabel: string;
|
|
963
|
+
taxRateLabel: string;
|
|
964
|
+
taxRatePlaceholder: string;
|
|
965
|
+
taxRateSuffix: string;
|
|
962
966
|
decreaseQuantityButton: string;
|
|
963
967
|
increaseQuantityButton: string;
|
|
964
968
|
addLineItemButton: string;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { ReceivablesWidget as e } from "../libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/
|
|
1
|
+
import { ReceivablesWidget as e } from "../libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index14.js";
|
|
2
2
|
import "../libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index.js";
|
|
3
3
|
export { e as ReceivablesWidget };
|
package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index10.js
CHANGED
|
@@ -1,255 +1,52 @@
|
|
|
1
|
-
|
|
2
|
-
"use client";
|
|
3
|
-
"use client";
|
|
4
|
-
"use client";
|
|
5
|
-
import { getStateOptions as e } from "../../../shared/util/dist/lib/usStates.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 { COUNTERPART_MESSAGE_LABELS_EN as r } from "../../../shared/counterpart-management/feature/dist/lib/labels.js";
|
|
9
|
-
import { useCounterpartAddressesQuery as i } from "../../../shared/counterpart-management/data-access/dist/index7.js";
|
|
10
|
-
import { useCounterpartForm as ee } from "../../../shared/counterpart-management/feature/dist/lib/useCounterpartForm.js";
|
|
11
|
-
import "../../../shared/counterpart-management/feature/dist/index.js";
|
|
12
|
-
import { buildLineItemControls as a, commitLineItemField as te, convertPriceInput as ne, createLineItem as re, getCurrencySymbol as o, lineItemFromProduct as s, reconcileMeasureUnits as c, sanitizeLineItemPatch as l, stepLineItemQuantity as u, stripBlankLineItems as ie, summarizeLineItemErrors as ae, toSheetLineItem as d, validateLineItems as oe } from "./index5.js";
|
|
13
|
-
import { createEmptyReceivableFormValues as f, getPaymentTermOptions as se, hasReceivableFormErrors as ce, receivableFormValuesToCreatePayload as le, receivableFormValuesToLineItemChanges as ue, receivableFormValuesToUpdatePayload as de, receivableToFormValues as fe, validateReceivableForm as p } from "./index6.js";
|
|
14
|
-
import { useCreateReceivableMutation as m, useUpdateReceivableMutation as pe } from "../../data-access/dist/index6.js";
|
|
15
|
-
import "../../data-access/dist/index.js";
|
|
16
|
-
import { getCurrencyOptions as me } from "../../../shared/product-catalog/feature/dist/lib/helpers.js";
|
|
17
|
-
import { useMeasureUnitsQuery as he } from "../../../shared/product-catalog/data-access/dist/index9.js";
|
|
18
|
-
import { useMeasureUnits as ge } from "../../../shared/product-catalog/feature/dist/lib/useMeasureUnits.js";
|
|
19
|
-
import "../../../shared/product-catalog/feature/dist/index.js";
|
|
20
|
-
import { useCallback as h, useEffect as g, useMemo as _, useRef as v, useState as y } from "react";
|
|
1
|
+
import { parseQuantity as e, priceInputToMinorUnits as t } from "./index5.js";
|
|
21
2
|
//#region ../../libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index10.js
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
customerId: e ?? ""
|
|
30
|
-
}));
|
|
31
|
-
}, []), Y = ee({
|
|
32
|
-
view: R,
|
|
33
|
-
setView: _e,
|
|
34
|
-
selectedId: P.customerId || void 0,
|
|
35
|
-
setSelectedId: Se,
|
|
36
|
-
messages: be,
|
|
37
|
-
counterpartType: "customer",
|
|
38
|
-
counterpart: void 0,
|
|
39
|
-
primaryAddress: xe
|
|
40
|
-
}), X = h(() => {
|
|
41
|
-
T.current = [], U(void 0), j("create"), N(void 0), F(f()), L({}), G(!1);
|
|
42
|
-
}, []), Ce = h((e = "invoice") => {
|
|
43
|
-
T.current = [], U(void 0), j("create"), N(void 0), F({
|
|
44
|
-
...f(),
|
|
45
|
-
type: e
|
|
46
|
-
}), L({}), G(!1), k(!0);
|
|
47
|
-
}, []), we = h((e) => {
|
|
48
|
-
e.type !== "credit_note" && (T.current = e.line_items, E.current = e.currency, U(void 0), j("edit"), N(e.id), F(fe(e, V)), L({}), G(!1), k(!0));
|
|
49
|
-
}, [V]);
|
|
50
|
-
g(() => {
|
|
51
|
-
V?.length && F((e) => {
|
|
52
|
-
let t = c(e.lineItems, V);
|
|
53
|
-
return t === e.lineItems ? e : {
|
|
54
|
-
...e,
|
|
55
|
-
lineItems: t
|
|
56
|
-
};
|
|
57
|
-
});
|
|
58
|
-
}, [V]);
|
|
59
|
-
let Te = h(() => {
|
|
60
|
-
k(!1), L({});
|
|
61
|
-
}, []), Ee = h((e) => {
|
|
62
|
-
let { currency: t } = e;
|
|
63
|
-
if (t === void 0) {
|
|
64
|
-
F((t) => ({
|
|
65
|
-
...t,
|
|
66
|
-
...e
|
|
67
|
-
}));
|
|
68
|
-
return;
|
|
69
|
-
}
|
|
70
|
-
K.current = !0, F((n) => n.currency === t ? {
|
|
71
|
-
...n,
|
|
72
|
-
...e
|
|
73
|
-
} : {
|
|
74
|
-
...n,
|
|
75
|
-
...e,
|
|
76
|
-
lineItems: n.lineItems.map((e) => ({
|
|
77
|
-
...e,
|
|
78
|
-
price: ne(e.price, n.currency, t)
|
|
79
|
-
}))
|
|
80
|
-
});
|
|
81
|
-
}, []), Z = h((e, t) => {
|
|
82
|
-
let n = oe(e, {
|
|
83
|
-
currency: t,
|
|
84
|
-
messages: b
|
|
85
|
-
});
|
|
86
|
-
L((e) => ({
|
|
87
|
-
...e,
|
|
88
|
-
lineItems: n,
|
|
89
|
-
lineItemsSummary: ae(n)
|
|
90
|
-
}));
|
|
91
|
-
}, [b]), Q = h((e, { validate: t }) => {
|
|
92
|
-
t && (K.current = !0), F((t) => ({
|
|
93
|
-
...t,
|
|
94
|
-
lineItems: e(t.lineItems)
|
|
95
|
-
}));
|
|
96
|
-
}, []);
|
|
97
|
-
g(() => {
|
|
98
|
-
K.current && (K.current = !1, Z(P.lineItems, P.currency));
|
|
99
|
-
}, [
|
|
100
|
-
Z,
|
|
101
|
-
P.currency,
|
|
102
|
-
P.lineItems
|
|
103
|
-
]);
|
|
104
|
-
let De = h((e, t) => {
|
|
105
|
-
let { unit: n, ...r } = t, i = l(r);
|
|
106
|
-
i.name !== void 0 && (i.productId = ""), n !== void 0 && (i.measureUnitId = n, i.measureUnitName = ""), Q((t) => t.map((t) => t.id === e ? {
|
|
107
|
-
...t,
|
|
108
|
-
...i
|
|
109
|
-
} : t), { validate: W });
|
|
110
|
-
}, [Q, W]), Oe = h((e, t) => {
|
|
111
|
-
Q((n) => n.map((n) => n.id === e ? {
|
|
112
|
-
...n,
|
|
113
|
-
...s({
|
|
114
|
-
product: t,
|
|
115
|
-
currency: P.currency,
|
|
116
|
-
unitNamesById: H
|
|
117
|
-
})
|
|
118
|
-
} : n), { validate: !0 });
|
|
119
|
-
}, [
|
|
120
|
-
Q,
|
|
121
|
-
H,
|
|
122
|
-
P.currency
|
|
123
|
-
]), $ = h((e, t) => {
|
|
124
|
-
t && Q((n) => t.kind === "remove" ? n.filter((t) => t.id !== e) : n.map((n) => n.id === e ? {
|
|
125
|
-
...n,
|
|
126
|
-
...t.patch
|
|
127
|
-
} : n), { validate: !0 });
|
|
128
|
-
}, [Q]), ke = h((e, t) => {
|
|
129
|
-
let n = P.lineItems.find((t) => t.id === e);
|
|
130
|
-
n && $(e, te({
|
|
131
|
-
lineItem: n,
|
|
132
|
-
field: t,
|
|
133
|
-
rowCount: P.lineItems.length,
|
|
134
|
-
currency: P.currency
|
|
135
|
-
}));
|
|
136
|
-
}, [
|
|
137
|
-
$,
|
|
138
|
-
P.currency,
|
|
139
|
-
P.lineItems
|
|
140
|
-
]), Ae = h((e, t) => {
|
|
141
|
-
let n = P.lineItems.find((t) => t.id === e);
|
|
142
|
-
n && $(e, u({
|
|
143
|
-
lineItem: n,
|
|
144
|
-
step: t,
|
|
145
|
-
rowCount: P.lineItems.length
|
|
146
|
-
}));
|
|
147
|
-
}, [$, P.lineItems]), je = h(() => {
|
|
148
|
-
let e = re(P.currency);
|
|
149
|
-
U(e.id), F((t) => ({
|
|
150
|
-
...t,
|
|
151
|
-
lineItems: [...t.lineItems, e]
|
|
152
|
-
}));
|
|
153
|
-
}, [P.currency]), Me = h((e) => {
|
|
154
|
-
Q((t) => t.length <= 1 ? t : t.filter((t) => t.id !== e), { validate: !0 });
|
|
155
|
-
}, [Q]), Ne = h(async () => {
|
|
156
|
-
if (B.isLoading) {
|
|
157
|
-
L({ form: b.lineItemsLoading });
|
|
158
|
-
return;
|
|
159
|
-
}
|
|
160
|
-
let e = ie(P.lineItems), n = e.length === P.lineItems.length ? P : {
|
|
161
|
-
...P,
|
|
162
|
-
lineItems: e
|
|
163
|
-
};
|
|
164
|
-
n !== P && F(n);
|
|
165
|
-
let r = p({
|
|
166
|
-
values: n,
|
|
167
|
-
billingAddressId: J,
|
|
168
|
-
messages: b
|
|
169
|
-
});
|
|
170
|
-
if (ce(r)) {
|
|
171
|
-
L(r), G(!0);
|
|
172
|
-
return;
|
|
173
|
-
}
|
|
174
|
-
L({});
|
|
175
|
-
try {
|
|
176
|
-
if (A === "edit" && M) {
|
|
177
|
-
let e = { receivable_id: M };
|
|
178
|
-
await w.mutateAsync({
|
|
179
|
-
path: e,
|
|
180
|
-
body: de({
|
|
181
|
-
values: n,
|
|
182
|
-
billingAddressId: J ?? "",
|
|
183
|
-
lineItemChanges: ue({
|
|
184
|
-
values: n,
|
|
185
|
-
originalLineItems: T.current,
|
|
186
|
-
originalCurrency: E.current,
|
|
187
|
-
unitNamesById: H,
|
|
188
|
-
units: V
|
|
189
|
-
})
|
|
190
|
-
})
|
|
191
|
-
}), k(!1), X();
|
|
192
|
-
return;
|
|
193
|
-
}
|
|
194
|
-
let e = await C.mutateAsync({ body: le({
|
|
195
|
-
values: n,
|
|
196
|
-
billingAddressId: J ?? "",
|
|
197
|
-
unitNamesById: H
|
|
198
|
-
}) });
|
|
199
|
-
k(!1), X(), e?.id && S?.(e.id, e.type);
|
|
200
|
-
} catch (e) {
|
|
201
|
-
L({ form: t(e) ?? b.genericError });
|
|
202
|
-
}
|
|
203
|
-
}, [
|
|
204
|
-
J,
|
|
205
|
-
C,
|
|
206
|
-
M,
|
|
207
|
-
b,
|
|
208
|
-
A,
|
|
209
|
-
S,
|
|
210
|
-
X,
|
|
211
|
-
V,
|
|
212
|
-
H,
|
|
213
|
-
B.isLoading,
|
|
214
|
-
w,
|
|
215
|
-
P
|
|
216
|
-
]), Pe = _(() => ({
|
|
217
|
-
...P,
|
|
218
|
-
lineItems: P.lineItems.map(d)
|
|
219
|
-
}), [P]), Fe = _(() => a(P.lineItems), [P.lineItems]);
|
|
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
|
+
}
|
|
220
10
|
return {
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
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
|
|
252
49
|
};
|
|
253
50
|
}
|
|
254
51
|
//#endregion
|
|
255
|
-
export {
|
|
52
|
+
export { a as allocateDiscount, o as calculateInvoiceTotals, r as calculateItemsSubtotals, i as resolveDiscountAmount };
|