@tesouro/embedded-components-react 0.5.231 → 0.5.233
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 -0
- package/dist/index.css +4 -0
- package/dist/index.d.ts +105 -2
- package/dist/index.js +1 -1
- package/dist/lib/ReceivablesWidget.d.ts +105 -2
- package/dist/lib/ReceivablesWidget.js +1 -1
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index.js +11 -10
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index10.js +92 -55
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index11.js +67 -142
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index12.js +186 -17
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index13.js +27 -0
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index3.js +45 -74
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index4.js +68 -53
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index5.js +66 -32
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index6.js +28 -34
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index7.js +24 -166
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index8.js +177 -1
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index9.js +42 -95
- 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 +36 -33
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index14.js +38 -0
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index16.js +1 -1
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index17.js +206 -147
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index18.js +2 -2
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index19.js +39 -58
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index20.js +53 -227
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index21.js +216 -287
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index22.js +453 -43
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index23.js +103 -126
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index24.js +122 -146
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index25.js +145 -41
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index26.js +39 -115
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index27.js +113 -90
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index28.js +81 -98
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index29.js +111 -27
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index30.js +26 -633
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index31.js +639 -39
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index32.js +41 -40
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index33.js +35 -74
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index34.js +73 -130
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index35.js +133 -329
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index36.js +345 -0
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index.js +13 -12
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index10.js +15 -12
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index19.js +35 -24
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index21.js +8 -71
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index22.js +70 -17
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index23.js +31 -12
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index24.js +18 -30
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index25.js +12 -301
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index26.js +33 -1
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index27.js +14 -46
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index28.js +23 -67
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index29.js +76 -485
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index30.js +395 -95
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index31.js +2 -0
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index32.js +48 -2
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index33.js +72 -4
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index34.js +496 -1
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index35.js +97 -91
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index37.js +2 -236
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index38.js +3 -2
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index39.js +1 -249
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index40.js +89 -82
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index41.js +23 -54
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index42.js +223 -340
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index43.js +3 -0
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index44.js +249 -0
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index45.js +93 -0
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index46.js +59 -0
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index47.js +353 -0
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index9.js +18 -1
- package/dist/libs/tesouro-embedded-components-react/shared/data-access/dist/index.js +41 -41
- package/dist/libs/tesouro-embedded-components-react/shared/data-access/dist/lib/clientRegistry.js +6 -3
- package/dist/libs/tesouro-embedded-components-react/shared/data-access/dist/lib/rest/sdk.gen.js +75 -43
- package/dist/libs/tesouro-embedded-components-react/shared/feature/dist/lib/analytics/build-info.js +1 -1
- package/package.json +1 -1
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index36.js +0 -28
package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index21.js
CHANGED
|
@@ -1,308 +1,237 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
1
|
+
import { minorExponentForCurrency as e } from "../../../shared/util/dist/lib/amountOutputToMajorUnits.js";
|
|
2
|
+
import "../../ui/dist/index15.js";
|
|
3
|
+
import "../../ui/dist/index.js";
|
|
4
|
+
import { isBlankLineItem as t, keepsSavedTaxRates as n, lineItemTaxRateMinorUnits as r, parseQuantity as i, priceInputToMinorUnits as a, taxRateToMinorUnits as o } from "./index6.js";
|
|
5
|
+
import { formatTermDate as s, resolveIssueDate as c, termDueDate as l } from "./index10.js";
|
|
6
|
+
import { formatMoney as u } from "./index13.js";
|
|
7
|
+
import { differenceInCalendarDays as d, parseISO as f } from "date-fns";
|
|
7
8
|
//#region ../../libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index21.js
|
|
8
|
-
var
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
primary: ["send", "recordPayment"],
|
|
15
|
-
overflow: ["clone", "cancel"]
|
|
16
|
-
},
|
|
17
|
-
overdue: {
|
|
18
|
-
primary: ["send", "recordPayment"],
|
|
19
|
-
overflow: [
|
|
20
|
-
"clone",
|
|
21
|
-
"cancel",
|
|
22
|
-
"markUncollectible"
|
|
23
|
-
]
|
|
24
|
-
},
|
|
25
|
-
partially_paid: {
|
|
26
|
-
primary: ["send", "recordPayment"],
|
|
27
|
-
overflow: ["clone"]
|
|
28
|
-
},
|
|
29
|
-
paid: {
|
|
30
|
-
primary: [],
|
|
31
|
-
overflow: ["clone"]
|
|
32
|
-
},
|
|
33
|
-
canceled: {
|
|
34
|
-
primary: [],
|
|
35
|
-
overflow: ["clone"]
|
|
36
|
-
},
|
|
37
|
-
uncollectible: {
|
|
38
|
-
primary: [],
|
|
39
|
-
overflow: ["clone"]
|
|
40
|
-
},
|
|
41
|
-
recurring: {
|
|
42
|
-
primary: [],
|
|
43
|
-
overflow: []
|
|
9
|
+
var p = "US", m = 100;
|
|
10
|
+
function h(e) {
|
|
11
|
+
try {
|
|
12
|
+
return new Intl.DisplayNames(void 0, { type: "region" }).of(e) ?? e;
|
|
13
|
+
} catch {
|
|
14
|
+
return e;
|
|
44
15
|
}
|
|
45
|
-
}, d = {
|
|
46
|
-
draft: "neutral",
|
|
47
|
-
issuing: "info",
|
|
48
|
-
issued: "info",
|
|
49
|
-
partially_paid: "info",
|
|
50
|
-
accepted: "success",
|
|
51
|
-
paid: "success",
|
|
52
|
-
failed: "danger",
|
|
53
|
-
expired: "danger",
|
|
54
|
-
declined: "danger",
|
|
55
|
-
overdue: "danger",
|
|
56
|
-
canceled: "neutral",
|
|
57
|
-
uncollectible: "neutral",
|
|
58
|
-
recurring: "neutral",
|
|
59
|
-
deleted: "neutral"
|
|
60
|
-
};
|
|
61
|
-
function f(e, t = /* @__PURE__ */ new Date()) {
|
|
62
|
-
if (!e) return 0;
|
|
63
|
-
let n = new Date(e);
|
|
64
|
-
if (Number.isNaN(n.getTime())) return 0;
|
|
65
|
-
let r = Date.UTC(t.getUTCFullYear(), t.getUTCMonth(), t.getUTCDate()), i = Date.UTC(n.getUTCFullYear(), n.getUTCMonth(), n.getUTCDate()), a = Math.floor((r - i) / 864e5);
|
|
66
|
-
return a > 0 ? a : 0;
|
|
67
16
|
}
|
|
68
|
-
function
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
17
|
+
function g({ address: e, issuerCountry: t, formatCountry: n = h }) {
|
|
18
|
+
if (!e) return [];
|
|
19
|
+
let r = [e.city, e.state].filter(Boolean).join(", "), i = e.country === p && t === p;
|
|
20
|
+
return [
|
|
21
|
+
[e.line1, e.line2].filter(Boolean).join(" "),
|
|
22
|
+
[r, e.postal_code].filter(Boolean).join(" "),
|
|
23
|
+
e.country && !i ? n(e.country) : ""
|
|
24
|
+
].filter(Boolean);
|
|
73
25
|
}
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
return i.length > 0 && o.push(`${p(i, r)} ${r.detailsRemindersBefore}`), a.length > 0 && o.push(`${p(a, r)} ${r.detailsRemindersAfter}`), o.length > 0 ? o.join("\n") : n ? "-" : r.detailsRemindersNone;
|
|
26
|
+
var _ = { kind: "pending" }, v = (e) => ({
|
|
27
|
+
kind: "text",
|
|
28
|
+
lines: e
|
|
29
|
+
});
|
|
30
|
+
function y(e, t) {
|
|
31
|
+
return e.previewNetDays.replace("{days}", String(t));
|
|
81
32
|
}
|
|
82
|
-
function
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
return [
|
|
86
|
-
e.line2 ? `${e.line1} ${e.line2}` : e.line1,
|
|
87
|
-
t,
|
|
88
|
-
e.country ? c(e.country) : void 0
|
|
89
|
-
].filter(Boolean).join(", ");
|
|
33
|
+
function b(e, t) {
|
|
34
|
+
let n = e.previewEarlyPaymentDays.replace("{days}", String(t.number_of_days));
|
|
35
|
+
return t.discount ? `${n}, ${e.previewEarlyPaymentDiscount.replace("{rate}", String(t.discount / m))}` : n;
|
|
90
36
|
}
|
|
91
|
-
function
|
|
92
|
-
let
|
|
93
|
-
|
|
94
|
-
|
|
37
|
+
function x({ paymentTermsId: e, paymentTermsCustomDate: t, paymentTerms: n, issueDate: r, messages: i }) {
|
|
38
|
+
let a = {
|
|
39
|
+
dueDate: _,
|
|
40
|
+
paymentTerms: _
|
|
95
41
|
};
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
value: t(e.amount_due),
|
|
103
|
-
emphasis: !0
|
|
104
|
-
}, ...e.amount_paid > 0 ? [{
|
|
105
|
-
...r,
|
|
106
|
-
tone: "success"
|
|
107
|
-
}] : []]
|
|
108
|
-
};
|
|
109
|
-
case "partially_paid": return {
|
|
110
|
-
amountTone: "default",
|
|
111
|
-
amountRows: [{
|
|
112
|
-
label: n.detailsBalanceDue,
|
|
113
|
-
value: t(e.amount_due),
|
|
114
|
-
emphasis: !0
|
|
115
|
-
}, {
|
|
116
|
-
...r,
|
|
117
|
-
tone: "success"
|
|
118
|
-
}]
|
|
119
|
-
};
|
|
120
|
-
case "paid": return {
|
|
121
|
-
amountTone: "success",
|
|
122
|
-
amountRows: [{
|
|
123
|
-
...r,
|
|
124
|
-
emphasis: !0
|
|
125
|
-
}]
|
|
126
|
-
};
|
|
127
|
-
case "canceled": return {
|
|
128
|
-
amountTone: "muted",
|
|
129
|
-
amountRows: [{
|
|
130
|
-
label: n.detailsCancelledAmount,
|
|
131
|
-
value: t(e.total_amount),
|
|
132
|
-
emphasis: !0
|
|
133
|
-
}]
|
|
134
|
-
};
|
|
135
|
-
case "uncollectible": return {
|
|
136
|
-
amountTone: "muted",
|
|
137
|
-
amountRows: [{
|
|
138
|
-
label: n.detailsAmountWrittenOff,
|
|
139
|
-
value: t(e.amount_due),
|
|
140
|
-
emphasis: !0
|
|
141
|
-
}]
|
|
142
|
-
};
|
|
143
|
-
default: return {
|
|
144
|
-
amountTone: "default",
|
|
145
|
-
amountRows: [{
|
|
146
|
-
label: n.detailsInvoiceAmount,
|
|
147
|
-
value: t(e.total_amount),
|
|
148
|
-
emphasis: !0
|
|
149
|
-
}]
|
|
42
|
+
if (e === "custom") {
|
|
43
|
+
if (!t) return a;
|
|
44
|
+
let e = f(t), n = Math.max(0, d(e, r));
|
|
45
|
+
return {
|
|
46
|
+
dueDate: v([s(e)]),
|
|
47
|
+
paymentTerms: v([y(i, n)])
|
|
150
48
|
};
|
|
151
49
|
}
|
|
50
|
+
if (e === "receipt_due") return {
|
|
51
|
+
dueDate: v([s(r)]),
|
|
52
|
+
paymentTerms: v([i.previewDueOnReceipt])
|
|
53
|
+
};
|
|
54
|
+
let o = n?.find((t) => t.id === e);
|
|
55
|
+
if (!o) return a;
|
|
56
|
+
let c = l(o, r), u = [
|
|
57
|
+
o.term_1 && b(i, o.term_1),
|
|
58
|
+
o.term_2 && b(i, o.term_2),
|
|
59
|
+
o.term_final && y(i, o.term_final.number_of_days)
|
|
60
|
+
].filter((e) => !!e);
|
|
61
|
+
return {
|
|
62
|
+
dueDate: c ? v([s(c)]) : _,
|
|
63
|
+
paymentTerms: u.length > 0 ? v(u) : _
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
function S(e, t) {
|
|
67
|
+
return t ? e.previewTaxId.replace("{taxId}", t) : void 0;
|
|
152
68
|
}
|
|
153
|
-
function
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
69
|
+
function C(e) {
|
|
70
|
+
return e.length > 0 ? e : void 0;
|
|
71
|
+
}
|
|
72
|
+
function w(e, t) {
|
|
73
|
+
return e ? {
|
|
74
|
+
name: e.type === "organization" ? e.organization.legal_name : void 0,
|
|
75
|
+
addressLines: C(g({
|
|
76
|
+
address: e.address,
|
|
77
|
+
issuerCountry: e.address?.country
|
|
78
|
+
})),
|
|
79
|
+
taxIdLine: S(t, e.tax_id),
|
|
80
|
+
email: e.email ?? void 0,
|
|
81
|
+
phone: e.phone ?? void 0
|
|
82
|
+
} : {};
|
|
83
|
+
}
|
|
84
|
+
function T(e) {
|
|
85
|
+
let t = "organization" in e ? e.organization : e.individual;
|
|
86
|
+
return {
|
|
87
|
+
name: "organization" in e ? e.organization.legal_name : [e.individual.first_name, e.individual.last_name].filter(Boolean).join(" "),
|
|
88
|
+
email: t.email,
|
|
89
|
+
phone: t.phone
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
function E({ counterpart: e, billingAddress: t, issuerCountry: n, messages: r }) {
|
|
93
|
+
if (!e) return { kind: "pending" };
|
|
94
|
+
let { name: i, email: a, phone: o } = T(e);
|
|
95
|
+
return i ? {
|
|
96
|
+
kind: "party",
|
|
97
|
+
name: i,
|
|
98
|
+
addressLines: C(g({
|
|
99
|
+
address: t,
|
|
100
|
+
issuerCountry: n
|
|
101
|
+
})),
|
|
102
|
+
taxIdLine: S(r, e.tax_id),
|
|
103
|
+
email: a || void 0,
|
|
104
|
+
phone: o || void 0
|
|
105
|
+
} : { kind: "pending" };
|
|
106
|
+
}
|
|
107
|
+
function D({ lineItems: e, currency: n, unitNamesById: r, messages: o }) {
|
|
108
|
+
return e.filter((e) => !t(e)).map((e) => {
|
|
109
|
+
let t = a(e.price, n), s = i(e.quantity), c = r[e.measureUnitId] || e.measureUnitName;
|
|
110
|
+
return {
|
|
111
|
+
id: e.id,
|
|
112
|
+
name: e.name,
|
|
113
|
+
quantity: String(s),
|
|
114
|
+
price: u({
|
|
115
|
+
amount: t,
|
|
116
|
+
currency: n,
|
|
117
|
+
fallback: ""
|
|
118
|
+
}),
|
|
119
|
+
...c ? { unit: c } : {},
|
|
120
|
+
taxable: e.taxable ? o.previewTaxableYes : o.previewTaxableNo,
|
|
121
|
+
amount: u({
|
|
122
|
+
amount: Math.round(t * s),
|
|
123
|
+
currency: n,
|
|
124
|
+
fallback: ""
|
|
125
|
+
})
|
|
162
126
|
};
|
|
163
|
-
}, {
|
|
164
|
-
taxableItemsSubtotal: 0,
|
|
165
|
-
nonTaxableItemsSubtotal: 0
|
|
166
|
-
}), s = r({
|
|
167
|
-
discount: t.discount,
|
|
168
|
-
subtotal: o.taxableItemsSubtotal + o.nonTaxableItemsSubtotal
|
|
169
|
-
}), { taxableSubtotal: c, nonTaxableSubtotal: u } = n({
|
|
170
|
-
...o,
|
|
171
|
-
discountAmount: s
|
|
172
|
-
}), d = s > 0, f = o.taxableItemsSubtotal > 0, p = o.nonTaxableItemsSubtotal > 0, m = [{
|
|
173
|
-
label: a.previewSubtotal,
|
|
174
|
-
value: i(t.subtotal)
|
|
175
|
-
}];
|
|
176
|
-
d && m.push({
|
|
177
|
-
label: a.previewDiscount,
|
|
178
|
-
value: l(s, t.currency)
|
|
179
|
-
}), p && (f || d) && m.push({
|
|
180
|
-
label: a.previewNonTaxableSubtotal,
|
|
181
|
-
value: i(u),
|
|
182
|
-
tone: "muted"
|
|
183
|
-
}), f && (p || d) && m.push({
|
|
184
|
-
label: a.previewTaxableSubtotal,
|
|
185
|
-
value: i(c),
|
|
186
|
-
tone: "muted"
|
|
187
|
-
});
|
|
188
|
-
for (let e of t.total_tax_amounts ?? []) m.push({
|
|
189
|
-
label: a.previewTaxWithRate.replace("{rate}", String((e.value ?? 0) / 100)),
|
|
190
|
-
value: i(e.amount)
|
|
191
127
|
});
|
|
192
|
-
return m.push({
|
|
193
|
-
label: a.previewTotal,
|
|
194
|
-
value: i(t.total_amount),
|
|
195
|
-
emphasis: !0
|
|
196
|
-
}), m;
|
|
197
128
|
}
|
|
198
|
-
function
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
129
|
+
function O(t, n) {
|
|
130
|
+
return n ? new Intl.NumberFormat(void 0, {
|
|
131
|
+
style: "currency",
|
|
132
|
+
currency: n,
|
|
133
|
+
currencySign: "accounting"
|
|
134
|
+
}).format(-t / 10 ** e(n)) : "";
|
|
135
|
+
}
|
|
136
|
+
function k(e, i) {
|
|
137
|
+
if (!e.taxRate) return i.previewTax;
|
|
138
|
+
let a = o(e.taxRate), s = n(e.taxRate, e.savedTaxRate);
|
|
139
|
+
return new Set(e.lineItems.filter((e) => e.taxable && !t(e)).map((e) => r(e, a, s))).size > 1 ? i.previewTax : i.previewTaxWithRate.replace("{rate}", String(a / m));
|
|
140
|
+
}
|
|
141
|
+
function A({ totals: e, currency: t, taxLabel: n, messages: r }) {
|
|
142
|
+
let i = (e) => u({
|
|
143
|
+
amount: e,
|
|
144
|
+
currency: t,
|
|
203
145
|
fallback: ""
|
|
204
|
-
}),
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
value: w(x.issue_date)
|
|
233
|
-
},
|
|
234
|
-
{
|
|
235
|
-
label: y.detailsDueDate,
|
|
236
|
-
value: w(x.due_date)
|
|
237
|
-
},
|
|
238
|
-
{
|
|
239
|
-
label: y.detailsPaymentTerms,
|
|
240
|
-
value: x.payment_terms?.name ?? y.detailsPending
|
|
241
|
-
},
|
|
242
|
-
{
|
|
243
|
-
label: y.detailsPaymentReminders,
|
|
244
|
-
value: m({
|
|
245
|
-
paymentReminder: r,
|
|
246
|
-
overdueReminder: c,
|
|
247
|
-
remindersConfigured: !!(x.payment_reminder_id || x.overdue_reminder_id),
|
|
248
|
-
messages: y
|
|
249
|
-
})
|
|
250
|
-
},
|
|
251
|
-
...x.purchase_order ? [{
|
|
252
|
-
label: y.detailsPoNumber,
|
|
253
|
-
value: x.purchase_order
|
|
254
|
-
}] : [],
|
|
255
|
-
{
|
|
256
|
-
label: y.detailsDepositAccount,
|
|
257
|
-
value: l ? s(l, y) : p && x.bank_account_id ? "-" : y.detailsNotProvided
|
|
146
|
+
}), a = e.discountAmount > 0, o = e.taxableItemsSubtotal > 0, s = e.nonTaxableItemsSubtotal > 0, c = [{
|
|
147
|
+
id: "subtotal",
|
|
148
|
+
label: r.previewSubtotal,
|
|
149
|
+
value: i(e.subtotal)
|
|
150
|
+
}];
|
|
151
|
+
return a && c.push({
|
|
152
|
+
id: "discount",
|
|
153
|
+
label: r.previewDiscount,
|
|
154
|
+
value: O(e.discountAmount, t)
|
|
155
|
+
}), s && (o || a) && c.push({
|
|
156
|
+
id: "nonTaxableSubtotal",
|
|
157
|
+
label: r.previewNonTaxableSubtotal,
|
|
158
|
+
value: i(e.nonTaxableSubtotal),
|
|
159
|
+
muted: !0
|
|
160
|
+
}), o && (s || a) && c.push({
|
|
161
|
+
id: "taxableSubtotal",
|
|
162
|
+
label: r.previewTaxableSubtotal,
|
|
163
|
+
value: i(e.taxableSubtotal),
|
|
164
|
+
muted: !0
|
|
165
|
+
}), c.push({
|
|
166
|
+
id: "tax",
|
|
167
|
+
label: n,
|
|
168
|
+
value: i(e.totalTaxes)
|
|
169
|
+
}), {
|
|
170
|
+
rows: c,
|
|
171
|
+
total: {
|
|
172
|
+
label: r.previewTotal,
|
|
173
|
+
value: i(e.total)
|
|
258
174
|
}
|
|
259
|
-
], P = i(x), F = u[T] ?? {
|
|
260
|
-
primary: [],
|
|
261
|
-
overflow: ["clone"]
|
|
262
175
|
};
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
quantityLabel: String(e.quantity),
|
|
274
|
-
unitPriceLabel: S(e.product.price?.value),
|
|
275
|
-
totalLabel: S(e.total_before_tax ?? (e.product.price?.value ?? 0) * e.quantity)
|
|
276
|
-
})),
|
|
277
|
-
panel: {
|
|
278
|
-
subtitle: x.document_id ? y.detailsInvoiceSubtitle.replace("{number}", x.document_id) : void 0,
|
|
279
|
-
statusLabel: T === "partially_paid" ? v.issued : v[T] ?? v.unknown,
|
|
280
|
-
recurring: !!x.recurrence_id || T === "recurring",
|
|
281
|
-
overdueLabel: D > 0 ? y.detailsDaysOverdue.replace("{days}", String(D)) : void 0,
|
|
282
|
-
amountTone: O,
|
|
283
|
-
amountRows: k,
|
|
284
|
-
issueDateLabel: w(x.issue_date),
|
|
285
|
-
dueDateLabel: E ? C(x.updated_at) : w(x.due_date),
|
|
286
|
-
dueDateCaption: E ? y.detailsCancelledOnCaption : y.detailsDueDate,
|
|
287
|
-
customerContact: M,
|
|
288
|
-
billingItems: N,
|
|
289
|
-
lineItemsCountLabel: String(x.line_items.length),
|
|
290
|
-
lineItemTotals: _(x, S, y),
|
|
291
|
-
notes: P && {
|
|
292
|
-
...P,
|
|
293
|
-
countLabel: String([P.opening, P.closing].filter(Boolean).length)
|
|
294
|
-
},
|
|
295
|
-
attachments: t(x, y),
|
|
296
|
-
primaryActions: F.primary,
|
|
297
|
-
overflowActions: F.overflow
|
|
298
|
-
}
|
|
176
|
+
}
|
|
177
|
+
function j({ bankDetails: e, canReceivePayments: t, messages: n }) {
|
|
178
|
+
let r = e ? [
|
|
179
|
+
[n.previewAccountHolderName, e.accountHolderName],
|
|
180
|
+
[n.previewRoutingNumber, e.routingNumber],
|
|
181
|
+
[n.previewAccountNumber, e.accountNumber]
|
|
182
|
+
].filter((e) => !!e[1]).map(([e, t]) => e.replace("{value}", t)) : [];
|
|
183
|
+
if (t || r.length !== 0) return {
|
|
184
|
+
showPayOnline: t,
|
|
185
|
+
bankLines: r
|
|
299
186
|
};
|
|
300
187
|
}
|
|
301
|
-
function
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
188
|
+
function M({ values: e, totals: t, entity: n, counterpart: r, billingAddress: i, paymentTerms: a, unitNamesById: o, bankDetails: l, canReceivePayments: u = !1, messages: d, today: f = /* @__PURE__ */ new Date() }) {
|
|
189
|
+
let p = D({
|
|
190
|
+
lineItems: e.lineItems,
|
|
191
|
+
currency: e.currency,
|
|
192
|
+
unitNamesById: o,
|
|
193
|
+
messages: d
|
|
194
|
+
}), m = n?.logo?.url, h = w(n, d), g = c(e.issueDate, f);
|
|
195
|
+
return {
|
|
196
|
+
issuer: h,
|
|
197
|
+
logo: m ? {
|
|
198
|
+
kind: "image",
|
|
199
|
+
src: m,
|
|
200
|
+
alt: h.name ? d.previewLogoAlt.replace("{name}", h.name) : d.previewLogoAltNoName
|
|
201
|
+
} : { kind: "placeholder" },
|
|
202
|
+
billTo: E({
|
|
203
|
+
counterpart: r,
|
|
204
|
+
billingAddress: i,
|
|
205
|
+
issuerCountry: n?.address?.country,
|
|
206
|
+
messages: d
|
|
207
|
+
}),
|
|
208
|
+
invoiceNumber: _,
|
|
209
|
+
issueDate: s(g),
|
|
210
|
+
...x({
|
|
211
|
+
paymentTermsId: e.paymentTermsId,
|
|
212
|
+
paymentTermsCustomDate: e.paymentTermsCustomDate,
|
|
213
|
+
paymentTerms: a,
|
|
214
|
+
issueDate: g,
|
|
215
|
+
messages: d
|
|
216
|
+
}),
|
|
217
|
+
openingNote: e.openingNote || void 0,
|
|
218
|
+
lineItems: p.length > 0 ? {
|
|
219
|
+
kind: "rows",
|
|
220
|
+
rows: p
|
|
221
|
+
} : { kind: "empty" },
|
|
222
|
+
totals: p.length > 0 ? A({
|
|
223
|
+
totals: t,
|
|
224
|
+
currency: e.currency,
|
|
225
|
+
taxLabel: k(e, d),
|
|
226
|
+
messages: d
|
|
227
|
+
}) : void 0,
|
|
228
|
+
closingNote: e.closingNote || void 0,
|
|
229
|
+
payment: j({
|
|
230
|
+
bankDetails: l,
|
|
231
|
+
canReceivePayments: u,
|
|
232
|
+
messages: d
|
|
233
|
+
})
|
|
305
234
|
};
|
|
306
235
|
}
|
|
307
236
|
//#endregion
|
|
308
|
-
export {
|
|
237
|
+
export { g as buildPreviewAddressLines, x as buildPreviewPaymentTerms, M as buildReceivablePreviewView, h as formatCountryName, O as formatDeduction };
|