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