@tesouro/embedded-components-react 0.5.267 → 0.5.270
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/dist/index.css +4 -10
- package/dist/index.d.ts +13 -9
- package/dist/lib/ReceivablesWidget.d.ts +13 -9
- package/dist/libs/tesouro-embedded-components-react/counterparts-widget/feature/dist/index.js +3 -1
- package/dist/libs/tesouro-embedded-components-react/counterparts-widget/feature/dist/lib/CounterpartsWidget/CounterpartDetailsContainer.js +44 -0
- package/dist/libs/tesouro-embedded-components-react/counterparts-widget/feature/dist/lib/CounterpartsWidget/useCounterpartDetailsSheetView.js +97 -0
- package/dist/libs/tesouro-embedded-components-react/counterparts-widget/feature/dist/lib/CounterpartsWidget/useCounterpartsWidget.js +76 -150
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/ReceivablesWidget.js +63 -57
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/actionsModal.js +1 -1
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/auditHistory/labels.js +1 -1
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/details.js +161 -152
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/helpers.js +30 -34
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/labels.js +12 -8
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/statusCards.js +18 -19
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/useReceivableActions.js +208 -158
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/useReceivableDetails.js +91 -85
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/useReceivableForm.js +197 -196
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/useReceivablesWidget.js +147 -115
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index.js +14 -14
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index13.js +3 -5
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index14.js +37 -34
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index22.js +22 -7
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index23.js +17 -15
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index24.js +17 -13
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index26.js +37 -31
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index27.js +29 -23
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index29.js +38 -11
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index30.js +26 -28
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index31.js +20 -14
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index32.js +8 -24
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index33.js +34 -83
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index34.js +14 -404
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index35.js +28 -2
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index36.js +79 -39
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index37.js +490 -68
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index38.js +2 -502
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index39.js +41 -216
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index40.js +70 -21
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index41.js +484 -5
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index42.js +224 -0
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index43.js +21 -263
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index44.js +8 -2
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index46.js +261 -24
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index47.js +2 -237
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index48.js +100 -3
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index49.js +21 -242
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index50.js +226 -82
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index51.js +3 -59
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index52.js +233 -178
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index53.js +85 -37
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index54.js +60 -0
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index55.js +194 -0
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index56.js +45 -0
- package/dist/libs/tesouro-embedded-components-react/shared/feature/dist/lib/analytics/build-info.js +1 -1
- package/package.json +1 -1
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index45.js +0 -100
|
@@ -47,41 +47,41 @@ function st(e, t) {
|
|
|
47
47
|
...t ? { customerEmail: "" } : {}
|
|
48
48
|
});
|
|
49
49
|
}
|
|
50
|
-
function ct({ messages: l, counterpartMessageLabels: ct, embeddedBankName: lt, onCreated: ut }) {
|
|
51
|
-
let
|
|
50
|
+
function ct({ messages: l, counterpartMessageLabels: ct, embeddedBankName: lt, onCreated: ut, onUpdated: dt }) {
|
|
51
|
+
let ft = Ue(), pt = Ge(), mt = Ke(), ht = Je(), gt = We(), g = m("draft"), _t = m(!1), [vt, yt] = h(), _ = m(!1), v = m(!1), bt = m(null), y = m(void 0), b = m([]), xt = m(""), [x, S] = h(!1), [C, St] = h("create"), [Ct, wt] = h(), [Tt, Et] = h(), [w, T] = h(() => Me()), E = m(w), [Dt, D] = h(!1), [Ot, O] = h({}), [kt, At] = h("none"), jt = ge(), k = he(), A = k.data?.data, { unitNamesById: j } = jt, [Mt, Nt] = h(), [M, Pt] = h(!1), Ft = m(!1), N = m(!1), P = m(!1), F = m({
|
|
52
52
|
lines: !1,
|
|
53
53
|
discount: !1
|
|
54
|
-
}), [It,
|
|
54
|
+
}), [It, I] = h(!1), Lt = p(() => t(), []), Rt = p(() => ({
|
|
55
55
|
...n,
|
|
56
56
|
...ct
|
|
57
|
-
}), [ct]), zt = a(w.customerId), Bt = i(w.customerId || void 0), Vt = zt.data?.data?.[0], { billingAddressId:
|
|
57
|
+
}), [ct]), zt = a(w.customerId), Bt = i(w.customerId || void 0), Vt = zt.data?.data?.[0], { billingAddressId: L, billingAddress: Ht, shippingAddressId: Ut } = Re({
|
|
58
58
|
values: w,
|
|
59
59
|
counterpart: Bt.data,
|
|
60
60
|
addresses: zt.data?.data
|
|
61
|
-
}),
|
|
61
|
+
}), R = !!w.customerId && (zt.isLoading || Bt.isLoading), z = Ye({
|
|
62
62
|
counterpartId: w.customerId,
|
|
63
|
-
billingAddressId:
|
|
63
|
+
billingAddressId: L,
|
|
64
64
|
billingCountry: Ht?.country
|
|
65
|
-
}), Wt =
|
|
65
|
+
}), Wt = z.isLoading || R, Gt = d((e) => {
|
|
66
66
|
T((t) => ({
|
|
67
67
|
...t,
|
|
68
68
|
attachments: e(t.attachments)
|
|
69
69
|
}));
|
|
70
|
-
}, []),
|
|
70
|
+
}, []), B = et({
|
|
71
71
|
attachments: w.attachments,
|
|
72
72
|
setAttachments: Gt,
|
|
73
|
-
receivableId:
|
|
74
|
-
}), { reset:
|
|
73
|
+
receivableId: Ct
|
|
74
|
+
}), { reset: V, discardUploads: Kt, commitRemovals: qt } = B, Jt = w.type === "invoice" ? me({
|
|
75
75
|
attachments: w.attachments,
|
|
76
|
-
pendingUploads:
|
|
77
|
-
isCountLimitReached:
|
|
76
|
+
pendingUploads: B.pendingUploads,
|
|
77
|
+
isCountLimitReached: B.isCountLimitReached,
|
|
78
78
|
isRecurring: u(w),
|
|
79
79
|
messages: l
|
|
80
80
|
}) : void 0, Yt = d((e) => {
|
|
81
81
|
T((t) => st(t, e ?? ""));
|
|
82
82
|
}, []), Xt = o({
|
|
83
|
-
view:
|
|
84
|
-
setView:
|
|
83
|
+
view: kt,
|
|
84
|
+
setView: At,
|
|
85
85
|
selectedId: w.customerId || void 0,
|
|
86
86
|
setSelectedId: Yt,
|
|
87
87
|
messages: Rt,
|
|
@@ -122,18 +122,18 @@ function ct({ messages: l, counterpartMessageLabels: ct, embeddedBankName: lt, o
|
|
|
122
122
|
...t,
|
|
123
123
|
...e
|
|
124
124
|
}));
|
|
125
|
-
}, []),
|
|
125
|
+
}, []), H = rt({
|
|
126
126
|
open: x,
|
|
127
127
|
bankAccountId: w.bankAccountId,
|
|
128
128
|
bankAccountType: w.bankAccountType,
|
|
129
129
|
embeddedBankName: lt,
|
|
130
130
|
messages: l,
|
|
131
131
|
onSelect: rn
|
|
132
|
-
}), an =
|
|
132
|
+
}), an = H.reset, on = qe(Tt), U = Tt ? on.data : void 0, W = be(U), sn = W > 0, G = !!Tt && on.isLoading, K = m(void 0);
|
|
133
133
|
f(() => {
|
|
134
|
-
if (!
|
|
135
|
-
|
|
136
|
-
let e = xe(
|
|
134
|
+
if (!U || K.current === U.id) return;
|
|
135
|
+
K.current = U.id;
|
|
136
|
+
let e = xe(U);
|
|
137
137
|
E.current = {
|
|
138
138
|
...E.current,
|
|
139
139
|
...e
|
|
@@ -141,7 +141,7 @@ function ct({ messages: l, counterpartMessageLabels: ct, embeddedBankName: lt, o
|
|
|
141
141
|
...t,
|
|
142
142
|
...e
|
|
143
143
|
}));
|
|
144
|
-
}, [
|
|
144
|
+
}, [U]);
|
|
145
145
|
let cn = d((e) => T(e), []), ln = d((e) => O((t) => {
|
|
146
146
|
if (!e.some((e) => e in t)) return t;
|
|
147
147
|
let n = { ...t };
|
|
@@ -159,7 +159,7 @@ function ct({ messages: l, counterpartMessageLabels: ct, embeddedBankName: lt, o
|
|
|
159
159
|
un.current = [];
|
|
160
160
|
let t = Se({
|
|
161
161
|
fields: w,
|
|
162
|
-
issuedCount:
|
|
162
|
+
issuedCount: W,
|
|
163
163
|
messages: l
|
|
164
164
|
});
|
|
165
165
|
O((n) => {
|
|
@@ -169,25 +169,25 @@ function ct({ messages: l, counterpartMessageLabels: ct, embeddedBankName: lt, o
|
|
|
169
169
|
}), r;
|
|
170
170
|
});
|
|
171
171
|
}, [
|
|
172
|
-
|
|
172
|
+
W,
|
|
173
173
|
l,
|
|
174
174
|
w
|
|
175
175
|
]);
|
|
176
176
|
let fn = nt({
|
|
177
177
|
values: w,
|
|
178
|
-
errors:
|
|
178
|
+
errors: Ot,
|
|
179
179
|
lockSchedule: sn,
|
|
180
180
|
messages: l,
|
|
181
181
|
onChange: cn,
|
|
182
182
|
onClearErrors: ln,
|
|
183
183
|
onRevalidateErrors: dn
|
|
184
|
-
}),
|
|
184
|
+
}), q = fn.reset, pn = d((e) => T((t) => ({
|
|
185
185
|
...t,
|
|
186
186
|
...e
|
|
187
|
-
})), []),
|
|
187
|
+
})), []), J = ft.isPending || pt.isPending || mt.isPending || ht.isPending || gt.isPending, mn = it({
|
|
188
188
|
open: x,
|
|
189
189
|
isInvoice: w.type === "invoice",
|
|
190
|
-
disabled:
|
|
190
|
+
disabled: J,
|
|
191
191
|
paymentTermsId: w.paymentTermsId,
|
|
192
192
|
paymentTermsCustomDate: w.paymentTermsCustomDate,
|
|
193
193
|
paymentReminderId: w.paymentReminderId,
|
|
@@ -195,40 +195,40 @@ function ct({ messages: l, counterpartMessageLabels: ct, embeddedBankName: lt, o
|
|
|
195
195
|
messages: l,
|
|
196
196
|
onSelect: pn
|
|
197
197
|
}), hn = mn.reset, gn = d(() => {
|
|
198
|
-
b.current = [],
|
|
198
|
+
b.current = [], Nt(void 0), St("create"), wt(void 0), Et(void 0), K.current = void 0, y.current = void 0, g.current = "draft", _.current = !1, v.current = !1, T(Me()), D(!1), O({}), Pt(!1), I(!1), F.current = {
|
|
199
199
|
lines: !1,
|
|
200
200
|
discount: !1
|
|
201
|
-
},
|
|
202
|
-
}, [
|
|
203
|
-
nn(), an(),
|
|
201
|
+
}, V(), q();
|
|
202
|
+
}, [V, q]), _n = d((e = "invoice", { customerId: t = "" } = {}) => {
|
|
203
|
+
nn(), an(), q();
|
|
204
204
|
let n = {
|
|
205
205
|
...Me(),
|
|
206
206
|
type: e,
|
|
207
207
|
customerId: t
|
|
208
208
|
};
|
|
209
|
-
hn(He(n)), b.current = [], y.current = void 0, g.current = "draft", _.current = !1, v.current = !1,
|
|
209
|
+
hn(He(n)), b.current = [], y.current = void 0, g.current = "draft", _.current = !1, v.current = !1, K.current = void 0, Nt(void 0), St("create"), wt(void 0), Et(void 0), E.current = n, T(n), D(!1), O({}), V(), Pt(!1), I(!1), F.current = {
|
|
210
210
|
lines: !1,
|
|
211
211
|
discount: !1
|
|
212
212
|
}, S(!0);
|
|
213
213
|
}, [
|
|
214
|
-
|
|
214
|
+
V,
|
|
215
215
|
nn,
|
|
216
216
|
an,
|
|
217
|
-
|
|
217
|
+
q,
|
|
218
218
|
hn
|
|
219
219
|
]), vn = d((e, { highlightForIssue: t = !1 } = {}) => {
|
|
220
220
|
if (e.type === "credit_note") return;
|
|
221
|
-
nn(), an(),
|
|
221
|
+
nn(), an(), q();
|
|
222
222
|
let n = Le(e, A);
|
|
223
|
-
hn(He(n)), b.current = e.line_items,
|
|
223
|
+
hn(He(n)), b.current = e.line_items, xt.current = e.currency, y.current = void 0, g.current = t ? "issue" : "draft", _.current = !1, v.current = t, K.current = void 0, Nt(void 0), St("edit"), wt(e.id), Et(e.type === "invoice" ? e.recurrence_id ?? void 0 : void 0), E.current = n, T(n), D(!1), O({}), Pt(!1), I(!1), F.current = {
|
|
224
224
|
lines: !1,
|
|
225
225
|
discount: !1
|
|
226
|
-
},
|
|
226
|
+
}, V(), S(!0);
|
|
227
227
|
}, [
|
|
228
|
-
|
|
228
|
+
V,
|
|
229
229
|
nn,
|
|
230
230
|
an,
|
|
231
|
-
|
|
231
|
+
q,
|
|
232
232
|
hn,
|
|
233
233
|
A
|
|
234
234
|
]);
|
|
@@ -244,14 +244,14 @@ function ct({ messages: l, counterpartMessageLabels: ct, embeddedBankName: lt, o
|
|
|
244
244
|
};
|
|
245
245
|
}));
|
|
246
246
|
}, [A]);
|
|
247
|
-
let
|
|
248
|
-
|
|
249
|
-
}, [Kt,
|
|
250
|
-
if (
|
|
247
|
+
let Y = B.isUploading, X = d(() => {
|
|
248
|
+
Y || (Kt(), D(!1), S(!1), O({}));
|
|
249
|
+
}, [Kt, Y]), yn = d(() => {
|
|
250
|
+
if (Dt) {
|
|
251
251
|
D(!1);
|
|
252
252
|
return;
|
|
253
253
|
}
|
|
254
|
-
if (
|
|
254
|
+
if (Y) {
|
|
255
255
|
e.error(l.attachmentsUploading);
|
|
256
256
|
return;
|
|
257
257
|
}
|
|
@@ -259,16 +259,16 @@ function ct({ messages: l, counterpartMessageLabels: ct, embeddedBankName: lt, o
|
|
|
259
259
|
D(!0);
|
|
260
260
|
return;
|
|
261
261
|
}
|
|
262
|
-
|
|
262
|
+
X();
|
|
263
263
|
}, [
|
|
264
|
+
X,
|
|
264
265
|
Y,
|
|
265
|
-
J,
|
|
266
266
|
l.attachmentsUploading,
|
|
267
|
-
|
|
267
|
+
Dt,
|
|
268
268
|
w
|
|
269
269
|
]), bn = d((e) => {
|
|
270
270
|
let t = { ...e };
|
|
271
|
-
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" && Kt(), 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 && (Ft.current = !0), T((e) => {
|
|
272
272
|
let n = {
|
|
273
273
|
...t.customerId === void 0 ? e : st(e, t.customerId),
|
|
274
274
|
...t
|
|
@@ -282,8 +282,8 @@ function ct({ messages: l, counterpartMessageLabels: ct, embeddedBankName: lt, o
|
|
|
282
282
|
currency: n.currency
|
|
283
283
|
})), n;
|
|
284
284
|
});
|
|
285
|
-
}, [Kt, M]), xn = d(() =>
|
|
286
|
-
|
|
285
|
+
}, [Kt, M]), xn = d(() => I(!0), []), Sn = d(() => {
|
|
286
|
+
I(!1), N.current = !0, T((e) => ({
|
|
287
287
|
...e,
|
|
288
288
|
discount: we({
|
|
289
289
|
value: e.discount,
|
|
@@ -292,45 +292,45 @@ function ct({ messages: l, counterpartMessageLabels: ct, embeddedBankName: lt, o
|
|
|
292
292
|
})
|
|
293
293
|
}));
|
|
294
294
|
}, []), Cn = d(() => {
|
|
295
|
-
|
|
295
|
+
P.current = !0, T((e) => {
|
|
296
296
|
let t = c(e.taxRate);
|
|
297
297
|
return t === e.taxRate ? e : {
|
|
298
298
|
...e,
|
|
299
299
|
taxRate: t
|
|
300
300
|
};
|
|
301
301
|
});
|
|
302
|
-
}, []),
|
|
303
|
-
t && (
|
|
302
|
+
}, []), Z = d((e, { validate: t }) => {
|
|
303
|
+
t && (Ft.current = !0), T((t) => ({
|
|
304
304
|
...t,
|
|
305
305
|
lineItems: e(t.lineItems)
|
|
306
306
|
}));
|
|
307
307
|
}, []);
|
|
308
308
|
f(() => {
|
|
309
|
-
let e =
|
|
310
|
-
if (!e && !t && !
|
|
311
|
-
|
|
312
|
-
let n = _.current ||
|
|
309
|
+
let e = Ft.current, t = N.current;
|
|
310
|
+
if (!e && !t && !P.current) return;
|
|
311
|
+
Ft.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, {
|
|
313
313
|
currency: w.currency,
|
|
314
314
|
messages: l,
|
|
315
315
|
requireComplete: n
|
|
316
316
|
}) : void 0;
|
|
317
317
|
O((t) => {
|
|
318
318
|
let i = { ...t };
|
|
319
|
-
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;
|
|
320
320
|
});
|
|
321
321
|
}, [
|
|
322
|
-
|
|
322
|
+
W,
|
|
323
323
|
l,
|
|
324
324
|
w
|
|
325
325
|
]);
|
|
326
326
|
let wn = d((e, t) => {
|
|
327
327
|
let { unit: n, ...r } = t, i = se(r);
|
|
328
|
-
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 ? {
|
|
329
329
|
...t,
|
|
330
330
|
...i
|
|
331
331
|
} : t), { validate: M });
|
|
332
|
-
}, [
|
|
333
|
-
|
|
332
|
+
}, [Z, M]), Tn = d((e, t) => {
|
|
333
|
+
Z((n) => n.map((n) => n.id === e ? {
|
|
334
334
|
...n,
|
|
335
335
|
...ie({
|
|
336
336
|
product: t,
|
|
@@ -339,15 +339,15 @@ function ct({ messages: l, counterpartMessageLabels: ct, embeddedBankName: lt, o
|
|
|
339
339
|
})
|
|
340
340
|
} : n), { validate: !0 });
|
|
341
341
|
}, [
|
|
342
|
-
|
|
342
|
+
Z,
|
|
343
343
|
j,
|
|
344
344
|
w.currency
|
|
345
345
|
]), En = d((e, t) => {
|
|
346
|
-
t &&
|
|
346
|
+
t && Z((n) => t.kind === "remove" ? n.filter((t) => t.id !== e) : n.map((n) => n.id === e ? {
|
|
347
347
|
...n,
|
|
348
348
|
...t.patch
|
|
349
349
|
} : n), { validate: !0 });
|
|
350
|
-
}, [
|
|
350
|
+
}, [Z]), Dn = d((e, t) => {
|
|
351
351
|
let n = w.lineItems.find((t) => t.id === e);
|
|
352
352
|
n && En(e, s({
|
|
353
353
|
lineItem: n,
|
|
@@ -368,32 +368,32 @@ function ct({ messages: l, counterpartMessageLabels: ct, embeddedBankName: lt, o
|
|
|
368
368
|
}));
|
|
369
369
|
}, [En, w.lineItems]), kn = d(() => {
|
|
370
370
|
let e = ne(w.currency);
|
|
371
|
-
|
|
371
|
+
Nt(e.id), T((t) => ({
|
|
372
372
|
...t,
|
|
373
373
|
lineItems: [...t.lineItems, e]
|
|
374
374
|
}));
|
|
375
375
|
}, [w.currency]), An = d((e) => {
|
|
376
|
-
|
|
377
|
-
}, [
|
|
376
|
+
Z((t) => t.length <= 1 ? t : t.filter((t) => t.id !== e), { validate: !0 });
|
|
377
|
+
}, [Z]), jn = d((e, t) => e.type === "invoice" && (t === "issue" || Ce(e) && W === 0), [W]), Mn = d((e, t) => ({
|
|
378
378
|
...Be({
|
|
379
379
|
values: e,
|
|
380
|
-
billingAddressId:
|
|
380
|
+
billingAddressId: L,
|
|
381
381
|
messages: l,
|
|
382
382
|
willIssue: t,
|
|
383
|
-
hasStartedRecurrence:
|
|
383
|
+
hasStartedRecurrence: W > 0
|
|
384
384
|
}),
|
|
385
385
|
...e.type === "invoice" && u(e) ? Se({
|
|
386
386
|
fields: e,
|
|
387
|
-
issuedCount:
|
|
387
|
+
issuedCount: W,
|
|
388
388
|
messages: l
|
|
389
389
|
}) : {}
|
|
390
390
|
}), [
|
|
391
|
-
|
|
392
|
-
|
|
391
|
+
L,
|
|
392
|
+
W,
|
|
393
393
|
l
|
|
394
|
-
]),
|
|
394
|
+
]), Nn = d(() => {
|
|
395
395
|
requestAnimationFrame(() => {
|
|
396
|
-
let e =
|
|
396
|
+
let e = bt.current, t = e?.querySelector("[aria-invalid=\"true\"], [data-invalid=\"true\"]");
|
|
397
397
|
if (!e || !t) return;
|
|
398
398
|
let n = t.getBoundingClientRect().top - e.getBoundingClientRect().top + e.scrollTop;
|
|
399
399
|
e.scrollTo({
|
|
@@ -401,36 +401,36 @@ function ct({ messages: l, counterpartMessageLabels: ct, embeddedBankName: lt, o
|
|
|
401
401
|
behavior: "smooth"
|
|
402
402
|
});
|
|
403
403
|
});
|
|
404
|
-
}, []),
|
|
405
|
-
O(e),
|
|
404
|
+
}, []), Pn = d((e, t) => {
|
|
405
|
+
O(e), Pt(!0), _.current = t, F.current = {
|
|
406
406
|
lines: !0,
|
|
407
407
|
discount: !0
|
|
408
|
-
},
|
|
409
|
-
}, [
|
|
408
|
+
}, Nn();
|
|
409
|
+
}, [Nn]), Fn = !Tt || w.frequency !== "once" || on.isError;
|
|
410
410
|
f(() => {
|
|
411
|
-
if (!x || !v.current ||
|
|
411
|
+
if (!x || !v.current || R || G || !Fn) return;
|
|
412
412
|
v.current = !1;
|
|
413
|
-
let e =
|
|
414
|
-
|
|
413
|
+
let e = jn(w, "issue");
|
|
414
|
+
Pn(Mn(w, e), e);
|
|
415
415
|
}, [
|
|
416
|
-
|
|
416
|
+
R,
|
|
417
417
|
x,
|
|
418
|
+
Fn,
|
|
419
|
+
G,
|
|
418
420
|
Pn,
|
|
419
|
-
|
|
420
|
-
Nn,
|
|
421
|
-
jn,
|
|
421
|
+
Mn,
|
|
422
422
|
w,
|
|
423
|
-
|
|
423
|
+
jn
|
|
424
424
|
]);
|
|
425
|
-
let
|
|
425
|
+
let In = m({
|
|
426
426
|
values: w,
|
|
427
|
-
billingAddressId:
|
|
427
|
+
billingAddressId: L
|
|
428
428
|
});
|
|
429
429
|
f(() => {
|
|
430
|
-
let e =
|
|
431
|
-
if (
|
|
430
|
+
let e = In.current;
|
|
431
|
+
if (In.current = {
|
|
432
432
|
values: w,
|
|
433
|
-
billingAddressId:
|
|
433
|
+
billingAddressId: L
|
|
434
434
|
}, !M) return;
|
|
435
435
|
let t = [
|
|
436
436
|
"customerId",
|
|
@@ -441,11 +441,11 @@ function ct({ messages: l, counterpartMessageLabels: ct, embeddedBankName: lt, o
|
|
|
441
441
|
"openingNote",
|
|
442
442
|
"closingNote",
|
|
443
443
|
"taxRate"
|
|
444
|
-
].filter((t) => e.values[t] !== w[t] || t === "customerId" && e.billingAddressId !==
|
|
444
|
+
].filter((t) => e.values[t] !== w[t] || t === "customerId" && e.billingAddressId !== L || t === "paymentTermsId" && e.values.paymentTermsCustomDate !== w.paymentTermsCustomDate);
|
|
445
445
|
if (!t.length) return;
|
|
446
446
|
let n = Be({
|
|
447
447
|
values: w,
|
|
448
|
-
billingAddressId:
|
|
448
|
+
billingAddressId: L,
|
|
449
449
|
messages: l,
|
|
450
450
|
willIssue: _.current
|
|
451
451
|
});
|
|
@@ -456,18 +456,18 @@ function ct({ messages: l, counterpartMessageLabels: ct, embeddedBankName: lt, o
|
|
|
456
456
|
}), r;
|
|
457
457
|
});
|
|
458
458
|
}, [
|
|
459
|
-
|
|
459
|
+
L,
|
|
460
460
|
l,
|
|
461
461
|
M,
|
|
462
462
|
w
|
|
463
463
|
]);
|
|
464
|
-
let
|
|
465
|
-
if (g.current = t,
|
|
466
|
-
if (
|
|
464
|
+
let Ln = d(async (t) => {
|
|
465
|
+
if (g.current = t, G) return;
|
|
466
|
+
if (Y) {
|
|
467
467
|
e.error(l.attachmentsUploading);
|
|
468
468
|
return;
|
|
469
469
|
}
|
|
470
|
-
if (k.isLoading ||
|
|
470
|
+
if (k.isLoading || R) {
|
|
471
471
|
e.error(l.lineItemsLoading);
|
|
472
472
|
return;
|
|
473
473
|
}
|
|
@@ -476,38 +476,38 @@ function ct({ messages: l, counterpartMessageLabels: ct, embeddedBankName: lt, o
|
|
|
476
476
|
lineItems: n
|
|
477
477
|
};
|
|
478
478
|
i !== w && T(i);
|
|
479
|
-
let a = i.type === "invoice" && u(i), o =
|
|
480
|
-
if (o && (Wt ||
|
|
479
|
+
let a = i.type === "invoice" && u(i), o = jn(i, t);
|
|
480
|
+
if (o && (Wt || H.isLoading)) {
|
|
481
481
|
e.error(l.issueChecksLoading);
|
|
482
482
|
return;
|
|
483
483
|
}
|
|
484
|
-
if (o && !
|
|
484
|
+
if (o && !H.canAddAccount && !i.bankAccountId && !H.hasAccounts) {
|
|
485
485
|
e.error(l.issueBankAccountUnavailable);
|
|
486
486
|
return;
|
|
487
487
|
}
|
|
488
|
-
let ee =
|
|
488
|
+
let ee = Mn(i, o);
|
|
489
489
|
if (Ne(ee)) {
|
|
490
|
-
|
|
490
|
+
Pn(ee, o);
|
|
491
491
|
return;
|
|
492
492
|
}
|
|
493
|
-
if (O({}), o &&
|
|
493
|
+
if (O({}), o && z.isTaxIdMissing) {
|
|
494
494
|
e.error(l.issueTaxIdRequired);
|
|
495
495
|
return;
|
|
496
496
|
}
|
|
497
497
|
if (o && (i.paymentReminderId || i.overdueReminderId)) {
|
|
498
|
-
let t = Ve(
|
|
498
|
+
let t = Ve(z.counterpart, l);
|
|
499
499
|
if (t) {
|
|
500
500
|
e.error(t);
|
|
501
501
|
return;
|
|
502
502
|
}
|
|
503
503
|
}
|
|
504
|
-
let s = C === "edit" ?
|
|
504
|
+
let s = C === "edit" ? Ct : y.current, c, te, ne = {};
|
|
505
505
|
try {
|
|
506
506
|
if (s) {
|
|
507
507
|
let e = Fe({
|
|
508
508
|
values: i,
|
|
509
509
|
originalLineItems: b.current,
|
|
510
|
-
originalCurrency:
|
|
510
|
+
originalCurrency: xt.current,
|
|
511
511
|
unitNamesById: j,
|
|
512
512
|
units: A
|
|
513
513
|
});
|
|
@@ -516,24 +516,24 @@ function ct({ messages: l, counterpartMessageLabels: ct, embeddedBankName: lt, o
|
|
|
516
516
|
originalLineItems: b.current,
|
|
517
517
|
changes: e
|
|
518
518
|
});
|
|
519
|
-
let t = await
|
|
519
|
+
let t = await pt.mutateAsync({
|
|
520
520
|
path: { receivable_id: s },
|
|
521
521
|
body: Ie({
|
|
522
522
|
values: i,
|
|
523
|
-
billingAddressId:
|
|
523
|
+
billingAddressId: L,
|
|
524
524
|
shippingAddressId: Ut,
|
|
525
525
|
lineItemChanges: e
|
|
526
526
|
})
|
|
527
527
|
});
|
|
528
|
-
qt(), c = s, te = t?.type ?? i.type, a && t && (b.current = t.line_items,
|
|
528
|
+
qt(), c = s, te = t?.type ?? i.type, a && t && (b.current = t.line_items, xt.current = t.currency, i = {
|
|
529
529
|
...i,
|
|
530
530
|
lineItems: ae(i.lineItems, t.line_items)
|
|
531
531
|
}, T(i));
|
|
532
532
|
} else {
|
|
533
533
|
ne = ze({ values: i });
|
|
534
|
-
let e = await
|
|
534
|
+
let e = await ft.mutateAsync({ body: Pe({
|
|
535
535
|
values: i,
|
|
536
|
-
billingAddressId:
|
|
536
|
+
billingAddressId: L,
|
|
537
537
|
shippingAddressId: Ut,
|
|
538
538
|
unitNamesById: j
|
|
539
539
|
}) });
|
|
@@ -541,7 +541,7 @@ function ct({ messages: l, counterpartMessageLabels: ct, embeddedBankName: lt, o
|
|
|
541
541
|
S(!1), gn();
|
|
542
542
|
return;
|
|
543
543
|
}
|
|
544
|
-
c = e.id, te = e.type, a && (y.current = e.id, b.current = e.line_items,
|
|
544
|
+
c = e.id, te = e.type, a && (y.current = e.id, b.current = e.line_items, xt.current = e.currency, i = {
|
|
545
545
|
...i,
|
|
546
546
|
lineItems: ae(i.lineItems, e.line_items)
|
|
547
547
|
}, T(i));
|
|
@@ -553,7 +553,7 @@ function ct({ messages: l, counterpartMessageLabels: ct, embeddedBankName: lt, o
|
|
|
553
553
|
});
|
|
554
554
|
e.error((s ? l.updateFailed : l.createFailed).replace("{errorMessage}", r));
|
|
555
555
|
let { errors: a, listError: ee } = Ze($e(t, n), ne), c = de(a.lineItems, void 0, ee);
|
|
556
|
-
|
|
556
|
+
Pn({
|
|
557
557
|
...a,
|
|
558
558
|
...c ? { lineItemsSummary: c } : {}
|
|
559
559
|
}, o);
|
|
@@ -561,100 +561,101 @@ function ct({ messages: l, counterpartMessageLabels: ct, embeddedBankName: lt, o
|
|
|
561
561
|
}
|
|
562
562
|
let re = a ? "recurrence" : "draft";
|
|
563
563
|
if (a) try {
|
|
564
|
-
|
|
565
|
-
path: { recurrence_id:
|
|
564
|
+
U ? await ht.mutateAsync({
|
|
565
|
+
path: { recurrence_id: U.id },
|
|
566
566
|
body: ye(i, { lockSchedule: sn })
|
|
567
|
-
}) : await
|
|
567
|
+
}) : await mt.mutateAsync({ body: ve(i, c) });
|
|
568
568
|
} catch (t) {
|
|
569
569
|
e.error(Qe(t, { messages: l }));
|
|
570
570
|
return;
|
|
571
571
|
}
|
|
572
572
|
else if (o) try {
|
|
573
|
-
await
|
|
573
|
+
await gt.mutateAsync({ path: { receivable_id: c } }), re = "issue";
|
|
574
574
|
} catch {
|
|
575
575
|
e.error(l.issueFailedAfterSave);
|
|
576
576
|
}
|
|
577
|
-
let ie = C === "create";
|
|
578
|
-
S(!1), gn(), ie
|
|
577
|
+
let ie = C === "create" ? ut : dt;
|
|
578
|
+
S(!1), gn(), ie?.(c, te, {
|
|
579
579
|
mode: re,
|
|
580
580
|
counterpartId: i.customerId,
|
|
581
581
|
inlineItems: _e(i.lineItems, i.currency),
|
|
582
|
-
hasCustomerEmail: !!(
|
|
582
|
+
hasCustomerEmail: !!(z.counterpart && r(z.counterpart).trim())
|
|
583
583
|
});
|
|
584
584
|
}, [
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
I,
|
|
589
|
-
qt,
|
|
590
|
-
dt,
|
|
591
|
-
pt,
|
|
592
|
-
St,
|
|
593
|
-
H,
|
|
585
|
+
H.canAddAccount,
|
|
586
|
+
H.hasAccounts,
|
|
587
|
+
H.isLoading,
|
|
594
588
|
L,
|
|
595
|
-
|
|
589
|
+
qt,
|
|
590
|
+
ft,
|
|
591
|
+
mt,
|
|
592
|
+
Ct,
|
|
593
|
+
U,
|
|
594
|
+
R,
|
|
595
|
+
Y,
|
|
596
596
|
Wt,
|
|
597
|
-
|
|
597
|
+
gt,
|
|
598
598
|
sn,
|
|
599
599
|
l,
|
|
600
600
|
C,
|
|
601
601
|
ut,
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
602
|
+
dt,
|
|
603
|
+
z.counterpart,
|
|
604
|
+
z.isTaxIdMissing,
|
|
605
|
+
G,
|
|
605
606
|
gn,
|
|
606
607
|
Ut,
|
|
607
|
-
|
|
608
|
+
Pn,
|
|
608
609
|
A,
|
|
609
610
|
j,
|
|
610
611
|
k.isLoading,
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
612
|
+
pt,
|
|
613
|
+
ht,
|
|
614
|
+
Mn,
|
|
614
615
|
w,
|
|
615
|
-
|
|
616
|
+
jn
|
|
616
617
|
]), Q = d(async (e = g.current) => {
|
|
617
|
-
if (!
|
|
618
|
-
|
|
618
|
+
if (!_t.current) {
|
|
619
|
+
_t.current = !0, yt(e);
|
|
619
620
|
try {
|
|
620
|
-
await
|
|
621
|
+
await Ln(e);
|
|
621
622
|
} finally {
|
|
622
|
-
|
|
623
|
+
_t.current = !1, yt(void 0);
|
|
623
624
|
}
|
|
624
625
|
}
|
|
625
|
-
}, [
|
|
626
|
+
}, [Ln]), Rn = p(() => ({
|
|
626
627
|
...w,
|
|
627
628
|
discount: It ? w.discount : Te(Ee(w.discount, w.discountType, w.currency), w.discountType, w.currency),
|
|
628
629
|
lineItems: w.lineItems.map(fe)
|
|
629
|
-
}), [It, w]),
|
|
630
|
+
}), [It, w]), zn = p(() => ee(w.lineItems), [w.lineItems]), Bn = p(() => ke(w), [w]), Vn = w.type === "invoice", Hn = Vn && u(w), Un = J || k.isLoading || R || B.isUploading || G, Wn = C === "edit" ? l.updateDraftButton : l.saveDraftButton, Gn = Hn ? U ? l.recurrenceUpdateButton : l.recurrenceActivateButton : Vn ? l.issueButton : Wn, $ = Vn && !Hn ? "issue" : "draft", Kn = d(() => Q("draft"), [Q]), qn = d(() => Q($), [$, Q]), Jn = d(() => Q(), [Q]), Yn = d(() => {
|
|
630
631
|
g.current = "draft";
|
|
631
|
-
}, []),
|
|
632
|
+
}, []), Xn = d(() => {
|
|
632
633
|
g.current = $;
|
|
633
|
-
}, [$]),
|
|
634
|
-
if (!
|
|
634
|
+
}, [$]), Zn = Un || Hn, Qn = d(async () => {
|
|
635
|
+
if (!Zn) try {
|
|
635
636
|
await Q("draft");
|
|
636
637
|
} finally {
|
|
637
638
|
D(!1);
|
|
638
639
|
}
|
|
639
|
-
}, [
|
|
640
|
-
open:
|
|
641
|
-
onSaveDraft: () => void
|
|
642
|
-
onDiscard:
|
|
643
|
-
onCancel:
|
|
644
|
-
isSaving:
|
|
645
|
-
isSaveDraftDisabled:
|
|
640
|
+
}, [Zn, Q]), $n = d(() => D(!1), []), er = p(() => ({
|
|
641
|
+
open: Dt,
|
|
642
|
+
onSaveDraft: () => void Qn(),
|
|
643
|
+
onDiscard: X,
|
|
644
|
+
onCancel: $n,
|
|
645
|
+
isSaving: J,
|
|
646
|
+
isSaveDraftDisabled: Zn
|
|
646
647
|
}), [
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
Xn,
|
|
648
|
+
$n,
|
|
649
|
+
X,
|
|
650
|
+
J,
|
|
651
651
|
Zn,
|
|
652
|
-
|
|
653
|
-
|
|
652
|
+
Qn,
|
|
653
|
+
Dt
|
|
654
|
+
]), tr = p(() => Oe(Bn, w.currency), [Bn, w.currency]), nr = at({
|
|
654
655
|
values: w,
|
|
655
|
-
totals:
|
|
656
|
+
totals: Bn,
|
|
656
657
|
billingAddress: Ht,
|
|
657
|
-
bankAccount:
|
|
658
|
+
bankAccount: H.selectedAccount,
|
|
658
659
|
unitNamesById: j,
|
|
659
660
|
messages: l,
|
|
660
661
|
enabled: x
|
|
@@ -664,8 +665,8 @@ function ct({ messages: l, counterpartMessageLabels: ct, embeddedBankName: lt, o
|
|
|
664
665
|
setOpen: S,
|
|
665
666
|
mode: C,
|
|
666
667
|
values: w,
|
|
667
|
-
sheetValues:
|
|
668
|
-
errors:
|
|
668
|
+
sheetValues: Rn,
|
|
669
|
+
errors: Ot,
|
|
669
670
|
setValues: T,
|
|
670
671
|
updateValues: bn,
|
|
671
672
|
commitTaxRate: Cn,
|
|
@@ -678,52 +679,52 @@ function ct({ messages: l, counterpartMessageLabels: ct, embeddedBankName: lt, o
|
|
|
678
679
|
addLineItem: kn,
|
|
679
680
|
removeLineItem: An,
|
|
680
681
|
attachmentsView: Jt,
|
|
681
|
-
attachmentsUploading:
|
|
682
|
-
draftButtonLabel:
|
|
683
|
-
draftDisabled:
|
|
684
|
-
draftLoading:
|
|
685
|
-
primaryButtonLabel:
|
|
686
|
-
primaryLoading:
|
|
687
|
-
primaryDisabled:
|
|
688
|
-
scrollContainerRef:
|
|
689
|
-
selectAttachmentFiles:
|
|
690
|
-
setAttachmentIncludeInEmail:
|
|
691
|
-
removeAttachment:
|
|
692
|
-
autoFocusLineItemId:
|
|
693
|
-
lineItemUnitOptions:
|
|
682
|
+
attachmentsUploading: B.isUploading,
|
|
683
|
+
draftButtonLabel: Vn && !Hn ? Wn : void 0,
|
|
684
|
+
draftDisabled: Un,
|
|
685
|
+
draftLoading: J && vt === "draft",
|
|
686
|
+
primaryButtonLabel: Gn,
|
|
687
|
+
primaryLoading: J && vt === $,
|
|
688
|
+
primaryDisabled: Un || H.isLoading && jn(w, $) || Vn && (Wt || !Hn && z.isCounterpartLoading),
|
|
689
|
+
scrollContainerRef: bt,
|
|
690
|
+
selectAttachmentFiles: B.selectFiles,
|
|
691
|
+
setAttachmentIncludeInEmail: B.setIncludeInEmail,
|
|
692
|
+
removeAttachment: B.remove,
|
|
693
|
+
autoFocusLineItemId: Mt,
|
|
694
|
+
lineItemUnitOptions: jt.unitOptions,
|
|
694
695
|
lineItemsLoading: k.isLoading,
|
|
695
|
-
lineItemControls:
|
|
696
|
-
totals:
|
|
697
|
-
preview:
|
|
698
|
-
totalsView:
|
|
696
|
+
lineItemControls: zn,
|
|
697
|
+
totals: Bn,
|
|
698
|
+
preview: nr,
|
|
699
|
+
totalsView: tr,
|
|
699
700
|
currencySymbol: re(w.currency),
|
|
700
|
-
isSubmitting:
|
|
701
|
+
isSubmitting: J,
|
|
701
702
|
paymentTerms: tn,
|
|
702
703
|
showBillingSection: w.type === "invoice" || C === "edit",
|
|
703
704
|
purchaseOrder: C === "create" ? {
|
|
704
705
|
value: w.purchaseOrder,
|
|
705
|
-
error:
|
|
706
|
+
error: Ot.purchaseOrder
|
|
706
707
|
} : void 0,
|
|
707
708
|
recurrence: fn,
|
|
708
709
|
showRecurrenceSection: w.type === "invoice",
|
|
709
|
-
recurrenceLoading:
|
|
710
|
+
recurrenceLoading: G,
|
|
710
711
|
showDueDateField: w.type === "quote",
|
|
711
712
|
openCreate: _n,
|
|
712
713
|
openEdit: vn,
|
|
713
|
-
close:
|
|
714
|
+
close: X,
|
|
714
715
|
requestClose: yn,
|
|
715
|
-
unsavedPrompt:
|
|
716
|
-
submit:
|
|
717
|
-
submitDraft:
|
|
718
|
-
submitPrimary:
|
|
719
|
-
selectDraftMode:
|
|
720
|
-
selectPrimaryMode:
|
|
721
|
-
units:
|
|
722
|
-
counterpartView:
|
|
716
|
+
unsavedPrompt: er,
|
|
717
|
+
submit: Jn,
|
|
718
|
+
submitDraft: Kn,
|
|
719
|
+
submitPrimary: qn,
|
|
720
|
+
selectDraftMode: Yn,
|
|
721
|
+
selectPrimaryMode: Xn,
|
|
722
|
+
units: jt,
|
|
723
|
+
counterpartView: kt,
|
|
723
724
|
counterpartForm: Xt,
|
|
724
725
|
stateOptions: Lt,
|
|
725
726
|
openCounterpartCreate: $t,
|
|
726
|
-
bankAccount:
|
|
727
|
+
bankAccount: H,
|
|
727
728
|
reminders: mn
|
|
728
729
|
};
|
|
729
730
|
}
|