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