@tesouro/embedded-components-react 0.7.64 → 0.7.66
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/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/shared/feature/dist/lib/analytics/build-info.js +1 -1
- package/package.json +1 -1
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { minorExponentForCurrency as e } from "../../../../../shared/util/dist/lib/amountOutputToMajorUnits.js";
|
|
2
|
+
import { currencyDisplayFor as t } from "./currencyDisplay.js";
|
|
2
3
|
//#region ../../libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/lineItems.js
|
|
3
|
-
var
|
|
4
|
-
function
|
|
4
|
+
var n = 9e15;
|
|
5
|
+
function r(e) {
|
|
5
6
|
let t = new Intl.NumberFormat(e), n = t.formatToParts(12345.67);
|
|
6
7
|
return {
|
|
7
8
|
decimal: n.find((e) => e.type === "decimal")?.value ?? ".",
|
|
@@ -9,91 +10,92 @@ function n(e) {
|
|
|
9
10
|
digits: Array.from({ length: 10 }, (e, n) => t.format(n))
|
|
10
11
|
};
|
|
11
12
|
}
|
|
12
|
-
function
|
|
13
|
+
function i(e) {
|
|
13
14
|
return e.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
14
15
|
}
|
|
15
|
-
function
|
|
16
|
+
function a(e) {
|
|
16
17
|
let t = e.replace(/[^0-9.]/g, ""), n = t.indexOf(".");
|
|
17
18
|
return n !== -1 && (t = t.slice(0, n + 1) + t.slice(n + 1).replace(/\./g, ""), t = t.slice(0, n + 3)), t;
|
|
18
19
|
}
|
|
19
|
-
function
|
|
20
|
+
function o(e) {
|
|
20
21
|
return e === "" || e === "." ? 0 : Number(e) || 0;
|
|
21
22
|
}
|
|
22
|
-
var
|
|
23
|
-
function
|
|
23
|
+
var s = (e) => Math.round(e * 100) / 100;
|
|
24
|
+
function c(t, n) {
|
|
24
25
|
let r = e(n);
|
|
25
26
|
return new Intl.NumberFormat(void 0, {
|
|
26
27
|
minimumFractionDigits: r,
|
|
27
28
|
maximumFractionDigits: r
|
|
28
29
|
}).format(t / 10 ** r);
|
|
29
30
|
}
|
|
30
|
-
function
|
|
31
|
-
return Math.round(
|
|
31
|
+
function l(t, n, i = r()) {
|
|
32
|
+
return Math.round(u(t, i) * 10 ** e(n));
|
|
32
33
|
}
|
|
33
|
-
function
|
|
34
|
+
function u(e, t = r()) {
|
|
34
35
|
if (e.trim() === "") return 0;
|
|
35
|
-
let
|
|
36
|
+
let n = Array.from(e, (e) => {
|
|
36
37
|
let n = t.digits.indexOf(e);
|
|
37
38
|
return n === -1 ? e : String(n);
|
|
38
39
|
}).join("");
|
|
39
|
-
t.group && (
|
|
40
|
-
let a = parseFloat(
|
|
40
|
+
t.group && (n = n.replace(new RegExp(i(t.group), "g"), "")), n = n.replace(t.decimal, ".");
|
|
41
|
+
let a = parseFloat(n);
|
|
41
42
|
return Number.isNaN(a) ? 0 : a;
|
|
42
43
|
}
|
|
43
|
-
function
|
|
44
|
-
let o =
|
|
45
|
-
return
|
|
44
|
+
function d(t, n, i, a = r()) {
|
|
45
|
+
let o = l(t, n, a) / 10 ** e(n);
|
|
46
|
+
return c(Math.round(o * 10 ** e(i)), i);
|
|
46
47
|
}
|
|
47
|
-
function
|
|
48
|
-
let t =
|
|
48
|
+
function f(e) {
|
|
49
|
+
let t = a(e);
|
|
49
50
|
return t.length > 1 && t.startsWith("0") && t[1] !== "." && (t = t.replace(/^0+/, "") || "0"), t === "" || t === "." ? t : Number(t) > 100 ? "100" : t;
|
|
50
51
|
}
|
|
51
|
-
function
|
|
52
|
+
function p(e) {
|
|
52
53
|
return e.endsWith(".") ? e.slice(0, -1) : e;
|
|
53
54
|
}
|
|
54
|
-
function
|
|
55
|
+
function m(e) {
|
|
55
56
|
return Math.round((Number(e) || 0) * 100);
|
|
56
57
|
}
|
|
57
|
-
function
|
|
58
|
-
return t !== void 0 &&
|
|
58
|
+
function h(e, t) {
|
|
59
|
+
return t !== void 0 && m(e) === m(t);
|
|
59
60
|
}
|
|
60
|
-
function
|
|
61
|
-
return n && e.savedTaxRate !== void 0 &&
|
|
61
|
+
function g(e, t, n) {
|
|
62
|
+
return n && e.savedTaxRate !== void 0 && _(e.savedTaxStatus) ? e.savedTaxRate : t;
|
|
62
63
|
}
|
|
63
|
-
function
|
|
64
|
+
function _(e) {
|
|
64
65
|
return (e ?? "taxable") === "taxable";
|
|
65
66
|
}
|
|
66
|
-
function
|
|
67
|
-
let t = e.find((e) =>
|
|
67
|
+
function v(e) {
|
|
68
|
+
let t = e.find((e) => _(e.tax_status))?.product.tax_rate?.value;
|
|
68
69
|
return t === void 0 ? "" : String(t / 100);
|
|
69
70
|
}
|
|
70
|
-
function
|
|
71
|
+
function y(e) {
|
|
71
72
|
try {
|
|
72
73
|
return new Intl.NumberFormat(void 0, {
|
|
73
74
|
style: "currency",
|
|
74
|
-
currency: e
|
|
75
|
+
currency: e,
|
|
76
|
+
currencyDisplay: t(e)
|
|
75
77
|
}).formatToParts(0).find((e) => e.type === "currency")?.value ?? e;
|
|
76
78
|
} catch {
|
|
77
79
|
return e;
|
|
78
80
|
}
|
|
79
81
|
}
|
|
80
|
-
function
|
|
82
|
+
function b() {
|
|
81
83
|
return typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID() : `${Date.now()}-${Math.random().toString(16).slice(2)}`;
|
|
82
84
|
}
|
|
83
|
-
function
|
|
85
|
+
function x(e = "USD") {
|
|
84
86
|
return {
|
|
85
|
-
id:
|
|
87
|
+
id: b(),
|
|
86
88
|
productId: "",
|
|
87
89
|
name: "",
|
|
88
90
|
quantity: "1",
|
|
89
|
-
price:
|
|
91
|
+
price: c(0, e),
|
|
90
92
|
measureUnitId: "",
|
|
91
93
|
measureUnitName: "",
|
|
92
94
|
productType: "product",
|
|
93
95
|
taxable: !0
|
|
94
96
|
};
|
|
95
97
|
}
|
|
96
|
-
function
|
|
98
|
+
function S({ id: e, name: t, quantity: n, price: r, measureUnitId: i, taxable: a }) {
|
|
97
99
|
return {
|
|
98
100
|
id: e,
|
|
99
101
|
name: t,
|
|
@@ -103,13 +105,13 @@ function x({ id: e, name: t, quantity: n, price: r, measureUnitId: i, taxable: a
|
|
|
103
105
|
taxable: a
|
|
104
106
|
};
|
|
105
107
|
}
|
|
106
|
-
function
|
|
108
|
+
function C(e) {
|
|
107
109
|
return !e.name.trim();
|
|
108
110
|
}
|
|
109
|
-
function
|
|
111
|
+
function w(e, t) {
|
|
110
112
|
let n = 0;
|
|
111
113
|
return e.map((e) => {
|
|
112
|
-
if (
|
|
114
|
+
if (C(e)) return e;
|
|
113
115
|
let r = t[n++]?.id;
|
|
114
116
|
return r ? {
|
|
115
117
|
...e,
|
|
@@ -117,17 +119,17 @@ function C(e, t) {
|
|
|
117
119
|
} : e;
|
|
118
120
|
});
|
|
119
121
|
}
|
|
120
|
-
function
|
|
121
|
-
let t = e.filter((e) => !
|
|
122
|
+
function T(e) {
|
|
123
|
+
let t = e.filter((e) => !C(e));
|
|
122
124
|
return t.length > 0 ? t : e.slice(0, 1);
|
|
123
125
|
}
|
|
124
|
-
function
|
|
126
|
+
function E({ product: e, currency: t, unitNamesById: n }) {
|
|
125
127
|
let r = e.measure_unit_id ?? "";
|
|
126
128
|
return {
|
|
127
129
|
productId: e.id,
|
|
128
130
|
name: e.name,
|
|
129
131
|
quantity: String(e.smallest_amount || 1),
|
|
130
|
-
price:
|
|
132
|
+
price: c(e.price?.value ?? 0, t),
|
|
131
133
|
productType: "product",
|
|
132
134
|
...r && n[r] ? {
|
|
133
135
|
measureUnitId: r,
|
|
@@ -135,19 +137,19 @@ function T({ product: e, currency: t, unitNamesById: n }) {
|
|
|
135
137
|
} : {}
|
|
136
138
|
};
|
|
137
139
|
}
|
|
138
|
-
function
|
|
140
|
+
function D(e) {
|
|
139
141
|
return e.quantity === void 0 ? e : {
|
|
140
142
|
...e,
|
|
141
|
-
quantity:
|
|
143
|
+
quantity: a(e.quantity)
|
|
142
144
|
};
|
|
143
145
|
}
|
|
144
|
-
function
|
|
146
|
+
function O({ lineItem: e, field: t, rowCount: n, currency: i, separators: u = r() }) {
|
|
145
147
|
if (t === "price") return {
|
|
146
148
|
kind: "update",
|
|
147
|
-
patch: { price:
|
|
149
|
+
patch: { price: c(l(e.price, i, u), i) }
|
|
148
150
|
};
|
|
149
|
-
let d = o(a(
|
|
150
|
-
return d <= 0 ?
|
|
151
|
+
let d = s(o(a(e.quantity)));
|
|
152
|
+
return d <= 0 ? n > 1 ? { kind: "remove" } : {
|
|
151
153
|
kind: "update",
|
|
152
154
|
patch: { quantity: "1" }
|
|
153
155
|
} : {
|
|
@@ -155,42 +157,42 @@ function D({ lineItem: e, field: t, rowCount: r, currency: l, separators: u = n(
|
|
|
155
157
|
patch: { quantity: String(d) }
|
|
156
158
|
};
|
|
157
159
|
}
|
|
158
|
-
function
|
|
159
|
-
if (
|
|
160
|
-
let r =
|
|
160
|
+
function k({ lineItem: e, step: t, rowCount: n }) {
|
|
161
|
+
if (C(e)) return;
|
|
162
|
+
let r = s(Math.max(0, o(e.quantity)) + t);
|
|
161
163
|
return r <= 0 && n > 1 ? { kind: "remove" } : {
|
|
162
164
|
kind: "update",
|
|
163
165
|
patch: { quantity: String(Math.max(n > 1 ? 0 : 1, r)) }
|
|
164
166
|
};
|
|
165
167
|
}
|
|
166
|
-
function
|
|
168
|
+
function A(e) {
|
|
167
169
|
return Object.fromEntries(e.map((t) => {
|
|
168
|
-
let n = !
|
|
170
|
+
let n = !C(t), r = o(t.quantity);
|
|
169
171
|
return [t.id, {
|
|
170
172
|
canDecreaseQuantity: n && (e.length > 1 || r > 1),
|
|
171
173
|
canIncreaseQuantity: n
|
|
172
174
|
}];
|
|
173
175
|
}));
|
|
174
176
|
}
|
|
175
|
-
function
|
|
177
|
+
function j(e, t, n = !1) {
|
|
176
178
|
return e.taxable ? {
|
|
177
179
|
tax_status: "taxable",
|
|
178
|
-
tax_rate_value:
|
|
180
|
+
tax_rate_value: g(e, m(t), n)
|
|
179
181
|
} : {
|
|
180
182
|
tax_status: e.savedTaxStatus === "exempt" ? "exempt" : "non_taxable",
|
|
181
183
|
tax_rate_value: void 0
|
|
182
184
|
};
|
|
183
185
|
}
|
|
184
|
-
function
|
|
185
|
-
let i = e.measureUnitId ? r[e.measureUnitId] : void 0, { tax_status:
|
|
186
|
+
function M({ lineItem: e, currency: t, taxRate: n, unitNamesById: r }) {
|
|
187
|
+
let i = e.measureUnitId ? r[e.measureUnitId] : void 0, { tax_status: a, tax_rate_value: s } = j(e, n);
|
|
186
188
|
return {
|
|
187
|
-
quantity:
|
|
188
|
-
tax_status:
|
|
189
|
+
quantity: o(e.quantity),
|
|
190
|
+
tax_status: a,
|
|
189
191
|
product: {
|
|
190
192
|
name: e.name,
|
|
191
193
|
price: {
|
|
192
194
|
currency: t,
|
|
193
|
-
value:
|
|
195
|
+
value: l(e.price, t)
|
|
194
196
|
},
|
|
195
197
|
measure_unit: i ? { name: i } : void 0,
|
|
196
198
|
type: "product"
|
|
@@ -198,52 +200,52 @@ function j({ lineItem: e, currency: t, taxRate: n, unitNamesById: r }) {
|
|
|
198
200
|
tax_rate_value: s
|
|
199
201
|
};
|
|
200
202
|
}
|
|
201
|
-
function
|
|
202
|
-
let
|
|
203
|
+
function N({ lineItem: e, currency: t, taxRate: n, keepSavedRate: r, unitNamesById: i }) {
|
|
204
|
+
let a = e.measureUnitId && i[e.measureUnitId] || e.measureUnitName || void 0, { tax_status: s, tax_rate_value: c } = j(e, n, r);
|
|
203
205
|
return {
|
|
204
|
-
quantity:
|
|
206
|
+
quantity: o(e.quantity),
|
|
205
207
|
tax_status: s,
|
|
206
208
|
product: {
|
|
207
209
|
name: e.name,
|
|
208
210
|
type: e.productType,
|
|
209
|
-
measure_unit:
|
|
211
|
+
measure_unit: a ? { name: a } : void 0,
|
|
210
212
|
price: {
|
|
211
213
|
currency: t,
|
|
212
|
-
value:
|
|
214
|
+
value: l(e.price, t)
|
|
213
215
|
}
|
|
214
216
|
},
|
|
215
|
-
tax_rate_value:
|
|
217
|
+
tax_rate_value: c,
|
|
216
218
|
discount: e.savedDiscount
|
|
217
219
|
};
|
|
218
220
|
}
|
|
219
|
-
function
|
|
221
|
+
function P({ lineItem: e, currency: t, units: n }) {
|
|
220
222
|
let r = e.product.measure_unit;
|
|
221
223
|
return {
|
|
222
224
|
id: e.id,
|
|
223
225
|
productId: e.product.id,
|
|
224
226
|
name: e.product.name,
|
|
225
227
|
quantity: String(e.quantity),
|
|
226
|
-
price:
|
|
227
|
-
measureUnitId:
|
|
228
|
+
price: c(e.product.price?.value ?? 0, t),
|
|
229
|
+
measureUnitId: I(r?.id ?? "", r?.name ?? "", n),
|
|
228
230
|
measureUnitName: r?.name ?? "",
|
|
229
231
|
productType: e.product.type ?? "product",
|
|
230
|
-
taxable:
|
|
232
|
+
taxable: _(e.tax_status),
|
|
231
233
|
savedTaxStatus: e.tax_status,
|
|
232
234
|
savedTaxRate: e.product.tax_rate?.value,
|
|
233
235
|
savedDiscount: e.discount ?? void 0
|
|
234
236
|
};
|
|
235
237
|
}
|
|
236
|
-
function
|
|
238
|
+
function F(e, t) {
|
|
237
239
|
if (!t) return;
|
|
238
240
|
let n = t.toLowerCase();
|
|
239
241
|
return e.find((e) => e.name.toLowerCase() === n);
|
|
240
242
|
}
|
|
241
|
-
function
|
|
242
|
-
return n?.length ? ((e ? n.find((t) => t.id === e) : void 0) ??
|
|
243
|
+
function I(e, t, n) {
|
|
244
|
+
return n?.length ? ((e ? n.find((t) => t.id === e) : void 0) ?? F(n, t))?.id ?? (t ? "" : e) : e;
|
|
243
245
|
}
|
|
244
|
-
function
|
|
246
|
+
function L(e, t) {
|
|
245
247
|
let n = !1, r = e.map((e) => {
|
|
246
|
-
let r =
|
|
248
|
+
let r = I(e.measureUnitId, e.measureUnitName, t);
|
|
247
249
|
return r === e.measureUnitId ? e : (n = !0, {
|
|
248
250
|
...e,
|
|
249
251
|
measureUnitId: r
|
|
@@ -251,19 +253,19 @@ function I(e, t) {
|
|
|
251
253
|
});
|
|
252
254
|
return n ? r : e;
|
|
253
255
|
}
|
|
254
|
-
function
|
|
255
|
-
return new Intl.NumberFormat().format(
|
|
256
|
+
function R(t) {
|
|
257
|
+
return new Intl.NumberFormat().format(n / 10 ** e(t));
|
|
256
258
|
}
|
|
257
|
-
var
|
|
258
|
-
function
|
|
259
|
+
var z = .1;
|
|
260
|
+
function B(e, { currency: t, messages: n, requireComplete: r = !1 }) {
|
|
259
261
|
let i = {};
|
|
260
|
-
for (let
|
|
262
|
+
for (let a of e) {
|
|
261
263
|
let e = {};
|
|
262
|
-
r &&
|
|
264
|
+
r && C(a) && (e.name = n.lineItemNameRequired), r && o(a.quantity) < z && (e.quantity = n.lineItemQuantityRequired), a.name.length > 100 && (e.name = n.lineItemNameTooLong), l(a.price, t) > 9e15 && (e.price = n.lineItemPriceTooHigh.replace("{maxAmount}", R(t))), Object.keys(e).length > 0 && (i[a.id] = e);
|
|
263
265
|
}
|
|
264
266
|
return Object.keys(i).length > 0 ? i : void 0;
|
|
265
267
|
}
|
|
266
|
-
function
|
|
268
|
+
function V(e, t, n) {
|
|
267
269
|
let r = Object.values(e ?? {}), i = [
|
|
268
270
|
n,
|
|
269
271
|
t,
|
|
@@ -277,4 +279,4 @@ function B(e, t, n) {
|
|
|
277
279
|
return i.length > 0 ? i : void 0;
|
|
278
280
|
}
|
|
279
281
|
//#endregion
|
|
280
|
-
export {
|
|
282
|
+
export { n as MAX_AMOUNT_MINOR_UNITS, A as buildLineItemControls, O as commitLineItemField, p as commitTaxRateInput, d as convertPriceInput, x as createLineItem, i as escapeRegex, c as formatPriceInput, y as getCurrencySymbol, r as getNumberSeparators, C as isBlankLineItem, _ as isLineItemTaxable, h as keepsSavedTaxRates, E as lineItemFromProduct, g as lineItemTaxRateMinorUnits, M as lineItemToCreatePayload, N as lineItemToUpdatePayload, R as maxAmountLabel, u as parseLocaleDecimal, o as parseQuantity, l as priceInputToMinorUnits, w as reconcileLineItemIds, L as reconcileMeasureUnits, P as responseLineItemToFormValues, D as sanitizeLineItemPatch, a as sanitizeQuantityInput, f as sanitizeTaxRateInput, k as stepLineItemQuantity, T as stripBlankLineItems, V as summarizeLineItemErrors, v as taxRateFromLineItems, m as taxRateToMinorUnits, S as toSheetLineItem, B as validateLineItems };
|
|
@@ -1,97 +1,98 @@
|
|
|
1
1
|
import { minorExponentForCurrency as e } from "../../../../../shared/util/dist/lib/amountOutputToMajorUnits.js";
|
|
2
2
|
import "../../../../ui/dist/index20.js";
|
|
3
3
|
import "../../../../ui/dist/index.js";
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
4
|
+
import { currencyDisplayFor as t } from "./currencyDisplay.js";
|
|
5
|
+
import { isBlankLineItem as n, keepsSavedTaxRates as r, lineItemTaxRateMinorUnits as i, parseQuantity as a, priceInputToMinorUnits as o, taxRateToMinorUnits as s } from "./lineItems.js";
|
|
6
|
+
import { formatPreviewDate as c, resolveIssueDate as l, termDueDate as u } from "./paymentTerms.js";
|
|
7
|
+
import { bracketAmount as d } from "./totals.js";
|
|
8
|
+
import { formatMoney as f } from "./helpers.js";
|
|
9
|
+
import { differenceInCalendarDays as p, parseISO as m } from "date-fns";
|
|
9
10
|
//#region ../../libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/preview.js
|
|
10
|
-
var
|
|
11
|
-
function g(e) {
|
|
12
|
-
return (e ?? []).filter(({ status: e, direction: t }) => e === "active" && t === "receive");
|
|
13
|
-
}
|
|
11
|
+
var h = "US", g = 100;
|
|
14
12
|
function _(e) {
|
|
15
|
-
return
|
|
13
|
+
return (e ?? []).filter(({ status: e, direction: t }) => e === "active" && t === "receive");
|
|
16
14
|
}
|
|
17
15
|
function v(e) {
|
|
18
|
-
return e
|
|
16
|
+
return _(e).length > 0;
|
|
19
17
|
}
|
|
20
18
|
function y(e) {
|
|
19
|
+
return e?.invoice?.display_organization_bank_account ?? e?.display_organization_bank_account ?? !0;
|
|
20
|
+
}
|
|
21
|
+
function b(e) {
|
|
21
22
|
try {
|
|
22
23
|
return new Intl.DisplayNames(void 0, { type: "region" }).of(e) ?? e;
|
|
23
24
|
} catch {
|
|
24
25
|
return e;
|
|
25
26
|
}
|
|
26
27
|
}
|
|
27
|
-
function
|
|
28
|
+
function x({ address: e, issuerCountry: t, formatCountry: n = b }) {
|
|
28
29
|
if (!e) return [];
|
|
29
|
-
let r = [e.city, e.state].filter(Boolean).join(", "), i = e.country ===
|
|
30
|
+
let r = [e.city, e.state].filter(Boolean).join(", "), i = e.country === h && t === h;
|
|
30
31
|
return [
|
|
31
32
|
[e.line1, e.line2].filter(Boolean).join(" "),
|
|
32
33
|
[r, e.postal_code].filter(Boolean).join(" "),
|
|
33
34
|
e.country && !i ? n(e.country) : ""
|
|
34
35
|
].filter(Boolean);
|
|
35
36
|
}
|
|
36
|
-
var
|
|
37
|
+
var S = { kind: "pending" }, C = (e) => ({
|
|
37
38
|
kind: "text",
|
|
38
39
|
lines: e
|
|
39
40
|
});
|
|
40
|
-
function
|
|
41
|
+
function w(e, t) {
|
|
41
42
|
return e.previewNetDays.replace("{days}", String(t));
|
|
42
43
|
}
|
|
43
|
-
function
|
|
44
|
+
function T(e, t) {
|
|
44
45
|
let n = e.previewEarlyPaymentDays.replace("{days}", String(t.number_of_days));
|
|
45
|
-
return t.discount ? `${n}, ${e.previewEarlyPaymentDiscount.replace("{rate}", String(t.discount /
|
|
46
|
+
return t.discount ? `${n}, ${e.previewEarlyPaymentDiscount.replace("{rate}", String(t.discount / g))}` : n;
|
|
46
47
|
}
|
|
47
|
-
function
|
|
48
|
+
function E({ paymentTermsId: e, paymentTermsCustomDate: t, paymentTerms: n, issueDate: r, messages: i }) {
|
|
48
49
|
let a = {
|
|
49
|
-
dueDate:
|
|
50
|
-
paymentTerms:
|
|
50
|
+
dueDate: S,
|
|
51
|
+
paymentTerms: S
|
|
51
52
|
};
|
|
52
53
|
if (e === "custom") {
|
|
53
54
|
if (!t) return a;
|
|
54
|
-
let e =
|
|
55
|
+
let e = m(t), n = Math.max(0, p(e, r));
|
|
55
56
|
return {
|
|
56
|
-
dueDate:
|
|
57
|
-
paymentTerms:
|
|
57
|
+
dueDate: C([c(e)]),
|
|
58
|
+
paymentTerms: C([w(i, n)])
|
|
58
59
|
};
|
|
59
60
|
}
|
|
60
61
|
if (e === "receipt_due") return {
|
|
61
|
-
dueDate:
|
|
62
|
-
paymentTerms:
|
|
62
|
+
dueDate: C([c(r)]),
|
|
63
|
+
paymentTerms: C([i.previewDueOnReceipt])
|
|
63
64
|
};
|
|
64
65
|
let o = n?.find((t) => t.id === e);
|
|
65
66
|
if (!o) return a;
|
|
66
|
-
let
|
|
67
|
-
o.term_1 &&
|
|
68
|
-
o.term_2 &&
|
|
69
|
-
o.term_final &&
|
|
67
|
+
let s = u(o, r), l = [
|
|
68
|
+
o.term_1 && T(i, o.term_1),
|
|
69
|
+
o.term_2 && T(i, o.term_2),
|
|
70
|
+
o.term_final && w(i, o.term_final.number_of_days)
|
|
70
71
|
].filter((e) => !!e);
|
|
71
72
|
return {
|
|
72
|
-
dueDate:
|
|
73
|
-
paymentTerms:
|
|
73
|
+
dueDate: s ? C([c(s)]) : S,
|
|
74
|
+
paymentTerms: l.length > 0 ? C(l) : S
|
|
74
75
|
};
|
|
75
76
|
}
|
|
76
|
-
function
|
|
77
|
+
function D(e, t) {
|
|
77
78
|
return t ? e.previewTaxId.replace("{taxId}", t) : void 0;
|
|
78
79
|
}
|
|
79
|
-
function
|
|
80
|
+
function O(e) {
|
|
80
81
|
return e.length > 0 ? e : void 0;
|
|
81
82
|
}
|
|
82
|
-
function
|
|
83
|
+
function k(e, t) {
|
|
83
84
|
return e ? {
|
|
84
85
|
name: e.type === "organization" ? e.organization.legal_name : void 0,
|
|
85
|
-
addressLines:
|
|
86
|
+
addressLines: O(x({
|
|
86
87
|
address: e.address,
|
|
87
88
|
issuerCountry: e.address?.country
|
|
88
89
|
})),
|
|
89
|
-
taxIdLine:
|
|
90
|
+
taxIdLine: D(t, e.tax_id),
|
|
90
91
|
email: e.email ?? void 0,
|
|
91
92
|
phone: e.phone ?? void 0
|
|
92
93
|
} : {};
|
|
93
94
|
}
|
|
94
|
-
function
|
|
95
|
+
function A(e) {
|
|
95
96
|
let t = "organization" in e ? e.organization : e.individual;
|
|
96
97
|
return {
|
|
97
98
|
name: "organization" in e ? e.organization.legal_name : [e.individual.first_name, e.individual.last_name].filter(Boolean).join(" "),
|
|
@@ -99,56 +100,57 @@ function k(e) {
|
|
|
99
100
|
phone: t.phone
|
|
100
101
|
};
|
|
101
102
|
}
|
|
102
|
-
function
|
|
103
|
+
function j({ counterpart: e, billingAddress: t, issuerCountry: n, messages: r }) {
|
|
103
104
|
if (!e) return { kind: "pending" };
|
|
104
|
-
let { name: i, email: a, phone: o } =
|
|
105
|
+
let { name: i, email: a, phone: o } = A(e);
|
|
105
106
|
return i ? {
|
|
106
107
|
kind: "party",
|
|
107
108
|
name: i,
|
|
108
|
-
addressLines:
|
|
109
|
+
addressLines: O(x({
|
|
109
110
|
address: t,
|
|
110
111
|
issuerCountry: n
|
|
111
112
|
})),
|
|
112
|
-
taxIdLine:
|
|
113
|
+
taxIdLine: D(r, e.tax_id),
|
|
113
114
|
email: a || void 0,
|
|
114
115
|
phone: o || void 0
|
|
115
116
|
} : { kind: "pending" };
|
|
116
117
|
}
|
|
117
|
-
function
|
|
118
|
-
return e.filter((e) => !
|
|
119
|
-
let
|
|
118
|
+
function M({ lineItems: e, currency: t, unitNamesById: r, messages: i }) {
|
|
119
|
+
return e.filter((e) => !n(e)).map((e) => {
|
|
120
|
+
let n = o(e.price, t), s = a(e.quantity), c = r[e.measureUnitId] || e.measureUnitName;
|
|
120
121
|
return {
|
|
121
122
|
id: e.id,
|
|
122
123
|
name: e.name,
|
|
123
124
|
quantity: String(s),
|
|
124
|
-
price:
|
|
125
|
-
amount:
|
|
126
|
-
currency:
|
|
125
|
+
price: f({
|
|
126
|
+
amount: n,
|
|
127
|
+
currency: t,
|
|
127
128
|
fallback: ""
|
|
128
129
|
}),
|
|
129
130
|
...c ? { unit: c } : {},
|
|
130
|
-
taxable: e.taxable ?
|
|
131
|
-
amount:
|
|
132
|
-
amount: Math.round(
|
|
133
|
-
currency:
|
|
131
|
+
taxable: e.taxable ? i.previewTaxableYes : i.previewTaxableNo,
|
|
132
|
+
amount: f({
|
|
133
|
+
amount: Math.round(n * s),
|
|
134
|
+
currency: t,
|
|
134
135
|
fallback: ""
|
|
135
136
|
})
|
|
136
137
|
};
|
|
137
138
|
});
|
|
138
139
|
}
|
|
139
|
-
function
|
|
140
|
-
return
|
|
140
|
+
function N(n, r) {
|
|
141
|
+
return r ? d(new Intl.NumberFormat(void 0, {
|
|
141
142
|
style: "currency",
|
|
142
|
-
currency:
|
|
143
|
-
|
|
143
|
+
currency: r,
|
|
144
|
+
currencyDisplay: t(r)
|
|
145
|
+
}), n / 10 ** e(r)) : "";
|
|
144
146
|
}
|
|
145
|
-
function
|
|
146
|
-
if (!e.taxRate) return
|
|
147
|
-
let a =
|
|
148
|
-
return new Set(e.lineItems.filter((e) => e.taxable && !
|
|
147
|
+
function P(e, t) {
|
|
148
|
+
if (!e.taxRate) return t.previewTax;
|
|
149
|
+
let a = s(e.taxRate), o = r(e.taxRate, e.savedTaxRate);
|
|
150
|
+
return new Set(e.lineItems.filter((e) => e.taxable && !n(e)).map((e) => i(e, a, o))).size > 1 ? t.previewTax : t.previewTaxWithRate.replace("{rate}", String(a / g));
|
|
149
151
|
}
|
|
150
|
-
function
|
|
151
|
-
let i = (e) =>
|
|
152
|
+
function F({ totals: e, currency: t, taxLabel: n, messages: r }) {
|
|
153
|
+
let i = (e) => f({
|
|
152
154
|
amount: e,
|
|
153
155
|
currency: t,
|
|
154
156
|
fallback: ""
|
|
@@ -160,7 +162,7 @@ function P({ totals: e, currency: t, taxLabel: n, messages: r }) {
|
|
|
160
162
|
return a && c.push({
|
|
161
163
|
id: "discount",
|
|
162
164
|
label: r.previewDiscount,
|
|
163
|
-
value:
|
|
165
|
+
value: N(e.discountAmount, t)
|
|
164
166
|
}), s && (o || a) && c.push({
|
|
165
167
|
id: "nonTaxableSubtotal",
|
|
166
168
|
label: r.previewNonTaxableSubtotal,
|
|
@@ -183,7 +185,7 @@ function P({ totals: e, currency: t, taxLabel: n, messages: r }) {
|
|
|
183
185
|
}
|
|
184
186
|
};
|
|
185
187
|
}
|
|
186
|
-
function
|
|
188
|
+
function I({ bankDetails: e, canReceivePayments: t, messages: n }) {
|
|
187
189
|
let r = e ? [
|
|
188
190
|
[n.previewAccountHolderName, e.accountHolderName],
|
|
189
191
|
[n.previewRoutingNumber, e.routingNumber],
|
|
@@ -194,13 +196,13 @@ function F({ bankDetails: e, canReceivePayments: t, messages: n }) {
|
|
|
194
196
|
bankLines: r
|
|
195
197
|
};
|
|
196
198
|
}
|
|
197
|
-
function
|
|
198
|
-
let p =
|
|
199
|
+
function L({ values: e, totals: t, entity: n, counterpart: r, billingAddress: i, paymentTerms: a, unitNamesById: o, bankDetails: s, canReceivePayments: u = !1, messages: d, today: f = /* @__PURE__ */ new Date() }) {
|
|
200
|
+
let p = M({
|
|
199
201
|
lineItems: e.lineItems,
|
|
200
202
|
currency: e.currency,
|
|
201
203
|
unitNamesById: o,
|
|
202
204
|
messages: d
|
|
203
|
-
}), m = n?.logo?.url, h =
|
|
205
|
+
}), m = n?.logo?.url, h = k(n, d), g = l(e.issueDate, f);
|
|
204
206
|
return {
|
|
205
207
|
issuer: h,
|
|
206
208
|
logo: m ? {
|
|
@@ -208,15 +210,15 @@ function I({ values: e, totals: t, entity: n, counterpart: r, billingAddress: i,
|
|
|
208
210
|
src: m,
|
|
209
211
|
alt: h.name ? d.previewLogoAlt.replace("{name}", h.name) : d.previewLogoAltNoName
|
|
210
212
|
} : { kind: "placeholder" },
|
|
211
|
-
billTo:
|
|
213
|
+
billTo: j({
|
|
212
214
|
counterpart: r,
|
|
213
215
|
billingAddress: i,
|
|
214
216
|
issuerCountry: n?.address?.country,
|
|
215
217
|
messages: d
|
|
216
218
|
}),
|
|
217
|
-
invoiceNumber:
|
|
218
|
-
issueDate:
|
|
219
|
-
...
|
|
219
|
+
invoiceNumber: S,
|
|
220
|
+
issueDate: c(g),
|
|
221
|
+
...E({
|
|
220
222
|
paymentTermsId: e.paymentTermsId,
|
|
221
223
|
paymentTermsCustomDate: e.paymentTermsCustomDate,
|
|
222
224
|
paymentTerms: a,
|
|
@@ -229,19 +231,19 @@ function I({ values: e, totals: t, entity: n, counterpart: r, billingAddress: i,
|
|
|
229
231
|
kind: "rows",
|
|
230
232
|
rows: p
|
|
231
233
|
} : { kind: "empty" },
|
|
232
|
-
totals: p.length > 0 ?
|
|
234
|
+
totals: p.length > 0 ? F({
|
|
233
235
|
totals: t,
|
|
234
236
|
currency: e.currency,
|
|
235
|
-
taxLabel:
|
|
237
|
+
taxLabel: P(e, d),
|
|
236
238
|
messages: d
|
|
237
239
|
}) : void 0,
|
|
238
240
|
closingNote: e.closingNote || void 0,
|
|
239
|
-
payment:
|
|
240
|
-
bankDetails:
|
|
241
|
+
payment: I({
|
|
242
|
+
bankDetails: s,
|
|
241
243
|
canReceivePayments: u,
|
|
242
244
|
messages: d
|
|
243
245
|
})
|
|
244
246
|
};
|
|
245
247
|
}
|
|
246
248
|
//#endregion
|
|
247
|
-
export {
|
|
249
|
+
export { x as buildPreviewAddressLines, E as buildPreviewPaymentTerms, L as buildReceivablePreviewView, y as displaysBankAccount, b as formatCountryName, N as formatDeduction, _ as getReceivePaymentMethods, v as hasReceivePaymentMethod };
|