@tesouro/embedded-components-react 0.5.201 → 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 +16 -0
- package/dist/index.js +1 -1
- package/dist/lib/ReceivablesWidget.d.ts +16 -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 +188 -45
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index11.js +30 -265
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index12.js +144 -64
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index13.js +47 -109
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index14.js +293 -216
- 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 +28 -243
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index6.js +212 -375
- 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 -398
- 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 +6 -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,195 +1,417 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
import { extractApiErrorMessage as e } from "../../../shared/util/dist/lib/apiErrors.js";
|
|
6
|
-
import { defaultPaymentValues as t, defaultSendValues as n, fromMajorUnits as r, hasPaymentErrors as i, hasSendErrors as a, splitEmailList as o, validatePaymentValues as s, validateSendValues as c } from "./index6.js";
|
|
7
|
-
import { useSendReceivableEmailMutation as l } from "../../data-access/dist/index5.js";
|
|
8
|
-
import { useAcceptReceivableMutation as ee, useCancelReceivableMutation as te, useCloneReceivableMutation as u, useDeclineReceivableMutation as d, useDeleteReceivableMutation as f, useIssueReceivableMutation as p } from "../../data-access/dist/index6.js";
|
|
9
|
-
import { useMarkReceivablePaidMutation as m, useMarkReceivablePartiallyPaidMutation as h, useMarkReceivableUncollectibleMutation as g } from "../../data-access/dist/index8.js";
|
|
10
|
-
import "../../data-access/dist/index.js";
|
|
11
|
-
import { useCallback as _, useState as v } from "react";
|
|
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, taxRateFromLineItems as c, validateLineItems as l } from "./index6.js";
|
|
4
|
+
import { attachmentFormValuesToPayload as u, receivableToAttachmentFormValues as d } from "./index7.js";
|
|
12
5
|
//#region ../../libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index8.js
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
G({
|
|
27
|
-
...o,
|
|
28
|
-
currency: s?.currency
|
|
29
|
-
}), q(t()), Y({});
|
|
30
|
-
return;
|
|
31
|
-
}
|
|
32
|
-
L(void 0), F(o);
|
|
33
|
-
}, [x, y]), Z = _(() => {
|
|
34
|
-
F(void 0), L(void 0);
|
|
35
|
-
}, []), Q = _(() => {
|
|
36
|
-
z(void 0), U({});
|
|
37
|
-
}, []), $ = _(() => {
|
|
38
|
-
G(void 0), Y({});
|
|
39
|
-
}, []), ne = _(async () => {
|
|
40
|
-
if (!P) return;
|
|
41
|
-
let t = { receivable_id: P.id };
|
|
42
|
-
try {
|
|
43
|
-
if (P.action === "issue") await w.mutateAsync({ path: t });
|
|
44
|
-
else if (P.action === "cancel") await T.mutateAsync({ path: t });
|
|
45
|
-
else if (P.action === "clone") {
|
|
46
|
-
let e = await E.mutateAsync({ path: t });
|
|
47
|
-
e?.id && S?.(e.id, e.type);
|
|
48
|
-
} else P.action === "accept" ? await D.mutateAsync({ path: t }) : P.action === "decline" ? await O.mutateAsync({ path: t }) : P.action === "delete" ? (await k.mutateAsync({ path: t }), C?.(P.id)) : P.action === "markPaid" ? await j.mutateAsync({
|
|
49
|
-
path: t,
|
|
50
|
-
body: { paid_at: (/* @__PURE__ */ new Date()).toISOString() }
|
|
51
|
-
}) : P.action === "markUncollectible" && await N.mutateAsync({ path: t });
|
|
52
|
-
F(void 0), L(void 0);
|
|
53
|
-
} catch (t) {
|
|
54
|
-
L(e(t) ?? x.genericError);
|
|
55
|
-
}
|
|
56
|
-
}, [
|
|
57
|
-
D,
|
|
58
|
-
P,
|
|
59
|
-
T,
|
|
60
|
-
E,
|
|
61
|
-
O,
|
|
62
|
-
k,
|
|
63
|
-
w,
|
|
64
|
-
j,
|
|
65
|
-
x.genericError,
|
|
66
|
-
S,
|
|
67
|
-
C,
|
|
68
|
-
N
|
|
69
|
-
]), re = _(async () => {
|
|
70
|
-
if (!R) return;
|
|
71
|
-
let t = c(B, x);
|
|
72
|
-
if (a(t)) {
|
|
73
|
-
U(t);
|
|
74
|
-
return;
|
|
75
|
-
}
|
|
76
|
-
try {
|
|
77
|
-
await A.mutateAsync({
|
|
78
|
-
path: { receivable_id: R.id },
|
|
79
|
-
body: {
|
|
80
|
-
body_text: B.body,
|
|
81
|
-
subject_text: B.subject,
|
|
82
|
-
recipients: {
|
|
83
|
-
to: o(B.to),
|
|
84
|
-
cc: o(B.cc),
|
|
85
|
-
bcc: o(B.bcc)
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
}), Q();
|
|
89
|
-
} catch (t) {
|
|
90
|
-
U({ form: e(t) ?? x.genericError });
|
|
91
|
-
}
|
|
92
|
-
}, [
|
|
93
|
-
Q,
|
|
94
|
-
x,
|
|
95
|
-
A,
|
|
96
|
-
R,
|
|
97
|
-
B
|
|
98
|
-
]), ie = _(async () => {
|
|
99
|
-
if (!W) return;
|
|
100
|
-
let t = s(K, x, W.currency);
|
|
101
|
-
if (i(t)) {
|
|
102
|
-
Y(t);
|
|
103
|
-
return;
|
|
104
|
-
}
|
|
105
|
-
try {
|
|
106
|
-
let e = { receivable_id: W.id }, t = K.paidAt ? new Date(K.paidAt).toISOString() : void 0;
|
|
107
|
-
K.mode === "full" ? await j.mutateAsync({
|
|
108
|
-
path: e,
|
|
109
|
-
body: {
|
|
110
|
-
comment: K.comment || void 0,
|
|
111
|
-
paid_at: t
|
|
112
|
-
}
|
|
113
|
-
}) : await M.mutateAsync({
|
|
114
|
-
path: e,
|
|
115
|
-
body: {
|
|
116
|
-
amount_paid: r(K.amountPaid, W.currency) ?? 0,
|
|
117
|
-
comment: K.comment || void 0
|
|
118
|
-
}
|
|
119
|
-
}), $();
|
|
120
|
-
} catch (t) {
|
|
121
|
-
Y({ form: e(t) ?? x.genericError });
|
|
122
|
-
}
|
|
123
|
-
}, [
|
|
124
|
-
$,
|
|
125
|
-
j,
|
|
126
|
-
x,
|
|
127
|
-
M,
|
|
128
|
-
W,
|
|
129
|
-
K
|
|
130
|
-
]);
|
|
6
|
+
var f = {
|
|
7
|
+
to: "",
|
|
8
|
+
cc: "",
|
|
9
|
+
bcc: "",
|
|
10
|
+
subject: "",
|
|
11
|
+
body: ""
|
|
12
|
+
}, p = {
|
|
13
|
+
mode: "full",
|
|
14
|
+
amountPaid: "",
|
|
15
|
+
paidAt: "",
|
|
16
|
+
comment: ""
|
|
17
|
+
};
|
|
18
|
+
function m() {
|
|
131
19
|
return {
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
setSendValues: V,
|
|
144
|
-
closeSend: Q,
|
|
145
|
-
submitSend: re,
|
|
146
|
-
paymentOpen: !!W,
|
|
147
|
-
paymentValues: K,
|
|
148
|
-
paymentErrors: J,
|
|
149
|
-
paymentInProgress: j.isPending || M.isPending,
|
|
150
|
-
setPaymentValues: q,
|
|
151
|
-
closePayment: $,
|
|
152
|
-
submitPayment: ie
|
|
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: []
|
|
153
31
|
};
|
|
154
32
|
}
|
|
155
|
-
function
|
|
156
|
-
return e === "
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
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
|
+
};
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
function D({ receivable: e, history: t, mails: n, pdfUrl: r, messages: i }) {
|
|
139
|
+
if (!e) return;
|
|
140
|
+
let a = e.type === "invoice" ? e.amount_due : void 0, o = e.type === "quote" ? e.expiry_date : e.due_date;
|
|
141
|
+
return {
|
|
142
|
+
id: e.id,
|
|
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
|
|
252
|
+
});
|
|
253
|
+
return i && (r.lineItems = i, r.lineItemsSummary = s(i)), r;
|
|
254
|
+
}
|
|
255
|
+
function j(e) {
|
|
256
|
+
return Object.keys(e).length > 0;
|
|
257
|
+
}
|
|
258
|
+
function M({ values: e, billingAddressId: t, unitNamesById: n }) {
|
|
259
|
+
let a = e.lineItems.filter((e) => !r(e)).map((t) => i({
|
|
260
|
+
lineItem: t,
|
|
261
|
+
currency: e.currency,
|
|
262
|
+
taxRate: e.taxRate,
|
|
263
|
+
unitNamesById: n
|
|
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"
|
|
187
276
|
} : {
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
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"
|
|
192
282
|
};
|
|
193
283
|
}
|
|
284
|
+
function N(e, t) {
|
|
285
|
+
let r = e.type === "quote" ? "quote" : "invoice", i = e.type === "invoice" ? e.payment_terms?.id ?? "" : "", a = e.line_items.map((n) => o({
|
|
286
|
+
lineItem: n,
|
|
287
|
+
currency: e.currency,
|
|
288
|
+
units: t
|
|
289
|
+
}));
|
|
290
|
+
return {
|
|
291
|
+
...m(),
|
|
292
|
+
type: r,
|
|
293
|
+
customerId: e.counterpart_id,
|
|
294
|
+
currency: e.currency,
|
|
295
|
+
issueDate: I(e.issue_date),
|
|
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)
|
|
303
|
+
};
|
|
304
|
+
}
|
|
305
|
+
function P({ values: e, billingAddressId: t, lineItemChanges: n }) {
|
|
306
|
+
let r = {
|
|
307
|
+
counterpart_billing_address_id: t,
|
|
308
|
+
counterpart_id: e.customerId,
|
|
309
|
+
currency: e.currency,
|
|
310
|
+
issue_date: e.issueDate || void 0,
|
|
311
|
+
memo: e.openingNote,
|
|
312
|
+
footer: e.closingNote
|
|
313
|
+
};
|
|
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
|
+
}
|
|
328
|
+
function F({ values: e, originalLineItems: t, originalCurrency: n, unitNamesById: i, units: s }) {
|
|
329
|
+
let l = (e, t, n) => a({
|
|
330
|
+
lineItem: e,
|
|
331
|
+
currency: t,
|
|
332
|
+
taxRate: n,
|
|
333
|
+
unitNamesById: i
|
|
334
|
+
}), u = c(t), d = new Map(t.map((e) => [e.id, JSON.stringify(l(o({
|
|
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 } : {}
|
|
351
|
+
};
|
|
352
|
+
}
|
|
353
|
+
function I(e) {
|
|
354
|
+
return e?.slice(0, 10) ?? "";
|
|
355
|
+
}
|
|
356
|
+
function L(e) {
|
|
357
|
+
return (e ?? []).map((e) => ({
|
|
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);
|
|
371
|
+
}
|
|
372
|
+
function V(e, t, n) {
|
|
373
|
+
let r = {};
|
|
374
|
+
if (e.mode === "partial") {
|
|
375
|
+
let i = x(e.amountPaid, n);
|
|
376
|
+
(!i || i <= 0) && (r.amountPaid = t.paymentAmountInvalid);
|
|
377
|
+
}
|
|
378
|
+
return r;
|
|
379
|
+
}
|
|
380
|
+
function H(e) {
|
|
381
|
+
return Object.keys(e).length > 0;
|
|
382
|
+
}
|
|
383
|
+
function U(e, t) {
|
|
384
|
+
return {
|
|
385
|
+
...f,
|
|
386
|
+
to: e?.counterpart_contact?.email ?? "",
|
|
387
|
+
subject: e?.document_id ? `${t.sendSubjectDefault} ${e.document_id}` : t.sendSubjectDefault,
|
|
388
|
+
body: t.sendBodyDefault
|
|
389
|
+
};
|
|
390
|
+
}
|
|
391
|
+
function W() {
|
|
392
|
+
return {
|
|
393
|
+
...p,
|
|
394
|
+
paidAt: (/* @__PURE__ */ new Date()).toISOString().slice(0, 10)
|
|
395
|
+
};
|
|
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
|
+
}
|
|
194
416
|
//#endregion
|
|
195
|
-
export { y as
|
|
417
|
+
export { p as EMPTY_RECEIVABLE_PAYMENT_VALUES, f as EMPTY_RECEIVABLE_SEND_VALUES, T as buildReceivableActions, D as buildReceivableDetailsView, E as buildReceivableRows, _ as coerceEnabledTabs, m as createEmptyReceivableFormValues, n as createLineItem, W as defaultPaymentValues, U as defaultSendValues, y as formatDate, b as formatMoney, x as fromMajorUnits, S as getDocumentTitle, C as getDocumentTypeLabel, L as getPaymentTermOptions, w as getStatusTone, H as hasPaymentErrors, j as hasReceivableFormErrors, z as hasSendErrors, M as receivableFormValuesToCreatePayload, F as receivableFormValuesToLineItemChanges, P as receivableFormValuesToUpdatePayload, N as receivableToFormValues, v as resolveInitialTab, B as splitEmailList, G as statusFilterOptions, g as tabForType, h as typeForTab, V as validatePaymentValues, A as validateReceivableForm, R as validateSendValues };
|