@tesouro/embedded-components-react 0.5.200 → 0.5.202
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 +20 -0
- package/dist/index.js +1 -1
- package/dist/lib/ReceivablesWidget.d.ts +20 -0
- package/dist/lib/ReceivablesWidget.js +1 -1
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index.js +6 -6
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index2.js +24 -18
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index4.js +65 -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/index10.js +174 -234
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index11.js +32 -65
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index12.js +143 -102
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index13.js +48 -221
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index14.js +303 -0
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index15.js +75 -0
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index16.js +114 -0
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index17.js +237 -0
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index4.js +14 -1
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index5.js +30 -215
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index6.js +211 -370
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index7.js +64 -62
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index8.js +409 -187
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index9.js +73 -40
- 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 +0 -9
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index11.js +4 -1
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index12.js +10 -263
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index13.js +1 -72
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index14.js +241 -363
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index15.js +66 -100
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index16.js +406 -76
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index17.js +92 -330
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index18.js +93 -0
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index19.js +344 -0
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index2.js +10 -1
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index4.js +157 -20
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index5.js +24 -1
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index6.js +1 -3
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index7.js +3 -18
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index8.js +2 -0
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index9.js +18 -4
- package/dist/libs/tesouro-embedded-components-react/shared/data-access/dist/index.js +37 -37
- package/dist/libs/tesouro-embedded-components-react/shared/data-access/dist/lib/rest/@tanstack/react-query.gen.js +54 -54
- package/dist/libs/tesouro-embedded-components-react/shared/data-access/dist/lib/rest/sdk.gen.js +115 -94
- package/dist/libs/tesouro-embedded-components-react/shared/feature/dist/lib/analytics/build-info.js +1 -1
- package/package.json +1 -1
|
@@ -1,408 +1,249 @@
|
|
|
1
1
|
import { minorExponentForCurrency as e } from "../../../shared/util/dist/lib/amountOutputToMajorUnits.js";
|
|
2
|
-
import { parseDateOrTimestamp as t } from "../../../shared/util/dist/lib/parseCalendarDate.js";
|
|
3
|
-
import { createLineItem as n, isBlankLineItem as r, lineItemToCreatePayload as i, lineItemToUpdatePayload as a, responseLineItemToFormValues as o, summarizeLineItemErrors as s, validateLineItems as c } from "./index5.js";
|
|
4
2
|
//#region ../../libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index6.js
|
|
5
|
-
var
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
bcc: "",
|
|
9
|
-
subject: "",
|
|
10
|
-
body: ""
|
|
11
|
-
}, u = {
|
|
12
|
-
mode: "full",
|
|
13
|
-
amountPaid: "",
|
|
14
|
-
paidAt: "",
|
|
15
|
-
comment: ""
|
|
16
|
-
};
|
|
17
|
-
function d() {
|
|
3
|
+
var t = 9e15;
|
|
4
|
+
function n(e) {
|
|
5
|
+
let t = new Intl.NumberFormat(e), n = t.formatToParts(12345.67);
|
|
18
6
|
return {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
issueDate: (/* @__PURE__ */ new Date()).toISOString().slice(0, 10),
|
|
23
|
-
dueDate: "",
|
|
24
|
-
openingNote: "",
|
|
25
|
-
closingNote: "",
|
|
26
|
-
paymentTermsId: "",
|
|
27
|
-
lineItems: [n()]
|
|
7
|
+
decimal: n.find((e) => e.type === "decimal")?.value ?? ".",
|
|
8
|
+
group: n.find((e) => e.type === "group")?.value ?? "",
|
|
9
|
+
digits: Array.from({ length: 10 }, (e, n) => t.format(n))
|
|
28
10
|
};
|
|
29
11
|
}
|
|
12
|
+
function r(e) {
|
|
13
|
+
return e.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
14
|
+
}
|
|
15
|
+
function i(e) {
|
|
16
|
+
let t = e.replace(/[^0-9.]/g, ""), n = t.indexOf(".");
|
|
17
|
+
return n !== -1 && (t = t.slice(0, n + 1) + t.slice(n + 1).replace(/\./g, ""), t = t.slice(0, n + 3)), t;
|
|
18
|
+
}
|
|
19
|
+
function a(e) {
|
|
20
|
+
return e === "" || e === "." ? 0 : Number(e) || 0;
|
|
21
|
+
}
|
|
22
|
+
var o = (e) => Math.round(e * 100) / 100;
|
|
23
|
+
function s(t, n) {
|
|
24
|
+
let r = e(n);
|
|
25
|
+
return new Intl.NumberFormat(void 0, {
|
|
26
|
+
minimumFractionDigits: r,
|
|
27
|
+
maximumFractionDigits: r
|
|
28
|
+
}).format(t / 10 ** r);
|
|
29
|
+
}
|
|
30
|
+
function c(t, i, a = n()) {
|
|
31
|
+
if (t.trim() === "") return 0;
|
|
32
|
+
let o = Array.from(t, (e) => {
|
|
33
|
+
let t = a.digits.indexOf(e);
|
|
34
|
+
return t === -1 ? e : String(t);
|
|
35
|
+
}).join("");
|
|
36
|
+
a.group && (o = o.replace(new RegExp(r(a.group), "g"), "")), o = o.replace(a.decimal, ".");
|
|
37
|
+
let s = parseFloat(o);
|
|
38
|
+
return Number.isNaN(s) ? 0 : Math.round(s * 10 ** e(i));
|
|
39
|
+
}
|
|
40
|
+
function l(t, r, i, a = n()) {
|
|
41
|
+
let o = c(t, r, a) / 10 ** e(r);
|
|
42
|
+
return s(Math.round(o * 10 ** e(i)), i);
|
|
43
|
+
}
|
|
44
|
+
function u(e) {
|
|
45
|
+
let t = i(e);
|
|
46
|
+
return t.length > 1 && t.startsWith("0") && t[1] !== "." && (t = t.replace(/^0+/, "") || "0"), t === "" || t === "." ? t : Number(t) > 100 ? "100" : t;
|
|
47
|
+
}
|
|
48
|
+
function d(e) {
|
|
49
|
+
return e.endsWith(".") ? e.slice(0, -1) : e;
|
|
50
|
+
}
|
|
30
51
|
function f(e) {
|
|
31
|
-
return e
|
|
52
|
+
return Math.round((Number(e) || 0) * 100);
|
|
32
53
|
}
|
|
33
54
|
function p(e) {
|
|
34
|
-
return e
|
|
55
|
+
return (e ?? "taxable") === "taxable";
|
|
35
56
|
}
|
|
36
57
|
function m(e) {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
}
|
|
50
|
-
function g(e, n) {
|
|
51
|
-
let r = t(e);
|
|
52
|
-
return r ? new Intl.DateTimeFormat(void 0, {
|
|
53
|
-
day: "numeric",
|
|
54
|
-
month: "short",
|
|
55
|
-
year: "numeric"
|
|
56
|
-
}).format(r) : n;
|
|
57
|
-
}
|
|
58
|
-
function _({ amount: t, currency: n, fallback: r }) {
|
|
59
|
-
return t == null || !n ? r : new Intl.NumberFormat(void 0, {
|
|
60
|
-
currency: n,
|
|
61
|
-
style: "currency"
|
|
62
|
-
}).format(t / 10 ** e(n));
|
|
63
|
-
}
|
|
64
|
-
function v(t, n) {
|
|
65
|
-
let r = Number(t);
|
|
66
|
-
if (!Number.isFinite(r)) return;
|
|
67
|
-
let i = n ? e(n) : 2;
|
|
68
|
-
return Math.round(r * 10 ** i);
|
|
69
|
-
}
|
|
70
|
-
function y(e, t) {
|
|
71
|
-
return e.document_id || t.untitledDocument;
|
|
72
|
-
}
|
|
73
|
-
function b(e, t) {
|
|
74
|
-
return e === "quote" ? t.quoteType : e === "credit_note" ? t.creditNoteType : t.invoiceType;
|
|
75
|
-
}
|
|
76
|
-
function x(e) {
|
|
77
|
-
return e === "paid" || e === "accepted" || e === "issued" || e === "recurring" ? "success" : e === "draft" || e === "issuing" ? "neutral" : e === "overdue" || e === "partially_paid" ? "warning" : e === "failed" || e === "declined" || e === "expired" || e === "uncollectible" || e === "canceled" || e === "deleted" ? "danger" : "info";
|
|
58
|
+
let t = e.find((e) => p(e.tax_status))?.product.tax_rate?.value;
|
|
59
|
+
return t === void 0 ? "" : String(t / 100);
|
|
60
|
+
}
|
|
61
|
+
function h(e) {
|
|
62
|
+
try {
|
|
63
|
+
return new Intl.NumberFormat(void 0, {
|
|
64
|
+
style: "currency",
|
|
65
|
+
currency: e
|
|
66
|
+
}).formatToParts(0).find((e) => e.type === "currency")?.value ?? e;
|
|
67
|
+
} catch {
|
|
68
|
+
return e;
|
|
69
|
+
}
|
|
78
70
|
}
|
|
79
|
-
function
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
"partially_paid"
|
|
84
|
-
].includes(e.status);
|
|
71
|
+
function g() {
|
|
72
|
+
return typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID() : `${Date.now()}-${Math.random().toString(16).slice(2)}`;
|
|
73
|
+
}
|
|
74
|
+
function _(e = "USD") {
|
|
85
75
|
return {
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
decline: i && n,
|
|
96
|
-
delete: t,
|
|
97
|
-
issue: t,
|
|
98
|
-
markPaid: o,
|
|
99
|
-
markUncollectible: o,
|
|
100
|
-
recordPayment: o,
|
|
101
|
-
send: [
|
|
102
|
-
"issued",
|
|
103
|
-
"accepted",
|
|
104
|
-
"overdue",
|
|
105
|
-
"partially_paid"
|
|
106
|
-
].includes(e.status) && !a
|
|
76
|
+
id: g(),
|
|
77
|
+
productId: "",
|
|
78
|
+
name: "",
|
|
79
|
+
quantity: "1",
|
|
80
|
+
price: s(0, e),
|
|
81
|
+
measureUnitId: "",
|
|
82
|
+
measureUnitName: "",
|
|
83
|
+
productType: "product",
|
|
84
|
+
taxable: !0
|
|
107
85
|
};
|
|
108
86
|
}
|
|
109
|
-
function
|
|
110
|
-
return e.map((e) => {
|
|
111
|
-
let n = e.type === "invoice" ? e.amount_due : void 0;
|
|
112
|
-
return {
|
|
113
|
-
id: e.id,
|
|
114
|
-
type: e.type,
|
|
115
|
-
documentLabel: y(e, t),
|
|
116
|
-
customerLabel: e.counterpart_name || t.unknownCustomer,
|
|
117
|
-
status: e.status,
|
|
118
|
-
statusTone: x(e.status),
|
|
119
|
-
issueDateLabel: g(e.issue_date, t.notAvailable),
|
|
120
|
-
dueDateLabel: g(e.type === "quote" ? e.expiry_date : e.due_date, t.notAvailable),
|
|
121
|
-
totalLabel: _({
|
|
122
|
-
amount: e.total_amount,
|
|
123
|
-
currency: e.currency,
|
|
124
|
-
fallback: t.notAvailable
|
|
125
|
-
}),
|
|
126
|
-
amountDueLabel: _({
|
|
127
|
-
amount: n,
|
|
128
|
-
currency: e.currency,
|
|
129
|
-
fallback: t.notAvailable
|
|
130
|
-
}),
|
|
131
|
-
actions: S(e)
|
|
132
|
-
};
|
|
133
|
-
});
|
|
134
|
-
}
|
|
135
|
-
function w({ receivable: e, history: t, mails: n, pdfUrl: r, messages: i }) {
|
|
136
|
-
if (!e) return;
|
|
137
|
-
let a = e.type === "invoice" ? e.amount_due : void 0, o = e.type === "quote" ? e.expiry_date : e.due_date;
|
|
87
|
+
function v({ id: e, name: t, quantity: n, price: r, measureUnitId: i, taxable: a }) {
|
|
138
88
|
return {
|
|
139
|
-
id: e
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
totalLabel: _({
|
|
146
|
-
amount: e.total_amount,
|
|
147
|
-
currency: e.currency,
|
|
148
|
-
fallback: i.notAvailable
|
|
149
|
-
}),
|
|
150
|
-
amountDueLabel: _({
|
|
151
|
-
amount: a,
|
|
152
|
-
currency: e.currency,
|
|
153
|
-
fallback: i.notAvailable
|
|
154
|
-
}),
|
|
155
|
-
pdfUrl: r || e.file_url || e.original_file_url || void 0,
|
|
156
|
-
summaryItems: [
|
|
157
|
-
{
|
|
158
|
-
label: i.summaryDocumentType,
|
|
159
|
-
value: b(e.type, i)
|
|
160
|
-
},
|
|
161
|
-
{
|
|
162
|
-
label: i.summaryDocumentNumber,
|
|
163
|
-
value: y(e, i)
|
|
164
|
-
},
|
|
165
|
-
{
|
|
166
|
-
label: i.summaryCustomer,
|
|
167
|
-
value: e.counterpart_name || i.unknownCustomer
|
|
168
|
-
},
|
|
169
|
-
{
|
|
170
|
-
label: i.summaryIssued,
|
|
171
|
-
value: g(e.issue_date, i.notAvailable)
|
|
172
|
-
},
|
|
173
|
-
{
|
|
174
|
-
label: i.summaryDue,
|
|
175
|
-
value: g(o, i.notAvailable)
|
|
176
|
-
},
|
|
177
|
-
{
|
|
178
|
-
label: i.summaryCreated,
|
|
179
|
-
value: g(e.created_at, i.notAvailable)
|
|
180
|
-
},
|
|
181
|
-
{
|
|
182
|
-
label: i.summaryUpdated,
|
|
183
|
-
value: g(e.updated_at, i.notAvailable)
|
|
184
|
-
},
|
|
185
|
-
{
|
|
186
|
-
label: i.summaryTotal,
|
|
187
|
-
value: _({
|
|
188
|
-
amount: e.total_amount,
|
|
189
|
-
currency: e.currency,
|
|
190
|
-
fallback: i.notAvailable
|
|
191
|
-
})
|
|
192
|
-
},
|
|
193
|
-
{
|
|
194
|
-
label: i.summaryAmountDue,
|
|
195
|
-
value: _({
|
|
196
|
-
amount: a,
|
|
197
|
-
currency: e.currency,
|
|
198
|
-
fallback: i.notAvailable
|
|
199
|
-
})
|
|
200
|
-
}
|
|
201
|
-
],
|
|
202
|
-
lineItems: e.line_items.map((t, n) => ({
|
|
203
|
-
id: t.product.id || String(n),
|
|
204
|
-
name: t.product.name,
|
|
205
|
-
quantityLabel: String(t.quantity),
|
|
206
|
-
unitPriceLabel: _({
|
|
207
|
-
amount: t.product.price?.value,
|
|
208
|
-
currency: t.product.price?.currency || e.currency,
|
|
209
|
-
fallback: i.notAvailable
|
|
210
|
-
}),
|
|
211
|
-
totalLabel: _({
|
|
212
|
-
amount: t.total_after_tax ?? t.total_before_tax,
|
|
213
|
-
currency: e.currency,
|
|
214
|
-
fallback: i.notAvailable
|
|
215
|
-
})
|
|
216
|
-
})),
|
|
217
|
-
activityItems: t.map((e) => ({
|
|
218
|
-
id: e.id,
|
|
219
|
-
title: T(e.event_type, i),
|
|
220
|
-
description: e.event_type,
|
|
221
|
-
timestampLabel: g(e.timestamp, i.notAvailable)
|
|
222
|
-
})),
|
|
223
|
-
mailItems: n.map((e) => ({
|
|
224
|
-
id: e.id,
|
|
225
|
-
statusLabel: e.status,
|
|
226
|
-
recipientsLabel: E(e, i),
|
|
227
|
-
sentAtLabel: g(e.created_at, i.notAvailable)
|
|
228
|
-
})),
|
|
229
|
-
actions: S(e)
|
|
89
|
+
id: e,
|
|
90
|
+
name: t,
|
|
91
|
+
quantity: n,
|
|
92
|
+
price: r,
|
|
93
|
+
unit: i,
|
|
94
|
+
taxable: a
|
|
230
95
|
};
|
|
231
96
|
}
|
|
232
|
-
function
|
|
233
|
-
return e
|
|
97
|
+
function y(e) {
|
|
98
|
+
return !e.name.trim();
|
|
234
99
|
}
|
|
235
|
-
function
|
|
236
|
-
let
|
|
237
|
-
|
|
238
|
-
...e.recipients?.cc ?? [],
|
|
239
|
-
...e.recipients?.bcc ?? []
|
|
240
|
-
].map((e) => e.email).filter(Boolean);
|
|
241
|
-
return n.length > 0 ? n.join(", ") : t.recipientsNone;
|
|
242
|
-
}
|
|
243
|
-
function D({ values: e, billingAddressId: t, messages: n }) {
|
|
244
|
-
let r = {};
|
|
245
|
-
e.customerId ? t || (r.customerId = n.customerAddressRequired) : r.customerId = n.customerRequired, e.currency || (r.currency = n.currencyRequired);
|
|
246
|
-
let i = c(e.lineItems, {
|
|
247
|
-
currency: e.currency,
|
|
248
|
-
messages: n
|
|
249
|
-
});
|
|
250
|
-
return i && (r.lineItems = i, r.lineItemsSummary = s(i)), r;
|
|
251
|
-
}
|
|
252
|
-
function O(e) {
|
|
253
|
-
return Object.keys(e).length > 0;
|
|
254
|
-
}
|
|
255
|
-
function k({ values: e, billingAddressId: t, unitNamesById: n }) {
|
|
256
|
-
let a = e.lineItems.filter((e) => !r(e)).map((t) => i({
|
|
257
|
-
lineItem: t,
|
|
258
|
-
currency: e.currency,
|
|
259
|
-
unitNamesById: n
|
|
260
|
-
})), o = {
|
|
261
|
-
counterpart_billing_address_id: t,
|
|
262
|
-
counterpart_id: e.customerId,
|
|
263
|
-
currency: e.currency,
|
|
264
|
-
line_items: a,
|
|
265
|
-
memo: e.openingNote,
|
|
266
|
-
footer: e.closingNote
|
|
267
|
-
};
|
|
268
|
-
return e.type === "quote" ? {
|
|
269
|
-
...o,
|
|
270
|
-
expiry_date: e.dueDate || void 0,
|
|
271
|
-
type: "quote"
|
|
272
|
-
} : {
|
|
273
|
-
...o,
|
|
274
|
-
payment_terms_id: e.paymentTermsId || void 0,
|
|
275
|
-
payment_terms: !e.paymentTermsId && e.dueDate ? { term_final: { end_date: e.dueDate } } : void 0,
|
|
276
|
-
type: "invoice"
|
|
277
|
-
};
|
|
100
|
+
function b(e) {
|
|
101
|
+
let t = e.filter((e) => !y(e));
|
|
102
|
+
return t.length > 0 ? t : e.slice(0, 1);
|
|
278
103
|
}
|
|
279
|
-
function
|
|
280
|
-
let r = e.
|
|
281
|
-
lineItem: n,
|
|
282
|
-
currency: e.currency,
|
|
283
|
-
units: t
|
|
284
|
-
}));
|
|
104
|
+
function x({ product: e, currency: t, unitNamesById: n }) {
|
|
105
|
+
let r = e.measure_unit_id ?? "";
|
|
285
106
|
return {
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
lineItems: a.length > 0 ? a : [n(e.currency)]
|
|
107
|
+
productId: e.id,
|
|
108
|
+
name: e.name,
|
|
109
|
+
quantity: String(e.smallest_amount || 1),
|
|
110
|
+
price: s(e.price?.value ?? 0, t),
|
|
111
|
+
productType: "product",
|
|
112
|
+
...r && n[r] ? {
|
|
113
|
+
measureUnitId: r,
|
|
114
|
+
measureUnitName: ""
|
|
115
|
+
} : {}
|
|
296
116
|
};
|
|
297
117
|
}
|
|
298
|
-
function
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
currency: e.currency,
|
|
303
|
-
issue_date: e.issueDate || void 0,
|
|
304
|
-
memo: e.openingNote,
|
|
305
|
-
footer: e.closingNote
|
|
118
|
+
function S(e) {
|
|
119
|
+
return e.quantity === void 0 ? e : {
|
|
120
|
+
...e,
|
|
121
|
+
quantity: i(e.quantity)
|
|
306
122
|
};
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
}
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
}
|
|
320
|
-
function M({ values: e, originalLineItems: t, originalCurrency: n, unitNamesById: i, units: s }) {
|
|
321
|
-
let c = (e, t) => a({
|
|
322
|
-
lineItem: e,
|
|
323
|
-
currency: t,
|
|
324
|
-
unitNamesById: i
|
|
325
|
-
}), l = new Map(t.map((e) => [e.id, JSON.stringify(c(o({
|
|
326
|
-
lineItem: e,
|
|
327
|
-
currency: n,
|
|
328
|
-
units: s
|
|
329
|
-
}), n))])), u = e.lineItems.filter((e) => !r(e)), d = new Set(u.map((e) => e.id)), f = u.filter((e) => !l.has(e.id)).map((t) => c(t, e.currency)), p = u.flatMap((t) => {
|
|
330
|
-
let n = l.get(t.id);
|
|
331
|
-
if (n === void 0) return [];
|
|
332
|
-
let r = c(t, e.currency);
|
|
333
|
-
return n === JSON.stringify(r) ? [] : [{
|
|
334
|
-
id: t.id,
|
|
335
|
-
data: r
|
|
336
|
-
}];
|
|
337
|
-
}), m = t.filter((e) => !d.has(e.id)).map((e) => e.id);
|
|
338
|
-
if (f.length || p.length || m.length) return {
|
|
339
|
-
...f.length ? { add: f } : {},
|
|
340
|
-
...p.length ? { replace: p } : {},
|
|
341
|
-
...m.length ? { remove: m } : {}
|
|
123
|
+
}
|
|
124
|
+
function C({ lineItem: e, field: t, rowCount: r, currency: l, separators: u = n() }) {
|
|
125
|
+
if (t === "price") return {
|
|
126
|
+
kind: "update",
|
|
127
|
+
patch: { price: s(c(e.price, l, u), l) }
|
|
128
|
+
};
|
|
129
|
+
let d = o(a(i(e.quantity)));
|
|
130
|
+
return d <= 0 ? r > 1 ? { kind: "remove" } : {
|
|
131
|
+
kind: "update",
|
|
132
|
+
patch: { quantity: "1" }
|
|
133
|
+
} : {
|
|
134
|
+
kind: "update",
|
|
135
|
+
patch: { quantity: String(d) }
|
|
342
136
|
};
|
|
343
137
|
}
|
|
344
|
-
function
|
|
345
|
-
|
|
138
|
+
function w({ lineItem: e, step: t, rowCount: n }) {
|
|
139
|
+
if (y(e)) return;
|
|
140
|
+
let r = o(Math.max(0, a(e.quantity)) + t);
|
|
141
|
+
return r <= 0 && n > 1 ? { kind: "remove" } : {
|
|
142
|
+
kind: "update",
|
|
143
|
+
patch: { quantity: String(Math.max(n > 1 ? 0 : 1, r)) }
|
|
144
|
+
};
|
|
346
145
|
}
|
|
347
|
-
function
|
|
348
|
-
return (e
|
|
349
|
-
|
|
350
|
-
|
|
146
|
+
function T(e) {
|
|
147
|
+
return Object.fromEntries(e.map((t) => {
|
|
148
|
+
let n = !y(t), r = a(t.quantity);
|
|
149
|
+
return [t.id, {
|
|
150
|
+
canDecreaseQuantity: n && (e.length > 1 || r > 1),
|
|
151
|
+
canIncreaseQuantity: n
|
|
152
|
+
}];
|
|
351
153
|
}));
|
|
352
154
|
}
|
|
353
|
-
function
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
return Object.keys(e).length > 0;
|
|
359
|
-
}
|
|
360
|
-
function L(e) {
|
|
361
|
-
return e.split(",").map((e) => e.trim()).filter(Boolean);
|
|
362
|
-
}
|
|
363
|
-
function R(e, t, n) {
|
|
364
|
-
let r = {};
|
|
365
|
-
if (e.mode === "partial") {
|
|
366
|
-
let i = v(e.amountPaid, n);
|
|
367
|
-
(!i || i <= 0) && (r.amountPaid = t.paymentAmountInvalid);
|
|
368
|
-
}
|
|
369
|
-
return r;
|
|
155
|
+
function E(e, t) {
|
|
156
|
+
return {
|
|
157
|
+
tax_status: e.taxable ? "taxable" : "non_taxable",
|
|
158
|
+
tax_rate_value: e.taxable ? f(t) : void 0
|
|
159
|
+
};
|
|
370
160
|
}
|
|
371
|
-
function
|
|
372
|
-
|
|
161
|
+
function D({ lineItem: e, currency: t, taxRate: n, unitNamesById: r }) {
|
|
162
|
+
let i = e.measureUnitId ? r[e.measureUnitId] : void 0, { tax_status: o, tax_rate_value: s } = E(e, n);
|
|
163
|
+
return {
|
|
164
|
+
quantity: a(e.quantity),
|
|
165
|
+
tax_status: o,
|
|
166
|
+
product: {
|
|
167
|
+
name: e.name,
|
|
168
|
+
price: {
|
|
169
|
+
currency: t,
|
|
170
|
+
value: c(e.price, t)
|
|
171
|
+
},
|
|
172
|
+
measure_unit: i ? { name: i } : void 0,
|
|
173
|
+
type: "product"
|
|
174
|
+
},
|
|
175
|
+
tax_rate_value: s
|
|
176
|
+
};
|
|
373
177
|
}
|
|
374
|
-
function
|
|
178
|
+
function O({ lineItem: e, currency: t, taxRate: n, unitNamesById: r }) {
|
|
179
|
+
let i = e.measureUnitId && r[e.measureUnitId] || e.measureUnitName || void 0, { tax_status: o, tax_rate_value: s } = E(e, n);
|
|
375
180
|
return {
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
181
|
+
quantity: a(e.quantity),
|
|
182
|
+
tax_status: o,
|
|
183
|
+
product: {
|
|
184
|
+
name: e.name,
|
|
185
|
+
type: e.productType,
|
|
186
|
+
measure_unit: i ? { name: i } : void 0,
|
|
187
|
+
price: {
|
|
188
|
+
currency: t,
|
|
189
|
+
value: c(e.price, t)
|
|
190
|
+
}
|
|
191
|
+
},
|
|
192
|
+
tax_rate_value: s
|
|
380
193
|
};
|
|
381
194
|
}
|
|
382
|
-
function
|
|
195
|
+
function k({ lineItem: e, currency: t, units: n }) {
|
|
196
|
+
let r = e.product.measure_unit;
|
|
383
197
|
return {
|
|
384
|
-
|
|
385
|
-
|
|
198
|
+
id: e.id,
|
|
199
|
+
productId: e.product.id,
|
|
200
|
+
name: e.product.name,
|
|
201
|
+
quantity: String(e.quantity),
|
|
202
|
+
price: s(e.product.price?.value ?? 0, t),
|
|
203
|
+
measureUnitId: j(r?.id ?? "", r?.name ?? "", n),
|
|
204
|
+
measureUnitName: r?.name ?? "",
|
|
205
|
+
productType: e.product.type ?? "product",
|
|
206
|
+
taxable: p(e.tax_status)
|
|
386
207
|
};
|
|
387
208
|
}
|
|
388
|
-
function
|
|
389
|
-
return
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
209
|
+
function A(e, t) {
|
|
210
|
+
if (!t) return;
|
|
211
|
+
let n = t.toLowerCase();
|
|
212
|
+
return e.find((e) => e.name.toLowerCase() === n);
|
|
213
|
+
}
|
|
214
|
+
function j(e, t, n) {
|
|
215
|
+
return n?.length ? ((e ? n.find((t) => t.id === e) : void 0) ?? A(n, t))?.id ?? (t ? "" : e) : e;
|
|
216
|
+
}
|
|
217
|
+
function M(e, t) {
|
|
218
|
+
let n = !1, r = e.map((e) => {
|
|
219
|
+
let r = j(e.measureUnitId, e.measureUnitName, t);
|
|
220
|
+
return r === e.measureUnitId ? e : (n = !0, {
|
|
221
|
+
...e,
|
|
222
|
+
measureUnitId: r
|
|
223
|
+
});
|
|
224
|
+
});
|
|
225
|
+
return n ? r : e;
|
|
226
|
+
}
|
|
227
|
+
function N(n) {
|
|
228
|
+
return new Intl.NumberFormat().format(t / 10 ** e(n));
|
|
229
|
+
}
|
|
230
|
+
function P(e, { currency: n, messages: r }) {
|
|
231
|
+
let i = {};
|
|
232
|
+
for (let a of e) {
|
|
233
|
+
let e = {};
|
|
234
|
+
a.name.length > 100 && (e.name = r.lineItemNameTooLong), c(a.price, n) > t && (e.price = r.lineItemPriceTooHigh.replace("{maxAmount}", N(n))), Object.keys(e).length > 0 && (i[a.id] = e);
|
|
235
|
+
}
|
|
236
|
+
return Object.keys(i).length > 0 ? i : void 0;
|
|
237
|
+
}
|
|
238
|
+
function F(e) {
|
|
239
|
+
if (!e) return;
|
|
240
|
+
let t = Object.values(e), n = [
|
|
241
|
+
"name",
|
|
242
|
+
"quantity",
|
|
243
|
+
"price",
|
|
244
|
+
"measureUnit"
|
|
245
|
+
].map((e) => t.find((t) => t[e])?.[e]).filter((e) => !!e);
|
|
246
|
+
return n.length > 0 ? n : void 0;
|
|
406
247
|
}
|
|
407
248
|
//#endregion
|
|
408
|
-
export {
|
|
249
|
+
export { T as buildLineItemControls, C as commitLineItemField, d as commitTaxRateInput, l as convertPriceInput, _ as createLineItem, s as formatPriceInput, h as getCurrencySymbol, n as getNumberSeparators, y as isBlankLineItem, p as isLineItemTaxable, x as lineItemFromProduct, D as lineItemToCreatePayload, O as lineItemToUpdatePayload, a as parseQuantity, c as priceInputToMinorUnits, M as reconcileMeasureUnits, k as responseLineItemToFormValues, S as sanitizeLineItemPatch, i as sanitizeQuantityInput, u as sanitizeTaxRateInput, w as stepLineItemQuantity, b as stripBlankLineItems, F as summarizeLineItemErrors, m as taxRateFromLineItems, f as taxRateToMinorUnits, v as toSheetLineItem, P as validateLineItems };
|