@tesouro/embedded-components-react 0.5.257 → 0.5.259
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 +2 -1
- package/dist/fixtures/index.d.ts +1 -1
- package/dist/index.css +109 -9
- package/dist/index.d.ts +41 -10
- package/dist/lib/ReceivablesWidget.d.ts +41 -10
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index.js +11 -10
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index10.js +42 -94
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index11.js +91 -76
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index12.js +67 -173
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index13.js +186 -17
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index14.js +27 -0
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index4.js +28 -72
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index5.js +128 -53
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index6.js +66 -28
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index7.js +28 -34
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index8.js +24 -168
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index9.js +173 -44
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/ReceivablesWidget.js +274 -267
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/helpers.js +99 -95
- 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/paymentTerms.js +28 -25
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/preview.js +49 -43
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/unsavedChanges.js +13 -0
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/useReceivableActions.js +4 -4
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/useReceivableActionsModal.js +2 -2
- 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/useReceivableBankAccount.js +77 -72
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/useReceivableDetails.js +4 -4
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/useReceivableForm.js +363 -295
- 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/useReceivablePreview.js +36 -21
- 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/ui/dist/index.js +12 -10
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index13.js +21 -14
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index15.js +1 -1
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index16.js +1 -1
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index20.js +68 -64
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index38.js +383 -379
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index40.js +22 -0
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index41.js +8 -2
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index43.js +258 -1
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index44.js +2 -100
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index45.js +95 -23
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index46.js +23 -231
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index47.js +237 -3
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index48.js +3 -249
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index49.js +234 -78
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index50.js +87 -53
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index51.js +49 -349
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index52.js +359 -0
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index53.js +45 -0
- package/dist/libs/tesouro-embedded-components-react/shared/data-access/dist/index.js +40 -40
- package/dist/libs/tesouro-embedded-components-react/shared/data-access/dist/lib/rest/@tanstack/react-query.gen.js +247 -214
- package/dist/libs/tesouro-embedded-components-react/shared/data-access/dist/lib/rest/sdk.gen.js +175 -147
- package/dist/libs/tesouro-embedded-components-react/shared/data-access/dist/lib/rest/zod.gen.js +1 -1
- package/dist/libs/tesouro-embedded-components-react/shared/feature/dist/lib/analytics/build-info.js +1 -1
- package/dist/libs/tesouro-embedded-components-react/shared/product-catalog/feature/dist/index.js +12 -12
- package/dist/libs/tesouro-embedded-components-react/shared/product-catalog/ui/dist/index2.js +2 -1
- package/dist/libs/tesouro-embedded-components-react/shared/product-catalog/ui/dist/index6.js +109 -89
- package/package.json +1 -1
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index42.js +0 -4
|
@@ -1,23 +1,25 @@
|
|
|
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
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
3
|
+
import { isEmail as n } from "../../../../../../shared/util-validation/dist/index5.js";
|
|
4
|
+
import { createLineItem as r, isBlankLineItem as i, keepsSavedTaxRates as a, lineItemToCreatePayload as o, lineItemToUpdatePayload as s, responseLineItemToFormValues as c, summarizeLineItemErrors as l, taxRateFromLineItems as u, validateLineItems as d } from "./lineItems.js";
|
|
5
|
+
import { attachmentFormValuesToPayload as f, receivableToAttachmentFormValues as p } from "./attachments.js";
|
|
6
|
+
import { createEmptyRecurrenceFields as m } from "./recurrence.js";
|
|
7
|
+
import { buildPaymentTermsPayload as h, buildPaymentTermsUpdatePayload as g, paymentTermsToFormFields as _ } from "./paymentTerms.js";
|
|
8
|
+
import { createEmptyDiscount as v, discountFromDraft as y, discountToDraft as b } from "./discount.js";
|
|
9
|
+
import { validateDiscount as x, validateInvoiceTotals as S } from "./totals.js";
|
|
9
10
|
//#region ../../libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/helpers.js
|
|
10
|
-
var
|
|
11
|
+
var C = {
|
|
11
12
|
to: "",
|
|
12
13
|
cc: "",
|
|
13
14
|
bcc: "",
|
|
14
15
|
subject: "",
|
|
15
16
|
body: ""
|
|
16
17
|
};
|
|
17
|
-
function
|
|
18
|
+
function w() {
|
|
18
19
|
return {
|
|
19
20
|
type: "invoice",
|
|
20
21
|
customerId: "",
|
|
22
|
+
customerEmail: "",
|
|
21
23
|
currency: "USD",
|
|
22
24
|
issueDate: (/* @__PURE__ */ new Date()).toISOString().slice(0, 10),
|
|
23
25
|
dueDate: "",
|
|
@@ -26,8 +28,8 @@ function C() {
|
|
|
26
28
|
paymentTermsId: "",
|
|
27
29
|
paymentTermsCustomDate: "",
|
|
28
30
|
taxRate: "",
|
|
29
|
-
...
|
|
30
|
-
lineItems: [
|
|
31
|
+
...v("USD"),
|
|
32
|
+
lineItems: [r()],
|
|
31
33
|
bankAccountId: "",
|
|
32
34
|
bankAccountType: "",
|
|
33
35
|
billingAddressId: "",
|
|
@@ -35,16 +37,16 @@ function C() {
|
|
|
35
37
|
paymentReminderId: "",
|
|
36
38
|
overdueReminderId: "",
|
|
37
39
|
attachments: [],
|
|
38
|
-
...
|
|
40
|
+
...m()
|
|
39
41
|
};
|
|
40
42
|
}
|
|
41
|
-
function
|
|
43
|
+
function T(e) {
|
|
42
44
|
return e === "quotes" ? "quote" : e === "credit_notes" ? "credit_note" : "invoice";
|
|
43
45
|
}
|
|
44
|
-
function
|
|
46
|
+
function E(e) {
|
|
45
47
|
return e === "quote" ? "quotes" : e === "credit_note" ? "credit_notes" : "invoices";
|
|
46
48
|
}
|
|
47
|
-
function
|
|
49
|
+
function D(e) {
|
|
48
50
|
return (e?.length ? e : [
|
|
49
51
|
"invoices",
|
|
50
52
|
"quotes",
|
|
@@ -55,10 +57,10 @@ function E(e) {
|
|
|
55
57
|
"credit_notes"
|
|
56
58
|
].includes(e) && n.indexOf(e) === t);
|
|
57
59
|
}
|
|
58
|
-
function
|
|
60
|
+
function O({ defaultTab: e, enabledTabs: t }) {
|
|
59
61
|
return e && t.includes(e) ? e : t[0] ?? "invoices";
|
|
60
62
|
}
|
|
61
|
-
function
|
|
63
|
+
function k(e, n) {
|
|
62
64
|
let r = t(e);
|
|
63
65
|
return r ? new Intl.DateTimeFormat(void 0, {
|
|
64
66
|
day: "numeric",
|
|
@@ -66,28 +68,28 @@ function O(e, n) {
|
|
|
66
68
|
year: "numeric"
|
|
67
69
|
}).format(r) : n;
|
|
68
70
|
}
|
|
69
|
-
function
|
|
71
|
+
function A({ amount: t, currency: n, fallback: r }) {
|
|
70
72
|
return t == null || !n ? r : new Intl.NumberFormat(void 0, {
|
|
71
73
|
currency: n,
|
|
72
74
|
style: "currency"
|
|
73
75
|
}).format(t / 10 ** e(n));
|
|
74
76
|
}
|
|
75
|
-
function
|
|
77
|
+
function j(t, n) {
|
|
76
78
|
let r = Number(t);
|
|
77
79
|
if (!Number.isFinite(r)) return;
|
|
78
80
|
let i = n ? e(n) : 2;
|
|
79
81
|
return Math.round(r * 10 ** i);
|
|
80
82
|
}
|
|
81
|
-
function
|
|
83
|
+
function M(e, t) {
|
|
82
84
|
return e.document_id || t.untitledDocument;
|
|
83
85
|
}
|
|
84
|
-
function
|
|
86
|
+
function N(e, t) {
|
|
85
87
|
return e === "quote" ? t.quoteType : e === "credit_note" ? t.creditNoteType : t.invoiceType;
|
|
86
88
|
}
|
|
87
|
-
function
|
|
89
|
+
function P(e) {
|
|
88
90
|
return e === "paid" || e === "accepted" || e === "issued" || e === "recurring" ? "success" : e === "draft" || e === "issuing" ? "neutral" : e === "overdue" || e === "partially_paid" ? "warning" : e === "failed" || e === "declined" || e === "expired" || e === "uncollectible" || e === "canceled" || e === "deleted" ? "danger" : "info";
|
|
89
91
|
}
|
|
90
|
-
function
|
|
92
|
+
function F(e) {
|
|
91
93
|
let t = e.status === "draft", n = e.status === "issued", r = e.type === "invoice", i = e.type === "quote", a = e.type === "credit_note", o = r && [
|
|
92
94
|
"issued",
|
|
93
95
|
"overdue",
|
|
@@ -117,7 +119,7 @@ function P(e) {
|
|
|
117
119
|
].includes(e.status) && !a
|
|
118
120
|
};
|
|
119
121
|
}
|
|
120
|
-
function
|
|
122
|
+
function I(e, t, n) {
|
|
121
123
|
let r = e.counterpart_name || (e.counterpart_id ? t.names.get(e.counterpart_id) : void 0);
|
|
122
124
|
return r ? {
|
|
123
125
|
customerLabel: r,
|
|
@@ -130,46 +132,46 @@ function F(e, t, n) {
|
|
|
130
132
|
customerState: "missing"
|
|
131
133
|
};
|
|
132
134
|
}
|
|
133
|
-
var
|
|
135
|
+
var L = {
|
|
134
136
|
names: /* @__PURE__ */ new Map(),
|
|
135
137
|
isResolving: !1
|
|
136
138
|
};
|
|
137
|
-
function
|
|
139
|
+
function R({ receivables: e, messages: t, canRecordPayment: n, customerNames: r = L }) {
|
|
138
140
|
return e.map((e) => {
|
|
139
141
|
let i = e.type === "invoice" ? e.amount_due : void 0;
|
|
140
142
|
return {
|
|
141
143
|
id: e.id,
|
|
142
144
|
type: e.type,
|
|
143
|
-
documentLabel:
|
|
144
|
-
...
|
|
145
|
+
documentLabel: M(e, t),
|
|
146
|
+
...I(e, r, t),
|
|
145
147
|
status: e.status,
|
|
146
|
-
statusTone:
|
|
147
|
-
issueDateLabel:
|
|
148
|
-
dueDateLabel:
|
|
149
|
-
totalLabel:
|
|
148
|
+
statusTone: P(e.status),
|
|
149
|
+
issueDateLabel: k(e.issue_date, t.notAvailable),
|
|
150
|
+
dueDateLabel: k(e.type === "quote" ? e.expiry_date : e.due_date, t.notAvailable),
|
|
151
|
+
totalLabel: A({
|
|
150
152
|
amount: e.total_amount,
|
|
151
153
|
currency: e.currency,
|
|
152
154
|
fallback: t.notAvailable
|
|
153
155
|
}),
|
|
154
|
-
amountDueLabel:
|
|
156
|
+
amountDueLabel: A({
|
|
155
157
|
amount: i,
|
|
156
158
|
currency: e.currency,
|
|
157
159
|
fallback: t.notAvailable
|
|
158
160
|
}),
|
|
159
161
|
actions: {
|
|
160
|
-
...
|
|
162
|
+
...F(e),
|
|
161
163
|
...n ? {} : { recordPayment: !1 }
|
|
162
164
|
}
|
|
163
165
|
};
|
|
164
166
|
});
|
|
165
167
|
}
|
|
166
|
-
function
|
|
168
|
+
function z(e) {
|
|
167
169
|
if (e.memo || e.footer) return {
|
|
168
170
|
opening: e.memo || void 0,
|
|
169
171
|
closing: e.footer || void 0
|
|
170
172
|
};
|
|
171
173
|
}
|
|
172
|
-
function
|
|
174
|
+
function B({ values: e, counterpart: t, addresses: n }) {
|
|
173
175
|
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 || "";
|
|
174
176
|
return {
|
|
175
177
|
billingAddressId: i,
|
|
@@ -177,51 +179,53 @@ function z({ values: e, counterpart: t, addresses: n }) {
|
|
|
177
179
|
shippingAddressId: a
|
|
178
180
|
};
|
|
179
181
|
}
|
|
180
|
-
function
|
|
181
|
-
let
|
|
182
|
-
e.customerId ? t || (
|
|
183
|
-
let
|
|
182
|
+
function V({ values: e, billingAddressId: t, messages: r, willIssue: i = !1, hasStartedRecurrence: a = !1 }) {
|
|
183
|
+
let o = {};
|
|
184
|
+
e.customerId ? t || (o.customerId = r.customerAddressRequired) : o.customerId = r.customerRequired;
|
|
185
|
+
let s = e.customerEmail.trim();
|
|
186
|
+
!e.customerId && s && !n(s) && (o.customerEmail = r.customerEmailInvalid), e.currency || (o.currency = r.currencyRequired), i && !e.paymentTermsId && (o.paymentTermsId = r.paymentTermsRequired), i && !e.bankAccountId && (o.bankAccountId = r.bankAccountRequired);
|
|
187
|
+
let c = d(e.lineItems, {
|
|
184
188
|
currency: e.currency,
|
|
185
|
-
messages:
|
|
186
|
-
requireComplete:
|
|
187
|
-
}),
|
|
188
|
-
|
|
189
|
-
let
|
|
190
|
-
return
|
|
191
|
-
}
|
|
192
|
-
function
|
|
189
|
+
messages: r,
|
|
190
|
+
requireComplete: i || a
|
|
191
|
+
}), u = l(c, S(e, r), (i || a) && e.lineItems.length === 0 ? r.lineItemsRequired : void 0);
|
|
192
|
+
c && (o.lineItems = c), u && (o.lineItemsSummary = u);
|
|
193
|
+
let f = x(e, r);
|
|
194
|
+
return f && (o.discount = f), o;
|
|
195
|
+
}
|
|
196
|
+
function H(e) {
|
|
193
197
|
return Object.keys(e).length > 0;
|
|
194
198
|
}
|
|
195
|
-
function
|
|
196
|
-
return !V(
|
|
197
|
-
values:
|
|
199
|
+
function U(e, t) {
|
|
200
|
+
return !H(V({
|
|
201
|
+
values: K(e),
|
|
198
202
|
billingAddressId: e.type === "invoice" ? e.counterpart_billing_address?.id ?? void 0 : void 0,
|
|
199
203
|
messages: t,
|
|
200
204
|
willIssue: !0
|
|
201
205
|
}));
|
|
202
206
|
}
|
|
203
|
-
function
|
|
207
|
+
function W({ bankAccountId: e, bankAccountType: t }) {
|
|
204
208
|
return {
|
|
205
209
|
bank_account_id: e || void 0,
|
|
206
210
|
bank_account_type: e && t || void 0
|
|
207
211
|
};
|
|
208
212
|
}
|
|
209
|
-
function
|
|
210
|
-
let
|
|
213
|
+
function G({ values: e, billingAddressId: t, shippingAddressId: n, unitNamesById: r }) {
|
|
214
|
+
let a = e.lineItems.filter((e) => !i(e)).map((t) => o({
|
|
211
215
|
lineItem: t,
|
|
212
216
|
currency: e.currency,
|
|
213
217
|
taxRate: e.taxRate,
|
|
214
|
-
unitNamesById:
|
|
218
|
+
unitNamesById: r
|
|
215
219
|
})), s = {
|
|
216
220
|
counterpart_billing_address_id: t,
|
|
217
221
|
counterpart_shipping_address_id: n || void 0,
|
|
218
222
|
counterpart_id: e.customerId,
|
|
219
223
|
currency: e.currency,
|
|
220
|
-
line_items:
|
|
224
|
+
line_items: a,
|
|
221
225
|
memo: e.openingNote,
|
|
222
226
|
footer: e.closingNote,
|
|
223
|
-
discount:
|
|
224
|
-
...
|
|
227
|
+
discount: y(e) ?? void 0,
|
|
228
|
+
...W(e)
|
|
225
229
|
};
|
|
226
230
|
return e.type === "quote" ? {
|
|
227
231
|
...s,
|
|
@@ -229,46 +233,46 @@ function W({ values: e, billingAddressId: t, shippingAddressId: n, unitNamesById
|
|
|
229
233
|
type: "quote"
|
|
230
234
|
} : {
|
|
231
235
|
...s,
|
|
232
|
-
...
|
|
236
|
+
...h(e),
|
|
233
237
|
payment_reminder_id: e.paymentReminderId || void 0,
|
|
234
238
|
overdue_reminder_id: e.overdueReminderId || void 0,
|
|
235
|
-
attachments:
|
|
239
|
+
attachments: f(e.attachments),
|
|
236
240
|
type: "invoice"
|
|
237
241
|
};
|
|
238
242
|
}
|
|
239
|
-
function
|
|
240
|
-
let
|
|
243
|
+
function K(e, t) {
|
|
244
|
+
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({
|
|
241
245
|
lineItem: n,
|
|
242
246
|
currency: e.currency,
|
|
243
247
|
units: t
|
|
244
248
|
}));
|
|
245
249
|
return {
|
|
246
|
-
...
|
|
247
|
-
type:
|
|
250
|
+
...w(),
|
|
251
|
+
type: n,
|
|
248
252
|
customerId: e.counterpart_id,
|
|
249
253
|
currency: e.currency,
|
|
250
|
-
issueDate:
|
|
251
|
-
dueDate: e.type === "quote" ?
|
|
254
|
+
issueDate: Z(e.issue_date),
|
|
255
|
+
dueDate: e.type === "quote" ? Z(e.expiry_date) : "",
|
|
252
256
|
openingNote: e.memo ?? "",
|
|
253
257
|
closingNote: e.footer ?? "",
|
|
254
|
-
...e.type === "invoice" ?
|
|
258
|
+
...e.type === "invoice" ? _(e.payment_terms) : {},
|
|
255
259
|
taxRate: i,
|
|
256
260
|
savedTaxRate: i,
|
|
257
|
-
...
|
|
258
|
-
lineItems: o.length > 0 ? o : [
|
|
261
|
+
...b(e.discount, e.currency),
|
|
262
|
+
lineItems: o.length > 0 ? o : [r(e.currency)],
|
|
259
263
|
bankAccountId: e.bank_account_id ?? "",
|
|
260
|
-
bankAccountType:
|
|
264
|
+
bankAccountType: q(e.bank_account_type),
|
|
261
265
|
billingAddressId: e.counterpart_billing_address?.id ?? "",
|
|
262
266
|
shippingAddressId: e.counterpart_shipping_address?.id ?? "",
|
|
263
267
|
paymentReminderId: a?.payment_reminder_id ?? "",
|
|
264
268
|
overdueReminderId: a?.overdue_reminder_id ?? "",
|
|
265
|
-
attachments:
|
|
269
|
+
attachments: p(e)
|
|
266
270
|
};
|
|
267
271
|
}
|
|
268
|
-
function
|
|
272
|
+
function q(e) {
|
|
269
273
|
return e === "BANK_DETAILS" || e === "INTERNAL" || e === "EXTERNAL" ? e : "";
|
|
270
274
|
}
|
|
271
|
-
function
|
|
275
|
+
function J({ values: e, billingAddressId: t, shippingAddressId: n, lineItemChanges: r }) {
|
|
272
276
|
let i = {
|
|
273
277
|
counterpart_billing_address_id: t,
|
|
274
278
|
counterpart_shipping_address_id: n || null,
|
|
@@ -277,35 +281,35 @@ function q({ values: e, billingAddressId: t, shippingAddressId: n, lineItemChang
|
|
|
277
281
|
issue_date: e.issueDate || void 0,
|
|
278
282
|
memo: e.openingNote,
|
|
279
283
|
footer: e.closingNote,
|
|
280
|
-
discount:
|
|
281
|
-
...
|
|
284
|
+
discount: y(e),
|
|
285
|
+
...W(e)
|
|
282
286
|
};
|
|
283
287
|
return e.type === "quote" ? { quote: {
|
|
284
288
|
...i,
|
|
285
289
|
...r ? { line_items: r } : {},
|
|
286
290
|
expiry_date: e.dueDate || void 0,
|
|
287
|
-
...
|
|
291
|
+
...g(e)
|
|
288
292
|
} } : { invoice: {
|
|
289
293
|
...i,
|
|
290
294
|
...r ? { line_items: r } : {},
|
|
291
|
-
...
|
|
295
|
+
...g(e),
|
|
292
296
|
payment_reminder_id: e.paymentReminderId || null,
|
|
293
297
|
overdue_reminder_id: e.overdueReminderId || null,
|
|
294
|
-
attachments:
|
|
298
|
+
attachments: f(e.attachments) ?? null
|
|
295
299
|
} };
|
|
296
300
|
}
|
|
297
|
-
function
|
|
298
|
-
let
|
|
301
|
+
function Y({ values: e, originalLineItems: t, originalCurrency: n, unitNamesById: r, units: o }) {
|
|
302
|
+
let l = u(t), d = a(e.taxRate, l), f = (e, t, n) => s({
|
|
299
303
|
lineItem: e,
|
|
300
304
|
currency: t,
|
|
301
305
|
taxRate: n,
|
|
302
306
|
keepSavedRate: d,
|
|
303
|
-
unitNamesById:
|
|
304
|
-
}), p = new Map(t.map((e) => [e.id, JSON.stringify(f(
|
|
307
|
+
unitNamesById: r
|
|
308
|
+
}), p = new Map(t.map((e) => [e.id, JSON.stringify(f(c({
|
|
305
309
|
lineItem: e,
|
|
306
310
|
currency: n,
|
|
307
|
-
units:
|
|
308
|
-
}), n,
|
|
311
|
+
units: o
|
|
312
|
+
}), n, l))])), m = e.lineItems.filter((e) => !i(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) => {
|
|
309
313
|
let n = p.get(t.id);
|
|
310
314
|
if (n === void 0) return [];
|
|
311
315
|
let r = f(t, e.currency, e.taxRate);
|
|
@@ -320,37 +324,37 @@ function J({ values: e, originalLineItems: t, originalCurrency: n, unitNamesById
|
|
|
320
324
|
...v.length ? { remove: v } : {}
|
|
321
325
|
};
|
|
322
326
|
}
|
|
323
|
-
function
|
|
324
|
-
let
|
|
325
|
-
if (!t) return { created:
|
|
327
|
+
function X({ values: e, originalLineItems: t, changes: n }) {
|
|
328
|
+
let r = e.lineItems.filter((e) => !i(e)).map((e) => e.id);
|
|
329
|
+
if (!t) return { created: r };
|
|
326
330
|
let a = new Set(t.map((e) => e.id));
|
|
327
331
|
return {
|
|
328
|
-
added:
|
|
332
|
+
added: r.filter((e) => !a.has(e)),
|
|
329
333
|
replaced: n?.replace?.map((e) => e.id) ?? []
|
|
330
334
|
};
|
|
331
335
|
}
|
|
332
|
-
function
|
|
336
|
+
function Z(e) {
|
|
333
337
|
return e?.slice(0, 10) ?? "";
|
|
334
338
|
}
|
|
335
|
-
function
|
|
339
|
+
function Q(e, t) {
|
|
336
340
|
let n = {};
|
|
337
341
|
return e.to.trim() || (n.to = t.sendToRequired), e.subject.trim() || (n.subject = t.sendSubjectRequired), e.body.trim() || (n.body = t.sendBodyRequired), n;
|
|
338
342
|
}
|
|
339
|
-
function
|
|
343
|
+
function $(e) {
|
|
340
344
|
return Object.keys(e).length > 0;
|
|
341
345
|
}
|
|
342
|
-
function
|
|
346
|
+
function ee(e) {
|
|
343
347
|
return e.split(",").map((e) => e.trim()).filter(Boolean);
|
|
344
348
|
}
|
|
345
|
-
function
|
|
349
|
+
function te(e, t) {
|
|
346
350
|
return {
|
|
347
|
-
...
|
|
351
|
+
...C,
|
|
348
352
|
to: e?.counterpart_contact?.email ?? "",
|
|
349
353
|
subject: e?.document_id ? `${t.sendSubjectDefault} ${e.document_id}` : t.sendSubjectDefault,
|
|
350
354
|
body: t.sendBodyDefault
|
|
351
355
|
};
|
|
352
356
|
}
|
|
353
|
-
function
|
|
357
|
+
function ne(e = "all") {
|
|
354
358
|
let t = [
|
|
355
359
|
"draft",
|
|
356
360
|
"issued",
|
|
@@ -371,4 +375,4 @@ function te(e = "all") {
|
|
|
371
375
|
}));
|
|
372
376
|
}
|
|
373
377
|
//#endregion
|
|
374
|
-
export {
|
|
378
|
+
export { C as EMPTY_RECEIVABLE_SEND_VALUES, F as buildReceivableActions, z as buildReceivableNotesView, R as buildReceivableRows, D as coerceEnabledTabs, w as createEmptyReceivableFormValues, r as createLineItem, te as defaultSendValues, k as formatDate, A as formatMoney, j as fromMajorUnits, M as getDocumentTitle, N as getDocumentTypeLabel, P as getStatusTone, H as hasReceivableFormErrors, $ as hasSendErrors, U as isReceivableReadyToIssue, G as receivableFormValuesToCreatePayload, Y as receivableFormValuesToLineItemChanges, J as receivableFormValuesToUpdatePayload, K as receivableToFormValues, B as resolveCounterpartAddresses, O as resolveInitialTab, ee as splitEmailList, ne as statusFilterOptions, X as submittedLineItemRows, E as tabForType, T as typeForTab, V as validateReceivableForm, Q as validateSendValues };
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
var e = {
|
|
3
3
|
customerRequired: "Customer is required",
|
|
4
4
|
customerAddressRequired: "The selected customer needs a billing address before a receivable can be created.",
|
|
5
|
+
customerEmailInvalid: "Please enter a valid email address",
|
|
5
6
|
currencyRequired: "Currency is required",
|
|
6
7
|
lineItemNameTooLong: "Product name must be 100 characters or less",
|
|
7
8
|
lineItemPriceTooHigh: "Price must be {maxAmount} or less",
|
|
@@ -2,8 +2,8 @@ import { RECEIVABLE_PAYMENT_TERMS_CUSTOM_DATE as e, RECEIVABLE_PAYMENT_TERMS_REC
|
|
|
2
2
|
import "../../../../ui/dist/index.js";
|
|
3
3
|
import { addDays as n, addYears as r, format as i, isValid as a, max as o, min as s, parseISO as c, subYears as l } from "date-fns";
|
|
4
4
|
//#region ../../libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/paymentTerms.js
|
|
5
|
-
var u = "MMM d, yyyy", d = "yyyy-MM-dd",
|
|
6
|
-
function
|
|
5
|
+
var u = "MMM d, yyyy", d = "MMM dd, yyyy", f = "yyyy-MM-dd", p = 10, m = 5;
|
|
6
|
+
function h(e) {
|
|
7
7
|
let t = (e) => e ? {
|
|
8
8
|
number_of_days: e.number_of_days ?? null,
|
|
9
9
|
discount: e.discount ?? null
|
|
@@ -16,43 +16,46 @@ function m(e) {
|
|
|
16
16
|
term_2: t(e.term_2)
|
|
17
17
|
});
|
|
18
18
|
}
|
|
19
|
-
function
|
|
19
|
+
function g(e) {
|
|
20
20
|
let t = /* @__PURE__ */ new Set();
|
|
21
21
|
return e.filter((e) => {
|
|
22
|
-
let n =
|
|
22
|
+
let n = h(e);
|
|
23
23
|
return !t.has(n) && (t.add(n), !0);
|
|
24
24
|
});
|
|
25
25
|
}
|
|
26
|
-
function
|
|
26
|
+
function _(e) {
|
|
27
27
|
return i(e, u);
|
|
28
28
|
}
|
|
29
|
-
function
|
|
29
|
+
function v(e) {
|
|
30
|
+
return i(e, d);
|
|
31
|
+
}
|
|
32
|
+
function y(e, t) {
|
|
30
33
|
let r = e.term_final?.number_of_days;
|
|
31
34
|
return r ? n(t, r) : void 0;
|
|
32
35
|
}
|
|
33
|
-
function
|
|
36
|
+
function b(e, t = /* @__PURE__ */ new Date()) {
|
|
34
37
|
let n = c(e);
|
|
35
38
|
return a(n) ? n : t;
|
|
36
39
|
}
|
|
37
|
-
function
|
|
38
|
-
let n =
|
|
40
|
+
function x(e, t) {
|
|
41
|
+
let n = y(e, t);
|
|
39
42
|
return {
|
|
40
43
|
value: e.id,
|
|
41
44
|
label: e.name,
|
|
42
|
-
...n ? { dueDateLabel:
|
|
45
|
+
...n ? { dueDateLabel: _(n) } : {}
|
|
43
46
|
};
|
|
44
47
|
}
|
|
45
|
-
function
|
|
48
|
+
function S(e) {
|
|
46
49
|
return e ? c(e) : void 0;
|
|
47
50
|
}
|
|
48
|
-
function
|
|
51
|
+
function C({ terms: e, isLoading: t, fields: n, customDatePickerOpen: r, isRecurring: i = !1, messages: a, issueDate: o = /* @__PURE__ */ new Date() }) {
|
|
49
52
|
if (t) return { kind: "loading" };
|
|
50
|
-
let s =
|
|
53
|
+
let s = g(e ?? []).map((e) => x(e, o)), c = S(n.paymentTermsCustomDate), l;
|
|
51
54
|
if (n.paymentTermsId === "receipt_due") l = { kind: "receiptDue" };
|
|
52
55
|
else if (n.paymentTermsId === "custom") l = {
|
|
53
56
|
kind: "customDate",
|
|
54
57
|
hasDate: !!c,
|
|
55
|
-
dateLabel: c ?
|
|
58
|
+
dateLabel: c ? _(c) : a.paymentTermsCustomDatePlaceholder
|
|
56
59
|
};
|
|
57
60
|
else {
|
|
58
61
|
let e = s.find((e) => e.value === n.paymentTermsId);
|
|
@@ -71,15 +74,15 @@ function x({ terms: e, isLoading: t, fields: n, customDatePickerOpen: r, isRecur
|
|
|
71
74
|
...i ? { description: a.recurrenceSeriesPaymentTerms } : {}
|
|
72
75
|
};
|
|
73
76
|
}
|
|
74
|
-
function
|
|
75
|
-
let n =
|
|
77
|
+
function w(e, t = /* @__PURE__ */ new Date()) {
|
|
78
|
+
let n = S(e), i = l(t, p), a = r(t, m);
|
|
76
79
|
return {
|
|
77
80
|
selected: n,
|
|
78
81
|
startMonth: n ? s([i, n]) : i,
|
|
79
82
|
endMonth: n ? o([a, n]) : a
|
|
80
83
|
};
|
|
81
84
|
}
|
|
82
|
-
function
|
|
85
|
+
function T(e, t) {
|
|
83
86
|
return t === "custom" ? {
|
|
84
87
|
paymentTermsId: t,
|
|
85
88
|
paymentTermsCustomDate: e.paymentTermsId === "custom" ? e.paymentTermsCustomDate : ""
|
|
@@ -88,25 +91,25 @@ function C(e, t) {
|
|
|
88
91
|
paymentTermsCustomDate: ""
|
|
89
92
|
};
|
|
90
93
|
}
|
|
91
|
-
function
|
|
94
|
+
function E(e) {
|
|
92
95
|
return e.paymentTermsId === "custom" && !e.paymentTermsCustomDate ? {
|
|
93
96
|
paymentTermsId: "",
|
|
94
97
|
paymentTermsCustomDate: ""
|
|
95
98
|
} : e;
|
|
96
99
|
}
|
|
97
|
-
function
|
|
98
|
-
return e ? i(e,
|
|
100
|
+
function D(e) {
|
|
101
|
+
return e ? i(e, f) : "";
|
|
99
102
|
}
|
|
100
|
-
function
|
|
103
|
+
function O(e) {
|
|
101
104
|
return e.paymentTermsId === "custom" ? e.paymentTermsCustomDate ? { payment_terms: { term_final: { end_date: e.paymentTermsCustomDate } } } : { payment_terms: { term_final: { number_of_days: 0 } } } : e.paymentTermsId === "receipt_due" ? { payment_terms: { term_final: { number_of_days: 0 } } } : e.paymentTermsId ? { payment_terms_id: e.paymentTermsId } : {};
|
|
102
105
|
}
|
|
103
|
-
function
|
|
104
|
-
return e.paymentTermsId ?
|
|
106
|
+
function k(e) {
|
|
107
|
+
return e.paymentTermsId ? O(e) : {
|
|
105
108
|
payment_terms_id: null,
|
|
106
109
|
payment_terms: null
|
|
107
110
|
};
|
|
108
111
|
}
|
|
109
|
-
function
|
|
112
|
+
function A(n) {
|
|
110
113
|
if (n?.id) return {
|
|
111
114
|
paymentTermsId: n.id,
|
|
112
115
|
paymentTermsCustomDate: ""
|
|
@@ -124,4 +127,4 @@ function O(n) {
|
|
|
124
127
|
};
|
|
125
128
|
}
|
|
126
129
|
//#endregion
|
|
127
|
-
export {
|
|
130
|
+
export { w as buildCustomDateCalendar, O as buildPaymentTermsPayload, k as buildPaymentTermsUpdatePayload, C as buildPaymentTermsView, E as closeCustomDatePickerFields, g as dedupePaymentTerms, v as formatPreviewDate, _ as formatTermDate, A as paymentTermsToFormFields, b as resolveIssueDate, T as selectPaymentTermsFields, y as termDueDate, D as toCustomDateValue };
|