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