@tesouro/embedded-components-react 0.5.228 → 0.5.230
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 +22 -21
- package/dist/index.d.ts +34 -1
- package/dist/index.js +1 -1
- package/dist/lib/ReceivablesWidget.d.ts +34 -1
- package/dist/lib/ReceivablesWidget.js +1 -1
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index.js +1 -1
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index11.js +1 -1
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index5.js +32 -33
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index6.js +34 -32
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index7.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 +120 -52
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index11.js +44 -100
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index12.js +93 -337
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index13.js +356 -211
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index14.js +225 -157
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index15.js +152 -21
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index16.js +18 -221
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index17.js +224 -56
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index18.js +126 -231
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index19.js +53 -298
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index20.js +232 -43
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index21.js +295 -118
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index22.js +38 -145
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index23.js +126 -46
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index24.js +145 -117
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index25.js +38 -91
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index26.js +113 -107
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index27.js +94 -27
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index28.js +104 -619
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index29.js +34 -41
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index30.js +635 -34
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index31.js +39 -77
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index32.js +34 -117
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index33.js +75 -318
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index34.js +139 -0
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index35.js +340 -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 +55 -468
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index9.js +443 -97
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index.js +24 -21
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index10.js +32 -2
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index11.js +205 -84
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index12.js +161 -3
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index13.js +12 -20
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index14.js +23 -40
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index15.js +2 -17
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index16.js +90 -68
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index17.js +3 -20
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index18.js +20 -12
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index19.js +40 -30
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index2.js +14 -7
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index20.js +15 -301
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index21.js +73 -1
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index22.js +17 -45
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index23.js +12 -68
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index24.js +26 -490
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index25.js +294 -95
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index26.js +1 -0
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index27.js +48 -2
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index28.js +72 -4
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index29.js +496 -1
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index3.js +121 -27
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index30.js +97 -91
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index32.js +2 -236
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index33.js +3 -2
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index34.js +1 -249
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index35.js +89 -82
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index36.js +23 -54
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index37.js +223 -340
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index38.js +3 -0
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index39.js +249 -0
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index4.js +100 -216
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index40.js +93 -0
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index41.js +59 -0
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index42.js +353 -0
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index5.js +35 -29
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index6.js +2 -216
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index7.js +9 -159
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index8.js +27 -14
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index9.js +216 -23
- 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/feature/dist/index.js +12 -12
- package/package.json +1 -1
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index31.js +0 -28
package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index16.js
CHANGED
|
@@ -2,230 +2,27 @@
|
|
|
2
2
|
"use client";
|
|
3
3
|
"use client";
|
|
4
4
|
"use client";
|
|
5
|
-
import {
|
|
6
|
-
import
|
|
7
|
-
import "../../../shared/
|
|
8
|
-
import
|
|
9
|
-
import {
|
|
10
|
-
import { useSendReceivableEmailMutation as te } from "../../data-access/dist/index5.js";
|
|
11
|
-
import { useAcceptReceivableMutation as f, useCancelReceivableMutation as p, useCloneReceivableMutation as m, useDeclineReceivableMutation as h, useDeleteReceivableMutation as ne, useIssueReceivableMutation as re } from "../../data-access/dist/index7.js";
|
|
12
|
-
import { useMarkReceivablePaidMutation as ie, useMarkReceivablePartiallyPaidMutation as ae, useMarkReceivableUncollectibleMutation as oe } from "../../data-access/dist/index9.js";
|
|
5
|
+
import { useMyEntityQuery as e } from "../../../shared/data-access/dist/lib/useMyEntityQuery.js";
|
|
6
|
+
import "../../../shared/data-access/dist/index.js";
|
|
7
|
+
import { useCounterpartQuery as t } from "../../../shared/counterpart-management/data-access/dist/index3.js";
|
|
8
|
+
import "../../../shared/counterpart-management/feature/dist/index.js";
|
|
9
|
+
import { useReceivableRequiredFieldsQuery as n } from "../../data-access/dist/index10.js";
|
|
13
10
|
import "../../data-access/dist/index.js";
|
|
14
|
-
import { useReceivableIssuePreflight as g } from "./index15.js";
|
|
15
|
-
import { useCallback as _, useState as v } from "react";
|
|
16
11
|
//#region ../../libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index16.js
|
|
17
|
-
function
|
|
18
|
-
let
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
type: t.type,
|
|
26
|
-
title: a,
|
|
27
|
-
action: e
|
|
28
|
-
}, c = i === void 0 ? y : i ?? void 0;
|
|
29
|
-
if (e === "send") {
|
|
30
|
-
z(o), V(r(c, x)), U({});
|
|
31
|
-
return;
|
|
32
|
-
}
|
|
33
|
-
if (e === "recordPayment") {
|
|
34
|
-
G({
|
|
35
|
-
...o,
|
|
36
|
-
currency: c?.currency
|
|
37
|
-
}), q(n()), J({});
|
|
38
|
-
return;
|
|
39
|
-
}
|
|
40
|
-
let l = e === "issue" && c?.type === "invoice" ? c : void 0;
|
|
41
|
-
if (l && w && !s(l, x)) {
|
|
42
|
-
w(l);
|
|
43
|
-
return;
|
|
44
|
-
}
|
|
45
|
-
L(void 0), I({
|
|
46
|
-
...o,
|
|
47
|
-
issueCheck: l ? {
|
|
48
|
-
counterpartId: l.counterpart_id,
|
|
49
|
-
billingAddressId: l.counterpart_billing_address?.id ?? void 0,
|
|
50
|
-
billingCountry: l.counterpart_billing_address?.country,
|
|
51
|
-
hasReminder: ee(l)
|
|
52
|
-
} : void 0
|
|
53
|
-
});
|
|
54
|
-
}, [
|
|
55
|
-
x,
|
|
56
|
-
w,
|
|
57
|
-
y
|
|
58
|
-
]), ue = _(() => {
|
|
59
|
-
I(void 0), L(void 0);
|
|
60
|
-
}, []), Q = _(() => {
|
|
61
|
-
z(void 0), U({});
|
|
62
|
-
}, []), $ = _(() => {
|
|
63
|
-
G(void 0), J({});
|
|
64
|
-
}, []), de = _(async () => {
|
|
65
|
-
if (!F) return;
|
|
66
|
-
let n = { receivable_id: F.id };
|
|
67
|
-
if (F.issueCheck) {
|
|
68
|
-
if (Z) return;
|
|
69
|
-
let t = X.isTaxIdMissing ? x.issueTaxIdRequired : F.issueCheck.hasReminder ? d(X.counterpart, x) : void 0;
|
|
70
|
-
if (t) {
|
|
71
|
-
e.error(t), I(void 0);
|
|
72
|
-
return;
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
try {
|
|
76
|
-
if (F.action === "issue") await T.mutateAsync({ path: n });
|
|
77
|
-
else if (F.action === "cancel") await E.mutateAsync({ path: n });
|
|
78
|
-
else if (F.action === "clone") {
|
|
79
|
-
let e = await D.mutateAsync({ path: n });
|
|
80
|
-
e?.id && S?.(e.id, e.type);
|
|
81
|
-
} else F.action === "accept" ? await O.mutateAsync({ path: n }) : F.action === "decline" ? await k.mutateAsync({ path: n }) : F.action === "delete" ? (await A.mutateAsync({ path: n }), C?.(F.id)) : F.action === "markPaid" ? await M.mutateAsync({
|
|
82
|
-
path: n,
|
|
83
|
-
body: { paid_at: (/* @__PURE__ */ new Date()).toISOString() }
|
|
84
|
-
}) : F.action === "markUncollectible" && await P.mutateAsync({ path: n });
|
|
85
|
-
I(void 0), L(void 0);
|
|
86
|
-
} catch (e) {
|
|
87
|
-
L(t(e) ?? x.genericError);
|
|
88
|
-
}
|
|
89
|
-
}, [
|
|
90
|
-
O,
|
|
91
|
-
F,
|
|
92
|
-
E,
|
|
93
|
-
D,
|
|
94
|
-
k,
|
|
95
|
-
A,
|
|
96
|
-
Z,
|
|
97
|
-
T,
|
|
98
|
-
M,
|
|
99
|
-
x,
|
|
100
|
-
S,
|
|
101
|
-
C,
|
|
102
|
-
X.counterpart,
|
|
103
|
-
X.isTaxIdMissing,
|
|
104
|
-
P
|
|
105
|
-
]), fe = _(async () => {
|
|
106
|
-
if (!R) return;
|
|
107
|
-
let e = u(B, x);
|
|
108
|
-
if (o(e)) {
|
|
109
|
-
U(e);
|
|
110
|
-
return;
|
|
111
|
-
}
|
|
112
|
-
try {
|
|
113
|
-
await j.mutateAsync({
|
|
114
|
-
path: { receivable_id: R.id },
|
|
115
|
-
body: {
|
|
116
|
-
body_text: B.body,
|
|
117
|
-
subject_text: B.subject,
|
|
118
|
-
recipients: {
|
|
119
|
-
to: c(B.to),
|
|
120
|
-
cc: c(B.cc),
|
|
121
|
-
bcc: c(B.bcc)
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
}), Q();
|
|
125
|
-
} catch (e) {
|
|
126
|
-
U({ form: t(e) ?? x.genericError });
|
|
127
|
-
}
|
|
128
|
-
}, [
|
|
129
|
-
Q,
|
|
130
|
-
x,
|
|
131
|
-
j,
|
|
132
|
-
R,
|
|
133
|
-
B
|
|
134
|
-
]), pe = _(async () => {
|
|
135
|
-
if (!W) return;
|
|
136
|
-
let e = l(K, x, W.currency);
|
|
137
|
-
if (a(e)) {
|
|
138
|
-
J(e);
|
|
139
|
-
return;
|
|
140
|
-
}
|
|
141
|
-
try {
|
|
142
|
-
let e = { receivable_id: W.id }, t = K.paidAt ? new Date(K.paidAt).toISOString() : void 0;
|
|
143
|
-
K.mode === "full" ? await M.mutateAsync({
|
|
144
|
-
path: e,
|
|
145
|
-
body: {
|
|
146
|
-
comment: K.comment || void 0,
|
|
147
|
-
paid_at: t
|
|
148
|
-
}
|
|
149
|
-
}) : await N.mutateAsync({
|
|
150
|
-
path: e,
|
|
151
|
-
body: {
|
|
152
|
-
amount_paid: i(K.amountPaid, W.currency) ?? 0,
|
|
153
|
-
comment: K.comment || void 0
|
|
154
|
-
}
|
|
155
|
-
}), $();
|
|
156
|
-
} catch (e) {
|
|
157
|
-
J({ form: t(e) ?? x.genericError });
|
|
158
|
-
}
|
|
159
|
-
}, [
|
|
160
|
-
$,
|
|
161
|
-
M,
|
|
162
|
-
x,
|
|
163
|
-
N,
|
|
164
|
-
W,
|
|
165
|
-
K
|
|
166
|
-
]);
|
|
12
|
+
function r({ counterpartId: r, billingAddressId: i, billingCountry: a }) {
|
|
13
|
+
let o = e(), s = t(r || void 0), c = s.data?.id === r ? s.data : void 0, l = n({
|
|
14
|
+
counterpart_id: r || void 0,
|
|
15
|
+
counterpart_billing_address_id: i || void 0,
|
|
16
|
+
counterpart_country: a,
|
|
17
|
+
counterpart_type: c?.type,
|
|
18
|
+
enabled: !!(r && i)
|
|
19
|
+
}), u = !!l.data?.entity?.tax_id?.required;
|
|
167
20
|
return {
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
openAction: le,
|
|
173
|
-
closeAction: ue,
|
|
174
|
-
confirmAction: de,
|
|
175
|
-
sendOpen: !!R,
|
|
176
|
-
sendValues: B,
|
|
177
|
-
sendErrors: H,
|
|
178
|
-
sendInProgress: j.isPending,
|
|
179
|
-
setSendValues: V,
|
|
180
|
-
closeSend: Q,
|
|
181
|
-
submitSend: fe,
|
|
182
|
-
paymentOpen: !!W,
|
|
183
|
-
paymentValues: K,
|
|
184
|
-
paymentErrors: ce,
|
|
185
|
-
paymentInProgress: M.isPending || N.isPending,
|
|
186
|
-
setPaymentValues: q,
|
|
187
|
-
closePayment: $,
|
|
188
|
-
submitPayment: pe
|
|
189
|
-
};
|
|
190
|
-
}
|
|
191
|
-
function b(e, t) {
|
|
192
|
-
return e === "issue" ? {
|
|
193
|
-
title: t.issueTitle,
|
|
194
|
-
description: t.issueDescription,
|
|
195
|
-
confirmLabel: t.issueConfirm
|
|
196
|
-
} : e === "accept" ? {
|
|
197
|
-
title: t.acceptTitle,
|
|
198
|
-
description: t.acceptDescription,
|
|
199
|
-
confirmLabel: t.acceptConfirm
|
|
200
|
-
} : e === "decline" ? {
|
|
201
|
-
title: t.declineTitle,
|
|
202
|
-
description: t.declineDescription,
|
|
203
|
-
confirmLabel: t.declineConfirm,
|
|
204
|
-
destructive: !0
|
|
205
|
-
} : e === "cancel" ? {
|
|
206
|
-
title: t.cancelTitle,
|
|
207
|
-
description: t.cancelDescription,
|
|
208
|
-
confirmLabel: t.cancelConfirm,
|
|
209
|
-
destructive: !0
|
|
210
|
-
} : e === "clone" ? {
|
|
211
|
-
title: t.cloneTitle,
|
|
212
|
-
description: t.cloneDescription,
|
|
213
|
-
confirmLabel: t.cloneConfirm
|
|
214
|
-
} : e === "delete" ? {
|
|
215
|
-
title: t.deleteTitle,
|
|
216
|
-
description: t.deleteDescription,
|
|
217
|
-
confirmLabel: t.deleteConfirm,
|
|
218
|
-
destructive: !0
|
|
219
|
-
} : e === "markPaid" ? {
|
|
220
|
-
title: t.markPaidTitle,
|
|
221
|
-
description: t.markPaidDescription,
|
|
222
|
-
confirmLabel: t.markPaidConfirm
|
|
223
|
-
} : {
|
|
224
|
-
title: t.markUncollectibleTitle,
|
|
225
|
-
description: t.markUncollectibleDescription,
|
|
226
|
-
confirmLabel: t.markUncollectibleConfirm,
|
|
227
|
-
destructive: !0
|
|
21
|
+
counterpart: c,
|
|
22
|
+
isCounterpartLoading: !!r && (s.isLoading || s.isFetching),
|
|
23
|
+
isLoading: o.isLoading || o.isFetching || l.isLoading || l.isFetching || !!r && (s.isLoading || s.isFetching),
|
|
24
|
+
isTaxIdMissing: u && !o.data?.tax_id
|
|
228
25
|
};
|
|
229
26
|
}
|
|
230
27
|
//#endregion
|
|
231
|
-
export {
|
|
28
|
+
export { r as useReceivableIssuePreflight };
|
package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index17.js
CHANGED
|
@@ -1,63 +1,231 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
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 "../../../shared/ui/dist/index.js";
|
|
8
|
+
import { defaultPaymentValues as n, defaultSendValues as r, fromMajorUnits as i, hasPaymentErrors as a, hasSendErrors as o, isReceivableReadyToIssue as s, splitEmailList as c, validatePaymentValues as l, validateSendValues as u } from "./index13.js";
|
|
9
|
+
import { getIssueReminderBlocker as d, hasSelectedReminder as ee } from "./index15.js";
|
|
10
|
+
import { useSendReceivableEmailMutation as te } from "../../data-access/dist/index6.js";
|
|
11
|
+
import { useAcceptReceivableMutation as f, useCancelReceivableMutation as p, useCloneReceivableMutation as m, useDeclineReceivableMutation as h, useDeleteReceivableMutation as ne, useIssueReceivableMutation as re } from "../../data-access/dist/index7.js";
|
|
12
|
+
import { useMarkReceivablePaidMutation as ie, useMarkReceivablePartiallyPaidMutation as ae, useMarkReceivableUncollectibleMutation as oe } from "../../data-access/dist/index9.js";
|
|
13
|
+
import "../../data-access/dist/index.js";
|
|
14
|
+
import { useReceivableIssuePreflight as g } from "./index16.js";
|
|
15
|
+
import { useCallback as _, useState as v } from "react";
|
|
4
16
|
//#region ../../libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index17.js
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
|
|
17
|
+
function y({ selectedReceivable: y, messages: x, onCreated: S, onDeleted: C, onCompleteBeforeIssue: w }) {
|
|
18
|
+
let T = re(), E = p(), D = m(), O = f(), k = h(), A = ne(), j = te(), M = ie(), N = ae(), P = oe(), [F, I] = v(), [se, L] = v(), [R, z] = v(), [B, V] = v(() => r(void 0, x)), [H, U] = v({}), [W, G] = v(), [K, q] = v(() => n()), [ce, J] = v({}), Y = F?.issueCheck, X = g({
|
|
19
|
+
counterpartId: Y?.counterpartId,
|
|
20
|
+
billingAddressId: Y?.billingAddressId,
|
|
21
|
+
billingCountry: Y?.billingCountry
|
|
22
|
+
}), Z = !!Y && X.isLoading, le = _((e, t, i) => {
|
|
23
|
+
let a = "documentLabel" in t ? t.documentLabel : t.title, o = {
|
|
24
|
+
id: t.id,
|
|
25
|
+
type: t.type,
|
|
26
|
+
title: a,
|
|
27
|
+
action: e
|
|
28
|
+
}, c = i === void 0 ? y : i ?? void 0;
|
|
29
|
+
if (e === "send") {
|
|
30
|
+
z(o), V(r(c, x)), U({});
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
if (e === "recordPayment") {
|
|
34
|
+
G({
|
|
35
|
+
...o,
|
|
36
|
+
currency: c?.currency
|
|
37
|
+
}), q(n()), J({});
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
let l = e === "issue" && c?.type === "invoice" ? c : void 0;
|
|
41
|
+
if (l && w && !s(l, x)) {
|
|
42
|
+
w(l);
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
L(void 0), I({
|
|
46
|
+
...o,
|
|
47
|
+
issueCheck: l ? {
|
|
48
|
+
counterpartId: l.counterpart_id,
|
|
49
|
+
billingAddressId: l.counterpart_billing_address?.id ?? void 0,
|
|
50
|
+
billingCountry: l.counterpart_billing_address?.country,
|
|
51
|
+
hasReminder: ee(l)
|
|
52
|
+
} : void 0
|
|
53
|
+
});
|
|
54
|
+
}, [
|
|
55
|
+
x,
|
|
56
|
+
w,
|
|
57
|
+
y
|
|
58
|
+
]), ue = _(() => {
|
|
59
|
+
I(void 0), L(void 0);
|
|
60
|
+
}, []), Q = _(() => {
|
|
61
|
+
z(void 0), U({});
|
|
62
|
+
}, []), $ = _(() => {
|
|
63
|
+
G(void 0), J({});
|
|
64
|
+
}, []), de = _(async () => {
|
|
65
|
+
if (!F) return;
|
|
66
|
+
let n = { receivable_id: F.id };
|
|
67
|
+
if (F.issueCheck) {
|
|
68
|
+
if (Z) return;
|
|
69
|
+
let t = X.isTaxIdMissing ? x.issueTaxIdRequired : F.issueCheck.hasReminder ? d(X.counterpart, x) : void 0;
|
|
70
|
+
if (t) {
|
|
71
|
+
e.error(t), I(void 0);
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
try {
|
|
76
|
+
if (F.action === "issue") await T.mutateAsync({ path: n });
|
|
77
|
+
else if (F.action === "cancel") await E.mutateAsync({ path: n });
|
|
78
|
+
else if (F.action === "clone") {
|
|
79
|
+
let e = await D.mutateAsync({ path: n });
|
|
80
|
+
e?.id && S?.(e.id, e.type);
|
|
81
|
+
} else F.action === "accept" ? await O.mutateAsync({ path: n }) : F.action === "decline" ? await k.mutateAsync({ path: n }) : F.action === "delete" ? (await A.mutateAsync({ path: n }), C?.(F.id)) : F.action === "markPaid" ? await M.mutateAsync({
|
|
82
|
+
path: n,
|
|
83
|
+
body: { paid_at: (/* @__PURE__ */ new Date()).toISOString() }
|
|
84
|
+
}) : F.action === "markUncollectible" && await P.mutateAsync({ path: n });
|
|
85
|
+
I(void 0), L(void 0);
|
|
86
|
+
} catch (e) {
|
|
87
|
+
L(t(e) ?? x.genericError);
|
|
88
|
+
}
|
|
89
|
+
}, [
|
|
90
|
+
O,
|
|
91
|
+
F,
|
|
92
|
+
E,
|
|
93
|
+
D,
|
|
94
|
+
k,
|
|
95
|
+
A,
|
|
96
|
+
Z,
|
|
97
|
+
T,
|
|
98
|
+
M,
|
|
99
|
+
x,
|
|
100
|
+
S,
|
|
101
|
+
C,
|
|
102
|
+
X.counterpart,
|
|
103
|
+
X.isTaxIdMissing,
|
|
104
|
+
P
|
|
105
|
+
]), fe = _(async () => {
|
|
106
|
+
if (!R) return;
|
|
107
|
+
let e = u(B, x);
|
|
108
|
+
if (o(e)) {
|
|
109
|
+
U(e);
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
try {
|
|
113
|
+
await j.mutateAsync({
|
|
114
|
+
path: { receivable_id: R.id },
|
|
115
|
+
body: {
|
|
116
|
+
body_text: B.body,
|
|
117
|
+
subject_text: B.subject,
|
|
118
|
+
recipients: {
|
|
119
|
+
to: c(B.to),
|
|
120
|
+
cc: c(B.cc),
|
|
121
|
+
bcc: c(B.bcc)
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
}), Q();
|
|
125
|
+
} catch (e) {
|
|
126
|
+
U({ form: t(e) ?? x.genericError });
|
|
127
|
+
}
|
|
128
|
+
}, [
|
|
129
|
+
Q,
|
|
130
|
+
x,
|
|
131
|
+
j,
|
|
132
|
+
R,
|
|
133
|
+
B
|
|
134
|
+
]), pe = _(async () => {
|
|
135
|
+
if (!W) return;
|
|
136
|
+
let e = l(K, x, W.currency);
|
|
137
|
+
if (a(e)) {
|
|
138
|
+
J(e);
|
|
139
|
+
return;
|
|
140
|
+
}
|
|
141
|
+
try {
|
|
142
|
+
let e = { receivable_id: W.id }, t = K.paidAt ? new Date(K.paidAt).toISOString() : void 0;
|
|
143
|
+
K.mode === "full" ? await M.mutateAsync({
|
|
144
|
+
path: e,
|
|
145
|
+
body: {
|
|
146
|
+
comment: K.comment || void 0,
|
|
147
|
+
paid_at: t
|
|
148
|
+
}
|
|
149
|
+
}) : await N.mutateAsync({
|
|
150
|
+
path: e,
|
|
151
|
+
body: {
|
|
152
|
+
amount_paid: i(K.amountPaid, W.currency) ?? 0,
|
|
153
|
+
comment: K.comment || void 0
|
|
154
|
+
}
|
|
155
|
+
}), $();
|
|
156
|
+
} catch (e) {
|
|
157
|
+
J({ form: t(e) ?? x.genericError });
|
|
158
|
+
}
|
|
159
|
+
}, [
|
|
160
|
+
$,
|
|
161
|
+
M,
|
|
162
|
+
x,
|
|
163
|
+
N,
|
|
164
|
+
W,
|
|
165
|
+
K
|
|
166
|
+
]);
|
|
13
167
|
return {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
168
|
+
actionTarget: F,
|
|
169
|
+
actionDialog: F ? b(F.action, x) : void 0,
|
|
170
|
+
actionError: se,
|
|
171
|
+
actionInProgress: Z || T.isPending || E.isPending || D.isPending || O.isPending || k.isPending || A.isPending || M.isPending || P.isPending,
|
|
172
|
+
openAction: le,
|
|
173
|
+
closeAction: ue,
|
|
174
|
+
confirmAction: de,
|
|
175
|
+
sendOpen: !!R,
|
|
176
|
+
sendValues: B,
|
|
177
|
+
sendErrors: H,
|
|
178
|
+
sendInProgress: j.isPending,
|
|
179
|
+
setSendValues: V,
|
|
180
|
+
closeSend: Q,
|
|
181
|
+
submitSend: fe,
|
|
182
|
+
paymentOpen: !!W,
|
|
183
|
+
paymentValues: K,
|
|
184
|
+
paymentErrors: ce,
|
|
185
|
+
paymentInProgress: M.isPending || N.isPending,
|
|
186
|
+
setPaymentValues: q,
|
|
187
|
+
closePayment: $,
|
|
188
|
+
submitPayment: pe
|
|
17
189
|
};
|
|
18
190
|
}
|
|
19
|
-
function
|
|
20
|
-
return
|
|
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
|
-
display_name: e.displayName || void 0,
|
|
57
|
-
account_holder_name: e.accountHolderName.trim() || void 0,
|
|
58
|
-
account_number: e.accountNumber.trim() || void 0,
|
|
59
|
-
routing_number: e.routingNumber.trim() || void 0
|
|
191
|
+
function b(e, t) {
|
|
192
|
+
return e === "issue" ? {
|
|
193
|
+
title: t.issueTitle,
|
|
194
|
+
description: t.issueDescription,
|
|
195
|
+
confirmLabel: t.issueConfirm
|
|
196
|
+
} : e === "accept" ? {
|
|
197
|
+
title: t.acceptTitle,
|
|
198
|
+
description: t.acceptDescription,
|
|
199
|
+
confirmLabel: t.acceptConfirm
|
|
200
|
+
} : e === "decline" ? {
|
|
201
|
+
title: t.declineTitle,
|
|
202
|
+
description: t.declineDescription,
|
|
203
|
+
confirmLabel: t.declineConfirm,
|
|
204
|
+
destructive: !0
|
|
205
|
+
} : e === "cancel" ? {
|
|
206
|
+
title: t.cancelTitle,
|
|
207
|
+
description: t.cancelDescription,
|
|
208
|
+
confirmLabel: t.cancelConfirm,
|
|
209
|
+
destructive: !0
|
|
210
|
+
} : e === "clone" ? {
|
|
211
|
+
title: t.cloneTitle,
|
|
212
|
+
description: t.cloneDescription,
|
|
213
|
+
confirmLabel: t.cloneConfirm
|
|
214
|
+
} : e === "delete" ? {
|
|
215
|
+
title: t.deleteTitle,
|
|
216
|
+
description: t.deleteDescription,
|
|
217
|
+
confirmLabel: t.deleteConfirm,
|
|
218
|
+
destructive: !0
|
|
219
|
+
} : e === "markPaid" ? {
|
|
220
|
+
title: t.markPaidTitle,
|
|
221
|
+
description: t.markPaidDescription,
|
|
222
|
+
confirmLabel: t.markPaidConfirm
|
|
223
|
+
} : {
|
|
224
|
+
title: t.markUncollectibleTitle,
|
|
225
|
+
description: t.markUncollectibleDescription,
|
|
226
|
+
confirmLabel: t.markUncollectibleConfirm,
|
|
227
|
+
destructive: !0
|
|
60
228
|
};
|
|
61
229
|
}
|
|
62
230
|
//#endregion
|
|
63
|
-
export {
|
|
231
|
+
export { y as useReceivableActions };
|