@tesouro/embedded-components-react 0.5.204 → 0.5.206
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 +15 -14
- package/dist/index.d.ts +49 -4
- package/dist/index.js +1 -1
- package/dist/lib/ReceivablesWidget.d.ts +49 -4
- package/dist/lib/ReceivablesWidget.js +1 -1
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index.js +7 -7
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index2.js +26 -23
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index3.js +79 -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 +88 -193
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index11.js +184 -31
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index12.js +32 -145
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index13.js +150 -47
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index14.js +37 -293
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index15.js +58 -70
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index16.js +86 -99
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index17.js +48 -233
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index18.js +336 -0
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index19.js +75 -0
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index20.js +115 -0
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index21.js +270 -0
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index5.js +1 -1
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index8.js +95 -394
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index9.js +422 -72
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index.js +15 -10
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index10.js +94 -1
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index11.js +3 -4
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index12.js +24 -11
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index13.js +1 -1
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index14.js +3 -264
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index15.js +3 -72
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index16.js +16 -421
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index17.js +1 -106
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index18.js +4 -93
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index19.js +11 -343
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index2.js +5 -159
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index20.js +1 -0
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index21.js +264 -0
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index22.js +72 -0
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index23.js +401 -0
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index24.js +106 -0
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index25.js +93 -0
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index26.js +344 -0
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index3.js +182 -32
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index4.js +27 -154
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index5.js +203 -20
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index6.js +161 -1
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index7.js +16 -3
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index8.js +25 -3
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index9.js +3 -17
- package/dist/libs/tesouro-embedded-components-react/shared/data-access/dist/index.js +38 -38
- package/dist/libs/tesouro-embedded-components-react/shared/data-access/dist/lib/rest/@tanstack/react-query.gen.js +213 -202
- package/dist/libs/tesouro-embedded-components-react/shared/data-access/dist/lib/rest/sdk.gen.js +136 -116
- package/dist/libs/tesouro-embedded-components-react/shared/feature/dist/lib/analytics/build-info.js +1 -1
- package/dist/packages/shared-ui-shadcn/dist/index.js +1763 -1749
- package/package.json +1 -1
|
@@ -1,417 +1,118 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
import { attachmentFormValuesToPayload as u, receivableToAttachmentFormValues as d } from "./index7.js";
|
|
1
|
+
import { RECEIVABLE_PAYMENT_TERMS_CUSTOM_DATE as e, RECEIVABLE_PAYMENT_TERMS_RECEIPT_DUE as t } from "../../ui/dist/index9.js";
|
|
2
|
+
import "../../ui/dist/index.js";
|
|
3
|
+
import { addDays as n, addYears as r, format as i, max as a, min as o, parseISO as s, subYears as c } from "date-fns";
|
|
5
4
|
//#region ../../libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index8.js
|
|
6
|
-
var f =
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
function m() {
|
|
19
|
-
return {
|
|
20
|
-
type: "invoice",
|
|
21
|
-
customerId: "",
|
|
22
|
-
currency: "USD",
|
|
23
|
-
issueDate: (/* @__PURE__ */ new Date()).toISOString().slice(0, 10),
|
|
24
|
-
dueDate: "",
|
|
25
|
-
openingNote: "",
|
|
26
|
-
closingNote: "",
|
|
27
|
-
paymentTermsId: "",
|
|
28
|
-
taxRate: "",
|
|
29
|
-
lineItems: [n()],
|
|
30
|
-
attachments: []
|
|
31
|
-
};
|
|
32
|
-
}
|
|
33
|
-
function h(e) {
|
|
34
|
-
return e === "quotes" ? "quote" : e === "credit_notes" ? "credit_note" : "invoice";
|
|
35
|
-
}
|
|
36
|
-
function g(e) {
|
|
37
|
-
return e === "quote" ? "quotes" : e === "credit_note" ? "credit_notes" : "invoices";
|
|
38
|
-
}
|
|
39
|
-
function _(e) {
|
|
40
|
-
return (e?.length ? e : [
|
|
41
|
-
"invoices",
|
|
42
|
-
"quotes",
|
|
43
|
-
"credit_notes"
|
|
44
|
-
]).filter((e, t, n) => [
|
|
45
|
-
"invoices",
|
|
46
|
-
"quotes",
|
|
47
|
-
"credit_notes"
|
|
48
|
-
].includes(e) && n.indexOf(e) === t);
|
|
49
|
-
}
|
|
50
|
-
function v({ defaultTab: e, enabledTabs: t }) {
|
|
51
|
-
return e && t.includes(e) ? e : t[0] ?? "invoices";
|
|
52
|
-
}
|
|
53
|
-
function y(e, n) {
|
|
54
|
-
let r = t(e);
|
|
55
|
-
return r ? new Intl.DateTimeFormat(void 0, {
|
|
56
|
-
day: "numeric",
|
|
57
|
-
month: "short",
|
|
58
|
-
year: "numeric"
|
|
59
|
-
}).format(r) : n;
|
|
60
|
-
}
|
|
61
|
-
function b({ amount: t, currency: n, fallback: r }) {
|
|
62
|
-
return t == null || !n ? r : new Intl.NumberFormat(void 0, {
|
|
63
|
-
currency: n,
|
|
64
|
-
style: "currency"
|
|
65
|
-
}).format(t / 10 ** e(n));
|
|
66
|
-
}
|
|
67
|
-
function x(t, n) {
|
|
68
|
-
let r = Number(t);
|
|
69
|
-
if (!Number.isFinite(r)) return;
|
|
70
|
-
let i = n ? e(n) : 2;
|
|
71
|
-
return Math.round(r * 10 ** i);
|
|
72
|
-
}
|
|
73
|
-
function S(e, t) {
|
|
74
|
-
return e.document_id || t.untitledDocument;
|
|
75
|
-
}
|
|
76
|
-
function C(e, t) {
|
|
77
|
-
return e === "quote" ? t.quoteType : e === "credit_note" ? t.creditNoteType : t.invoiceType;
|
|
78
|
-
}
|
|
79
|
-
function w(e) {
|
|
80
|
-
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";
|
|
81
|
-
}
|
|
82
|
-
function T(e) {
|
|
83
|
-
let t = e.status === "draft", n = e.status === "issued", r = e.type === "invoice", i = e.type === "quote", a = e.type === "credit_note", o = r && [
|
|
84
|
-
"issued",
|
|
85
|
-
"overdue",
|
|
86
|
-
"partially_paid"
|
|
87
|
-
].includes(e.status);
|
|
88
|
-
return {
|
|
89
|
-
edit: t && !a,
|
|
90
|
-
accept: i && n,
|
|
91
|
-
cancel: ![
|
|
92
|
-
"paid",
|
|
93
|
-
"canceled",
|
|
94
|
-
"deleted",
|
|
95
|
-
"uncollectible"
|
|
96
|
-
].includes(e.status) && !t,
|
|
97
|
-
clone: !a && e.status !== "deleted",
|
|
98
|
-
decline: i && n,
|
|
99
|
-
delete: t,
|
|
100
|
-
issue: t,
|
|
101
|
-
markPaid: o,
|
|
102
|
-
markUncollectible: o,
|
|
103
|
-
recordPayment: o,
|
|
104
|
-
send: [
|
|
105
|
-
"issued",
|
|
106
|
-
"accepted",
|
|
107
|
-
"overdue",
|
|
108
|
-
"partially_paid"
|
|
109
|
-
].includes(e.status) && !a
|
|
110
|
-
};
|
|
111
|
-
}
|
|
112
|
-
function E({ receivables: e, messages: t }) {
|
|
113
|
-
return e.map((e) => {
|
|
114
|
-
let n = e.type === "invoice" ? e.amount_due : void 0;
|
|
115
|
-
return {
|
|
116
|
-
id: e.id,
|
|
117
|
-
type: e.type,
|
|
118
|
-
documentLabel: S(e, t),
|
|
119
|
-
customerLabel: e.counterpart_name || t.unknownCustomer,
|
|
120
|
-
status: e.status,
|
|
121
|
-
statusTone: w(e.status),
|
|
122
|
-
issueDateLabel: y(e.issue_date, t.notAvailable),
|
|
123
|
-
dueDateLabel: y(e.type === "quote" ? e.expiry_date : e.due_date, t.notAvailable),
|
|
124
|
-
totalLabel: b({
|
|
125
|
-
amount: e.total_amount,
|
|
126
|
-
currency: e.currency,
|
|
127
|
-
fallback: t.notAvailable
|
|
128
|
-
}),
|
|
129
|
-
amountDueLabel: b({
|
|
130
|
-
amount: n,
|
|
131
|
-
currency: e.currency,
|
|
132
|
-
fallback: t.notAvailable
|
|
133
|
-
}),
|
|
134
|
-
actions: T(e)
|
|
135
|
-
};
|
|
5
|
+
var l = "MMM d, yyyy", u = "yyyy-MM-dd", d = 10, f = 5;
|
|
6
|
+
function p(e) {
|
|
7
|
+
let t = (e) => e ? {
|
|
8
|
+
number_of_days: e.number_of_days ?? null,
|
|
9
|
+
discount: e.discount ?? null
|
|
10
|
+
} : null;
|
|
11
|
+
return JSON.stringify({
|
|
12
|
+
name: e.name,
|
|
13
|
+
description: e.description ?? null,
|
|
14
|
+
term_final: { number_of_days: e.term_final?.number_of_days ?? null },
|
|
15
|
+
term_1: t(e.term_1),
|
|
16
|
+
term_2: t(e.term_2)
|
|
136
17
|
});
|
|
137
18
|
}
|
|
138
|
-
function
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
type: e.type,
|
|
144
|
-
title: S(e, i),
|
|
145
|
-
customerLabel: e.counterpart_name || i.unknownCustomer,
|
|
146
|
-
status: e.status,
|
|
147
|
-
statusTone: w(e.status),
|
|
148
|
-
totalLabel: b({
|
|
149
|
-
amount: e.total_amount,
|
|
150
|
-
currency: e.currency,
|
|
151
|
-
fallback: i.notAvailable
|
|
152
|
-
}),
|
|
153
|
-
amountDueLabel: b({
|
|
154
|
-
amount: a,
|
|
155
|
-
currency: e.currency,
|
|
156
|
-
fallback: i.notAvailable
|
|
157
|
-
}),
|
|
158
|
-
pdfUrl: r || e.file_url || e.original_file_url || void 0,
|
|
159
|
-
summaryItems: [
|
|
160
|
-
{
|
|
161
|
-
label: i.summaryDocumentType,
|
|
162
|
-
value: C(e.type, i)
|
|
163
|
-
},
|
|
164
|
-
{
|
|
165
|
-
label: i.summaryDocumentNumber,
|
|
166
|
-
value: S(e, i)
|
|
167
|
-
},
|
|
168
|
-
{
|
|
169
|
-
label: i.summaryCustomer,
|
|
170
|
-
value: e.counterpart_name || i.unknownCustomer
|
|
171
|
-
},
|
|
172
|
-
{
|
|
173
|
-
label: i.summaryIssued,
|
|
174
|
-
value: y(e.issue_date, i.notAvailable)
|
|
175
|
-
},
|
|
176
|
-
{
|
|
177
|
-
label: i.summaryDue,
|
|
178
|
-
value: y(o, i.notAvailable)
|
|
179
|
-
},
|
|
180
|
-
{
|
|
181
|
-
label: i.summaryCreated,
|
|
182
|
-
value: y(e.created_at, i.notAvailable)
|
|
183
|
-
},
|
|
184
|
-
{
|
|
185
|
-
label: i.summaryUpdated,
|
|
186
|
-
value: y(e.updated_at, i.notAvailable)
|
|
187
|
-
},
|
|
188
|
-
{
|
|
189
|
-
label: i.summaryTotal,
|
|
190
|
-
value: b({
|
|
191
|
-
amount: e.total_amount,
|
|
192
|
-
currency: e.currency,
|
|
193
|
-
fallback: i.notAvailable
|
|
194
|
-
})
|
|
195
|
-
},
|
|
196
|
-
{
|
|
197
|
-
label: i.summaryAmountDue,
|
|
198
|
-
value: b({
|
|
199
|
-
amount: a,
|
|
200
|
-
currency: e.currency,
|
|
201
|
-
fallback: i.notAvailable
|
|
202
|
-
})
|
|
203
|
-
}
|
|
204
|
-
],
|
|
205
|
-
lineItems: e.line_items.map((t, n) => ({
|
|
206
|
-
id: t.product.id || String(n),
|
|
207
|
-
name: t.product.name,
|
|
208
|
-
quantityLabel: String(t.quantity),
|
|
209
|
-
unitPriceLabel: b({
|
|
210
|
-
amount: t.product.price?.value,
|
|
211
|
-
currency: t.product.price?.currency || e.currency,
|
|
212
|
-
fallback: i.notAvailable
|
|
213
|
-
}),
|
|
214
|
-
totalLabel: b({
|
|
215
|
-
amount: t.total_after_tax ?? t.total_before_tax,
|
|
216
|
-
currency: e.currency,
|
|
217
|
-
fallback: i.notAvailable
|
|
218
|
-
})
|
|
219
|
-
})),
|
|
220
|
-
activityItems: t.map((e) => ({
|
|
221
|
-
id: e.id,
|
|
222
|
-
title: O(e.event_type, i),
|
|
223
|
-
description: e.event_type,
|
|
224
|
-
timestampLabel: y(e.timestamp, i.notAvailable)
|
|
225
|
-
})),
|
|
226
|
-
mailItems: n.map((e) => ({
|
|
227
|
-
id: e.id,
|
|
228
|
-
statusLabel: e.status,
|
|
229
|
-
recipientsLabel: k(e, i),
|
|
230
|
-
sentAtLabel: y(e.created_at, i.notAvailable)
|
|
231
|
-
})),
|
|
232
|
-
actions: T(e)
|
|
233
|
-
};
|
|
234
|
-
}
|
|
235
|
-
function O(e, t) {
|
|
236
|
-
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;
|
|
237
|
-
}
|
|
238
|
-
function k(e, t) {
|
|
239
|
-
let n = [
|
|
240
|
-
...e.recipients?.to ?? [],
|
|
241
|
-
...e.recipients?.cc ?? [],
|
|
242
|
-
...e.recipients?.bcc ?? []
|
|
243
|
-
].map((e) => e.email).filter(Boolean);
|
|
244
|
-
return n.length > 0 ? n.join(", ") : t.recipientsNone;
|
|
245
|
-
}
|
|
246
|
-
function A({ values: e, billingAddressId: t, messages: n }) {
|
|
247
|
-
let r = {};
|
|
248
|
-
e.customerId ? t || (r.customerId = n.customerAddressRequired) : r.customerId = n.customerRequired, e.currency || (r.currency = n.currencyRequired);
|
|
249
|
-
let i = l(e.lineItems, {
|
|
250
|
-
currency: e.currency,
|
|
251
|
-
messages: n
|
|
19
|
+
function m(e) {
|
|
20
|
+
let t = /* @__PURE__ */ new Set();
|
|
21
|
+
return e.filter((e) => {
|
|
22
|
+
let n = p(e);
|
|
23
|
+
return !t.has(n) && (t.add(n), !0);
|
|
252
24
|
});
|
|
253
|
-
return i && (r.lineItems = i, r.lineItemsSummary = s(i)), r;
|
|
254
25
|
}
|
|
255
|
-
function
|
|
256
|
-
|
|
26
|
+
function h(e, t) {
|
|
27
|
+
let r = e.term_final?.number_of_days;
|
|
28
|
+
return r ? n(t, r) : void 0;
|
|
257
29
|
}
|
|
258
|
-
function
|
|
259
|
-
let
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
})), o = {
|
|
265
|
-
counterpart_billing_address_id: t,
|
|
266
|
-
counterpart_id: e.customerId,
|
|
267
|
-
currency: e.currency,
|
|
268
|
-
line_items: a,
|
|
269
|
-
memo: e.openingNote,
|
|
270
|
-
footer: e.closingNote
|
|
271
|
-
};
|
|
272
|
-
return e.type === "quote" ? {
|
|
273
|
-
...o,
|
|
274
|
-
expiry_date: e.dueDate || void 0,
|
|
275
|
-
type: "quote"
|
|
276
|
-
} : {
|
|
277
|
-
...o,
|
|
278
|
-
payment_terms_id: e.paymentTermsId || void 0,
|
|
279
|
-
payment_terms: !e.paymentTermsId && e.dueDate ? { term_final: { end_date: e.dueDate } } : void 0,
|
|
280
|
-
attachments: u(e.attachments),
|
|
281
|
-
type: "invoice"
|
|
30
|
+
function g(e, t) {
|
|
31
|
+
let n = h(e, t);
|
|
32
|
+
return {
|
|
33
|
+
value: e.id,
|
|
34
|
+
label: e.name,
|
|
35
|
+
...n ? { dueDateLabel: i(n, l) } : {}
|
|
282
36
|
};
|
|
283
37
|
}
|
|
284
|
-
function
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
38
|
+
function _(e) {
|
|
39
|
+
return e ? s(e) : void 0;
|
|
40
|
+
}
|
|
41
|
+
function v({ terms: e, isLoading: t, fields: n, customDatePickerOpen: r, messages: a, today: o = /* @__PURE__ */ new Date() }) {
|
|
42
|
+
if (t) return { kind: "loading" };
|
|
43
|
+
let s = m(e ?? []).map((e) => g(e, o)), c = _(n.paymentTermsCustomDate), u;
|
|
44
|
+
if (n.paymentTermsId === "receipt_due") u = { kind: "receiptDue" };
|
|
45
|
+
else if (n.paymentTermsId === "custom") u = {
|
|
46
|
+
kind: "customDate",
|
|
47
|
+
hasDate: !!c,
|
|
48
|
+
dateLabel: c ? i(c, l) : a.paymentTermsCustomDatePlaceholder
|
|
49
|
+
};
|
|
50
|
+
else {
|
|
51
|
+
let e = s.find((e) => e.value === n.paymentTermsId);
|
|
52
|
+
e && (u = {
|
|
53
|
+
kind: "term",
|
|
54
|
+
option: e
|
|
55
|
+
});
|
|
56
|
+
}
|
|
290
57
|
return {
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
dueDate: I(e.type === "quote" ? e.expiry_date : e.due_date),
|
|
297
|
-
openingNote: e.memo ?? "",
|
|
298
|
-
closingNote: e.footer ?? "",
|
|
299
|
-
paymentTermsId: i,
|
|
300
|
-
taxRate: c(e.line_items),
|
|
301
|
-
lineItems: a.length > 0 ? a : [n(e.currency)],
|
|
302
|
-
attachments: d(e)
|
|
58
|
+
kind: "ready",
|
|
59
|
+
value: n.paymentTermsId,
|
|
60
|
+
options: s,
|
|
61
|
+
selection: u,
|
|
62
|
+
customDatePicker: { open: r }
|
|
303
63
|
};
|
|
304
64
|
}
|
|
305
|
-
function
|
|
306
|
-
let
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
memo: e.openingNote,
|
|
312
|
-
footer: e.closingNote
|
|
65
|
+
function y(e, t = /* @__PURE__ */ new Date()) {
|
|
66
|
+
let n = _(e), i = c(t, d), s = r(t, f);
|
|
67
|
+
return {
|
|
68
|
+
selected: n,
|
|
69
|
+
startMonth: n ? o([i, n]) : i,
|
|
70
|
+
endMonth: n ? a([s, n]) : s
|
|
313
71
|
};
|
|
314
|
-
return e.type === "quote" ? { quote: {
|
|
315
|
-
...r,
|
|
316
|
-
...n ? { line_items: n } : {},
|
|
317
|
-
expiry_date: e.dueDate || void 0,
|
|
318
|
-
payment_terms_id: e.paymentTermsId || void 0
|
|
319
|
-
} } : { invoice: {
|
|
320
|
-
...r,
|
|
321
|
-
...n ? { line_items: n } : {},
|
|
322
|
-
due_date: e.dueDate || void 0,
|
|
323
|
-
payment_terms_id: e.paymentTermsId || void 0,
|
|
324
|
-
payment_terms: !e.paymentTermsId && e.dueDate ? { term_final: { end_date: e.dueDate } } : void 0,
|
|
325
|
-
attachments: u(e.attachments) ?? null
|
|
326
|
-
} };
|
|
327
72
|
}
|
|
328
|
-
function
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
lineItem: e,
|
|
336
|
-
currency: n,
|
|
337
|
-
units: s
|
|
338
|
-
}), n, u))])), f = e.lineItems.filter((e) => !r(e)), p = new Set(f.map((e) => e.id)), m = f.filter((e) => !d.has(e.id)).map((t) => l(t, e.currency, e.taxRate)), h = f.flatMap((t) => {
|
|
339
|
-
let n = d.get(t.id);
|
|
340
|
-
if (n === void 0) return [];
|
|
341
|
-
let r = l(t, e.currency, e.taxRate);
|
|
342
|
-
return n === JSON.stringify(r) ? [] : [{
|
|
343
|
-
id: t.id,
|
|
344
|
-
data: r
|
|
345
|
-
}];
|
|
346
|
-
}), g = t.filter((e) => !p.has(e.id)).map((e) => e.id);
|
|
347
|
-
if (m.length || h.length || g.length) return {
|
|
348
|
-
...m.length ? { add: m } : {},
|
|
349
|
-
...h.length ? { replace: h } : {},
|
|
350
|
-
...g.length ? { remove: g } : {}
|
|
73
|
+
function b(e, t) {
|
|
74
|
+
return t === "custom" ? {
|
|
75
|
+
paymentTermsId: t,
|
|
76
|
+
paymentTermsCustomDate: e.paymentTermsId === "custom" ? e.paymentTermsCustomDate : ""
|
|
77
|
+
} : {
|
|
78
|
+
paymentTermsId: t,
|
|
79
|
+
paymentTermsCustomDate: ""
|
|
351
80
|
};
|
|
352
81
|
}
|
|
353
|
-
function
|
|
354
|
-
return e
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
value: e.id,
|
|
359
|
-
label: e.name
|
|
360
|
-
}));
|
|
361
|
-
}
|
|
362
|
-
function R(e, t) {
|
|
363
|
-
let n = {};
|
|
364
|
-
return e.to.trim() || (n.to = t.sendToRequired), e.subject.trim() || (n.subject = t.sendSubjectRequired), e.body.trim() || (n.body = t.sendBodyRequired), n;
|
|
365
|
-
}
|
|
366
|
-
function z(e) {
|
|
367
|
-
return Object.keys(e).length > 0;
|
|
368
|
-
}
|
|
369
|
-
function B(e) {
|
|
370
|
-
return e.split(",").map((e) => e.trim()).filter(Boolean);
|
|
82
|
+
function x(e) {
|
|
83
|
+
return e.paymentTermsId === "custom" && !e.paymentTermsCustomDate ? {
|
|
84
|
+
paymentTermsId: "",
|
|
85
|
+
paymentTermsCustomDate: ""
|
|
86
|
+
} : e;
|
|
371
87
|
}
|
|
372
|
-
function
|
|
373
|
-
|
|
374
|
-
if (e.mode === "partial") {
|
|
375
|
-
let i = x(e.amountPaid, n);
|
|
376
|
-
(!i || i <= 0) && (r.amountPaid = t.paymentAmountInvalid);
|
|
377
|
-
}
|
|
378
|
-
return r;
|
|
88
|
+
function S(e) {
|
|
89
|
+
return e ? i(e, u) : "";
|
|
379
90
|
}
|
|
380
|
-
function
|
|
381
|
-
return
|
|
91
|
+
function C(e) {
|
|
92
|
+
return e.paymentTermsId === "custom" ? e.paymentTermsCustomDate ? { payment_terms: { term_final: { end_date: e.paymentTermsCustomDate } } } : { payment_terms: { term_final: { number_of_days: 0 } } } : e.paymentTermsId === "receipt_due" ? { payment_terms: { term_final: { number_of_days: 0 } } } : e.paymentTermsId ? { payment_terms_id: e.paymentTermsId } : {};
|
|
382
93
|
}
|
|
383
|
-
function
|
|
384
|
-
return {
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
subject: e?.document_id ? `${t.sendSubjectDefault} ${e.document_id}` : t.sendSubjectDefault,
|
|
388
|
-
body: t.sendBodyDefault
|
|
94
|
+
function w(e) {
|
|
95
|
+
return e.paymentTermsId ? C(e) : {
|
|
96
|
+
payment_terms_id: null,
|
|
97
|
+
payment_terms: null
|
|
389
98
|
};
|
|
390
99
|
}
|
|
391
|
-
function
|
|
392
|
-
return {
|
|
393
|
-
|
|
394
|
-
|
|
100
|
+
function T(n) {
|
|
101
|
+
if (n?.id) return {
|
|
102
|
+
paymentTermsId: n.id,
|
|
103
|
+
paymentTermsCustomDate: ""
|
|
104
|
+
};
|
|
105
|
+
let r = n?.term_final?.end_date;
|
|
106
|
+
return r ? {
|
|
107
|
+
paymentTermsId: e,
|
|
108
|
+
paymentTermsCustomDate: r.slice(0, 10)
|
|
109
|
+
} : n?.term_final?.number_of_days === 0 ? {
|
|
110
|
+
paymentTermsId: t,
|
|
111
|
+
paymentTermsCustomDate: ""
|
|
112
|
+
} : {
|
|
113
|
+
paymentTermsId: "",
|
|
114
|
+
paymentTermsCustomDate: ""
|
|
395
115
|
};
|
|
396
|
-
}
|
|
397
|
-
function G() {
|
|
398
|
-
return [
|
|
399
|
-
"draft",
|
|
400
|
-
"issued",
|
|
401
|
-
"failed",
|
|
402
|
-
"accepted",
|
|
403
|
-
"expired",
|
|
404
|
-
"declined",
|
|
405
|
-
"recurring",
|
|
406
|
-
"partially_paid",
|
|
407
|
-
"paid",
|
|
408
|
-
"overdue",
|
|
409
|
-
"uncollectible",
|
|
410
|
-
"canceled"
|
|
411
|
-
].map((e) => ({
|
|
412
|
-
value: e,
|
|
413
|
-
label: e.split("_").map((e) => `${e.slice(0, 1).toUpperCase()}${e.slice(1)}`).join(" ")
|
|
414
|
-
}));
|
|
415
116
|
}
|
|
416
117
|
//#endregion
|
|
417
|
-
export {
|
|
118
|
+
export { y as buildCustomDateCalendar, C as buildPaymentTermsPayload, w as buildPaymentTermsUpdatePayload, v as buildPaymentTermsView, x as closeCustomDatePickerFields, m as dedupePaymentTerms, T as paymentTermsToFormFields, b as selectPaymentTermsFields, S as toCustomDateValue };
|