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