@tesouro/embedded-components-react 0.5.279 → 0.5.280
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/dist/index.d.ts +21 -6
- package/dist/lib/ReceivablesWidget.d.ts +21 -6
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index.js +14 -13
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index10.js +24 -168
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index11.js +173 -44
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index12.js +42 -94
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index13.js +91 -76
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index14.js +67 -173
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index15.js +186 -17
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index16.js +27 -0
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index3.js +11 -13
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index4.js +42 -27
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index5.js +28 -132
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index6.js +137 -16
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index7.js +16 -62
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index8.js +66 -28
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index9.js +28 -34
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/ReceivableAttachmentsSection.js +1 -1
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/ReceivableCustomerSection.js +38 -0
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/ReceivablesWidget.js +304 -287
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/auditHistory/labels.js +1 -1
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/customer.js +58 -0
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/helpers.js +15 -15
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/labels.js +14 -6
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/paymentTerms.js +1 -1
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/permissions.js +2 -1
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/preview.js +62 -62
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/recurrence.js +41 -35
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/reminders.js +1 -1
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/totals.js +21 -13
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/useReceivableActions.js +124 -124
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/useReceivableActionsModal.js +11 -11
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/useReceivableAttachmentUploads.js +13 -13
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/useReceivableBankAccount.js +1 -1
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/useReceivableCustomerPicker.js +109 -0
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/useReceivableDetails.js +6 -6
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/useReceivableForm.js +520 -476
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/useReceivableIssuePreflight.js +10 -10
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/useReceivablePaymentRecord.js +6 -6
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/useReceivablePaymentTerms.js +1 -1
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/useReceivablePreview.js +1 -1
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/useReceivableRecurrence.js +92 -77
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/useReceivableReminders.js +11 -11
- 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 +4 -4
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/useReceivablesWidget.js +79 -75
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/useSendReceivableWithPaymentLink.js +3 -3
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index.js +26 -23
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index12.js +9 -25
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index13.js +26 -228
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index14.js +227 -52
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index15.js +50 -212
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index16.js +193 -138
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index17.js +157 -12
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index18.js +10 -19
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index19.js +23 -2
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index20.js +2 -116
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index21.js +118 -3
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index22.js +3 -39
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index23.js +209 -53
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index24.js +2 -23
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index25.js +36 -7
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index26.js +53 -77
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index27.js +17 -35
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index28.js +8 -18
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index29.js +73 -37
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index30.js +36 -26
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index31.js +17 -19
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index32.js +39 -8
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index33.js +26 -33
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index34.js +20 -14
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index35.js +8 -24
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index36.js +34 -84
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index37.js +14 -492
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index38.js +28 -2
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index39.js +79 -39
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index40.js +490 -68
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index41.js +2 -487
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index42.js +41 -217
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index43.js +70 -21
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index44.js +440 -5
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index45.js +224 -0
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index46.js +21 -263
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index47.js +8 -2
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index49.js +261 -24
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index50.js +2 -237
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index51.js +100 -3
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index52.js +21 -242
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index53.js +226 -82
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index54.js +3 -60
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index55.js +233 -178
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index56.js +85 -37
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index57.js +60 -0
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index58.js +194 -0
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index59.js +45 -0
- package/dist/libs/tesouro-embedded-components-react/shared/counterpart-management/feature/dist/index.js +9 -9
- package/dist/libs/tesouro-embedded-components-react/shared/counterpart-management/feature/dist/lib/CounterpartSelector.js +2 -23
- package/dist/libs/tesouro-embedded-components-react/shared/counterpart-management/feature/dist/lib/useCounterpartSelector.js +2 -51
- package/dist/libs/tesouro-embedded-components-react/shared/counterpart-management/ui/dist/index.js +8 -8
- package/dist/libs/tesouro-embedded-components-react/shared/counterpart-management/ui/dist/index15.js +4 -80
- package/dist/libs/tesouro-embedded-components-react/shared/counterpart-management/ui/dist/index2.js +10 -22
- 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/index48.js +0 -100
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { RECEIVABLE_STATUS_BADGE_LABELS_EN as e } from "../../../../../ui/dist/
|
|
1
|
+
import { RECEIVABLE_STATUS_BADGE_LABELS_EN as e } from "../../../../../ui/dist/index14.js";
|
|
2
2
|
import "../../../../../ui/dist/index.js";
|
|
3
3
|
import { formatDate as t, formatMoney as n, getDocumentTypeLabel as r } from "../helpers.js";
|
|
4
4
|
import { RECEIVABLE_MESSAGE_LABELS_EN as i } from "../labels.js";
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { getCounterpartEmail as e, getCounterpartName as t } from "../../../../../shared/counterpart-management/feature/dist/lib/helpers.js";
|
|
2
|
+
import "../../../../../shared/counterpart-management/feature/dist/index.js";
|
|
3
|
+
//#region ../../libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/customer.js
|
|
4
|
+
function n(n) {
|
|
5
|
+
return (n ?? []).map((n) => ({
|
|
6
|
+
id: n.id,
|
|
7
|
+
name: t(n),
|
|
8
|
+
email: e(n)
|
|
9
|
+
}));
|
|
10
|
+
}
|
|
11
|
+
function r(e, t) {
|
|
12
|
+
let n = t.toLowerCase().trim();
|
|
13
|
+
return n ? e.filter((e) => e.name.toLowerCase().includes(n) || e.email.toLowerCase().includes(n)) : e;
|
|
14
|
+
}
|
|
15
|
+
function i(e, t) {
|
|
16
|
+
if (t.trim()) return e.length === 1 ? e[0] : void 0;
|
|
17
|
+
}
|
|
18
|
+
function a(e, t) {
|
|
19
|
+
let n = t.toLowerCase().trim();
|
|
20
|
+
if (!n) return;
|
|
21
|
+
let r = e.filter((e) => e.name.toLowerCase().trim() === n);
|
|
22
|
+
return r.length === 1 ? r[0] : void 0;
|
|
23
|
+
}
|
|
24
|
+
function o(n) {
|
|
25
|
+
let r = n ? t(n) : "";
|
|
26
|
+
return {
|
|
27
|
+
name: r,
|
|
28
|
+
email: n ? e(n) : "",
|
|
29
|
+
initial: r ? Array.from(r)[0]?.toUpperCase() ?? "?" : "?"
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
function s(e, { name: t, email: n }) {
|
|
33
|
+
let r = t.trim(), i = r.indexOf(" ");
|
|
34
|
+
return {
|
|
35
|
+
...e,
|
|
36
|
+
legalName: r,
|
|
37
|
+
firstName: i === -1 ? r : r.slice(0, i),
|
|
38
|
+
lastName: i === -1 ? "" : r.slice(i + 1),
|
|
39
|
+
email: n.trim()
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
var c = "organization";
|
|
43
|
+
function l({ name: e, email: t }) {
|
|
44
|
+
let n = t.trim();
|
|
45
|
+
return {
|
|
46
|
+
type: c,
|
|
47
|
+
is_customer: !0,
|
|
48
|
+
is_vendor: !1,
|
|
49
|
+
reminders_enabled: !0,
|
|
50
|
+
language: "en",
|
|
51
|
+
organization: {
|
|
52
|
+
legal_name: e.trim(),
|
|
53
|
+
...n ? { email: n } : {}
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
//#endregion
|
|
58
|
+
export { c as INLINE_CUSTOMER_TYPE, o as buildCustomerCardView, l as buildInlineCustomerPayload, r as filterCustomerPickerEntries, a as findCustomerExactMatch, i as findCustomerTabMatch, s as seedCustomerFormValues, n as toCustomerPickerEntries };
|
|
@@ -19,6 +19,7 @@ function w() {
|
|
|
19
19
|
return {
|
|
20
20
|
type: "invoice",
|
|
21
21
|
customerId: "",
|
|
22
|
+
customerName: "",
|
|
22
23
|
customerEmail: "",
|
|
23
24
|
currency: "USD",
|
|
24
25
|
issueDate: (/* @__PURE__ */ new Date()).toISOString().slice(0, 10),
|
|
@@ -114,19 +115,19 @@ function P({ values: e, counterpart: t, addresses: n }) {
|
|
|
114
115
|
shippingAddressId: a
|
|
115
116
|
};
|
|
116
117
|
}
|
|
117
|
-
function F({ values: e,
|
|
118
|
-
let o = {};
|
|
119
|
-
e.customerId
|
|
120
|
-
let
|
|
121
|
-
!e.customerId &&
|
|
122
|
-
let
|
|
118
|
+
function F({ values: e, messages: t, willIssue: r = !1, hasStartedRecurrence: i = !1, canCreateCustomer: a = !0 }) {
|
|
119
|
+
let o = {}, s = a && !!e.customerName.trim();
|
|
120
|
+
!e.customerId && !s && (o.customerId = t.customerRequired);
|
|
121
|
+
let c = e.customerEmail.trim();
|
|
122
|
+
!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);
|
|
123
|
+
let u = d(e.lineItems, {
|
|
123
124
|
currency: e.currency,
|
|
124
|
-
messages:
|
|
125
|
-
requireComplete:
|
|
126
|
-
}),
|
|
127
|
-
|
|
128
|
-
let
|
|
129
|
-
return
|
|
125
|
+
messages: t,
|
|
126
|
+
requireComplete: r || i
|
|
127
|
+
}), f = l(u, S(e, t), (r || i) && e.lineItems.length === 0 ? t.lineItemsRequired : void 0);
|
|
128
|
+
u && (o.lineItems = u), f && (o.lineItemsSummary = f);
|
|
129
|
+
let p = x(e, t);
|
|
130
|
+
return p && (o.discount = p), o;
|
|
130
131
|
}
|
|
131
132
|
function I(e) {
|
|
132
133
|
return Object.keys(e).length > 0;
|
|
@@ -134,7 +135,6 @@ function I(e) {
|
|
|
134
135
|
function L(e, t) {
|
|
135
136
|
return !I(F({
|
|
136
137
|
values: B(e),
|
|
137
|
-
billingAddressId: e.type === "invoice" ? e.counterpart_billing_address?.id ?? void 0 : void 0,
|
|
138
138
|
messages: t,
|
|
139
139
|
willIssue: !0
|
|
140
140
|
}));
|
|
@@ -152,7 +152,7 @@ function z({ values: e, billingAddressId: t, shippingAddressId: n, unitNamesById
|
|
|
152
152
|
taxRate: e.taxRate,
|
|
153
153
|
unitNamesById: r
|
|
154
154
|
})), s = {
|
|
155
|
-
counterpart_billing_address_id: t,
|
|
155
|
+
counterpart_billing_address_id: t || void 0,
|
|
156
156
|
counterpart_shipping_address_id: n || void 0,
|
|
157
157
|
counterpart_id: e.customerId,
|
|
158
158
|
currency: e.currency,
|
|
@@ -211,7 +211,7 @@ function V(e) {
|
|
|
211
211
|
}
|
|
212
212
|
function H({ values: e, billingAddressId: t, shippingAddressId: n, lineItemChanges: r }) {
|
|
213
213
|
let i = {
|
|
214
|
-
counterpart_billing_address_id: t,
|
|
214
|
+
counterpart_billing_address_id: t || null,
|
|
215
215
|
counterpart_shipping_address_id: n || null,
|
|
216
216
|
counterpart_id: e.customerId,
|
|
217
217
|
currency: e.currency,
|
|
@@ -1,8 +1,16 @@
|
|
|
1
1
|
//#region ../../libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/labels.js
|
|
2
2
|
var e = {
|
|
3
|
-
customerRequired: "Customer is required",
|
|
4
|
-
customerAddressRequired: "The selected customer needs a billing address before a receivable can be created.",
|
|
3
|
+
customerRequired: "Customer is a required field",
|
|
5
4
|
customerEmailInvalid: "Please enter a valid email address",
|
|
5
|
+
customerPickerPlaceholder: "Search or type to add a customer",
|
|
6
|
+
customerPickerSearchOnlyPlaceholder: "Search for a customer",
|
|
7
|
+
customerPickerEmpty: "No customers found - type to add a customer",
|
|
8
|
+
customerPickerSearchOnlyEmpty: "No customers found",
|
|
9
|
+
customerPickerLoading: "Loading customers…",
|
|
10
|
+
customerPickerLoadFailed: "Couldn't load customers",
|
|
11
|
+
customerPickerMoreMatches: "Keep typing to narrow down the list",
|
|
12
|
+
customerPickerDescription: "Search by customer name or email. New customers will be saved when saving the invoice.",
|
|
13
|
+
customerPickerSearchOnlyDescription: "Search by customer name or email.",
|
|
6
14
|
currencyRequired: "Currency is required",
|
|
7
15
|
lineItemNameTooLong: "Product name must be 100 characters or less",
|
|
8
16
|
lineItemPriceTooHigh: "Price must be {maxAmount} or less",
|
|
@@ -54,9 +62,9 @@ var e = {
|
|
|
54
62
|
detailsInvoiceAmount: "Invoice amount",
|
|
55
63
|
detailsBalanceDue: "Balance due",
|
|
56
64
|
detailsAmountReceived: "Amount received",
|
|
57
|
-
detailsCancelledAmount: "
|
|
65
|
+
detailsCancelledAmount: "Canceled amount",
|
|
58
66
|
detailsAmountWrittenOff: "Amount written off",
|
|
59
|
-
detailsCancelledOnCaption: "
|
|
67
|
+
detailsCancelledOnCaption: "Canceled on",
|
|
60
68
|
detailsPending: "Pending",
|
|
61
69
|
detailsNotProvided: "Not provided",
|
|
62
70
|
detailsCustomerName: "Name",
|
|
@@ -91,11 +99,11 @@ var e = {
|
|
|
91
99
|
detailsScheduleOpenInvoice: "Open invoice {number}",
|
|
92
100
|
detailsSeriesStatusActive: "Active",
|
|
93
101
|
detailsSeriesStatusPaused: "Paused",
|
|
94
|
-
detailsSeriesStatusCanceled: "
|
|
102
|
+
detailsSeriesStatusCanceled: "Canceled",
|
|
95
103
|
detailsSeriesStatusCompleted: "Complete",
|
|
96
104
|
detailsIterationStatusPending: "Scheduled",
|
|
97
105
|
detailsIterationStatusSkipped: "Skipped",
|
|
98
|
-
detailsIterationStatusCanceled: "
|
|
106
|
+
detailsIterationStatusCanceled: "Canceled",
|
|
99
107
|
detailsIterationStatusIssueFailed: "Issue failed",
|
|
100
108
|
detailsIterationStatusSendFailed: "Send failed",
|
|
101
109
|
detailsIterationStatusCompleted: "Complete",
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { RECEIVABLE_PAYMENT_TERMS_CUSTOM_DATE as e, RECEIVABLE_PAYMENT_TERMS_RECEIPT_DUE as t } from "../../../../ui/dist/
|
|
1
|
+
import { RECEIVABLE_PAYMENT_TERMS_CUSTOM_DATE as e, RECEIVABLE_PAYMENT_TERMS_RECEIPT_DUE as t } from "../../../../ui/dist/index20.js";
|
|
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
|
|
@@ -7,7 +7,8 @@ function n(n) {
|
|
|
7
7
|
return {
|
|
8
8
|
canRead: e(r, [t.InvoiceReadOrg]),
|
|
9
9
|
canWrite: e(r, [t.InvoiceWriteOrg]),
|
|
10
|
-
canEditSettings: e(r, [t.OrganizationSettingsWriteOrg])
|
|
10
|
+
canEditSettings: e(r, [t.OrganizationSettingsWriteOrg]),
|
|
11
|
+
canCreateCustomer: e(r, [t.CounterpartWriteOrg])
|
|
11
12
|
};
|
|
12
13
|
}
|
|
13
14
|
//#endregion
|
|
@@ -1,96 +1,97 @@
|
|
|
1
1
|
import { minorExponentForCurrency as e } from "../../../../../shared/util/dist/lib/amountOutputToMajorUnits.js";
|
|
2
|
-
import "../../../../ui/dist/
|
|
2
|
+
import "../../../../ui/dist/index20.js";
|
|
3
3
|
import "../../../../ui/dist/index.js";
|
|
4
4
|
import { isBlankLineItem as t, keepsSavedTaxRates as n, lineItemTaxRateMinorUnits as r, parseQuantity as i, priceInputToMinorUnits as a, taxRateToMinorUnits as o } from "./lineItems.js";
|
|
5
5
|
import { formatPreviewDate as s, resolveIssueDate as c, termDueDate as l } from "./paymentTerms.js";
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
6
|
+
import { bracketAmount as u } from "./totals.js";
|
|
7
|
+
import { formatMoney as d } from "./helpers.js";
|
|
8
|
+
import { differenceInCalendarDays as f, parseISO as p } from "date-fns";
|
|
8
9
|
//#region ../../libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/preview.js
|
|
9
|
-
var
|
|
10
|
-
function h(e) {
|
|
11
|
-
return (e ?? []).filter(({ status: e, direction: t }) => e === "active" && t === "receive");
|
|
12
|
-
}
|
|
10
|
+
var m = "US", h = 100;
|
|
13
11
|
function g(e) {
|
|
14
|
-
return
|
|
12
|
+
return (e ?? []).filter(({ status: e, direction: t }) => e === "active" && t === "receive");
|
|
15
13
|
}
|
|
16
14
|
function _(e) {
|
|
17
|
-
return e
|
|
15
|
+
return g(e).length > 0;
|
|
18
16
|
}
|
|
19
17
|
function v(e) {
|
|
18
|
+
return e?.invoice?.display_organization_bank_account ?? e?.display_organization_bank_account ?? !0;
|
|
19
|
+
}
|
|
20
|
+
function y(e) {
|
|
20
21
|
try {
|
|
21
22
|
return new Intl.DisplayNames(void 0, { type: "region" }).of(e) ?? e;
|
|
22
23
|
} catch {
|
|
23
24
|
return e;
|
|
24
25
|
}
|
|
25
26
|
}
|
|
26
|
-
function
|
|
27
|
+
function b({ address: e, issuerCountry: t, formatCountry: n = y }) {
|
|
27
28
|
if (!e) return [];
|
|
28
|
-
let r = [e.city, e.state].filter(Boolean).join(", "), i = e.country ===
|
|
29
|
+
let r = [e.city, e.state].filter(Boolean).join(", "), i = e.country === m && t === m;
|
|
29
30
|
return [
|
|
30
31
|
[e.line1, e.line2].filter(Boolean).join(" "),
|
|
31
32
|
[r, e.postal_code].filter(Boolean).join(" "),
|
|
32
33
|
e.country && !i ? n(e.country) : ""
|
|
33
34
|
].filter(Boolean);
|
|
34
35
|
}
|
|
35
|
-
var
|
|
36
|
+
var x = { kind: "pending" }, S = (e) => ({
|
|
36
37
|
kind: "text",
|
|
37
38
|
lines: e
|
|
38
39
|
});
|
|
39
|
-
function
|
|
40
|
+
function C(e, t) {
|
|
40
41
|
return e.previewNetDays.replace("{days}", String(t));
|
|
41
42
|
}
|
|
42
|
-
function
|
|
43
|
+
function w(e, t) {
|
|
43
44
|
let n = e.previewEarlyPaymentDays.replace("{days}", String(t.number_of_days));
|
|
44
|
-
return t.discount ? `${n}, ${e.previewEarlyPaymentDiscount.replace("{rate}", String(t.discount /
|
|
45
|
+
return t.discount ? `${n}, ${e.previewEarlyPaymentDiscount.replace("{rate}", String(t.discount / h))}` : n;
|
|
45
46
|
}
|
|
46
|
-
function
|
|
47
|
+
function T({ paymentTermsId: e, paymentTermsCustomDate: t, paymentTerms: n, issueDate: r, messages: i }) {
|
|
47
48
|
let a = {
|
|
48
|
-
dueDate:
|
|
49
|
-
paymentTerms:
|
|
49
|
+
dueDate: x,
|
|
50
|
+
paymentTerms: x
|
|
50
51
|
};
|
|
51
52
|
if (e === "custom") {
|
|
52
53
|
if (!t) return a;
|
|
53
|
-
let e =
|
|
54
|
+
let e = p(t), n = Math.max(0, f(e, r));
|
|
54
55
|
return {
|
|
55
|
-
dueDate:
|
|
56
|
-
paymentTerms:
|
|
56
|
+
dueDate: S([s(e)]),
|
|
57
|
+
paymentTerms: S([C(i, n)])
|
|
57
58
|
};
|
|
58
59
|
}
|
|
59
60
|
if (e === "receipt_due") return {
|
|
60
|
-
dueDate:
|
|
61
|
-
paymentTerms:
|
|
61
|
+
dueDate: S([s(r)]),
|
|
62
|
+
paymentTerms: S([i.previewDueOnReceipt])
|
|
62
63
|
};
|
|
63
64
|
let o = n?.find((t) => t.id === e);
|
|
64
65
|
if (!o) return a;
|
|
65
66
|
let c = l(o, r), u = [
|
|
66
|
-
o.term_1 &&
|
|
67
|
-
o.term_2 &&
|
|
68
|
-
o.term_final &&
|
|
67
|
+
o.term_1 && w(i, o.term_1),
|
|
68
|
+
o.term_2 && w(i, o.term_2),
|
|
69
|
+
o.term_final && C(i, o.term_final.number_of_days)
|
|
69
70
|
].filter((e) => !!e);
|
|
70
71
|
return {
|
|
71
|
-
dueDate: c ?
|
|
72
|
-
paymentTerms: u.length > 0 ?
|
|
72
|
+
dueDate: c ? S([s(c)]) : x,
|
|
73
|
+
paymentTerms: u.length > 0 ? S(u) : x
|
|
73
74
|
};
|
|
74
75
|
}
|
|
75
|
-
function
|
|
76
|
+
function E(e, t) {
|
|
76
77
|
return t ? e.previewTaxId.replace("{taxId}", t) : void 0;
|
|
77
78
|
}
|
|
78
|
-
function
|
|
79
|
+
function D(e) {
|
|
79
80
|
return e.length > 0 ? e : void 0;
|
|
80
81
|
}
|
|
81
|
-
function
|
|
82
|
+
function O(e, t) {
|
|
82
83
|
return e ? {
|
|
83
84
|
name: e.type === "organization" ? e.organization.legal_name : void 0,
|
|
84
|
-
addressLines:
|
|
85
|
+
addressLines: D(b({
|
|
85
86
|
address: e.address,
|
|
86
87
|
issuerCountry: e.address?.country
|
|
87
88
|
})),
|
|
88
|
-
taxIdLine:
|
|
89
|
+
taxIdLine: E(t, e.tax_id),
|
|
89
90
|
email: e.email ?? void 0,
|
|
90
91
|
phone: e.phone ?? void 0
|
|
91
92
|
} : {};
|
|
92
93
|
}
|
|
93
|
-
function
|
|
94
|
+
function k(e) {
|
|
94
95
|
let t = "organization" in e ? e.organization : e.individual;
|
|
95
96
|
return {
|
|
96
97
|
name: "organization" in e ? e.organization.legal_name : [e.individual.first_name, e.individual.last_name].filter(Boolean).join(" "),
|
|
@@ -98,36 +99,36 @@ function O(e) {
|
|
|
98
99
|
phone: t.phone
|
|
99
100
|
};
|
|
100
101
|
}
|
|
101
|
-
function
|
|
102
|
+
function A({ counterpart: e, billingAddress: t, issuerCountry: n, messages: r }) {
|
|
102
103
|
if (!e) return { kind: "pending" };
|
|
103
|
-
let { name: i, email: a, phone: o } =
|
|
104
|
+
let { name: i, email: a, phone: o } = k(e);
|
|
104
105
|
return i ? {
|
|
105
106
|
kind: "party",
|
|
106
107
|
name: i,
|
|
107
|
-
addressLines:
|
|
108
|
+
addressLines: D(b({
|
|
108
109
|
address: t,
|
|
109
110
|
issuerCountry: n
|
|
110
111
|
})),
|
|
111
|
-
taxIdLine:
|
|
112
|
+
taxIdLine: E(r, e.tax_id),
|
|
112
113
|
email: a || void 0,
|
|
113
114
|
phone: o || void 0
|
|
114
115
|
} : { kind: "pending" };
|
|
115
116
|
}
|
|
116
|
-
function
|
|
117
|
+
function j({ lineItems: e, currency: n, unitNamesById: r, messages: o }) {
|
|
117
118
|
return e.filter((e) => !t(e)).map((e) => {
|
|
118
119
|
let t = a(e.price, n), s = i(e.quantity), c = r[e.measureUnitId] || e.measureUnitName;
|
|
119
120
|
return {
|
|
120
121
|
id: e.id,
|
|
121
122
|
name: e.name,
|
|
122
123
|
quantity: String(s),
|
|
123
|
-
price:
|
|
124
|
+
price: d({
|
|
124
125
|
amount: t,
|
|
125
126
|
currency: n,
|
|
126
127
|
fallback: ""
|
|
127
128
|
}),
|
|
128
129
|
...c ? { unit: c } : {},
|
|
129
130
|
taxable: e.taxable ? o.previewTaxableYes : o.previewTaxableNo,
|
|
130
|
-
amount:
|
|
131
|
+
amount: d({
|
|
131
132
|
amount: Math.round(t * s),
|
|
132
133
|
currency: n,
|
|
133
134
|
fallback: ""
|
|
@@ -135,20 +136,19 @@ function A({ lineItems: e, currency: n, unitNamesById: r, messages: o }) {
|
|
|
135
136
|
};
|
|
136
137
|
});
|
|
137
138
|
}
|
|
138
|
-
function
|
|
139
|
-
return n ? new Intl.NumberFormat(void 0, {
|
|
139
|
+
function M(t, n) {
|
|
140
|
+
return n ? u(new Intl.NumberFormat(void 0, {
|
|
140
141
|
style: "currency",
|
|
141
|
-
currency: n
|
|
142
|
-
|
|
143
|
-
}).format(-t / 10 ** e(n)) : "";
|
|
142
|
+
currency: n
|
|
143
|
+
}), t / 10 ** e(n)) : "";
|
|
144
144
|
}
|
|
145
|
-
function
|
|
145
|
+
function N(e, i) {
|
|
146
146
|
if (!e.taxRate) return i.previewTax;
|
|
147
147
|
let a = o(e.taxRate), s = n(e.taxRate, e.savedTaxRate);
|
|
148
|
-
return new Set(e.lineItems.filter((e) => e.taxable && !t(e)).map((e) => r(e, a, s))).size > 1 ? i.previewTax : i.previewTaxWithRate.replace("{rate}", String(a /
|
|
148
|
+
return new Set(e.lineItems.filter((e) => e.taxable && !t(e)).map((e) => r(e, a, s))).size > 1 ? i.previewTax : i.previewTaxWithRate.replace("{rate}", String(a / h));
|
|
149
149
|
}
|
|
150
|
-
function
|
|
151
|
-
let i = (e) =>
|
|
150
|
+
function P({ totals: e, currency: t, taxLabel: n, messages: r }) {
|
|
151
|
+
let i = (e) => d({
|
|
152
152
|
amount: e,
|
|
153
153
|
currency: t,
|
|
154
154
|
fallback: ""
|
|
@@ -160,7 +160,7 @@ function N({ totals: e, currency: t, taxLabel: n, messages: r }) {
|
|
|
160
160
|
return a && c.push({
|
|
161
161
|
id: "discount",
|
|
162
162
|
label: r.previewDiscount,
|
|
163
|
-
value:
|
|
163
|
+
value: M(e.discountAmount, t)
|
|
164
164
|
}), s && (o || a) && c.push({
|
|
165
165
|
id: "nonTaxableSubtotal",
|
|
166
166
|
label: r.previewNonTaxableSubtotal,
|
|
@@ -183,7 +183,7 @@ function N({ totals: e, currency: t, taxLabel: n, messages: r }) {
|
|
|
183
183
|
}
|
|
184
184
|
};
|
|
185
185
|
}
|
|
186
|
-
function
|
|
186
|
+
function F({ bankDetails: e, canReceivePayments: t, messages: n }) {
|
|
187
187
|
let r = e ? [
|
|
188
188
|
[n.previewAccountHolderName, e.accountHolderName],
|
|
189
189
|
[n.previewRoutingNumber, e.routingNumber],
|
|
@@ -194,13 +194,13 @@ function P({ bankDetails: e, canReceivePayments: t, messages: n }) {
|
|
|
194
194
|
bankLines: r
|
|
195
195
|
};
|
|
196
196
|
}
|
|
197
|
-
function
|
|
198
|
-
let p =
|
|
197
|
+
function I({ values: e, totals: t, entity: n, counterpart: r, billingAddress: i, paymentTerms: a, unitNamesById: o, bankDetails: l, canReceivePayments: u = !1, messages: d, today: f = /* @__PURE__ */ new Date() }) {
|
|
198
|
+
let p = j({
|
|
199
199
|
lineItems: e.lineItems,
|
|
200
200
|
currency: e.currency,
|
|
201
201
|
unitNamesById: o,
|
|
202
202
|
messages: d
|
|
203
|
-
}), m = n?.logo?.url, h =
|
|
203
|
+
}), m = n?.logo?.url, h = O(n, d), g = c(e.issueDate, f);
|
|
204
204
|
return {
|
|
205
205
|
issuer: h,
|
|
206
206
|
logo: m ? {
|
|
@@ -208,15 +208,15 @@ function F({ values: e, totals: t, entity: n, counterpart: r, billingAddress: i,
|
|
|
208
208
|
src: m,
|
|
209
209
|
alt: h.name ? d.previewLogoAlt.replace("{name}", h.name) : d.previewLogoAltNoName
|
|
210
210
|
} : { kind: "placeholder" },
|
|
211
|
-
billTo:
|
|
211
|
+
billTo: A({
|
|
212
212
|
counterpart: r,
|
|
213
213
|
billingAddress: i,
|
|
214
214
|
issuerCountry: n?.address?.country,
|
|
215
215
|
messages: d
|
|
216
216
|
}),
|
|
217
|
-
invoiceNumber:
|
|
217
|
+
invoiceNumber: x,
|
|
218
218
|
issueDate: s(g),
|
|
219
|
-
...
|
|
219
|
+
...T({
|
|
220
220
|
paymentTermsId: e.paymentTermsId,
|
|
221
221
|
paymentTermsCustomDate: e.paymentTermsCustomDate,
|
|
222
222
|
paymentTerms: a,
|
|
@@ -229,14 +229,14 @@ function F({ values: e, totals: t, entity: n, counterpart: r, billingAddress: i,
|
|
|
229
229
|
kind: "rows",
|
|
230
230
|
rows: p
|
|
231
231
|
} : { kind: "empty" },
|
|
232
|
-
totals: p.length > 0 ?
|
|
232
|
+
totals: p.length > 0 ? P({
|
|
233
233
|
totals: t,
|
|
234
234
|
currency: e.currency,
|
|
235
|
-
taxLabel:
|
|
235
|
+
taxLabel: N(e, d),
|
|
236
236
|
messages: d
|
|
237
237
|
}) : void 0,
|
|
238
238
|
closingNote: e.closingNote || void 0,
|
|
239
|
-
payment:
|
|
239
|
+
payment: F({
|
|
240
240
|
bankDetails: l,
|
|
241
241
|
canReceivePayments: u,
|
|
242
242
|
messages: d
|
|
@@ -244,4 +244,4 @@ function F({ values: e, totals: t, entity: n, counterpart: r, billingAddress: i,
|
|
|
244
244
|
};
|
|
245
245
|
}
|
|
246
246
|
//#endregion
|
|
247
|
-
export {
|
|
247
|
+
export { b as buildPreviewAddressLines, T as buildPreviewPaymentTerms, I as buildReceivablePreviewView, v as displaysBankAccount, y as formatCountryName, M as formatDeduction, g as getReceivePaymentMethods, _ as hasReceivePaymentMethod };
|