@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.
Files changed (64) hide show
  1. package/README.md +2 -1
  2. package/dist/fixtures/index.d.ts +1 -1
  3. package/dist/index.css +109 -9
  4. package/dist/index.d.ts +41 -10
  5. package/dist/lib/ReceivablesWidget.d.ts +41 -10
  6. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index.js +11 -10
  7. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index10.js +42 -94
  8. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index11.js +91 -76
  9. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index12.js +67 -173
  10. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index13.js +186 -17
  11. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index14.js +27 -0
  12. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index4.js +28 -72
  13. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index5.js +128 -53
  14. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index6.js +66 -28
  15. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index7.js +28 -34
  16. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index8.js +24 -168
  17. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index9.js +173 -44
  18. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/ReceivablesWidget.js +274 -267
  19. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/helpers.js +99 -95
  20. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/labels.js +1 -0
  21. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/paymentTerms.js +28 -25
  22. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/preview.js +49 -43
  23. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/unsavedChanges.js +13 -0
  24. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/useReceivableActions.js +4 -4
  25. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/useReceivableActionsModal.js +2 -2
  26. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/useReceivableAttachmentUploads.js +1 -1
  27. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/useReceivableBankAccount.js +77 -72
  28. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/useReceivableDetails.js +4 -4
  29. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/useReceivableForm.js +363 -295
  30. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/useReceivableIssuePreflight.js +1 -1
  31. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/useReceivablePaymentRecord.js +1 -1
  32. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/useReceivablePreview.js +36 -21
  33. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/useReceivableReminders.js +1 -1
  34. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/useReceivableStatusCards.js +1 -1
  35. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/lib/ReceivablesWidget/useReceivablesTable.js +1 -1
  36. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index.js +12 -10
  37. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index13.js +21 -14
  38. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index15.js +1 -1
  39. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index16.js +1 -1
  40. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index20.js +68 -64
  41. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index38.js +383 -379
  42. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index40.js +22 -0
  43. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index41.js +8 -2
  44. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index43.js +258 -1
  45. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index44.js +2 -100
  46. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index45.js +95 -23
  47. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index46.js +23 -231
  48. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index47.js +237 -3
  49. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index48.js +3 -249
  50. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index49.js +234 -78
  51. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index50.js +87 -53
  52. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index51.js +49 -349
  53. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index52.js +359 -0
  54. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index53.js +45 -0
  55. package/dist/libs/tesouro-embedded-components-react/shared/data-access/dist/index.js +40 -40
  56. package/dist/libs/tesouro-embedded-components-react/shared/data-access/dist/lib/rest/@tanstack/react-query.gen.js +247 -214
  57. package/dist/libs/tesouro-embedded-components-react/shared/data-access/dist/lib/rest/sdk.gen.js +175 -147
  58. package/dist/libs/tesouro-embedded-components-react/shared/data-access/dist/lib/rest/zod.gen.js +1 -1
  59. package/dist/libs/tesouro-embedded-components-react/shared/feature/dist/lib/analytics/build-info.js +1 -1
  60. package/dist/libs/tesouro-embedded-components-react/shared/product-catalog/feature/dist/index.js +12 -12
  61. package/dist/libs/tesouro-embedded-components-react/shared/product-catalog/ui/dist/index2.js +2 -1
  62. package/dist/libs/tesouro-embedded-components-react/shared/product-catalog/ui/dist/index6.js +109 -89
  63. package/package.json +1 -1
  64. 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 { createLineItem as n, isBlankLineItem as r, keepsSavedTaxRates as i, lineItemToCreatePayload as a, lineItemToUpdatePayload as o, responseLineItemToFormValues as s, summarizeLineItemErrors as c, taxRateFromLineItems as l, validateLineItems as u } from "./lineItems.js";
4
- import { attachmentFormValuesToPayload as d, receivableToAttachmentFormValues as f } from "./attachments.js";
5
- import { createEmptyRecurrenceFields as p } from "./recurrence.js";
6
- import { buildPaymentTermsPayload as m, buildPaymentTermsUpdatePayload as h, paymentTermsToFormFields as g } from "./paymentTerms.js";
7
- import { createEmptyDiscount as _, discountFromDraft as v, discountToDraft as y } from "./discount.js";
8
- import { validateDiscount as b, validateInvoiceTotals as x } from "./totals.js";
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 S = {
11
+ var C = {
11
12
  to: "",
12
13
  cc: "",
13
14
  bcc: "",
14
15
  subject: "",
15
16
  body: ""
16
17
  };
17
- function C() {
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
- ..._("USD"),
30
- lineItems: [n()],
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
- ...p()
40
+ ...m()
39
41
  };
40
42
  }
