@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,195 +1,64 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
"use client";
|
|
3
|
-
"use client";
|
|
4
|
-
"use client";
|
|
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 "./index5.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";
|
|
12
1
|
//#region ../../libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index7.js
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
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
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
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
|
-
]);
|
|
131
|
-
return {
|
|
132
|
-
actionTarget: P,
|
|
133
|
-
actionDialog: P ? b(P.action, x) : void 0,
|
|
134
|
-
actionError: I,
|
|
135
|
-
actionInProgress: w.isPending || T.isPending || E.isPending || D.isPending || O.isPending || k.isPending || j.isPending || N.isPending,
|
|
136
|
-
openAction: X,
|
|
137
|
-
closeAction: Z,
|
|
138
|
-
confirmAction: ne,
|
|
139
|
-
sendOpen: !!R,
|
|
140
|
-
sendValues: B,
|
|
141
|
-
sendErrors: H,
|
|
142
|
-
sendInProgress: A.isPending,
|
|
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
|
|
153
|
-
};
|
|
154
|
-
}
|
|
155
|
-
function b(e, t) {
|
|
156
|
-
return e === "issue" ? {
|
|
157
|
-
title: t.issueTitle,
|
|
158
|
-
description: t.issueDescription,
|
|
159
|
-
confirmLabel: t.issueConfirm
|
|
160
|
-
} : e === "accept" ? {
|
|
161
|
-
title: t.acceptTitle,
|
|
162
|
-
description: t.acceptDescription,
|
|
163
|
-
confirmLabel: t.acceptConfirm
|
|
164
|
-
} : e === "decline" ? {
|
|
165
|
-
title: t.declineTitle,
|
|
166
|
-
description: t.declineDescription,
|
|
167
|
-
confirmLabel: t.declineConfirm,
|
|
168
|
-
destructive: !0
|
|
169
|
-
} : e === "cancel" ? {
|
|
170
|
-
title: t.cancelTitle,
|
|
171
|
-
description: t.cancelDescription,
|
|
172
|
-
confirmLabel: t.cancelConfirm,
|
|
173
|
-
destructive: !0
|
|
174
|
-
} : e === "clone" ? {
|
|
175
|
-
title: t.cloneTitle,
|
|
176
|
-
description: t.cloneDescription,
|
|
177
|
-
confirmLabel: t.cloneConfirm
|
|
178
|
-
} : e === "delete" ? {
|
|
179
|
-
title: t.deleteTitle,
|
|
180
|
-
description: t.deleteDescription,
|
|
181
|
-
confirmLabel: t.deleteConfirm,
|
|
182
|
-
destructive: !0
|
|
183
|
-
} : e === "markPaid" ? {
|
|
184
|
-
title: t.markPaidTitle,
|
|
185
|
-
description: t.markPaidDescription,
|
|
186
|
-
confirmLabel: t.markPaidConfirm
|
|
187
|
-
} : {
|
|
188
|
-
title: t.markUncollectibleTitle,
|
|
189
|
-
description: t.markUncollectibleDescription,
|
|
190
|
-
confirmLabel: t.markUncollectibleConfirm,
|
|
191
|
-
destructive: !0
|
|
192
|
-
};
|
|
193
|
-
}
|
|
2
|
+
var e = {
|
|
3
|
+
customerRequired: "Customer is required",
|
|
4
|
+
customerAddressRequired: "The selected customer needs a billing address before a receivable can be created.",
|
|
5
|
+
currencyRequired: "Currency is required",
|
|
6
|
+
lineItemNameTooLong: "Product name must be 100 characters or less",
|
|
7
|
+
lineItemPriceTooHigh: "Price must be {maxAmount} or less",
|
|
8
|
+
sendToRequired: "Enter at least one recipient",
|
|
9
|
+
sendSubjectRequired: "Subject is required",
|
|
10
|
+
sendBodyRequired: "Message is required",
|
|
11
|
+
paymentAmountInvalid: "Amount paid must be greater than 0",
|
|
12
|
+
genericError: "Something went wrong. Please try again.",
|
|
13
|
+
lineItemsLoading: "Please wait for invoice details to finish loading.",
|
|
14
|
+
untitledDocument: "Untitled document",
|
|
15
|
+
unknownCustomer: "Unknown customer",
|
|
16
|
+
notAvailable: "Not available",
|
|
17
|
+
invoiceType: "Invoice",
|
|
18
|
+
quoteType: "Quote",
|
|
19
|
+
creditNoteType: "Credit note",
|
|
20
|
+
summaryDocumentType: "Document type",
|
|
21
|
+
summaryDocumentNumber: "Document number",
|
|
22
|
+
summaryCustomer: "Customer",
|
|
23
|
+
summaryIssued: "Issued",
|
|
24
|
+
summaryDue: "Due",
|
|
25
|
+
summaryCreated: "Created",
|
|
26
|
+
summaryUpdated: "Updated",
|
|
27
|
+
summaryTotal: "Total",
|
|
28
|
+
summaryAmountDue: "Amount due",
|
|
29
|
+
activityStatusChanged: "Status changed",
|
|
30
|
+
activityReceivableCreated: "Receivable created",
|
|
31
|
+
activityReceivableUpdated: "Receivable updated",
|
|
32
|
+
activityPaymentReceived: "Payment received",
|
|
33
|
+
activityMailSent: "Email sent",
|
|
34
|
+
activityUnknown: "Activity",
|
|
35
|
+
recipientsNone: "No recipients",
|
|
36
|
+
sendSubjectDefault: "Your receivable document",
|
|
37
|
+
sendBodyDefault: "Please find the receivable document attached.",
|
|
38
|
+
issueTitle: "Issue receivable?",
|
|
39
|
+
issueDescription: "Issuing locks the document and makes it ready to send to the customer.",
|
|
40
|
+
issueConfirm: "Issue",
|
|
41
|
+
acceptTitle: "Accept quote?",
|
|
42
|
+
acceptDescription: "This marks the quote as accepted.",
|
|
43
|
+
acceptConfirm: "Accept",
|
|
44
|
+
declineTitle: "Decline quote?",
|
|
45
|
+
declineDescription: "This marks the quote as declined.",
|
|
46
|
+
declineConfirm: "Decline",
|
|
47
|
+
cancelTitle: "Cancel receivable?",
|
|
48
|
+
cancelDescription: "This cancels the document. You cannot undo this action.",
|
|
49
|
+
cancelConfirm: "Cancel document",
|
|
50
|
+
cloneTitle: "Clone receivable?",
|
|
51
|
+
cloneDescription: "This creates a new draft based on the selected document.",
|
|
52
|
+
cloneConfirm: "Clone",
|
|
53
|
+
deleteTitle: "Delete draft?",
|
|
54
|
+
deleteDescription: "This permanently deletes the draft document. You cannot undo this action.",
|
|
55
|
+
deleteConfirm: "Delete",
|
|
56
|
+
markPaidTitle: "Mark invoice as paid?",
|
|
57
|
+
markPaidDescription: "This records the invoice as fully paid.",
|
|
58
|
+
markPaidConfirm: "Mark paid",
|
|
59
|
+
markUncollectibleTitle: "Mark invoice uncollectible?",
|
|
60
|
+
markUncollectibleDescription: "This records the invoice as uncollectible. You cannot undo this action.",
|
|
61
|
+
markUncollectibleConfirm: "Mark uncollectible"
|
|
62
|
+
};
|
|
194
63
|
//#endregion
|
|
195
|
-
export {
|
|
64
|
+
export { e as RECEIVABLE_MESSAGE_LABELS_EN };
|
|
@@ -2,41 +2,194 @@
|
|
|
2
2
|
"use client";
|
|
3
3
|
"use client";
|
|
4
4
|
"use client";
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
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";
|
|
7
10
|
import "../../data-access/dist/index.js";
|
|
8
|
-
import {
|
|
11
|
+
import { useCallback as _, useState as v } from "react";
|
|
9
12
|
//#region ../../libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index8.js
|
|
10
|
-
function
|
|
11
|
-
let l =
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
13
|
+
function y({ selectedReceivable: y, messages: x, onCreated: S, onDeleted: C }) {
|
|
14
|
+
let w = p(), T = te(), E = u(), D = ee(), O = d(), k = f(), A = l(), j = m(), M = h(), N = g(), [P, F] = v(), [I, L] = v(), [R, z] = v(), [B, V] = v(() => n(void 0, x)), [H, U] = v({}), [W, G] = v(), [K, q] = v(() => t()), [J, Y] = v({}), X = _((e, r, i) => {
|
|
15
|
+
let a = "documentLabel" in r ? r.documentLabel : r.title, o = {
|
|
16
|
+
id: r.id,
|
|
17
|
+
type: r.type,
|
|
18
|
+
title: a,
|
|
19
|
+
action: e
|
|
20
|
+
}, s = i === void 0 ? y : i ?? void 0;
|
|
21
|
+
if (e === "send") {
|
|
22
|
+
z(o), V(n(s, x)), U({});
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
if (e === "recordPayment") {
|
|
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
|
|
33
130
|
]);
|
|
34
131
|
return {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
132
|
+
actionTarget: P,
|
|
133
|
+
actionDialog: P ? b(P.action, x) : void 0,
|
|
134
|
+
actionError: I,
|
|
135
|
+
actionInProgress: w.isPending || T.isPending || E.isPending || D.isPending || O.isPending || k.isPending || j.isPending || N.isPending,
|
|
136
|
+
openAction: X,
|
|
137
|
+
closeAction: Z,
|
|
138
|
+
confirmAction: ne,
|
|
139
|
+
sendOpen: !!R,
|
|
140
|
+
sendValues: B,
|
|
141
|
+
sendErrors: H,
|
|
142
|
+
sendInProgress: A.isPending,
|
|
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
|
|
153
|
+
};
|
|
154
|
+
}
|
|
155
|
+
function b(e, t) {
|
|
156
|
+
return e === "issue" ? {
|
|
157
|
+
title: t.issueTitle,
|
|
158
|
+
description: t.issueDescription,
|
|
159
|
+
confirmLabel: t.issueConfirm
|
|
160
|
+
} : e === "accept" ? {
|
|
161
|
+
title: t.acceptTitle,
|
|
162
|
+
description: t.acceptDescription,
|
|
163
|
+
confirmLabel: t.acceptConfirm
|
|
164
|
+
} : e === "decline" ? {
|
|
165
|
+
title: t.declineTitle,
|
|
166
|
+
description: t.declineDescription,
|
|
167
|
+
confirmLabel: t.declineConfirm,
|
|
168
|
+
destructive: !0
|
|
169
|
+
} : e === "cancel" ? {
|
|
170
|
+
title: t.cancelTitle,
|
|
171
|
+
description: t.cancelDescription,
|
|
172
|
+
confirmLabel: t.cancelConfirm,
|
|
173
|
+
destructive: !0
|
|
174
|
+
} : e === "clone" ? {
|
|
175
|
+
title: t.cloneTitle,
|
|
176
|
+
description: t.cloneDescription,
|
|
177
|
+
confirmLabel: t.cloneConfirm
|
|
178
|
+
} : e === "delete" ? {
|
|
179
|
+
title: t.deleteTitle,
|
|
180
|
+
description: t.deleteDescription,
|
|
181
|
+
confirmLabel: t.deleteConfirm,
|
|
182
|
+
destructive: !0
|
|
183
|
+
} : e === "markPaid" ? {
|
|
184
|
+
title: t.markPaidTitle,
|
|
185
|
+
description: t.markPaidDescription,
|
|
186
|
+
confirmLabel: t.markPaidConfirm
|
|
187
|
+
} : {
|
|
188
|
+
title: t.markUncollectibleTitle,
|
|
189
|
+
description: t.markUncollectibleDescription,
|
|
190
|
+
confirmLabel: t.markUncollectibleConfirm,
|
|
191
|
+
destructive: !0
|
|
39
192
|
};
|
|
40
193
|
}
|
|
41
194
|
//#endregion
|
|
42
|
-
export {
|
|
195
|
+
export { y as useReceivableActions };
|
|
@@ -2,159 +2,41 @@
|
|
|
2
2
|
"use client";
|
|
3
3
|
"use client";
|
|
4
4
|
"use client";
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import { usePaymentTermsQuery as n } from "../../../shared/data-access/dist/lib/reference-data/usePaymentTermsQuery.js";
|
|
8
|
-
import { COUNTERPART_MESSAGE_LABELS_EN as r } from "../../../shared/counterpart-management/feature/dist/lib/labels.js";
|
|
9
|
-
import { useCounterpartAddressesQuery as i } from "../../../shared/counterpart-management/data-access/dist/index7.js";
|
|
10
|
-
import { useCounterpartForm as ee } from "../../../shared/counterpart-management/feature/dist/lib/useCounterpartForm.js";
|
|
11
|
-
import "../../../shared/counterpart-management/feature/dist/index.js";
|
|
12
|
-
import { createEmptyReceivableFormValues as a, createLineItem as o, getPaymentTermOptions as s, hasReceivableFormErrors as c, receivableFormValuesToCreatePayload as l, receivableFormValuesToLineItemChanges as u, receivableFormValuesToUpdatePayload as te, receivableToFormValues as d, validateReceivableForm as f } from "./index5.js";
|
|
13
|
-
import { useCreateReceivableMutation as p, useUpdateReceivableMutation as m } from "../../data-access/dist/index6.js";
|
|
5
|
+
import { buildReceivableDetailsView as e } from "./index6.js";
|
|
6
|
+
import { useReceivableHistoryQuery as t, useReceivableMailsQuery as n, useReceivablePdfLinkQuery as r, useReceivableQuery as i } from "../../data-access/dist/index9.js";
|
|
14
7
|
import "../../data-access/dist/index.js";
|
|
15
|
-
import {
|
|
16
|
-
import { EMPTY_PRODUCT_FORM_VALUES as re, getCurrencyOptions as ie } from "../../../shared/product-catalog/feature/dist/lib/helpers.js";
|
|
17
|
-
import { useMeasureUnits as h } from "../../../shared/product-catalog/feature/dist/lib/useMeasureUnits.js";
|
|
18
|
-
import { useProductForm as g } from "../../../shared/product-catalog/feature/dist/lib/useProductForm.js";
|
|
19
|
-
import "../../../shared/product-catalog/feature/dist/index.js";
|
|
20
|
-
import { useCallback as _, useMemo as v, useRef as y, useState as b } from "react";
|
|
8
|
+
import { useMemo as a } from "react";
|
|
21
9
|
//#region ../../libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index9.js
|
|
22
|
-
function
|
|
23
|
-
let
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
setSelectedId: oe,
|
|
46
|
-
messages: J,
|
|
47
|
-
counterpartType: "customer",
|
|
48
|
-
counterpart: void 0,
|
|
49
|
-
primaryAddress: ae
|
|
50
|
-
}), $ = _(() => {
|
|
51
|
-
D.current = [], M("create"), P(void 0), I(a()), R({});
|
|
52
|
-
}, []), se = _((e = "invoice") => {
|
|
53
|
-
D.current = [], M("create"), P(void 0), I({
|
|
54
|
-
...a(),
|
|
55
|
-
type: e
|
|
56
|
-
}), R({}), A(!0);
|
|
57
|
-
}, []), ce = _((e) => {
|
|
58
|
-
e.type !== "credit_note" && (D.current = e.line_items.filter((e) => !!e.product.id), M("edit"), P(e.id), I(d(e)), R({}), A(!0));
|
|
59
|
-
}, []), le = _(() => {
|
|
60
|
-
A(!1), R({});
|
|
61
|
-
}, []), ue = _((e) => {
|
|
62
|
-
I((t) => ({
|
|
63
|
-
...t,
|
|
64
|
-
...e
|
|
65
|
-
}));
|
|
66
|
-
}, []), de = _((e, t) => {
|
|
67
|
-
I((n) => ({
|
|
68
|
-
...n,
|
|
69
|
-
lineItems: n.lineItems.map((n) => n.id === e ? {
|
|
70
|
-
...n,
|
|
71
|
-
...t
|
|
72
|
-
} : n)
|
|
73
|
-
}));
|
|
74
|
-
}, []), fe = _(() => {
|
|
75
|
-
I((e) => ({
|
|
76
|
-
...e,
|
|
77
|
-
lineItems: [...e.lineItems, o()]
|
|
78
|
-
}));
|
|
79
|
-
}, []), pe = _((e) => {
|
|
80
|
-
I((t) => ({
|
|
81
|
-
...t,
|
|
82
|
-
lineItems: t.lineItems.length <= 1 ? t.lineItems : t.lineItems.filter((t) => t.id !== e)
|
|
83
|
-
}));
|
|
84
|
-
}, []), me = _(async () => {
|
|
85
|
-
let e = f({
|
|
86
|
-
values: F,
|
|
87
|
-
billingAddressId: X,
|
|
88
|
-
messages: x
|
|
89
|
-
});
|
|
90
|
-
if (c(e)) {
|
|
91
|
-
R(e);
|
|
92
|
-
return;
|
|
93
|
-
}
|
|
94
|
-
R({});
|
|
95
|
-
try {
|
|
96
|
-
if (j === "edit" && N) {
|
|
97
|
-
let e = { receivable_id: N };
|
|
98
|
-
await E.mutateAsync({
|
|
99
|
-
path: e,
|
|
100
|
-
body: te({
|
|
101
|
-
values: F,
|
|
102
|
-
billingAddressId: X ?? "",
|
|
103
|
-
lineItemChanges: u({
|
|
104
|
-
values: F,
|
|
105
|
-
originalLineItems: D.current
|
|
106
|
-
})
|
|
107
|
-
})
|
|
108
|
-
}), A(!1), $();
|
|
109
|
-
return;
|
|
110
|
-
}
|
|
111
|
-
let e = await T.mutateAsync({ body: l({
|
|
112
|
-
values: F,
|
|
113
|
-
billingAddressId: X ?? ""
|
|
114
|
-
}) });
|
|
115
|
-
A(!1), $(), e?.id && w?.(e.id, e.type);
|
|
116
|
-
} catch (e) {
|
|
117
|
-
R({ form: t(e) ?? x.genericError });
|
|
118
|
-
}
|
|
119
|
-
}, [
|
|
120
|
-
X,
|
|
121
|
-
T,
|
|
122
|
-
N,
|
|
123
|
-
x,
|
|
124
|
-
j,
|
|
125
|
-
w,
|
|
126
|
-
$,
|
|
127
|
-
E,
|
|
128
|
-
F
|
|
10
|
+
function o({ selectedReceivableId: o, enabled: s = !0, messages: c }) {
|
|
11
|
+
let l = i(o, { enabled: s }), u = t(o, {
|
|
12
|
+
enabled: s,
|
|
13
|
+
limit: 25,
|
|
14
|
+
sort: "timestamp",
|
|
15
|
+
order: "desc"
|
|
16
|
+
}), d = n(o, {
|
|
17
|
+
enabled: s,
|
|
18
|
+
limit: 10,
|
|
19
|
+
sort: "created_at",
|
|
20
|
+
order: "desc"
|
|
21
|
+
}), f = r(o, { enabled: s && !!l.data }), p = a(() => e({
|
|
22
|
+
receivable: l.data,
|
|
23
|
+
history: u.data?.data ?? [],
|
|
24
|
+
mails: d.data?.data ?? [],
|
|
25
|
+
pdfUrl: f.data?.file_url || f.data?.original_file_url || void 0,
|
|
26
|
+
messages: c
|
|
27
|
+
}), [
|
|
28
|
+
l.data,
|
|
29
|
+
u.data?.data,
|
|
30
|
+
d.data?.data,
|
|
31
|
+
c,
|
|
32
|
+
f.data
|
|
129
33
|
]);
|
|
130
34
|
return {
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
errors: L,
|
|
136
|
-
setValues: I,
|
|
137
|
-
updateValues: ue,
|
|
138
|
-
updateLineItem: de,
|
|
139
|
-
addLineItem: fe,
|
|
140
|
-
removeLineItem: pe,
|
|
141
|
-
isSubmitting: T.isPending || E.isPending,
|
|
142
|
-
currencyOptions: ie(F.currency),
|
|
143
|
-
paymentTermsOptions: s(O.data?.data),
|
|
144
|
-
openCreate: se,
|
|
145
|
-
openEdit: ce,
|
|
146
|
-
close: le,
|
|
147
|
-
submit: me,
|
|
148
|
-
productView: z,
|
|
149
|
-
productForm: Z,
|
|
150
|
-
units: G,
|
|
151
|
-
counterpartView: V,
|
|
152
|
-
counterpartForm: Q,
|
|
153
|
-
stateOptions: K,
|
|
154
|
-
openProductCreate: Z.openCreate,
|
|
155
|
-
openCounterpartCreate: Q.openCreate,
|
|
156
|
-
productCreateValues: z === "create" ? Z.values : re
|
|
35
|
+
receivable: l.data,
|
|
36
|
+
detailsView: p,
|
|
37
|
+
isLoading: l.isLoading || u.isLoading || d.isLoading || f.isLoading,
|
|
38
|
+
isError: l.isError
|
|
157
39
|
};
|
|
158
40
|
}
|
|
159
41
|
//#endregion
|
|
160
|
-
export {
|
|
42
|
+
export { o as useReceivableDetails };
|