@tesouro/embedded-components-react 0.5.214 → 0.5.216
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.d.ts +144 -3
- package/dist/index.js +14 -13
- package/dist/lib/BankAccountOnboardingWidget.d.ts +56 -2
- package/dist/lib/BankAccountOnboardingWidget.js +4 -3
- package/dist/lib/MarketingWidget.js +1 -1
- package/dist/lib/ReceivablesWidget.d.ts +88 -1
- package/dist/lib/ReceivablesWidget.js +1 -1
- package/dist/lib/WidgetSuite.d.ts +53 -0
- package/dist/libs/shared/util-validation/dist/index5.js +7 -0
- package/dist/libs/tesouro-embedded-components-react/bank-account-onboarding-widget/feature/dist/index.js +3 -2
- package/dist/libs/tesouro-embedded-components-react/bank-account-onboarding-widget/feature/dist/index11.js +72 -72
- package/dist/libs/tesouro-embedded-components-react/bank-account-onboarding-widget/feature/dist/index12.js +4 -1
- package/dist/libs/tesouro-embedded-components-react/bank-account-onboarding-widget/feature/dist/index13.js +15 -15
- package/dist/libs/tesouro-embedded-components-react/bank-account-onboarding-widget/feature/dist/index14.js +60 -60
- package/dist/libs/tesouro-embedded-components-react/bank-account-onboarding-widget/feature/dist/index15.js +12 -12
- package/dist/libs/tesouro-embedded-components-react/bank-account-onboarding-widget/feature/dist/index16.js +16 -16
- package/dist/libs/tesouro-embedded-components-react/bank-account-onboarding-widget/feature/dist/index18.js +11 -11
- package/dist/libs/tesouro-embedded-components-react/bank-account-onboarding-widget/feature/dist/index21.js +8 -8
- package/dist/libs/tesouro-embedded-components-react/bank-account-onboarding-widget/feature/dist/index22.js +71 -5
- package/dist/libs/tesouro-embedded-components-react/bank-account-onboarding-widget/feature/dist/index23.js +95 -33
- package/dist/libs/tesouro-embedded-components-react/bank-account-onboarding-widget/feature/dist/index24.js +6 -17
- package/dist/libs/tesouro-embedded-components-react/bank-account-onboarding-widget/feature/dist/index25.js +16 -616
- package/dist/libs/tesouro-embedded-components-react/bank-account-onboarding-widget/feature/dist/index26.js +669 -0
- package/dist/libs/tesouro-embedded-components-react/bank-account-onboarding-widget/ui/dist/index.js +15 -13
- package/dist/libs/tesouro-embedded-components-react/bank-account-onboarding-widget/ui/dist/index10.js +52 -37
- package/dist/libs/tesouro-embedded-components-react/bank-account-onboarding-widget/ui/dist/index11.js +31 -37
- package/dist/libs/tesouro-embedded-components-react/bank-account-onboarding-widget/ui/dist/index12.js +33 -89
- package/dist/libs/tesouro-embedded-components-react/bank-account-onboarding-widget/ui/dist/index13.js +39 -12
- package/dist/libs/tesouro-embedded-components-react/bank-account-onboarding-widget/ui/dist/index14.js +98 -2
- package/dist/libs/tesouro-embedded-components-react/bank-account-onboarding-widget/ui/dist/index15.js +14 -4
- package/dist/libs/tesouro-embedded-components-react/bank-account-onboarding-widget/ui/dist/index16.js +2 -185
- package/dist/libs/tesouro-embedded-components-react/bank-account-onboarding-widget/ui/dist/index17.js +4 -30
- package/dist/libs/tesouro-embedded-components-react/bank-account-onboarding-widget/ui/dist/index18.js +183 -21
- package/dist/libs/tesouro-embedded-components-react/bank-account-onboarding-widget/ui/dist/index19.js +26 -66
- package/dist/libs/tesouro-embedded-components-react/bank-account-onboarding-widget/ui/dist/index20.js +21 -233
- package/dist/libs/tesouro-embedded-components-react/bank-account-onboarding-widget/ui/dist/index21.js +66 -27
- package/dist/libs/tesouro-embedded-components-react/bank-account-onboarding-widget/ui/dist/index22.js +233 -26
- package/dist/libs/tesouro-embedded-components-react/bank-account-onboarding-widget/ui/dist/index23.js +27 -72
- package/dist/libs/tesouro-embedded-components-react/bank-account-onboarding-widget/ui/dist/index24.js +26 -85
- package/dist/libs/tesouro-embedded-components-react/bank-account-onboarding-widget/ui/dist/index25.js +74 -8
- package/dist/libs/tesouro-embedded-components-react/bank-account-onboarding-widget/ui/dist/index26.js +83 -55
- package/dist/libs/tesouro-embedded-components-react/bank-account-onboarding-widget/ui/dist/index27.js +6 -7
- package/dist/libs/tesouro-embedded-components-react/bank-account-onboarding-widget/ui/dist/index28.js +37 -42
- package/dist/libs/tesouro-embedded-components-react/bank-account-onboarding-widget/ui/dist/index29.js +11 -0
- package/dist/libs/tesouro-embedded-components-react/bank-account-onboarding-widget/ui/dist/index30.js +64 -0
- package/dist/libs/tesouro-embedded-components-react/bank-account-onboarding-widget/ui/dist/index9.js +7 -33
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index.js +7 -7
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index10.js +63 -67
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index11.js +160 -1
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index12.js +6 -0
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index2.js +32 -25
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index6.js +25 -200
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index7.js +175 -1
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index8.js +1 -101
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index9.js +92 -71
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index.js +1 -1
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index10.js +44 -100
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index11.js +93 -421
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index12.js +442 -112
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index13.js +166 -157
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index14.js +150 -204
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index15.js +202 -31
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index16.js +32 -145
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index17.js +145 -37
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index18.js +44 -58
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index19.js +113 -87
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index20.js +58 -116
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index21.js +83 -357
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index22.js +111 -65
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index23.js +449 -99
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index24.js +68 -281
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index25.js +115 -0
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index26.js +314 -0
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index5.js +1 -1
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index6.js +34 -23
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index8.js +444 -92
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index9.js +113 -52
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index.js +18 -14
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index10.js +2 -92
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index11.js +95 -3
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index12.js +3 -24
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index13.js +24 -1
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index14.js +1 -3
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index15.js +1 -1
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index16.js +3 -18
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index17.js +18 -1
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index18.js +0 -3
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index19.js +0 -8
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index20.js +11 -0
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index21.js +1 -264
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index22.js +258 -42
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index23.js +38 -62
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index24.js +61 -463
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index25.js +457 -89
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index26.js +91 -234
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index27.js +89 -82
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index28.js +22 -338
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index29.js +236 -0
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index3.js +26 -204
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index30.js +3 -0
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index31.js +249 -0
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index32.js +93 -0
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index33.js +344 -0
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index4.js +208 -32
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index5.js +29 -202
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index6.js +183 -137
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index7.js +157 -12
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index8.js +10 -19
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index9.js +23 -2
- package/dist/libs/tesouro-embedded-components-react/marketing-widget/feature/dist/index.js +1 -1
- package/dist/libs/tesouro-embedded-components-react/marketing-widget/feature/dist/index5.js +16 -19
- package/dist/libs/tesouro-embedded-components-react/marketing-widget/feature/dist/index6.js +157 -16
- package/dist/libs/tesouro-embedded-components-react/shared/data-access/dist/index.js +40 -40
- package/dist/libs/tesouro-embedded-components-react/shared/data-access/dist/lib/onboardingSuppressionReason.js +3 -1
- package/dist/libs/tesouro-embedded-components-react/shared/data-access/dist/lib/rest/@tanstack/react-query.gen.js +167 -156
- package/dist/libs/tesouro-embedded-components-react/shared/data-access/dist/lib/rest/sdk.gen.js +66 -34
- package/dist/libs/tesouro-embedded-components-react/shared/feature/dist/index.js +2 -1
- 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/application/bankAccountApplication.js +26 -0
- package/dist/libs/tesouro-embedded-components-react/widget-suite/feature/dist/index16.js +1 -1
- package/dist/packages/shared-ui-shadcn/dist/index.js +13 -13
- package/package.json +1 -1
- package/dist/libs/tesouro-embedded-components-react/marketing-widget/feature/dist/index7.js +0 -161
package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index23.js
CHANGED
|
@@ -2,114 +2,464 @@
|
|
|
2
2
|
"use client";
|
|
3
3
|
"use client";
|
|
4
4
|
"use client";
|
|
5
|
-
import {
|
|
6
|
-
import "../../../shared/
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import
|
|
11
|
-
import
|
|
12
|
-
import
|
|
5
|
+
import { getStateOptions as e } from "../../../shared/util/dist/lib/usStates.js";
|
|
6
|
+
import { extractApiErrorMessage as t } from "../../../shared/util/dist/lib/apiErrors.js";
|
|
7
|
+
import { COUNTERPART_MESSAGE_LABELS_EN as n } from "../../../shared/counterpart-management/feature/dist/lib/labels.js";
|
|
8
|
+
import { useCounterpartAddressesQuery as r } from "../../../shared/counterpart-management/data-access/dist/index7.js";
|
|
9
|
+
import { useCounterpartForm as i } from "../../../shared/counterpart-management/feature/dist/lib/useCounterpartForm.js";
|
|
10
|
+
import "../../../shared/counterpart-management/feature/dist/index.js";
|
|
11
|
+
import "../../ui/dist/index10.js";
|
|
12
|
+
import "../../ui/dist/index.js";
|
|
13
|
+
import { buildLineItemControls as a, commitLineItemField as ee, commitTaxRateInput as te, convertPriceInput as ne, createLineItem as re, getCurrencySymbol as ie, lineItemFromProduct as ae, reconcileLineItemIds as oe, reconcileMeasureUnits as se, sanitizeLineItemPatch as ce, sanitizeTaxRateInput as le, stepLineItemQuantity as ue, stripBlankLineItems as de, summarizeLineItemErrors as fe, toSheetLineItem as pe, validateLineItems as me } from "./index6.js";
|
|
14
|
+
import { buildReceivableAttachmentsView as he } from "./index7.js";
|
|
15
|
+
import { buildCreateRecurrencePayload as ge, buildUpdateRecurrencePayload as _e, clearRecurrenceRecipients as ve, countIssuedIterations as ye, isRecurring as o, recurrenceToFormFields as be, validateRecurrence as xe } from "./index8.js";
|
|
16
|
+
import { convertDiscountInput as Se, decorateDiscountInput as Ce, discountInputToMinorUnits as we, sanitizeDiscountInput as Te } from "./index10.js";
|
|
17
|
+
import { buildFormTotalsView as Ee, calculateFormTotals as De, validateDiscount as Oe, validateInvoiceTotals as ke } from "./index11.js";
|
|
18
|
+
import { createEmptyReceivableFormValues as Ae, hasReceivableFormErrors as je, receivableFormValuesToCreatePayload as Me, receivableFormValuesToLineItemChanges as Ne, receivableFormValuesToUpdatePayload as Pe, receivableToFormValues as Fe, validateReceivableForm as Ie } from "./index12.js";
|
|
19
|
+
import { shouldShowRemindersInitially as Le } from "./index14.js";
|
|
20
|
+
import { useCreateReceivableMutation as Re, useUpdateReceivableMutation as ze } from "../../data-access/dist/index7.js";
|
|
21
|
+
import { useCreateRecurrenceMutation as Be, useRecurrenceQuery as Ve, useUpdateRecurrenceMutation as He } from "../../data-access/dist/index11.js";
|
|
22
|
+
import "../../data-access/dist/index.js";
|
|
23
|
+
import { useReceivableAttachmentUploads as Ue } from "./index17.js";
|
|
24
|
+
import { useReceivablePaymentTerms as We } from "./index18.js";
|
|
25
|
+
import { useReceivableRecurrence as Ge } from "./index19.js";
|
|
26
|
+
import { useReceivableBankAccount as Ke } from "./index21.js";
|
|
27
|
+
import { useReceivableReminders as qe } from "./index22.js";
|
|
28
|
+
import { getCurrencyOptions as Je } from "../../../shared/product-catalog/feature/dist/lib/helpers.js";
|
|
29
|
+
import { useMeasureUnitsQuery as Ye } from "../../../shared/product-catalog/data-access/dist/index9.js";
|
|
30
|
+
import { useMeasureUnits as Xe } from "../../../shared/product-catalog/feature/dist/lib/useMeasureUnits.js";
|
|
13
31
|
import "../../../shared/product-catalog/feature/dist/index.js";
|
|
14
|
-
import {
|
|
15
|
-
import { useReceivablesTable as d } from "./index22.js";
|
|
16
|
-
import { useCallback as f, useEffect as p, useMemo as m, useState as h } from "react";
|
|
32
|
+
import { useCallback as s, useEffect as c, useMemo as l, useRef as u, useState as d } from "react";
|
|
17
33
|
//#region ../../libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index23.js
|
|
18
|
-
function
|
|
19
|
-
let C =
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
}, [
|
|
23
|
-
|
|
24
|
-
...
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
})), [O, k] = h(), [A, j] = h(!1);
|
|
30
|
-
p(() => {
|
|
31
|
-
T.includes(E) || D(r({
|
|
32
|
-
defaultTab: _,
|
|
33
|
-
enabledTabs: T
|
|
34
|
+
function f({ messages: f, counterpartMessageLabels: Ze, embeddedBankName: Qe, onCreated: $e }) {
|
|
35
|
+
let p = Re(), m = ze(), et = Be(), tt = He(), h = u(void 0), g = u([]), _ = u(""), [v, y] = d(!1), [b, nt] = d("create"), [rt, it] = d(), [at, x] = d(), [S, C] = d(() => Ae()), [ot, w] = d({}), [st, ct] = d("none"), T = Xe(), E = Ye(), D = E.data?.data, { unitNamesById: O } = T, [lt, k] = d(), [A, j] = d(!1), M = u(!1), N = u(!1), P = u(!1), F = u({
|
|
36
|
+
lines: !1,
|
|
37
|
+
discount: !1
|
|
38
|
+
}), [ut, I] = d(!1), dt = l(() => e(), []), ft = l(() => ({
|
|
39
|
+
...n,
|
|
40
|
+
...Ze
|
|
41
|
+
}), [Ze]), pt = r(S.customerId), mt = pt.data?.data?.[0], L = pt.data?.data?.[0]?.id, ht = s((e) => {
|
|
42
|
+
C((t) => ({
|
|
43
|
+
...t,
|
|
44
|
+
attachments: e(t.attachments)
|
|
34
45
|
}));
|
|
46
|
+
}, []), R = Ue({
|
|
47
|
+
attachments: S.attachments,
|
|
48
|
+
setAttachments: ht,
|
|
49
|
+
receivableId: rt
|
|
50
|
+
}), { reset: z, discardUploads: B, commitRemovals: gt } = R, _t = S.type === "invoice" ? he({
|
|
51
|
+
attachments: S.attachments,
|
|
52
|
+
pendingUploads: R.pendingUploads,
|
|
53
|
+
isCountLimitReached: R.isCountLimitReached,
|
|
54
|
+
isRecurring: o(S),
|
|
55
|
+
messages: f
|
|
56
|
+
}) : void 0, vt = s((e) => {
|
|
57
|
+
C((t) => {
|
|
58
|
+
let n = e ?? "";
|
|
59
|
+
return n === t.customerId ? t : ve({
|
|
60
|
+
...t,
|
|
61
|
+
customerId: n
|
|
62
|
+
});
|
|
63
|
+
});
|
|
64
|
+
}, []), yt = i({
|
|
65
|
+
view: st,
|
|
66
|
+
setView: ct,
|
|
67
|
+
selectedId: S.customerId || void 0,
|
|
68
|
+
setSelectedId: vt,
|
|
69
|
+
messages: ft,
|
|
70
|
+
counterpartType: "customer",
|
|
71
|
+
counterpart: void 0,
|
|
72
|
+
primaryAddress: mt
|
|
73
|
+
}), bt = s((e) => C((t) => {
|
|
74
|
+
let n = e({
|
|
75
|
+
paymentTermsId: t.paymentTermsId,
|
|
76
|
+
paymentTermsCustomDate: t.paymentTermsCustomDate
|
|
77
|
+
});
|
|
78
|
+
return {
|
|
79
|
+
...t,
|
|
80
|
+
...n,
|
|
81
|
+
...n.paymentTermsId === "receipt_due" ? { paymentReminderId: "" } : {}
|
|
82
|
+
};
|
|
83
|
+
}), []), xt = We({
|
|
84
|
+
paymentTermsId: S.paymentTermsId,
|
|
85
|
+
paymentTermsCustomDate: S.paymentTermsCustomDate,
|
|
86
|
+
isRecurring: S.type === "invoice" && o(S),
|
|
87
|
+
messages: f,
|
|
88
|
+
onChange: bt
|
|
89
|
+
}), V = xt.reset, St = s((e) => C((t) => ({
|
|
90
|
+
...t,
|
|
91
|
+
...e
|
|
92
|
+
})), []), Ct = Ke({
|
|
93
|
+
open: v,
|
|
94
|
+
bankAccountId: S.bankAccountId,
|
|
95
|
+
embeddedBankName: Qe,
|
|
96
|
+
messages: f,
|
|
97
|
+
onSelect: St
|
|
98
|
+
}), H = Ct.reset, wt = Ve(at), U = at ? wt.data : void 0, W = ye(U), G = W > 0, K = !!at && wt.isLoading, q = u(void 0);
|
|
99
|
+
c(() => {
|
|
100
|
+
U && q.current !== U.id && (q.current = U.id, C((e) => ({
|
|
101
|
+
...e,
|
|
102
|
+
...be(U)
|
|
103
|
+
})));
|
|
104
|
+
}, [U]);
|
|
105
|
+
let Tt = s((e) => C(e), []), Et = s((e) => w((t) => {
|
|
106
|
+
if (!e.some((e) => e in t)) return t;
|
|
107
|
+
let n = { ...t };
|
|
108
|
+
return e.forEach((e) => delete n[e]), n;
|
|
109
|
+
}), []), Dt = u([]), Ot = s((e) => {
|
|
110
|
+
if (!A) {
|
|
111
|
+
Et(e);
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
114
|
+
Dt.current.push(...e);
|
|
115
|
+
}, [Et, A]);
|
|
116
|
+
c(() => {
|
|
117
|
+
let e = Dt.current;
|
|
118
|
+
if (!e.length) return;
|
|
119
|
+
Dt.current = [];
|
|
120
|
+
let t = xe({
|
|
121
|
+
fields: S,
|
|
122
|
+
issuedCount: W,
|
|
123
|
+
messages: f
|
|
124
|
+
});
|
|
125
|
+
w((n) => {
|
|
126
|
+
let r = { ...n };
|
|
127
|
+
return e.forEach((e) => {
|
|
128
|
+
t[e] ? r[e] = t[e] : delete r[e];
|
|
129
|
+
}), r;
|
|
130
|
+
});
|
|
35
131
|
}, [
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
132
|
+
W,
|
|
133
|
+
f,
|
|
134
|
+
S
|
|
39
135
|
]);
|
|
40
|
-
let
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
messages:
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
messages:
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
136
|
+
let kt = Ge({
|
|
137
|
+
values: S,
|
|
138
|
+
errors: ot,
|
|
139
|
+
lockSchedule: G,
|
|
140
|
+
messages: f,
|
|
141
|
+
onChange: Tt,
|
|
142
|
+
onClearErrors: Et,
|
|
143
|
+
onRevalidateErrors: Ot
|
|
144
|
+
}), J = kt.reset, At = s((e) => C((t) => ({
|
|
145
|
+
...t,
|
|
146
|
+
...e
|
|
147
|
+
})), []), jt = p.isPending || m.isPending || et.isPending || tt.isPending, Mt = qe({
|
|
148
|
+
open: v,
|
|
149
|
+
isInvoice: S.type === "invoice",
|
|
150
|
+
disabled: jt,
|
|
151
|
+
paymentTermsId: S.paymentTermsId,
|
|
152
|
+
paymentTermsCustomDate: S.paymentTermsCustomDate,
|
|
153
|
+
paymentReminderId: S.paymentReminderId,
|
|
154
|
+
overdueReminderId: S.overdueReminderId,
|
|
155
|
+
messages: f,
|
|
156
|
+
onSelect: At
|
|
157
|
+
}), Y = Mt.reset, Nt = s(() => {
|
|
158
|
+
g.current = [], k(void 0), nt("create"), it(void 0), x(void 0), q.current = void 0, h.current = void 0, C(Ae()), w({}), j(!1), I(!1), F.current = {
|
|
159
|
+
lines: !1,
|
|
160
|
+
discount: !1
|
|
161
|
+
}, z(), J();
|
|
162
|
+
}, [z, J]), Pt = s((e = "invoice") => {
|
|
163
|
+
V(), H(), J();
|
|
164
|
+
let t = {
|
|
165
|
+
...Ae(),
|
|
166
|
+
type: e
|
|
167
|
+
};
|
|
168
|
+
Y(Le(t)), g.current = [], h.current = void 0, q.current = void 0, k(void 0), nt("create"), it(void 0), x(void 0), C(t), w({}), z(), j(!1), I(!1), F.current = {
|
|
169
|
+
lines: !1,
|
|
170
|
+
discount: !1
|
|
171
|
+
}, y(!0);
|
|
172
|
+
}, [
|
|
173
|
+
z,
|
|
174
|
+
V,
|
|
175
|
+
H,
|
|
176
|
+
J,
|
|
177
|
+
Y
|
|
178
|
+
]), Ft = s((e) => {
|
|
179
|
+
if (e.type === "credit_note") return;
|
|
180
|
+
V(), H(), J();
|
|
181
|
+
let t = Fe(e, D);
|
|
182
|
+
Y(Le(t)), g.current = e.line_items, _.current = e.currency, h.current = void 0, q.current = void 0, k(void 0), nt("edit"), it(e.id), x(e.type === "invoice" ? e.recurrence_id ?? void 0 : void 0), C(t), w({}), j(!1), I(!1), F.current = {
|
|
183
|
+
lines: !1,
|
|
184
|
+
discount: !1
|
|
185
|
+
}, z(), y(!0);
|
|
186
|
+
}, [
|
|
187
|
+
z,
|
|
188
|
+
V,
|
|
189
|
+
H,
|
|
190
|
+
J,
|
|
191
|
+
Y,
|
|
192
|
+
D
|
|
193
|
+
]);
|
|
194
|
+
c(() => {
|
|
195
|
+
D?.length && C((e) => {
|
|
196
|
+
let t = se(e.lineItems, D);
|
|
197
|
+
return t === e.lineItems ? e : {
|
|
198
|
+
...e,
|
|
199
|
+
lineItems: t
|
|
200
|
+
};
|
|
201
|
+
});
|
|
202
|
+
}, [D]);
|
|
203
|
+
let X = R.isUploading, It = s(() => {
|
|
204
|
+
X || (B(), y(!1), w({}));
|
|
205
|
+
}, [B, X]), Lt = s((e) => {
|
|
206
|
+
let t = { ...e };
|
|
207
|
+
t.taxRate !== void 0 && (t.taxRate = le(t.taxRate), P.current = !0), t.type !== void 0 && t.type !== "invoice" && B(), t.discount !== void 0 && A && (N.current = !0), t.discountType !== void 0 && (N.current = !0), t.currency !== void 0 && (M.current = !0), C((e) => {
|
|
208
|
+
let n = {
|
|
209
|
+
...e,
|
|
210
|
+
...t
|
|
211
|
+
};
|
|
212
|
+
return t.discount !== void 0 && (n.discount = Te(t.discount, n.discountType, n.currency)), n.currency !== e.currency && (n.lineItems = e.lineItems.map((t) => ({
|
|
213
|
+
...t,
|
|
214
|
+
price: ne(t.price, e.currency, n.currency)
|
|
215
|
+
}))), (n.currency !== e.currency || n.discountType !== e.discountType) && (n.discount = Se({
|
|
216
|
+
value: n.discount,
|
|
217
|
+
type: n.discountType,
|
|
218
|
+
currency: n.currency
|
|
219
|
+
})), n;
|
|
220
|
+
});
|
|
221
|
+
}, [B, A]), Rt = s(() => I(!0), []), zt = s(() => {
|
|
222
|
+
I(!1), N.current = !0, C((e) => ({
|
|
223
|
+
...e,
|
|
224
|
+
discount: Se({
|
|
225
|
+
value: e.discount,
|
|
226
|
+
type: e.discountType,
|
|
227
|
+
currency: e.currency
|
|
228
|
+
})
|
|
229
|
+
}));
|
|
230
|
+
}, []), Bt = s(() => {
|
|
231
|
+
P.current = !0, C((e) => {
|
|
232
|
+
let t = te(e.taxRate);
|
|
233
|
+
return t === e.taxRate ? e : {
|
|
234
|
+
...e,
|
|
235
|
+
taxRate: t
|
|
236
|
+
};
|
|
237
|
+
});
|
|
238
|
+
}, []), Z = s((e, { validate: t }) => {
|
|
239
|
+
t && (M.current = !0), C((t) => ({
|
|
240
|
+
...t,
|
|
241
|
+
lineItems: e(t.lineItems)
|
|
242
|
+
}));
|
|
243
|
+
}, []);
|
|
244
|
+
c(() => {
|
|
245
|
+
let e = M.current, t = N.current;
|
|
246
|
+
if (!e && !t && !P.current) return;
|
|
247
|
+
M.current = !1, N.current = !1, P.current = !1, e && (F.current.lines = !0), t && (F.current.discount = !0);
|
|
248
|
+
let n = e ? me(S.lineItems, {
|
|
249
|
+
currency: S.currency,
|
|
250
|
+
messages: f
|
|
251
|
+
}) : void 0;
|
|
252
|
+
w((t) => {
|
|
253
|
+
let r = { ...t };
|
|
254
|
+
return F.current.lines && (r.lineItems = e ? n : t.lineItems, r.lineItemsSummary = fe(r.lineItems, ke(S, f))), F.current.discount && (r.discount = Oe(S, f)), r;
|
|
255
|
+
});
|
|
256
|
+
}, [f, S]);
|
|
257
|
+
let Vt = s((e, t) => {
|
|
258
|
+
let { unit: n, ...r } = t, i = ce(r);
|
|
259
|
+
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 ? {
|
|
260
|
+
...t,
|
|
261
|
+
...i
|
|
262
|
+
} : t), { validate: A });
|
|
263
|
+
}, [Z, A]), Ht = s((e, t) => {
|
|
264
|
+
Z((n) => n.map((n) => n.id === e ? {
|
|
265
|
+
...n,
|
|
266
|
+
...ae({
|
|
267
|
+
product: t,
|
|
268
|
+
currency: S.currency,
|
|
269
|
+
unitNamesById: O
|
|
270
|
+
})
|
|
271
|
+
} : n), { validate: !0 });
|
|
272
|
+
}, [
|
|
273
|
+
Z,
|
|
274
|
+
O,
|
|
275
|
+
S.currency
|
|
276
|
+
]), Q = s((e, t) => {
|
|
277
|
+
t && Z((n) => t.kind === "remove" ? n.filter((t) => t.id !== e) : n.map((n) => n.id === e ? {
|
|
278
|
+
...n,
|
|
279
|
+
...t.patch
|
|
280
|
+
} : n), { validate: !0 });
|
|
281
|
+
}, [Z]), Ut = s((e, t) => {
|
|
282
|
+
let n = S.lineItems.find((t) => t.id === e);
|
|
283
|
+
n && Q(e, ee({
|
|
284
|
+
lineItem: n,
|
|
285
|
+
field: t,
|
|
286
|
+
rowCount: S.lineItems.length,
|
|
287
|
+
currency: S.currency
|
|
288
|
+
}));
|
|
289
|
+
}, [
|
|
290
|
+
Q,
|
|
291
|
+
S.currency,
|
|
292
|
+
S.lineItems
|
|
293
|
+
]), Wt = s((e, t) => {
|
|
294
|
+
let n = S.lineItems.find((t) => t.id === e);
|
|
295
|
+
n && Q(e, ue({
|
|
296
|
+
lineItem: n,
|
|
297
|
+
step: t,
|
|
298
|
+
rowCount: S.lineItems.length
|
|
299
|
+
}));
|
|
300
|
+
}, [Q, S.lineItems]), Gt = s(() => {
|
|
301
|
+
let e = re(S.currency);
|
|
302
|
+
k(e.id), C((t) => ({
|
|
303
|
+
...t,
|
|
304
|
+
lineItems: [...t.lineItems, e]
|
|
305
|
+
}));
|
|
306
|
+
}, [S.currency]), Kt = s((e) => {
|
|
307
|
+
Z((t) => t.length <= 1 ? t : t.filter((t) => t.id !== e), { validate: !0 });
|
|
308
|
+
}, [Z]), qt = s(async () => {
|
|
309
|
+
if (X || K) return;
|
|
310
|
+
if (E.isLoading) {
|
|
311
|
+
w({ form: f.lineItemsLoading });
|
|
312
|
+
return;
|
|
63
313
|
}
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
314
|
+
let e = de(S.lineItems), n = e.length === S.lineItems.length ? S : {
|
|
315
|
+
...S,
|
|
316
|
+
lineItems: e
|
|
317
|
+
};
|
|
318
|
+
n !== S && C(n);
|
|
319
|
+
let r = n.type === "invoice" && o(n), i = {
|
|
320
|
+
...Ie({
|
|
321
|
+
values: n,
|
|
322
|
+
billingAddressId: L,
|
|
323
|
+
messages: f
|
|
324
|
+
}),
|
|
325
|
+
...r ? xe({
|
|
326
|
+
fields: n,
|
|
327
|
+
issuedCount: W,
|
|
328
|
+
messages: f
|
|
329
|
+
}) : {}
|
|
330
|
+
};
|
|
331
|
+
if (je(i)) {
|
|
332
|
+
w(i), j(!0), F.current = {
|
|
333
|
+
lines: !0,
|
|
334
|
+
discount: !0
|
|
335
|
+
};
|
|
336
|
+
return;
|
|
337
|
+
}
|
|
338
|
+
w({});
|
|
339
|
+
let a = b === "edit" ? rt : h.current;
|
|
340
|
+
try {
|
|
341
|
+
let e, t;
|
|
342
|
+
if (a) {
|
|
343
|
+
let i = await m.mutateAsync({
|
|
344
|
+
path: { receivable_id: a },
|
|
345
|
+
body: Pe({
|
|
346
|
+
values: n,
|
|
347
|
+
billingAddressId: L ?? "",
|
|
348
|
+
lineItemChanges: Ne({
|
|
349
|
+
values: n,
|
|
350
|
+
originalLineItems: g.current,
|
|
351
|
+
originalCurrency: _.current,
|
|
352
|
+
unitNamesById: O,
|
|
353
|
+
units: D
|
|
354
|
+
})
|
|
355
|
+
})
|
|
356
|
+
});
|
|
357
|
+
gt(), e = a, t = i?.type ?? n.type, r && i && (g.current = i.line_items, _.current = i.currency, n = {
|
|
358
|
+
...n,
|
|
359
|
+
lineItems: oe(n.lineItems, i.line_items)
|
|
360
|
+
}, C(n));
|
|
361
|
+
} else {
|
|
362
|
+
let i = await p.mutateAsync({ body: Me({
|
|
363
|
+
values: n,
|
|
364
|
+
billingAddressId: L ?? "",
|
|
365
|
+
unitNamesById: O
|
|
366
|
+
}) });
|
|
367
|
+
if (!i?.id) {
|
|
368
|
+
y(!1), Nt();
|
|
86
369
|
return;
|
|
87
370
|
}
|
|
88
|
-
|
|
89
|
-
|
|
371
|
+
e = i.id, t = i.type, r && (h.current = i.id, g.current = i.line_items, _.current = i.currency, n = {
|
|
372
|
+
...n,
|
|
373
|
+
lineItems: oe(n.lineItems, i.line_items)
|
|
374
|
+
}, C(n));
|
|
90
375
|
}
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
376
|
+
r && (U ? await tt.mutateAsync({
|
|
377
|
+
path: { recurrence_id: U.id },
|
|
378
|
+
body: _e(n, { lockSchedule: G })
|
|
379
|
+
}) : await et.mutateAsync({ body: ge(n, e) }));
|
|
380
|
+
let i = b === "create";
|
|
381
|
+
y(!1), Nt(), i && $e?.(e, t);
|
|
382
|
+
} catch (e) {
|
|
383
|
+
w({ form: t(e) ?? f.genericError });
|
|
384
|
+
}
|
|
385
|
+
}, [
|
|
386
|
+
L,
|
|
387
|
+
gt,
|
|
388
|
+
p,
|
|
389
|
+
et,
|
|
390
|
+
rt,
|
|
391
|
+
U,
|
|
392
|
+
X,
|
|
393
|
+
W,
|
|
394
|
+
G,
|
|
395
|
+
f,
|
|
396
|
+
b,
|
|
397
|
+
$e,
|
|
398
|
+
K,
|
|
399
|
+
Nt,
|
|
400
|
+
D,
|
|
401
|
+
O,
|
|
402
|
+
E.isLoading,
|
|
403
|
+
m,
|
|
404
|
+
tt,
|
|
405
|
+
S
|
|
406
|
+
]), Jt = l(() => ({
|
|
407
|
+
...S,
|
|
408
|
+
discount: ut ? S.discount : Ce(we(S.discount, S.discountType, S.currency), S.discountType, S.currency),
|
|
409
|
+
lineItems: S.lineItems.map(pe)
|
|
410
|
+
}), [ut, S]), Yt = l(() => a(S.lineItems), [S.lineItems]), $ = l(() => De(S), [S]), Xt = l(() => Ee($, S.currency), [$, S.currency]);
|
|
411
|
+
return {
|
|
412
|
+
open: v,
|
|
413
|
+
setOpen: y,
|
|
414
|
+
mode: b,
|
|
415
|
+
values: S,
|
|
416
|
+
sheetValues: Jt,
|
|
417
|
+
errors: ot,
|
|
418
|
+
setValues: C,
|
|
419
|
+
updateValues: Lt,
|
|
420
|
+
commitTaxRate: Bt,
|
|
421
|
+
focusDiscount: Rt,
|
|
422
|
+
commitDiscount: zt,
|
|
423
|
+
updateLineItem: Vt,
|
|
424
|
+
selectProduct: Ht,
|
|
425
|
+
commitLineItem: Ut,
|
|
426
|
+
stepLineItem: Wt,
|
|
427
|
+
addLineItem: Gt,
|
|
428
|
+
removeLineItem: Kt,
|
|
429
|
+
attachmentsView: _t,
|
|
430
|
+
attachmentsUploading: R.isUploading,
|
|
431
|
+
saveDisabled: E.isLoading || R.isUploading || K,
|
|
432
|
+
selectAttachmentFiles: R.selectFiles,
|
|
433
|
+
setAttachmentIncludeInEmail: R.setIncludeInEmail,
|
|
434
|
+
removeAttachment: R.remove,
|
|
435
|
+
autoFocusLineItemId: lt,
|
|
436
|
+
lineItemUnitOptions: T.unitOptions,
|
|
437
|
+
lineItemsLoading: E.isLoading,
|
|
438
|
+
lineItemControls: Yt,
|
|
439
|
+
totals: $,
|
|
440
|
+
totalsView: Xt,
|
|
441
|
+
currencySymbol: ie(S.currency),
|
|
442
|
+
isSubmitting: jt,
|
|
443
|
+
currencyOptions: Je(S.currency),
|
|
444
|
+
paymentTerms: xt,
|
|
445
|
+
showBillingSection: S.type === "invoice" || b === "edit",
|
|
446
|
+
recurrence: kt,
|
|
447
|
+
showRecurrenceSection: S.type === "invoice",
|
|
448
|
+
recurrenceLoading: K,
|
|
449
|
+
submitLabel: S.type === "invoice" && o(S) ? U ? f.recurrenceUpdateButton : f.recurrenceActivateButton : void 0,
|
|
450
|
+
showDueDateField: S.type === "quote",
|
|
451
|
+
openCreate: Pt,
|
|
452
|
+
openEdit: Ft,
|
|
453
|
+
close: It,
|
|
454
|
+
submit: qt,
|
|
455
|
+
units: T,
|
|
456
|
+
counterpartView: st,
|
|
457
|
+
counterpartForm: yt,
|
|
458
|
+
stateOptions: dt,
|
|
459
|
+
openCounterpartCreate: yt.openCreate,
|
|
460
|
+
bankAccount: Ct,
|
|
461
|
+
reminders: Mt
|
|
112
462
|
};
|
|
113
463
|
}
|
|
114
464
|
//#endregion
|
|
115
|
-
export {
|
|
465
|
+
export { f as useReceivableForm };
|