@tesouro/embedded-components-react 0.5.227 → 0.5.228
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 +21 -21
- package/dist/index.d.ts +54 -34
- package/dist/index.js +1 -1
- package/dist/lib/ReceivablesWidget.d.ts +54 -34
- package/dist/lib/ReceivablesWidget.js +1 -1
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index.js +4 -4
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index10.js +29 -59
- 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/index12.js +36 -141
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index13.js +26 -16
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index17.js +58 -37
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index18.js +228 -122
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index19.js +300 -147
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index20.js +34 -37
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index21.js +126 -122
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index22.js +150 -58
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index23.js +38 -91
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index24.js +113 -107
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index25.js +98 -231
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index26.js +111 -27
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index27.js +25 -624
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index28.js +631 -39
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index29.js +41 -40
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index30.js +35 -74
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index31.js +73 -115
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index32.js +115 -313
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index33.js +325 -0
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index7.js +15 -2
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index.js +11 -12
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index14.js +42 -1
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index15.js +19 -3
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index16.js +73 -3
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index17.js +3 -1
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index18.js +16 -1
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index19.js +32 -4
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index20.js +304 -11
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index22.js +42 -258
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index23.js +62 -38
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index24.js +485 -61
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index25.js +90 -480
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index27.js +2 -0
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index28.js +3 -1
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index29.js +0 -3
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index30.js +100 -1
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index31.js +23 -95
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index32.js +231 -23
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index33.js +3 -236
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index34.js +249 -3
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index35.js +78 -234
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index36.js +53 -87
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index37.js +343 -49
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index4.js +29 -20
- package/dist/libs/tesouro-embedded-components-react/shared/data-access/dist/index.js +40 -40
- package/dist/libs/tesouro-embedded-components-react/shared/data-access/dist/lib/rest/@tanstack/react-query.gen.js +189 -211
- package/dist/libs/tesouro-embedded-components-react/shared/data-access/dist/lib/rest/sdk.gen.js +43 -59
- package/dist/libs/tesouro-embedded-components-react/shared/feature/dist/lib/analytics/build-info.js +1 -1
- package/package.json +1 -1
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index26.js +0 -106
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index38.js +0 -353
package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index24.js
CHANGED
|
@@ -2,120 +2,126 @@
|
|
|
2
2
|
"use client";
|
|
3
3
|
"use client";
|
|
4
4
|
"use client";
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import
|
|
8
|
-
import "
|
|
9
|
-
import {
|
|
10
|
-
import "../../../shared/feature/dist/index.js";
|
|
11
|
-
import { areOverdueTermsValid as i, buildOverdueReminderPayload as a, buildPaymentReminderPayload as o, buildRemindersView as s, canCreateReminders as c, getImpliedDueDate as l, isBeforeDueDaysValid as u, sanitizeReminderDays as d } from "./index14.js";
|
|
12
|
-
import { useCreateOverdueReminderMutation as f, useCreatePaymentReminderMutation as p, useOverdueRemindersQuery as m, usePaymentRemindersQuery as h } from "../../data-access/dist/index11.js";
|
|
13
|
-
import "../../data-access/dist/index.js";
|
|
14
|
-
import { useCallback as g, useMemo as _, useState as v } from "react";
|
|
5
|
+
import { getCounterpartEmail as e } from "../../../shared/counterpart-management/feature/dist/lib/helpers.js";
|
|
6
|
+
import { useCounterpartQuery as t } from "../../../shared/counterpart-management/data-access/dist/index3.js";
|
|
7
|
+
import "../../../shared/counterpart-management/feature/dist/index.js";
|
|
8
|
+
import { applyRecurrenceEmailDraft as n, buildRecurrenceEmailView as r, buildRecurrenceView as i, clearRecurrenceRecipients as a, createRecurrenceEmailDraft as o, selectRecurrenceDate as s, selectRecurrenceDayOfWeek as c, selectRecurrenceEndMode as l, selectRecurrenceFrequency as u, selectRecurrenceIssueMode as d, shouldOpenRecurrenceEmail as f } from "./index8.js";
|
|
9
|
+
import { useCallback as p, useEffect as m, useMemo as h, useRef as g, useState as _ } from "react";
|
|
15
10
|
//#region ../../libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index24.js
|
|
16
|
-
var
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
paymentTermsCustomDate: w,
|
|
33
|
-
paymentTerms: A,
|
|
34
|
-
today: /* @__PURE__ */ new Date()
|
|
35
|
-
}), [
|
|
36
|
-
A,
|
|
37
|
-
w,
|
|
38
|
-
C
|
|
39
|
-
]), Q = g(async () => {
|
|
40
|
-
if (u(P)) try {
|
|
41
|
-
let t = await V.mutateAsync({ body: o({
|
|
42
|
-
daysBefore: Number(P),
|
|
43
|
-
dueDate: Z(),
|
|
44
|
-
messages: D
|
|
45
|
-
}) });
|
|
46
|
-
F(""), O({ paymentReminderId: t.id }), e.success(D.reminderAdded);
|
|
47
|
-
} catch (n) {
|
|
48
|
-
e.error(t(n) ?? D.genericError);
|
|
49
|
-
}
|
|
50
|
-
}, [
|
|
51
|
-
P,
|
|
52
|
-
V,
|
|
53
|
-
Z,
|
|
54
|
-
D,
|
|
55
|
-
O
|
|
56
|
-
]), $ = g(async () => {
|
|
57
|
-
if (i(I)) try {
|
|
58
|
-
let t = await H.mutateAsync({ body: a({
|
|
59
|
-
terms: I,
|
|
60
|
-
dueDate: Z(),
|
|
61
|
-
messages: D
|
|
62
|
-
}) });
|
|
63
|
-
L(y), O({ overdueReminderId: t.id }), e.success(D.reminderAdded);
|
|
64
|
-
} catch (n) {
|
|
65
|
-
e.error(t(n) ?? D.genericError);
|
|
66
|
-
}
|
|
67
|
-
}, [
|
|
68
|
-
H,
|
|
69
|
-
Z,
|
|
70
|
-
D,
|
|
11
|
+
var v = [
|
|
12
|
+
"recurrenceStartDate",
|
|
13
|
+
"recurrenceEndDate",
|
|
14
|
+
"recurrenceIssueMode",
|
|
15
|
+
"recurrenceDayOfWeek",
|
|
16
|
+
"recurrenceEndMode",
|
|
17
|
+
"recurrenceMaxOccurrences"
|
|
18
|
+
], y = [
|
|
19
|
+
"recurrenceSubject",
|
|
20
|
+
"recurrenceBody",
|
|
21
|
+
"recurrenceRecipientsTo",
|
|
22
|
+
"recurrenceRecipientsCc",
|
|
23
|
+
"recurrenceRecipientsBcc"
|
|
24
|
+
];
|
|
25
|
+
function b({ values: b, errors: x, lockSchedule: S, messages: C, onChange: w, onClearErrors: T, onRevalidateErrors: E }) {
|
|
26
|
+
let D = t(b.customerId || void 0), O = D.data ? e(D.data).trim() : "", [k, A] = _(!1), [j, M] = _(b), [N, P] = _(null), F = h(() => N ?? o(j, O), [
|
|
71
27
|
O,
|
|
72
|
-
|
|
73
|
-
|
|
28
|
+
N,
|
|
29
|
+
j
|
|
30
|
+
]), I = g(O);
|
|
31
|
+
m(() => {
|
|
32
|
+
let e = I.current;
|
|
33
|
+
I.current = O, e && e !== O && w(a);
|
|
34
|
+
}, [O, w]);
|
|
35
|
+
let L = p((e) => {
|
|
36
|
+
M(e), P(null), A(!0);
|
|
37
|
+
}, []);
|
|
74
38
|
return {
|
|
75
|
-
view:
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
paymentReminders: z.data?.data,
|
|
82
|
-
overdueReminders: B.data?.data,
|
|
83
|
-
canCreate: j,
|
|
84
|
-
disabled: S,
|
|
85
|
-
beforeDueInput: P,
|
|
86
|
-
overdueTerms: I,
|
|
87
|
-
isCreatingPaymentReminder: V.isPending,
|
|
88
|
-
isCreatingOverdueReminder: H.isPending,
|
|
89
|
-
today: /* @__PURE__ */ new Date(),
|
|
90
|
-
messages: D
|
|
91
|
-
}) : void 0, [
|
|
92
|
-
P,
|
|
93
|
-
j,
|
|
94
|
-
H.isPending,
|
|
95
|
-
V.isPending,
|
|
96
|
-
S,
|
|
39
|
+
view: h(() => i({
|
|
40
|
+
fields: b,
|
|
41
|
+
errors: x,
|
|
42
|
+
lockSchedule: S,
|
|
43
|
+
messages: C
|
|
44
|
+
}), [
|
|
97
45
|
x,
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
46
|
+
S,
|
|
47
|
+
C,
|
|
48
|
+
b
|
|
49
|
+
]),
|
|
50
|
+
emailView: h(() => r({
|
|
51
|
+
open: k,
|
|
52
|
+
ready: !D.isLoading,
|
|
53
|
+
draft: F,
|
|
54
|
+
messages: C
|
|
55
|
+
}), [
|
|
56
|
+
D.isLoading,
|
|
57
|
+
F,
|
|
58
|
+
k,
|
|
59
|
+
C
|
|
60
|
+
]),
|
|
61
|
+
changeFrequency: p((e) => {
|
|
62
|
+
T(v), w((t) => u(t, e));
|
|
63
|
+
}, [w, T]),
|
|
64
|
+
changeMonthDay: p((e) => {
|
|
65
|
+
E(["recurrenceIssueMode"]), w((t) => d(t, e, { lockSchedule: S }));
|
|
66
|
+
}, [
|
|
67
|
+
S,
|
|
68
|
+
w,
|
|
69
|
+
E
|
|
70
|
+
]),
|
|
71
|
+
changeWeekday: p((e) => {
|
|
72
|
+
S || (T(["recurrenceStartDate"]), E(["recurrenceDayOfWeek"]), w((t) => c(t, e, { lockSchedule: S })));
|
|
73
|
+
}, [
|
|
74
|
+
S,
|
|
75
|
+
w,
|
|
102
76
|
T,
|
|
103
|
-
|
|
77
|
+
E
|
|
78
|
+
]),
|
|
79
|
+
changeStartDate: p((e) => {
|
|
80
|
+
E(["recurrenceStartDate"]), w((t) => s(t, "recurrenceStartDate", e));
|
|
81
|
+
}, [w, E]),
|
|
82
|
+
changeEndDate: p((e) => {
|
|
83
|
+
E(["recurrenceEndDate"]), w((t) => s(t, "recurrenceEndDate", e));
|
|
84
|
+
}, [w, E]),
|
|
85
|
+
changeEndMode: p((e) => {
|
|
86
|
+
E(["recurrenceEndMode"]), w((t) => l(t, e));
|
|
87
|
+
}, [w, E]),
|
|
88
|
+
changeMaxOccurrences: p((e) => {
|
|
89
|
+
E(["recurrenceMaxOccurrences"]), w((t) => ({
|
|
90
|
+
...t,
|
|
91
|
+
recurrenceMaxOccurrences: e
|
|
92
|
+
}));
|
|
93
|
+
}, [w, E]),
|
|
94
|
+
changeCreationMode: p((e) => {
|
|
95
|
+
let t = {
|
|
96
|
+
...b,
|
|
97
|
+
recurrenceAutomationLevel: e
|
|
98
|
+
};
|
|
99
|
+
w((t) => ({
|
|
100
|
+
...t,
|
|
101
|
+
recurrenceAutomationLevel: e
|
|
102
|
+
})), f(t, e) && L(t);
|
|
103
|
+
}, [
|
|
104
104
|
w,
|
|
105
|
-
|
|
106
|
-
|
|
105
|
+
L,
|
|
106
|
+
b
|
|
107
|
+
]),
|
|
108
|
+
setUpEmail: p(() => L(b), [L, b]),
|
|
109
|
+
changeEmailOpen: A,
|
|
110
|
+
changeEmail: p((e, t) => P((n) => ({
|
|
111
|
+
...n ?? F,
|
|
112
|
+
[e]: t
|
|
113
|
+
})), [F]),
|
|
114
|
+
saveEmail: p(() => {
|
|
115
|
+
w((e) => n(e, F)), T(y), A(!1);
|
|
116
|
+
}, [
|
|
117
|
+
F,
|
|
118
|
+
w,
|
|
119
|
+
T
|
|
107
120
|
]),
|
|
108
|
-
reset:
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
selectOverdueReminder: K,
|
|
112
|
-
changeBeforeDueInput: q,
|
|
113
|
-
saveBeforeDue: Q,
|
|
114
|
-
changeOverdueTerm: J,
|
|
115
|
-
addOverdueTerm: Y,
|
|
116
|
-
clearOverdueTerms: X,
|
|
117
|
-
saveOverdue: $
|
|
121
|
+
reset: p(() => {
|
|
122
|
+
A(!1), I.current = "";
|
|
123
|
+
}, [])
|
|
118
124
|
};
|
|
119
125
|
}
|
|
120
126
|
//#endregion
|
|
121
|
-
export { b as
|
|
127
|
+
export { b as useReceivableRecurrence };
|
package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index25.js
CHANGED
|
@@ -1,237 +1,104 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import
|
|
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 { useWidgetConfig as n } from "../../../shared/feature/dist/lib/WidgetProvider/hooks.js";
|
|
9
|
+
import "../../../shared/feature/dist/index.js";
|
|
10
|
+
import { useCreateEntityBankAccountMutation as r, usePaymentAccountsQuery as i } from "../../data-access/dist/index3.js";
|
|
11
|
+
import "../../data-access/dist/index.js";
|
|
12
|
+
import { EMPTY_BANK_ACCOUNT_FORM_VALUES as a, bankAccountFormToPayload as o, buildBankAccountSectionView as s, buildPaymentAccountOptions as c, getBankAccountPermissions as l, validateBankAccountForm as u } from "./index17.js";
|
|
13
|
+
import { useCallback as d, useEffect as f, useMemo as p, useRef as m, useState as h } from "react";
|
|
8
14
|
//#region ../../libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index25.js
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
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
|
-
if (!
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
dueDate: v([s(r)]),
|
|
52
|
-
paymentTerms: v([i.previewDueOnReceipt])
|
|
53
|
-
};
|
|
54
|
-
let o = n?.find((t) => t.id === e);
|
|
55
|
-
if (!o) return a;
|
|
56
|
-
let c = l(o, r), u = [
|
|
57
|
-
o.term_1 && b(i, o.term_1),
|
|
58
|
-
o.term_2 && b(i, o.term_2),
|
|
59
|
-
o.term_final && y(i, o.term_final.number_of_days)
|
|
60
|
-
].filter((e) => !!e);
|
|
61
|
-
return {
|
|
62
|
-
dueDate: c ? v([s(c)]) : _,
|
|
63
|
-
paymentTerms: u.length > 0 ? v(u) : _
|
|
64
|
-
};
|
|
65
|
-
}
|
|
66
|
-
function S(e, t) {
|
|
67
|
-
return t ? e.previewTaxId.replace("{taxId}", t) : void 0;
|
|
68
|
-
}
|
|
69
|
-
function C(e) {
|
|
70
|
-
return e.length > 0 ? e : void 0;
|
|
71
|
-
}
|
|
72
|
-
function w(e, t) {
|
|
73
|
-
return e ? {
|
|
74
|
-
name: e.type === "organization" ? e.organization.legal_name : void 0,
|
|
75
|
-
addressLines: C(g({
|
|
76
|
-
address: e.address,
|
|
77
|
-
issuerCountry: e.address?.country
|
|
78
|
-
})),
|
|
79
|
-
taxIdLine: S(t, e.tax_id),
|
|
80
|
-
email: e.email ?? void 0,
|
|
81
|
-
phone: e.phone ?? void 0
|
|
82
|
-
} : {};
|
|
83
|
-
}
|
|
84
|
-
function T(e) {
|
|
85
|
-
let t = "organization" in e ? e.organization : e.individual;
|
|
86
|
-
return {
|
|
87
|
-
name: "organization" in e ? e.organization.legal_name : [e.individual.first_name, e.individual.last_name].filter(Boolean).join(" "),
|
|
88
|
-
email: t.email,
|
|
89
|
-
phone: t.phone
|
|
90
|
-
};
|
|
91
|
-
}
|
|
92
|
-
function E({ counterpart: e, billingAddress: t, issuerCountry: n, messages: r }) {
|
|
93
|
-
if (!e) return { kind: "pending" };
|
|
94
|
-
let { name: i, email: a, phone: o } = T(e);
|
|
95
|
-
return i ? {
|
|
96
|
-
kind: "party",
|
|
97
|
-
name: i,
|
|
98
|
-
addressLines: C(g({
|
|
99
|
-
address: t,
|
|
100
|
-
issuerCountry: n
|
|
101
|
-
})),
|
|
102
|
-
taxIdLine: S(r, e.tax_id),
|
|
103
|
-
email: a || void 0,
|
|
104
|
-
phone: o || void 0
|
|
105
|
-
} : { kind: "pending" };
|
|
106
|
-
}
|
|
107
|
-
function D({ lineItems: e, currency: n, unitNamesById: r, messages: o }) {
|
|
108
|
-
return e.filter((e) => !t(e)).map((e) => {
|
|
109
|
-
let t = a(e.price, n), s = i(e.quantity), c = r[e.measureUnitId] || e.measureUnitName;
|
|
110
|
-
return {
|
|
111
|
-
id: e.id,
|
|
112
|
-
name: e.name,
|
|
113
|
-
quantity: String(s),
|
|
114
|
-
price: u({
|
|
115
|
-
amount: t,
|
|
116
|
-
currency: n,
|
|
117
|
-
fallback: ""
|
|
118
|
-
}),
|
|
119
|
-
...c ? { unit: c } : {},
|
|
120
|
-
taxable: e.taxable ? o.previewTaxableYes : o.previewTaxableNo,
|
|
121
|
-
amount: u({
|
|
122
|
-
amount: Math.round(t * s),
|
|
123
|
-
currency: n,
|
|
124
|
-
fallback: ""
|
|
125
|
-
})
|
|
126
|
-
};
|
|
127
|
-
});
|
|
128
|
-
}
|
|
129
|
-
function O(t, n) {
|
|
130
|
-
return n ? new Intl.NumberFormat(void 0, {
|
|
131
|
-
style: "currency",
|
|
132
|
-
currency: n,
|
|
133
|
-
currencySign: "accounting"
|
|
134
|
-
}).format(-t / 10 ** e(n)) : "";
|
|
135
|
-
}
|
|
136
|
-
function k(e, i) {
|
|
137
|
-
if (!e.taxRate) return i.previewTax;
|
|
138
|
-
let a = o(e.taxRate), s = n(e.taxRate, e.savedTaxRate);
|
|
139
|
-
return new Set(e.lineItems.filter((e) => e.taxable && !t(e)).map((e) => r(e, a, s))).size > 1 ? i.previewTax : i.previewTaxWithRate.replace("{rate}", String(a / m));
|
|
140
|
-
}
|
|
141
|
-
function A({ totals: e, currency: t, taxLabel: n, messages: r }) {
|
|
142
|
-
let i = (e) => u({
|
|
143
|
-
amount: e,
|
|
144
|
-
currency: t,
|
|
145
|
-
fallback: ""
|
|
146
|
-
}), a = e.discountAmount > 0, o = e.taxableItemsSubtotal > 0, s = e.nonTaxableItemsSubtotal > 0, c = [{
|
|
147
|
-
id: "subtotal",
|
|
148
|
-
label: r.previewSubtotal,
|
|
149
|
-
value: i(e.subtotal)
|
|
150
|
-
}];
|
|
151
|
-
return a && c.push({
|
|
152
|
-
id: "discount",
|
|
153
|
-
label: r.previewDiscount,
|
|
154
|
-
value: O(e.discountAmount, t)
|
|
155
|
-
}), s && (o || a) && c.push({
|
|
156
|
-
id: "nonTaxableSubtotal",
|
|
157
|
-
label: r.previewNonTaxableSubtotal,
|
|
158
|
-
value: i(e.nonTaxableSubtotal),
|
|
159
|
-
muted: !0
|
|
160
|
-
}), o && (s || a) && c.push({
|
|
161
|
-
id: "taxableSubtotal",
|
|
162
|
-
label: r.previewTaxableSubtotal,
|
|
163
|
-
value: i(e.taxableSubtotal),
|
|
164
|
-
muted: !0
|
|
165
|
-
}), c.push({
|
|
166
|
-
id: "tax",
|
|
167
|
-
label: n,
|
|
168
|
-
value: i(e.totalTaxes)
|
|
169
|
-
}), {
|
|
170
|
-
rows: c,
|
|
171
|
-
total: {
|
|
172
|
-
label: r.previewTotal,
|
|
173
|
-
value: i(e.total)
|
|
15
|
+
function g({ open: g, bankAccountId: _, embeddedBankName: v, messages: y, onSelect: b }) {
|
|
16
|
+
let { initResponse: x } = n(), S = p(() => l(x?.scopes), [x?.scopes]), { paymentAccounts: C, isLoading: w, isIncomplete: T } = i({
|
|
17
|
+
enabled: g,
|
|
18
|
+
canReadEmbedded: S.canReadEmbedded,
|
|
19
|
+
canReadExternal: S.canReadExternal
|
|
20
|
+
}), E = r(), [D, O] = h(!1), [k, A] = h(a), [j, M] = h({}), N = m(!1), P = d(() => {
|
|
21
|
+
N.current = !1, O(!1), A(a), M({});
|
|
22
|
+
}, []);
|
|
23
|
+
f(() => {
|
|
24
|
+
if (!g || T || N.current || C.length !== 1) return;
|
|
25
|
+
let [e] = C;
|
|
26
|
+
N.current = !0, b({
|
|
27
|
+
bankAccountId: e.id,
|
|
28
|
+
bankAccountType: e.type
|
|
29
|
+
});
|
|
30
|
+
}, [
|
|
31
|
+
T,
|
|
32
|
+
b,
|
|
33
|
+
g,
|
|
34
|
+
C
|
|
35
|
+
]);
|
|
36
|
+
let F = d((e) => {
|
|
37
|
+
let t = C.find((t) => t.id === e);
|
|
38
|
+
t && b({
|
|
39
|
+
bankAccountId: t.id,
|
|
40
|
+
bankAccountType: t.type
|
|
41
|
+
});
|
|
42
|
+
}, [b, C]), I = d(() => O(!0), []), L = d(() => {
|
|
43
|
+
O(!1), A(a), M({});
|
|
44
|
+
}, []), R = d((e) => A((t) => ({
|
|
45
|
+
...t,
|
|
46
|
+
...e
|
|
47
|
+
})), []), z = d(async () => {
|
|
48
|
+
let n = u(k, y);
|
|
49
|
+
if (M(n), !(Object.keys(n).length > 0)) try {
|
|
50
|
+
let t = await E.mutateAsync({ body: o(k) });
|
|
51
|
+
O(!1), A(a), b({
|
|
52
|
+
bankAccountId: t.id,
|
|
53
|
+
bankAccountType: "BANK_DETAILS"
|
|
54
|
+
}), e.success(y.bankAccountCreated.replace("{name}", t.display_name ?? ""));
|
|
55
|
+
} catch (n) {
|
|
56
|
+
e.error(t(n) ?? y.bankAccountCreateFailed);
|
|
174
57
|
}
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
let p = D({
|
|
190
|
-
lineItems: e.lineItems,
|
|
191
|
-
currency: e.currency,
|
|
192
|
-
unitNamesById: o,
|
|
193
|
-
messages: d
|
|
194
|
-
}), m = n?.logo?.url, h = w(n, d), g = c(e.issueDate, f);
|
|
58
|
+
}, [
|
|
59
|
+
E,
|
|
60
|
+
k,
|
|
61
|
+
y,
|
|
62
|
+
b
|
|
63
|
+
]), B = p(() => c({
|
|
64
|
+
accounts: C,
|
|
65
|
+
embeddedBankName: v,
|
|
66
|
+
messages: y
|
|
67
|
+
}), [
|
|
68
|
+
v,
|
|
69
|
+
y,
|
|
70
|
+
C
|
|
71
|
+
]);
|
|
195
72
|
return {
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
currency: e.currency,
|
|
225
|
-
taxLabel: k(e, d),
|
|
226
|
-
messages: d
|
|
227
|
-
}) : void 0,
|
|
228
|
-
closingNote: e.closingNote || void 0,
|
|
229
|
-
payment: j({
|
|
230
|
-
bankDetails: l,
|
|
231
|
-
canReceivePayments: u,
|
|
232
|
-
messages: d
|
|
233
|
-
})
|
|
73
|
+
view: p(() => s({
|
|
74
|
+
options: B,
|
|
75
|
+
isLoading: w,
|
|
76
|
+
selectedId: _,
|
|
77
|
+
isAddingAccount: D,
|
|
78
|
+
canAddAccount: S.canAddAccount,
|
|
79
|
+
formValues: k,
|
|
80
|
+
formErrors: j,
|
|
81
|
+
isSaving: E.isPending
|
|
82
|
+
}), [
|
|
83
|
+
_,
|
|
84
|
+
E.isPending,
|
|
85
|
+
j,
|
|
86
|
+
k,
|
|
87
|
+
D,
|
|
88
|
+
w,
|
|
89
|
+
B,
|
|
90
|
+
S.canAddAccount
|
|
91
|
+
]),
|
|
92
|
+
isLoading: w,
|
|
93
|
+
hasAccounts: C.length > 0,
|
|
94
|
+
canAddAccount: S.canAddAccount,
|
|
95
|
+
reset: P,
|
|
96
|
+
selectAccount: F,
|
|
97
|
+
openAddAccount: I,
|
|
98
|
+
cancelAddAccount: L,
|
|
99
|
+
updateAccountForm: R,
|
|
100
|
+
saveAccount: z
|
|
234
101
|
};
|
|
235
102
|
}
|
|
236
103
|
//#endregion
|
|
237
|
-
export { g as
|
|
104
|
+
export { g as useReceivableBankAccount };
|