@tesouro/embedded-components-react 0.5.272 → 0.5.274
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -0
- package/dist/index.d.ts +1 -0
- package/dist/lib/ReceivablesWidget.d.ts +1 -0
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index.js +10 -9
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index10.js +173 -44
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index11.js +42 -94
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index12.js +91 -76
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index13.js +67 -173
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index14.js +186 -17
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index15.js +27 -0
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index6.js +16 -62
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index7.js +66 -28
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index8.js +28 -34
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index9.js +24 -168
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/details.js +9 -9
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/labels.js +1 -0
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/preview.js +47 -44
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/useReceivableActions.js +125 -122
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/useReceivableActionsModal.js +50 -47
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/useReceivableAttachmentUploads.js +1 -1
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/useReceivableDetails.js +3 -3
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/useReceivableForm.js +2 -2
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/useReceivableIssuePreflight.js +1 -1
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/useReceivablePaymentRecord.js +1 -1
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/useReceivableReminders.js +1 -1
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/useReceivableStatusCards.js +1 -1
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/useReceivablesTable.js +1 -1
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/useReceivablesWidget.js +3 -0
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/useSendReceivableWithPaymentLink.js +54 -0
- package/dist/libs/tesouro-embedded-components-react/shared/data-access/dist/index.js +41 -41
- package/dist/libs/tesouro-embedded-components-react/shared/data-access/dist/lib/rest/sdk.gen.js +83 -71
- package/dist/libs/tesouro-embedded-components-react/shared/feature/dist/lib/analytics/build-info.js +1 -1
- package/package.json +7 -2
|
@@ -8,19 +8,22 @@ import { differenceInCalendarDays as d, parseISO as f } from "date-fns";
|
|
|
8
8
|
//#region ../../libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/preview.js
|
|
9
9
|
var p = "US", m = 100;
|
|
10
10
|
function h(e) {
|
|
11
|
-
return (e ?? []).
|
|
11
|
+
return (e ?? []).filter(({ status: e, direction: t }) => e === "active" && t === "receive");
|
|
12
12
|
}
|
|
13
13
|
function g(e) {
|
|
14
|
-
return e
|
|
14
|
+
return h(e).length > 0;
|
|
15
15
|
}
|
|
16
16
|
function _(e) {
|
|
17
|
+
return e?.invoice?.display_organization_bank_account ?? e?.display_organization_bank_account ?? !0;
|
|
18
|
+
}
|
|
19
|
+
function v(e) {
|
|
17
20
|
try {
|
|
18
21
|
return new Intl.DisplayNames(void 0, { type: "region" }).of(e) ?? e;
|
|
19
22
|
} catch {
|
|
20
23
|
return e;
|
|
21
24
|
}
|
|
22
25
|
}
|
|
23
|
-
function
|
|
26
|
+
function y({ address: e, issuerCountry: t, formatCountry: n = v }) {
|
|
24
27
|
if (!e) return [];
|
|
25
28
|
let r = [e.city, e.state].filter(Boolean).join(", "), i = e.country === p && t === p;
|
|
26
29
|
return [
|
|
@@ -29,65 +32,65 @@ function v({ address: e, issuerCountry: t, formatCountry: n = _ }) {
|
|
|
29
32
|
e.country && !i ? n(e.country) : ""
|
|
30
33
|
].filter(Boolean);
|
|
31
34
|
}
|
|
32
|
-
var
|
|
35
|
+
var b = { kind: "pending" }, x = (e) => ({
|
|
33
36
|
kind: "text",
|
|
34
37
|
lines: e
|
|
35
38
|
});
|
|
36
|
-
function
|
|
39
|
+
function S(e, t) {
|
|
37
40
|
return e.previewNetDays.replace("{days}", String(t));
|
|
38
41
|
}
|
|
39
|
-
function
|
|
42
|
+
function C(e, t) {
|
|
40
43
|
let n = e.previewEarlyPaymentDays.replace("{days}", String(t.number_of_days));
|
|
41
44
|
return t.discount ? `${n}, ${e.previewEarlyPaymentDiscount.replace("{rate}", String(t.discount / m))}` : n;
|
|
42
45
|
}
|
|
43
|
-
function
|
|
46
|
+
function w({ paymentTermsId: e, paymentTermsCustomDate: t, paymentTerms: n, issueDate: r, messages: i }) {
|
|
44
47
|
let a = {
|
|
45
|
-
dueDate:
|
|
46
|
-
paymentTerms:
|
|
48
|
+
dueDate: b,
|
|
49
|
+
paymentTerms: b
|
|
47
50
|
};
|
|
48
51
|
if (e === "custom") {
|
|
49
52
|
if (!t) return a;
|
|
50
53
|
let e = f(t), n = Math.max(0, d(e, r));
|
|
51
54
|
return {
|
|
52
|
-
dueDate:
|
|
53
|
-
paymentTerms:
|
|
55
|
+
dueDate: x([s(e)]),
|
|
56
|
+
paymentTerms: x([S(i, n)])
|
|
54
57
|
};
|
|
55
58
|
}
|
|
56
59
|
if (e === "receipt_due") return {
|
|
57
|
-
dueDate:
|
|
58
|
-
paymentTerms:
|
|
60
|
+
dueDate: x([s(r)]),
|
|
61
|
+
paymentTerms: x([i.previewDueOnReceipt])
|
|
59
62
|
};
|
|
60
63
|
let o = n?.find((t) => t.id === e);
|
|
61
64
|
if (!o) return a;
|
|
62
65
|
let c = l(o, r), u = [
|
|
63
|
-
o.term_1 &&
|
|
64
|
-
o.term_2 &&
|
|
65
|
-
o.term_final &&
|
|
66
|
+
o.term_1 && C(i, o.term_1),
|
|
67
|
+
o.term_2 && C(i, o.term_2),
|
|
68
|
+
o.term_final && S(i, o.term_final.number_of_days)
|
|
66
69
|
].filter((e) => !!e);
|
|
67
70
|
return {
|
|
68
|
-
dueDate: c ?
|
|
69
|
-
paymentTerms: u.length > 0 ?
|
|
71
|
+
dueDate: c ? x([s(c)]) : b,
|
|
72
|
+
paymentTerms: u.length > 0 ? x(u) : b
|
|
70
73
|
};
|
|
71
74
|
}
|
|
72
|
-
function
|
|
75
|
+
function T(e, t) {
|
|
73
76
|
return t ? e.previewTaxId.replace("{taxId}", t) : void 0;
|
|
74
77
|
}
|
|
75
|
-
function
|
|
78
|
+
function E(e) {
|
|
76
79
|
return e.length > 0 ? e : void 0;
|
|
77
80
|
}
|
|
78
|
-
function
|
|
81
|
+
function D(e, t) {
|
|
79
82
|
return e ? {
|
|
80
83
|
name: e.type === "organization" ? e.organization.legal_name : void 0,
|
|
81
|
-
addressLines:
|
|
84
|
+
addressLines: E(y({
|
|
82
85
|
address: e.address,
|
|
83
86
|
issuerCountry: e.address?.country
|
|
84
87
|
})),
|
|
85
|
-
taxIdLine:
|
|
88
|
+
taxIdLine: T(t, e.tax_id),
|
|
86
89
|
email: e.email ?? void 0,
|
|
87
90
|
phone: e.phone ?? void 0
|
|
88
91
|
} : {};
|
|
89
92
|
}
|
|
90
|
-
function
|
|
93
|
+
function O(e) {
|
|
91
94
|
let t = "organization" in e ? e.organization : e.individual;
|
|
92
95
|
return {
|
|
93
96
|
name: "organization" in e ? e.organization.legal_name : [e.individual.first_name, e.individual.last_name].filter(Boolean).join(" "),
|
|
@@ -95,22 +98,22 @@ function D(e) {
|
|
|
95
98
|
phone: t.phone
|
|
96
99
|
};
|
|
97
100
|
}
|
|
98
|
-
function
|
|
101
|
+
function k({ counterpart: e, billingAddress: t, issuerCountry: n, messages: r }) {
|
|
99
102
|
if (!e) return { kind: "pending" };
|
|
100
|
-
let { name: i, email: a, phone: o } =
|
|
103
|
+
let { name: i, email: a, phone: o } = O(e);
|
|
101
104
|
return i ? {
|
|
102
105
|
kind: "party",
|
|
103
106
|
name: i,
|
|
104
|
-
addressLines:
|
|
107
|
+
addressLines: E(y({
|
|
105
108
|
address: t,
|
|
106
109
|
issuerCountry: n
|
|
107
110
|
})),
|
|
108
|
-
taxIdLine:
|
|
111
|
+
taxIdLine: T(r, e.tax_id),
|
|
109
112
|
email: a || void 0,
|
|
110
113
|
phone: o || void 0
|
|
111
114
|
} : { kind: "pending" };
|
|
112
115
|
}
|
|
113
|
-
function
|
|
116
|
+
function A({ lineItems: e, currency: n, unitNamesById: r, messages: o }) {
|
|
114
117
|
return e.filter((e) => !t(e)).map((e) => {
|
|
115
118
|
let t = a(e.price, n), s = i(e.quantity), c = r[e.measureUnitId] || e.measureUnitName;
|
|
116
119
|
return {
|
|
@@ -132,19 +135,19 @@ function k({ lineItems: e, currency: n, unitNamesById: r, messages: o }) {
|
|
|
132
135
|
};
|
|
133
136
|
});
|
|
134
137
|
}
|
|
135
|
-
function
|
|
138
|
+
function j(t, n) {
|
|
136
139
|
return n ? new Intl.NumberFormat(void 0, {
|
|
137
140
|
style: "currency",
|
|
138
141
|
currency: n,
|
|
139
142
|
currencySign: "accounting"
|
|
140
143
|
}).format(-t / 10 ** e(n)) : "";
|
|
141
144
|
}
|
|
142
|
-
function
|
|
145
|
+
function M(e, i) {
|
|
143
146
|
if (!e.taxRate) return i.previewTax;
|
|
144
147
|
let a = o(e.taxRate), s = n(e.taxRate, e.savedTaxRate);
|
|
145
148
|
return new Set(e.lineItems.filter((e) => e.taxable && !t(e)).map((e) => r(e, a, s))).size > 1 ? i.previewTax : i.previewTaxWithRate.replace("{rate}", String(a / m));
|
|
146
149
|
}
|
|
147
|
-
function
|
|
150
|
+
function N({ totals: e, currency: t, taxLabel: n, messages: r }) {
|
|
148
151
|
let i = (e) => u({
|
|
149
152
|
amount: e,
|
|
150
153
|
currency: t,
|
|
@@ -157,7 +160,7 @@ function M({ totals: e, currency: t, taxLabel: n, messages: r }) {
|
|
|
157
160
|
return a && c.push({
|
|
158
161
|
id: "discount",
|
|
159
162
|
label: r.previewDiscount,
|
|
160
|
-
value:
|
|
163
|
+
value: j(e.discountAmount, t)
|
|
161
164
|
}), s && (o || a) && c.push({
|
|
162
165
|
id: "nonTaxableSubtotal",
|
|
163
166
|
label: r.previewNonTaxableSubtotal,
|
|
@@ -180,7 +183,7 @@ function M({ totals: e, currency: t, taxLabel: n, messages: r }) {
|
|
|
180
183
|
}
|
|
181
184
|
};
|
|
182
185
|
}
|
|
183
|
-
function
|
|
186
|
+
function P({ bankDetails: e, canReceivePayments: t, messages: n }) {
|
|
184
187
|
let r = e ? [
|
|
185
188
|
[n.previewAccountHolderName, e.accountHolderName],
|
|
186
189
|
[n.previewRoutingNumber, e.routingNumber],
|
|
@@ -191,13 +194,13 @@ function N({ bankDetails: e, canReceivePayments: t, messages: n }) {
|
|
|
191
194
|
bankLines: r
|
|
192
195
|
};
|
|
193
196
|
}
|
|
194
|
-
function
|
|
195
|
-
let p =
|
|
197
|
+
function F({ values: e, totals: t, entity: n, counterpart: r, billingAddress: i, paymentTerms: a, unitNamesById: o, bankDetails: l, canReceivePayments: u = !1, messages: d, today: f = /* @__PURE__ */ new Date() }) {
|
|
198
|
+
let p = A({
|
|
196
199
|
lineItems: e.lineItems,
|
|
197
200
|
currency: e.currency,
|
|
198
201
|
unitNamesById: o,
|
|
199
202
|
messages: d
|
|
200
|
-
}), m = n?.logo?.url, h =
|
|
203
|
+
}), m = n?.logo?.url, h = D(n, d), g = c(e.issueDate, f);
|
|
201
204
|
return {
|
|
202
205
|
issuer: h,
|
|
203
206
|
logo: m ? {
|
|
@@ -205,15 +208,15 @@ function P({ values: e, totals: t, entity: n, counterpart: r, billingAddress: i,
|
|
|
205
208
|
src: m,
|
|
206
209
|
alt: h.name ? d.previewLogoAlt.replace("{name}", h.name) : d.previewLogoAltNoName
|
|
207
210
|
} : { kind: "placeholder" },
|
|
208
|
-
billTo:
|
|
211
|
+
billTo: k({
|
|
209
212
|
counterpart: r,
|
|
210
213
|
billingAddress: i,
|
|
211
214
|
issuerCountry: n?.address?.country,
|
|
212
215
|
messages: d
|
|
213
216
|
}),
|
|
214
|
-
invoiceNumber:
|
|
217
|
+
invoiceNumber: b,
|
|
215
218
|
issueDate: s(g),
|
|
216
|
-
...
|
|
219
|
+
...w({
|
|
217
220
|
paymentTermsId: e.paymentTermsId,
|
|
218
221
|
paymentTermsCustomDate: e.paymentTermsCustomDate,
|
|
219
222
|
paymentTerms: a,
|
|
@@ -226,14 +229,14 @@ function P({ values: e, totals: t, entity: n, counterpart: r, billingAddress: i,
|
|
|
226
229
|
kind: "rows",
|
|
227
230
|
rows: p
|
|
228
231
|
} : { kind: "empty" },
|
|
229
|
-
totals: p.length > 0 ?
|
|
232
|
+
totals: p.length > 0 ? N({
|
|
230
233
|
totals: t,
|
|
231
234
|
currency: e.currency,
|
|
232
|
-
taxLabel:
|
|
235
|
+
taxLabel: M(e, d),
|
|
233
236
|
messages: d
|
|
234
237
|
}) : void 0,
|
|
235
238
|
closingNote: e.closingNote || void 0,
|
|
236
|
-
payment:
|
|
239
|
+
payment: P({
|
|
237
240
|
bankDetails: l,
|
|
238
241
|
canReceivePayments: u,
|
|
239
242
|
messages: d
|
|
@@ -241,4 +244,4 @@ function P({ values: e, totals: t, entity: n, counterpart: r, billingAddress: i,
|
|
|
241
244
|
};
|
|
242
245
|
}
|
|
243
246
|
//#endregion
|
|
244
|
-
export {
|
|
247
|
+
export { y as buildPreviewAddressLines, w as buildPreviewPaymentTerms, F as buildReceivablePreviewView, _ as displaysBankAccount, v as formatCountryName, j as formatDeduction, h as getReceivePaymentMethods, g as hasReceivePaymentMethod };
|
|
@@ -7,241 +7,244 @@ import { extractApiErrorMessage as t } from "../../../../../shared/util/dist/lib
|
|
|
7
7
|
import "../../../../../shared/ui/dist/index.js";
|
|
8
8
|
import { getCounterpartEmail as n } from "../../../../../shared/counterpart-management/feature/dist/lib/helpers.js";
|
|
9
9
|
import "../../../../../shared/counterpart-management/feature/dist/index.js";
|
|
10
|
-
import { defaultSendValues as r, formatMoney as i, hasSendErrors as a, isReceivableReadyToIssue as
|
|
11
|
-
import { getIssueReminderBlocker as
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import { useCancelRecurrenceMutation as ae, usePauseRecurrenceMutation as oe, useResumeRecurrenceMutation as se } from "../../../../data-access/dist/index13.js";
|
|
10
|
+
import { defaultSendValues as r, formatMoney as i, hasSendErrors as a, isReceivableReadyToIssue as o, splitEmailList as s, validateSendValues as c } from "./helpers.js";
|
|
11
|
+
import { getIssueReminderBlocker as ee, hasSelectedReminder as l } from "./reminders.js";
|
|
12
|
+
import { useAcceptReceivableMutation as te, useCancelReceivableMutation as u, useCloneReceivableMutation as d, useDeclineReceivableMutation as f, useDeleteReceivableMutation as p, useIssueReceivableMutation as ne } from "../../../../data-access/dist/index10.js";
|
|
13
|
+
import { useMarkReceivablePaidMutation as re, useMarkReceivableUncollectibleMutation as ie } from "../../../../data-access/dist/index12.js";
|
|
14
|
+
import { useCancelRecurrenceMutation as ae, usePauseRecurrenceMutation as oe, useResumeRecurrenceMutation as se } from "../../../../data-access/dist/index14.js";
|
|
16
15
|
import "../../../../data-access/dist/index.js";
|
|
17
16
|
import { useReceivableIssuePreflight as ce } from "./useReceivableIssuePreflight.js";
|
|
18
17
|
import { useReceivablePaymentRecord as le } from "./useReceivablePaymentRecord.js";
|
|
19
|
-
import {
|
|
18
|
+
import { useSendReceivableWithPaymentLink as ue } from "./useSendReceivableWithPaymentLink.js";
|
|
19
|
+
import { useCallback as m, useEffect as de, useState as h } from "react";
|
|
20
20
|
//#region ../../libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/useReceivableActions.js
|
|
21
|
-
function
|
|
22
|
-
let
|
|
21
|
+
function g({ selectedReceivable: i, selectedRecurrence: g, messages: v, onCreated: y, onDeleted: b, onCompleteBeforeIssue: x, onIssuedForSend: S }) {
|
|
22
|
+
let C = ne(), w = u(), T = d(), E = te(), D = f(), O = p(), k = re(), A = ie(), j = oe(), M = se(), N = ae(), [P, F] = h(), [me, I] = h(), [L, R] = h(""), [z, B] = h(), [V, H] = h(() => r(void 0, v)), [he, U] = h({}), { send: W, isPending: ge } = ue({
|
|
23
|
+
messages: v,
|
|
24
|
+
documentType: z?.type
|
|
25
|
+
}), G = le({ messages: v }), K = G.open, q = j.mutate, _e = T.mutate, ve = M.mutate, J = i?.type === "invoice" && i.status === "draft" ? i : void 0, [Y, ye] = h(), X = Y?.issueCheck ?? (J ? _(J) : void 0), Z = C.mutate, Q = ce({
|
|
23
26
|
counterpartId: X?.counterpartId,
|
|
24
27
|
billingAddressId: X?.billingAddressId,
|
|
25
28
|
billingCountry: X?.billingCountry
|
|
26
29
|
});
|
|
27
|
-
|
|
30
|
+
de(() => {
|
|
28
31
|
if (!Y || Q.isLoading) return;
|
|
29
|
-
|
|
30
|
-
let t = Y.issueCheck ? Q.isTaxIdMissing ?
|
|
32
|
+
ye(void 0);
|
|
33
|
+
let t = Y.issueCheck ? Q.isTaxIdMissing ? v.issueTaxIdRequired : Y.issueCheck.hasReminder ? ee(Q.counterpart, v) : void 0 : void 0;
|
|
31
34
|
if (t) {
|
|
32
35
|
e.error(t);
|
|
33
36
|
return;
|
|
34
37
|
}
|
|
35
38
|
Z({ path: { receivable_id: Y.id } }, {
|
|
36
|
-
onSuccess: () => e.success(
|
|
37
|
-
onError: () => e.error(
|
|
39
|
+
onSuccess: () => e.success(v.issueSucceeded),
|
|
40
|
+
onError: () => e.error(v.issueFailed)
|
|
38
41
|
});
|
|
39
42
|
}, [
|
|
40
43
|
Z,
|
|
41
|
-
|
|
44
|
+
v,
|
|
42
45
|
Y,
|
|
43
46
|
Q.counterpart,
|
|
44
47
|
Q.isLoading,
|
|
45
48
|
Q.isTaxIdMissing
|
|
46
49
|
]);
|
|
47
|
-
let
|
|
48
|
-
let
|
|
49
|
-
id:
|
|
50
|
-
type:
|
|
51
|
-
title:
|
|
50
|
+
let be = m((a, s, c) => {
|
|
51
|
+
let te = "documentLabel" in s ? s.documentLabel : s.title, u = {
|
|
52
|
+
id: s.id,
|
|
53
|
+
type: s.type,
|
|
54
|
+
title: te,
|
|
52
55
|
action: a
|
|
53
|
-
},
|
|
56
|
+
}, d = c === void 0 ? i : c ?? void 0;
|
|
54
57
|
if (a === "send") {
|
|
55
|
-
|
|
58
|
+
B(u), H(r(d, v)), U({});
|
|
56
59
|
return;
|
|
57
60
|
}
|
|
58
61
|
if (a === "issueAndSend") {
|
|
59
|
-
if (
|
|
60
|
-
let t =
|
|
62
|
+
if (d?.type !== "invoice") return;
|
|
63
|
+
let t = d;
|
|
61
64
|
if (Q.isLoading) return;
|
|
62
65
|
if (!Q.counterpart || !n(Q.counterpart)) {
|
|
63
|
-
e.error(
|
|
66
|
+
e.error(v.issueAndSendNoEmail);
|
|
64
67
|
return;
|
|
65
68
|
}
|
|
66
|
-
if (
|
|
67
|
-
|
|
69
|
+
if (x && !o(t, v)) {
|
|
70
|
+
x(t, "issueAndSend");
|
|
68
71
|
return;
|
|
69
72
|
}
|
|
70
|
-
let r = Q.isTaxIdMissing ?
|
|
73
|
+
let r = Q.isTaxIdMissing ? v.issueTaxIdRequired : l(t) ? ee(Q.counterpart, v) : void 0;
|
|
71
74
|
if (r) {
|
|
72
75
|
e.error(r);
|
|
73
76
|
return;
|
|
74
77
|
}
|
|
75
78
|
Z({ path: { receivable_id: t.id } }, {
|
|
76
79
|
onSuccess: () => {
|
|
77
|
-
e.success(
|
|
80
|
+
e.success(v.issueSucceeded), S?.(t.id, t.counterpart_id);
|
|
78
81
|
},
|
|
79
|
-
onError: () => e.error(
|
|
82
|
+
onError: () => e.error(v.issueFailed)
|
|
80
83
|
});
|
|
81
84
|
return;
|
|
82
85
|
}
|
|
83
86
|
if (a === "clone") {
|
|
84
|
-
|
|
87
|
+
_e({ path: { receivable_id: s.id } }, {
|
|
85
88
|
onSuccess: (t) => {
|
|
86
|
-
t?.id &&
|
|
89
|
+
t?.id && y?.(t.id, t.type), e.success(v.cloneSuccess);
|
|
87
90
|
},
|
|
88
|
-
onError: (n) => e.error(t(n) ??
|
|
91
|
+
onError: (n) => e.error(t(n) ?? v.cloneError)
|
|
89
92
|
});
|
|
90
93
|
return;
|
|
91
94
|
}
|
|
92
|
-
let
|
|
95
|
+
let f = d?.type === "invoice" ? d.recurrence_id ?? void 0 : void 0;
|
|
93
96
|
if (a === "pauseRecurrence" || a === "resumeRecurrence") {
|
|
94
|
-
if (!
|
|
97
|
+
if (!f) return;
|
|
95
98
|
let n = a === "pauseRecurrence";
|
|
96
|
-
(n ? q :
|
|
97
|
-
path: { recurrence_id:
|
|
98
|
-
receivableId:
|
|
99
|
+
(n ? q : ve)({
|
|
100
|
+
path: { recurrence_id: f },
|
|
101
|
+
receivableId: s.id
|
|
99
102
|
}, {
|
|
100
|
-
onSuccess: () => e.success(n ?
|
|
101
|
-
onError: (n) => e.error(t(n) ??
|
|
103
|
+
onSuccess: () => e.success(n ? v.recurrencePaused : v.recurrenceResumed),
|
|
104
|
+
onError: (n) => e.error(t(n) ?? v.genericError)
|
|
102
105
|
});
|
|
103
106
|
return;
|
|
104
107
|
}
|
|
105
108
|
if (a === "cancelRecurrence") {
|
|
106
|
-
if (!
|
|
107
|
-
|
|
108
|
-
...
|
|
109
|
-
recurrenceId:
|
|
110
|
-
description:
|
|
109
|
+
if (!f || d?.type !== "invoice") return;
|
|
110
|
+
I(void 0), F({
|
|
111
|
+
...u,
|
|
112
|
+
recurrenceId: f,
|
|
113
|
+
description: fe(d, g, v)
|
|
111
114
|
});
|
|
112
115
|
return;
|
|
113
116
|
}
|
|
114
117
|
if (a === "recordPayment") {
|
|
115
|
-
|
|
118
|
+
d?.type === "invoice" && K(d);
|
|
116
119
|
return;
|
|
117
120
|
}
|
|
118
|
-
let
|
|
119
|
-
if (
|
|
120
|
-
|
|
121
|
+
let p = a === "issue" && d?.type === "invoice" ? d : void 0;
|
|
122
|
+
if (p && x && !o(p, v)) {
|
|
123
|
+
x(p, "issue");
|
|
121
124
|
return;
|
|
122
125
|
}
|
|
123
126
|
if (a === "issue") {
|
|
124
|
-
|
|
125
|
-
id:
|
|
126
|
-
issueCheck:
|
|
127
|
+
ye({
|
|
128
|
+
id: s.id,
|
|
129
|
+
issueCheck: p ? _(p) : void 0
|
|
127
130
|
});
|
|
128
131
|
return;
|
|
129
132
|
}
|
|
130
|
-
|
|
133
|
+
I(void 0), R(""), F(u);
|
|
131
134
|
}, [
|
|
132
|
-
|
|
135
|
+
_e,
|
|
133
136
|
Z,
|
|
137
|
+
v,
|
|
138
|
+
x,
|
|
134
139
|
y,
|
|
135
140
|
S,
|
|
136
|
-
b,
|
|
137
|
-
C,
|
|
138
141
|
K,
|
|
139
142
|
Q.counterpart,
|
|
140
143
|
Q.isLoading,
|
|
141
144
|
Q.isTaxIdMissing,
|
|
142
145
|
q,
|
|
143
|
-
|
|
146
|
+
ve,
|
|
144
147
|
i,
|
|
145
|
-
|
|
146
|
-
]),
|
|
147
|
-
|
|
148
|
-
}, []), $ =
|
|
149
|
-
|
|
150
|
-
}, []),
|
|
151
|
-
if (!
|
|
152
|
-
let n = { receivable_id:
|
|
153
|
-
if (
|
|
154
|
-
if (!
|
|
148
|
+
g
|
|
149
|
+
]), xe = m(() => {
|
|
150
|
+
F(void 0), I(void 0);
|
|
151
|
+
}, []), $ = m(() => {
|
|
152
|
+
B(void 0), U({});
|
|
153
|
+
}, []), Se = m(async () => {
|
|
154
|
+
if (!P) return;
|
|
155
|
+
let n = { receivable_id: P.id };
|
|
156
|
+
if (P.action === "cancelRecurrence") {
|
|
157
|
+
if (!P.recurrenceId) return;
|
|
155
158
|
try {
|
|
156
|
-
await
|
|
157
|
-
path: { recurrence_id:
|
|
158
|
-
receivableId:
|
|
159
|
-
}), e.success(
|
|
159
|
+
await N.mutateAsync({
|
|
160
|
+
path: { recurrence_id: P.recurrenceId },
|
|
161
|
+
receivableId: P.id
|
|
162
|
+
}), e.success(v.recurrenceCanceled), F(void 0);
|
|
160
163
|
} catch (n) {
|
|
161
|
-
e.error(t(n) ??
|
|
164
|
+
e.error(t(n) ?? v.genericError);
|
|
162
165
|
}
|
|
163
166
|
return;
|
|
164
167
|
}
|
|
165
168
|
try {
|
|
166
|
-
|
|
169
|
+
P.action === "cancel" ? await w.mutateAsync({ path: n }) : P.action === "accept" ? await E.mutateAsync({ path: n }) : P.action === "decline" ? await D.mutateAsync({ path: n }) : P.action === "delete" ? (await O.mutateAsync({ path: n }), b?.(P.id)) : P.action === "markPaid" ? await k.mutateAsync({
|
|
167
170
|
path: n,
|
|
168
171
|
body: { paid_at: (/* @__PURE__ */ new Date()).toISOString() }
|
|
169
|
-
}) :
|
|
172
|
+
}) : P.action === "markUncollectible" && await A.mutateAsync({
|
|
170
173
|
path: n,
|
|
171
|
-
body: { comment:
|
|
172
|
-
}),
|
|
174
|
+
body: { comment: L.trim() || void 0 }
|
|
175
|
+
}), F(void 0), I(void 0);
|
|
173
176
|
} catch (e) {
|
|
174
|
-
|
|
177
|
+
I(t(e) ?? v.genericError);
|
|
175
178
|
}
|
|
176
179
|
}, [
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
F,
|
|
180
|
-
T,
|
|
180
|
+
E,
|
|
181
|
+
L,
|
|
181
182
|
P,
|
|
183
|
+
w,
|
|
184
|
+
N,
|
|
185
|
+
D,
|
|
182
186
|
O,
|
|
183
187
|
k,
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
let e = s(H, y);
|
|
188
|
+
v,
|
|
189
|
+
b,
|
|
190
|
+
A
|
|
191
|
+
]), Ce = m(async () => {
|
|
192
|
+
if (!z) return;
|
|
193
|
+
let e = c(V, v);
|
|
191
194
|
if (a(e)) {
|
|
192
|
-
|
|
195
|
+
U(e);
|
|
193
196
|
return;
|
|
194
197
|
}
|
|
195
198
|
try {
|
|
196
|
-
await
|
|
197
|
-
path: { receivable_id:
|
|
199
|
+
await W({
|
|
200
|
+
path: { receivable_id: z.id },
|
|
198
201
|
body: {
|
|
199
|
-
body_text:
|
|
200
|
-
subject_text:
|
|
202
|
+
body_text: V.body,
|
|
203
|
+
subject_text: V.subject,
|
|
201
204
|
recipients: {
|
|
202
|
-
to:
|
|
203
|
-
cc:
|
|
204
|
-
bcc:
|
|
205
|
+
to: s(V.to),
|
|
206
|
+
cc: s(V.cc),
|
|
207
|
+
bcc: s(V.bcc)
|
|
205
208
|
}
|
|
206
209
|
}
|
|
207
210
|
}), $();
|
|
208
211
|
} catch (e) {
|
|
209
|
-
|
|
212
|
+
U({ form: t(e) ?? v.genericError });
|
|
210
213
|
}
|
|
211
214
|
}, [
|
|
212
215
|
$,
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
216
|
+
v,
|
|
217
|
+
W,
|
|
218
|
+
z,
|
|
219
|
+
V
|
|
217
220
|
]);
|
|
218
221
|
return {
|
|
219
|
-
actionTarget:
|
|
220
|
-
actionDialog:
|
|
222
|
+
actionTarget: P,
|
|
223
|
+
actionDialog: P ? pe(P, v) : void 0,
|
|
221
224
|
actionError: me,
|
|
222
|
-
actionComment:
|
|
223
|
-
setActionComment:
|
|
224
|
-
actionInProgress:
|
|
225
|
+
actionComment: P?.action === "markUncollectible" ? L : void 0,
|
|
226
|
+
setActionComment: R,
|
|
227
|
+
actionInProgress: C.isPending || w.isPending || E.isPending || D.isPending || O.isPending || k.isPending || A.isPending || N.isPending,
|
|
225
228
|
pendingActions: [
|
|
226
|
-
...
|
|
227
|
-
...
|
|
228
|
-
...
|
|
229
|
-
...
|
|
229
|
+
...j.isPending ? ["pauseRecurrence"] : [],
|
|
230
|
+
...M.isPending ? ["resumeRecurrence"] : [],
|
|
231
|
+
...T.isPending ? ["clone"] : [],
|
|
232
|
+
...C.isPending || Y || J && Q.isLoading ? ["issue", "issueAndSend"] : []
|
|
230
233
|
],
|
|
231
|
-
openAction:
|
|
232
|
-
closeAction:
|
|
233
|
-
confirmAction:
|
|
234
|
-
sendOpen: !!
|
|
235
|
-
sendValues:
|
|
234
|
+
openAction: be,
|
|
235
|
+
closeAction: xe,
|
|
236
|
+
confirmAction: Se,
|
|
237
|
+
sendOpen: !!z,
|
|
238
|
+
sendValues: V,
|
|
236
239
|
sendErrors: he,
|
|
237
|
-
sendInProgress:
|
|
238
|
-
setSendValues:
|
|
240
|
+
sendInProgress: ge,
|
|
241
|
+
setSendValues: H,
|
|
239
242
|
closeSend: $,
|
|
240
|
-
submitSend:
|
|
243
|
+
submitSend: Ce,
|
|
241
244
|
payment: G
|
|
242
245
|
};
|
|
243
246
|
}
|
|
244
|
-
function
|
|
247
|
+
function fe(e, t, n) {
|
|
245
248
|
let r = (t?.iterations ?? []).filter((e) => e.status === "pending").length, a = i({
|
|
246
249
|
amount: e.total_amount_with_credit_notes * r,
|
|
247
250
|
currency: e.currency,
|
|
@@ -254,7 +257,7 @@ function de(e, t, n) {
|
|
|
254
257
|
n.cancelRecurrenceIrreversible
|
|
255
258
|
].join("\n");
|
|
256
259
|
}
|
|
257
|
-
function
|
|
260
|
+
function _(e) {
|
|
258
261
|
return {
|
|
259
262
|
counterpartId: e.counterpart_id,
|
|
260
263
|
billingAddressId: e.counterpart_billing_address?.id ?? void 0,
|
|
@@ -262,7 +265,7 @@ function v(e) {
|
|
|
262
265
|
hasReminder: l(e)
|
|
263
266
|
};
|
|
264
267
|
}
|
|
265
|
-
function
|
|
268
|
+
function pe({ action: e, description: t, title: n }, r) {
|
|
266
269
|
return e === "cancelRecurrence" ? {
|
|
267
270
|
title: r.cancelRecurrenceTitle,
|
|
268
271
|
description: t ?? "",
|
|
@@ -302,4 +305,4 @@ function fe({ action: e, description: t, title: n }, r) {
|
|
|
302
305
|
};
|
|
303
306
|
}
|
|
304
307
|
//#endregion
|
|
305
|
-
export {
|
|
308
|
+
export { g as useReceivableActions };
|