@tesouro/embedded-components-react 0.7.63 → 0.7.66
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 +5 -0
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/currencyDisplay.js +6 -0
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/discount.js +31 -30
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/helpers.js +89 -87
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/lineItems.js +84 -82
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/preview.js +77 -75
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/totals.js +54 -53
- package/dist/libs/tesouro-embedded-components-react/shared/feature/dist/lib/analytics/build-info.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -11,6 +11,11 @@ dependencies.
|
|
|
11
11
|
These steps put one widget on screen: a token route on your server, a provider
|
|
12
12
|
in the browser, and the widget itself. The examples use the Next.js App Router.
|
|
13
13
|
|
|
14
|
+
Using a coding assistant? Point it at
|
|
15
|
+
[`llms-full.txt`](https://components.tesouro.com/llms-full.txt), which has every
|
|
16
|
+
page of the docs site as Markdown in one file.
|
|
17
|
+
[`llms.txt`](https://components.tesouro.com/llms.txt) is the index.
|
|
18
|
+
|
|
14
19
|
### Before you start
|
|
15
20
|
|
|
16
21
|
You need three credentials from Tesouro: a client ID, a client secret and a
|
|
@@ -1,59 +1,60 @@
|
|
|
1
1
|
import { minorExponentForCurrency as e } from "../../../../../shared/util/dist/lib/amountOutputToMajorUnits.js";
|
|
2
|
-
import {
|
|
2
|
+
import { currencyDisplayFor as t } from "./currencyDisplay.js";
|
|
3
|
+
import { escapeRegex as n, getNumberSeparators as r, parseLocaleDecimal as i } from "./lineItems.js";
|
|
3
4
|
//#region ../../libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/discount.js
|
|
4
|
-
function
|
|
5
|
+
function a(t, n) {
|
|
5
6
|
return t === "percentage" ? 2 : e(n);
|
|
6
7
|
}
|
|
7
|
-
function
|
|
8
|
-
let s = `0-9${
|
|
9
|
-
return l === -1 ? c : c.slice(0, l + o.decimal.length) + Array.from(c.slice(l + o.decimal.length).split(o.decimal).join("")).slice(0,
|
|
8
|
+
function o(e, t, i, o = r()) {
|
|
9
|
+
let s = `0-9${n(o.digits.join(""))}${n(o.decimal)}${o.group ? n(o.group) : ""}`, c = e.replace(RegExp(`[^${s}]`, "gu"), ""), l = c.indexOf(o.decimal);
|
|
10
|
+
return l === -1 ? c : c.slice(0, l + o.decimal.length) + Array.from(c.slice(l + o.decimal.length).split(o.decimal).join("")).slice(0, a(t, i)).join("");
|
|
10
11
|
}
|
|
11
|
-
function
|
|
12
|
-
return Math.round(
|
|
12
|
+
function s(e, t, n, o = r()) {
|
|
13
|
+
return Math.round(i(e, o) * 10 ** a(t, n));
|
|
13
14
|
}
|
|
14
|
-
function
|
|
15
|
-
let r =
|
|
15
|
+
function c(e, t, n) {
|
|
16
|
+
let r = a(t, n);
|
|
16
17
|
return new Intl.NumberFormat(void 0, {
|
|
17
18
|
minimumFractionDigits: r,
|
|
18
19
|
maximumFractionDigits: r
|
|
19
20
|
}).format(e / 10 ** r);
|
|
20
21
|
}
|
|
21
|
-
function
|
|
22
|
-
let
|
|
23
|
-
minimumFractionDigits:
|
|
24
|
-
maximumFractionDigits:
|
|
22
|
+
function l(e, n, r) {
|
|
23
|
+
let i = a(n, r), o = {
|
|
24
|
+
minimumFractionDigits: i,
|
|
25
|
+
maximumFractionDigits: i
|
|
25
26
|
};
|
|
26
|
-
return
|
|
27
|
-
...
|
|
27
|
+
return n === "percentage" ? new Intl.NumberFormat(void 0, {
|
|
28
|
+
...o,
|
|
28
29
|
style: "percent"
|
|
29
|
-
}).format(e / 10 ** (
|
|
30
|
-
...
|
|
30
|
+
}).format(e / 10 ** (i + 2)) : new Intl.NumberFormat(void 0, {
|
|
31
|
+
...o,
|
|
31
32
|
style: "currency",
|
|
32
|
-
currency:
|
|
33
|
-
currencyDisplay:
|
|
34
|
-
}).format(e / 10 **
|
|
33
|
+
currency: r,
|
|
34
|
+
currencyDisplay: t(r)
|
|
35
|
+
}).format(e / 10 ** i);
|
|
35
36
|
}
|
|
36
|
-
function
|
|
37
|
-
return s(
|
|
37
|
+
function u({ value: e, type: t, currency: n }) {
|
|
38
|
+
return c(s(e, t, n), t, n);
|
|
38
39
|
}
|
|
39
|
-
function
|
|
40
|
+
function d(e) {
|
|
40
41
|
return {
|
|
41
42
|
discountType: "amount",
|
|
42
|
-
discount:
|
|
43
|
+
discount: c(0, "amount", e)
|
|
43
44
|
};
|
|
44
45
|
}
|
|
45
|
-
function
|
|
46
|
-
let t =
|
|
46
|
+
function f(e) {
|
|
47
|
+
let t = s(e.discount, e.discountType, e.currency);
|
|
47
48
|
return t > 0 ? {
|
|
48
49
|
type: e.discountType,
|
|
49
50
|
amount: t
|
|
50
51
|
} : null;
|
|
51
52
|
}
|
|
52
|
-
function
|
|
53
|
+
function p(e, t) {
|
|
53
54
|
return e ? {
|
|
54
55
|
discountType: e.type,
|
|
55
|
-
discount:
|
|
56
|
-
} :
|
|
56
|
+
discount: c(e.amount, e.type, t)
|
|
57
|
+
} : d(t);
|
|
57
58
|
}
|
|
58
59
|
//#endregion
|
|
59
|
-
export {
|
|
60
|
+
export { u as convertDiscountInput, d as createEmptyDiscount, l as decorateDiscountInput, f as discountFromDraft, s as discountInputToMinorUnits, p as discountToDraft, c as formatDiscountInput, o as sanitizeDiscountInput };
|
|
@@ -1,30 +1,31 @@
|
|
|
1
1
|
import { minorExponentForCurrency as e } from "../../../../../shared/util/dist/lib/amountOutputToMajorUnits.js";
|
|
2
2
|
import { parseDateOrTimestamp as t } from "../../../../../shared/util/dist/lib/parseCalendarDate.js";
|
|
3
3
|
import { isEmail as n } from "../../../../../../shared/util-validation/dist/index5.js";
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
4
|
+
import { currencyDisplayFor as r } from "./currencyDisplay.js";
|
|
5
|
+
import { createLineItem as i, isBlankLineItem as a, keepsSavedTaxRates as o, lineItemToCreatePayload as s, lineItemToUpdatePayload as c, responseLineItemToFormValues as l, summarizeLineItemErrors as u, taxRateFromLineItems as d, validateLineItems as f } from "./lineItems.js";
|
|
6
|
+
import { attachmentFormValuesToPayload as p, receivableToAttachmentFormValues as m } from "./attachments.js";
|
|
7
|
+
import { createEmptyRecurrenceFields as h, willRecurrenceIssue as g } from "./recurrence.js";
|
|
8
|
+
import { buildPaymentTermsPayload as _, buildPaymentTermsUpdatePayload as v, paymentTermsToFormFields as y } from "./paymentTerms.js";
|
|
9
|
+
import { createEmptyDiscount as b, discountFromDraft as x, discountToDraft as S } from "./discount.js";
|
|
10
|
+
import { validateDiscount as C, validateInvoiceTotals as w, validateIssuableTotal as T } from "./totals.js";
|
|
11
|
+
import { format as E } from "date-fns";
|
|
11
12
|
//#region ../../libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/helpers.js
|
|
12
|
-
function
|
|
13
|
+
function D() {
|
|
13
14
|
return {
|
|
14
15
|
type: "invoice",
|
|
15
16
|
customerId: "",
|
|
16
17
|
customerName: "",
|
|
17
18
|
customerEmail: "",
|
|
18
19
|
currency: "USD",
|
|
19
|
-
issueDate:
|
|
20
|
+
issueDate: E(/* @__PURE__ */ new Date(), "yyyy-MM-dd"),
|
|
20
21
|
dueDate: "",
|
|
21
22
|
openingNote: "",
|
|
22
23
|
closingNote: "",
|
|
23
24
|
paymentTermsId: "",
|
|
24
25
|
paymentTermsCustomDate: "",
|
|
25
26
|
taxRate: "",
|
|
26
|
-
...
|
|
27
|
-
lineItems: [
|
|
27
|
+
...b("USD"),
|
|
28
|
+
lineItems: [i()],
|
|
28
29
|
bankAccountId: "",
|
|
29
30
|
bankAccountType: "",
|
|
30
31
|
billingAddressId: "",
|
|
@@ -33,10 +34,10 @@ function E() {
|
|
|
33
34
|
overdueReminderId: "",
|
|
34
35
|
purchaseOrder: "",
|
|
35
36
|
attachments: [],
|
|
36
|
-
...
|
|
37
|
+
...h()
|
|
37
38
|
};
|
|
38
39
|
}
|
|
39
|
-
function
|
|
40
|
+
function O(e, n) {
|
|
40
41
|
let r = t(e);
|
|
41
42
|
return r ? new Intl.DateTimeFormat(void 0, {
|
|
42
43
|
day: "2-digit",
|
|
@@ -44,25 +45,26 @@ function D(e, n) {
|
|
|
44
45
|
year: "numeric"
|
|
45
46
|
}).format(r) : n;
|
|
46
47
|
}
|
|
47
|
-
function
|
|
48
|
-
return t == null || !n ?
|
|
48
|
+
function k({ amount: t, currency: n, fallback: i }) {
|
|
49
|
+
return t == null || !n ? i : new Intl.NumberFormat(void 0, {
|
|
49
50
|
currency: n,
|
|
50
|
-
style: "currency"
|
|
51
|
+
style: "currency",
|
|
52
|
+
currencyDisplay: r(n)
|
|
51
53
|
}).format(t / 10 ** e(n));
|
|
52
54
|
}
|
|
53
|
-
function
|
|
55
|
+
function A(t, n) {
|
|
54
56
|
let r = Number(t);
|
|
55
57
|
if (!Number.isFinite(r)) return;
|
|
56
58
|
let i = n ? e(n) : 2;
|
|
57
59
|
return Math.round(r * 10 ** i);
|
|
58
60
|
}
|
|
59
|
-
function
|
|
61
|
+
function j(e, t) {
|
|
60
62
|
return e.document_id || t.untitledDocument;
|
|
61
63
|
}
|
|
62
|
-
function
|
|
64
|
+
function M(e, t) {
|
|
63
65
|
return e === "quote" ? t.quoteType : e === "credit_note" ? t.creditNoteType : t.invoiceType;
|
|
64
66
|
}
|
|
65
|
-
function
|
|
67
|
+
function N(e, t, n) {
|
|
66
68
|
let r = e.counterpart_name || (e.counterpart_id ? t.names.get(e.counterpart_id) : void 0);
|
|
67
69
|
return r ? {
|
|
68
70
|
customerLabel: r,
|
|
@@ -75,62 +77,62 @@ function M(e, t, n) {
|
|
|
75
77
|
customerState: "missing"
|
|
76
78
|
};
|
|
77
79
|
}
|
|
78
|
-
function
|
|
80
|
+
function P(e, t = /* @__PURE__ */ new Date()) {
|
|
79
81
|
if (!e) return 0;
|
|
80
82
|
let n = new Date(e);
|
|
81
83
|
if (Number.isNaN(n.getTime())) return 0;
|
|
82
84
|
let r = Date.UTC(t.getUTCFullYear(), t.getUTCMonth(), t.getUTCDate()), i = Date.UTC(n.getUTCFullYear(), n.getUTCMonth(), n.getUTCDate()), a = Math.floor((r - i) / 864e5);
|
|
83
85
|
return a > 0 ? a : 0;
|
|
84
86
|
}
|
|
85
|
-
function
|
|
87
|
+
function F(e, t, n) {
|
|
86
88
|
if (e.type !== "invoice" || e.status !== "draft") return {};
|
|
87
|
-
let r =
|
|
89
|
+
let r = P(e.due_date, n);
|
|
88
90
|
return r === 0 ? {} : { dueDateOverdueLabel: (r === 1 ? t.listDayOverdue : t.listDaysOverdue).replace("{days}", String(r)) };
|
|
89
91
|
}
|
|
90
|
-
var
|
|
92
|
+
var I = {
|
|
91
93
|
names: /* @__PURE__ */ new Map(),
|
|
92
94
|
isResolving: !1
|
|
93
95
|
};
|
|
94
|
-
function
|
|
96
|
+
function L(e) {
|
|
95
97
|
return e?.isLoading ? { kind: "loading" } : e?.status ? {
|
|
96
98
|
kind: "chip",
|
|
97
99
|
...e.status
|
|
98
100
|
} : { kind: "blank" };
|
|
99
101
|
}
|
|
100
|
-
function
|
|
102
|
+
function R(e, t, n) {
|
|
101
103
|
if (e.type !== "invoice" || e.status !== "recurring") return {};
|
|
102
104
|
let r = e.recurrence_id ? t.get(e.recurrence_id) : void 0;
|
|
103
105
|
return {
|
|
104
106
|
documentLabel: e.document_id || n.recurringNumber,
|
|
105
|
-
statusOverride:
|
|
107
|
+
statusOverride: L(r),
|
|
106
108
|
showDocumentSyncIcon: !0
|
|
107
109
|
};
|
|
108
110
|
}
|
|
109
|
-
function
|
|
111
|
+
function z({ receivables: e, messages: t, customerNames: n = I, seriesStatuses: r = /* @__PURE__ */ new Map(), now: i = /* @__PURE__ */ new Date() }) {
|
|
110
112
|
return e.map((e) => ({
|
|
111
113
|
id: e.id,
|
|
112
114
|
type: e.type,
|
|
113
115
|
documentLabel: e.document_id || t.pendingValue,
|
|
114
|
-
...
|
|
116
|
+
...N(e, n, t),
|
|
115
117
|
status: e.status,
|
|
116
|
-
issueDateLabel:
|
|
117
|
-
dueDateLabel:
|
|
118
|
-
...
|
|
119
|
-
totalLabel:
|
|
118
|
+
issueDateLabel: O(e.issue_date, t.pendingValue),
|
|
119
|
+
dueDateLabel: O(e.type === "invoice" ? e.due_date : void 0, t.pendingValue),
|
|
120
|
+
...F(e, t, i),
|
|
121
|
+
totalLabel: k({
|
|
120
122
|
amount: e.total_amount ?? 0,
|
|
121
123
|
currency: e.currency,
|
|
122
124
|
fallback: ""
|
|
123
125
|
}),
|
|
124
|
-
...
|
|
126
|
+
...R(e, r, t)
|
|
125
127
|
}));
|
|
126
128
|
}
|
|
127
|
-
function
|
|
129
|
+
function B(e) {
|
|
128
130
|
if (e.memo || e.footer) return {
|
|
129
131
|
opening: e.memo || void 0,
|
|
130
132
|
closing: e.footer || void 0
|
|
131
133
|
};
|
|
132
134
|
}
|
|
133
|
-
function
|
|
135
|
+
function V({ values: e, counterpart: t, addresses: n }) {
|
|
134
136
|
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 || "";
|
|
135
137
|
return {
|
|
136
138
|
billingAddressId: i,
|
|
@@ -138,101 +140,101 @@ function B({ values: e, counterpart: t, addresses: n }) {
|
|
|
138
140
|
shippingAddressId: a
|
|
139
141
|
};
|
|
140
142
|
}
|
|
141
|
-
function
|
|
143
|
+
function H({ values: e, messages: t, willIssue: r = !1, hasStartedRecurrence: i = !1, canCreateCustomer: a = !0 }) {
|
|
142
144
|
let o = {}, s = a && !!e.customerName.trim();
|
|
143
145
|
!e.customerId && !s && (o.customerId = t.customerRequired);
|
|
144
146
|
let c = e.customerEmail.trim();
|
|
145
147
|
!e.customerId && c && !n(c) && (o.customerEmail = t.customerEmailInvalid), e.currency || (o.currency = t.currencyRequired), r && !e.paymentTermsId && (o.paymentTermsId = t.paymentTermsRequired), r && !e.bankAccountId && (o.bankAccountId = t.bankAccountRequired);
|
|
146
|
-
let
|
|
148
|
+
let l = f(e.lineItems, {
|
|
147
149
|
currency: e.currency,
|
|
148
150
|
messages: t,
|
|
149
151
|
requireComplete: r || i
|
|
150
|
-
}),
|
|
151
|
-
|
|
152
|
-
let m =
|
|
152
|
+
}), d = (r || i && g(e)) && !l && e.lineItems.length > 0 ? T(e, t) : void 0, p = u(l, w(e, t) ?? d, (r || i) && e.lineItems.length === 0 ? t.lineItemsRequired : void 0);
|
|
153
|
+
l && (o.lineItems = l), p && (o.lineItemsSummary = p);
|
|
154
|
+
let m = C(e, t);
|
|
153
155
|
return m && (o.discount = m), o;
|
|
154
156
|
}
|
|
155
|
-
function
|
|
157
|
+
function U(e) {
|
|
156
158
|
return Object.keys(e).length > 0;
|
|
157
159
|
}
|
|
158
|
-
function
|
|
159
|
-
return !H(
|
|
160
|
-
values:
|
|
160
|
+
function W(e, t) {
|
|
161
|
+
return !U(H({
|
|
162
|
+
values: q(e),
|
|
161
163
|
messages: t,
|
|
162
164
|
willIssue: !0
|
|
163
165
|
}));
|
|
164
166
|
}
|
|
165
|
-
function
|
|
167
|
+
function G({ bankAccountId: e, bankAccountType: t }) {
|
|
166
168
|
return {
|
|
167
169
|
bank_account_id: e || void 0,
|
|
168
170
|
bank_account_type: e && t || void 0
|
|
169
171
|
};
|
|
170
172
|
}
|
|
171
|
-
function
|
|
172
|
-
let
|
|
173
|
+
function K({ values: e, billingAddressId: t, shippingAddressId: n, unitNamesById: r }) {
|
|
174
|
+
let i = e.lineItems.filter((e) => !a(e)).map((t) => s({
|
|
173
175
|
lineItem: t,
|
|
174
176
|
currency: e.currency,
|
|
175
177
|
taxRate: e.taxRate,
|
|
176
178
|
unitNamesById: r
|
|
177
|
-
})),
|
|
179
|
+
})), o = {
|
|
178
180
|
counterpart_billing_address_id: t || void 0,
|
|
179
181
|
counterpart_shipping_address_id: n || void 0,
|
|
180
182
|
counterpart_id: e.customerId,
|
|
181
183
|
currency: e.currency,
|
|
182
|
-
line_items:
|
|
184
|
+
line_items: i,
|
|
183
185
|
memo: e.openingNote,
|
|
184
186
|
footer: e.closingNote,
|
|
185
|
-
discount:
|
|
186
|
-
...
|
|
187
|
+
discount: x(e) ?? void 0,
|
|
188
|
+
...G(e)
|
|
187
189
|
};
|
|
188
190
|
return e.type === "quote" ? {
|
|
189
|
-
...
|
|
191
|
+
...o,
|
|
190
192
|
expiry_date: e.dueDate || void 0,
|
|
191
193
|
type: "quote"
|
|
192
194
|
} : {
|
|
193
|
-
...
|
|
194
|
-
...
|
|
195
|
+
...o,
|
|
196
|
+
..._(e),
|
|
195
197
|
payment_reminder_id: e.paymentReminderId || void 0,
|
|
196
198
|
overdue_reminder_id: e.overdueReminderId || void 0,
|
|
197
199
|
purchase_order: e.purchaseOrder || void 0,
|
|
198
|
-
attachments:
|
|
200
|
+
attachments: p(e.attachments),
|
|
199
201
|
type: "invoice"
|
|
200
202
|
};
|
|
201
203
|
}
|
|
202
|
-
function
|
|
203
|
-
let n = e.type === "quote" ? "quote" : "invoice",
|
|
204
|
+
function q(e, t) {
|
|
205
|
+
let n = e.type === "quote" ? "quote" : "invoice", r = d(e.line_items), a = e.type === "invoice" ? e : void 0, o = e.line_items.map((n) => l({
|
|
204
206
|
lineItem: n,
|
|
205
207
|
currency: e.currency,
|
|
206
208
|
units: t
|
|
207
209
|
}));
|
|
208
210
|
return {
|
|
209
|
-
...
|
|
211
|
+
...D(),
|
|
210
212
|
type: n,
|
|
211
213
|
customerId: e.counterpart_id,
|
|
212
214
|
currency: e.currency,
|
|
213
|
-
issueDate:
|
|
214
|
-
dueDate: e.type === "quote" ?
|
|
215
|
+
issueDate: Q(e.issue_date),
|
|
216
|
+
dueDate: e.type === "quote" ? Q(e.expiry_date) : "",
|
|
215
217
|
openingNote: e.memo ?? "",
|
|
216
218
|
closingNote: e.footer ?? "",
|
|
217
|
-
...e.type === "invoice" ?
|
|
218
|
-
taxRate:
|
|
219
|
-
savedTaxRate:
|
|
220
|
-
...
|
|
221
|
-
lineItems: o.length > 0 ? o : [
|
|
219
|
+
...e.type === "invoice" ? y(e.payment_terms) : {},
|
|
220
|
+
taxRate: r,
|
|
221
|
+
savedTaxRate: r,
|
|
222
|
+
...S(e.discount, e.currency),
|
|
223
|
+
lineItems: o.length > 0 ? o : [i(e.currency)],
|
|
222
224
|
bankAccountId: e.bank_account_id ?? "",
|
|
223
|
-
bankAccountType:
|
|
225
|
+
bankAccountType: J(e.bank_account_type),
|
|
224
226
|
billingAddressId: e.counterpart_billing_address?.id ?? "",
|
|
225
227
|
shippingAddressId: e.counterpart_shipping_address?.id ?? "",
|
|
226
228
|
paymentReminderId: a?.payment_reminder_id ?? "",
|
|
227
229
|
overdueReminderId: a?.overdue_reminder_id ?? "",
|
|
228
230
|
purchaseOrder: a?.purchase_order ?? "",
|
|
229
|
-
attachments:
|
|
231
|
+
attachments: m(e)
|
|
230
232
|
};
|
|
231
233
|
}
|
|
232
|
-
function
|
|
234
|
+
function J(e) {
|
|
233
235
|
return e === "BANK_DETAILS" || e === "INTERNAL" || e === "EXTERNAL" ? e : "";
|
|
234
236
|
}
|
|
235
|
-
function
|
|
237
|
+
function Y({ values: e, billingAddressId: t, shippingAddressId: n, lineItemChanges: r }) {
|
|
236
238
|
let i = {
|
|
237
239
|
counterpart_billing_address_id: t || null,
|
|
238
240
|
counterpart_shipping_address_id: n || null,
|
|
@@ -241,35 +243,35 @@ function J({ values: e, billingAddressId: t, shippingAddressId: n, lineItemChang
|
|
|
241
243
|
issue_date: e.issueDate || void 0,
|
|
242
244
|
memo: e.openingNote,
|
|
243
245
|
footer: e.closingNote,
|
|
244
|
-
discount:
|
|
245
|
-
...
|
|
246
|
+
discount: x(e),
|
|
247
|
+
...G(e)
|
|
246
248
|
};
|
|
247
249
|
return e.type === "quote" ? { quote: {
|
|
248
250
|
...i,
|
|
249
251
|
...r ? { line_items: r } : {},
|
|
250
252
|
expiry_date: e.dueDate || void 0,
|
|
251
|
-
...
|
|
253
|
+
...v(e)
|
|
252
254
|
} } : { invoice: {
|
|
253
255
|
...i,
|
|
254
256
|
...r ? { line_items: r } : {},
|
|
255
|
-
...
|
|
257
|
+
...v(e),
|
|
256
258
|
payment_reminder_id: e.paymentReminderId || null,
|
|
257
259
|
overdue_reminder_id: e.overdueReminderId || null,
|
|
258
|
-
attachments:
|
|
260
|
+
attachments: p(e.attachments) ?? null
|
|
259
261
|
} };
|
|
260
262
|
}
|
|
261
|
-
function
|
|
262
|
-
let
|
|
263
|
+
function X({ values: e, originalLineItems: t, originalCurrency: n, unitNamesById: r, units: i }) {
|
|
264
|
+
let s = d(t), u = o(e.taxRate, s), f = (e, t, n) => c({
|
|
263
265
|
lineItem: e,
|
|
264
266
|
currency: t,
|
|
265
267
|
taxRate: n,
|
|
266
|
-
keepSavedRate:
|
|
268
|
+
keepSavedRate: u,
|
|
267
269
|
unitNamesById: r
|
|
268
|
-
}), p = new Map(t.map((e) => [e.id, JSON.stringify(f(
|
|
270
|
+
}), p = new Map(t.map((e) => [e.id, JSON.stringify(f(l({
|
|
269
271
|
lineItem: e,
|
|
270
272
|
currency: n,
|
|
271
|
-
units:
|
|
272
|
-
}), n,
|
|
273
|
+
units: i
|
|
274
|
+
}), n, s))])), m = e.lineItems.filter((e) => !a(e)), h = new Set(m.map((e) => e.id)), g = m.filter((e) => !p.has(e.id)).map((t) => f(t, e.currency, e.taxRate)), _ = m.flatMap((t) => {
|
|
273
275
|
let n = p.get(t.id);
|
|
274
276
|
if (n === void 0) return [];
|
|
275
277
|
let r = f(t, e.currency, e.taxRate);
|
|
@@ -284,17 +286,17 @@ function Y({ values: e, originalLineItems: t, originalCurrency: n, unitNamesById
|
|
|
284
286
|
...v.length ? { remove: v } : {}
|
|
285
287
|
};
|
|
286
288
|
}
|
|
287
|
-
function
|
|
288
|
-
let r = e.lineItems.filter((e) => !
|
|
289
|
+
function Z({ values: e, originalLineItems: t, changes: n }) {
|
|
290
|
+
let r = e.lineItems.filter((e) => !a(e)).map((e) => e.id);
|
|
289
291
|
if (!t) return { created: r };
|
|
290
|
-
let
|
|
292
|
+
let i = new Set(t.map((e) => e.id));
|
|
291
293
|
return {
|
|
292
|
-
added: r.filter((e) => !
|
|
294
|
+
added: r.filter((e) => !i.has(e)),
|
|
293
295
|
replaced: n?.replace?.map((e) => e.id) ?? []
|
|
294
296
|
};
|
|
295
297
|
}
|
|
296
|
-
function
|
|
298
|
+
function Q(e) {
|
|
297
299
|
return e?.slice(0, 10) ?? "";
|
|
298
300
|
}
|
|
299
301
|
//#endregion
|
|
300
|
-
export {
|
|
302
|
+
export { B as buildReceivableNotesView, z as buildReceivableRows, D as createEmptyReceivableFormValues, i as createLineItem, O as formatDate, k as formatMoney, A as fromMajorUnits, P as getDaysOverdue, j as getDocumentTitle, M as getDocumentTypeLabel, U as hasReceivableFormErrors, W as isReceivableReadyToIssue, K as receivableFormValuesToCreatePayload, X as receivableFormValuesToLineItemChanges, Y as receivableFormValuesToUpdatePayload, q as receivableToFormValues, V as resolveCounterpartAddresses, Z as submittedLineItemRows, H as validateReceivableForm };
|