@tesouro/embedded-components-react 0.7.66 → 0.7.67
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.css +3 -0
- package/dist/index.d.ts +10 -10
- package/dist/lib/ProductsWidget.d.ts +40 -10
- package/dist/lib/ReceivablesWidget.d.ts +9 -9
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/apiValidationErrors.js +34 -63
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/useReceivableForm.js +458 -457
- package/dist/libs/tesouro-embedded-components-react/products-widget/feature/dist/lib/ProductsWidget/ProductsWidget.js +0 -2
- 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/lib/helpers.js +33 -41
- package/dist/libs/tesouro-embedded-components-react/shared/product-catalog/feature/dist/lib/labels.js +3 -4
- package/dist/libs/tesouro-embedded-components-react/shared/product-catalog/feature/dist/lib/useProductForm.js +42 -44
- package/dist/libs/tesouro-embedded-components-react/shared/product-catalog/ui/dist/index2.js +14 -13
- package/dist/libs/tesouro-embedded-components-react/shared/product-catalog/ui/dist/index3.js +128 -147
- package/dist/libs/tesouro-embedded-components-react/shared/product-catalog/ui/dist/index4.js +109 -92
- package/dist/libs/tesouro-embedded-components-react/shared/util/dist/lib/apiValidationErrors.js +33 -0
- package/package.json +1 -1
|
@@ -5,43 +5,44 @@
|
|
|
5
5
|
import { toast as e } from "../../../../../../../packages/shared-ui-shadcn/dist/index.js";
|
|
6
6
|
import { getStateOptions as t } from "../../../../../shared/util/dist/lib/usStates.js";
|
|
7
7
|
import { extractApiErrorMessage as n } from "../../../../../shared/util/dist/lib/apiErrors.js";
|
|
8
|
+
import { parseApiValidationErrors as r } from "../../../../../shared/util/dist/lib/apiValidationErrors.js";
|
|
8
9
|
import "../../../../../shared/ui/dist/index.js";
|
|
9
|
-
import { COUNTERPART_MESSAGE_LABELS_EN as
|
|
10
|
-
import { getCounterpartEmail as
|
|
10
|
+
import { COUNTERPART_MESSAGE_LABELS_EN as i } from "../../../../../shared/counterpart-management/feature/dist/lib/labels.js";
|
|
11
|
+
import { getCounterpartEmail as ee } from "../../../../../shared/counterpart-management/feature/dist/lib/helpers.js";
|
|
11
12
|
import { useCounterpartQuery as a, useCreateCounterpartMutation as o } from "../../../../../shared/counterpart-management/data-access/dist/index3.js";
|
|
12
13
|
import { useCounterpartAddressesQuery as s } from "../../../../../shared/counterpart-management/data-access/dist/index5.js";
|
|
13
|
-
import { useCounterpartForm as
|
|
14
|
+
import { useCounterpartForm as te } from "../../../../../shared/counterpart-management/feature/dist/lib/useCounterpartForm.js";
|
|
14
15
|
import "../../../../../shared/counterpart-management/feature/dist/index.js";
|
|
15
16
|
import "../../../../ui/dist/index20.js";
|
|
16
17
|
import "../../../../ui/dist/index.js";
|
|
17
|
-
import { INLINE_CUSTOMER_TYPE as
|
|
18
|
-
import { useCreateReceivableMutation as
|
|
19
|
-
import { useCreateRecurrenceMutation as
|
|
18
|
+
import { INLINE_CUSTOMER_TYPE as ne, buildInlineCustomerPayload as re, seedCustomerFormValues as ie } from "./customer.js";
|
|
19
|
+
import { useCreateReceivableMutation as c, useIssueReceivableMutation as l, useUpdateReceivableMutation as ae } from "../../../../data-access/dist/index11.js";
|
|
20
|
+
import { useCreateRecurrenceMutation as oe, useRecurrenceQuery as se, useUpdateRecurrenceMutation as ce } from "../../../../data-access/dist/index16.js";
|
|
20
21
|
import "../../../../data-access/dist/index.js";
|
|
21
|
-
import { buildLineItemControls as
|
|
22
|
-
import { buildReceivableAttachmentsView as
|
|
23
|
-
import { useMeasureUnitsQuery as
|
|
24
|
-
import { useMeasureUnits as
|
|
22
|
+
import { buildLineItemControls as le, commitLineItemField as ue, commitTaxRateInput as de, convertPriceInput as fe, createLineItem as pe, getCurrencySymbol as me, lineItemFromProduct as he, reconcileLineItemIds as ge, reconcileMeasureUnits as _e, sanitizeLineItemPatch as ve, sanitizeTaxRateInput as ye, stepLineItemQuantity as be, stripBlankLineItems as xe, summarizeLineItemErrors as Se, toSheetLineItem as Ce, validateLineItems as we } from "./lineItems.js";
|
|
23
|
+
import { buildReceivableAttachmentsView as Te } from "./attachments.js";
|
|
24
|
+
import { useMeasureUnitsQuery as Ee } from "../../../../../shared/product-catalog/data-access/dist/index9.js";
|
|
25
|
+
import { useMeasureUnits as De } from "../../../../../shared/product-catalog/feature/dist/lib/useMeasureUnits.js";
|
|
25
26
|
import "../../../../../shared/product-catalog/feature/dist/index.js";
|
|
26
|
-
import { getInlineItems as
|
|
27
|
-
import { buildCreateRecurrencePayload as
|
|
28
|
-
import { convertDiscountInput as
|
|
29
|
-
import { buildFormTotalsView as
|
|
30
|
-
import { createEmptyReceivableFormValues as
|
|
31
|
-
import { getIssueReminderBlocker as
|
|
32
|
-
import { useReceivableIssuePreflight as
|
|
33
|
-
import { UNSUBMITTED_PAYLOAD_VARIANTS as
|
|
34
|
-
import { useReceivableAttachmentUploads as
|
|
35
|
-
import { useReceivablePaymentTerms as
|
|
36
|
-
import { useReceivableRecurrence as
|
|
37
|
-
import { useReceivableBankAccount as
|
|
38
|
-
import { useReceivableReminders as
|
|
39
|
-
import { useReceivablePreview as
|
|
40
|
-
import { hasUnsavedChanges as
|
|
41
|
-
import { useCallback as
|
|
27
|
+
import { getInlineItems as Oe } from "./actionsModal.js";
|
|
28
|
+
import { buildCreateRecurrencePayload as ke, buildUpdateRecurrencePayload as Ae, clearRecurrenceRecipients as u, countIssuedIterations as je, isRecurring as d, recurrenceToFormFields as Me, validateRecurrence as Ne, willRecurrenceIssue as Pe } from "./recurrence.js";
|
|
29
|
+
import { convertDiscountInput as Fe, decorateDiscountInput as Ie, discountInputToMinorUnits as Le, sanitizeDiscountInput as Re } from "./discount.js";
|
|
30
|
+
import { buildFormTotalsView as ze, calculateFormTotals as Be, validateDiscount as Ve, validateInvoiceTotals as He } from "./totals.js";
|
|
31
|
+
import { createEmptyReceivableFormValues as Ue, hasReceivableFormErrors as We, receivableFormValuesToCreatePayload as Ge, receivableFormValuesToLineItemChanges as Ke, receivableFormValuesToUpdatePayload as qe, receivableToFormValues as Je, resolveCounterpartAddresses as Ye, submittedLineItemRows as Xe, validateReceivableForm as Ze } from "./helpers.js";
|
|
32
|
+
import { getIssueReminderBlocker as Qe, shouldShowRemindersInitially as $e } from "./reminders.js";
|
|
33
|
+
import { useReceivableIssuePreflight as et } from "./useReceivableIssuePreflight.js";
|
|
34
|
+
import { UNSUBMITTED_PAYLOAD_VARIANTS as tt, apiValidationErrorsToFormErrors as nt, getApiErrorMessage as rt } from "./apiValidationErrors.js";
|
|
35
|
+
import { useReceivableAttachmentUploads as it } from "./useReceivableAttachmentUploads.js";
|
|
36
|
+
import { useReceivablePaymentTerms as at } from "./useReceivablePaymentTerms.js";
|
|
37
|
+
import { useReceivableRecurrence as ot } from "./useReceivableRecurrence.js";
|
|
38
|
+
import { useReceivableBankAccount as st } from "./useReceivableBankAccount.js";
|
|
39
|
+
import { useReceivableReminders as ct } from "./useReceivableReminders.js";
|
|
40
|
+
import { useReceivablePreview as lt } from "./useReceivablePreview.js";
|
|
41
|
+
import { hasUnsavedChanges as ut } from "./unsavedChanges.js";
|
|
42
|
+
import { useCallback as f, useEffect as p, useMemo as m, useRef as h, useState as g } from "react";
|
|
42
43
|
//#region ../../libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/useReceivableForm.js
|
|
43
|
-
function
|
|
44
|
-
return t === e.customerId ? e :
|
|
44
|
+
function dt(e, t) {
|
|
45
|
+
return t === e.customerId ? e : u({
|
|
45
46
|
...e,
|
|
46
47
|
customerId: t,
|
|
47
48
|
billingAddressId: "",
|
|
@@ -52,7 +53,7 @@ function ut(e, t) {
|
|
|
52
53
|
} : {}
|
|
53
54
|
});
|
|
54
55
|
}
|
|
55
|
-
function
|
|
56
|
+
function ft(e, t) {
|
|
56
57
|
return {
|
|
57
58
|
...e,
|
|
58
59
|
customerId: t,
|
|
@@ -60,60 +61,60 @@ function dt(e, t) {
|
|
|
60
61
|
customerEmail: ""
|
|
61
62
|
};
|
|
62
63
|
}
|
|
63
|
-
function
|
|
64
|
-
let
|
|
64
|
+
function pt({ messages: u, counterpartMessageLabels: pt, embeddedBankName: mt, canCreateCustomer: _ = !0, onCreated: ht, onUpdated: gt }) {
|
|
65
|
+
let _t = c(), vt = ae(), yt = oe(), bt = ce(), xt = l(), St = o(), v = h("draft"), Ct = h(!1), [wt, Tt] = g(), y = h(!1), b = h(!1), Et = h(null), x = h(void 0), S = h([]), Dt = h(""), [C, w] = g(!1), [T, Ot] = g("create"), [kt, At] = g(), [jt, Mt] = g(), [E, D] = g(() => Ue()), O = h(E), [Nt, k] = g(!1), [Pt, A] = g({}), [Ft, It] = g("none"), Lt = De(), j = Ee(), M = j.data?.data, { unitNamesById: N } = Lt, [Rt, zt] = g(), [P, Bt] = g(!1), Vt = h(!1), F = h(!1), I = h(!1), L = h({
|
|
65
66
|
lines: !1,
|
|
66
67
|
discount: !1
|
|
67
|
-
}), [
|
|
68
|
-
...
|
|
69
|
-
...
|
|
70
|
-
}), [
|
|
71
|
-
values:
|
|
72
|
-
counterpart:
|
|
73
|
-
addresses:
|
|
74
|
-
}),
|
|
75
|
-
counterpartId:
|
|
76
|
-
billingAddressId:
|
|
77
|
-
billingCountry:
|
|
78
|
-
inlineCustomerType:
|
|
79
|
-
isAddressesLoading:
|
|
80
|
-
}),
|
|
81
|
-
|
|
68
|
+
}), [Ht, R] = g(!1), [Ut, Wt] = g(!1), Gt = m(() => t(), []), Kt = m(() => ({
|
|
69
|
+
...i,
|
|
70
|
+
...pt
|
|
71
|
+
}), [pt]), qt = s(E.customerId), Jt = a(E.customerId || void 0), Yt = qt.data?.data?.[0], { billingAddressId: Xt, billingAddress: Zt, shippingAddressId: Qt } = Ye({
|
|
72
|
+
values: E,
|
|
73
|
+
counterpart: Jt.data,
|
|
74
|
+
addresses: qt.data?.data
|
|
75
|
+
}), z = !!E.customerId && (qt.isLoading || Jt.isLoading), B = et({
|
|
76
|
+
counterpartId: E.customerId,
|
|
77
|
+
billingAddressId: Xt,
|
|
78
|
+
billingCountry: Zt?.country,
|
|
79
|
+
inlineCustomerType: _ && !E.customerId && E.customerName.trim() ? ne : void 0,
|
|
80
|
+
isAddressesLoading: z
|
|
81
|
+
}), $t = B.isLoading || z, en = f((e) => {
|
|
82
|
+
D((t) => ({
|
|
82
83
|
...t,
|
|
83
84
|
attachments: e(t.attachments)
|
|
84
85
|
}));
|
|
85
|
-
}, []),
|
|
86
|
-
attachments:
|
|
87
|
-
setAttachments:
|
|
88
|
-
receivableId:
|
|
89
|
-
}), { reset:
|
|
90
|
-
attachments:
|
|
91
|
-
pendingUploads:
|
|
92
|
-
isCountLimitReached:
|
|
93
|
-
isRecurring:
|
|
94
|
-
messages:
|
|
95
|
-
}) : void 0,
|
|
96
|
-
e &&
|
|
97
|
-
}, []),
|
|
98
|
-
view:
|
|
99
|
-
setView:
|
|
100
|
-
selectedId:
|
|
101
|
-
setSelectedId:
|
|
102
|
-
messages:
|
|
86
|
+
}, []), V = it({
|
|
87
|
+
attachments: E.attachments,
|
|
88
|
+
setAttachments: en,
|
|
89
|
+
receivableId: kt
|
|
90
|
+
}), { reset: H, discardUploads: tn, commitRemovals: nn } = V, rn = E.type === "invoice" ? Te({
|
|
91
|
+
attachments: E.attachments,
|
|
92
|
+
pendingUploads: V.pendingUploads,
|
|
93
|
+
isCountLimitReached: V.isCountLimitReached,
|
|
94
|
+
isRecurring: d(E),
|
|
95
|
+
messages: u
|
|
96
|
+
}) : void 0, an = f((e) => {
|
|
97
|
+
e && D((t) => dt(t, e));
|
|
98
|
+
}, []), on = te({
|
|
99
|
+
view: Ft,
|
|
100
|
+
setView: It,
|
|
101
|
+
selectedId: E.customerId || void 0,
|
|
102
|
+
setSelectedId: an,
|
|
103
|
+
messages: Kt,
|
|
103
104
|
counterpartType: "customer",
|
|
104
105
|
counterpart: void 0,
|
|
105
|
-
primaryAddress:
|
|
106
|
-
}), { openCreate:
|
|
107
|
-
|
|
108
|
-
name:
|
|
109
|
-
email:
|
|
106
|
+
primaryAddress: Yt
|
|
107
|
+
}), { openCreate: sn, setValues: cn } = on, ln = f(() => {
|
|
108
|
+
sn(), cn((e) => ie(e, {
|
|
109
|
+
name: E.customerName,
|
|
110
|
+
email: E.customerEmail
|
|
110
111
|
}));
|
|
111
112
|
}, [
|
|
112
|
-
on,
|
|
113
113
|
sn,
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
114
|
+
cn,
|
|
115
|
+
E.customerName,
|
|
116
|
+
E.customerEmail
|
|
117
|
+
]), un = f((e) => D((t) => {
|
|
117
118
|
let n = e({
|
|
118
119
|
paymentTermsId: t.paymentTermsId,
|
|
119
120
|
paymentTermsCustomDate: t.paymentTermsCustomDate
|
|
@@ -123,314 +124,314 @@ function ft({ messages: d, counterpartMessageLabels: ft, embeddedBankName: pt, c
|
|
|
123
124
|
...n,
|
|
124
125
|
...n.paymentTermsId === "receipt_due" ? { paymentReminderId: "" } : {}
|
|
125
126
|
};
|
|
126
|
-
}), []),
|
|
127
|
-
paymentTermsId:
|
|
128
|
-
paymentTermsCustomDate:
|
|
129
|
-
issueDate:
|
|
130
|
-
isRecurring:
|
|
131
|
-
messages:
|
|
132
|
-
onChange:
|
|
133
|
-
}),
|
|
134
|
-
t && (
|
|
135
|
-
...
|
|
127
|
+
}), []), dn = at({
|
|
128
|
+
paymentTermsId: E.paymentTermsId,
|
|
129
|
+
paymentTermsCustomDate: E.paymentTermsCustomDate,
|
|
130
|
+
issueDate: E.issueDate,
|
|
131
|
+
isRecurring: E.type === "invoice" && d(E),
|
|
132
|
+
messages: u,
|
|
133
|
+
onChange: un
|
|
134
|
+
}), fn = dn.reset, pn = f((e, { automatic: t = !1 } = {}) => {
|
|
135
|
+
t && (O.current = {
|
|
136
|
+
...O.current,
|
|
136
137
|
...e
|
|
137
|
-
}),
|
|
138
|
+
}), D((t) => ({
|
|
138
139
|
...t,
|
|
139
140
|
...e
|
|
140
141
|
}));
|
|
141
|
-
}, []),
|
|
142
|
-
open:
|
|
143
|
-
bankAccountId:
|
|
144
|
-
bankAccountType:
|
|
145
|
-
embeddedBankName:
|
|
146
|
-
messages:
|
|
147
|
-
onSelect:
|
|
148
|
-
}),
|
|
149
|
-
|
|
150
|
-
if (!
|
|
151
|
-
|
|
152
|
-
let e =
|
|
153
|
-
|
|
154
|
-
...
|
|
142
|
+
}, []), U = st({
|
|
143
|
+
open: C,
|
|
144
|
+
bankAccountId: E.bankAccountId,
|
|
145
|
+
bankAccountType: E.bankAccountType,
|
|
146
|
+
embeddedBankName: mt,
|
|
147
|
+
messages: u,
|
|
148
|
+
onSelect: pn
|
|
149
|
+
}), mn = U.reset, hn = se(jt), W = jt ? hn.data : void 0, G = je(W), gn = G > 0, K = !!jt && hn.isLoading, q = h(void 0);
|
|
150
|
+
p(() => {
|
|
151
|
+
if (!W || q.current === W.id) return;
|
|
152
|
+
q.current = W.id;
|
|
153
|
+
let e = Me(W);
|
|
154
|
+
O.current = {
|
|
155
|
+
...O.current,
|
|
155
156
|
...e
|
|
156
|
-
},
|
|
157
|
+
}, D((t) => ({
|
|
157
158
|
...t,
|
|
158
159
|
...e
|
|
159
160
|
}));
|
|
160
|
-
}, [
|
|
161
|
-
let
|
|
161
|
+
}, [W]);
|
|
162
|
+
let _n = f((e) => D(e), []), vn = f((e) => A((t) => {
|
|
162
163
|
if (!e.some((e) => e in t)) return t;
|
|
163
164
|
let n = { ...t };
|
|
164
165
|
return e.forEach((e) => delete n[e]), n;
|
|
165
|
-
}), []),
|
|
166
|
-
if (!
|
|
167
|
-
|
|
166
|
+
}), []), yn = h([]), bn = f((e) => {
|
|
167
|
+
if (!P) {
|
|
168
|
+
vn(e);
|
|
168
169
|
return;
|
|
169
170
|
}
|
|
170
|
-
|
|
171
|
-
}, [
|
|
172
|
-
|
|
173
|
-
let e =
|
|
171
|
+
yn.current.push(...e);
|
|
172
|
+
}, [vn, P]);
|
|
173
|
+
p(() => {
|
|
174
|
+
let e = yn.current;
|
|
174
175
|
if (!e.length) return;
|
|
175
|
-
|
|
176
|
-
let t =
|
|
177
|
-
fields:
|
|
178
|
-
issuedCount:
|
|
179
|
-
messages:
|
|
176
|
+
yn.current = [];
|
|
177
|
+
let t = Ne({
|
|
178
|
+
fields: E,
|
|
179
|
+
issuedCount: G,
|
|
180
|
+
messages: u
|
|
180
181
|
});
|
|
181
|
-
|
|
182
|
+
A((n) => {
|
|
182
183
|
let r = { ...n };
|
|
183
184
|
return e.forEach((e) => {
|
|
184
185
|
t[e] ? r[e] = t[e] : delete r[e];
|
|
185
186
|
}), r;
|
|
186
187
|
});
|
|
187
188
|
}, [
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
189
|
+
G,
|
|
190
|
+
u,
|
|
191
|
+
E
|
|
191
192
|
]);
|
|
192
|
-
let
|
|
193
|
-
values:
|
|
194
|
-
errors:
|
|
195
|
-
lockSchedule:
|
|
196
|
-
messages:
|
|
197
|
-
onChange:
|
|
198
|
-
onClearErrors:
|
|
199
|
-
onRevalidateErrors:
|
|
200
|
-
}),
|
|
193
|
+
let xn = ot({
|
|
194
|
+
values: E,
|
|
195
|
+
errors: Pt,
|
|
196
|
+
lockSchedule: gn,
|
|
197
|
+
messages: u,
|
|
198
|
+
onChange: _n,
|
|
199
|
+
onClearErrors: vn,
|
|
200
|
+
onRevalidateErrors: bn
|
|
201
|
+
}), J = xn.reset, Sn = f((e) => D((t) => ({
|
|
201
202
|
...t,
|
|
202
203
|
...e
|
|
203
|
-
})), []),
|
|
204
|
-
open:
|
|
205
|
-
isInvoice:
|
|
206
|
-
disabled:
|
|
207
|
-
paymentTermsId:
|
|
208
|
-
paymentTermsCustomDate:
|
|
209
|
-
paymentReminderId:
|
|
210
|
-
overdueReminderId:
|
|
211
|
-
messages:
|
|
212
|
-
onSelect:
|
|
213
|
-
}),
|
|
214
|
-
|
|
204
|
+
})), []), Y = St.isPending || _t.isPending || vt.isPending || yt.isPending || bt.isPending || xt.isPending, Cn = ct({
|
|
205
|
+
open: C,
|
|
206
|
+
isInvoice: E.type === "invoice",
|
|
207
|
+
disabled: Y,
|
|
208
|
+
paymentTermsId: E.paymentTermsId,
|
|
209
|
+
paymentTermsCustomDate: E.paymentTermsCustomDate,
|
|
210
|
+
paymentReminderId: E.paymentReminderId,
|
|
211
|
+
overdueReminderId: E.overdueReminderId,
|
|
212
|
+
messages: u,
|
|
213
|
+
onSelect: Sn
|
|
214
|
+
}), wn = Cn.reset, Tn = f(() => {
|
|
215
|
+
S.current = [], zt(void 0), Ot("create"), At(void 0), Mt(void 0), q.current = void 0, x.current = void 0, v.current = "draft", y.current = !1, b.current = !1, D(Ue()), k(!1), A({}), Bt(!1), R(!1), L.current = {
|
|
215
216
|
lines: !1,
|
|
216
217
|
discount: !1
|
|
217
|
-
},
|
|
218
|
-
}, [
|
|
219
|
-
|
|
218
|
+
}, H(), J();
|
|
219
|
+
}, [H, J]), En = f((e = "invoice", { customerId: t = "" } = {}) => {
|
|
220
|
+
fn(), mn(), J();
|
|
220
221
|
let n = {
|
|
221
|
-
...
|
|
222
|
+
...Ue(),
|
|
222
223
|
type: e,
|
|
223
224
|
customerId: t
|
|
224
225
|
};
|
|
225
|
-
|
|
226
|
+
wn($e(n)), S.current = [], x.current = void 0, v.current = "draft", y.current = !1, b.current = !1, q.current = void 0, zt(void 0), Ot("create"), At(void 0), Mt(void 0), O.current = n, D(n), k(!1), A({}), H(), Bt(!1), R(!1), L.current = {
|
|
226
227
|
lines: !1,
|
|
227
228
|
discount: !1
|
|
228
|
-
},
|
|
229
|
+
}, w(!0);
|
|
229
230
|
}, [
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
]),
|
|
231
|
+
H,
|
|
232
|
+
fn,
|
|
233
|
+
mn,
|
|
234
|
+
J,
|
|
235
|
+
wn
|
|
236
|
+
]), Dn = f((e, { highlightForIssue: t = !1 } = {}) => {
|
|
236
237
|
if (e.type === "credit_note") return;
|
|
237
|
-
|
|
238
|
-
let n =
|
|
239
|
-
|
|
238
|
+
fn(), mn(), J();
|
|
239
|
+
let n = Je(e, M);
|
|
240
|
+
wn($e(n)), S.current = e.line_items, Dt.current = e.currency, x.current = void 0, v.current = "draft", y.current = !1, b.current = t, q.current = void 0, zt(void 0), Ot("edit"), At(e.id), Mt(e.type === "invoice" ? e.recurrence_id ?? void 0 : void 0), O.current = n, D(n), k(!1), A({}), Bt(!1), R(!1), L.current = {
|
|
240
241
|
lines: !1,
|
|
241
242
|
discount: !1
|
|
242
|
-
},
|
|
243
|
+
}, H(), w(!0);
|
|
243
244
|
}, [
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
245
|
+
H,
|
|
246
|
+
fn,
|
|
247
|
+
mn,
|
|
248
|
+
J,
|
|
249
|
+
wn,
|
|
250
|
+
M
|
|
250
251
|
]);
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
...
|
|
254
|
-
lineItems:
|
|
255
|
-
},
|
|
256
|
-
let t =
|
|
252
|
+
p(() => {
|
|
253
|
+
M?.length && (O.current = {
|
|
254
|
+
...O.current,
|
|
255
|
+
lineItems: _e(O.current.lineItems, M)
|
|
256
|
+
}, D((e) => {
|
|
257
|
+
let t = _e(e.lineItems, M);
|
|
257
258
|
return t === e.lineItems ? e : {
|
|
258
259
|
...e,
|
|
259
260
|
lineItems: t
|
|
260
261
|
};
|
|
261
262
|
}));
|
|
262
|
-
}, [
|
|
263
|
-
let
|
|
264
|
-
|
|
265
|
-
}, [
|
|
266
|
-
if (
|
|
267
|
-
|
|
263
|
+
}, [M]);
|
|
264
|
+
let X = V.isUploading, Z = f(() => {
|
|
265
|
+
X || (tn(), k(!1), w(!1), A({}));
|
|
266
|
+
}, [tn, X]), On = f(() => {
|
|
267
|
+
if (Nt) {
|
|
268
|
+
k(!1);
|
|
268
269
|
return;
|
|
269
270
|
}
|
|
270
|
-
if (
|
|
271
|
-
e.error(
|
|
271
|
+
if (X) {
|
|
272
|
+
e.error(u.attachmentsUploading);
|
|
272
273
|
return;
|
|
273
274
|
}
|
|
274
|
-
if (
|
|
275
|
-
|
|
275
|
+
if (ut(O.current, E)) {
|
|
276
|
+
k(!0);
|
|
276
277
|
return;
|
|
277
278
|
}
|
|
278
|
-
|
|
279
|
+
Z();
|
|
279
280
|
}, [
|
|
280
|
-
Dn,
|
|
281
281
|
Z,
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
282
|
+
X,
|
|
283
|
+
u.attachmentsUploading,
|
|
284
|
+
Nt,
|
|
285
|
+
E
|
|
286
|
+
]), kn = f((e) => {
|
|
286
287
|
let t = { ...e };
|
|
287
|
-
t.taxRate !== void 0 && (t.taxRate =
|
|
288
|
+
t.taxRate !== void 0 && (t.taxRate = ye(t.taxRate), I.current = !0), t.type !== void 0 && t.type !== "invoice" && tn(), t.discount !== void 0 && Wt(!1), t.discount !== void 0 && P && (F.current = !0), t.discountType !== void 0 && (F.current = !0), t.currency !== void 0 && (Vt.current = !0), D((e) => {
|
|
288
289
|
let n = {
|
|
289
|
-
...t.customerId === void 0 ? e :
|
|
290
|
+
...t.customerId === void 0 ? e : dt(e, t.customerId),
|
|
290
291
|
...t
|
|
291
292
|
};
|
|
292
|
-
return t.discount !== void 0 && (n.discount =
|
|
293
|
+
return t.discount !== void 0 && (n.discount = Re(t.discount, n.discountType, n.currency)), n.currency !== e.currency && (n.lineItems = e.lineItems.map((t) => ({
|
|
293
294
|
...t,
|
|
294
|
-
price:
|
|
295
|
-
}))), (n.currency !== e.currency || n.discountType !== e.discountType) && (n.discount =
|
|
295
|
+
price: fe(t.price, e.currency, n.currency)
|
|
296
|
+
}))), (n.currency !== e.currency || n.discountType !== e.discountType) && (n.discount = Fe({
|
|
296
297
|
value: n.discount,
|
|
297
298
|
type: n.discountType,
|
|
298
299
|
currency: n.currency
|
|
299
300
|
})), n;
|
|
300
301
|
});
|
|
301
|
-
}, [
|
|
302
|
-
|
|
302
|
+
}, [tn, P]), An = f(() => {
|
|
303
|
+
R(!0), Wt(Le(E.discount, E.discountType, E.currency) === 0);
|
|
303
304
|
}, [
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
]), jn =
|
|
308
|
-
|
|
305
|
+
E.discount,
|
|
306
|
+
E.discountType,
|
|
307
|
+
E.currency
|
|
308
|
+
]), jn = f(() => {
|
|
309
|
+
R(!1), F.current = !0, D((e) => ({
|
|
309
310
|
...e,
|
|
310
|
-
discount:
|
|
311
|
+
discount: Fe({
|
|
311
312
|
value: e.discount,
|
|
312
313
|
type: e.discountType,
|
|
313
314
|
currency: e.currency
|
|
314
315
|
})
|
|
315
316
|
}));
|
|
316
|
-
}, []), Mn =
|
|
317
|
-
let e =
|
|
318
|
-
values:
|
|
319
|
-
messages:
|
|
320
|
-
canCreateCustomer:
|
|
317
|
+
}, []), Mn = f(() => {
|
|
318
|
+
let e = Ze({
|
|
319
|
+
values: E,
|
|
320
|
+
messages: u,
|
|
321
|
+
canCreateCustomer: _
|
|
321
322
|
}).customerEmail;
|
|
322
|
-
|
|
323
|
+
A((t) => {
|
|
323
324
|
if (t.customerEmail === e) return t;
|
|
324
325
|
let n = { ...t };
|
|
325
326
|
return e ? n.customerEmail = e : delete n.customerEmail, n;
|
|
326
327
|
});
|
|
327
328
|
}, [
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
]), Nn =
|
|
332
|
-
|
|
333
|
-
let t =
|
|
329
|
+
_,
|
|
330
|
+
u,
|
|
331
|
+
E
|
|
332
|
+
]), Nn = f(() => {
|
|
333
|
+
I.current = !0, D((e) => {
|
|
334
|
+
let t = de(e.taxRate);
|
|
334
335
|
return t === e.taxRate ? e : {
|
|
335
336
|
...e,
|
|
336
337
|
taxRate: t
|
|
337
338
|
};
|
|
338
339
|
});
|
|
339
|
-
}, []), Q =
|
|
340
|
-
t && (
|
|
340
|
+
}, []), Q = f((e, { validate: t }) => {
|
|
341
|
+
t && (Vt.current = !0), D((t) => ({
|
|
341
342
|
...t,
|
|
342
343
|
lineItems: e(t.lineItems)
|
|
343
344
|
}));
|
|
344
345
|
}, []);
|
|
345
|
-
|
|
346
|
-
let e =
|
|
347
|
-
if (!e && !t && !
|
|
348
|
-
|
|
349
|
-
let n =
|
|
350
|
-
currency:
|
|
351
|
-
messages:
|
|
346
|
+
p(() => {
|
|
347
|
+
let e = Vt.current, t = F.current;
|
|
348
|
+
if (!e && !t && !I.current) return;
|
|
349
|
+
Vt.current = !1, F.current = !1, I.current = !1, e && (L.current.lines = !0), t && (L.current.discount = !0);
|
|
350
|
+
let n = y.current || G > 0, r = e ? we(E.lineItems, {
|
|
351
|
+
currency: E.currency,
|
|
352
|
+
messages: u,
|
|
352
353
|
requireComplete: n
|
|
353
354
|
}) : void 0;
|
|
354
|
-
|
|
355
|
+
A((t) => {
|
|
355
356
|
let i = { ...t };
|
|
356
|
-
return
|
|
357
|
+
return L.current.lines && (i.lineItems = e ? r : t.lineItems, i.lineItemsSummary = Se(i.lineItems, He(E, u), n && E.lineItems.length === 0 ? u.lineItemsRequired : void 0)), L.current.discount && (i.discount = Ve(E, u)), i;
|
|
357
358
|
});
|
|
358
359
|
}, [
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
360
|
+
G,
|
|
361
|
+
u,
|
|
362
|
+
E
|
|
362
363
|
]);
|
|
363
|
-
let Pn =
|
|
364
|
-
let { unit: n, ...r } = t, i =
|
|
365
|
-
i.name !== void 0 && (i.productId = ""), n !== void 0 && (i.measureUnitId = n, i.measureUnitName = ""), i.taxable !== void 0 && (
|
|
364
|
+
let Pn = f((e, t) => {
|
|
365
|
+
let { unit: n, ...r } = t, i = ve(r);
|
|
366
|
+
i.name !== void 0 && (i.productId = ""), n !== void 0 && (i.measureUnitId = n, i.measureUnitName = ""), i.taxable !== void 0 && (I.current = !0), Q((t) => t.map((t) => t.id === e ? {
|
|
366
367
|
...t,
|
|
367
368
|
...i
|
|
368
|
-
} : t), { validate:
|
|
369
|
-
}, [Q,
|
|
369
|
+
} : t), { validate: P });
|
|
370
|
+
}, [Q, P]), Fn = f((e, t) => {
|
|
370
371
|
Q((n) => n.map((n) => n.id === e ? {
|
|
371
372
|
...n,
|
|
372
|
-
...
|
|
373
|
+
...he({
|
|
373
374
|
product: t,
|
|
374
|
-
currency:
|
|
375
|
-
unitNamesById:
|
|
375
|
+
currency: E.currency,
|
|
376
|
+
unitNamesById: N
|
|
376
377
|
})
|
|
377
378
|
} : n), { validate: !0 });
|
|
378
379
|
}, [
|
|
379
380
|
Q,
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
]), In =
|
|
381
|
+
N,
|
|
382
|
+
E.currency
|
|
383
|
+
]), In = f((e, t) => {
|
|
383
384
|
t && Q((n) => t.kind === "remove" ? n.filter((t) => t.id !== e) : n.map((n) => n.id === e ? {
|
|
384
385
|
...n,
|
|
385
386
|
...t.patch
|
|
386
387
|
} : n), { validate: !0 });
|
|
387
|
-
}, [Q]), Ln =
|
|
388
|
-
let n =
|
|
389
|
-
n && In(e,
|
|
388
|
+
}, [Q]), Ln = f((e, t) => {
|
|
389
|
+
let n = E.lineItems.find((t) => t.id === e);
|
|
390
|
+
n && In(e, ue({
|
|
390
391
|
lineItem: n,
|
|
391
392
|
field: t,
|
|
392
|
-
rowCount:
|
|
393
|
-
currency:
|
|
393
|
+
rowCount: E.lineItems.length,
|
|
394
|
+
currency: E.currency
|
|
394
395
|
}));
|
|
395
396
|
}, [
|
|
396
397
|
In,
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
]), Rn =
|
|
400
|
-
let n =
|
|
401
|
-
n && In(e,
|
|
398
|
+
E.currency,
|
|
399
|
+
E.lineItems
|
|
400
|
+
]), Rn = f((e, t) => {
|
|
401
|
+
let n = E.lineItems.find((t) => t.id === e);
|
|
402
|
+
n && In(e, be({
|
|
402
403
|
lineItem: n,
|
|
403
404
|
step: t,
|
|
404
|
-
rowCount:
|
|
405
|
+
rowCount: E.lineItems.length
|
|
405
406
|
}));
|
|
406
|
-
}, [In,
|
|
407
|
-
let e =
|
|
408
|
-
|
|
407
|
+
}, [In, E.lineItems]), zn = f(() => {
|
|
408
|
+
let e = pe(E.currency);
|
|
409
|
+
zt(e.id), D((t) => ({
|
|
409
410
|
...t,
|
|
410
411
|
lineItems: [...t.lineItems, e]
|
|
411
412
|
}));
|
|
412
|
-
}, [
|
|
413
|
+
}, [E.currency]), Bn = f((e) => {
|
|
413
414
|
Q((t) => t.length <= 1 ? t : t.filter((t) => t.id !== e), { validate: !0 });
|
|
414
|
-
}, [Q]), Vn =
|
|
415
|
-
...
|
|
415
|
+
}, [Q]), Vn = f((e, t) => e.type === "invoice" && (t === "issue" || Pe(e) && G === 0), [G]), Hn = f((e, t) => ({
|
|
416
|
+
...Ze({
|
|
416
417
|
values: e,
|
|
417
|
-
messages:
|
|
418
|
+
messages: u,
|
|
418
419
|
willIssue: t,
|
|
419
|
-
hasStartedRecurrence:
|
|
420
|
-
canCreateCustomer:
|
|
420
|
+
hasStartedRecurrence: G > 0,
|
|
421
|
+
canCreateCustomer: _
|
|
421
422
|
}),
|
|
422
|
-
...e.type === "invoice" &&
|
|
423
|
+
...e.type === "invoice" && d(e) ? Ne({
|
|
423
424
|
fields: e,
|
|
424
|
-
issuedCount:
|
|
425
|
-
messages:
|
|
425
|
+
issuedCount: G,
|
|
426
|
+
messages: u
|
|
426
427
|
}) : {}
|
|
427
428
|
}), [
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
]), Un =
|
|
429
|
+
_,
|
|
430
|
+
G,
|
|
431
|
+
u
|
|
432
|
+
]), Un = f(() => {
|
|
432
433
|
requestAnimationFrame(() => {
|
|
433
|
-
let e =
|
|
434
|
+
let e = Et.current, t = e?.querySelector("[aria-invalid=\"true\"], [data-invalid=\"true\"]");
|
|
434
435
|
if (!e || !t) return;
|
|
435
436
|
let n = t.getBoundingClientRect().top - e.getBoundingClientRect().top + e.scrollTop;
|
|
436
437
|
e.scrollTo({
|
|
@@ -438,31 +439,31 @@ function ft({ messages: d, counterpartMessageLabels: ft, embeddedBankName: pt, c
|
|
|
438
439
|
behavior: "smooth"
|
|
439
440
|
});
|
|
440
441
|
});
|
|
441
|
-
}, []), Wn =
|
|
442
|
-
|
|
442
|
+
}, []), Wn = f((e, t) => {
|
|
443
|
+
A(e), Bt(!0), y.current = t, L.current = {
|
|
443
444
|
lines: !0,
|
|
444
445
|
discount: !0
|
|
445
446
|
}, Un();
|
|
446
|
-
}, [Un]), Gn = !
|
|
447
|
-
|
|
448
|
-
if (!
|
|
449
|
-
|
|
450
|
-
let e = Vn(
|
|
451
|
-
Wn(Hn(
|
|
447
|
+
}, [Un]), Gn = !jt || E.frequency !== "once" || hn.isError;
|
|
448
|
+
p(() => {
|
|
449
|
+
if (!C || !b.current || z || K || !Gn) return;
|
|
450
|
+
b.current = !1;
|
|
451
|
+
let e = Vn(E, "issue");
|
|
452
|
+
Wn(Hn(E, e), e);
|
|
452
453
|
}, [
|
|
453
|
-
|
|
454
|
-
|
|
454
|
+
z,
|
|
455
|
+
C,
|
|
455
456
|
Gn,
|
|
456
|
-
|
|
457
|
+
K,
|
|
457
458
|
Wn,
|
|
458
459
|
Hn,
|
|
459
|
-
|
|
460
|
+
E,
|
|
460
461
|
Vn
|
|
461
462
|
]);
|
|
462
|
-
let Kn =
|
|
463
|
-
|
|
463
|
+
let Kn = h({ values: E });
|
|
464
|
+
p(() => {
|
|
464
465
|
let e = Kn.current;
|
|
465
|
-
if (Kn.current = { values:
|
|
466
|
+
if (Kn.current = { values: E }, !P) return;
|
|
466
467
|
let t = [
|
|
467
468
|
"customerId",
|
|
468
469
|
"customerEmail",
|
|
@@ -472,257 +473,257 @@ function ft({ messages: d, counterpartMessageLabels: ft, embeddedBankName: pt, c
|
|
|
472
473
|
"openingNote",
|
|
473
474
|
"closingNote",
|
|
474
475
|
"taxRate"
|
|
475
|
-
].filter((t) => e.values[t] !==
|
|
476
|
+
].filter((t) => e.values[t] !== E[t] || t === "customerId" && e.values.customerName !== E.customerName || t === "paymentTermsId" && e.values.paymentTermsCustomDate !== E.paymentTermsCustomDate);
|
|
476
477
|
if (!t.length) return;
|
|
477
|
-
let n =
|
|
478
|
-
values:
|
|
479
|
-
messages:
|
|
480
|
-
willIssue:
|
|
481
|
-
canCreateCustomer:
|
|
478
|
+
let n = Ze({
|
|
479
|
+
values: E,
|
|
480
|
+
messages: u,
|
|
481
|
+
willIssue: y.current,
|
|
482
|
+
canCreateCustomer: _
|
|
482
483
|
});
|
|
483
|
-
|
|
484
|
+
A((e) => {
|
|
484
485
|
let r = { ...e };
|
|
485
486
|
return t.forEach((e) => {
|
|
486
487
|
n[e] ? r[e] = n[e] : delete r[e];
|
|
487
488
|
}), r;
|
|
488
489
|
});
|
|
489
490
|
}, [
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
491
|
+
_,
|
|
492
|
+
u,
|
|
493
|
+
P,
|
|
494
|
+
E
|
|
494
495
|
]);
|
|
495
|
-
let qn =
|
|
496
|
-
if (
|
|
497
|
-
if (
|
|
498
|
-
e.error(
|
|
496
|
+
let qn = f(async (t) => {
|
|
497
|
+
if (v.current = t, K) return;
|
|
498
|
+
if (X) {
|
|
499
|
+
e.error(u.attachmentsUploading);
|
|
499
500
|
return;
|
|
500
501
|
}
|
|
501
|
-
if (
|
|
502
|
-
e.error(
|
|
502
|
+
if (j.isLoading || z) {
|
|
503
|
+
e.error(u.lineItemsLoading);
|
|
503
504
|
return;
|
|
504
505
|
}
|
|
505
|
-
let
|
|
506
|
-
...
|
|
507
|
-
lineItems:
|
|
506
|
+
let i = xe(E.lineItems), a = i.length === E.lineItems.length ? E : {
|
|
507
|
+
...E,
|
|
508
|
+
lineItems: i
|
|
508
509
|
};
|
|
509
|
-
a !==
|
|
510
|
-
let o = a.type === "invoice" &&
|
|
511
|
-
if (s && (
|
|
512
|
-
e.error(
|
|
510
|
+
a !== E && D(a);
|
|
511
|
+
let o = a.type === "invoice" && d(a), s = Vn(a, t);
|
|
512
|
+
if (s && ($t || U.isLoading)) {
|
|
513
|
+
e.error(u.issueChecksLoading);
|
|
513
514
|
return;
|
|
514
515
|
}
|
|
515
|
-
if (s && !
|
|
516
|
-
e.error(
|
|
516
|
+
if (s && !U.canAddAccount && !a.bankAccountId && !U.hasAccounts) {
|
|
517
|
+
e.error(u.issueBankAccountUnavailable);
|
|
517
518
|
return;
|
|
518
519
|
}
|
|
519
|
-
let
|
|
520
|
-
if (
|
|
521
|
-
Wn(
|
|
520
|
+
let te = Hn(a, s);
|
|
521
|
+
if (We(te)) {
|
|
522
|
+
Wn(te, s);
|
|
522
523
|
return;
|
|
523
524
|
}
|
|
524
|
-
if (
|
|
525
|
-
e.error(
|
|
525
|
+
if (A({}), s && B.isTaxIdMissing) {
|
|
526
|
+
e.error(u.issueTaxIdRequired);
|
|
526
527
|
return;
|
|
527
528
|
}
|
|
528
|
-
let
|
|
529
|
+
let ne = _ && !a.customerId && !!a.customerName.trim(), ie = a.customerEmail.trim();
|
|
529
530
|
if (s && (a.paymentReminderId || a.overdueReminderId)) {
|
|
530
|
-
let t =
|
|
531
|
+
let t = ne ? ie ? void 0 : u.issueRemindersNoEmail : Qe(B.counterpart, u);
|
|
531
532
|
if (t) {
|
|
532
533
|
e.error(t);
|
|
533
534
|
return;
|
|
534
535
|
}
|
|
535
536
|
}
|
|
536
|
-
if (
|
|
537
|
+
if (ne) {
|
|
537
538
|
let t;
|
|
538
539
|
try {
|
|
539
|
-
t = (await
|
|
540
|
+
t = (await St.mutateAsync({ body: re({
|
|
540
541
|
name: a.customerName,
|
|
541
542
|
email: a.customerEmail
|
|
542
543
|
}) }))?.id;
|
|
543
544
|
} catch (t) {
|
|
544
|
-
e.error(
|
|
545
|
+
e.error(rt(t, { messages: u }));
|
|
545
546
|
return;
|
|
546
547
|
}
|
|
547
548
|
if (!t) return;
|
|
548
|
-
a =
|
|
549
|
+
a = ft(a, t);
|
|
549
550
|
let n = t;
|
|
550
|
-
|
|
551
|
+
D((e) => ft(e, n));
|
|
551
552
|
}
|
|
552
|
-
let
|
|
553
|
+
let c = T === "edit" ? kt : x.current, l, ae, oe = "", se = {};
|
|
553
554
|
try {
|
|
554
|
-
if (
|
|
555
|
-
let e =
|
|
555
|
+
if (c) {
|
|
556
|
+
let e = Ke({
|
|
556
557
|
values: a,
|
|
557
|
-
originalLineItems:
|
|
558
|
-
originalCurrency:
|
|
559
|
-
unitNamesById:
|
|
560
|
-
units:
|
|
558
|
+
originalLineItems: S.current,
|
|
559
|
+
originalCurrency: Dt.current,
|
|
560
|
+
unitNamesById: N,
|
|
561
|
+
units: M
|
|
561
562
|
});
|
|
562
|
-
|
|
563
|
+
se = Xe({
|
|
563
564
|
values: a,
|
|
564
|
-
originalLineItems:
|
|
565
|
+
originalLineItems: S.current,
|
|
565
566
|
changes: e
|
|
566
567
|
});
|
|
567
|
-
let t = await
|
|
568
|
-
path: { receivable_id:
|
|
569
|
-
body:
|
|
568
|
+
let t = await vt.mutateAsync({
|
|
569
|
+
path: { receivable_id: c },
|
|
570
|
+
body: qe({
|
|
570
571
|
values: a,
|
|
571
|
-
billingAddressId:
|
|
572
|
-
shippingAddressId:
|
|
572
|
+
billingAddressId: Xt,
|
|
573
|
+
shippingAddressId: Qt,
|
|
573
574
|
lineItemChanges: e
|
|
574
575
|
})
|
|
575
576
|
});
|
|
576
|
-
|
|
577
|
+
nn(), l = c, ae = t?.type ?? a.type, o && t && (S.current = t.line_items, Dt.current = t.currency, a = {
|
|
577
578
|
...a,
|
|
578
|
-
lineItems:
|
|
579
|
-
},
|
|
579
|
+
lineItems: ge(a.lineItems, t.line_items)
|
|
580
|
+
}, D(a));
|
|
580
581
|
} else {
|
|
581
|
-
|
|
582
|
-
let e = await
|
|
582
|
+
se = Xe({ values: a });
|
|
583
|
+
let e = await _t.mutateAsync({ body: Ge({
|
|
583
584
|
values: a,
|
|
584
|
-
billingAddressId:
|
|
585
|
-
shippingAddressId:
|
|
586
|
-
unitNamesById:
|
|
585
|
+
billingAddressId: Xt,
|
|
586
|
+
shippingAddressId: Qt,
|
|
587
|
+
unitNamesById: N
|
|
587
588
|
}) });
|
|
588
589
|
if (!e?.id) {
|
|
589
|
-
|
|
590
|
+
w(!1), Tn();
|
|
590
591
|
return;
|
|
591
592
|
}
|
|
592
|
-
|
|
593
|
+
l = e.id, ae = e.type, oe = e.counterpart_name ?? "", o && (x.current = e.id, S.current = e.line_items, Dt.current = e.currency, a = {
|
|
593
594
|
...a,
|
|
594
|
-
lineItems:
|
|
595
|
-
},
|
|
595
|
+
lineItems: ge(a.lineItems, e.line_items)
|
|
596
|
+
}, D(a));
|
|
596
597
|
}
|
|
597
598
|
} catch (t) {
|
|
598
|
-
let n =
|
|
599
|
+
let n = tt[a.type], i = rt(t, {
|
|
599
600
|
irrelevantVariants: n,
|
|
600
|
-
messages:
|
|
601
|
+
messages: u
|
|
601
602
|
});
|
|
602
|
-
e.error((
|
|
603
|
-
let { errors:
|
|
603
|
+
e.error((c ? u.updateFailed : u.createFailed).replace("{errorMessage}", i));
|
|
604
|
+
let { errors: ee, listError: o } = nt(r(t, n), se), te = Se(ee.lineItems, void 0, o);
|
|
604
605
|
Wn({
|
|
605
|
-
...
|
|
606
|
-
...
|
|
606
|
+
...ee,
|
|
607
|
+
...te ? { lineItemsSummary: te } : {}
|
|
607
608
|
}, s);
|
|
608
609
|
return;
|
|
609
610
|
}
|
|
610
|
-
let
|
|
611
|
+
let ce = o ? "recurrence" : "draft";
|
|
611
612
|
if (o) try {
|
|
612
|
-
|
|
613
|
-
path: { recurrence_id:
|
|
614
|
-
body:
|
|
615
|
-
}), e.success(
|
|
613
|
+
W ? (await bt.mutateAsync({
|
|
614
|
+
path: { recurrence_id: W.id },
|
|
615
|
+
body: Ae(a, { lockSchedule: gn })
|
|
616
|
+
}), e.success(u.recurrenceUpdated)) : (await yt.mutateAsync({ body: ke(a, l) }), e.success(u.recurrenceActivated));
|
|
616
617
|
} catch (t) {
|
|
617
|
-
e.error(
|
|
618
|
+
e.error(rt(t, { messages: u }));
|
|
618
619
|
return;
|
|
619
620
|
}
|
|
620
621
|
else if (s) try {
|
|
621
|
-
await
|
|
622
|
+
await xt.mutateAsync({ path: { receivable_id: l } }), ce = "issue", e.success(u.issueSucceeded);
|
|
622
623
|
} catch (t) {
|
|
623
|
-
e.error(n(t) ??
|
|
624
|
+
e.error(n(t) ?? u.unrecognizedError), e.error(u.issueFailedAfterSave);
|
|
624
625
|
}
|
|
625
|
-
else
|
|
626
|
-
let
|
|
627
|
-
|
|
628
|
-
mode:
|
|
626
|
+
else T === "create" ? e.success(u.createSucceeded.replace("{customer}", oe)) : e.success(u.updateSucceeded);
|
|
627
|
+
let le = T === "create" ? ht : gt;
|
|
628
|
+
w(!1), Tn(), le?.(l, ae, {
|
|
629
|
+
mode: ce,
|
|
629
630
|
counterpartId: a.customerId,
|
|
630
|
-
inlineItems:
|
|
631
|
-
hasCustomerEmail:
|
|
631
|
+
inlineItems: Oe(a.lineItems, a.currency),
|
|
632
|
+
hasCustomerEmail: ne ? !!ie : !!(B.counterpart && ee(B.counterpart).trim())
|
|
632
633
|
});
|
|
633
634
|
}, [
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
635
|
+
U.canAddAccount,
|
|
636
|
+
U.hasAccounts,
|
|
637
|
+
U.isLoading,
|
|
638
|
+
Xt,
|
|
639
|
+
_,
|
|
640
|
+
nn,
|
|
641
|
+
St,
|
|
642
|
+
_t,
|
|
643
|
+
yt,
|
|
644
|
+
kt,
|
|
645
|
+
W,
|
|
646
|
+
z,
|
|
647
|
+
X,
|
|
648
|
+
$t,
|
|
640
649
|
xt,
|
|
650
|
+
gn,
|
|
651
|
+
u,
|
|
652
|
+
T,
|
|
653
|
+
ht,
|
|
641
654
|
gt,
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
Z,
|
|
655
|
+
B.counterpart,
|
|
656
|
+
B.isTaxIdMissing,
|
|
657
|
+
K,
|
|
658
|
+
Tn,
|
|
647
659
|
Qt,
|
|
648
|
-
bt,
|
|
649
|
-
hn,
|
|
650
|
-
d,
|
|
651
|
-
E,
|
|
652
|
-
mt,
|
|
653
|
-
ht,
|
|
654
|
-
V.counterpart,
|
|
655
|
-
V.isTaxIdMissing,
|
|
656
|
-
q,
|
|
657
|
-
wn,
|
|
658
|
-
Zt,
|
|
659
660
|
Wn,
|
|
661
|
+
M,
|
|
660
662
|
N,
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
yt,
|
|
663
|
+
j.isLoading,
|
|
664
|
+
vt,
|
|
665
|
+
bt,
|
|
665
666
|
Hn,
|
|
666
|
-
|
|
667
|
+
E,
|
|
667
668
|
Vn
|
|
668
|
-
]), $ =
|
|
669
|
-
if (!
|
|
670
|
-
|
|
669
|
+
]), $ = f(async (e = v.current) => {
|
|
670
|
+
if (!Ct.current) {
|
|
671
|
+
Ct.current = !0, Tt(e);
|
|
671
672
|
try {
|
|
672
673
|
await qn(e);
|
|
673
674
|
} finally {
|
|
674
|
-
|
|
675
|
+
Ct.current = !1, Tt(void 0);
|
|
675
676
|
}
|
|
676
677
|
}
|
|
677
|
-
}, [qn]), Jn =
|
|
678
|
-
...
|
|
679
|
-
discount:
|
|
680
|
-
lineItems:
|
|
678
|
+
}, [qn]), Jn = m(() => ({
|
|
679
|
+
...E,
|
|
680
|
+
discount: Ht ? Ut ? "" : E.discount : Ie(Le(E.discount, E.discountType, E.currency), E.discountType, E.currency),
|
|
681
|
+
lineItems: E.lineItems.map(Ce)
|
|
681
682
|
}), [
|
|
683
|
+
Ut,
|
|
682
684
|
Ht,
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
}, [rr]), lr = er || Qn, ur = p(async () => {
|
|
685
|
+
E
|
|
686
|
+
]), Yn = m(() => le(E.lineItems), [E.lineItems]), Xn = m(() => Be(E), [E]), Zn = E.type === "invoice", Qn = Zn && d(E), $n = Y || j.isLoading || U.isLoading, er = $n || z || V.isUploading || K, tr = T === "edit" ? u.updateDraftButton : u.saveDraftButton, nr = Qn ? W ? u.recurrenceUpdateButton : u.recurrenceActivateButton : Zn ? u.issueButton : tr, rr = Zn && !Qn ? "issue" : "draft", ir = f(() => $("draft"), [$]), ar = f(() => $(rr), [rr, $]), or = f(() => $(), [$]), sr = f(() => {
|
|
687
|
+
v.current = "draft";
|
|
688
|
+
}, []), cr = f(() => {
|
|
689
|
+
v.current = rr;
|
|
690
|
+
}, [rr]), lr = er || Qn, ur = f(async () => {
|
|
690
691
|
if (!lr) try {
|
|
691
692
|
await $("draft");
|
|
692
693
|
} finally {
|
|
693
|
-
|
|
694
|
+
k(!1);
|
|
694
695
|
}
|
|
695
|
-
}, [lr, $]), dr =
|
|
696
|
-
open:
|
|
696
|
+
}, [lr, $]), dr = f(() => k(!1), []), fr = m(() => ({
|
|
697
|
+
open: Nt,
|
|
697
698
|
onSaveDraft: () => void ur(),
|
|
698
|
-
onDiscard:
|
|
699
|
+
onDiscard: Z,
|
|
699
700
|
onCancel: dr,
|
|
700
|
-
isSaving:
|
|
701
|
+
isSaving: Y,
|
|
701
702
|
isSaveDraftDisabled: lr
|
|
702
703
|
}), [
|
|
703
704
|
dr,
|
|
704
|
-
|
|
705
|
-
|
|
705
|
+
Z,
|
|
706
|
+
Y,
|
|
706
707
|
lr,
|
|
707
708
|
ur,
|
|
708
|
-
|
|
709
|
-
]), pr =
|
|
710
|
-
values:
|
|
709
|
+
Nt
|
|
710
|
+
]), pr = m(() => ze(Xn, E.currency), [Xn, E.currency]), mr = lt({
|
|
711
|
+
values: E,
|
|
711
712
|
totals: Xn,
|
|
712
|
-
billingAddress:
|
|
713
|
-
bankAccount:
|
|
714
|
-
unitNamesById:
|
|
715
|
-
messages:
|
|
716
|
-
enabled:
|
|
713
|
+
billingAddress: Zt,
|
|
714
|
+
bankAccount: U.selectedAccount,
|
|
715
|
+
unitNamesById: N,
|
|
716
|
+
messages: u,
|
|
717
|
+
enabled: C
|
|
717
718
|
});
|
|
718
719
|
return {
|
|
719
|
-
open:
|
|
720
|
-
setOpen:
|
|
721
|
-
mode:
|
|
722
|
-
values:
|
|
720
|
+
open: C,
|
|
721
|
+
setOpen: w,
|
|
722
|
+
mode: T,
|
|
723
|
+
values: E,
|
|
723
724
|
sheetValues: Jn,
|
|
724
|
-
errors:
|
|
725
|
-
setValues:
|
|
725
|
+
errors: Pt,
|
|
726
|
+
setValues: D,
|
|
726
727
|
updateValues: kn,
|
|
727
728
|
commitTaxRate: Nn,
|
|
728
729
|
commitCustomerEmail: Mn,
|
|
@@ -734,41 +735,41 @@ function ft({ messages: d, counterpartMessageLabels: ft, embeddedBankName: pt, c
|
|
|
734
735
|
stepLineItem: Rn,
|
|
735
736
|
addLineItem: zn,
|
|
736
737
|
removeLineItem: Bn,
|
|
737
|
-
attachmentsView:
|
|
738
|
-
attachmentsUploading:
|
|
738
|
+
attachmentsView: rn,
|
|
739
|
+
attachmentsUploading: V.isUploading,
|
|
739
740
|
draftButtonLabel: Zn && !Qn ? tr : void 0,
|
|
740
741
|
draftDisabled: er,
|
|
741
|
-
draftLoading:
|
|
742
|
+
draftLoading: Y && wt === "draft",
|
|
742
743
|
primaryButtonLabel: nr,
|
|
743
|
-
primaryLoading:
|
|
744
|
-
primaryDisabled: er || Zn && (
|
|
745
|
-
scrollContainerRef:
|
|
746
|
-
selectAttachmentFiles:
|
|
747
|
-
setAttachmentIncludeInEmail:
|
|
748
|
-
removeAttachment:
|
|
749
|
-
autoFocusLineItemId:
|
|
750
|
-
lineItemUnitOptions:
|
|
751
|
-
lineItemsLoading:
|
|
744
|
+
primaryLoading: Y && wt === rr,
|
|
745
|
+
primaryDisabled: er || Zn && ($t || !Qn && B.isCounterpartLoading),
|
|
746
|
+
scrollContainerRef: Et,
|
|
747
|
+
selectAttachmentFiles: V.selectFiles,
|
|
748
|
+
setAttachmentIncludeInEmail: V.setIncludeInEmail,
|
|
749
|
+
removeAttachment: V.remove,
|
|
750
|
+
autoFocusLineItemId: Rt,
|
|
751
|
+
lineItemUnitOptions: Lt.unitOptions,
|
|
752
|
+
lineItemsLoading: j.isLoading,
|
|
752
753
|
lineItemControls: Yn,
|
|
753
754
|
totals: Xn,
|
|
754
755
|
preview: mr,
|
|
755
756
|
totalsView: pr,
|
|
756
|
-
currencySymbol:
|
|
757
|
-
isSubmitting:
|
|
757
|
+
currencySymbol: me(E.currency),
|
|
758
|
+
isSubmitting: Y,
|
|
758
759
|
fieldsDisabled: $n,
|
|
759
|
-
paymentTerms:
|
|
760
|
-
showBillingSection:
|
|
761
|
-
purchaseOrder:
|
|
762
|
-
value:
|
|
763
|
-
error:
|
|
760
|
+
paymentTerms: dn,
|
|
761
|
+
showBillingSection: E.type === "invoice" || T === "edit",
|
|
762
|
+
purchaseOrder: T === "create" ? {
|
|
763
|
+
value: E.purchaseOrder,
|
|
764
|
+
error: Pt.purchaseOrder
|
|
764
765
|
} : void 0,
|
|
765
|
-
recurrence:
|
|
766
|
-
showRecurrenceSection:
|
|
767
|
-
recurrenceLoading:
|
|
768
|
-
showDueDateField:
|
|
769
|
-
openCreate:
|
|
770
|
-
openEdit:
|
|
771
|
-
close:
|
|
766
|
+
recurrence: xn,
|
|
767
|
+
showRecurrenceSection: E.type === "invoice",
|
|
768
|
+
recurrenceLoading: K,
|
|
769
|
+
showDueDateField: E.type === "quote",
|
|
770
|
+
openCreate: En,
|
|
771
|
+
openEdit: Dn,
|
|
772
|
+
close: Z,
|
|
772
773
|
requestClose: On,
|
|
773
774
|
unsavedPrompt: fr,
|
|
774
775
|
submit: or,
|
|
@@ -776,15 +777,15 @@ function ft({ messages: d, counterpartMessageLabels: ft, embeddedBankName: pt, c
|
|
|
776
777
|
submitPrimary: ar,
|
|
777
778
|
selectDraftMode: sr,
|
|
778
779
|
selectPrimaryMode: cr,
|
|
779
|
-
units:
|
|
780
|
-
counterpartView:
|
|
781
|
-
counterpartForm:
|
|
782
|
-
stateOptions:
|
|
783
|
-
openCounterpartCreate:
|
|
784
|
-
customer:
|
|
785
|
-
bankAccount:
|
|
786
|
-
reminders:
|
|
780
|
+
units: Lt,
|
|
781
|
+
counterpartView: Ft,
|
|
782
|
+
counterpartForm: on,
|
|
783
|
+
stateOptions: Gt,
|
|
784
|
+
openCounterpartCreate: ln,
|
|
785
|
+
customer: Jt.data?.id === E.customerId ? Jt.data : void 0,
|
|
786
|
+
bankAccount: U,
|
|
787
|
+
reminders: Cn
|
|
787
788
|
};
|
|
788
789
|
}
|
|
789
790
|
//#endregion
|
|
790
|
-
export {
|
|
791
|
+
export { pt as useReceivableForm };
|