@tesouro/embedded-components-react 0.7.64 → 0.7.67
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 +1 -1
- package/dist/index.css +3 -0
- package/dist/index.d.ts +10 -10
- package/dist/lib/ProductsWidget.d.ts +40 -10
- package/dist/lib/ReceivablesWidget.d.ts +9 -9
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/apiValidationErrors.js +34 -63
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/currencyDisplay.js +6 -0
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/discount.js +31 -30
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/helpers.js +89 -87
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/lineItems.js +84 -82
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/preview.js +77 -75
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/totals.js +54 -53
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/useReceivableForm.js +458 -457
- package/dist/libs/tesouro-embedded-components-react/products-widget/feature/dist/lib/ProductsWidget/ProductsWidget.js +0 -2
- package/dist/libs/tesouro-embedded-components-react/shared/feature/dist/lib/analytics/build-info.js +1 -1
- package/dist/libs/tesouro-embedded-components-react/shared/product-catalog/feature/dist/lib/helpers.js +33 -41
- package/dist/libs/tesouro-embedded-components-react/shared/product-catalog/feature/dist/lib/labels.js +3 -4
- package/dist/libs/tesouro-embedded-components-react/shared/product-catalog/feature/dist/lib/useProductForm.js +42 -44
- package/dist/libs/tesouro-embedded-components-react/shared/product-catalog/ui/dist/index2.js +14 -13
- package/dist/libs/tesouro-embedded-components-react/shared/product-catalog/ui/dist/index3.js +128 -147
- package/dist/libs/tesouro-embedded-components-react/shared/product-catalog/ui/dist/index4.js +109 -92
- package/dist/libs/tesouro-embedded-components-react/shared/util/dist/lib/apiValidationErrors.js +33 -0
- package/package.json +1 -1
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
import { minorExponentForCurrency as e } from "../../../../../shared/util/dist/lib/amountOutputToMajorUnits.js";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { currencyDisplayFor as t } from "./currencyDisplay.js";
|
|
3
|
+
import { isBlankLineItem as n, keepsSavedTaxRates as r, lineItemTaxRateMinorUnits as i, maxAmountLabel as a, parseQuantity as o, priceInputToMinorUnits as s } from "./lineItems.js";
|
|
4
|
+
import { discountFromDraft as c } from "./discount.js";
|
|
4
5
|
//#region ../../libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/totals.js
|
|
5
|
-
var
|
|
6
|
-
function
|
|
7
|
-
return Math.round(
|
|
6
|
+
var l = 1e4;
|
|
7
|
+
function u(e, t) {
|
|
8
|
+
return Math.round(s(e.price, t) * o(e.quantity));
|
|
8
9
|
}
|
|
9
|
-
function
|
|
10
|
+
function d({ lineItems: e, currency: t, taxRate: n }) {
|
|
10
11
|
let r = n ? Math.round(n * 100) : 0, i = 0, a = 0;
|
|
11
12
|
for (let n of e) {
|
|
12
|
-
let e =
|
|
13
|
+
let e = u(n, t);
|
|
13
14
|
n.taxable ? i += e : a += e;
|
|
14
15
|
}
|
|
15
16
|
return {
|
|
@@ -19,84 +20,84 @@ function u({ lineItems: e, currency: t, taxRate: n }) {
|
|
|
19
20
|
rateMinorUnits: r
|
|
20
21
|
};
|
|
21
22
|
}
|
|
22
|
-
function
|
|
23
|
+
function f({ discount: e, subtotal: t }) {
|
|
23
24
|
if (!e) return 0;
|
|
24
25
|
let n = e.value ?? (e.type === "amount" ? e.amount : Math.round(t * e.amount / 1e4));
|
|
25
26
|
return Math.min(Math.max(n, 0), t);
|
|
26
27
|
}
|
|
27
|
-
function
|
|
28
|
+
function p({ taxableItemsSubtotal: e, nonTaxableItemsSubtotal: t, discountAmount: n }) {
|
|
28
29
|
let r = e + t, i = r > 0 ? Math.round(e / r * n) : 0;
|
|
29
30
|
return {
|
|
30
31
|
taxableSubtotal: e - i,
|
|
31
32
|
nonTaxableSubtotal: t - (n - i)
|
|
32
33
|
};
|
|
33
34
|
}
|
|
34
|
-
function
|
|
35
|
+
function m({ lineItems: e, currency: t, rateMinorUnits: n, keepSavedRate: r, taxableItemsSubtotal: a, taxableSubtotal: o }) {
|
|
35
36
|
if (a <= 0) return 0;
|
|
36
37
|
let s = /* @__PURE__ */ new Map();
|
|
37
38
|
for (let a of e) {
|
|
38
39
|
if (!a.taxable) continue;
|
|
39
|
-
let e =
|
|
40
|
-
s.set(e, (s.get(e) ?? 0) +
|
|
40
|
+
let e = i(a, n, r);
|
|
41
|
+
s.set(e, (s.get(e) ?? 0) + u(a, t));
|
|
41
42
|
}
|
|
42
|
-
let
|
|
43
|
-
return
|
|
44
|
-
let r = n ===
|
|
43
|
+
let c = [...s], d = o, f = 0;
|
|
44
|
+
return c.forEach(([e, t], n) => {
|
|
45
|
+
let r = n === c.length - 1 ? d : Math.round(o * t / a);
|
|
45
46
|
d -= r, f += r * e;
|
|
46
|
-
}), Math.round(f /
|
|
47
|
+
}), Math.round(f / l);
|
|
47
48
|
}
|
|
48
|
-
function
|
|
49
|
-
let a =
|
|
49
|
+
function h({ lineItems: e, currency: t, taxRate: n, keepSavedRate: r = !1, discount: i }) {
|
|
50
|
+
let a = d({
|
|
50
51
|
lineItems: e,
|
|
51
52
|
currency: t,
|
|
52
53
|
taxRate: n
|
|
53
|
-
}), o =
|
|
54
|
+
}), o = f({
|
|
54
55
|
discount: i,
|
|
55
56
|
subtotal: a.subtotal
|
|
56
|
-
}), { taxableSubtotal: s, nonTaxableSubtotal: c } =
|
|
57
|
+
}), { taxableSubtotal: s, nonTaxableSubtotal: c } = p({
|
|
57
58
|
...a,
|
|
58
59
|
discountAmount: o
|
|
59
|
-
}), l =
|
|
60
|
+
}), l = m({
|
|
60
61
|
lineItems: e,
|
|
61
62
|
currency: t,
|
|
62
63
|
rateMinorUnits: a.rateMinorUnits,
|
|
63
64
|
keepSavedRate: r,
|
|
64
65
|
taxableItemsSubtotal: a.taxableItemsSubtotal,
|
|
65
66
|
taxableSubtotal: s
|
|
66
|
-
}),
|
|
67
|
+
}), u = a.subtotal - o;
|
|
67
68
|
return {
|
|
68
69
|
...a,
|
|
69
70
|
discountAmount: o,
|
|
70
|
-
discountedSubtotal:
|
|
71
|
+
discountedSubtotal: u,
|
|
71
72
|
taxableSubtotal: s,
|
|
72
73
|
nonTaxableSubtotal: c,
|
|
73
74
|
totalTaxes: l,
|
|
74
|
-
total:
|
|
75
|
+
total: u + l
|
|
75
76
|
};
|
|
76
77
|
}
|
|
77
|
-
function
|
|
78
|
-
return
|
|
79
|
-
lineItems: e.lineItems.filter((e) => !
|
|
78
|
+
function g(e) {
|
|
79
|
+
return h({
|
|
80
|
+
lineItems: e.lineItems.filter((e) => !n(e)),
|
|
80
81
|
currency: e.currency,
|
|
81
82
|
taxRate: Number(e.taxRate) || void 0,
|
|
82
|
-
keepSavedRate:
|
|
83
|
-
discount:
|
|
83
|
+
keepSavedRate: r(e.taxRate, e.savedTaxRate),
|
|
84
|
+
discount: c(e)
|
|
84
85
|
});
|
|
85
86
|
}
|
|
86
|
-
function
|
|
87
|
-
let n =
|
|
88
|
-
if (n) return n.type === "percentage" ? n.amount > 1e4 ? t.discountPercentageTooHigh : void 0 : n.amount >
|
|
89
|
-
}
|
|
90
|
-
function _(e, n) {
|
|
91
|
-
if (e.lineItems.filter((e) => !t(e)).some((t) => o(t.price, e.currency) > 9e15)) return;
|
|
92
|
-
let { subtotal: r, total: a } = h(e), s = i(e.currency);
|
|
93
|
-
if (r > 9e15) return n.invoiceSubtotalTooHigh.replace("{maxAmount}", s);
|
|
94
|
-
if (a > 9e15) return n.invoiceTotalTooHigh.replace("{maxAmount}", s);
|
|
87
|
+
function _(e, t) {
|
|
88
|
+
let n = c(e);
|
|
89
|
+
if (n) return n.type === "percentage" ? n.amount > 1e4 ? t.discountPercentageTooHigh : void 0 : n.amount > g(e).subtotal ? t.discountExceedsSubtotal : void 0;
|
|
95
90
|
}
|
|
96
91
|
function v(e, t) {
|
|
97
|
-
|
|
92
|
+
if (e.lineItems.filter((e) => !n(e)).some((t) => s(t.price, e.currency) > 9e15)) return;
|
|
93
|
+
let { subtotal: r, total: i } = g(e), o = a(e.currency);
|
|
94
|
+
if (r > 9e15) return t.invoiceSubtotalTooHigh.replace("{maxAmount}", o);
|
|
95
|
+
if (i > 9e15) return t.invoiceTotalTooHigh.replace("{maxAmount}", o);
|
|
98
96
|
}
|
|
99
97
|
function y(e, t) {
|
|
98
|
+
return g(e).total > 0 ? void 0 : t.invoiceTotalZero;
|
|
99
|
+
}
|
|
100
|
+
function b(e, t) {
|
|
100
101
|
let n = e.formatToParts(t), r = (e) => e.type !== "currency" && e.type !== "literal", i = n.findIndex(r);
|
|
101
102
|
if (i === -1) return e.format(t);
|
|
102
103
|
let a = n.length - 1;
|
|
@@ -104,23 +105,23 @@ function y(e, t) {
|
|
|
104
105
|
let o = (e) => e.map((e) => e.value).join("");
|
|
105
106
|
return `${o(n.slice(0, i))}(${o(n.slice(i, a + 1))})${o(n.slice(a + 1))}`;
|
|
106
107
|
}
|
|
107
|
-
function
|
|
108
|
-
let
|
|
108
|
+
function x(n, r, i = !1) {
|
|
109
|
+
let a = new Intl.NumberFormat(void 0, {
|
|
109
110
|
style: "currency",
|
|
110
|
-
currency:
|
|
111
|
-
currencyDisplay:
|
|
112
|
-
}),
|
|
113
|
-
return
|
|
111
|
+
currency: r,
|
|
112
|
+
currencyDisplay: t(r)
|
|
113
|
+
}), o = n / 10 ** e(r);
|
|
114
|
+
return i ? b(a, o) : a.format(o);
|
|
114
115
|
}
|
|
115
|
-
function
|
|
116
|
+
function S(e, t) {
|
|
116
117
|
return {
|
|
117
|
-
subtotal:
|
|
118
|
-
discount: e.discountAmount > 0 ?
|
|
119
|
-
nonTaxableSubtotal:
|
|
120
|
-
taxableSubtotal:
|
|
121
|
-
tax:
|
|
122
|
-
total:
|
|
118
|
+
subtotal: x(e.subtotal, t),
|
|
119
|
+
discount: e.discountAmount > 0 ? x(e.discountAmount, t, !0) : x(0, t),
|
|
120
|
+
nonTaxableSubtotal: x(e.nonTaxableSubtotal, t),
|
|
121
|
+
taxableSubtotal: x(e.taxableSubtotal, t),
|
|
122
|
+
tax: x(e.totalTaxes, t),
|
|
123
|
+
total: x(e.total, t)
|
|
123
124
|
};
|
|
124
125
|
}
|
|
125
126
|
//#endregion
|
|
126
|
-
export {
|
|
127
|
+
export { l as FULL_PERCENT_MINOR_UNITS, p as allocateDiscount, b as bracketAmount, S as buildFormTotalsView, g as calculateFormTotals, h as calculateInvoiceTotals, d as calculateItemsSubtotals, f as resolveDiscountAmount, _ as validateDiscount, v as validateInvoiceTotals, y as validateIssuableTotal };
|