@tesouro/embedded-components-react 0.5.206 → 0.5.210
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 -1
- package/dist/index.d.ts +40 -0
- package/dist/index.js +1 -1
- package/dist/lib/ReceivablesWidget.d.ts +40 -0
- package/dist/lib/ReceivablesWidget.js +1 -1
- 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 +84 -2
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index2.js +31 -25
- 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 +22 -1
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index11.js +151 -187
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index12.js +202 -31
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index13.js +32 -145
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index14.js +145 -37
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index15.js +42 -58
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index16.js +58 -96
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index17.js +96 -47
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index18.js +103 -318
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index19.js +47 -70
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index20.js +350 -100
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index21.js +68 -263
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index22.js +115 -0
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index23.js +285 -0
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index9.js +10 -2
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index.js +4 -3
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index23.js +11 -10
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index25.js +234 -78
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index26.js +80 -331
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index27.js +344 -0
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index3.js +14 -1
- package/dist/libs/tesouro-embedded-components-react/settings-widget/invoice-settings/data-access/dist/index.js +7 -8
- package/dist/libs/tesouro-embedded-components-react/settings-widget/invoice-settings/data-access/dist/index2.js +11 -10
- package/dist/libs/tesouro-embedded-components-react/settings-widget/invoice-settings/data-access/dist/index3.js +2 -2
- package/dist/libs/tesouro-embedded-components-react/settings-widget/invoice-settings/data-access/dist/index4.js +12 -24
- package/dist/libs/tesouro-embedded-components-react/settings-widget/invoice-settings/data-access/dist/index5.js +36 -14
- package/dist/libs/tesouro-embedded-components-react/settings-widget/invoice-settings/data-access/dist/index6.js +16 -21
- package/dist/libs/tesouro-embedded-components-react/settings-widget/invoice-settings/data-access/dist/index7.js +6 -7
- package/dist/libs/tesouro-embedded-components-react/settings-widget/invoice-settings/feature/dist/index10.js +23 -22
- package/dist/libs/tesouro-embedded-components-react/settings-widget/invoice-settings/feature/dist/index7.js +1 -1
- package/dist/libs/tesouro-embedded-components-react/settings-widget/invoice-settings/feature/dist/index8.js +2 -2
- package/dist/libs/tesouro-embedded-components-react/shared/counterpart-management/feature/dist/index.js +11 -11
- package/dist/libs/tesouro-embedded-components-react/shared/data-access/dist/index.js +40 -39
- package/dist/libs/tesouro-embedded-components-react/shared/data-access/dist/lib/queryKeys.js +8 -4
- package/dist/libs/tesouro-embedded-components-react/shared/data-access/dist/lib/rest/@tanstack/react-query.gen.js +220 -198
- package/dist/libs/tesouro-embedded-components-react/shared/data-access/dist/lib/rest/sdk.gen.js +124 -84
- package/dist/libs/tesouro-embedded-components-react/shared/data-access/dist/lib/useMyEntityQuery.js +25 -0
- 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/settings-widget/invoice-settings/data-access/dist/index8.js +0 -34
package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index17.js
CHANGED
|
@@ -1,52 +1,101 @@
|
|
|
1
|
-
|
|
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 "./index16.js";
|
|
13
|
+
import { useCallback as d, useEffect as f, useMemo as p, useRef as m, useState as h } from "react";
|
|
2
14
|
//#region ../../libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index17.js
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
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);
|
|
57
|
+
}
|
|
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
|
+
]);
|
|
10
72
|
return {
|
|
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
|
-
subtotal: s.subtotal
|
|
37
|
-
}), { taxableSubtotal: l, nonTaxableSubtotal: u } = a({
|
|
38
|
-
...s,
|
|
39
|
-
discountAmount: c
|
|
40
|
-
}), d = s.rate ? Math.round(l * s.rate) : 0, f = s.subtotal - c;
|
|
41
|
-
return {
|
|
42
|
-
...s,
|
|
43
|
-
discountAmount: c,
|
|
44
|
-
discountedSubtotal: f,
|
|
45
|
-
taxableSubtotal: l,
|
|
46
|
-
nonTaxableSubtotal: u,
|
|
47
|
-
totalTaxes: d,
|
|
48
|
-
total: f + d
|
|
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
|
+
reset: P,
|
|
93
|
+
selectAccount: F,
|
|
94
|
+
openAddAccount: I,
|
|
95
|
+
cancelAddAccount: L,
|
|
96
|
+
updateAccountForm: R,
|
|
97
|
+
saveAccount: z
|
|
49
98
|
};
|
|
50
99
|
}
|
|
51
100
|
//#endregion
|
|
52
|
-
export {
|
|
101
|
+
export { g as useReceivableBankAccount };
|
package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index18.js
CHANGED
|
@@ -2,335 +2,120 @@
|
|
|
2
2
|
"use client";
|
|
3
3
|
"use client";
|
|
4
4
|
"use client";
|
|
5
|
-
import {
|
|
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
|
-
import {
|
|
8
|
-
import
|
|
9
|
-
import {
|
|
10
|
-
import "../../../shared/
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import { createEmptyReceivableFormValues as o, hasReceivableFormErrors as ge, receivableFormValuesToCreatePayload as _e, receivableFormValuesToLineItemChanges as ve, receivableFormValuesToUpdatePayload as ye, receivableToFormValues as be, validateReceivableForm as xe } from "./index9.js";
|
|
14
|
-
import { useCreateReceivableMutation as Se, useUpdateReceivableMutation as Ce } from "../../data-access/dist/index6.js";
|
|
7
|
+
import { usePaymentTermsQuery as n } from "../../../shared/data-access/dist/lib/reference-data/usePaymentTermsQuery.js";
|
|
8
|
+
import "../../../shared/ui/dist/index.js";
|
|
9
|
+
import { useWidgetConfig as r } from "../../../shared/feature/dist/lib/WidgetProvider/hooks.js";
|
|
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 "./index11.js";
|
|
12
|
+
import { useCreateOverdueReminderMutation as f, useCreatePaymentReminderMutation as p, useOverdueRemindersQuery as m, usePaymentRemindersQuery as h } from "../../data-access/dist/index10.js";
|
|
15
13
|
import "../../data-access/dist/index.js";
|
|
16
|
-
import {
|
|
17
|
-
import { useReceivablePaymentTerms as Te } from "./index14.js";
|
|
18
|
-
import { useReceivableBankAccount as Ee } from "./index16.js";
|
|
19
|
-
import { calculateInvoiceTotals as De } from "./index17.js";
|
|
20
|
-
import { getCurrencyOptions as Oe } from "../../../shared/product-catalog/feature/dist/lib/helpers.js";
|
|
21
|
-
import { useMeasureUnitsQuery as ke } from "../../../shared/product-catalog/data-access/dist/index9.js";
|
|
22
|
-
import { useMeasureUnits as Ae } from "../../../shared/product-catalog/feature/dist/lib/useMeasureUnits.js";
|
|
23
|
-
import "../../../shared/product-catalog/feature/dist/index.js";
|
|
24
|
-
import { useCallback as s, useEffect as c, useMemo as l, useRef as u, useState as d } from "react";
|
|
14
|
+
import { useCallback as g, useMemo as _, useState as v } from "react";
|
|
25
15
|
//#region ../../libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index18.js
|
|
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
|
-
}), Be = s((e) => E((t) => ({
|
|
60
|
-
...t,
|
|
61
|
-
...e({
|
|
62
|
-
paymentTermsId: t.paymentTermsId,
|
|
63
|
-
paymentTermsCustomDate: t.paymentTermsCustomDate
|
|
64
|
-
})
|
|
65
|
-
})), []), G = Te({
|
|
66
|
-
paymentTermsId: T.paymentTermsId,
|
|
67
|
-
paymentTermsCustomDate: T.paymentTermsCustomDate,
|
|
68
|
-
messages: f,
|
|
69
|
-
onChange: Be
|
|
70
|
-
}), K = G.reset, Ve = s((e) => E((t) => ({
|
|
71
|
-
...t,
|
|
72
|
-
...e
|
|
73
|
-
})), []), q = Ee({
|
|
74
|
-
open: y,
|
|
75
|
-
bankAccountId: T.bankAccountId,
|
|
76
|
-
embeddedBankName: je,
|
|
77
|
-
messages: f,
|
|
78
|
-
onSelect: Ve
|
|
79
|
-
}), J = q.reset, Y = s(() => {
|
|
80
|
-
_.current = [], N(void 0), S("create"), w(void 0), E(o()), D({}), F(!1), V();
|
|
81
|
-
}, [V]), He = s((e = "invoice") => {
|
|
82
|
-
K(), J(), _.current = [], N(void 0), S("create"), w(void 0), E({
|
|
83
|
-
...o(),
|
|
84
|
-
type: e
|
|
85
|
-
}), D({}), V(), F(!1), b(!0);
|
|
86
|
-
}, [
|
|
87
|
-
V,
|
|
88
|
-
K,
|
|
89
|
-
J
|
|
90
|
-
]), Ue = s((e) => {
|
|
91
|
-
e.type !== "credit_note" && (K(), J(), _.current = e.line_items, v.current = e.currency, N(void 0), S("edit"), w(e.id), E(be(e, j)), D({}), F(!1), V(), b(!0));
|
|
92
|
-
}, [
|
|
93
|
-
V,
|
|
94
|
-
K,
|
|
95
|
-
J,
|
|
96
|
-
j
|
|
97
|
-
]);
|
|
98
|
-
c(() => {
|
|
99
|
-
j?.length && E((e) => {
|
|
100
|
-
let t = se(e.lineItems, j);
|
|
101
|
-
return t === e.lineItems ? e : {
|
|
102
|
-
...e,
|
|
103
|
-
lineItems: t
|
|
104
|
-
};
|
|
105
|
-
});
|
|
106
|
-
}, [j]);
|
|
107
|
-
let X = B.isUploading, We = s(() => {
|
|
108
|
-
X || (H(), b(!1), D({}));
|
|
109
|
-
}, [H, X]), Ge = s((e) => {
|
|
110
|
-
let t = e.taxRate === void 0 ? e : {
|
|
111
|
-
...e,
|
|
112
|
-
taxRate: le(e.taxRate)
|
|
113
|
-
}, { currency: n, type: r } = t;
|
|
114
|
-
if (r !== void 0 && r !== "invoice" && H(), n === void 0) {
|
|
115
|
-
E((e) => ({
|
|
116
|
-
...e,
|
|
117
|
-
...t
|
|
118
|
-
}));
|
|
119
|
-
return;
|
|
16
|
+
var y = [""];
|
|
17
|
+
function b({ open: b, isInvoice: x, disabled: S, paymentTermsId: C, paymentTermsCustomDate: w, paymentReminderId: T, overdueReminderId: E, messages: D, onSelect: O }) {
|
|
18
|
+
let { initResponse: k } = r(), A = n().data?.data, j = _(() => c(k?.scopes), [k?.scopes]), [M, N] = v(!1), [P, F] = v(""), [I, L] = v(y), R = b && x && M, z = h({ enabled: R }), B = m({ enabled: R }), V = p(), H = f(), U = g((e) => {
|
|
19
|
+
N(e), F(""), L(y);
|
|
20
|
+
}, []), W = g((e) => {
|
|
21
|
+
e || (O({
|
|
22
|
+
paymentReminderId: "",
|
|
23
|
+
overdueReminderId: ""
|
|
24
|
+
}), F(""), L(y)), N(e);
|
|
25
|
+
}, [O]), G = g((e) => O({ paymentReminderId: e }), [O]), K = g((e) => O({ overdueReminderId: e }), [O]), q = g((e) => F(d(e)), []), J = g((e, t) => {
|
|
26
|
+
let n = d(t);
|
|
27
|
+
L((t) => t.map((t, r) => r === e ? n : t));
|
|
28
|
+
}, []), Y = g(() => {
|
|
29
|
+
L((e) => e.length < 3 ? [...e, ""] : e);
|
|
30
|
+
}, []), X = g(() => L(y), []), Z = g(() => l({
|
|
31
|
+
paymentTermsId: C,
|
|
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);
|
|
120
49
|
}
|
|
121
|
-
I.current = !0, E((e) => e.currency === n ? {
|
|
122
|
-
...e,
|
|
123
|
-
...t
|
|
124
|
-
} : {
|
|
125
|
-
...e,
|
|
126
|
-
...t,
|
|
127
|
-
lineItems: e.lineItems.map((t) => ({
|
|
128
|
-
...t,
|
|
129
|
-
price: ne(t.price, e.currency, n)
|
|
130
|
-
}))
|
|
131
|
-
});
|
|
132
|
-
}, [H]), Ke = s(() => {
|
|
133
|
-
E((e) => {
|
|
134
|
-
let t = a(e.taxRate);
|
|
135
|
-
return t === e.taxRate ? e : {
|
|
136
|
-
...e,
|
|
137
|
-
taxRate: t
|
|
138
|
-
};
|
|
139
|
-
});
|
|
140
|
-
}, []), Z = s((e, t) => {
|
|
141
|
-
let n = me(e, {
|
|
142
|
-
currency: t,
|
|
143
|
-
messages: f
|
|
144
|
-
});
|
|
145
|
-
D((e) => ({
|
|
146
|
-
...e,
|
|
147
|
-
lineItems: n,
|
|
148
|
-
lineItemsSummary: fe(n)
|
|
149
|
-
}));
|
|
150
|
-
}, [f]), Q = s((e, { validate: t }) => {
|
|
151
|
-
t && (I.current = !0), E((t) => ({
|
|
152
|
-
...t,
|
|
153
|
-
lineItems: e(t.lineItems)
|
|
154
|
-
}));
|
|
155
|
-
}, []);
|
|
156
|
-
c(() => {
|
|
157
|
-
I.current && (I.current = !1, Z(T.lineItems, T.currency));
|
|
158
50
|
}, [
|
|
51
|
+
P,
|
|
52
|
+
V,
|
|
159
53
|
Z,
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
])
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
} : t), { validate: P });
|
|
169
|
-
}, [Q, P]), Je = s((e, t) => {
|
|
170
|
-
Q((n) => n.map((n) => n.id === e ? {
|
|
171
|
-
...n,
|
|
172
|
-
...oe({
|
|
173
|
-
product: t,
|
|
174
|
-
currency: T.currency,
|
|
175
|
-
unitNamesById: M
|
|
176
|
-
})
|
|
177
|
-
} : n), { validate: !0 });
|
|
178
|
-
}, [
|
|
179
|
-
Q,
|
|
180
|
-
M,
|
|
181
|
-
T.currency
|
|
182
|
-
]), $ = s((e, t) => {
|
|
183
|
-
t && Q((n) => t.kind === "remove" ? n.filter((t) => t.id !== e) : n.map((n) => n.id === e ? {
|
|
184
|
-
...n,
|
|
185
|
-
...t.patch
|
|
186
|
-
} : n), { validate: !0 });
|
|
187
|
-
}, [Q]), Ye = s((e, t) => {
|
|
188
|
-
let n = T.lineItems.find((t) => t.id === e);
|
|
189
|
-
n && $(e, te({
|
|
190
|
-
lineItem: n,
|
|
191
|
-
field: t,
|
|
192
|
-
rowCount: T.lineItems.length,
|
|
193
|
-
currency: T.currency
|
|
194
|
-
}));
|
|
195
|
-
}, [
|
|
196
|
-
$,
|
|
197
|
-
T.currency,
|
|
198
|
-
T.lineItems
|
|
199
|
-
]), Xe = s((e, t) => {
|
|
200
|
-
let n = T.lineItems.find((t) => t.id === e);
|
|
201
|
-
n && $(e, ue({
|
|
202
|
-
lineItem: n,
|
|
203
|
-
step: t,
|
|
204
|
-
rowCount: T.lineItems.length
|
|
205
|
-
}));
|
|
206
|
-
}, [$, T.lineItems]), Ze = s(() => {
|
|
207
|
-
let e = re(T.currency);
|
|
208
|
-
N(e.id), E((t) => ({
|
|
209
|
-
...t,
|
|
210
|
-
lineItems: [...t.lineItems, e]
|
|
211
|
-
}));
|
|
212
|
-
}, [T.currency]), Qe = s((e) => {
|
|
213
|
-
Q((t) => t.length <= 1 ? t : t.filter((t) => t.id !== e), { validate: !0 });
|
|
214
|
-
}, [Q]), $e = s(async () => {
|
|
215
|
-
if (X) return;
|
|
216
|
-
if (A.isLoading) {
|
|
217
|
-
D({ form: f.lineItemsLoading });
|
|
218
|
-
return;
|
|
219
|
-
}
|
|
220
|
-
let e = de(T.lineItems), n = e.length === T.lineItems.length ? T : {
|
|
221
|
-
...T,
|
|
222
|
-
lineItems: e
|
|
223
|
-
};
|
|
224
|
-
n !== T && E(n);
|
|
225
|
-
let r = xe({
|
|
226
|
-
values: n,
|
|
227
|
-
billingAddressId: z,
|
|
228
|
-
messages: f
|
|
229
|
-
});
|
|
230
|
-
if (ge(r)) {
|
|
231
|
-
D(r), F(!0);
|
|
232
|
-
return;
|
|
233
|
-
}
|
|
234
|
-
D({});
|
|
235
|
-
try {
|
|
236
|
-
if (x === "edit" && C) {
|
|
237
|
-
let e = { receivable_id: C };
|
|
238
|
-
await g.mutateAsync({
|
|
239
|
-
path: e,
|
|
240
|
-
body: ye({
|
|
241
|
-
values: n,
|
|
242
|
-
billingAddressId: z ?? "",
|
|
243
|
-
lineItemChanges: ve({
|
|
244
|
-
values: n,
|
|
245
|
-
originalLineItems: _.current,
|
|
246
|
-
originalCurrency: v.current,
|
|
247
|
-
unitNamesById: M,
|
|
248
|
-
units: j
|
|
249
|
-
})
|
|
250
|
-
})
|
|
251
|
-
}), U(), b(!1), Y();
|
|
252
|
-
return;
|
|
253
|
-
}
|
|
254
|
-
let e = await h.mutateAsync({ body: _e({
|
|
255
|
-
values: n,
|
|
256
|
-
billingAddressId: z ?? "",
|
|
257
|
-
unitNamesById: M
|
|
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
|
|
258
62
|
}) });
|
|
259
|
-
|
|
260
|
-
} catch (
|
|
261
|
-
|
|
63
|
+
L(y), O({ overdueReminderId: t.id }), e.success(D.reminderAdded);
|
|
64
|
+
} catch (n) {
|
|
65
|
+
e.error(t(n) ?? D.genericError);
|
|
262
66
|
}
|
|
263
67
|
}, [
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
f,
|
|
270
|
-
x,
|
|
271
|
-
m,
|
|
272
|
-
Y,
|
|
273
|
-
j,
|
|
274
|
-
M,
|
|
275
|
-
A.isLoading,
|
|
276
|
-
g,
|
|
277
|
-
T
|
|
278
|
-
]), et = l(() => ({
|
|
279
|
-
...T,
|
|
280
|
-
lineItems: T.lineItems.map(pe)
|
|
281
|
-
}), [T]), tt = l(() => ee(T.lineItems), [T.lineItems]), nt = l(() => De({
|
|
282
|
-
lineItems: T.lineItems.filter((e) => !ae(e)),
|
|
283
|
-
currency: T.currency,
|
|
284
|
-
taxRate: Number(T.taxRate) || void 0
|
|
285
|
-
}), [
|
|
286
|
-
T.currency,
|
|
287
|
-
T.lineItems,
|
|
288
|
-
T.taxRate
|
|
68
|
+
H,
|
|
69
|
+
Z,
|
|
70
|
+
D,
|
|
71
|
+
O,
|
|
72
|
+
I
|
|
289
73
|
]);
|
|
290
74
|
return {
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
75
|
+
view: _(() => x ? s({
|
|
76
|
+
showReminders: M,
|
|
77
|
+
paymentTermsId: C,
|
|
78
|
+
paymentTermsCustomDate: w,
|
|
79
|
+
paymentReminderId: T,
|
|
80
|
+
overdueReminderId: E,
|
|
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,
|
|
97
|
+
x,
|
|
98
|
+
D,
|
|
99
|
+
E,
|
|
100
|
+
B.data?.data,
|
|
101
|
+
I,
|
|
102
|
+
T,
|
|
103
|
+
z.data?.data,
|
|
104
|
+
w,
|
|
105
|
+
C,
|
|
106
|
+
M
|
|
107
|
+
]),
|
|
108
|
+
reset: U,
|
|
109
|
+
toggle: W,
|
|
110
|
+
selectPaymentReminder: G,
|
|
111
|
+
selectOverdueReminder: K,
|
|
112
|
+
changeBeforeDueInput: q,
|
|
113
|
+
saveBeforeDue: Q,
|
|
114
|
+
changeOverdueTerm: J,
|
|
115
|
+
addOverdueTerm: Y,
|
|
116
|
+
clearOverdueTerms: X,
|
|
117
|
+
saveOverdue: $
|
|
333
118
|
};
|
|
334
119
|
}
|
|
335
120
|
//#endregion
|
|
336
|
-
export {
|
|
121
|
+
export { b as useReceivableReminders };
|