@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,63 +1,404 @@
|
|
|
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";
|
|
1
4
|
//#region ../../libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index6.js
|
|
2
|
-
var
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
untitledDocument: "Untitled document",
|
|
14
|
-
unknownCustomer: "Unknown customer",
|
|
15
|
-
notAvailable: "Not available",
|
|
16
|
-
invoiceType: "Invoice",
|
|
17
|
-
quoteType: "Quote",
|
|
18
|
-
creditNoteType: "Credit note",
|
|
19
|
-
summaryDocumentType: "Document type",
|
|
20
|
-
summaryDocumentNumber: "Document number",
|
|
21
|
-
summaryCustomer: "Customer",
|
|
22
|
-
summaryIssued: "Issued",
|
|
23
|
-
summaryDue: "Due",
|
|
24
|
-
summaryCreated: "Created",
|
|
25
|
-
summaryUpdated: "Updated",
|
|
26
|
-
summaryTotal: "Total",
|
|
27
|
-
summaryAmountDue: "Amount due",
|
|
28
|
-
activityStatusChanged: "Status changed",
|
|
29
|
-
activityReceivableCreated: "Receivable created",
|
|
30
|
-
activityReceivableUpdated: "Receivable updated",
|
|
31
|
-
activityPaymentReceived: "Payment received",
|
|
32
|
-
activityMailSent: "Email sent",
|
|
33
|
-
activityUnknown: "Activity",
|
|
34
|
-
recipientsNone: "No recipients",
|
|
35
|
-
sendSubjectDefault: "Your receivable document",
|
|
36
|
-
sendBodyDefault: "Please find the receivable document attached.",
|
|
37
|
-
issueTitle: "Issue receivable?",
|
|
38
|
-
issueDescription: "Issuing locks the document and makes it ready to send to the customer.",
|
|
39
|
-
issueConfirm: "Issue",
|
|
40
|
-
acceptTitle: "Accept quote?",
|
|
41
|
-
acceptDescription: "This marks the quote as accepted.",
|
|
42
|
-
acceptConfirm: "Accept",
|
|
43
|
-
declineTitle: "Decline quote?",
|
|
44
|
-
declineDescription: "This marks the quote as declined.",
|
|
45
|
-
declineConfirm: "Decline",
|
|
46
|
-
cancelTitle: "Cancel receivable?",
|
|
47
|
-
cancelDescription: "This cancels the document. You cannot undo this action.",
|
|
48
|
-
cancelConfirm: "Cancel document",
|
|
49
|
-
cloneTitle: "Clone receivable?",
|
|
50
|
-
cloneDescription: "This creates a new draft based on the selected document.",
|
|
51
|
-
cloneConfirm: "Clone",
|
|
52
|
-
deleteTitle: "Delete draft?",
|
|
53
|
-
deleteDescription: "This permanently deletes the draft document. You cannot undo this action.",
|
|
54
|
-
deleteConfirm: "Delete",
|
|
55
|
-
markPaidTitle: "Mark invoice as paid?",
|
|
56
|
-
markPaidDescription: "This records the invoice as fully paid.",
|
|
57
|
-
markPaidConfirm: "Mark paid",
|
|
58
|
-
markUncollectibleTitle: "Mark invoice uncollectible?",
|
|
59
|
-
markUncollectibleDescription: "This records the invoice as uncollectible. You cannot undo this action.",
|
|
60
|
-
markUncollectibleConfirm: "Mark uncollectible"
|
|
5
|
+
var l = {
|
|
6
|
+
to: "",
|
|
7
|
+
cc: "",
|
|
8
|
+
bcc: "",
|
|
9
|
+
subject: "",
|
|
10
|
+
body: ""
|
|
11
|
+
}, u = {
|
|
12
|
+
mode: "full",
|
|
13
|
+
amountPaid: "",
|
|
14
|
+
paidAt: "",
|
|
15
|
+
comment: ""
|
|
61
16
|
};
|
|
17
|
+
function d() {
|
|
18
|
+
return {
|
|
19
|
+
type: "invoice",
|
|
20
|
+
customerId: "",
|
|
21
|
+
currency: "USD",
|
|
22
|
+
issueDate: (/* @__PURE__ */ new Date()).toISOString().slice(0, 10),
|
|
23
|
+
dueDate: "",
|
|
24
|
+
memo: "",
|
|
25
|
+
paymentTermsId: "",
|
|
26
|
+
lineItems: [n()]
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
function f(e) {
|
|
30
|
+
return e === "quotes" ? "quote" : e === "credit_notes" ? "credit_note" : "invoice";
|
|
31
|
+
}
|
|
32
|
+
function p(e) {
|
|
33
|
+
return e === "quote" ? "quotes" : e === "credit_note" ? "credit_notes" : "invoices";
|
|
34
|
+
}
|
|
35
|
+
function m(e) {
|
|
36
|
+
return (e?.length ? e : [
|
|
37
|
+
"invoices",
|
|
38
|
+
"quotes",
|
|
39
|
+
"credit_notes"
|
|
40
|
+
]).filter((e, t, n) => [
|
|
41
|
+
"invoices",
|
|
42
|
+
"quotes",
|
|
43
|
+
"credit_notes"
|
|
44
|
+
].includes(e) && n.indexOf(e) === t);
|
|
45
|
+
}
|
|
46
|
+
function h({ defaultTab: e, enabledTabs: t }) {
|
|
47
|
+
return e && t.includes(e) ? e : t[0] ?? "invoices";
|
|
48
|
+
}
|
|
49
|
+
function g(e, n) {
|
|
50
|
+
let r = t(e);
|
|
51
|
+
return r ? new Intl.DateTimeFormat(void 0, {
|
|
52
|
+
day: "numeric",
|
|
53
|
+
month: "short",
|
|
54
|
+
year: "numeric"
|
|
55
|
+
}).format(r) : n;
|
|
56
|
+
}
|
|
57
|
+
function _({ amount: t, currency: n, fallback: r }) {
|
|
58
|
+
return t == null || !n ? r : new Intl.NumberFormat(void 0, {
|
|
59
|
+
currency: n,
|
|
60
|
+
style: "currency"
|
|
61
|
+
}).format(t / 10 ** e(n));
|
|
62
|
+
}
|
|
63
|
+
function v(t, n) {
|
|
64
|
+
let r = Number(t);
|
|
65
|
+
if (!Number.isFinite(r)) return;
|
|
66
|
+
let i = n ? e(n) : 2;
|
|
67
|
+
return Math.round(r * 10 ** i);
|
|
68
|
+
}
|
|
69
|
+
function y(e, t) {
|
|
70
|
+
return e.document_id || t.untitledDocument;
|
|
71
|
+
}
|
|
72
|
+
function b(e, t) {
|
|
73
|
+
return e === "quote" ? t.quoteType : e === "credit_note" ? t.creditNoteType : t.invoiceType;
|
|
74
|
+
}
|
|
75
|
+
function x(e) {
|
|
76
|
+
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";
|
|
77
|
+
}
|
|
78
|
+
function S(e) {
|
|
79
|
+
let t = e.status === "draft", n = e.status === "issued", r = e.type === "invoice", i = e.type === "quote", a = e.type === "credit_note", o = r && [
|
|
80
|
+
"issued",
|
|
81
|
+
"overdue",
|
|
82
|
+
"partially_paid"
|
|
83
|
+
].includes(e.status);
|
|
84
|
+
return {
|
|
85
|
+
edit: t && !a,
|
|
86
|
+
accept: i && n,
|
|
87
|
+
cancel: ![
|
|
88
|
+
"paid",
|
|
89
|
+
"canceled",
|
|
90
|
+
"deleted",
|
|
91
|
+
"uncollectible"
|
|
92
|
+
].includes(e.status) && !t,
|
|
93
|
+
clone: !a && e.status !== "deleted",
|
|
94
|
+
decline: i && n,
|
|
95
|
+
delete: t,
|
|
96
|
+
issue: t,
|
|
97
|
+
markPaid: o,
|
|
98
|
+
markUncollectible: o,
|
|
99
|
+
recordPayment: o,
|
|
100
|
+
send: [
|
|
101
|
+
"issued",
|
|
102
|
+
"accepted",
|
|
103
|
+
"overdue",
|
|
104
|
+
"partially_paid"
|
|
105
|
+
].includes(e.status) && !a
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
function C({ receivables: e, messages: t }) {
|
|
109
|
+
return e.map((e) => {
|
|
110
|
+
let n = e.type === "invoice" ? e.amount_due : void 0;
|
|
111
|
+
return {
|
|
112
|
+
id: e.id,
|
|
113
|
+
type: e.type,
|
|
114
|
+
documentLabel: y(e, t),
|
|
115
|
+
customerLabel: e.counterpart_name || t.unknownCustomer,
|
|
116
|
+
status: e.status,
|
|
117
|
+
statusTone: x(e.status),
|
|
118
|
+
issueDateLabel: g(e.issue_date, t.notAvailable),
|
|
119
|
+
dueDateLabel: g(e.type === "quote" ? e.expiry_date : e.due_date, t.notAvailable),
|
|
120
|
+
totalLabel: _({
|
|
121
|
+
amount: e.total_amount,
|
|
122
|
+
currency: e.currency,
|
|
123
|
+
fallback: t.notAvailable
|
|
124
|
+
}),
|
|
125
|
+
amountDueLabel: _({
|
|
126
|
+
amount: n,
|
|
127
|
+
currency: e.currency,
|
|
128
|
+
fallback: t.notAvailable
|
|
129
|
+
}),
|
|
130
|
+
actions: S(e)
|
|
131
|
+
};
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
function w({ receivable: e, history: t, mails: n, pdfUrl: r, messages: i }) {
|
|
135
|
+
if (!e) return;
|
|
136
|
+
let a = e.type === "invoice" ? e.amount_due : void 0, o = e.type === "quote" ? e.expiry_date : e.due_date;
|
|
137
|
+
return {
|
|
138
|
+
id: e.id,
|
|
139
|
+
type: e.type,
|
|
140
|
+
title: y(e, i),
|
|
141
|
+
customerLabel: e.counterpart_name || i.unknownCustomer,
|
|
142
|
+
status: e.status,
|
|
143
|
+
statusTone: x(e.status),
|
|
144
|
+
totalLabel: _({
|
|
145
|
+
amount: e.total_amount,
|
|
146
|
+
currency: e.currency,
|
|
147
|
+
fallback: i.notAvailable
|
|
148
|
+
}),
|
|
149
|
+
amountDueLabel: _({
|
|
150
|
+
amount: a,
|
|
151
|
+
currency: e.currency,
|
|
152
|
+
fallback: i.notAvailable
|
|
153
|
+
}),
|
|
154
|
+
pdfUrl: r || e.file_url || e.original_file_url || void 0,
|
|
155
|
+
summaryItems: [
|
|
156
|
+
{
|
|
157
|
+
label: i.summaryDocumentType,
|
|
158
|
+
value: b(e.type, i)
|
|
159
|
+
},
|
|
160
|
+
{
|
|
161
|
+
label: i.summaryDocumentNumber,
|
|
162
|
+
value: y(e, i)
|
|
163
|
+
},
|
|
164
|
+
{
|
|
165
|
+
label: i.summaryCustomer,
|
|
166
|
+
value: e.counterpart_name || i.unknownCustomer
|
|
167
|
+
},
|
|
168
|
+
{
|
|
169
|
+
label: i.summaryIssued,
|
|
170
|
+
value: g(e.issue_date, i.notAvailable)
|
|
171
|
+
},
|
|
172
|
+
{
|
|
173
|
+
label: i.summaryDue,
|
|
174
|
+
value: g(o, i.notAvailable)
|
|
175
|
+
},
|
|
176
|
+
{
|
|
177
|
+
label: i.summaryCreated,
|
|
178
|
+
value: g(e.created_at, i.notAvailable)
|
|
179
|
+
},
|
|
180
|
+
{
|
|
181
|
+
label: i.summaryUpdated,
|
|
182
|
+
value: g(e.updated_at, i.notAvailable)
|
|
183
|
+
},
|
|
184
|
+
{
|
|
185
|
+
label: i.summaryTotal,
|
|
186
|
+
value: _({
|
|
187
|
+
amount: e.total_amount,
|
|
188
|
+
currency: e.currency,
|
|
189
|
+
fallback: i.notAvailable
|
|
190
|
+
})
|
|
191
|
+
},
|
|
192
|
+
{
|
|
193
|
+
label: i.summaryAmountDue,
|
|
194
|
+
value: _({
|
|
195
|
+
amount: a,
|
|
196
|
+
currency: e.currency,
|
|
197
|
+
fallback: i.notAvailable
|
|
198
|
+
})
|
|
199
|
+
}
|
|
200
|
+
],
|
|
201
|
+
lineItems: e.line_items.map((t, n) => ({
|
|
202
|
+
id: t.product.id || String(n),
|
|
203
|
+
name: t.product.name,
|
|
204
|
+
quantityLabel: String(t.quantity),
|
|
205
|
+
unitPriceLabel: _({
|
|
206
|
+
amount: t.product.price?.value,
|
|
207
|
+
currency: t.product.price?.currency || e.currency,
|
|
208
|
+
fallback: i.notAvailable
|
|
209
|
+
}),
|
|
210
|
+
totalLabel: _({
|
|
211
|
+
amount: t.total_after_tax ?? t.total_before_tax,
|
|
212
|
+
currency: e.currency,
|
|
213
|
+
fallback: i.notAvailable
|
|
214
|
+
})
|
|
215
|
+
})),
|
|
216
|
+
activityItems: t.map((e) => ({
|
|
217
|
+
id: e.id,
|
|
218
|
+
title: T(e.event_type, i),
|
|
219
|
+
description: e.event_type,
|
|
220
|
+
timestampLabel: g(e.timestamp, i.notAvailable)
|
|
221
|
+
})),
|
|
222
|
+
mailItems: n.map((e) => ({
|
|
223
|
+
id: e.id,
|
|
224
|
+
statusLabel: e.status,
|
|
225
|
+
recipientsLabel: E(e, i),
|
|
226
|
+
sentAtLabel: g(e.created_at, i.notAvailable)
|
|
227
|
+
})),
|
|
228
|
+
actions: S(e)
|
|
229
|
+
};
|
|
230
|
+
}
|
|
231
|
+
function T(e, t) {
|
|
232
|
+
return e === "status_changed" ? t.activityStatusChanged : e === "receivable_created" ? t.activityReceivableCreated : e === "receivable_updated" ? t.activityReceivableUpdated : e === "payment_received" ? t.activityPaymentReceived : e === "mail_sent" ? t.activityMailSent : t.activityUnknown;
|
|
233
|
+
}
|
|
234
|
+
function E(e, t) {
|
|
235
|
+
let n = [
|
|
236
|
+
...e.recipients?.to ?? [],
|
|
237
|
+
...e.recipients?.cc ?? [],
|
|
238
|
+
...e.recipients?.bcc ?? []
|
|
239
|
+
].map((e) => e.email).filter(Boolean);
|
|
240
|
+
return n.length > 0 ? n.join(", ") : t.recipientsNone;
|
|
241
|
+
}
|
|
242
|
+
function D({ values: e, billingAddressId: t, messages: n }) {
|
|
243
|
+
let r = {};
|
|
244
|
+
e.customerId ? t || (r.customerId = n.customerAddressRequired) : r.customerId = n.customerRequired, e.currency || (r.currency = n.currencyRequired);
|
|
245
|
+
let i = c(e.lineItems, {
|
|
246
|
+
currency: e.currency,
|
|
247
|
+
messages: n
|
|
248
|
+
});
|
|
249
|
+
return i && (r.lineItems = i, r.lineItemsSummary = s(i)), r;
|
|
250
|
+
}
|
|
251
|
+
function O(e) {
|
|
252
|
+
return Object.keys(e).length > 0;
|
|
253
|
+
}
|
|
254
|
+
function k({ values: e, billingAddressId: t, unitNamesById: n }) {
|
|
255
|
+
let a = e.lineItems.filter((e) => !r(e)).map((t) => i({
|
|
256
|
+
lineItem: t,
|
|
257
|
+
currency: e.currency,
|
|
258
|
+
unitNamesById: n
|
|
259
|
+
})), o = {
|
|
260
|
+
counterpart_billing_address_id: t,
|
|
261
|
+
counterpart_id: e.customerId,
|
|
262
|
+
currency: e.currency,
|
|
263
|
+
line_items: a,
|
|
264
|
+
memo: e.memo || void 0
|
|
265
|
+
};
|
|
266
|
+
return e.type === "quote" ? {
|
|
267
|
+
...o,
|
|
268
|
+
expiry_date: e.dueDate || void 0,
|
|
269
|
+
type: "quote"
|
|
270
|
+
} : {
|
|
271
|
+
...o,
|
|
272
|
+
payment_terms_id: e.paymentTermsId || void 0,
|
|
273
|
+
payment_terms: !e.paymentTermsId && e.dueDate ? { term_final: { end_date: e.dueDate } } : void 0,
|
|
274
|
+
type: "invoice"
|
|
275
|
+
};
|
|
276
|
+
}
|
|
277
|
+
function A(e, t) {
|
|
278
|
+
let r = e.type === "quote" ? "quote" : "invoice", i = e.type === "invoice" ? e.payment_terms?.id ?? "" : "", a = e.line_items.map((n) => o({
|
|
279
|
+
lineItem: n,
|
|
280
|
+
currency: e.currency,
|
|
281
|
+
units: t
|
|
282
|
+
}));
|
|
283
|
+
return {
|
|
284
|
+
...d(),
|
|
285
|
+
type: r,
|
|
286
|
+
customerId: e.counterpart_id,
|
|
287
|
+
currency: e.currency,
|
|
288
|
+
issueDate: N(e.issue_date),
|
|
289
|
+
dueDate: N(e.type === "quote" ? e.expiry_date : e.due_date),
|
|
290
|
+
memo: e.memo ?? "",
|
|
291
|
+
paymentTermsId: i,
|
|
292
|
+
lineItems: a.length > 0 ? a : [n(e.currency)]
|
|
293
|
+
};
|
|
294
|
+
}
|
|
295
|
+
function j({ values: e, billingAddressId: t, lineItemChanges: n }) {
|
|
296
|
+
let r = {
|
|
297
|
+
counterpart_billing_address_id: t,
|
|
298
|
+
counterpart_id: e.customerId,
|
|
299
|
+
currency: e.currency,
|
|
300
|
+
issue_date: e.issueDate || void 0,
|
|
301
|
+
memo: e.memo || void 0
|
|
302
|
+
};
|
|
303
|
+
return e.type === "quote" ? { quote: {
|
|
304
|
+
...r,
|
|
305
|
+
...n ? { line_items: n } : {},
|
|
306
|
+
expiry_date: e.dueDate || void 0,
|
|
307
|
+
payment_terms_id: e.paymentTermsId || void 0
|
|
308
|
+
} } : { invoice: {
|
|
309
|
+
...r,
|
|
310
|
+
...n ? { line_items: n } : {},
|
|
311
|
+
due_date: e.dueDate || void 0,
|
|
312
|
+
payment_terms_id: e.paymentTermsId || void 0,
|
|
313
|
+
payment_terms: !e.paymentTermsId && e.dueDate ? { term_final: { end_date: e.dueDate } } : void 0
|
|
314
|
+
} };
|
|
315
|
+
}
|
|
316
|
+
function M({ values: e, originalLineItems: t, originalCurrency: n, unitNamesById: i, units: s }) {
|
|
317
|
+
let c = (e, t) => a({
|
|
318
|
+
lineItem: e,
|
|
319
|
+
currency: t,
|
|
320
|
+
unitNamesById: i
|
|
321
|
+
}), l = new Map(t.map((e) => [e.id, JSON.stringify(c(o({
|
|
322
|
+
lineItem: e,
|
|
323
|
+
currency: n,
|
|
324
|
+
units: s
|
|
325
|
+
}), 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) => {
|
|
326
|
+
let n = l.get(t.id);
|
|
327
|
+
if (n === void 0) return [];
|
|
328
|
+
let r = c(t, e.currency);
|
|
329
|
+
return n === JSON.stringify(r) ? [] : [{
|
|
330
|
+
id: t.id,
|
|
331
|
+
data: r
|
|
332
|
+
}];
|
|
333
|
+
}), m = t.filter((e) => !d.has(e.id)).map((e) => e.id);
|
|
334
|
+
if (f.length || p.length || m.length) return {
|
|
335
|
+
...f.length ? { add: f } : {},
|
|
336
|
+
...p.length ? { replace: p } : {},
|
|
337
|
+
...m.length ? { remove: m } : {}
|
|
338
|
+
};
|
|
339
|
+
}
|
|
340
|
+
function N(e) {
|
|
341
|
+
return e?.slice(0, 10) ?? "";
|
|
342
|
+
}
|
|
343
|
+
function P(e) {
|
|
344
|
+
return (e ?? []).map((e) => ({
|
|
345
|
+
value: e.id,
|
|
346
|
+
label: e.name
|
|
347
|
+
}));
|
|
348
|
+
}
|
|
349
|
+
function F(e, t) {
|
|
350
|
+
let n = {};
|
|
351
|
+
return e.to.trim() || (n.to = t.sendToRequired), e.subject.trim() || (n.subject = t.sendSubjectRequired), e.body.trim() || (n.body = t.sendBodyRequired), n;
|
|
352
|
+
}
|
|
353
|
+
function I(e) {
|
|
354
|
+
return Object.keys(e).length > 0;
|
|
355
|
+
}
|
|
356
|
+
function L(e) {
|
|
357
|
+
return e.split(",").map((e) => e.trim()).filter(Boolean);
|
|
358
|
+
}
|
|
359
|
+
function R(e, t, n) {
|
|
360
|
+
let r = {};
|
|
361
|
+
if (e.mode === "partial") {
|
|
362
|
+
let i = v(e.amountPaid, n);
|
|
363
|
+
(!i || i <= 0) && (r.amountPaid = t.paymentAmountInvalid);
|
|
364
|
+
}
|
|
365
|
+
return r;
|
|
366
|
+
}
|
|
367
|
+
function z(e) {
|
|
368
|
+
return Object.keys(e).length > 0;
|
|
369
|
+
}
|
|
370
|
+
function B(e, t) {
|
|
371
|
+
return {
|
|
372
|
+
...l,
|
|
373
|
+
to: e?.counterpart_contact?.email ?? "",
|
|
374
|
+
subject: e?.document_id ? `${t.sendSubjectDefault} ${e.document_id}` : t.sendSubjectDefault,
|
|
375
|
+
body: t.sendBodyDefault
|
|
376
|
+
};
|
|
377
|
+
}
|
|
378
|
+
function V() {
|
|
379
|
+
return {
|
|
380
|
+
...u,
|
|
381
|
+
paidAt: (/* @__PURE__ */ new Date()).toISOString().slice(0, 10)
|
|
382
|
+
};
|
|
383
|
+
}
|
|
384
|
+
function H() {
|
|
385
|
+
return [
|
|
386
|
+
"draft",
|
|
387
|
+
"issued",
|
|
388
|
+
"failed",
|
|
389
|
+
"accepted",
|
|
390
|
+
"expired",
|
|
391
|
+
"declined",
|
|
392
|
+
"recurring",
|
|
393
|
+
"partially_paid",
|
|
394
|
+
"paid",
|
|
395
|
+
"overdue",
|
|
396
|
+
"uncollectible",
|
|
397
|
+
"canceled"
|
|
398
|
+
].map((e) => ({
|
|
399
|
+
value: e,
|
|
400
|
+
label: e.split("_").map((e) => `${e.slice(0, 1).toUpperCase()}${e.slice(1)}`).join(" ")
|
|
401
|
+
}));
|
|
402
|
+
}
|
|
62
403
|
//#endregion
|
|
63
|
-
export {
|
|
404
|
+
export { u as EMPTY_RECEIVABLE_PAYMENT_VALUES, l as EMPTY_RECEIVABLE_SEND_VALUES, S as buildReceivableActions, w as buildReceivableDetailsView, C as buildReceivableRows, m as coerceEnabledTabs, d as createEmptyReceivableFormValues, n as createLineItem, V as defaultPaymentValues, B as defaultSendValues, g as formatDate, _ as formatMoney, v as fromMajorUnits, y as getDocumentTitle, b as getDocumentTypeLabel, P as getPaymentTermOptions, x as getStatusTone, z as hasPaymentErrors, O as hasReceivableFormErrors, I as hasSendErrors, k as receivableFormValuesToCreatePayload, M as receivableFormValuesToLineItemChanges, j as receivableFormValuesToUpdatePayload, A as receivableToFormValues, h as resolveInitialTab, L as splitEmailList, H as statusFilterOptions, p as tabForType, f as typeForTab, R as validatePaymentValues, D as validateReceivableForm, F as validateSendValues };
|