@tesouro/embedded-components-react 0.5.284 → 0.5.285
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 +27 -28
- package/dist/index.d.ts +6 -19
- package/dist/lib/ReceivablesWidget.d.ts +6 -19
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/ReceivablesWidget.js +268 -285
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/helpers.js +35 -60
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/labels.js +4 -6
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/useReceivableActions.js +124 -147
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/useReceivableActionsModal.js +6 -2
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/useReceivableIssuePreflight.js +10 -9
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/useReceivableRecurrence.js +1 -1
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/useReceivablesWidget.js +54 -48
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index.js +3 -4
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index14.js +2 -12
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index56.js +54 -87
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index57.js +185 -51
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index58.js +38 -187
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index7.js +33 -33
- package/dist/libs/tesouro-embedded-components-react/shared/feature/dist/lib/analytics/build-info.js +1 -1
- package/package.json +1 -1
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index59.js +0 -45
|
@@ -8,14 +8,7 @@ import { buildPaymentTermsPayload as h, buildPaymentTermsUpdatePayload as g, pay
|
|
|
8
8
|
import { createEmptyDiscount as v, discountFromDraft as y, discountToDraft as b } from "./discount.js";
|
|
9
9
|
import { validateDiscount as x, validateInvoiceTotals as S } from "./totals.js";
|
|
10
10
|
//#region ../../libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/helpers.js
|
|
11
|
-
|
|
12
|
-
to: "",
|
|
13
|
-
cc: "",
|
|
14
|
-
bcc: "",
|
|
15
|
-
subject: "",
|
|
16
|
-
body: ""
|
|
17
|
-
};
|
|
18
|
-
function w() {
|
|
11
|
+
function C() {
|
|
19
12
|
return {
|
|
20
13
|
type: "invoice",
|
|
21
14
|
customerId: "",
|
|
@@ -42,7 +35,7 @@ function w() {
|
|
|
42
35
|
...m()
|
|
43
36
|
};
|
|
44
37
|
}
|
|
45
|
-
function
|
|
38
|
+
function w(e, n) {
|
|
46
39
|
let r = t(e);
|
|
47
40
|
return r ? new Intl.DateTimeFormat(void 0, {
|
|
48
41
|
day: "2-digit",
|
|
@@ -50,25 +43,25 @@ function T(e, n) {
|
|
|
50
43
|
year: "numeric"
|
|
51
44
|
}).format(r) : n;
|
|
52
45
|
}
|
|
53
|
-
function
|
|
46
|
+
function T({ amount: t, currency: n, fallback: r }) {
|
|
54
47
|
return t == null || !n ? r : new Intl.NumberFormat(void 0, {
|
|
55
48
|
currency: n,
|
|
56
49
|
style: "currency"
|
|
57
50
|
}).format(t / 10 ** e(n));
|
|
58
51
|
}
|
|
59
|
-
function
|
|
52
|
+
function E(t, n) {
|
|
60
53
|
let r = Number(t);
|
|
61
54
|
if (!Number.isFinite(r)) return;
|
|
62
55
|
let i = n ? e(n) : 2;
|
|
63
56
|
return Math.round(r * 10 ** i);
|
|
64
57
|
}
|
|
65
|
-
function
|
|
58
|
+
function D(e, t) {
|
|
66
59
|
return e.document_id || t.untitledDocument;
|
|
67
60
|
}
|
|
68
|
-
function
|
|
61
|
+
function O(e, t) {
|
|
69
62
|
return e === "quote" ? t.quoteType : e === "credit_note" ? t.creditNoteType : t.invoiceType;
|
|
70
63
|
}
|
|
71
|
-
function
|
|
64
|
+
function k(e, t, n) {
|
|
72
65
|
let r = e.counterpart_name || (e.counterpart_id ? t.names.get(e.counterpart_id) : void 0);
|
|
73
66
|
return r ? {
|
|
74
67
|
customerLabel: r,
|
|
@@ -81,33 +74,33 @@ function A(e, t, n) {
|
|
|
81
74
|
customerState: "missing"
|
|
82
75
|
};
|
|
83
76
|
}
|
|
84
|
-
var
|
|
77
|
+
var A = {
|
|
85
78
|
names: /* @__PURE__ */ new Map(),
|
|
86
79
|
isResolving: !1
|
|
87
80
|
};
|
|
88
|
-
function
|
|
81
|
+
function j({ receivables: e, messages: t, customerNames: n = A }) {
|
|
89
82
|
return e.map((e) => ({
|
|
90
83
|
id: e.id,
|
|
91
84
|
type: e.type,
|
|
92
85
|
documentLabel: e.document_id || t.pendingValue,
|
|
93
|
-
...
|
|
86
|
+
...k(e, n, t),
|
|
94
87
|
status: e.status,
|
|
95
|
-
issueDateLabel:
|
|
96
|
-
dueDateLabel:
|
|
97
|
-
totalLabel:
|
|
88
|
+
issueDateLabel: w(e.issue_date, t.pendingValue),
|
|
89
|
+
dueDateLabel: w(e.type === "invoice" ? e.due_date : void 0, t.pendingValue),
|
|
90
|
+
totalLabel: T({
|
|
98
91
|
amount: e.total_amount,
|
|
99
92
|
currency: e.currency,
|
|
100
93
|
fallback: ""
|
|
101
94
|
})
|
|
102
95
|
}));
|
|
103
96
|
}
|
|
104
|
-
function
|
|
97
|
+
function M(e) {
|
|
105
98
|
if (e.memo || e.footer) return {
|
|
106
99
|
opening: e.memo || void 0,
|
|
107
100
|
closing: e.footer || void 0
|
|
108
101
|
};
|
|
109
102
|
}
|
|
110
|
-
function
|
|
103
|
+
function N({ values: e, counterpart: t, addresses: n }) {
|
|
111
104
|
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 || "";
|
|
112
105
|
return {
|
|
113
106
|
billingAddressId: i,
|
|
@@ -115,7 +108,7 @@ function P({ values: e, counterpart: t, addresses: n }) {
|
|
|
115
108
|
shippingAddressId: a
|
|
116
109
|
};
|
|
117
110
|
}
|
|
118
|
-
function
|
|
111
|
+
function P({ values: e, messages: t, willIssue: r = !1, hasStartedRecurrence: i = !1, canCreateCustomer: a = !0 }) {
|
|
119
112
|
let o = {}, s = a && !!e.customerName.trim();
|
|
120
113
|
!e.customerId && !s && (o.customerId = t.customerRequired);
|
|
121
114
|
let c = e.customerEmail.trim();
|
|
@@ -129,23 +122,23 @@ function F({ values: e, messages: t, willIssue: r = !1, hasStartedRecurrence: i
|
|
|
129
122
|
let p = x(e, t);
|
|
130
123
|
return p && (o.discount = p), o;
|
|
131
124
|
}
|
|
132
|
-
function
|
|
125
|
+
function F(e) {
|
|
133
126
|
return Object.keys(e).length > 0;
|
|
134
127
|
}
|
|
135
|
-
function
|
|
136
|
-
return !
|
|
137
|
-
values:
|
|
128
|
+
function I(e, t) {
|
|
129
|
+
return !F(P({
|
|
130
|
+
values: z(e),
|
|
138
131
|
messages: t,
|
|
139
132
|
willIssue: !0
|
|
140
133
|
}));
|
|
141
134
|
}
|
|
142
|
-
function
|
|
135
|
+
function L({ bankAccountId: e, bankAccountType: t }) {
|
|
143
136
|
return {
|
|
144
137
|
bank_account_id: e || void 0,
|
|
145
138
|
bank_account_type: e && t || void 0
|
|
146
139
|
};
|
|
147
140
|
}
|
|
148
|
-
function
|
|
141
|
+
function R({ values: e, billingAddressId: t, shippingAddressId: n, unitNamesById: r }) {
|
|
149
142
|
let a = e.lineItems.filter((e) => !i(e)).map((t) => o({
|
|
150
143
|
lineItem: t,
|
|
151
144
|
currency: e.currency,
|
|
@@ -160,7 +153,7 @@ function z({ values: e, billingAddressId: t, shippingAddressId: n, unitNamesById
|
|
|
160
153
|
memo: e.openingNote,
|
|
161
154
|
footer: e.closingNote,
|
|
162
155
|
discount: y(e) ?? void 0,
|
|
163
|
-
...
|
|
156
|
+
...L(e)
|
|
164
157
|
};
|
|
165
158
|
return e.type === "quote" ? {
|
|
166
159
|
...s,
|
|
@@ -176,19 +169,19 @@ function z({ values: e, billingAddressId: t, shippingAddressId: n, unitNamesById
|
|
|
176
169
|
type: "invoice"
|
|
177
170
|
};
|
|
178
171
|
}
|
|
179
|
-
function
|
|
172
|
+
function z(e, t) {
|
|
180
173
|
let n = e.type === "quote" ? "quote" : "invoice", i = u(e.line_items), a = e.type === "invoice" ? e : void 0, o = e.line_items.map((n) => c({
|
|
181
174
|
lineItem: n,
|
|
182
175
|
currency: e.currency,
|
|
183
176
|
units: t
|
|
184
177
|
}));
|
|
185
178
|
return {
|
|
186
|
-
...
|
|
179
|
+
...C(),
|
|
187
180
|
type: n,
|
|
188
181
|
customerId: e.counterpart_id,
|
|
189
182
|
currency: e.currency,
|
|
190
|
-
issueDate:
|
|
191
|
-
dueDate: e.type === "quote" ?
|
|
183
|
+
issueDate: W(e.issue_date),
|
|
184
|
+
dueDate: e.type === "quote" ? W(e.expiry_date) : "",
|
|
192
185
|
openingNote: e.memo ?? "",
|
|
193
186
|
closingNote: e.footer ?? "",
|
|
194
187
|
...e.type === "invoice" ? _(e.payment_terms) : {},
|
|
@@ -197,7 +190,7 @@ function B(e, t) {
|
|
|
197
190
|
...b(e.discount, e.currency),
|
|
198
191
|
lineItems: o.length > 0 ? o : [r(e.currency)],
|
|
199
192
|
bankAccountId: e.bank_account_id ?? "",
|
|
200
|
-
bankAccountType:
|
|
193
|
+
bankAccountType: B(e.bank_account_type),
|
|
201
194
|
billingAddressId: e.counterpart_billing_address?.id ?? "",
|
|
202
195
|
shippingAddressId: e.counterpart_shipping_address?.id ?? "",
|
|
203
196
|
paymentReminderId: a?.payment_reminder_id ?? "",
|
|
@@ -206,10 +199,10 @@ function B(e, t) {
|
|
|
206
199
|
attachments: p(e)
|
|
207
200
|
};
|
|
208
201
|
}
|
|
209
|
-
function
|
|
202
|
+
function B(e) {
|
|
210
203
|
return e === "BANK_DETAILS" || e === "INTERNAL" || e === "EXTERNAL" ? e : "";
|
|
211
204
|
}
|
|
212
|
-
function
|
|
205
|
+
function V({ values: e, billingAddressId: t, shippingAddressId: n, lineItemChanges: r }) {
|
|
213
206
|
let i = {
|
|
214
207
|
counterpart_billing_address_id: t || null,
|
|
215
208
|
counterpart_shipping_address_id: n || null,
|
|
@@ -219,7 +212,7 @@ function H({ values: e, billingAddressId: t, shippingAddressId: n, lineItemChang
|
|
|
219
212
|
memo: e.openingNote,
|
|
220
213
|
footer: e.closingNote,
|
|
221
214
|
discount: y(e),
|
|
222
|
-
...
|
|
215
|
+
...L(e)
|
|
223
216
|
};
|
|
224
217
|
return e.type === "quote" ? { quote: {
|
|
225
218
|
...i,
|
|
@@ -235,7 +228,7 @@ function H({ values: e, billingAddressId: t, shippingAddressId: n, lineItemChang
|
|
|
235
228
|
attachments: f(e.attachments) ?? null
|
|
236
229
|
} };
|
|
237
230
|
}
|
|
238
|
-
function
|
|
231
|
+
function H({ values: e, originalLineItems: t, originalCurrency: n, unitNamesById: r, units: o }) {
|
|
239
232
|
let l = u(t), d = a(e.taxRate, l), f = (e, t, n) => s({
|
|
240
233
|
lineItem: e,
|
|
241
234
|
currency: t,
|
|
@@ -261,7 +254,7 @@ function U({ values: e, originalLineItems: t, originalCurrency: n, unitNamesById
|
|
|
261
254
|
...v.length ? { remove: v } : {}
|
|
262
255
|
};
|
|
263
256
|
}
|
|
264
|
-
function
|
|
257
|
+
function U({ values: e, originalLineItems: t, changes: n }) {
|
|
265
258
|
let r = e.lineItems.filter((e) => !i(e)).map((e) => e.id);
|
|
266
259
|
if (!t) return { created: r };
|
|
267
260
|
let a = new Set(t.map((e) => e.id));
|
|
@@ -270,26 +263,8 @@ function W({ values: e, originalLineItems: t, changes: n }) {
|
|
|
270
263
|
replaced: n?.replace?.map((e) => e.id) ?? []
|
|
271
264
|
};
|
|
272
265
|
}
|
|
273
|
-
function
|
|
266
|
+
function W(e) {
|
|
274
267
|
return e?.slice(0, 10) ?? "";
|
|
275
268
|
}
|
|
276
|
-
function K(e, t) {
|
|
277
|
-
let n = {};
|
|
278
|
-
return e.to.trim() || (n.to = t.sendToRequired), e.subject.trim() || (n.subject = t.sendSubjectRequired), e.body.trim() || (n.body = t.sendBodyRequired), n;
|
|
279
|
-
}
|
|
280
|
-
function q(e) {
|
|
281
|
-
return Object.keys(e).length > 0;
|
|
282
|
-
}
|
|
283
|
-
function J(e) {
|
|
284
|
-
return e.split(",").map((e) => e.trim()).filter(Boolean);
|
|
285
|
-
}
|
|
286
|
-
function Y(e, t) {
|
|
287
|
-
return {
|
|
288
|
-
...C,
|
|
289
|
-
to: e?.counterpart_contact?.email ?? "",
|
|
290
|
-
subject: e?.document_id ? `${t.sendSubjectDefault} ${e.document_id}` : t.sendSubjectDefault,
|
|
291
|
-
body: t.sendBodyDefault
|
|
292
|
-
};
|
|
293
|
-
}
|
|
294
269
|
//#endregion
|
|
295
|
-
export {
|
|
270
|
+
export { M as buildReceivableNotesView, j as buildReceivableRows, C as createEmptyReceivableFormValues, r as createLineItem, w as formatDate, T as formatMoney, E as fromMajorUnits, D as getDocumentTitle, O as getDocumentTypeLabel, F as hasReceivableFormErrors, I as isReceivableReadyToIssue, R as receivableFormValuesToCreatePayload, H as receivableFormValuesToLineItemChanges, V as receivableFormValuesToUpdatePayload, z as receivableToFormValues, N as resolveCounterpartAddresses, U as submittedLineItemRows, P as validateReceivableForm };
|
|
@@ -18,9 +18,6 @@ var e = {
|
|
|
18
18
|
discountExceedsSubtotal: "Discount amount cannot exceed subtotal",
|
|
19
19
|
invoiceSubtotalTooHigh: "Invoice subtotal must be {maxAmount} or less",
|
|
20
20
|
invoiceTotalTooHigh: "Invoice total must be {maxAmount} or less",
|
|
21
|
-
sendToRequired: "Enter at least one recipient",
|
|
22
|
-
sendSubjectRequired: "Subject is required",
|
|
23
|
-
sendBodyRequired: "Message is required",
|
|
24
21
|
paymentRecordAmountRequired: "Amount is required",
|
|
25
22
|
paymentRecordAmountNegative: "Can't be a negative number",
|
|
26
23
|
paymentRecordAmountZero: "Amount must be greater than 0",
|
|
@@ -107,8 +104,6 @@ var e = {
|
|
|
107
104
|
detailsIterationStatusIssueFailed: "Issue failed",
|
|
108
105
|
detailsIterationStatusSendFailed: "Send failed",
|
|
109
106
|
detailsIterationStatusCompleted: "Complete",
|
|
110
|
-
sendSubjectDefault: "Your receivable document",
|
|
111
|
-
sendBodyDefault: "Please find the receivable document attached.",
|
|
112
107
|
issueSucceeded: "Invoice has been issued",
|
|
113
108
|
acceptTitle: "Accept quote?",
|
|
114
109
|
acceptDescription: "This marks the quote as accepted.",
|
|
@@ -117,7 +112,7 @@ var e = {
|
|
|
117
112
|
declineDescription: "This marks the quote as declined.",
|
|
118
113
|
declineConfirm: "Decline",
|
|
119
114
|
issueFailed: "Failed to issue invoice. Add any missing information to your draft invoice and try again.",
|
|
120
|
-
|
|
115
|
+
sendNoEmail: "This customer has no email address. Add one in the customer details to send the invoice.",
|
|
121
116
|
cancelTitle: "Cancel receivable?",
|
|
122
117
|
cancelNumberedTitle: "Cancel receivable \"{number}\"?",
|
|
123
118
|
cancelDescription: "This action can't be undone.",
|
|
@@ -249,6 +244,9 @@ var e = {
|
|
|
249
244
|
unknownError: "Unknown",
|
|
250
245
|
apiErrorsSummary: "{message} (+{count} more)",
|
|
251
246
|
actionsIssueTitle: "Invoice issued. Send a copy to {name}?",
|
|
247
|
+
actionsResendTitle: "Send a copy to {name}?",
|
|
248
|
+
actionsIssueDismiss: "Skip",
|
|
249
|
+
actionsResendDismiss: "Cancel",
|
|
252
250
|
actionsSubjectWithNumber: "Invoice #{documentId} for {name}",
|
|
253
251
|
actionsSubject: "Invoice for {name}",
|
|
254
252
|
actionsSendSucceeded: "Invoice sent successfully",
|
|
@@ -11,84 +11,95 @@ import { useAcceptReceivableMutation as r, useCancelReceivableMutation as i, use
|
|
|
11
11
|
import { useMarkReceivablePaidMutation as l, useMarkReceivableUncollectibleMutation as u } from "../../../../data-access/dist/index13.js";
|
|
12
12
|
import { useCancelRecurrenceMutation as ee, usePauseRecurrenceMutation as te, useResumeRecurrenceMutation as ne } from "../../../../data-access/dist/index15.js";
|
|
13
13
|
import "../../../../data-access/dist/index.js";
|
|
14
|
-
import {
|
|
15
|
-
import { getIssueReminderBlocker as
|
|
16
|
-
import { useReceivableIssuePreflight as
|
|
17
|
-
import { useReceivablePaymentRecord as
|
|
18
|
-
import {
|
|
19
|
-
import { useCallback as h, useEffect as ue, useState as g } from "react";
|
|
14
|
+
import { formatMoney as d, isReceivableReadyToIssue as f } from "./helpers.js";
|
|
15
|
+
import { getIssueReminderBlocker as p, hasSelectedReminder as m } from "./reminders.js";
|
|
16
|
+
import { useReceivableIssuePreflight as re } from "./useReceivableIssuePreflight.js";
|
|
17
|
+
import { useReceivablePaymentRecord as ie } from "./useReceivablePaymentRecord.js";
|
|
18
|
+
import { useCallback as h, useEffect as g, useState as _ } from "react";
|
|
20
19
|
//#region ../../libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/useReceivableActions.js
|
|
21
|
-
function
|
|
22
|
-
let
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
billingAddressId: X?.billingAddressId,
|
|
28
|
-
billingCountry: X?.billingCountry
|
|
20
|
+
function v({ selectedReceivable: d, selectedRecurrence: v, messages: b, onCreated: x, onDeleted: S, onCompleteBeforeIssue: C, onIssuedForSend: w, onResend: T }) {
|
|
21
|
+
let E = c(), D = i(), O = a(), k = r(), A = o(), j = s(), M = l(), N = u(), P = te(), F = ne(), I = ee(), [L, R] = _(), [se, z] = _(), [B, V] = _(""), H = ie({ messages: b }), U = H.open, W = P.mutate, G = O.mutate, K = F.mutate, q = d?.type === "invoice" && d.status === "draft" ? d : void 0, J = d?.type === "invoice" && d.status !== "draft" ? d : void 0, [Y, X] = _(), Z = Y?.issueCheck ?? (q ? y(q) : void 0), Q = E.mutate, $ = re({
|
|
22
|
+
counterpartId: Z?.counterpartId ?? J?.counterpart_id,
|
|
23
|
+
billingAddressId: Z?.billingAddressId,
|
|
24
|
+
billingCountry: Z?.billingCountry,
|
|
25
|
+
checkRequiredFields: !!Z
|
|
29
26
|
});
|
|
30
|
-
|
|
31
|
-
if (!Y ||
|
|
32
|
-
|
|
33
|
-
let t = Y.issueCheck ?
|
|
27
|
+
g(() => {
|
|
28
|
+
if (!Y || $.isLoading) return;
|
|
29
|
+
X(void 0);
|
|
30
|
+
let t = Y.issueCheck ? $.isTaxIdMissing ? b.issueTaxIdRequired : Y.issueCheck.hasReminder ? p($.counterpart, b) : void 0 : void 0;
|
|
34
31
|
if (t) {
|
|
35
32
|
e.error(t);
|
|
36
33
|
return;
|
|
37
34
|
}
|
|
38
|
-
|
|
39
|
-
onSuccess: () => e.success(
|
|
40
|
-
onError: () => e.error(
|
|
35
|
+
Q({ path: { receivable_id: Y.id } }, {
|
|
36
|
+
onSuccess: () => e.success(b.issueSucceeded),
|
|
37
|
+
onError: () => e.error(b.issueFailed)
|
|
41
38
|
});
|
|
42
39
|
}, [
|
|
43
|
-
|
|
44
|
-
|
|
40
|
+
Q,
|
|
41
|
+
b,
|
|
45
42
|
Y,
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
43
|
+
$.counterpart,
|
|
44
|
+
$.isLoading,
|
|
45
|
+
$.isTaxIdMissing
|
|
49
46
|
]);
|
|
50
|
-
let
|
|
47
|
+
let ce = h((r, i, a) => {
|
|
51
48
|
let o = "documentLabel" in i ? i.documentLabel : i.title, s = {
|
|
52
49
|
id: i.id,
|
|
53
50
|
type: i.type,
|
|
54
51
|
title: o,
|
|
55
52
|
action: r
|
|
56
|
-
}, c = a === void 0 ?
|
|
53
|
+
}, c = a === void 0 ? d : a ?? void 0;
|
|
57
54
|
if (r === "send") {
|
|
58
|
-
|
|
55
|
+
if (c?.type !== "invoice" || $.isCounterpartLoading) return;
|
|
56
|
+
if ($.isCounterpartError) {
|
|
57
|
+
e.error(b.genericError);
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
let t = $.counterpart?.id === c.counterpart_id ? $.counterpart : void 0;
|
|
61
|
+
if (!t || !n(t)) {
|
|
62
|
+
e.error(b.sendNoEmail);
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
T?.(c.id, c.counterpart_id);
|
|
59
66
|
return;
|
|
60
67
|
}
|
|
61
68
|
if (r === "issueAndSend") {
|
|
62
69
|
if (c?.type !== "invoice") return;
|
|
63
70
|
let t = c;
|
|
64
|
-
if (
|
|
65
|
-
if (
|
|
66
|
-
e.error(
|
|
71
|
+
if ($.isLoading) return;
|
|
72
|
+
if ($.isCounterpartError) {
|
|
73
|
+
e.error(b.genericError);
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
if (!$.counterpart || !n($.counterpart)) {
|
|
77
|
+
e.error(b.sendNoEmail);
|
|
67
78
|
return;
|
|
68
79
|
}
|
|
69
|
-
if (
|
|
70
|
-
|
|
80
|
+
if (C && !f(t, b)) {
|
|
81
|
+
C(t, "issueAndSend");
|
|
71
82
|
return;
|
|
72
83
|
}
|
|
73
|
-
let r =
|
|
84
|
+
let r = $.isTaxIdMissing ? b.issueTaxIdRequired : m(t) ? p($.counterpart, b) : void 0;
|
|
74
85
|
if (r) {
|
|
75
86
|
e.error(r);
|
|
76
87
|
return;
|
|
77
88
|
}
|
|
78
|
-
|
|
89
|
+
Q({ path: { receivable_id: t.id } }, {
|
|
79
90
|
onSuccess: () => {
|
|
80
|
-
e.success(
|
|
91
|
+
e.success(b.issueSucceeded), w?.(t.id, t.counterpart_id);
|
|
81
92
|
},
|
|
82
|
-
onError: () => e.error(
|
|
93
|
+
onError: () => e.error(b.issueFailed)
|
|
83
94
|
});
|
|
84
95
|
return;
|
|
85
96
|
}
|
|
86
97
|
if (r === "clone") {
|
|
87
|
-
|
|
98
|
+
G({ path: { receivable_id: i.id } }, {
|
|
88
99
|
onSuccess: (t) => {
|
|
89
|
-
t?.id &&
|
|
100
|
+
t?.id && x?.(t.id, t.type), e.success(b.cloneSuccess);
|
|
90
101
|
},
|
|
91
|
-
onError: (n) => e.error(t(n) ??
|
|
102
|
+
onError: (n) => e.error(t(n) ?? b.cloneError)
|
|
92
103
|
});
|
|
93
104
|
return;
|
|
94
105
|
}
|
|
@@ -96,156 +107,122 @@ function _({ selectedReceivable: f, selectedRecurrence: _, messages: y, onCreate
|
|
|
96
107
|
if (r === "pauseRecurrence" || r === "resumeRecurrence") {
|
|
97
108
|
if (!l) return;
|
|
98
109
|
let n = r === "pauseRecurrence";
|
|
99
|
-
(n ?
|
|
110
|
+
(n ? W : K)({
|
|
100
111
|
path: { recurrence_id: l },
|
|
101
112
|
receivableId: i.id
|
|
102
113
|
}, {
|
|
103
|
-
onSuccess: () => e.success(n ?
|
|
104
|
-
onError: (n) => e.error(t(n) ??
|
|
114
|
+
onSuccess: () => e.success(n ? b.recurrencePaused : b.recurrenceResumed),
|
|
115
|
+
onError: (n) => e.error(t(n) ?? b.genericError)
|
|
105
116
|
});
|
|
106
117
|
return;
|
|
107
118
|
}
|
|
108
119
|
if (r === "cancelRecurrence") {
|
|
109
120
|
if (!l || c?.type !== "invoice") return;
|
|
110
|
-
|
|
121
|
+
z(void 0), R({
|
|
111
122
|
...s,
|
|
112
123
|
recurrenceId: l,
|
|
113
|
-
description:
|
|
124
|
+
description: ae(c, v, b)
|
|
114
125
|
});
|
|
115
126
|
return;
|
|
116
127
|
}
|
|
117
128
|
if (r === "recordPayment") {
|
|
118
|
-
c?.type === "invoice" &&
|
|
129
|
+
c?.type === "invoice" && U(c);
|
|
119
130
|
return;
|
|
120
131
|
}
|
|
121
132
|
let u = r === "issue" && c?.type === "invoice" ? c : void 0;
|
|
122
|
-
if (u &&
|
|
123
|
-
|
|
133
|
+
if (u && C && !f(u, b)) {
|
|
134
|
+
C(u, "issue");
|
|
124
135
|
return;
|
|
125
136
|
}
|
|
126
137
|
if (r === "issue") {
|
|
127
|
-
|
|
138
|
+
X({
|
|
128
139
|
id: i.id,
|
|
129
|
-
issueCheck: u ?
|
|
140
|
+
issueCheck: u ? y(u) : void 0
|
|
130
141
|
});
|
|
131
142
|
return;
|
|
132
143
|
}
|
|
133
|
-
|
|
144
|
+
z(void 0), V(""), R(s);
|
|
134
145
|
}, [
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
y,
|
|
138
|
-
S,
|
|
146
|
+
G,
|
|
147
|
+
Q,
|
|
139
148
|
b,
|
|
140
149
|
C,
|
|
150
|
+
x,
|
|
151
|
+
w,
|
|
152
|
+
T,
|
|
153
|
+
U,
|
|
154
|
+
$.counterpart,
|
|
155
|
+
$.isCounterpartError,
|
|
156
|
+
$.isCounterpartLoading,
|
|
157
|
+
$.isLoading,
|
|
158
|
+
$.isTaxIdMissing,
|
|
159
|
+
W,
|
|
141
160
|
K,
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
}, []), $ = h(() => {
|
|
152
|
-
me(void 0), U({});
|
|
153
|
-
}, []), Se = h(async () => {
|
|
154
|
-
if (!F) return;
|
|
155
|
-
let n = { receivable_id: F.id };
|
|
156
|
-
if (F.action === "cancelRecurrence") {
|
|
157
|
-
if (!F.recurrenceId) return;
|
|
161
|
+
d,
|
|
162
|
+
v
|
|
163
|
+
]), le = h(() => {
|
|
164
|
+
R(void 0), z(void 0);
|
|
165
|
+
}, []), ue = h(async () => {
|
|
166
|
+
if (!L) return;
|
|
167
|
+
let n = { receivable_id: L.id };
|
|
168
|
+
if (L.action === "cancelRecurrence") {
|
|
169
|
+
if (!L.recurrenceId) return;
|
|
158
170
|
try {
|
|
159
|
-
await
|
|
160
|
-
path: { recurrence_id:
|
|
161
|
-
receivableId:
|
|
162
|
-
}), e.success(
|
|
171
|
+
await I.mutateAsync({
|
|
172
|
+
path: { recurrence_id: L.recurrenceId },
|
|
173
|
+
receivableId: L.id
|
|
174
|
+
}), e.success(b.recurrenceCanceled), R(void 0);
|
|
163
175
|
} catch (n) {
|
|
164
|
-
e.error(t(n) ??
|
|
176
|
+
e.error(t(n) ?? b.genericError);
|
|
165
177
|
}
|
|
166
178
|
return;
|
|
167
179
|
}
|
|
168
180
|
try {
|
|
169
|
-
|
|
181
|
+
L.action === "cancel" ? await D.mutateAsync({ path: n }) : L.action === "accept" ? await k.mutateAsync({ path: n }) : L.action === "decline" ? await A.mutateAsync({ path: n }) : L.action === "delete" ? (await j.mutateAsync({ path: n }), S?.(L.id)) : L.action === "markPaid" ? await M.mutateAsync({
|
|
170
182
|
path: n,
|
|
171
183
|
body: { paid_at: (/* @__PURE__ */ new Date()).toISOString() }
|
|
172
|
-
}) :
|
|
184
|
+
}) : L.action === "markUncollectible" && await N.mutateAsync({
|
|
173
185
|
path: n,
|
|
174
|
-
body: { comment:
|
|
175
|
-
}),
|
|
186
|
+
body: { comment: B.trim() || void 0 }
|
|
187
|
+
}), R(void 0), z(void 0);
|
|
176
188
|
} catch (e) {
|
|
177
|
-
|
|
189
|
+
z(t(e) ?? b.genericError);
|
|
178
190
|
}
|
|
179
191
|
}, [
|
|
180
|
-
D,
|
|
181
|
-
R,
|
|
182
|
-
F,
|
|
183
|
-
T,
|
|
184
|
-
P,
|
|
185
|
-
O,
|
|
186
192
|
k,
|
|
187
|
-
A,
|
|
188
|
-
y,
|
|
189
|
-
x,
|
|
190
|
-
j
|
|
191
|
-
]), Ce = h(async () => {
|
|
192
|
-
if (!B) return;
|
|
193
|
-
let e = ie(V, y);
|
|
194
|
-
if (re(e)) {
|
|
195
|
-
U(e);
|
|
196
|
-
return;
|
|
197
|
-
}
|
|
198
|
-
try {
|
|
199
|
-
await W({
|
|
200
|
-
path: { receivable_id: B.id },
|
|
201
|
-
body: {
|
|
202
|
-
body_text: V.body,
|
|
203
|
-
subject_text: V.subject,
|
|
204
|
-
recipients: {
|
|
205
|
-
to: m(V.to),
|
|
206
|
-
cc: m(V.cc),
|
|
207
|
-
bcc: m(V.bcc)
|
|
208
|
-
}
|
|
209
|
-
}
|
|
210
|
-
}), $();
|
|
211
|
-
} catch (e) {
|
|
212
|
-
U({ form: t(e) ?? y.genericError });
|
|
213
|
-
}
|
|
214
|
-
}, [
|
|
215
|
-
$,
|
|
216
|
-
y,
|
|
217
|
-
W,
|
|
218
193
|
B,
|
|
219
|
-
|
|
194
|
+
L,
|
|
195
|
+
D,
|
|
196
|
+
I,
|
|
197
|
+
A,
|
|
198
|
+
j,
|
|
199
|
+
M,
|
|
200
|
+
b,
|
|
201
|
+
S,
|
|
202
|
+
N
|
|
220
203
|
]);
|
|
221
204
|
return {
|
|
222
|
-
actionTarget:
|
|
223
|
-
actionDialog:
|
|
224
|
-
actionError:
|
|
225
|
-
actionComment:
|
|
226
|
-
setActionComment:
|
|
227
|
-
actionInProgress:
|
|
205
|
+
actionTarget: L,
|
|
206
|
+
actionDialog: L ? oe(L, b) : void 0,
|
|
207
|
+
actionError: se,
|
|
208
|
+
actionComment: L?.action === "markUncollectible" ? B : void 0,
|
|
209
|
+
setActionComment: V,
|
|
210
|
+
actionInProgress: E.isPending || D.isPending || k.isPending || A.isPending || j.isPending || M.isPending || N.isPending || I.isPending,
|
|
228
211
|
pendingActions: [
|
|
229
|
-
...
|
|
230
|
-
...
|
|
231
|
-
...
|
|
232
|
-
...
|
|
212
|
+
...P.isPending ? ["pauseRecurrence"] : [],
|
|
213
|
+
...F.isPending ? ["resumeRecurrence"] : [],
|
|
214
|
+
...O.isPending ? ["clone"] : [],
|
|
215
|
+
...E.isPending || Y || q && $.isLoading ? ["issue", "issueAndSend"] : [],
|
|
216
|
+
...J && $.isCounterpartLoading ? ["send"] : []
|
|
233
217
|
],
|
|
234
|
-
openAction:
|
|
235
|
-
closeAction:
|
|
236
|
-
confirmAction:
|
|
237
|
-
|
|
238
|
-
sendValues: V,
|
|
239
|
-
sendErrors: he,
|
|
240
|
-
sendInProgress: ge,
|
|
241
|
-
setSendValues: H,
|
|
242
|
-
closeSend: $,
|
|
243
|
-
submitSend: Ce,
|
|
244
|
-
payment: G
|
|
218
|
+
openAction: ce,
|
|
219
|
+
closeAction: le,
|
|
220
|
+
confirmAction: ue,
|
|
221
|
+
payment: H
|
|
245
222
|
};
|
|
246
223
|
}
|
|
247
|
-
function
|
|
248
|
-
let r = (t?.iterations ?? []).filter((e) => e.status === "pending").length, i =
|
|
224
|
+
function ae(e, t, n) {
|
|
225
|
+
let r = (t?.iterations ?? []).filter((e) => e.status === "pending").length, i = d({
|
|
249
226
|
amount: e.total_amount_with_credit_notes * r,
|
|
250
227
|
currency: e.currency,
|
|
251
228
|
fallback: ""
|
|
@@ -257,15 +234,15 @@ function de(e, t, n) {
|
|
|
257
234
|
n.cancelRecurrenceIrreversible
|
|
258
235
|
].join("\n");
|
|
259
236
|
}
|
|
260
|
-
function
|
|
237
|
+
function y(e) {
|
|
261
238
|
return {
|
|
262
239
|
counterpartId: e.counterpart_id,
|
|
263
240
|
billingAddressId: e.counterpart_billing_address?.id ?? void 0,
|
|
264
241
|
billingCountry: e.counterpart_billing_address?.country,
|
|
265
|
-
hasReminder:
|
|
242
|
+
hasReminder: m(e)
|
|
266
243
|
};
|
|
267
244
|
}
|
|
268
|
-
function
|
|
245
|
+
function oe({ action: e, description: t, title: n }, r) {
|
|
269
246
|
return e === "cancelRecurrence" ? {
|
|
270
247
|
title: r.cancelRecurrenceTitle,
|
|
271
248
|
description: t ?? "",
|
|
@@ -305,4 +282,4 @@ function fe({ action: e, description: t, title: n }, r) {
|
|
|
305
282
|
};
|
|
306
283
|
}
|
|
307
284
|
//#endregion
|
|
308
|
-
export {
|
|
285
|
+
export { v as useReceivableActions };
|