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