@tesouro/embedded-components-react 0.5.206 → 0.5.207
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/shared/counterpart-management/feature/dist/index.js +11 -11
- package/dist/libs/tesouro-embedded-components-react/shared/data-access/dist/index.js +38 -38
- 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/feature/dist/lib/analytics/build-info.js +1 -1
- package/package.json +1 -1
package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index19.js
CHANGED
|
@@ -1,75 +1,52 @@
|
|
|
1
|
-
|
|
2
|
-
"use client";
|
|
3
|
-
"use client";
|
|
4
|
-
"use client";
|
|
5
|
-
import { buildReceivableRows as e, statusFilterOptions as t, typeForTab as n } from "./index9.js";
|
|
6
|
-
import { useReceivablesQuery as r } from "../../data-access/dist/index9.js";
|
|
7
|
-
import "../../data-access/dist/index.js";
|
|
8
|
-
import { useCallback as i, useEffect as a, useMemo as o, useState as s } from "react";
|
|
1
|
+
import { parseQuantity as e, priceInputToMinorUnits as t } from "./index6.js";
|
|
9
2
|
//#region ../../libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index19.js
|
|
10
|
-
var
|
|
11
|
-
function
|
|
12
|
-
let
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
x(v), _(void 0);
|
|
18
|
-
}, 300);
|
|
19
|
-
return () => clearTimeout(e);
|
|
20
|
-
}, [v]);
|
|
21
|
-
let w = f[0]?.id, T = w ? u[w] : void 0, E = f[0] ? f[0].desc ? "desc" : "asc" : void 0, D = r({
|
|
22
|
-
type: n(l),
|
|
23
|
-
limit: m,
|
|
24
|
-
pagination_token: g,
|
|
25
|
-
search_text: b || void 0,
|
|
26
|
-
status: S === "all" ? void 0 : S,
|
|
27
|
-
...T ? {
|
|
28
|
-
sort: T,
|
|
29
|
-
order: E
|
|
30
|
-
} : {}
|
|
31
|
-
}), O = D.data?.data ?? c, k = o(() => new Map(O.map((e) => [e.id, e])), [O]), A = i((e) => k.get(e), [k]), j = o(() => e({
|
|
32
|
-
receivables: O,
|
|
33
|
-
messages: d
|
|
34
|
-
}), [d, O]), M = !!b || S !== "all", N = i((e) => {
|
|
35
|
-
let t = typeof e == "function" ? e(f) : e;
|
|
36
|
-
p(t), _(void 0);
|
|
37
|
-
}, [f]), P = i((e) => {
|
|
38
|
-
h(e), _(void 0);
|
|
39
|
-
}, []), F = i((e) => {
|
|
40
|
-
C(e), _(void 0);
|
|
41
|
-
}, []), I = i(() => _(D.data?.next_pagination_token ?? void 0), [D.data?.next_pagination_token]), L = i(() => _(D.data?.prev_pagination_token ?? void 0), [D.data?.prev_pagination_token]), R = i(() => {
|
|
42
|
-
D.refetch();
|
|
43
|
-
}, [D]);
|
|
3
|
+
var n = 1e4;
|
|
4
|
+
function r({ lineItems: n, currency: r, taxRate: i }) {
|
|
5
|
+
let a = i ? i / 100 : 0, o = 0, s = 0;
|
|
6
|
+
for (let i of n) {
|
|
7
|
+
let n = Math.round(t(i.price, r) * e(i.quantity));
|
|
8
|
+
i.taxable ? o += n : s += n;
|
|
9
|
+
}
|
|
44
10
|
return {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
11
|
+
taxableItemsSubtotal: o,
|
|
12
|
+
nonTaxableItemsSubtotal: s,
|
|
13
|
+
subtotal: o + s,
|
|
14
|
+
rate: a
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
function i({ discount: e, subtotal: t }) {
|
|
18
|
+
if (!e) return 0;
|
|
19
|
+
let r = e.value ?? (e.type === "amount" ? e.amount : Math.round(t * e.amount / n));
|
|
20
|
+
return Math.min(Math.max(r, 0), t);
|
|
21
|
+
}
|
|
22
|
+
function a({ taxableItemsSubtotal: e, nonTaxableItemsSubtotal: t, discountAmount: n }) {
|
|
23
|
+
let r = e + t, i = r > 0 ? Math.round(e / r * n) : 0;
|
|
24
|
+
return {
|
|
25
|
+
taxableSubtotal: e - i,
|
|
26
|
+
nonTaxableSubtotal: t - (n - i)
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
function o({ lineItems: e, currency: t, taxRate: n, discount: o }) {
|
|
30
|
+
let s = r({
|
|
31
|
+
lineItems: e,
|
|
32
|
+
currency: t,
|
|
33
|
+
taxRate: n
|
|
34
|
+
}), c = i({
|
|
35
|
+
discount: o,
|
|
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
|
|
64
49
|
};
|
|
65
50
|
}
|
|
66
|
-
var u = {
|
|
67
|
-
documentLabel: "document_id",
|
|
68
|
-
customerLabel: "counterpart_name",
|
|
69
|
-
status: "status",
|
|
70
|
-
issueDateLabel: "issue_date",
|
|
71
|
-
dueDateLabel: "due_date",
|
|
72
|
-
totalLabel: "total_amount"
|
|
73
|
-
};
|
|
74
51
|
//#endregion
|
|
75
|
-
export {
|
|
52
|
+
export { a as allocateDiscount, o as calculateInvoiceTotals, r as calculateItemsSubtotals, i as resolveDiscountAmount };
|
package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index20.js
CHANGED
|
@@ -2,114 +2,364 @@
|
|
|
2
2
|
"use client";
|
|
3
3
|
"use client";
|
|
4
4
|
"use client";
|
|
5
|
-
import {
|
|
6
|
-
import "../../../shared/
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import
|
|
11
|
-
import
|
|
12
|
-
import
|
|
5
|
+
import { getStateOptions as e } from "../../../shared/util/dist/lib/usStates.js";
|
|
6
|
+
import { extractApiErrorMessage as t } from "../../../shared/util/dist/lib/apiErrors.js";
|
|
7
|
+
import { COUNTERPART_MESSAGE_LABELS_EN as n } from "../../../shared/counterpart-management/feature/dist/lib/labels.js";
|
|
8
|
+
import { useCounterpartAddressesQuery as r } from "../../../shared/counterpart-management/data-access/dist/index7.js";
|
|
9
|
+
import { useCounterpartForm as i } from "../../../shared/counterpart-management/feature/dist/lib/useCounterpartForm.js";
|
|
10
|
+
import "../../../shared/counterpart-management/feature/dist/index.js";
|
|
11
|
+
import "../../ui/dist/index9.js";
|
|
12
|
+
import "../../ui/dist/index.js";
|
|
13
|
+
import { buildLineItemControls as ee, commitLineItemField as te, commitTaxRateInput as ne, convertPriceInput as re, createLineItem as ie, getCurrencySymbol as ae, isBlankLineItem as oe, lineItemFromProduct as se, reconcileMeasureUnits as ce, sanitizeLineItemPatch as le, sanitizeTaxRateInput as ue, stepLineItemQuantity as de, stripBlankLineItems as fe, summarizeLineItemErrors as pe, toSheetLineItem as me, validateLineItems as he } from "./index6.js";
|
|
14
|
+
import { buildReceivableAttachmentsView as ge } from "./index7.js";
|
|
15
|
+
import { createEmptyReceivableFormValues as a, hasReceivableFormErrors as _e, receivableFormValuesToCreatePayload as ve, receivableFormValuesToLineItemChanges as ye, receivableFormValuesToUpdatePayload as be, receivableToFormValues as xe, validateReceivableForm as Se } from "./index9.js";
|
|
16
|
+
import { shouldShowRemindersInitially as Ce } from "./index11.js";
|
|
17
|
+
import { useCreateReceivableMutation as we, useUpdateReceivableMutation as Te } from "../../data-access/dist/index6.js";
|
|
18
|
+
import "../../data-access/dist/index.js";
|
|
19
|
+
import { useReceivableAttachmentUploads as Ee } from "./index14.js";
|
|
20
|
+
import { useReceivablePaymentTerms as De } from "./index15.js";
|
|
21
|
+
import { useReceivableBankAccount as Oe } from "./index17.js";
|
|
22
|
+
import { useReceivableReminders as ke } from "./index18.js";
|
|
23
|
+
import { calculateInvoiceTotals as Ae } from "./index19.js";
|
|
24
|
+
import { getCurrencyOptions as je } from "../../../shared/product-catalog/feature/dist/lib/helpers.js";
|
|
25
|
+
import { useMeasureUnitsQuery as Me } from "../../../shared/product-catalog/data-access/dist/index9.js";
|
|
26
|
+
import { useMeasureUnits as Ne } from "../../../shared/product-catalog/feature/dist/lib/useMeasureUnits.js";
|
|
13
27
|
import "../../../shared/product-catalog/feature/dist/index.js";
|
|
14
|
-
import {
|
|
15
|
-
import { useReceivablesTable as d } from "./index19.js";
|
|
16
|
-
import { useCallback as f, useEffect as p, useMemo as m, useState as h } from "react";
|
|
28
|
+
import { useCallback as o, useEffect as s, useMemo as c, useRef as l, useState as u } from "react";
|
|
17
29
|
//#region ../../libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index20.js
|
|
18
|
-
function
|
|
19
|
-
let C = e()
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
}, [
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
}), [b]), T = m(() => n(y), [y]), [E, D] = h(() => r({
|
|
27
|
-
defaultTab: _,
|
|
28
|
-
enabledTabs: T
|
|
29
|
-
})), [O, k] = h(), [A, j] = h(!1);
|
|
30
|
-
p(() => {
|
|
31
|
-
T.includes(E) || D(r({
|
|
32
|
-
defaultTab: _,
|
|
33
|
-
enabledTabs: T
|
|
30
|
+
function d({ messages: d, counterpartMessageLabels: f, embeddedBankName: Pe, onCreated: p }) {
|
|
31
|
+
let m = we(), h = Te(), g = l([]), _ = l(""), [v, y] = u(!1), [b, x] = u("create"), [S, C] = u(), [w, T] = u(() => a()), [Fe, E] = u({}), [D, Ie] = u("none"), O = Ne(), k = Me(), A = k.data?.data, { unitNamesById: j } = O, [Le, M] = u(), [N, P] = u(!1), F = l(!1), Re = c(() => e(), []), ze = c(() => ({
|
|
32
|
+
...n,
|
|
33
|
+
...f
|
|
34
|
+
}), [f]), I = r(w.customerId), Be = I.data?.data?.[0], L = I.data?.data?.[0]?.id, Ve = o((e) => {
|
|
35
|
+
T((t) => ({
|
|
36
|
+
...t,
|
|
37
|
+
attachments: e(t.attachments)
|
|
34
38
|
}));
|
|
39
|
+
}, []), R = Ee({
|
|
40
|
+
attachments: w.attachments,
|
|
41
|
+
setAttachments: Ve,
|
|
42
|
+
receivableId: S
|
|
43
|
+
}), { reset: z, discardUploads: B, commitRemovals: V } = R, He = w.type === "invoice" ? ge({
|
|
44
|
+
attachments: w.attachments,
|
|
45
|
+
pendingUploads: R.pendingUploads,
|
|
46
|
+
isCountLimitReached: R.isCountLimitReached,
|
|
47
|
+
isRecurring: !1,
|
|
48
|
+
messages: d
|
|
49
|
+
}) : void 0, Ue = o((e) => {
|
|
50
|
+
T((t) => ({
|
|
51
|
+
...t,
|
|
52
|
+
customerId: e ?? ""
|
|
53
|
+
}));
|
|
54
|
+
}, []), H = i({
|
|
55
|
+
view: D,
|
|
56
|
+
setView: Ie,
|
|
57
|
+
selectedId: w.customerId || void 0,
|
|
58
|
+
setSelectedId: Ue,
|
|
59
|
+
messages: ze,
|
|
60
|
+
counterpartType: "customer",
|
|
61
|
+
counterpart: void 0,
|
|
62
|
+
primaryAddress: Be
|
|
63
|
+
}), We = o((e) => T((t) => {
|
|
64
|
+
let n = e({
|
|
65
|
+
paymentTermsId: t.paymentTermsId,
|
|
66
|
+
paymentTermsCustomDate: t.paymentTermsCustomDate
|
|
67
|
+
});
|
|
68
|
+
return {
|
|
69
|
+
...t,
|
|
70
|
+
...n,
|
|
71
|
+
...n.paymentTermsId === "receipt_due" ? { paymentReminderId: "" } : {}
|
|
72
|
+
};
|
|
73
|
+
}), []), U = De({
|
|
74
|
+
paymentTermsId: w.paymentTermsId,
|
|
75
|
+
paymentTermsCustomDate: w.paymentTermsCustomDate,
|
|
76
|
+
messages: d,
|
|
77
|
+
onChange: We
|
|
78
|
+
}), W = U.reset, Ge = o((e) => T((t) => ({
|
|
79
|
+
...t,
|
|
80
|
+
...e
|
|
81
|
+
})), []), G = Oe({
|
|
82
|
+
open: v,
|
|
83
|
+
bankAccountId: w.bankAccountId,
|
|
84
|
+
embeddedBankName: Pe,
|
|
85
|
+
messages: d,
|
|
86
|
+
onSelect: Ge
|
|
87
|
+
}), K = G.reset, Ke = o((e) => T((t) => ({
|
|
88
|
+
...t,
|
|
89
|
+
...e
|
|
90
|
+
})), []), q = m.isPending || h.isPending, qe = ke({
|
|
91
|
+
open: v,
|
|
92
|
+
isInvoice: w.type === "invoice",
|
|
93
|
+
disabled: q,
|
|
94
|
+
paymentTermsId: w.paymentTermsId,
|
|
95
|
+
paymentTermsCustomDate: w.paymentTermsCustomDate,
|
|
96
|
+
paymentReminderId: w.paymentReminderId,
|
|
97
|
+
overdueReminderId: w.overdueReminderId,
|
|
98
|
+
messages: d,
|
|
99
|
+
onSelect: Ke
|
|
100
|
+
}), J = qe.reset, Y = o(() => {
|
|
101
|
+
g.current = [], M(void 0), x("create"), C(void 0), T(a()), E({}), P(!1), z();
|
|
102
|
+
}, [z]), Je = o((e = "invoice") => {
|
|
103
|
+
W(), K();
|
|
104
|
+
let t = {
|
|
105
|
+
...a(),
|
|
106
|
+
type: e
|
|
107
|
+
};
|
|
108
|
+
J(Ce(t)), g.current = [], M(void 0), x("create"), C(void 0), T(t), E({}), z(), P(!1), y(!0);
|
|
109
|
+
}, [
|
|
110
|
+
z,
|
|
111
|
+
W,
|
|
112
|
+
K,
|
|
113
|
+
J
|
|
114
|
+
]), Ye = o((e) => {
|
|
115
|
+
if (e.type === "credit_note") return;
|
|
116
|
+
W(), K();
|
|
117
|
+
let t = xe(e, A);
|
|
118
|
+
J(Ce(t)), g.current = e.line_items, _.current = e.currency, M(void 0), x("edit"), C(e.id), T(t), E({}), P(!1), z(), y(!0);
|
|
35
119
|
}, [
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
120
|
+
z,
|
|
121
|
+
W,
|
|
122
|
+
K,
|
|
123
|
+
J,
|
|
124
|
+
A
|
|
39
125
|
]);
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
e === O && (k(void 0), j(!1));
|
|
126
|
+
s(() => {
|
|
127
|
+
A?.length && T((e) => {
|
|
128
|
+
let t = ce(e.lineItems, A);
|
|
129
|
+
return t === e.lineItems ? e : {
|
|
130
|
+
...e,
|
|
131
|
+
lineItems: t
|
|
132
|
+
};
|
|
133
|
+
});
|
|
134
|
+
}, [A]);
|
|
135
|
+
let X = R.isUploading, Xe = o(() => {
|
|
136
|
+
X || (B(), y(!1), E({}));
|
|
137
|
+
}, [B, X]), Ze = o((e) => {
|
|
138
|
+
let t = e.taxRate === void 0 ? e : {
|
|
139
|
+
...e,
|
|
140
|
+
taxRate: ue(e.taxRate)
|
|
141
|
+
}, { currency: n, type: r } = t;
|
|
142
|
+
if (r !== void 0 && r !== "invoice" && B(), n === void 0) {
|
|
143
|
+
T((e) => ({
|
|
144
|
+
...e,
|
|
145
|
+
...t
|
|
146
|
+
}));
|
|
147
|
+
return;
|
|
63
148
|
}
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
149
|
+
F.current = !0, T((e) => e.currency === n ? {
|
|
150
|
+
...e,
|
|
151
|
+
...t
|
|
152
|
+
} : {
|
|
153
|
+
...e,
|
|
154
|
+
...t,
|
|
155
|
+
lineItems: e.lineItems.map((t) => ({
|
|
156
|
+
...t,
|
|
157
|
+
price: re(t.price, e.currency, n)
|
|
158
|
+
}))
|
|
159
|
+
});
|
|
160
|
+
}, [B]), Qe = o(() => {
|
|
161
|
+
T((e) => {
|
|
162
|
+
let t = ne(e.taxRate);
|
|
163
|
+
return t === e.taxRate ? e : {
|
|
164
|
+
...e,
|
|
165
|
+
taxRate: t
|
|
166
|
+
};
|
|
167
|
+
});
|
|
168
|
+
}, []), Z = o((e, t) => {
|
|
169
|
+
let n = he(e, {
|
|
170
|
+
currency: t,
|
|
171
|
+
messages: d
|
|
172
|
+
});
|
|
173
|
+
E((e) => ({
|
|
174
|
+
...e,
|
|
175
|
+
lineItems: n,
|
|
176
|
+
lineItemsSummary: pe(n)
|
|
177
|
+
}));
|
|
178
|
+
}, [d]), Q = o((e, { validate: t }) => {
|
|
179
|
+
t && (F.current = !0), T((t) => ({
|
|
180
|
+
...t,
|
|
181
|
+
lineItems: e(t.lineItems)
|
|
182
|
+
}));
|
|
183
|
+
}, []);
|
|
184
|
+
s(() => {
|
|
185
|
+
F.current && (F.current = !1, Z(w.lineItems, w.currency));
|
|
186
|
+
}, [
|
|
187
|
+
Z,
|
|
188
|
+
w.currency,
|
|
189
|
+
w.lineItems
|
|
190
|
+
]);
|
|
191
|
+
let $e = o((e, t) => {
|
|
192
|
+
let { unit: n, ...r } = t, i = le(r);
|
|
193
|
+
i.name !== void 0 && (i.productId = ""), n !== void 0 && (i.measureUnitId = n, i.measureUnitName = ""), Q((t) => t.map((t) => t.id === e ? {
|
|
194
|
+
...t,
|
|
195
|
+
...i
|
|
196
|
+
} : t), { validate: N });
|
|
197
|
+
}, [Q, N]), et = o((e, t) => {
|
|
198
|
+
Q((n) => n.map((n) => n.id === e ? {
|
|
199
|
+
...n,
|
|
200
|
+
...se({
|
|
201
|
+
product: t,
|
|
202
|
+
currency: w.currency,
|
|
203
|
+
unitNamesById: j
|
|
204
|
+
})
|
|
205
|
+
} : n), { validate: !0 });
|
|
206
|
+
}, [
|
|
207
|
+
Q,
|
|
208
|
+
j,
|
|
209
|
+
w.currency
|
|
210
|
+
]), $ = o((e, t) => {
|
|
211
|
+
t && Q((n) => t.kind === "remove" ? n.filter((t) => t.id !== e) : n.map((n) => n.id === e ? {
|
|
212
|
+
...n,
|
|
213
|
+
...t.patch
|
|
214
|
+
} : n), { validate: !0 });
|
|
215
|
+
}, [Q]), tt = o((e, t) => {
|
|
216
|
+
let n = w.lineItems.find((t) => t.id === e);
|
|
217
|
+
n && $(e, te({
|
|
218
|
+
lineItem: n,
|
|
219
|
+
field: t,
|
|
220
|
+
rowCount: w.lineItems.length,
|
|
221
|
+
currency: w.currency
|
|
222
|
+
}));
|
|
223
|
+
}, [
|
|
224
|
+
$,
|
|
225
|
+
w.currency,
|
|
226
|
+
w.lineItems
|
|
227
|
+
]), nt = o((e, t) => {
|
|
228
|
+
let n = w.lineItems.find((t) => t.id === e);
|
|
229
|
+
n && $(e, de({
|
|
230
|
+
lineItem: n,
|
|
231
|
+
step: t,
|
|
232
|
+
rowCount: w.lineItems.length
|
|
233
|
+
}));
|
|
234
|
+
}, [$, w.lineItems]), rt = o(() => {
|
|
235
|
+
let e = ie(w.currency);
|
|
236
|
+
M(e.id), T((t) => ({
|
|
237
|
+
...t,
|
|
238
|
+
lineItems: [...t.lineItems, e]
|
|
239
|
+
}));
|
|
240
|
+
}, [w.currency]), it = o((e) => {
|
|
241
|
+
Q((t) => t.length <= 1 ? t : t.filter((t) => t.id !== e), { validate: !0 });
|
|
242
|
+
}, [Q]), at = o(async () => {
|
|
243
|
+
if (X) return;
|
|
244
|
+
if (k.isLoading) {
|
|
245
|
+
E({ form: d.lineItemsLoading });
|
|
246
|
+
return;
|
|
247
|
+
}
|
|
248
|
+
let e = fe(w.lineItems), n = e.length === w.lineItems.length ? w : {
|
|
249
|
+
...w,
|
|
250
|
+
lineItems: e
|
|
251
|
+
};
|
|
252
|
+
n !== w && T(n);
|
|
253
|
+
let r = Se({
|
|
254
|
+
values: n,
|
|
255
|
+
billingAddressId: L,
|
|
256
|
+
messages: d
|
|
257
|
+
});
|
|
258
|
+
if (_e(r)) {
|
|
259
|
+
E(r), P(!0);
|
|
260
|
+
return;
|
|
261
|
+
}
|
|
262
|
+
E({});
|
|
263
|
+
try {
|
|
264
|
+
if (b === "edit" && S) {
|
|
265
|
+
let e = { receivable_id: S };
|
|
266
|
+
await h.mutateAsync({
|
|
267
|
+
path: e,
|
|
268
|
+
body: be({
|
|
269
|
+
values: n,
|
|
270
|
+
billingAddressId: L ?? "",
|
|
271
|
+
lineItemChanges: ye({
|
|
272
|
+
values: n,
|
|
273
|
+
originalLineItems: g.current,
|
|
274
|
+
originalCurrency: _.current,
|
|
275
|
+
unitNamesById: j,
|
|
276
|
+
units: A
|
|
277
|
+
})
|
|
278
|
+
})
|
|
279
|
+
}), V(), y(!1), Y();
|
|
100
280
|
return;
|
|
101
281
|
}
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
282
|
+
let e = await m.mutateAsync({ body: ve({
|
|
283
|
+
values: n,
|
|
284
|
+
billingAddressId: L ?? "",
|
|
285
|
+
unitNamesById: j
|
|
286
|
+
}) });
|
|
287
|
+
y(!1), Y(), e?.id && p?.(e.id, e.type);
|
|
288
|
+
} catch (e) {
|
|
289
|
+
E({ form: t(e) ?? d.genericError });
|
|
290
|
+
}
|
|
291
|
+
}, [
|
|
292
|
+
L,
|
|
293
|
+
V,
|
|
294
|
+
m,
|
|
295
|
+
S,
|
|
296
|
+
X,
|
|
297
|
+
d,
|
|
298
|
+
b,
|
|
299
|
+
p,
|
|
300
|
+
Y,
|
|
301
|
+
A,
|
|
302
|
+
j,
|
|
303
|
+
k.isLoading,
|
|
304
|
+
h,
|
|
305
|
+
w
|
|
306
|
+
]), ot = c(() => ({
|
|
307
|
+
...w,
|
|
308
|
+
lineItems: w.lineItems.map(me)
|
|
309
|
+
}), [w]), st = c(() => ee(w.lineItems), [w.lineItems]), ct = c(() => Ae({
|
|
310
|
+
lineItems: w.lineItems.filter((e) => !oe(e)),
|
|
311
|
+
currency: w.currency,
|
|
312
|
+
taxRate: Number(w.taxRate) || void 0
|
|
313
|
+
}), [
|
|
314
|
+
w.currency,
|
|
315
|
+
w.lineItems,
|
|
316
|
+
w.taxRate
|
|
317
|
+
]);
|
|
318
|
+
return {
|
|
319
|
+
open: v,
|
|
320
|
+
setOpen: y,
|
|
321
|
+
mode: b,
|
|
322
|
+
values: w,
|
|
323
|
+
sheetValues: ot,
|
|
324
|
+
errors: Fe,
|
|
325
|
+
setValues: T,
|
|
326
|
+
updateValues: Ze,
|
|
327
|
+
commitTaxRate: Qe,
|
|
328
|
+
updateLineItem: $e,
|
|
329
|
+
selectProduct: et,
|
|
330
|
+
commitLineItem: tt,
|
|
331
|
+
stepLineItem: nt,
|
|
332
|
+
addLineItem: rt,
|
|
333
|
+
removeLineItem: it,
|
|
334
|
+
attachmentsView: He,
|
|
335
|
+
attachmentsUploading: R.isUploading,
|
|
336
|
+
saveDisabled: k.isLoading || R.isUploading,
|
|
337
|
+
selectAttachmentFiles: R.selectFiles,
|
|
338
|
+
setAttachmentIncludeInEmail: R.setIncludeInEmail,
|
|
339
|
+
removeAttachment: R.remove,
|
|
340
|
+
autoFocusLineItemId: Le,
|
|
341
|
+
lineItemUnitOptions: O.unitOptions,
|
|
342
|
+
lineItemsLoading: k.isLoading,
|
|
343
|
+
lineItemControls: st,
|
|
344
|
+
totals: ct,
|
|
345
|
+
currencySymbol: ae(w.currency),
|
|
346
|
+
isSubmitting: q,
|
|
347
|
+
currencyOptions: je(w.currency),
|
|
348
|
+
paymentTerms: U,
|
|
349
|
+
showBillingSection: w.type === "invoice" || b === "edit",
|
|
350
|
+
showDueDateField: w.type === "quote",
|
|
351
|
+
openCreate: Je,
|
|
352
|
+
openEdit: Ye,
|
|
353
|
+
close: Xe,
|
|
354
|
+
submit: at,
|
|
355
|
+
units: O,
|
|
356
|
+
counterpartView: D,
|
|
357
|
+
counterpartForm: H,
|
|
358
|
+
stateOptions: Re,
|
|
359
|
+
openCounterpartCreate: H.openCreate,
|
|
360
|
+
bankAccount: G,
|
|
361
|
+
reminders: qe
|
|
112
362
|
};
|
|
113
363
|
}
|
|
114
364
|
//#endregion
|
|
115
|
-
export {
|
|
365
|
+
export { d as useReceivableForm };
|