@tesouro/embedded-components-react 0.5.251 → 0.5.254
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 +95 -79
- package/dist/lib/ReceivablesWidget.d.ts +25 -9
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index24.js +4 -1
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index27.js +214 -209
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index35.js +162 -145
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/ui/dist/index14.js +2 -2
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/ui/dist/index15.js +2 -2
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/ui/dist/index31.js +1 -1
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/ui/dist/index33.js +2 -2
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/ui/dist/index34.js +3 -3
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/ui/dist/index37.js +2 -2
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/ui/dist/index48.js +1 -1
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/ui/dist/index49.js +1 -1
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/ui/dist/index5.js +2 -2
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bills-list/feature/dist/index17.js +32 -23
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bills-list/ui/dist/index18.js +2 -2
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bills-list/ui/dist/index2.js +1 -1
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bills-list/ui/dist/index20.js +5 -5
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bills-list/ui/dist/index3.js +1 -1
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/lib/BillPayWidgetNative/BillPayWidgetNative.js +48 -48
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/lib/BillPayWidgetNative/BillsTab.js +32 -24
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/lib/BillPayWidgetNative/labels.js +2 -2
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/pay-bill/ui/dist/index5.js +1 -1
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/pay-bill/ui/dist/index6.js +1 -1
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index.js +19 -21
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index10.js +38 -51
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index12.js +12 -2
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index13.js +11 -39
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index14.js +18 -2
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index15.js +2 -14
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index16.js +9 -16
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index17.js +78 -2
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index19.js +2 -78
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index20.js +29 -0
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index21.js +4 -2
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index22.js +26 -25
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index23.js +2 -4
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index24.js +5 -28
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index25.js +34 -2
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index26.js +2 -7
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index6.js +16 -11
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index7.js +54 -2
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index8.js +1 -0
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index9.js +2 -16
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index.js +2 -2
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index10.js +16 -17
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/ReceivablesWidget.js +15 -11
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/details.js +89 -88
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/helpers.js +55 -74
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/labels.js +8 -1
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/paymentRecord.js +71 -0
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/useReceivableActions.js +123 -164
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/useReceivableDetails.js +40 -37
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/useReceivablePaymentRecord.js +91 -0
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/useReceivablesTable.js +83 -78
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/useReceivablesWidget.js +7 -3
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/mocks/receivables.js +2 -1
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index13.js +15 -8
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index39.js +206 -89
- package/dist/libs/tesouro-embedded-components-react/shared/data-access/dist/index.js +2 -2
- package/dist/libs/tesouro-embedded-components-react/shared/data-access/dist/lib/rest/sdk.gen.js +38 -38
- 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 +8 -7
- package/package.json +1 -1
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index18.js +0 -11
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index27.js +0 -34
- package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index28.js +0 -2
|
@@ -5,249 +5,208 @@
|
|
|
5
5
|
import { toast as e } from "../../../../../../../packages/shared-ui-shadcn/dist/index.js";
|
|
6
6
|
import { extractApiErrorMessage as t } from "../../../../../shared/util/dist/lib/apiErrors.js";
|
|
7
7
|
import "../../../../../shared/ui/dist/index.js";
|
|
8
|
-
import {
|
|
9
|
-
import { getIssueReminderBlocker as
|
|
10
|
-
import { useSendReceivableEmailMutation as
|
|
11
|
-
import { useAcceptReceivableMutation as
|
|
12
|
-
import { useMarkReceivablePaidMutation as
|
|
13
|
-
import { useCancelRecurrenceMutation as
|
|
8
|
+
import { defaultSendValues as n, formatMoney as r, hasSendErrors as i, isReceivableReadyToIssue as a, splitEmailList as o, validateSendValues as s } from "./helpers.js";
|
|
9
|
+
import { getIssueReminderBlocker as c, hasSelectedReminder as ee } from "./reminders.js";
|
|
10
|
+
import { useSendReceivableEmailMutation as l } from "../../../../data-access/dist/index7.js";
|
|
11
|
+
import { useAcceptReceivableMutation as u, useCancelReceivableMutation as d, useCloneReceivableMutation as f, useDeclineReceivableMutation as te, useDeleteReceivableMutation as ne, useIssueReceivableMutation as p } from "../../../../data-access/dist/index8.js";
|
|
12
|
+
import { useMarkReceivablePaidMutation as re, useMarkReceivableUncollectibleMutation as ie } from "../../../../data-access/dist/index10.js";
|
|
13
|
+
import { useCancelRecurrenceMutation as ae, usePauseRecurrenceMutation as m, useResumeRecurrenceMutation as oe } from "../../../../data-access/dist/index12.js";
|
|
14
14
|
import "../../../../data-access/dist/index.js";
|
|
15
|
-
import { useReceivableIssuePreflight as
|
|
16
|
-
import {
|
|
15
|
+
import { useReceivableIssuePreflight as h } from "./useReceivableIssuePreflight.js";
|
|
16
|
+
import { useReceivablePaymentRecord as g } from "./useReceivablePaymentRecord.js";
|
|
17
|
+
import { useCallback as _, useState as v } from "react";
|
|
17
18
|
//#region ../../libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/useReceivableActions.js
|
|
18
|
-
function
|
|
19
|
-
let
|
|
20
|
-
counterpartId:
|
|
21
|
-
billingAddressId:
|
|
22
|
-
billingCountry:
|
|
23
|
-
}),
|
|
19
|
+
function y({ selectedReceivable: r, selectedRecurrence: y, messages: b, onCreated: x, onDeleted: S, onCompleteBeforeIssue: C }) {
|
|
20
|
+
let w = p(), T = d(), E = f(), D = u(), O = te(), k = ne(), A = l(), j = re(), M = ie(), N = m(), P = oe(), F = ae(), [I, L] = v(), [le, R] = v(), [z, B] = v(""), [V, H] = v(), [U, W] = v(() => n(void 0, b)), [ue, G] = v({}), K = g({ messages: b }), q = K.open, J = N.mutate, Y = P.mutate, X = I?.issueCheck, Z = h({
|
|
21
|
+
counterpartId: X?.counterpartId,
|
|
22
|
+
billingAddressId: X?.billingAddressId,
|
|
23
|
+
billingCountry: X?.billingCountry
|
|
24
|
+
}), Q = !!X && Z.isLoading, de = _((i, o, s) => {
|
|
24
25
|
let c = "documentLabel" in o ? o.documentLabel : o.title, l = {
|
|
25
26
|
id: o.id,
|
|
26
27
|
type: o.type,
|
|
27
28
|
title: c,
|
|
28
|
-
action:
|
|
29
|
-
}, u = s === void 0 ?
|
|
30
|
-
if (
|
|
31
|
-
|
|
29
|
+
action: i
|
|
30
|
+
}, u = s === void 0 ? r : s ?? void 0;
|
|
31
|
+
if (i === "send") {
|
|
32
|
+
H(l), W(n(u, b)), G({});
|
|
32
33
|
return;
|
|
33
34
|
}
|
|
34
35
|
let d = u?.type === "invoice" ? u.recurrence_id ?? void 0 : void 0;
|
|
35
|
-
if (
|
|
36
|
+
if (i === "pauseRecurrence" || i === "resumeRecurrence") {
|
|
36
37
|
if (!d) return;
|
|
37
|
-
let n =
|
|
38
|
-
(n ? J :
|
|
38
|
+
let n = i === "pauseRecurrence";
|
|
39
|
+
(n ? J : Y)({
|
|
39
40
|
path: { recurrence_id: d },
|
|
40
41
|
receivableId: o.id
|
|
41
42
|
}, {
|
|
42
|
-
onSuccess: () => e.success(n ?
|
|
43
|
-
onError: (n) => e.error(t(n) ??
|
|
43
|
+
onSuccess: () => e.success(n ? b.recurrencePaused : b.recurrenceResumed),
|
|
44
|
+
onError: (n) => e.error(t(n) ?? b.genericError)
|
|
44
45
|
});
|
|
45
46
|
return;
|
|
46
47
|
}
|
|
47
|
-
if (
|
|
48
|
+
if (i === "cancelRecurrence") {
|
|
48
49
|
if (!d || u?.type !== "invoice") return;
|
|
49
|
-
|
|
50
|
+
R(void 0), L({
|
|
50
51
|
...l,
|
|
51
52
|
recurrenceId: d,
|
|
52
|
-
description:
|
|
53
|
+
description: se(u, y, b)
|
|
53
54
|
});
|
|
54
55
|
return;
|
|
55
56
|
}
|
|
56
|
-
if (
|
|
57
|
-
|
|
58
|
-
...l,
|
|
59
|
-
currency: u?.currency
|
|
60
|
-
}), K(n()), q({});
|
|
57
|
+
if (i === "recordPayment") {
|
|
58
|
+
u?.type === "invoice" && q(u);
|
|
61
59
|
return;
|
|
62
60
|
}
|
|
63
|
-
let f =
|
|
64
|
-
if (f &&
|
|
65
|
-
|
|
61
|
+
let f = i === "issue" && u?.type === "invoice" ? u : void 0;
|
|
62
|
+
if (f && C && !a(f, b)) {
|
|
63
|
+
C(f);
|
|
66
64
|
return;
|
|
67
65
|
}
|
|
68
|
-
|
|
66
|
+
R(void 0), B(""), L({
|
|
69
67
|
...l,
|
|
70
68
|
issueCheck: f ? {
|
|
71
69
|
counterpartId: f.counterpart_id,
|
|
72
70
|
billingAddressId: f.counterpart_billing_address?.id ?? void 0,
|
|
73
71
|
billingCountry: f.counterpart_billing_address?.country,
|
|
74
|
-
hasReminder:
|
|
72
|
+
hasReminder: ee(f)
|
|
75
73
|
} : void 0
|
|
76
74
|
});
|
|
77
75
|
}, [
|
|
78
|
-
|
|
79
|
-
|
|
76
|
+
b,
|
|
77
|
+
C,
|
|
78
|
+
q,
|
|
80
79
|
J,
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
]),
|
|
85
|
-
|
|
86
|
-
}, []),
|
|
87
|
-
|
|
88
|
-
}, []),
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
if (
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
if (Z) return;
|
|
95
|
-
let t = X.isTaxIdMissing ? g.issueTaxIdRequired : N.issueCheck.hasReminder ? d(X.counterpart, g) : void 0;
|
|
80
|
+
Y,
|
|
81
|
+
r,
|
|
82
|
+
y
|
|
83
|
+
]), fe = _(() => {
|
|
84
|
+
L(void 0), R(void 0);
|
|
85
|
+
}, []), $ = _(() => {
|
|
86
|
+
H(void 0), G({});
|
|
87
|
+
}, []), pe = _(async () => {
|
|
88
|
+
if (!I) return;
|
|
89
|
+
let n = { receivable_id: I.id };
|
|
90
|
+
if (I.issueCheck) {
|
|
91
|
+
if (Q) return;
|
|
92
|
+
let t = Z.isTaxIdMissing ? b.issueTaxIdRequired : I.issueCheck.hasReminder ? c(Z.counterpart, b) : void 0;
|
|
96
93
|
if (t) {
|
|
97
|
-
e.error(t),
|
|
94
|
+
e.error(t), L(void 0);
|
|
98
95
|
return;
|
|
99
96
|
}
|
|
100
97
|
}
|
|
101
|
-
if (
|
|
102
|
-
if (!
|
|
98
|
+
if (I.action === "cancelRecurrence") {
|
|
99
|
+
if (!I.recurrenceId) return;
|
|
103
100
|
try {
|
|
104
|
-
await
|
|
105
|
-
path: { recurrence_id:
|
|
106
|
-
receivableId:
|
|
107
|
-
}), e.success(
|
|
101
|
+
await F.mutateAsync({
|
|
102
|
+
path: { recurrence_id: I.recurrenceId },
|
|
103
|
+
receivableId: I.id
|
|
104
|
+
}), e.success(b.recurrenceCanceled), L(void 0);
|
|
108
105
|
} catch (n) {
|
|
109
|
-
e.error(t(n) ??
|
|
106
|
+
e.error(t(n) ?? b.genericError);
|
|
110
107
|
}
|
|
111
108
|
return;
|
|
112
109
|
}
|
|
113
110
|
try {
|
|
114
|
-
if (
|
|
115
|
-
else if (
|
|
116
|
-
else if (
|
|
117
|
-
let e = await
|
|
118
|
-
e?.id &&
|
|
119
|
-
} else
|
|
111
|
+
if (I.action === "issue") await w.mutateAsync({ path: n });
|
|
112
|
+
else if (I.action === "cancel") await T.mutateAsync({ path: n });
|
|
113
|
+
else if (I.action === "clone") {
|
|
114
|
+
let e = await E.mutateAsync({ path: n });
|
|
115
|
+
e?.id && x?.(e.id, e.type);
|
|
116
|
+
} else I.action === "accept" ? await D.mutateAsync({ path: n }) : I.action === "decline" ? await O.mutateAsync({ path: n }) : I.action === "delete" ? (await k.mutateAsync({ path: n }), S?.(I.id)) : I.action === "markPaid" ? await j.mutateAsync({
|
|
120
117
|
path: n,
|
|
121
118
|
body: { paid_at: (/* @__PURE__ */ new Date()).toISOString() }
|
|
122
|
-
}) :
|
|
119
|
+
}) : I.action === "markUncollectible" && await M.mutateAsync({
|
|
123
120
|
path: n,
|
|
124
|
-
body: { comment:
|
|
121
|
+
body: { comment: z.trim() || void 0 }
|
|
125
122
|
});
|
|
126
|
-
|
|
123
|
+
L(void 0), R(void 0);
|
|
127
124
|
} catch (e) {
|
|
128
|
-
|
|
125
|
+
R(t(e) ?? b.genericError);
|
|
129
126
|
}
|
|
130
127
|
}, [
|
|
131
|
-
|
|
128
|
+
D,
|
|
129
|
+
z,
|
|
132
130
|
I,
|
|
133
|
-
N,
|
|
134
|
-
x,
|
|
135
|
-
M,
|
|
136
|
-
S,
|
|
137
|
-
w,
|
|
138
131
|
T,
|
|
139
|
-
|
|
132
|
+
F,
|
|
133
|
+
E,
|
|
134
|
+
O,
|
|
135
|
+
k,
|
|
136
|
+
Q,
|
|
137
|
+
w,
|
|
138
|
+
j,
|
|
140
139
|
b,
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
if (
|
|
150
|
-
|
|
151
|
-
if (s(e)) {
|
|
152
|
-
H(e);
|
|
140
|
+
x,
|
|
141
|
+
S,
|
|
142
|
+
Z.counterpart,
|
|
143
|
+
Z.isTaxIdMissing,
|
|
144
|
+
M
|
|
145
|
+
]), me = _(async () => {
|
|
146
|
+
if (!V) return;
|
|
147
|
+
let e = s(U, b);
|
|
148
|
+
if (i(e)) {
|
|
149
|
+
G(e);
|
|
153
150
|
return;
|
|
154
151
|
}
|
|
155
152
|
try {
|
|
156
|
-
await
|
|
157
|
-
path: { receivable_id:
|
|
153
|
+
await A.mutateAsync({
|
|
154
|
+
path: { receivable_id: V.id },
|
|
158
155
|
body: {
|
|
159
|
-
body_text:
|
|
160
|
-
subject_text:
|
|
156
|
+
body_text: U.body,
|
|
157
|
+
subject_text: U.subject,
|
|
161
158
|
recipients: {
|
|
162
|
-
to:
|
|
163
|
-
cc:
|
|
164
|
-
bcc:
|
|
159
|
+
to: o(U.to),
|
|
160
|
+
cc: o(U.cc),
|
|
161
|
+
bcc: o(U.bcc)
|
|
165
162
|
}
|
|
166
163
|
}
|
|
167
|
-
}), Q();
|
|
168
|
-
} catch (e) {
|
|
169
|
-
H({ form: t(e) ?? g.genericError });
|
|
170
|
-
}
|
|
171
|
-
}, [
|
|
172
|
-
Q,
|
|
173
|
-
g,
|
|
174
|
-
E,
|
|
175
|
-
R,
|
|
176
|
-
B
|
|
177
|
-
]), Te = p(async () => {
|
|
178
|
-
if (!U) return;
|
|
179
|
-
let e = l(G, g, U.currency);
|
|
180
|
-
if (o(e)) {
|
|
181
|
-
q(e);
|
|
182
|
-
return;
|
|
183
|
-
}
|
|
184
|
-
try {
|
|
185
|
-
let e = { receivable_id: U.id }, t = G.paidAt ? new Date(G.paidAt).toISOString() : void 0;
|
|
186
|
-
G.mode === "full" ? await D.mutateAsync({
|
|
187
|
-
path: e,
|
|
188
|
-
body: {
|
|
189
|
-
comment: G.comment || void 0,
|
|
190
|
-
paid_at: t
|
|
191
|
-
}
|
|
192
|
-
}) : await O.mutateAsync({
|
|
193
|
-
path: e,
|
|
194
|
-
body: {
|
|
195
|
-
amount_paid: a(G.amountPaid, U.currency) ?? 0,
|
|
196
|
-
comment: G.comment || void 0
|
|
197
|
-
}
|
|
198
164
|
}), $();
|
|
199
165
|
} catch (e) {
|
|
200
|
-
|
|
166
|
+
G({ form: t(e) ?? b.genericError });
|
|
201
167
|
}
|
|
202
168
|
}, [
|
|
203
169
|
$,
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
U
|
|
208
|
-
G
|
|
170
|
+
b,
|
|
171
|
+
A,
|
|
172
|
+
V,
|
|
173
|
+
U
|
|
209
174
|
]);
|
|
210
175
|
return {
|
|
211
|
-
actionTarget:
|
|
212
|
-
actionDialog:
|
|
213
|
-
actionError:
|
|
214
|
-
actionComment:
|
|
215
|
-
setActionComment:
|
|
216
|
-
actionInProgress:
|
|
217
|
-
pendingActions: [...
|
|
218
|
-
openAction:
|
|
219
|
-
closeAction:
|
|
220
|
-
confirmAction:
|
|
221
|
-
sendOpen: !!
|
|
222
|
-
sendValues:
|
|
223
|
-
sendErrors:
|
|
224
|
-
sendInProgress:
|
|
225
|
-
setSendValues:
|
|
226
|
-
closeSend:
|
|
227
|
-
submitSend:
|
|
228
|
-
|
|
229
|
-
paymentValues: G,
|
|
230
|
-
paymentErrors: ye,
|
|
231
|
-
paymentInProgress: D.isPending || O.isPending,
|
|
232
|
-
setPaymentValues: K,
|
|
233
|
-
closePayment: $,
|
|
234
|
-
submitPayment: Te
|
|
176
|
+
actionTarget: I,
|
|
177
|
+
actionDialog: I ? ce(I, b) : void 0,
|
|
178
|
+
actionError: le,
|
|
179
|
+
actionComment: I?.action === "markUncollectible" ? z : void 0,
|
|
180
|
+
setActionComment: B,
|
|
181
|
+
actionInProgress: Q || w.isPending || T.isPending || E.isPending || D.isPending || O.isPending || k.isPending || j.isPending || M.isPending || F.isPending,
|
|
182
|
+
pendingActions: [...N.isPending ? ["pauseRecurrence"] : [], ...P.isPending ? ["resumeRecurrence"] : []],
|
|
183
|
+
openAction: de,
|
|
184
|
+
closeAction: fe,
|
|
185
|
+
confirmAction: pe,
|
|
186
|
+
sendOpen: !!V,
|
|
187
|
+
sendValues: U,
|
|
188
|
+
sendErrors: ue,
|
|
189
|
+
sendInProgress: A.isPending,
|
|
190
|
+
setSendValues: W,
|
|
191
|
+
closeSend: $,
|
|
192
|
+
submitSend: me,
|
|
193
|
+
payment: K
|
|
235
194
|
};
|
|
236
195
|
}
|
|
237
|
-
function
|
|
238
|
-
let
|
|
239
|
-
amount: e.total_amount_with_credit_notes *
|
|
196
|
+
function se(e, t, n) {
|
|
197
|
+
let i = (t?.iterations ?? []).filter((e) => e.status === "pending").length, a = r({
|
|
198
|
+
amount: e.total_amount_with_credit_notes * i,
|
|
240
199
|
currency: e.currency,
|
|
241
200
|
fallback: ""
|
|
242
201
|
});
|
|
243
202
|
return [
|
|
244
203
|
n.cancelRecurrenceQuestion,
|
|
245
204
|
n.cancelRecurrenceFutureIterations,
|
|
246
|
-
n.cancelRecurrenceTotal.replace("{count}", String(
|
|
205
|
+
n.cancelRecurrenceTotal.replace("{count}", String(i)).replace("{invoices}", i === 1 ? n.cancelRecurrenceInvoice : n.cancelRecurrenceInvoices).replace("{amount}", a),
|
|
247
206
|
n.cancelRecurrenceIrreversible
|
|
248
207
|
].join("\n");
|
|
249
208
|
}
|
|
250
|
-
function
|
|
209
|
+
function ce({ action: e, description: t }, n) {
|
|
251
210
|
return e === "cancelRecurrence" ? {
|
|
252
211
|
title: n.cancelRecurrenceTitle,
|
|
253
212
|
description: t ?? "",
|
|
@@ -293,4 +252,4 @@ function ge({ action: e, description: t }, n) {
|
|
|
293
252
|
};
|
|
294
253
|
}
|
|
295
254
|
//#endregion
|
|
296
|
-
export {
|
|
255
|
+
export { y as useReceivableActions };
|
|
@@ -4,40 +4,41 @@
|
|
|
4
4
|
"use client";
|
|
5
5
|
import { buildReceivableAuditHistory as e } from "../../../../../shared/util/dist/lib/auditHistory/buildReceivableAuditHistory.js";
|
|
6
6
|
import { hasAnyScope as t } from "../../../../../shared/data-access/dist/lib/hasAnyScope.js";
|
|
7
|
-
import { Scope as
|
|
7
|
+
import { Scope as n } from "../../../../../shared/data-access/dist/lib/scopes.js";
|
|
8
8
|
import "../../../../../shared/data-access/dist/index.js";
|
|
9
|
-
import { useWidgetConfig as
|
|
10
|
-
import { useOrganizationUserNames as
|
|
9
|
+
import { useWidgetConfig as ee } from "../../../../../shared/feature/dist/lib/WidgetProvider/hooks.js";
|
|
10
|
+
import { useOrganizationUserNames as r } from "../../../../../shared/feature/dist/lib/user/useOrganizationUserNames.js";
|
|
11
11
|
import "../../../../../shared/feature/dist/index.js";
|
|
12
|
-
import { RECEIVABLE_DETAILS_SECTION as
|
|
12
|
+
import { RECEIVABLE_DETAILS_SECTION as i } from "../../../../ui/dist/index25.js";
|
|
13
13
|
import "../../../../ui/dist/index.js";
|
|
14
|
-
import { useAllReceivableHistoryQuery as
|
|
15
|
-
import { usePaymentAccountsQuery as
|
|
16
|
-
import { useReceivablePaymentRecordsQuery as
|
|
17
|
-
import { useReceivablePdfLinkQuery as
|
|
18
|
-
import { useOverdueRemindersQuery as
|
|
14
|
+
import { useAllReceivableHistoryQuery as a } from "../../../../data-access/dist/index3.js";
|
|
15
|
+
import { usePaymentAccountsQuery as te } from "../../../../data-access/dist/index4.js";
|
|
16
|
+
import { useReceivablePaymentRecordsQuery as o } from "../../../../data-access/dist/index9.js";
|
|
17
|
+
import { useReceivablePdfLinkQuery as s, useReceivableQuery as ne, useReceivablesByIdQueries as re } from "../../../../data-access/dist/index11.js";
|
|
18
|
+
import { useOverdueRemindersQuery as c, usePaymentRemindersQuery as ie, useRecurrenceQuery as l } from "../../../../data-access/dist/index12.js";
|
|
19
19
|
import "../../../../data-access/dist/index.js";
|
|
20
|
-
import {
|
|
21
|
-
import {
|
|
22
|
-
import {
|
|
23
|
-
import {
|
|
20
|
+
import { canRecordPayments as u } from "./paymentRecord.js";
|
|
21
|
+
import { buildReceivableAuditHistoryLabels as d } from "./auditHistory/labels.js";
|
|
22
|
+
import { getBankAccountPermissions as f } from "./bankAccounts.js";
|
|
23
|
+
import { buildReceivableDetailsView as ae, buildUnsupportedDetailsView as oe } from "./details.js";
|
|
24
|
+
import { useMemo as p, useState as m } from "react";
|
|
24
25
|
//#region ../../libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/useReceivableDetails.js
|
|
25
|
-
var
|
|
26
|
-
function
|
|
27
|
-
let { initResponse:
|
|
28
|
-
enabled:
|
|
29
|
-
canReadEmbedded:
|
|
30
|
-
canReadExternal:
|
|
31
|
-
}), j = l(
|
|
32
|
-
B !==
|
|
33
|
-
let H = R.includes(
|
|
34
|
-
...
|
|
35
|
-
...
|
|
26
|
+
var h = [i.attachments];
|
|
27
|
+
function g({ selectedReceivableId: g, enabled: _ = !0, canWrite: v = !0, messages: y, statusLabels: b, auditHistoryLabels: x, onOpenReceivable: S }) {
|
|
28
|
+
let { initResponse: C } = ee(), w = p(() => f(C?.scopes), [C?.scopes]), T = u(C?.scopes), E = ne(g, { enabled: _ }), D = E.data, O = D?.type === "invoice" ? D : void 0, k = s(g, { enabled: _ && !!O }), se = ie({ enabled: _ && !!O?.payment_reminder_id }), ce = c({ enabled: _ && !!O?.overdue_reminder_id }), A = te({
|
|
29
|
+
enabled: _ && !!O,
|
|
30
|
+
canReadEmbedded: w.canReadEmbedded,
|
|
31
|
+
canReadExternal: w.canReadExternal
|
|
32
|
+
}), j = l(_ ? O?.recurrence_id : void 0), M = j.data, N = o(O?.id, { enabled: _ }), P = a(O?.id, { enabled: _ && !!O }), F = p(() => O?.status === "recurring" ? (M?.iterations ?? []).flatMap((e) => e.issued_invoice_id ? [e.issued_invoice_id] : []) : [], [O?.status, M?.iterations]), I = re(F, { enabled: _ }), L = p(() => new Map(I.filter((e) => !!e).map((e) => [e.id, e])), [I]), [R, z] = m(h), [B, V] = m(g);
|
|
33
|
+
B !== g && (V(g), z(h));
|
|
34
|
+
let H = R.includes(i.auditHistory), U = p(() => P.data?.data ?? [], [P.data]), W = U.some((e) => e.recorded_by === "user" && !!e.entity_user_id), G = t(C?.scopes, [n.UserReadOrg]), { userNames: K, isError: q } = r({ enabled: _ && H && G && W }), J = p(() => ({
|
|
35
|
+
...d(y, b),
|
|
36
|
+
...x
|
|
36
37
|
}), [
|
|
38
|
+
y,
|
|
37
39
|
b,
|
|
38
|
-
x
|
|
39
|
-
|
|
40
|
-
]), Y = m(() => {
|
|
40
|
+
x
|
|
41
|
+
]), Y = p(() => {
|
|
41
42
|
let t = O ? e(U, K, J, {
|
|
42
43
|
documentType: "invoice",
|
|
43
44
|
currency: O.currency,
|
|
@@ -62,11 +63,11 @@ function _({ selectedReceivableId: _, enabled: v = !0, canWrite: y = !0, message
|
|
|
62
63
|
G,
|
|
63
64
|
q,
|
|
64
65
|
W
|
|
65
|
-
]), X =
|
|
66
|
+
]), X = se.data?.data.find((e) => e.id === O?.payment_reminder_id), Z = ce.data?.data.find((e) => e.id === O?.overdue_reminder_id), Q = A.paymentAccounts.find((e) => e.id === O?.bank_account_id), $ = k.data?.file_url || void 0;
|
|
66
67
|
return {
|
|
67
68
|
receivable: D,
|
|
68
69
|
recurrence: M,
|
|
69
|
-
detailsView:
|
|
70
|
+
detailsView: p(() => ae({
|
|
70
71
|
receivable: D,
|
|
71
72
|
pdfUrl: $,
|
|
72
73
|
paymentReminder: X,
|
|
@@ -78,10 +79,11 @@ function _({ selectedReceivableId: _, enabled: v = !0, canWrite: y = !0, message
|
|
|
78
79
|
isLoadingPaymentRecords: N.isLoading,
|
|
79
80
|
iterationInvoices: L,
|
|
80
81
|
auditHistory: Y,
|
|
81
|
-
statusLabels:
|
|
82
|
-
messages:
|
|
83
|
-
|
|
84
|
-
|
|
82
|
+
statusLabels: b,
|
|
83
|
+
messages: y,
|
|
84
|
+
canRecordPayment: T,
|
|
85
|
+
canWrite: v,
|
|
86
|
+
onOpenReceivable: S
|
|
85
87
|
}), [
|
|
86
88
|
D,
|
|
87
89
|
$,
|
|
@@ -94,12 +96,13 @@ function _({ selectedReceivableId: _, enabled: v = !0, canWrite: y = !0, message
|
|
|
94
96
|
N.isLoading,
|
|
95
97
|
L,
|
|
96
98
|
Y,
|
|
97
|
-
x,
|
|
98
99
|
b,
|
|
99
100
|
y,
|
|
100
|
-
|
|
101
|
+
T,
|
|
102
|
+
v,
|
|
103
|
+
S
|
|
101
104
|
]),
|
|
102
|
-
unsupportedView:
|
|
105
|
+
unsupportedView: p(() => oe(D, y), [D, y]),
|
|
103
106
|
openSections: R,
|
|
104
107
|
setOpenSections: z,
|
|
105
108
|
isLoading: E.isLoading || k.isLoading || j.isLoading,
|
|
@@ -107,4 +110,4 @@ function _({ selectedReceivableId: _, enabled: v = !0, canWrite: y = !0, message
|
|
|
107
110
|
};
|
|
108
111
|
}
|
|
109
112
|
//#endregion
|
|
110
|
-
export {
|
|
113
|
+
export { g as useReceivableDetails };
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
"use client";
|
|
3
|
+
"use client";
|
|
4
|
+
"use client";
|
|
5
|
+
import { toast as e } from "../../../../../../../packages/shared-ui-shadcn/dist/index.js";
|
|
6
|
+
import { extractApiErrorMessage as t } from "../../../../../shared/util/dist/lib/apiErrors.js";
|
|
7
|
+
import { useCurrentUserQuery as n } from "../../../../../shared/data-access/dist/lib/useCurrentUserQuery.js";
|
|
8
|
+
import "../../../../../shared/data-access/dist/index.js";
|
|
9
|
+
import "../../../../../shared/ui/dist/index.js";
|
|
10
|
+
import { useWidgetConfig as r } from "../../../../../shared/feature/dist/lib/WidgetProvider/hooks.js";
|
|
11
|
+
import "../../../../../shared/feature/dist/index.js";
|
|
12
|
+
import { getCurrencySymbol as i } from "./lineItems.js";
|
|
13
|
+
import { formatMoney as a } from "./helpers.js";
|
|
14
|
+
import { useCreateReceivablePaymentRecordMutation as o } from "../../../../data-access/dist/index10.js";
|
|
15
|
+
import "../../../../data-access/dist/index.js";
|
|
16
|
+
import { amountDueInputValue as s, buildPaymentRecordPayload as c, buildPaymentReviewView as l, defaultPaymentRecordValues as u, hasPaymentRecordErrors as d, validatePaymentRecordValues as f } from "./paymentRecord.js";
|
|
17
|
+
import { useCallback as p, useState as m } from "react";
|
|
18
|
+
//#region ../../libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/useReceivablePaymentRecord.js
|
|
19
|
+
function h({ messages: h }) {
|
|
20
|
+
let [g, _] = m(), [v, y] = m("form"), [b, x] = m(() => u()), [S, C] = m({}), [w, T] = m(!1), { initResponse: E } = r(), D = E?.userId ?? void 0, O = o(), k = n({ enabled: !!g }), A = p((e) => {
|
|
21
|
+
_(e), y("form"), x(u()), C({}), T(!1);
|
|
22
|
+
}, []), j = p(() => _(void 0), []), M = p((e) => {
|
|
23
|
+
let t = {
|
|
24
|
+
...b,
|
|
25
|
+
...e
|
|
26
|
+
};
|
|
27
|
+
x(t), w && C(f(t, h, g?.currency));
|
|
28
|
+
}, [
|
|
29
|
+
w,
|
|
30
|
+
g?.currency,
|
|
31
|
+
h,
|
|
32
|
+
b
|
|
33
|
+
]), N = p(() => {
|
|
34
|
+
g && M({ amount: s(g) });
|
|
35
|
+
}, [M, g]), P = p(() => {
|
|
36
|
+
let e = f(b, h, g?.currency);
|
|
37
|
+
C(e), T(!0), d(e) || y("review");
|
|
38
|
+
}, [
|
|
39
|
+
g?.currency,
|
|
40
|
+
h,
|
|
41
|
+
b
|
|
42
|
+
]), F = p(() => y("form"), []), I = p(() => {
|
|
43
|
+
g && O.mutate({ body: c({
|
|
44
|
+
invoice: g,
|
|
45
|
+
values: b,
|
|
46
|
+
entityUserId: D
|
|
47
|
+
}) }, {
|
|
48
|
+
onSuccess: () => {
|
|
49
|
+
e.success(h.paymentRecordCreated), _(void 0);
|
|
50
|
+
},
|
|
51
|
+
onError: (n) => {
|
|
52
|
+
e.error(h.paymentRecordCreateFailed.replace("{errorMessage}", t(n) ?? h.genericError));
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
}, [
|
|
56
|
+
O,
|
|
57
|
+
D,
|
|
58
|
+
g,
|
|
59
|
+
h,
|
|
60
|
+
b
|
|
61
|
+
]);
|
|
62
|
+
return {
|
|
63
|
+
open: A,
|
|
64
|
+
isOpen: !!g,
|
|
65
|
+
step: v,
|
|
66
|
+
values: b,
|
|
67
|
+
errors: S,
|
|
68
|
+
currencySymbol: g ? i(g.currency) : "",
|
|
69
|
+
amountDueLabel: g ? a({
|
|
70
|
+
amount: g.amount_due,
|
|
71
|
+
currency: g.currency,
|
|
72
|
+
fallback: ""
|
|
73
|
+
}) : "",
|
|
74
|
+
review: g ? l({
|
|
75
|
+
invoice: g,
|
|
76
|
+
values: b,
|
|
77
|
+
user: k.data,
|
|
78
|
+
isUserLoading: k.isLoading,
|
|
79
|
+
messages: h
|
|
80
|
+
}) : void 0,
|
|
81
|
+
inProgress: O.isPending || v === "review" && k.isLoading,
|
|
82
|
+
change: M,
|
|
83
|
+
fillAmountDue: N,
|
|
84
|
+
save: P,
|
|
85
|
+
edit: F,
|
|
86
|
+
confirm: I,
|
|
87
|
+
close: j
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
//#endregion
|
|
91
|
+
export { h as useReceivablePaymentRecord };
|