41
- function w(e) {
43
+ function T(e) {
42
44
  return e === "quotes" ? "quote" : e === "credit_notes" ? "credit_note" : "invoice";
43
45
  }
44
- function T(e) {
46
+ function E(e) {
45
47
  return e === "quote" ? "quotes" : e === "credit_note" ? "credit_notes" : "invoices";
46
48
  }
47
- function E(e) {
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 D({ defaultTab: e, enabledTabs: t }) {
60
+ function O({ defaultTab: e, enabledTabs: t }) {
59
61
  return e && t.includes(e) ? e : t[0] ?? "invoices";
60
62
  }
61
- function O(e, n) {
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 k({ amount: t, currency: n, fallback: r }) {
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 A(t, n) {
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 j(e, t) {
83
+ function M(e, t) {
82
84
  return e.document_id || t.untitledDocument;
83
85
  }
84
- function M(e, t) {
86
+ function N(e, t) {
85
87
  return e === "quote" ? t.quoteType : e === "credit_note" ? t.creditNoteType : t.invoiceType;
86
88
  }
87
- function N(e) {
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 P(e) {
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 F(e, t, n) {
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 I = {
135
+ var L = {
134
136
  names: /* @__PURE__ */ new Map(),
135
137
  isResolving: !1
136
138
  };
137
- function L({ receivables: e, messages: t, canRecordPayment: n, customerNames: r = I }) {
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: j(e, t),
144
- ...F(e, r, t),
145
+ documentLabel: M(e, t),
146
+ ...I(e, r, t),
145
147
  status: e.status,
146
- statusTone: N(e.status),
147
- issueDateLabel: O(e.issue_date, t.notAvailable),
148
- dueDateLabel: O(e.type === "quote" ? e.expiry_date : e.due_date, t.notAvailable),
149
- totalLabel: k({
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: k({
156
+ amountDueLabel: A({
155
157
  amount: i,
156
158
  currency: e.currency,
157
159
  fallback: t.notAvailable
158
160
  }),
159
161
  actions: {
160
- ...P(e),
162
+ ...F(e),
161
163
  ...n ? {} : { recordPayment: !1 }
162
164
  }
163
165
  };
164
166
  });
165
167
  }
166
- function R(e) {
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 z({ values: e, counterpart: t, addresses: n }) {
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 B({ values: e, billingAddressId: t, messages: n, willIssue: r = !1, hasStartedRecurrence: i = !1 }) {
181
- let a = {};
182
- e.customerId ? t || (a.customerId = n.customerAddressRequired) : a.customerId = n.customerRequired, e.currency || (a.currency = n.currencyRequired), r && !e.paymentTermsId && (a.paymentTermsId = n.paymentTermsRequired), r && !e.bankAccountId && (a.bankAccountId = n.bankAccountRequired);
183
- let o = u(e.lineItems, {
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: n,
186
- requireComplete: r || i
187
- }), s = c(o, x(e, n), (r || i) && e.lineItems.length === 0 ? n.lineItemsRequired : void 0);
188
- o && (a.lineItems = o), s && (a.lineItemsSummary = s);
189
- let l = b(e, n);
190
- return l && (a.discount = l), a;
191
- }
192
- function V(e) {
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 H(e, t) {
196
- return !V(B({
197
- values: G(e),
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 U({ bankAccountId: e, bankAccountType: t }) {
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 W({ values: e, billingAddressId: t, shippingAddressId: n, unitNamesById: i }) {
210
- let o = e.lineItems.filter((e) => !r(e)).map((t) => a({
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: i
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: o,
224
+ line_items: a,
221
225
  memo: e.openingNote,
222
226
  footer: e.closingNote,
223
- discount: v(e) ?? void 0,
224
- ...U(e)
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
- ...m(e),
236
+ ...h(e),
233
237
  payment_reminder_id: e.paymentReminderId || void 0,
234
238
  overdue_reminder_id: e.overdueReminderId || void 0,
235
- attachments: d(e.attachments),
239
+ attachments: f(e.attachments),
236
240
  type: "invoice"
237
241
  };
238
242
  }
239
- function G(e, t) {
240
- let r = e.type === "quote" ? "quote" : "invoice", i = l(e.line_items), a = e.type === "invoice" ? e : void 0, o = e.line_items.map((n) => s({
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
- ...C(),
247
- type: r,
250
+ ...w(),
251
+ type: n,
248
252
  customerId: e.counterpart_id,
249
253
  currency: e.currency,
250
- issueDate: X(e.issue_date),
251
- dueDate: e.type === "quote" ? X(e.expiry_date) : "",
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" ? g(e.payment_terms) : {},
258
+ ...e.type === "invoice" ? _(e.payment_terms) : {},
255
259
  taxRate: i,
256
260
  savedTaxRate: i,
257
- ...y(e.discount, e.currency),
258
- lineItems: o.length > 0 ? o : [n(e.currency)],
261
+ ...b(e.discount, e.currency),
262
+ lineItems: o.length > 0 ? o : [r(e.currency)],
259
263
  bankAccountId: e.bank_account_id ?? "",
260
- bankAccountType: K(e.bank_account_type),
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: f(e)
269
+ attachments: p(e)
266
270
  };
267
271
  }
268
- function K(e) {
272
+ function q(e) {
269
273
  return e === "BANK_DETAILS" || e === "INTERNAL" || e === "EXTERNAL" ? e : "";
270
274
  }
271
- function q({ values: e, billingAddressId: t, shippingAddressId: n, lineItemChanges: r }) {
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: v(e),
281
- ...U(e)
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
- ...h(e)
291
+ ...g(e)
288
292
  } } : { invoice: {
289
293
  ...i,
290
294
  ...r ? { line_items: r } : {},
291
- ...h(e),
295
+ ...g(e),
292
296
  payment_reminder_id: e.paymentReminderId || null,
293
297
  overdue_reminder_id: e.overdueReminderId || null,
294
- attachments: d(e.attachments) ?? null
298
+ attachments: f(e.attachments) ?? null
295
299
  } };
296
300
  }
297
- function J({ values: e, originalLineItems: t, originalCurrency: n, unitNamesById: a, units: c }) {
298
- let u = l(t), d = i(e.taxRate, u), f = (e, t, n) => o({
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: a
304
- }), p = new Map(t.map((e) => [e.id, JSON.stringify(f(s({
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: c
308
- }), n, u))])), m = e.lineItems.filter((e) => !r(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) => {
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 Y({ values: e, originalLineItems: t, changes: n }) {
324
- let i = e.lineItems.filter((e) => !r(e)).map((e) => e.id);
325
- if (!t) return { created: i };
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: i.filter((e) => !a.has(e)),
332
+ added: r.filter((e) => !a.has(e)),
329
333
  replaced: n?.replace?.map((e) => e.id) ?? []
330
334
  };
331
335
  }
332
- function X(e) {
336
+ function Z(e) {
333
337
  return e?.slice(0, 10) ?? "";
334
338
  }
335
- function Z(e, t) {
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 Q(e) {
343
+ function $(e) {
340
344
  return Object.keys(e).length > 0;
341
345
  }
342
- function $(e) {
346
+ function ee(e) {
343
347
  return e.split(",").map((e) => e.trim()).filter(Boolean);
344
348
  }
345
- function ee(e, t) {
349
+ function te(e, t) {
346
350
  return {
347
- ...S,
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 te(e = "all") {
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 { S as EMPTY_RECEIVABLE_SEND_VALUES, P as buildReceivableActions, R as buildReceivableNotesView, L as buildReceivableRows, E as coerceEnabledTabs, C as createEmptyReceivableFormValues, n as createLineItem, ee as defaultSendValues, O as formatDate, k as formatMoney, A as fromMajorUnits, j as getDocumentTitle, M as getDocumentTypeLabel, N as getStatusTone, V as hasReceivableFormErrors, Q as hasSendErrors, H as isReceivableReadyToIssue, W as receivableFormValuesToCreatePayload, J as receivableFormValuesToLineItemChanges, q as receivableFormValuesToUpdatePayload, G as receivableToFormValues, z as resolveCounterpartAddresses, D as resolveInitialTab, $ as splitEmailList, te as statusFilterOptions, Y as submittedLineItemRows, T as tabForType, w as typeForTab, B as validateReceivableForm, Z as validateSendValues };
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", f = 10, p = 5;
6
- function m(e) {
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 h(e) {
19
+ function g(e) {
20
20
  let t = /* @__PURE__ */ new Set();
21
21
  return e.filter((e) => {
22
- let n = m(e);
22
+ let n = h(e);
23
23
  return !t.has(n) && (t.add(n), !0);
24
24
  });
25
25
  }
26
- function g(e) {
26
+ function _(e) {
27
27
  return i(e, u);
28
28
  }
29
- function _(e, t) {
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 v(e, t = /* @__PURE__ */ new Date()) {
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 y(e, t) {
38
- let n = _(e, t);
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: g(n) } : {}
45
+ ...n ? { dueDateLabel: _(n) } : {}
43
46
  };
44
47
  }
45
- function b(e) {
48
+ function S(e) {
46
49
  return e ? c(e) : void 0;
47
50
  }
48
- function x({ terms: e, isLoading: t, fields: n, customDatePickerOpen: r, isRecurring: i = !1, messages: a, issueDate: o = /* @__PURE__ */ new Date() }) {
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 = h(e ?? []).map((e) => y(e, o)), c = b(n.paymentTermsCustomDate), l;
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 ? g(c) : a.paymentTermsCustomDatePlaceholder
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 S(e, t = /* @__PURE__ */ new Date()) {
75
- let n = b(e), i = l(t, f), a = r(t, p);
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 C(e, t) {
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 w(e) {
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 T(e) {
98
- return e ? i(e, d) : "";
100
+ function D(e) {
101
+ return e ? i(e, f) : "";
99
102
  }
100
- function E(e) {
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 D(e) {
104
- return e.paymentTermsId ? E(e) : {
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 O(n) {
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 { S as buildCustomDateCalendar, E as buildPaymentTermsPayload, D as buildPaymentTermsUpdatePayload, x as buildPaymentTermsView, w as closeCustomDatePickerFields, h as dedupePaymentTerms, g as formatTermDate, O as paymentTermsToFormFields, v as resolveIssueDate, C as selectPaymentTermsFields, _ as termDueDate, T as toCustomDateValue };
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 };