@tesouro/embedded-components-react 0.5.231 → 0.5.233
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 -0
- package/dist/index.css +4 -0
- package/dist/index.d.ts +105 -2
- package/dist/index.js +1 -1
- package/dist/lib/ReceivablesWidget.d.ts +105 -2
- package/dist/lib/ReceivablesWidget.js +1 -1
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index.js +11 -10
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index10.js +92 -55
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index11.js +67 -142
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index12.js +186 -17
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index13.js +27 -0
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index3.js +45 -74
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index4.js +68 -53
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index5.js +66 -32
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index6.js +28 -34
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index7.js +24 -166
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index8.js +177 -1
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index9.js +42 -95
- 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/index13.js +36 -33
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index14.js +38 -0
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index16.js +1 -1
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index17.js +206 -147
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index18.js +2 -2
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index19.js +39 -58
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index20.js +53 -227
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index21.js +216 -287
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index22.js +453 -43
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index23.js +103 -126
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index24.js +122 -146
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index25.js +145 -41
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index26.js +39 -115
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index27.js +113 -90
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index28.js +81 -98
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index29.js +111 -27
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index30.js +26 -633
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index31.js +639 -39
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index32.js +41 -40
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index33.js +35 -74
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index34.js +73 -130
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index35.js +133 -329
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index36.js +345 -0
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index.js +13 -12
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index10.js +15 -12
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index19.js +35 -24
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index21.js +8 -71
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index22.js +70 -17
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index23.js +31 -12
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index24.js +18 -30
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index25.js +12 -301
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index26.js +33 -1
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index27.js +14 -46
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index28.js +23 -67
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index29.js +76 -485
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index30.js +395 -95
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index31.js +2 -0
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index32.js +48 -2
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index33.js +72 -4
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index34.js +496 -1
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index35.js +97 -91
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index37.js +2 -236
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index38.js +3 -2
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index39.js +1 -249
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index40.js +89 -82
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index41.js +23 -54
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index42.js +223 -340
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index43.js +3 -0
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index44.js +249 -0
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index45.js +93 -0
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index46.js +59 -0
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index47.js +353 -0
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index9.js +18 -1
- package/dist/libs/tesouro-embedded-components-react/shared/data-access/dist/index.js +41 -41
- package/dist/libs/tesouro-embedded-components-react/shared/data-access/dist/lib/clientRegistry.js +6 -3
- package/dist/libs/tesouro-embedded-components-react/shared/data-access/dist/lib/rest/sdk.gen.js +75 -43
- 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/index36.js +0 -28
package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index30.js
CHANGED
|
@@ -2,643 +2,36 @@
|
|
|
2
2
|
"use client";
|
|
3
3
|
"use client";
|
|
4
4
|
"use client";
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import "../../../shared/
|
|
8
|
-
import {
|
|
9
|
-
import { getCounterpartEmail as r } from "../../../shared/counterpart-management/feature/dist/lib/helpers.js";
|
|
10
|
-
import { useCounterpartAddressesQuery as i } from "../../../shared/counterpart-management/data-access/dist/index7.js";
|
|
11
|
-
import { useCounterpartForm as a } from "../../../shared/counterpart-management/feature/dist/lib/useCounterpartForm.js";
|
|
5
|
+
import { useMyEntityQuery as e } from "../../../shared/data-access/dist/lib/useMyEntityQuery.js";
|
|
6
|
+
import { usePaymentTermsQuery as t } from "../../../shared/data-access/dist/lib/reference-data/usePaymentTermsQuery.js";
|
|
7
|
+
import "../../../shared/data-access/dist/index.js";
|
|
8
|
+
import { useCounterpartQuery as n } from "../../../shared/counterpart-management/data-access/dist/index3.js";
|
|
12
9
|
import "../../../shared/counterpart-management/feature/dist/index.js";
|
|
13
|
-
import "../../ui/dist/index15.js";
|
|
14
|
-
import "../../ui/dist/index.js";
|
|
15
|
-
import { buildLineItemControls as o, commitLineItemField as s, commitTaxRateInput as c, convertPriceInput as l, createLineItem as u, getCurrencySymbol as ee, lineItemFromProduct as te, reconcileLineItemIds as ne, reconcileMeasureUnits as re, sanitizeLineItemPatch as ie, sanitizeTaxRateInput as ae, stepLineItemQuantity as oe, stripBlankLineItems as se, summarizeLineItemErrors as ce, toSheetLineItem as le, validateLineItems as ue } from "./index6.js";
|
|
16
|
-
import { buildReceivableAttachmentsView as de } from "./index7.js";
|
|
17
|
-
import { getCurrencyOptions as fe } from "../../../shared/product-catalog/feature/dist/lib/helpers.js";
|
|
18
|
-
import { useMeasureUnitsQuery as pe } from "../../../shared/product-catalog/data-access/dist/index9.js";
|
|
19
|
-
import { useMeasureUnits as me } from "../../../shared/product-catalog/feature/dist/lib/useMeasureUnits.js";
|
|
20
|
-
import "../../../shared/product-catalog/feature/dist/index.js";
|
|
21
|
-
import { getInlineItems as he } from "./index8.js";
|
|
22
|
-
import { buildCreateRecurrencePayload as ge, buildUpdateRecurrencePayload as _e, clearRecurrenceRecipients as ve, countIssuedIterations as ye, isRecurring as d, recurrenceToFormFields as be, validateRecurrence as xe, willRecurrenceIssue as Se } from "./index9.js";
|
|
23
|
-
import { convertDiscountInput as Ce, decorateDiscountInput as we, discountInputToMinorUnits as Te, sanitizeDiscountInput as Ee } from "./index11.js";
|
|
24
|
-
import { buildFormTotalsView as De, calculateFormTotals as Oe, validateDiscount as ke, validateInvoiceTotals as Ae } from "./index12.js";
|
|
25
|
-
import { createEmptyReceivableFormValues as je, hasReceivableFormErrors as Me, receivableFormValuesToCreatePayload as Ne, receivableFormValuesToLineItemChanges as Pe, receivableFormValuesToUpdatePayload as Fe, receivableToFormValues as Ie, submittedLineItemRows as Le, validateReceivableForm as Re } from "./index13.js";
|
|
26
|
-
import { getIssueReminderBlocker as ze, shouldShowRemindersInitially as Be } from "./index15.js";
|
|
27
|
-
import { useCreateReceivableMutation as Ve, useIssueReceivableMutation as He, useUpdateReceivableMutation as Ue } from "../../data-access/dist/index7.js";
|
|
28
|
-
import { useCreateRecurrenceMutation as We, useRecurrenceQuery as Ge, useUpdateRecurrenceMutation as Ke } from "../../data-access/dist/index11.js";
|
|
29
10
|
import "../../data-access/dist/index.js";
|
|
30
|
-
import {
|
|
31
|
-
import {
|
|
32
|
-
import { useReceivableAttachmentUploads as Qe } from "./index24.js";
|
|
33
|
-
import { useReceivablePaymentTerms as $e } from "./index25.js";
|
|
34
|
-
import { useReceivableRecurrence as et } from "./index26.js";
|
|
35
|
-
import { useReceivableBankAccount as tt } from "./index27.js";
|
|
36
|
-
import { useReceivableReminders as nt } from "./index28.js";
|
|
37
|
-
import { useReceivablePreview as rt } from "./index29.js";
|
|
38
|
-
import { useCallback as f, useEffect as p, useMemo as m, useRef as h, useState as g } from "react";
|
|
11
|
+
import { buildReceivablePreviewView as r } from "./index21.js";
|
|
12
|
+
import { useMemo as i } from "react";
|
|
39
13
|
//#region ../../libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index30.js
|
|
40
|
-
function
|
|
41
|
-
let
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
}), Nt = z.isLoading || Mt, Pt = f((e) => {
|
|
52
|
-
D((t) => ({
|
|
53
|
-
...t,
|
|
54
|
-
attachments: e(t.attachments)
|
|
55
|
-
}));
|
|
56
|
-
}, []), B = Qe({
|
|
57
|
-
attachments: E.attachments,
|
|
58
|
-
setAttachments: Pt,
|
|
59
|
-
receivableId: gt
|
|
60
|
-
}), { reset: V, discardUploads: Ft, commitRemovals: It } = B, Lt = E.type === "invoice" ? de({
|
|
61
|
-
attachments: E.attachments,
|
|
62
|
-
pendingUploads: B.pendingUploads,
|
|
63
|
-
isCountLimitReached: B.isCountLimitReached,
|
|
64
|
-
isRecurring: d(E),
|
|
65
|
-
messages: _
|
|
66
|
-
}) : void 0, Rt = f((e) => {
|
|
67
|
-
D((t) => {
|
|
68
|
-
let n = e ?? "";
|
|
69
|
-
return n === t.customerId ? t : ve({
|
|
70
|
-
...t,
|
|
71
|
-
customerId: n
|
|
72
|
-
});
|
|
73
|
-
});
|
|
74
|
-
}, []), zt = a({
|
|
75
|
-
view: xt,
|
|
76
|
-
setView: St,
|
|
77
|
-
selectedId: E.customerId || void 0,
|
|
78
|
-
setSelectedId: Rt,
|
|
79
|
-
messages: At,
|
|
80
|
-
counterpartType: "customer",
|
|
81
|
-
counterpart: void 0,
|
|
82
|
-
primaryAddress: jt
|
|
83
|
-
}), Bt = f((e) => D((t) => {
|
|
84
|
-
let n = e({
|
|
85
|
-
paymentTermsId: t.paymentTermsId,
|
|
86
|
-
paymentTermsCustomDate: t.paymentTermsCustomDate
|
|
87
|
-
});
|
|
88
|
-
return {
|
|
89
|
-
...t,
|
|
90
|
-
...n,
|
|
91
|
-
...n.paymentTermsId === "receipt_due" ? { paymentReminderId: "" } : {}
|
|
92
|
-
};
|
|
93
|
-
}), []), Vt = $e({
|
|
94
|
-
paymentTermsId: E.paymentTermsId,
|
|
95
|
-
paymentTermsCustomDate: E.paymentTermsCustomDate,
|
|
96
|
-
issueDate: E.issueDate,
|
|
97
|
-
isRecurring: E.type === "invoice" && d(E),
|
|
98
|
-
messages: _,
|
|
99
|
-
onChange: Bt
|
|
100
|
-
}), Ht = Vt.reset, Ut = f((e) => D((t) => ({
|
|
101
|
-
...t,
|
|
102
|
-
...e
|
|
103
|
-
})), []), H = tt({
|
|
104
|
-
open: C,
|
|
105
|
-
bankAccountId: E.bankAccountId,
|
|
106
|
-
embeddedBankName: at,
|
|
107
|
-
messages: _,
|
|
108
|
-
onSelect: Ut
|
|
109
|
-
}), Wt = H.reset, Gt = Ge(vt), U = vt ? Gt.data : void 0, W = ye(U), Kt = W > 0, G = !!vt && Gt.isLoading, K = h(void 0);
|
|
110
|
-
p(() => {
|
|
111
|
-
U && K.current !== U.id && (K.current = U.id, D((e) => ({
|
|
112
|
-
...e,
|
|
113
|
-
...be(U)
|
|
114
|
-
})));
|
|
115
|
-
}, [U]);
|
|
116
|
-
let qt = f((e) => D(e), []), Jt = f((e) => O((t) => {
|
|
117
|
-
if (!e.some((e) => e in t)) return t;
|
|
118
|
-
let n = { ...t };
|
|
119
|
-
return e.forEach((e) => delete n[e]), n;
|
|
120
|
-
}), []), Yt = h([]), Xt = f((e) => {
|
|
121
|
-
if (!M) {
|
|
122
|
-
Jt(e);
|
|
123
|
-
return;
|
|
124
|
-
}
|
|
125
|
-
Yt.current.push(...e);
|
|
126
|
-
}, [Jt, M]);
|
|
127
|
-
p(() => {
|
|
128
|
-
let e = Yt.current;
|
|
129
|
-
if (!e.length) return;
|
|
130
|
-
Yt.current = [];
|
|
131
|
-
let t = xe({
|
|
132
|
-
fields: E,
|
|
133
|
-
issuedCount: W,
|
|
134
|
-
messages: _
|
|
135
|
-
});
|
|
136
|
-
O((n) => {
|
|
137
|
-
let r = { ...n };
|
|
138
|
-
return e.forEach((e) => {
|
|
139
|
-
t[e] ? r[e] = t[e] : delete r[e];
|
|
140
|
-
}), r;
|
|
141
|
-
});
|
|
142
|
-
}, [
|
|
143
|
-
W,
|
|
144
|
-
_,
|
|
145
|
-
E
|
|
146
|
-
]);
|
|
147
|
-
let Zt = et({
|
|
148
|
-
values: E,
|
|
149
|
-
errors: bt,
|
|
150
|
-
lockSchedule: Kt,
|
|
151
|
-
messages: _,
|
|
152
|
-
onChange: qt,
|
|
153
|
-
onClearErrors: Jt,
|
|
154
|
-
onRevalidateErrors: Xt
|
|
155
|
-
}), q = Zt.reset, Qt = f((e) => D((t) => ({
|
|
156
|
-
...t,
|
|
157
|
-
...e
|
|
158
|
-
})), []), $t = st.isPending || ct.isPending || lt.isPending || ut.isPending || dt.isPending, en = nt({
|
|
159
|
-
open: C,
|
|
160
|
-
isInvoice: E.type === "invoice",
|
|
161
|
-
disabled: $t,
|
|
162
|
-
paymentTermsId: E.paymentTermsId,
|
|
163
|
-
paymentTermsCustomDate: E.paymentTermsCustomDate,
|
|
164
|
-
paymentReminderId: E.paymentReminderId,
|
|
165
|
-
overdueReminderId: E.overdueReminderId,
|
|
166
|
-
messages: _,
|
|
167
|
-
onSelect: Qt
|
|
168
|
-
}), tn = en.reset, nn = f(() => {
|
|
169
|
-
S.current = [], Tt(void 0), ht("create"), _t(void 0), yt(void 0), K.current = void 0, x.current = void 0, v.current = "draft", y.current = !1, b.current = !1, D(je()), O({}), Et(!1), I(!1), F.current = {
|
|
170
|
-
lines: !1,
|
|
171
|
-
discount: !1
|
|
172
|
-
}, V(), q();
|
|
173
|
-
}, [V, q]), rn = f((e = "invoice") => {
|
|
174
|
-
Ht(), Wt(), q();
|
|
175
|
-
let t = {
|
|
176
|
-
...je(),
|
|
177
|
-
type: e
|
|
178
|
-
};
|
|
179
|
-
tn(Be(t)), S.current = [], x.current = void 0, v.current = "draft", y.current = !1, b.current = !1, K.current = void 0, Tt(void 0), ht("create"), _t(void 0), yt(void 0), D(t), O({}), V(), Et(!1), I(!1), F.current = {
|
|
180
|
-
lines: !1,
|
|
181
|
-
discount: !1
|
|
182
|
-
}, w(!0);
|
|
183
|
-
}, [
|
|
184
|
-
V,
|
|
185
|
-
Ht,
|
|
186
|
-
Wt,
|
|
187
|
-
q,
|
|
188
|
-
tn
|
|
189
|
-
]), an = f((e, { highlightForIssue: t = !1 } = {}) => {
|
|
190
|
-
if (e.type === "credit_note") return;
|
|
191
|
-
Ht(), Wt(), q();
|
|
192
|
-
let n = Ie(e, A);
|
|
193
|
-
tn(Be(n)), S.current = e.line_items, mt.current = e.currency, x.current = void 0, v.current = t ? "issue" : "draft", y.current = !1, b.current = t, K.current = void 0, Tt(void 0), ht("edit"), _t(e.id), yt(e.type === "invoice" ? e.recurrence_id ?? void 0 : void 0), D(n), O({}), Et(!1), I(!1), F.current = {
|
|
194
|
-
lines: !1,
|
|
195
|
-
discount: !1
|
|
196
|
-
}, V(), w(!0);
|
|
197
|
-
}, [
|
|
198
|
-
V,
|
|
199
|
-
Ht,
|
|
200
|
-
Wt,
|
|
201
|
-
q,
|
|
202
|
-
tn,
|
|
203
|
-
A
|
|
204
|
-
]);
|
|
205
|
-
p(() => {
|
|
206
|
-
A?.length && D((e) => {
|
|
207
|
-
let t = re(e.lineItems, A);
|
|
208
|
-
return t === e.lineItems ? e : {
|
|
209
|
-
...e,
|
|
210
|
-
lineItems: t
|
|
211
|
-
};
|
|
212
|
-
});
|
|
213
|
-
}, [A]);
|
|
214
|
-
let on = B.isUploading, sn = f(() => {
|
|
215
|
-
on || (Ft(), w(!1), O({}));
|
|
216
|
-
}, [Ft, on]), cn = f((e) => {
|
|
217
|
-
let t = { ...e };
|
|
218
|
-
t.taxRate !== void 0 && (t.taxRate = ae(t.taxRate), P.current = !0), t.type !== void 0 && t.type !== "invoice" && Ft(), t.type !== void 0 && (v.current = "draft"), t.discount !== void 0 && M && (N.current = !0), t.discountType !== void 0 && (N.current = !0), t.currency !== void 0 && (Dt.current = !0), D((e) => {
|
|
219
|
-
let n = {
|
|
220
|
-
...e,
|
|
221
|
-
...t
|
|
222
|
-
};
|
|
223
|
-
return t.discount !== void 0 && (n.discount = Ee(t.discount, n.discountType, n.currency)), n.currency !== e.currency && (n.lineItems = e.lineItems.map((t) => ({
|
|
224
|
-
...t,
|
|
225
|
-
price: l(t.price, e.currency, n.currency)
|
|
226
|
-
}))), (n.currency !== e.currency || n.discountType !== e.discountType) && (n.discount = Ce({
|
|
227
|
-
value: n.discount,
|
|
228
|
-
type: n.discountType,
|
|
229
|
-
currency: n.currency
|
|
230
|
-
})), n;
|
|
231
|
-
});
|
|
232
|
-
}, [Ft, M]), ln = f(() => I(!0), []), un = f(() => {
|
|
233
|
-
I(!1), N.current = !0, D((e) => ({
|
|
234
|
-
...e,
|
|
235
|
-
discount: Ce({
|
|
236
|
-
value: e.discount,
|
|
237
|
-
type: e.discountType,
|
|
238
|
-
currency: e.currency
|
|
239
|
-
})
|
|
240
|
-
}));
|
|
241
|
-
}, []), dn = f(() => {
|
|
242
|
-
P.current = !0, D((e) => {
|
|
243
|
-
let t = c(e.taxRate);
|
|
244
|
-
return t === e.taxRate ? e : {
|
|
245
|
-
...e,
|
|
246
|
-
taxRate: t
|
|
247
|
-
};
|
|
248
|
-
});
|
|
249
|
-
}, []), J = f((e, { validate: t }) => {
|
|
250
|
-
t && (Dt.current = !0), D((t) => ({
|
|
251
|
-
...t,
|
|
252
|
-
lineItems: e(t.lineItems)
|
|
253
|
-
}));
|
|
254
|
-
}, []);
|
|
255
|
-
p(() => {
|
|
256
|
-
let e = Dt.current, t = N.current;
|
|
257
|
-
if (!e && !t && !P.current) return;
|
|
258
|
-
Dt.current = !1, N.current = !1, P.current = !1, e && (F.current.lines = !0), t && (F.current.discount = !0);
|
|
259
|
-
let n = y.current || W > 0, r = e ? ue(E.lineItems, {
|
|
260
|
-
currency: E.currency,
|
|
261
|
-
messages: _,
|
|
262
|
-
requireComplete: n
|
|
263
|
-
}) : void 0;
|
|
264
|
-
O((t) => {
|
|
265
|
-
let i = { ...t };
|
|
266
|
-
return F.current.lines && (i.lineItems = e ? r : t.lineItems, i.lineItemsSummary = ce(i.lineItems, Ae(E, _), n && E.lineItems.length === 0 ? _.lineItemsRequired : void 0)), F.current.discount && (i.discount = ke(E, _)), i;
|
|
267
|
-
});
|
|
268
|
-
}, [
|
|
269
|
-
W,
|
|
270
|
-
_,
|
|
271
|
-
E
|
|
272
|
-
]);
|
|
273
|
-
let fn = f((e, t) => {
|
|
274
|
-
let { unit: n, ...r } = t, i = ie(r);
|
|
275
|
-
i.name !== void 0 && (i.productId = ""), n !== void 0 && (i.measureUnitId = n, i.measureUnitName = ""), i.taxable !== void 0 && (P.current = !0), J((t) => t.map((t) => t.id === e ? {
|
|
276
|
-
...t,
|
|
277
|
-
...i
|
|
278
|
-
} : t), { validate: M });
|
|
279
|
-
}, [J, M]), pn = f((e, t) => {
|
|
280
|
-
J((n) => n.map((n) => n.id === e ? {
|
|
281
|
-
...n,
|
|
282
|
-
...te({
|
|
283
|
-
product: t,
|
|
284
|
-
currency: E.currency,
|
|
285
|
-
unitNamesById: j
|
|
286
|
-
})
|
|
287
|
-
} : n), { validate: !0 });
|
|
288
|
-
}, [
|
|
289
|
-
J,
|
|
290
|
-
j,
|
|
291
|
-
E.currency
|
|
292
|
-
]), mn = f((e, t) => {
|
|
293
|
-
t && J((n) => t.kind === "remove" ? n.filter((t) => t.id !== e) : n.map((n) => n.id === e ? {
|
|
294
|
-
...n,
|
|
295
|
-
...t.patch
|
|
296
|
-
} : n), { validate: !0 });
|
|
297
|
-
}, [J]), hn = f((e, t) => {
|
|
298
|
-
let n = E.lineItems.find((t) => t.id === e);
|
|
299
|
-
n && mn(e, s({
|
|
300
|
-
lineItem: n,
|
|
301
|
-
field: t,
|
|
302
|
-
rowCount: E.lineItems.length,
|
|
303
|
-
currency: E.currency
|
|
304
|
-
}));
|
|
305
|
-
}, [
|
|
306
|
-
mn,
|
|
307
|
-
E.currency,
|
|
308
|
-
E.lineItems
|
|
309
|
-
]), gn = f((e, t) => {
|
|
310
|
-
let n = E.lineItems.find((t) => t.id === e);
|
|
311
|
-
n && mn(e, oe({
|
|
312
|
-
lineItem: n,
|
|
313
|
-
step: t,
|
|
314
|
-
rowCount: E.lineItems.length
|
|
315
|
-
}));
|
|
316
|
-
}, [mn, E.lineItems]), _n = f(() => {
|
|
317
|
-
let e = u(E.currency);
|
|
318
|
-
Tt(e.id), D((t) => ({
|
|
319
|
-
...t,
|
|
320
|
-
lineItems: [...t.lineItems, e]
|
|
321
|
-
}));
|
|
322
|
-
}, [E.currency]), vn = f((e) => {
|
|
323
|
-
J((t) => t.length <= 1 ? t : t.filter((t) => t.id !== e), { validate: !0 });
|
|
324
|
-
}, [J]), Y = f((e, t) => e.type === "invoice" && (t === "issue" || Se(e) && W === 0), [W]), yn = f((e, t) => ({
|
|
325
|
-
...Re({
|
|
326
|
-
values: e,
|
|
327
|
-
billingAddressId: R,
|
|
328
|
-
messages: _,
|
|
329
|
-
willIssue: t,
|
|
330
|
-
hasStartedRecurrence: W > 0
|
|
331
|
-
}),
|
|
332
|
-
...e.type === "invoice" && d(e) ? xe({
|
|
333
|
-
fields: e,
|
|
334
|
-
issuedCount: W,
|
|
335
|
-
messages: _
|
|
336
|
-
}) : {}
|
|
14
|
+
function a({ values: a, totals: o, billingAddress: s, unitNamesById: c, messages: l, enabled: u = !0 }) {
|
|
15
|
+
let d = e({ enabled: u }), f = n(u && a.customerId || void 0), p = t({ enabled: u }), m = d.data, h = f.data, g = p.data?.data;
|
|
16
|
+
return i(() => r({
|
|
17
|
+
values: a,
|
|
18
|
+
totals: o,
|
|
19
|
+
entity: m,
|
|
20
|
+
counterpart: h,
|
|
21
|
+
billingAddress: s,
|
|
22
|
+
paymentTerms: g,
|
|
23
|
+
unitNamesById: c,
|
|
24
|
+
messages: l
|
|
337
25
|
}), [
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
e.scrollTo({
|
|
347
|
-
top: Math.max(0, n - e.clientHeight / 2 + t.offsetHeight / 2),
|
|
348
|
-
behavior: "smooth"
|
|
349
|
-
});
|
|
350
|
-
});
|
|
351
|
-
}, []), X = f((e, t) => {
|
|
352
|
-
O(e), Et(!0), y.current = t, F.current = {
|
|
353
|
-
lines: !0,
|
|
354
|
-
discount: !0
|
|
355
|
-
}, bn();
|
|
356
|
-
}, [bn]), xn = !vt || E.frequency !== "once" || Gt.isError;
|
|
357
|
-
p(() => {
|
|
358
|
-
if (!C || !b.current || Mt || G || !xn) return;
|
|
359
|
-
b.current = !1;
|
|
360
|
-
let e = Y(E, "issue");
|
|
361
|
-
X(yn(E, e), e);
|
|
362
|
-
}, [
|
|
363
|
-
Mt,
|
|
364
|
-
C,
|
|
365
|
-
xn,
|
|
366
|
-
G,
|
|
367
|
-
X,
|
|
368
|
-
yn,
|
|
369
|
-
E,
|
|
370
|
-
Y
|
|
371
|
-
]);
|
|
372
|
-
let Sn = h({
|
|
373
|
-
values: E,
|
|
374
|
-
billingAddressId: R
|
|
375
|
-
});
|
|
376
|
-
p(() => {
|
|
377
|
-
let e = Sn.current;
|
|
378
|
-
if (Sn.current = {
|
|
379
|
-
values: E,
|
|
380
|
-
billingAddressId: R
|
|
381
|
-
}, !M) return;
|
|
382
|
-
let t = [
|
|
383
|
-
"customerId",
|
|
384
|
-
"paymentTermsId",
|
|
385
|
-
"bankAccountId",
|
|
386
|
-
"openingNote",
|
|
387
|
-
"closingNote",
|
|
388
|
-
"taxRate"
|
|
389
|
-
].filter((t) => e.values[t] !== E[t] || t === "customerId" && e.billingAddressId !== R || t === "paymentTermsId" && e.values.paymentTermsCustomDate !== E.paymentTermsCustomDate);
|
|
390
|
-
if (!t.length) return;
|
|
391
|
-
let n = Re({
|
|
392
|
-
values: E,
|
|
393
|
-
billingAddressId: R,
|
|
394
|
-
messages: _,
|
|
395
|
-
willIssue: y.current
|
|
396
|
-
});
|
|
397
|
-
O((e) => {
|
|
398
|
-
let r = { ...e };
|
|
399
|
-
return t.forEach((e) => {
|
|
400
|
-
n[e] ? r[e] = n[e] : delete r[e];
|
|
401
|
-
}), r;
|
|
402
|
-
});
|
|
403
|
-
}, [
|
|
404
|
-
R,
|
|
405
|
-
_,
|
|
406
|
-
M,
|
|
407
|
-
E
|
|
26
|
+
s,
|
|
27
|
+
h,
|
|
28
|
+
m,
|
|
29
|
+
l,
|
|
30
|
+
g,
|
|
31
|
+
o,
|
|
32
|
+
c,
|
|
33
|
+
a
|
|
408
34
|
]);
|
|
409
|
-
let Cn = f(async (t) => {
|
|
410
|
-
if (v.current = t, G) return;
|
|
411
|
-
if (on) {
|
|
412
|
-
e.error(_.attachmentsUploading);
|
|
413
|
-
return;
|
|
414
|
-
}
|
|
415
|
-
if (k.isLoading) {
|
|
416
|
-
e.error(_.lineItemsLoading);
|
|
417
|
-
return;
|
|
418
|
-
}
|
|
419
|
-
let n = se(E.lineItems), i = n.length === E.lineItems.length ? E : {
|
|
420
|
-
...E,
|
|
421
|
-
lineItems: n
|
|
422
|
-
};
|
|
423
|
-
i !== E && D(i);
|
|
424
|
-
let a = i.type === "invoice" && d(i), o = Y(i, t);
|
|
425
|
-
if (o && (Nt || H.isLoading)) {
|
|
426
|
-
e.error(_.issueChecksLoading);
|
|
427
|
-
return;
|
|
428
|
-
}
|
|
429
|
-
if (o && !H.canAddAccount && !i.bankAccountId && !H.hasAccounts) {
|
|
430
|
-
e.error(_.issueBankAccountUnavailable);
|
|
431
|
-
return;
|
|
432
|
-
}
|
|
433
|
-
let s = yn(i, o);
|
|
434
|
-
if (Me(s)) {
|
|
435
|
-
X(s, o);
|
|
436
|
-
return;
|
|
437
|
-
}
|
|
438
|
-
if (O({}), o && z.isTaxIdMissing) {
|
|
439
|
-
e.error(_.issueTaxIdRequired);
|
|
440
|
-
return;
|
|
441
|
-
}
|
|
442
|
-
if (o && (i.paymentReminderId || i.overdueReminderId)) {
|
|
443
|
-
let t = ze(z.counterpart, _);
|
|
444
|
-
if (t) {
|
|
445
|
-
e.error(t);
|
|
446
|
-
return;
|
|
447
|
-
}
|
|
448
|
-
}
|
|
449
|
-
let c = T === "edit" ? gt : x.current, l, u, ee = {};
|
|
450
|
-
try {
|
|
451
|
-
if (c) {
|
|
452
|
-
let e = Pe({
|
|
453
|
-
values: i,
|
|
454
|
-
originalLineItems: S.current,
|
|
455
|
-
originalCurrency: mt.current,
|
|
456
|
-
unitNamesById: j,
|
|
457
|
-
units: A
|
|
458
|
-
});
|
|
459
|
-
ee = Le({
|
|
460
|
-
values: i,
|
|
461
|
-
originalLineItems: S.current,
|
|
462
|
-
changes: e
|
|
463
|
-
});
|
|
464
|
-
let t = await ct.mutateAsync({
|
|
465
|
-
path: { receivable_id: c },
|
|
466
|
-
body: Fe({
|
|
467
|
-
values: i,
|
|
468
|
-
billingAddressId: R ?? "",
|
|
469
|
-
lineItemChanges: e
|
|
470
|
-
})
|
|
471
|
-
});
|
|
472
|
-
It(), l = c, u = t?.type ?? i.type, a && t && (S.current = t.line_items, mt.current = t.currency, i = {
|
|
473
|
-
...i,
|
|
474
|
-
lineItems: ne(i.lineItems, t.line_items)
|
|
475
|
-
}, D(i));
|
|
476
|
-
} else {
|
|
477
|
-
ee = Le({ values: i });
|
|
478
|
-
let e = await st.mutateAsync({ body: Ne({
|
|
479
|
-
values: i,
|
|
480
|
-
billingAddressId: R ?? "",
|
|
481
|
-
unitNamesById: j
|
|
482
|
-
}) });
|
|
483
|
-
if (!e?.id) {
|
|
484
|
-
w(!1), nn();
|
|
485
|
-
return;
|
|
486
|
-
}
|
|
487
|
-
l = e.id, u = e.type, a && (x.current = e.id, S.current = e.line_items, mt.current = e.currency, i = {
|
|
488
|
-
...i,
|
|
489
|
-
lineItems: ne(i.lineItems, e.line_items)
|
|
490
|
-
}, D(i));
|
|
491
|
-
}
|
|
492
|
-
} catch (t) {
|
|
493
|
-
let n = Je[i.type], r = Xe(t, {
|
|
494
|
-
irrelevantVariants: n,
|
|
495
|
-
messages: _
|
|
496
|
-
});
|
|
497
|
-
e.error((c ? _.updateFailed : _.createFailed).replace("{errorMessage}", r));
|
|
498
|
-
let { errors: a, listError: s } = Ye(Ze(t, n), ee), l = ce(a.lineItems, void 0, s);
|
|
499
|
-
X({
|
|
500
|
-
...a,
|
|
501
|
-
...l ? { lineItemsSummary: l } : {}
|
|
502
|
-
}, o);
|
|
503
|
-
return;
|
|
504
|
-
}
|
|
505
|
-
let te = a ? "recurrence" : "draft";
|
|
506
|
-
if (a) try {
|
|
507
|
-
U ? await ut.mutateAsync({
|
|
508
|
-
path: { recurrence_id: U.id },
|
|
509
|
-
body: _e(i, { lockSchedule: Kt })
|
|
510
|
-
}) : await lt.mutateAsync({ body: ge(i, l) });
|
|
511
|
-
} catch (t) {
|
|
512
|
-
e.error(Xe(t, { messages: _ }));
|
|
513
|
-
return;
|
|
514
|
-
}
|
|
515
|
-
else if (o) try {
|
|
516
|
-
await dt.mutateAsync({ path: { receivable_id: l } }), te = "issue";
|
|
517
|
-
} catch {
|
|
518
|
-
e.error(_.issueFailedAfterSave);
|
|
519
|
-
}
|
|
520
|
-
let re = T === "create";
|
|
521
|
-
w(!1), nn(), re && ot?.(l, u, {
|
|
522
|
-
mode: te,
|
|
523
|
-
counterpartId: i.customerId,
|
|
524
|
-
inlineItems: he(i.lineItems, i.currency),
|
|
525
|
-
hasCustomerEmail: !!(z.counterpart && r(z.counterpart).trim())
|
|
526
|
-
});
|
|
527
|
-
}, [
|
|
528
|
-
H.canAddAccount,
|
|
529
|
-
H.hasAccounts,
|
|
530
|
-
H.isLoading,
|
|
531
|
-
R,
|
|
532
|
-
It,
|
|
533
|
-
st,
|
|
534
|
-
lt,
|
|
535
|
-
gt,
|
|
536
|
-
U,
|
|
537
|
-
on,
|
|
538
|
-
Nt,
|
|
539
|
-
dt,
|
|
540
|
-
Kt,
|
|
541
|
-
_,
|
|
542
|
-
T,
|
|
543
|
-
ot,
|
|
544
|
-
z.counterpart,
|
|
545
|
-
z.isTaxIdMissing,
|
|
546
|
-
G,
|
|
547
|
-
nn,
|
|
548
|
-
X,
|
|
549
|
-
A,
|
|
550
|
-
j,
|
|
551
|
-
k.isLoading,
|
|
552
|
-
ct,
|
|
553
|
-
ut,
|
|
554
|
-
yn,
|
|
555
|
-
E,
|
|
556
|
-
Y
|
|
557
|
-
]), Z = f(async (e = v.current) => {
|
|
558
|
-
if (!ft.current) {
|
|
559
|
-
ft.current = !0;
|
|
560
|
-
try {
|
|
561
|
-
await Cn(e);
|
|
562
|
-
} finally {
|
|
563
|
-
ft.current = !1;
|
|
564
|
-
}
|
|
565
|
-
}
|
|
566
|
-
}, [Cn]), wn = m(() => ({
|
|
567
|
-
...E,
|
|
568
|
-
discount: Ot ? E.discount : we(Te(E.discount, E.discountType, E.currency), E.discountType, E.currency),
|
|
569
|
-
lineItems: E.lineItems.map(le)
|
|
570
|
-
}), [Ot, E]), Tn = m(() => o(E.lineItems), [E.lineItems]), En = m(() => Oe(E), [E]), Q = E.type === "invoice", Dn = Q && d(E), On = $t || k.isLoading || B.isUploading || G, kn = T === "edit" ? _.updateDraftButton : _.saveDraftButton, An = Dn ? U ? _.recurrenceUpdateButton : _.recurrenceActivateButton : Q ? _.issueButton : kn, $ = Q && !Dn ? "issue" : "draft", jn = f(() => Z("draft"), [Z]), Mn = f(() => Z($), [$, Z]), Nn = f(() => Z(), [Z]), Pn = f(() => {
|
|
571
|
-
v.current = "draft";
|
|
572
|
-
}, []), Fn = f(() => {
|
|
573
|
-
v.current = $;
|
|
574
|
-
}, [$]), In = m(() => De(En, E.currency), [En, E.currency]), Ln = rt({
|
|
575
|
-
values: E,
|
|
576
|
-
totals: En,
|
|
577
|
-
billingAddress: jt,
|
|
578
|
-
unitNamesById: j,
|
|
579
|
-
messages: _,
|
|
580
|
-
enabled: C
|
|
581
|
-
});
|
|
582
|
-
return {
|
|
583
|
-
open: C,
|
|
584
|
-
setOpen: w,
|
|
585
|
-
mode: T,
|
|
586
|
-
values: E,
|
|
587
|
-
sheetValues: wn,
|
|
588
|
-
errors: bt,
|
|
589
|
-
setValues: D,
|
|
590
|
-
updateValues: cn,
|
|
591
|
-
commitTaxRate: dn,
|
|
592
|
-
focusDiscount: ln,
|
|
593
|
-
commitDiscount: un,
|
|
594
|
-
updateLineItem: fn,
|
|
595
|
-
selectProduct: pn,
|
|
596
|
-
commitLineItem: hn,
|
|
597
|
-
stepLineItem: gn,
|
|
598
|
-
addLineItem: _n,
|
|
599
|
-
removeLineItem: vn,
|
|
600
|
-
attachmentsView: Lt,
|
|
601
|
-
attachmentsUploading: B.isUploading,
|
|
602
|
-
draftButtonLabel: Q && !Dn ? kn : void 0,
|
|
603
|
-
draftDisabled: On,
|
|
604
|
-
primaryButtonLabel: An,
|
|
605
|
-
primaryDisabled: On || H.isLoading && Y(E, $) || Q && (Nt || !Dn && z.isCounterpartLoading),
|
|
606
|
-
scrollContainerRef: pt,
|
|
607
|
-
selectAttachmentFiles: B.selectFiles,
|
|
608
|
-
setAttachmentIncludeInEmail: B.setIncludeInEmail,
|
|
609
|
-
removeAttachment: B.remove,
|
|
610
|
-
autoFocusLineItemId: wt,
|
|
611
|
-
lineItemUnitOptions: Ct.unitOptions,
|
|
612
|
-
lineItemsLoading: k.isLoading,
|
|
613
|
-
lineItemControls: Tn,
|
|
614
|
-
totals: En,
|
|
615
|
-
preview: Ln,
|
|
616
|
-
totalsView: In,
|
|
617
|
-
currencySymbol: ee(E.currency),
|
|
618
|
-
isSubmitting: $t,
|
|
619
|
-
currencyOptions: fe(E.currency),
|
|
620
|
-
paymentTerms: Vt,
|
|
621
|
-
showBillingSection: E.type === "invoice" || T === "edit",
|
|
622
|
-
recurrence: Zt,
|
|
623
|
-
showRecurrenceSection: E.type === "invoice",
|
|
624
|
-
recurrenceLoading: G,
|
|
625
|
-
showDueDateField: E.type === "quote",
|
|
626
|
-
openCreate: rn,
|
|
627
|
-
openEdit: an,
|
|
628
|
-
close: sn,
|
|
629
|
-
submit: Nn,
|
|
630
|
-
submitDraft: jn,
|
|
631
|
-
submitPrimary: Mn,
|
|
632
|
-
selectDraftMode: Pn,
|
|
633
|
-
selectPrimaryMode: Fn,
|
|
634
|
-
units: Ct,
|
|
635
|
-
counterpartView: xt,
|
|
636
|
-
counterpartForm: zt,
|
|
637
|
-
stateOptions: kt,
|
|
638
|
-
openCounterpartCreate: zt.openCreate,
|
|
639
|
-
bankAccount: H,
|
|
640
|
-
reminders: en
|
|
641
|
-
};
|
|
642
35
|
}
|
|
643
36
|
//#endregion
|
|
644
|
-
export {
|
|
37
|
+
export { a as useReceivablePreview };
|