@tesouro/embedded-components-react 0.5.278 → 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.
Files changed (107) hide show
  1. package/dist/index.d.ts +21 -6
  2. package/dist/lib/ReceivablesWidget.d.ts +21 -6
  3. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index.js +14 -13
  4. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index10.js +24 -168
  5. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index11.js +173 -44
  6. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index12.js +42 -94
  7. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index13.js +91 -76
  8. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index14.js +67 -173
  9. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index15.js +186 -17
  10. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index16.js +27 -0
  11. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index3.js +11 -13
  12. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index4.js +42 -27
  13. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index5.js +28 -132
  14. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index6.js +137 -16
  15. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index7.js +16 -62
  16. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index8.js +66 -28
  17. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index9.js +28 -34
  18. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/ReceivableAttachmentsSection.js +1 -1
  19. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/ReceivableCustomerSection.js +38 -0
  20. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/ReceivablesWidget.js +304 -287
  21. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/auditHistory/labels.js +1 -1
  22. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/customer.js +58 -0
  23. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/helpers.js +15 -15
  24. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/labels.js +14 -6
  25. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/paymentTerms.js +1 -1
  26. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/permissions.js +2 -1
  27. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/preview.js +62 -62
  28. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/recurrence.js +41 -35
  29. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/reminders.js +1 -1
  30. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/totals.js +21 -13
  31. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/useReceivableActions.js +124 -124
  32. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/useReceivableActionsModal.js +11 -11
  33. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/useReceivableAttachmentUploads.js +13 -13
  34. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/useReceivableBankAccount.js +1 -1
  35. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/useReceivableCustomerPicker.js +109 -0
  36. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/useReceivableDetails.js +6 -6
  37. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/useReceivableForm.js +520 -476
  38. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/useReceivableIssuePreflight.js +10 -10
  39. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/useReceivablePaymentRecord.js +6 -6
  40. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/useReceivablePaymentTerms.js +1 -1
  41. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/useReceivablePreview.js +1 -1
  42. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/useReceivableRecurrence.js +92 -77
  43. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/useReceivableReminders.js +11 -11
  44. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/useReceivableStatusCards.js +1 -1
  45. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/useReceivablesTable.js +4 -4
  46. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/useReceivablesWidget.js +79 -75
  47. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/useSendReceivableWithPaymentLink.js +3 -3
  48. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index.js +26 -23
  49. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index12.js +9 -25
  50. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index13.js +26 -228
  51. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index14.js +227 -52
  52. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index15.js +50 -212
  53. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index16.js +193 -138
  54. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index17.js +157 -12
  55. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index18.js +10 -19
  56. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index19.js +23 -2
  57. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index20.js +2 -116
  58. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index21.js +118 -3
  59. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index22.js +3 -39
  60. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index23.js +209 -53
  61. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index24.js +2 -23
  62. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index25.js +36 -7
  63. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index26.js +53 -77
  64. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index27.js +17 -35
  65. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index28.js +8 -18
  66. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index29.js +73 -37
  67. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index30.js +36 -26
  68. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index31.js +17 -19
  69. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index32.js +39 -8
  70. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index33.js +26 -33
  71. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index34.js +20 -14
  72. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index35.js +8 -24
  73. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index36.js +34 -84
  74. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index37.js +14 -492
  75. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index38.js +28 -2
  76. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index39.js +79 -39
  77. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index40.js +490 -68
  78. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index41.js +2 -487
  79. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index42.js +41 -217
  80. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index43.js +70 -21
  81. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index44.js +440 -5
  82. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index45.js +224 -0
  83. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index46.js +21 -263
  84. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index47.js +8 -2
  85. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index49.js +261 -24
  86. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index50.js +2 -237
  87. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index51.js +100 -3
  88. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index52.js +21 -242
  89. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index53.js +226 -82
  90. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index54.js +3 -60
  91. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index55.js +233 -178
  92. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index56.js +85 -37
  93. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index57.js +60 -0
  94. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index58.js +194 -0
  95. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index59.js +45 -0
  96. package/dist/libs/tesouro-embedded-components-react/linked-accounts-widget/feature/dist/lib/useLinkedAccountsWidget.js +1 -1
  97. package/dist/libs/tesouro-embedded-components-react/monite-sdk/dist/index503.js +1 -1
  98. package/dist/libs/tesouro-embedded-components-react/shared/counterpart-management/feature/dist/index.js +9 -9
  99. package/dist/libs/tesouro-embedded-components-react/shared/counterpart-management/feature/dist/lib/CounterpartSelector.js +2 -23
  100. package/dist/libs/tesouro-embedded-components-react/shared/counterpart-management/feature/dist/lib/useCounterpartSelector.js +2 -51
  101. package/dist/libs/tesouro-embedded-components-react/shared/counterpart-management/ui/dist/index.js +8 -8
  102. package/dist/libs/tesouro-embedded-components-react/shared/counterpart-management/ui/dist/index15.js +4 -80
  103. package/dist/libs/tesouro-embedded-components-react/shared/counterpart-management/ui/dist/index2.js +10 -22
  104. package/dist/libs/tesouro-embedded-components-react/shared/feature/dist/lib/analytics/build-info.js +1 -1
  105. package/dist/libs/tesouro-embedded-components-react/shared/util/dist/lib/widgetDomEvents.js +1 -1
  106. package/package.json +1 -1
  107. 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/index13.js";
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, billingAddressId: t, messages: r, willIssue: i = !1, hasStartedRecurrence: a = !1 }) {
118
- let o = {};
119
- e.customerId ? t || (o.customerId = r.customerAddressRequired) : o.customerId = r.customerRequired;
120
- let s = e.customerEmail.trim();
121
- !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);
122
- let c = d(e.lineItems, {
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: r,
125
- requireComplete: i || a
126
- }), u = l(c, S(e, r), (i || a) && e.lineItems.length === 0 ? r.lineItemsRequired : void 0);
127
- c && (o.lineItems = c), u && (o.lineItemsSummary = u);
128
- let f = x(e, r);
129
- return f && (o.discount = f), o;
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: "Cancelled amount",
65
+ detailsCancelledAmount: "Canceled amount",
58
66
  detailsAmountWrittenOff: "Amount written off",
