@tesouro/embedded-components-react 0.5.225 → 0.5.226
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 +21 -21
- package/dist/index.d.ts +23 -2
- package/dist/index.js +1 -1
- package/dist/lib/ReceivablesWidget.d.ts +23 -2
- package/dist/lib/ReceivablesWidget.js +1 -1
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index.js +4 -4
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index10.js +45 -31
- 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/index12.js +51 -32
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index13.js +20 -1
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index15.js +17 -202
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index16.js +220 -31
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index17.js +32 -145
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index18.js +126 -44
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index19.js +145 -117
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index20.js +46 -58
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index21.js +113 -87
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index22.js +58 -116
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index23.js +98 -225
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index24.js +111 -27
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index25.js +225 -462
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index26.js +34 -41
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index27.js +627 -34
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index28.js +39 -77
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index29.js +34 -112
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index30.js +75 -310
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index31.js +124 -0
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index32.js +324 -0
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index6.js +20 -15
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index8.js +56 -53
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index9.js +33 -29
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index25.js +184 -162
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index4.js +1 -3
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index6.js +78 -69
- package/dist/libs/tesouro-embedded-components-react/shared/counterpart-management/feature/dist/lib/CounterpartSelector.js +7 -6
- package/dist/libs/tesouro-embedded-components-react/shared/counterpart-management/ui/dist/index15.js +20 -19
- package/dist/libs/tesouro-embedded-components-react/shared/data-access/dist/index.js +39 -39
- package/dist/libs/tesouro-embedded-components-react/shared/data-access/dist/lib/rest/@tanstack/react-query.gen.js +210 -199
- package/dist/libs/tesouro-embedded-components-react/shared/data-access/dist/lib/rest/sdk.gen.js +60 -52
- 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/feature/dist/index25.js
CHANGED
|
@@ -1,474 +1,237 @@
|
|
|
1
|
-
|
|
2
|
-
"use client";
|
|
3
|
-
"use client";
|
|
4
|
-
"use client";
|
|
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";
|
|
1
|
+
import { minorExponentForCurrency as e } from "../../../shared/util/dist/lib/amountOutputToMajorUnits.js";
|
|
11
2
|
import "../../ui/dist/index10.js";
|
|
12
3
|
import "../../ui/dist/index.js";
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
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 { useReceivablePreview as Je } from "./index24.js";
|
|
29
|
-
import { getCurrencyOptions as Ye } from "../../../shared/product-catalog/feature/dist/lib/helpers.js";
|
|
30
|
-
import { useMeasureUnitsQuery as Xe } from "../../../shared/product-catalog/data-access/dist/index9.js";
|
|
31
|
-
import { useMeasureUnits as Ze } from "../../../shared/product-catalog/feature/dist/lib/useMeasureUnits.js";
|
|
32
|
-
import "../../../shared/product-catalog/feature/dist/index.js";
|
|
33
|
-
import { useCallback as s, useEffect as c, useMemo as l, useRef as u, useState as d } from "react";
|
|
4
|
+
import { isBlankLineItem as t, keepsSavedTaxRates as n, lineItemTaxRateMinorUnits as r, parseQuantity as i, priceInputToMinorUnits as a, taxRateToMinorUnits as o } from "./index6.js";
|
|
5
|
+
import { formatTermDate as s, resolveIssueDate as c, termDueDate as l } from "./index9.js";
|
|
6
|
+
import { formatMoney as u } from "./index12.js";
|
|
7
|
+
import { differenceInCalendarDays as d, parseISO as f } from "date-fns";
|
|
34
8
|
//#region ../../libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index25.js
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
counterpartType: "customer",
|
|
72
|
-
counterpart: void 0,
|
|
73
|
-
primaryAddress: mt
|
|
74
|
-
}), bt = s((e) => w((t) => {
|
|
75
|
-
let n = e({
|
|
76
|
-
paymentTermsId: t.paymentTermsId,
|
|
77
|
-
paymentTermsCustomDate: t.paymentTermsCustomDate
|
|
78
|
-
});
|
|
9
|
+
var p = "US", m = 100;
|
|
10
|
+
function h(e) {
|
|
11
|
+
try {
|
|
12
|
+
return new Intl.DisplayNames(void 0, { type: "region" }).of(e) ?? e;
|
|
13
|
+
} catch {
|
|
14
|
+
return e;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
function g({ address: e, issuerCountry: t, formatCountry: n = h }) {
|
|
18
|
+
if (!e) return [];
|
|
19
|
+
let r = [e.city, e.state].filter(Boolean).join(", "), i = e.country === p && t === p;
|
|
20
|
+
return [
|
|
21
|
+
[e.line1, e.line2].filter(Boolean).join(" "),
|
|
22
|
+
[r, e.postal_code].filter(Boolean).join(" "),
|
|
23
|
+
e.country && !i ? n(e.country) : ""
|
|
24
|
+
].filter(Boolean);
|
|
25
|
+
}
|
|
26
|
+
var _ = { kind: "pending" }, v = (e) => ({
|
|
27
|
+
kind: "text",
|
|
28
|
+
lines: e
|
|
29
|
+
});
|
|
30
|
+
function y(e, t) {
|
|
31
|
+
return e.previewNetDays.replace("{days}", String(t));
|
|
32
|
+
}
|
|
33
|
+
function b(e, t) {
|
|
34
|
+
let n = e.previewEarlyPaymentDays.replace("{days}", String(t.number_of_days));
|
|
35
|
+
return t.discount ? `${n}, ${e.previewEarlyPaymentDiscount.replace("{rate}", String(t.discount / m))}` : n;
|
|
36
|
+
}
|
|
37
|
+
function x({ paymentTermsId: e, paymentTermsCustomDate: t, paymentTerms: n, issueDate: r, messages: i }) {
|
|
38
|
+
let a = {
|
|
39
|
+
dueDate: _,
|
|
40
|
+
paymentTerms: _
|
|
41
|
+
};
|
|
42
|
+
if (e === "custom") {
|
|
43
|
+
if (!t) return a;
|
|
44
|
+
let e = f(t), n = Math.max(0, d(e, r));
|
|
79
45
|
return {
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
...n.paymentTermsId === "receipt_due" ? { paymentReminderId: "" } : {}
|
|
46
|
+
dueDate: v([s(e)]),
|
|
47
|
+
paymentTerms: v([y(i, n)])
|
|
83
48
|
};
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
paymentTermsCustomDate: C.paymentTermsCustomDate,
|
|
154
|
-
paymentReminderId: C.paymentReminderId,
|
|
155
|
-
overdueReminderId: C.overdueReminderId,
|
|
156
|
-
messages: f,
|
|
157
|
-
onSelect: jt
|
|
158
|
-
}), Y = Nt.reset, Pt = s(() => {
|
|
159
|
-
g.current = [], A(void 0), rt("create"), at(void 0), S(void 0), q.current = void 0, h.current = void 0, w(Ae()), T({}), M(!1), L(!1), I.current = {
|
|
160
|
-
lines: !1,
|
|
161
|
-
discount: !1
|
|
162
|
-
}, B(), J();
|
|
163
|
-
}, [B, J]), Ft = s((e = "invoice") => {
|
|
164
|
-
H(), U(), J();
|
|
165
|
-
let t = {
|
|
166
|
-
...Ae(),
|
|
167
|
-
type: e
|
|
168
|
-
};
|
|
169
|
-
Y(Le(t)), g.current = [], h.current = void 0, q.current = void 0, A(void 0), rt("create"), at(void 0), S(void 0), w(t), T({}), B(), M(!1), L(!1), I.current = {
|
|
170
|
-
lines: !1,
|
|
171
|
-
discount: !1
|
|
172
|
-
}, y(!0);
|
|
173
|
-
}, [
|
|
174
|
-
B,
|
|
175
|
-
H,
|
|
176
|
-
U,
|
|
177
|
-
J,
|
|
178
|
-
Y
|
|
179
|
-
]), It = s((e) => {
|
|
180
|
-
if (e.type === "credit_note") return;
|
|
181
|
-
H(), U(), J();
|
|
182
|
-
let t = Fe(e, O);
|
|
183
|
-
Y(Le(t)), g.current = e.line_items, _.current = e.currency, h.current = void 0, q.current = void 0, A(void 0), rt("edit"), at(e.id), S(e.type === "invoice" ? e.recurrence_id ?? void 0 : void 0), w(t), T({}), M(!1), L(!1), I.current = {
|
|
184
|
-
lines: !1,
|
|
185
|
-
discount: !1
|
|
186
|
-
}, B(), y(!0);
|
|
187
|
-
}, [
|
|
188
|
-
B,
|
|
189
|
-
H,
|
|
190
|
-
U,
|
|
191
|
-
J,
|
|
192
|
-
Y,
|
|
193
|
-
O
|
|
194
|
-
]);
|
|
195
|
-
c(() => {
|
|
196
|
-
O?.length && w((e) => {
|
|
197
|
-
let t = se(e.lineItems, O);
|
|
198
|
-
return t === e.lineItems ? e : {
|
|
199
|
-
...e,
|
|
200
|
-
lineItems: t
|
|
201
|
-
};
|
|
202
|
-
});
|
|
203
|
-
}, [O]);
|
|
204
|
-
let X = z.isUploading, Lt = s(() => {
|
|
205
|
-
X || (V(), y(!1), T({}));
|
|
206
|
-
}, [V, X]), Rt = s((e) => {
|
|
207
|
-
let t = { ...e };
|
|
208
|
-
t.taxRate !== void 0 && (t.taxRate = le(t.taxRate), F.current = !0), t.type !== void 0 && t.type !== "invoice" && V(), t.discount !== void 0 && j && (P.current = !0), t.discountType !== void 0 && (P.current = !0), t.currency !== void 0 && (N.current = !0), w((e) => {
|
|
209
|
-
let n = {
|
|
210
|
-
...e,
|
|
211
|
-
...t
|
|
212
|
-
};
|
|
213
|
-
return t.discount !== void 0 && (n.discount = Te(t.discount, n.discountType, n.currency)), n.currency !== e.currency && (n.lineItems = e.lineItems.map((t) => ({
|
|
214
|
-
...t,
|
|
215
|
-
price: ne(t.price, e.currency, n.currency)
|
|
216
|
-
}))), (n.currency !== e.currency || n.discountType !== e.discountType) && (n.discount = Se({
|
|
217
|
-
value: n.discount,
|
|
218
|
-
type: n.discountType,
|
|
219
|
-
currency: n.currency
|
|
220
|
-
})), n;
|
|
221
|
-
});
|
|
222
|
-
}, [V, j]), zt = s(() => L(!0), []), Bt = s(() => {
|
|
223
|
-
L(!1), P.current = !0, w((e) => ({
|
|
224
|
-
...e,
|
|
225
|
-
discount: Se({
|
|
226
|
-
value: e.discount,
|
|
227
|
-
type: e.discountType,
|
|
228
|
-
currency: e.currency
|
|
229
|
-
})
|
|
230
|
-
}));
|
|
231
|
-
}, []), Vt = s(() => {
|
|
232
|
-
F.current = !0, w((e) => {
|
|
233
|
-
let t = te(e.taxRate);
|
|
234
|
-
return t === e.taxRate ? e : {
|
|
235
|
-
...e,
|
|
236
|
-
taxRate: t
|
|
237
|
-
};
|
|
238
|
-
});
|
|
239
|
-
}, []), Z = s((e, { validate: t }) => {
|
|
240
|
-
t && (N.current = !0), w((t) => ({
|
|
241
|
-
...t,
|
|
242
|
-
lineItems: e(t.lineItems)
|
|
243
|
-
}));
|
|
244
|
-
}, []);
|
|
245
|
-
c(() => {
|
|
246
|
-
let e = N.current, t = P.current;
|
|
247
|
-
if (!e && !t && !F.current) return;
|
|
248
|
-
N.current = !1, P.current = !1, F.current = !1, e && (I.current.lines = !0), t && (I.current.discount = !0);
|
|
249
|
-
let n = e ? me(C.lineItems, {
|
|
250
|
-
currency: C.currency,
|
|
251
|
-
messages: f
|
|
252
|
-
}) : void 0;
|
|
253
|
-
T((t) => {
|
|
254
|
-
let r = { ...t };
|
|
255
|
-
return I.current.lines && (r.lineItems = e ? n : t.lineItems, r.lineItemsSummary = fe(r.lineItems, ke(C, f))), I.current.discount && (r.discount = Oe(C, f)), r;
|
|
256
|
-
});
|
|
257
|
-
}, [f, C]);
|
|
258
|
-
let Ht = s((e, t) => {
|
|
259
|
-
let { unit: n, ...r } = t, i = ce(r);
|
|
260
|
-
i.name !== void 0 && (i.productId = ""), n !== void 0 && (i.measureUnitId = n, i.measureUnitName = ""), i.taxable !== void 0 && (F.current = !0), Z((t) => t.map((t) => t.id === e ? {
|
|
261
|
-
...t,
|
|
262
|
-
...i
|
|
263
|
-
} : t), { validate: j });
|
|
264
|
-
}, [Z, j]), Ut = s((e, t) => {
|
|
265
|
-
Z((n) => n.map((n) => n.id === e ? {
|
|
266
|
-
...n,
|
|
267
|
-
...ae({
|
|
268
|
-
product: t,
|
|
269
|
-
currency: C.currency,
|
|
270
|
-
unitNamesById: k
|
|
271
|
-
})
|
|
272
|
-
} : n), { validate: !0 });
|
|
273
|
-
}, [
|
|
274
|
-
Z,
|
|
275
|
-
k,
|
|
276
|
-
C.currency
|
|
277
|
-
]), Q = s((e, t) => {
|
|
278
|
-
t && Z((n) => t.kind === "remove" ? n.filter((t) => t.id !== e) : n.map((n) => n.id === e ? {
|
|
279
|
-
...n,
|
|
280
|
-
...t.patch
|
|
281
|
-
} : n), { validate: !0 });
|
|
282
|
-
}, [Z]), Wt = s((e, t) => {
|
|
283
|
-
let n = C.lineItems.find((t) => t.id === e);
|
|
284
|
-
n && Q(e, ee({
|
|
285
|
-
lineItem: n,
|
|
286
|
-
field: t,
|
|
287
|
-
rowCount: C.lineItems.length,
|
|
288
|
-
currency: C.currency
|
|
289
|
-
}));
|
|
290
|
-
}, [
|
|
291
|
-
Q,
|
|
292
|
-
C.currency,
|
|
293
|
-
C.lineItems
|
|
294
|
-
]), Gt = s((e, t) => {
|
|
295
|
-
let n = C.lineItems.find((t) => t.id === e);
|
|
296
|
-
n && Q(e, ue({
|
|
297
|
-
lineItem: n,
|
|
298
|
-
step: t,
|
|
299
|
-
rowCount: C.lineItems.length
|
|
300
|
-
}));
|
|
301
|
-
}, [Q, C.lineItems]), Kt = s(() => {
|
|
302
|
-
let e = re(C.currency);
|
|
303
|
-
A(e.id), w((t) => ({
|
|
304
|
-
...t,
|
|
305
|
-
lineItems: [...t.lineItems, e]
|
|
306
|
-
}));
|
|
307
|
-
}, [C.currency]), qt = s((e) => {
|
|
308
|
-
Z((t) => t.length <= 1 ? t : t.filter((t) => t.id !== e), { validate: !0 });
|
|
309
|
-
}, [Z]), Jt = s(async () => {
|
|
310
|
-
if (X || K) return;
|
|
311
|
-
if (D.isLoading) {
|
|
312
|
-
T({ form: f.lineItemsLoading });
|
|
313
|
-
return;
|
|
314
|
-
}
|
|
315
|
-
let e = de(C.lineItems), n = e.length === C.lineItems.length ? C : {
|
|
316
|
-
...C,
|
|
317
|
-
lineItems: e
|
|
318
|
-
};
|
|
319
|
-
n !== C && w(n);
|
|
320
|
-
let r = n.type === "invoice" && o(n), i = {
|
|
321
|
-
...Ie({
|
|
322
|
-
values: n,
|
|
323
|
-
billingAddressId: R,
|
|
324
|
-
messages: f
|
|
49
|
+
}
|
|
50
|
+
if (e === "receipt_due") return {
|
|
51
|
+
dueDate: v([s(r)]),
|
|
52
|
+
paymentTerms: v([i.previewDueOnReceipt])
|
|
53
|
+
};
|
|
54
|
+
let o = n?.find((t) => t.id === e);
|
|
55
|
+
if (!o) return a;
|
|
56
|
+
let c = l(o, r), u = [
|
|
57
|
+
o.term_1 && b(i, o.term_1),
|
|
58
|
+
o.term_2 && b(i, o.term_2),
|
|
59
|
+
o.term_final && y(i, o.term_final.number_of_days)
|
|
60
|
+
].filter((e) => !!e);
|
|
61
|
+
return {
|
|
62
|
+
dueDate: c ? v([s(c)]) : _,
|
|
63
|
+
paymentTerms: u.length > 0 ? v(u) : _
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
function S(e, t) {
|
|
67
|
+
return t ? e.previewTaxId.replace("{taxId}", t) : void 0;
|
|
68
|
+
}
|
|
69
|
+
function C(e) {
|
|
70
|
+
return e.length > 0 ? e : void 0;
|
|
71
|
+
}
|
|
72
|
+
function w(e, t) {
|
|
73
|
+
return e ? {
|
|
74
|
+
name: e.type === "organization" ? e.organization.legal_name : void 0,
|
|
75
|
+
addressLines: C(g({
|
|
76
|
+
address: e.address,
|
|
77
|
+
issuerCountry: e.address?.country
|
|
78
|
+
})),
|
|
79
|
+
taxIdLine: S(t, e.tax_id),
|
|
80
|
+
email: e.email ?? void 0,
|
|
81
|
+
phone: e.phone ?? void 0
|
|
82
|
+
} : {};
|
|
83
|
+
}
|
|
84
|
+
function T(e) {
|
|
85
|
+
let t = "organization" in e ? e.organization : e.individual;
|
|
86
|
+
return {
|
|
87
|
+
name: "organization" in e ? e.organization.legal_name : [e.individual.first_name, e.individual.last_name].filter(Boolean).join(" "),
|
|
88
|
+
email: t.email,
|
|
89
|
+
phone: t.phone
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
function E({ counterpart: e, billingAddress: t, issuerCountry: n, messages: r }) {
|
|
93
|
+
if (!e) return { kind: "pending" };
|
|
94
|
+
let { name: i, email: a, phone: o } = T(e);
|
|
95
|
+
return i ? {
|
|
96
|
+
kind: "party",
|
|
97
|
+
name: i,
|
|
98
|
+
addressLines: C(g({
|
|
99
|
+
address: t,
|
|
100
|
+
issuerCountry: n
|
|
101
|
+
})),
|
|
102
|
+
taxIdLine: S(r, e.tax_id),
|
|
103
|
+
email: a || void 0,
|
|
104
|
+
phone: o || void 0
|
|
105
|
+
} : { kind: "pending" };
|
|
106
|
+
}
|
|
107
|
+
function D({ lineItems: e, currency: n, unitNamesById: r, messages: o }) {
|
|
108
|
+
return e.filter((e) => !t(e)).map((e) => {
|
|
109
|
+
let t = a(e.price, n), s = i(e.quantity), c = r[e.measureUnitId] || e.measureUnitName;
|
|
110
|
+
return {
|
|
111
|
+
id: e.id,
|
|
112
|
+
name: e.name,
|
|
113
|
+
quantity: String(s),
|
|
114
|
+
price: u({
|
|
115
|
+
amount: t,
|
|
116
|
+
currency: n,
|
|
117
|
+
fallback: ""
|
|
325
118
|
}),
|
|
326
|
-
...
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
119
|
+
...c ? { unit: c } : {},
|
|
120
|
+
taxable: e.taxable ? o.previewTaxableYes : o.previewTaxableNo,
|
|
121
|
+
amount: u({
|
|
122
|
+
amount: Math.round(t * s),
|
|
123
|
+
currency: n,
|
|
124
|
+
fallback: ""
|
|
125
|
+
})
|
|
331
126
|
};
|
|
332
|
-
if (je(i)) {
|
|
333
|
-
T(i), M(!0), I.current = {
|
|
334
|
-
lines: !0,
|
|
335
|
-
discount: !0
|
|
336
|
-
};
|
|
337
|
-
return;
|
|
338
|
-
}
|
|
339
|
-
T({});
|
|
340
|
-
let a = b === "edit" ? it : h.current;
|
|
341
|
-
try {
|
|
342
|
-
let e, t;
|
|
343
|
-
if (a) {
|
|
344
|
-
let i = await m.mutateAsync({
|
|
345
|
-
path: { receivable_id: a },
|
|
346
|
-
body: Pe({
|
|
347
|
-
values: n,
|
|
348
|
-
billingAddressId: R ?? "",
|
|
349
|
-
lineItemChanges: Ne({
|
|
350
|
-
values: n,
|
|
351
|
-
originalLineItems: g.current,
|
|
352
|
-
originalCurrency: _.current,
|
|
353
|
-
unitNamesById: k,
|
|
354
|
-
units: O
|
|
355
|
-
})
|
|
356
|
-
})
|
|
357
|
-
});
|
|
358
|
-
gt(), e = a, t = i?.type ?? n.type, r && i && (g.current = i.line_items, _.current = i.currency, n = {
|
|
359
|
-
...n,
|
|
360
|
-
lineItems: oe(n.lineItems, i.line_items)
|
|
361
|
-
}, w(n));
|
|
362
|
-
} else {
|
|
363
|
-
let i = await p.mutateAsync({ body: Me({
|
|
364
|
-
values: n,
|
|
365
|
-
billingAddressId: R ?? "",
|
|
366
|
-
unitNamesById: k
|
|
367
|
-
}) });
|
|
368
|
-
if (!i?.id) {
|
|
369
|
-
y(!1), Pt();
|
|
370
|
-
return;
|
|
371
|
-
}
|
|
372
|
-
e = i.id, t = i.type, r && (h.current = i.id, g.current = i.line_items, _.current = i.currency, n = {
|
|
373
|
-
...n,
|
|
374
|
-
lineItems: oe(n.lineItems, i.line_items)
|
|
375
|
-
}, w(n));
|
|
376
|
-
}
|
|
377
|
-
r && (W ? await nt.mutateAsync({
|
|
378
|
-
path: { recurrence_id: W.id },
|
|
379
|
-
body: _e(n, { lockSchedule: Tt })
|
|
380
|
-
}) : await tt.mutateAsync({ body: ge(n, e) }));
|
|
381
|
-
let i = b === "create";
|
|
382
|
-
y(!1), Pt(), i && et?.(e, t);
|
|
383
|
-
} catch (e) {
|
|
384
|
-
T({ form: t(e) ?? f.genericError });
|
|
385
|
-
}
|
|
386
|
-
}, [
|
|
387
|
-
R,
|
|
388
|
-
gt,
|
|
389
|
-
p,
|
|
390
|
-
tt,
|
|
391
|
-
it,
|
|
392
|
-
W,
|
|
393
|
-
X,
|
|
394
|
-
G,
|
|
395
|
-
Tt,
|
|
396
|
-
f,
|
|
397
|
-
b,
|
|
398
|
-
et,
|
|
399
|
-
K,
|
|
400
|
-
Pt,
|
|
401
|
-
O,
|
|
402
|
-
k,
|
|
403
|
-
D.isLoading,
|
|
404
|
-
m,
|
|
405
|
-
nt,
|
|
406
|
-
C
|
|
407
|
-
]), Yt = l(() => ({
|
|
408
|
-
...C,
|
|
409
|
-
discount: ut ? C.discount : Ce(we(C.discount, C.discountType, C.currency), C.discountType, C.currency),
|
|
410
|
-
lineItems: C.lineItems.map(pe)
|
|
411
|
-
}), [ut, C]), Xt = l(() => a(C.lineItems), [C.lineItems]), $ = l(() => De(C), [C]), Zt = l(() => Ee($, C.currency), [$, C.currency]), Qt = Je({
|
|
412
|
-
values: C,
|
|
413
|
-
totals: $,
|
|
414
|
-
billingAddress: mt,
|
|
415
|
-
unitNamesById: k,
|
|
416
|
-
messages: f,
|
|
417
|
-
enabled: v
|
|
418
127
|
});
|
|
128
|
+
}
|
|
129
|
+
function O(t, n) {
|
|
130
|
+
return n ? new Intl.NumberFormat(void 0, {
|
|
131
|
+
style: "currency",
|
|
132
|
+
currency: n,
|
|
133
|
+
currencySign: "accounting"
|
|
134
|
+
}).format(-t / 10 ** e(n)) : "";
|
|
135
|
+
}
|
|
136
|
+
function k(e, i) {
|
|
137
|
+
if (!e.taxRate) return i.previewTax;
|
|
138
|
+
let a = o(e.taxRate), s = n(e.taxRate, e.savedTaxRate);
|
|
139
|
+
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));
|
|
140
|
+
}
|
|
141
|
+
function A({ totals: e, currency: t, taxLabel: n, messages: r }) {
|
|
142
|
+
let i = (e) => u({
|
|
143
|
+
amount: e,
|
|
144
|
+
currency: t,
|
|
145
|
+
fallback: ""
|
|
146
|
+
}), a = e.discountAmount > 0, o = e.taxableItemsSubtotal > 0, s = e.nonTaxableItemsSubtotal > 0, c = [{
|
|
147
|
+
id: "subtotal",
|
|
148
|
+
label: r.previewSubtotal,
|
|
149
|
+
value: i(e.subtotal)
|
|
150
|
+
}];
|
|
151
|
+
return a && c.push({
|
|
152
|
+
id: "discount",
|
|
153
|
+
label: r.previewDiscount,
|
|
154
|
+
value: O(e.discountAmount, t)
|
|
155
|
+
}), s && (o || a) && c.push({
|
|
156
|
+
id: "nonTaxableSubtotal",
|
|
157
|
+
label: r.previewNonTaxableSubtotal,
|
|
158
|
+
value: i(e.nonTaxableSubtotal),
|
|
159
|
+
muted: !0
|
|
160
|
+
}), o && (s || a) && c.push({
|
|
161
|
+
id: "taxableSubtotal",
|
|
162
|
+
label: r.previewTaxableSubtotal,
|
|
163
|
+
value: i(e.taxableSubtotal),
|
|
164
|
+
muted: !0
|
|
165
|
+
}), c.push({
|
|
166
|
+
id: "tax",
|
|
167
|
+
label: n,
|
|
168
|
+
value: i(e.totalTaxes)
|
|
169
|
+
}), {
|
|
170
|
+
rows: c,
|
|
171
|
+
total: {
|
|
172
|
+
label: r.previewTotal,
|
|
173
|
+
value: i(e.total)
|
|
174
|
+
}
|
|
175
|
+
};
|
|
176
|
+
}
|
|
177
|
+
function j({ bankDetails: e, canReceivePayments: t, messages: n }) {
|
|
178
|
+
let r = e ? [
|
|
179
|
+
[n.previewAccountHolderName, e.accountHolderName],
|
|
180
|
+
[n.previewRoutingNumber, e.routingNumber],
|
|
181
|
+
[n.previewAccountNumber, e.accountNumber]
|
|
182
|
+
].filter((e) => !!e[1]).map(([e, t]) => e.replace("{value}", t)) : [];
|
|
183
|
+
if (t || r.length !== 0) return {
|
|
184
|
+
showPayOnline: t,
|
|
185
|
+
bankLines: r
|
|
186
|
+
};
|
|
187
|
+
}
|
|
188
|
+
function M({ 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() }) {
|
|
189
|
+
let p = D({
|
|
190
|
+
lineItems: e.lineItems,
|
|
191
|
+
currency: e.currency,
|
|
192
|
+
unitNamesById: o,
|
|
193
|
+
messages: d
|
|
194
|
+
}), m = n?.logo?.url, h = w(n, d), g = c(e.issueDate, f);
|
|
419
195
|
return {
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
submitLabel: C.type === "invoice" && o(C) ? W ? f.recurrenceUpdateButton : f.recurrenceActivateButton : void 0,
|
|
459
|
-
showDueDateField: C.type === "quote",
|
|
460
|
-
openCreate: Ft,
|
|
461
|
-
openEdit: It,
|
|
462
|
-
close: Lt,
|
|
463
|
-
submit: Jt,
|
|
464
|
-
units: E,
|
|
465
|
-
counterpartView: st,
|
|
466
|
-
counterpartForm: yt,
|
|
467
|
-
stateOptions: dt,
|
|
468
|
-
openCounterpartCreate: yt.openCreate,
|
|
469
|
-
bankAccount: Ct,
|
|
470
|
-
reminders: Nt
|
|
196
|
+
issuer: h,
|
|
197
|
+
logo: m ? {
|
|
198
|
+
kind: "image",
|
|
199
|
+
src: m,
|
|
200
|
+
alt: h.name ? d.previewLogoAlt.replace("{name}", h.name) : d.previewLogoAltNoName
|
|
201
|
+
} : { kind: "placeholder" },
|
|
202
|
+
billTo: E({
|
|
203
|
+
counterpart: r,
|
|
204
|
+
billingAddress: i,
|
|
205
|
+
issuerCountry: n?.address?.country,
|
|
206
|
+
messages: d
|
|
207
|
+
}),
|
|
208
|
+
invoiceNumber: _,
|
|
209
|
+
issueDate: s(g),
|
|
210
|
+
...x({
|
|
211
|
+
paymentTermsId: e.paymentTermsId,
|
|
212
|
+
paymentTermsCustomDate: e.paymentTermsCustomDate,
|
|
213
|
+
paymentTerms: a,
|
|
214
|
+
issueDate: g,
|
|
215
|
+
messages: d
|
|
216
|
+
}),
|
|
217
|
+
openingNote: e.openingNote || void 0,
|
|
218
|
+
lineItems: p.length > 0 ? {
|
|
219
|
+
kind: "rows",
|
|
220
|
+
rows: p
|
|
221
|
+
} : { kind: "empty" },
|
|
222
|
+
totals: p.length > 0 ? A({
|
|
223
|
+
totals: t,
|
|
224
|
+
currency: e.currency,
|
|
225
|
+
taxLabel: k(e, d),
|
|
226
|
+
messages: d
|
|
227
|
+
}) : void 0,
|
|
228
|
+
closingNote: e.closingNote || void 0,
|
|
229
|
+
payment: j({
|
|
230
|
+
bankDetails: l,
|
|
231
|
+
canReceivePayments: u,
|
|
232
|
+
messages: d
|
|
233
|
+
})
|
|
471
234
|
};
|
|
472
235
|
}
|
|
473
236
|
//#endregion
|
|
474
|
-
export {
|
|
237
|
+
export { g as buildPreviewAddressLines, x as buildPreviewPaymentTerms, M as buildReceivablePreviewView, h as formatCountryName };
|