59
- detailsCancelledOnCaption: "Cancelled on",
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: "Cancelled",
102
+ detailsSeriesStatusCanceled: "Canceled",
95
103
  detailsSeriesStatusCompleted: "Complete",
96
104
  detailsIterationStatusPending: "Scheduled",
97
105
  detailsIterationStatusSkipped: "Skipped",
98
- detailsIterationStatusCanceled: "Cancelled",
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/index19.js";
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/index19.js";
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 { formatMoney as u } from "./helpers.js";
7
- import { differenceInCalendarDays as d, parseISO as f } from "date-fns";
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 p = "US", m = 100;
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 h(e).length > 0;
12
+ return (e ?? []).filter(({ status: e, direction: t }) => e === "active" && t === "receive");
15
13
  }
16
14
  function _(e) {
17
- return e?.invoice?.display_organization_bank_account ?? e?.display_organization_bank_account ?? !0;
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 y({ address: e, issuerCountry: t, formatCountry: n = v }) {
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 === p && t === p;
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 b = { kind: "pending" }, x = (e) => ({
36
+ var x = { kind: "pending" }, S = (e) => ({
36
37
  kind: "text",
37
38
  lines: e
38
39
  });
39
- function S(e, t) {
40
+ function C(e, t) {
40
41
  return e.previewNetDays.replace("{days}", String(t));
41
42
  }
42
- function C(e, t) {
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 / m))}` : n;
45
+ return t.discount ? `${n}, ${e.previewEarlyPaymentDiscount.replace("{rate}", String(t.discount / h))}` : n;
45
46
  }
46
- function w({ paymentTermsId: e, paymentTermsCustomDate: t, paymentTerms: n, issueDate: r, messages: i }) {
47
+ function T({ paymentTermsId: e, paymentTermsCustomDate: t, paymentTerms: n, issueDate: r, messages: i }) {
47
48
  let a = {
48
- dueDate: b,
49
- paymentTerms: b
49
+ dueDate: x,
50
+ paymentTerms: x
50
51
  };
51
52
  if (e === "custom") {
52
53
  if (!t) return a;
53
- let e = f(t), n = Math.max(0, d(e, r));
54
+ let e = p(t), n = Math.max(0, f(e, r));
54
55
  return {
55
- dueDate: x([s(e)]),
56
- paymentTerms: x([S(i, n)])
56
+ dueDate: S([s(e)]),
57
+ paymentTerms: S([C(i, n)])
57
58
  };
58
59
  }
59
60
  if (e === "receipt_due") return {
60
- dueDate: x([s(r)]),
61
- paymentTerms: x([i.previewDueOnReceipt])
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 && C(i, o.term_1),
67
- o.term_2 && C(i, o.term_2),
68
- o.term_final && S(i, o.term_final.number_of_days)
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 ? x([s(c)]) : b,
72
- paymentTerms: u.length > 0 ? x(u) : b
72
+ dueDate: c ? S([s(c)]) : x,
73
+ paymentTerms: u.length > 0 ? S(u) : x
73
74
  };
74
75
  }
75
- function T(e, t) {
76
+ function E(e, t) {
76
77
  return t ? e.previewTaxId.replace("{taxId}", t) : void 0;
77
78
  }
78
- function E(e) {
79
+ function D(e) {
79
80
  return e.length > 0 ? e : void 0;
80
81
  }
81
- function D(e, t) {
82
+ function O(e, t) {
82
83
  return e ? {
83
84
  name: e.type === "organization" ? e.organization.legal_name : void 0,
84
- addressLines: E(y({
85
+ addressLines: D(b({
85
86
  address: e.address,
86
87
  issuerCountry: e.address?.country
87
88
  })),
88
- taxIdLine: T(t, e.tax_id),
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 O(e) {
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 k({ counterpart: e, billingAddress: t, issuerCountry: n, messages: r }) {
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 } = O(e);
104
+ let { name: i, email: a, phone: o } = k(e);
104
105
  return i ? {
105
106
  kind: "party",
106
107
  name: i,
107
- addressLines: E(y({
108
+ addressLines: D(b({
108
109
  address: t,
109
110
  issuerCountry: n
110
111
  })),
111
- taxIdLine: T(r, e.tax_id),
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 A({ lineItems: e, currency: n, unitNamesById: r, messages: o }) {
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: u({
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: u({
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 j(t, n) {
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
- currencySign: "accounting"
143
- }).format(-t / 10 ** e(n)) : "";
142
+ currency: n
143
+ }), t / 10 ** e(n)) : "";
144
144
  }
145
- function M(e, i) {
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 / m));
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 N({ totals: e, currency: t, taxLabel: n, messages: r }) {
151
- let i = (e) => u({
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: j(e.discountAmount, t)
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 P({ bankDetails: e, canReceivePayments: t, messages: n }) {
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 F({ 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 = A({
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 = D(n, d), g = c(e.issueDate, f);
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: k({
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: b,
217
+ invoiceNumber: x,
218
218
  issueDate: s(g),
219
- ...w({
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 ? N({
232
+ totals: p.length > 0 ? P({
233
233
  totals: t,
234
234
  currency: e.currency,
235
- taxLabel: M(e, d),
235
+ taxLabel: N(e, d),
236
236
  messages: d
237
237
  }) : void 0,
238
238
  closingNote: e.closingNote || void 0,
239
- payment: P({
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 { y as buildPreviewAddressLines, w as buildPreviewPaymentTerms, F as buildReceivablePreviewView, _ as displaysBankAccount, v as formatCountryName, j as formatDeduction, h as getReceivePaymentMethods, g as hasReceivePaymentMethod };
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 };