@tesouro/embedded-components-react 0.5.204 → 0.5.206

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 (56) hide show
  1. package/README.md +15 -14
  2. package/dist/index.d.ts +49 -4
  3. package/dist/index.js +1 -1
  4. package/dist/lib/ReceivablesWidget.d.ts +49 -4
  5. package/dist/lib/ReceivablesWidget.js +1 -1
  6. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index.js +7 -7
  7. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index2.js +26 -23
  8. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index3.js +79 -2
  9. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index.js +1 -1
  10. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index10.js +88 -193
  11. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index11.js +184 -31
  12. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index12.js +32 -145
  13. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index13.js +150 -47
  14. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index14.js +37 -293
  15. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index15.js +58 -70
  16. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index16.js +86 -99
  17. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index17.js +48 -233
  18. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index18.js +336 -0
  19. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index19.js +75 -0
  20. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index20.js +115 -0
  21. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index21.js +270 -0
  22. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index5.js +1 -1
  23. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index8.js +95 -394
  24. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index9.js +422 -72
  25. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index.js +15 -10
  26. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index10.js +94 -1
  27. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index11.js +3 -4
  28. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index12.js +24 -11
  29. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index13.js +1 -1
  30. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index14.js +3 -264
  31. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index15.js +3 -72
  32. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index16.js +16 -421
  33. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index17.js +1 -106
  34. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index18.js +4 -93
  35. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index19.js +11 -343
  36. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index2.js +5 -159
  37. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index20.js +1 -0
  38. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index21.js +264 -0
  39. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index22.js +72 -0
  40. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index23.js +401 -0
  41. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index24.js +106 -0
  42. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index25.js +93 -0
  43. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index26.js +344 -0
  44. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index3.js +182 -32
  45. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index4.js +27 -154
  46. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index5.js +203 -20
  47. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index6.js +161 -1
  48. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index7.js +16 -3
  49. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index8.js +25 -3
  50. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index9.js +3 -17
  51. package/dist/libs/tesouro-embedded-components-react/shared/data-access/dist/index.js +38 -38
  52. package/dist/libs/tesouro-embedded-components-react/shared/data-access/dist/lib/rest/@tanstack/react-query.gen.js +213 -202
  53. package/dist/libs/tesouro-embedded-components-react/shared/data-access/dist/lib/rest/sdk.gen.js +136 -116
  54. package/dist/libs/tesouro-embedded-components-react/shared/feature/dist/lib/analytics/build-info.js +1 -1
  55. package/dist/packages/shared-ui-shadcn/dist/index.js +1763 -1749
  56. package/package.json +1 -1
@@ -1,417 +1,118 @@
1
- import { minorExponentForCurrency as e } from "../../../shared/util/dist/lib/amountOutputToMajorUnits.js";
2
- import { parseDateOrTimestamp as t } from "../../../shared/util/dist/lib/parseCalendarDate.js";
3
- import { createLineItem as n, isBlankLineItem as r, lineItemToCreatePayload as i, lineItemToUpdatePayload as a, responseLineItemToFormValues as o, summarizeLineItemErrors as s, taxRateFromLineItems as c, validateLineItems as l } from "./index6.js";
4
- import { attachmentFormValuesToPayload as u, receivableToAttachmentFormValues as d } from "./index7.js";
1
+ import { RECEIVABLE_PAYMENT_TERMS_CUSTOM_DATE as e, RECEIVABLE_PAYMENT_TERMS_RECEIPT_DUE as t } from "../../ui/dist/index9.js";
2
+ import "../../ui/dist/index.js";
3
+ import { addDays as n, addYears as r, format as i, max as a, min as o, parseISO as s, subYears as c } from "date-fns";
5
4
  //#region ../../libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index8.js
6
- var f = {
7
- to: "",
8
- cc: "",
9
- bcc: "",
10
- subject: "",
11
- body: ""
12
- }, p = {
13
- mode: "full",
14
- amountPaid: "",
15
- paidAt: "",
16
- comment: ""
17
- };
18
- function m() {
19
- return {
20
- type: "invoice",
21
- customerId: "",
22
- currency: "USD",
23
- issueDate: (/* @__PURE__ */ new Date()).toISOString().slice(0, 10),
24
- dueDate: "",
25
- openingNote: "",
26
- closingNote: "",
27
- paymentTermsId: "",
28
- taxRate: "",
29
- lineItems: [n()],
30
- attachments: []
31
- };
32
- }
33
- function h(e) {
34
- return e === "quotes" ? "quote" : e === "credit_notes" ? "credit_note" : "invoice";
35
- }
36
- function g(e) {
37
- return e === "quote" ? "quotes" : e === "credit_note" ? "credit_notes" : "invoices";
38
- }
39
- function _(e) {
40
- return (e?.length ? e : [
41
- "invoices",
42
- "quotes",
43
- "credit_notes"
44
- ]).filter((e, t, n) => [
45
- "invoices",
46
- "quotes",
47
- "credit_notes"
48
- ].includes(e) && n.indexOf(e) === t);
49
- }
50
- function v({ defaultTab: e, enabledTabs: t }) {
51
- return e && t.includes(e) ? e : t[0] ?? "invoices";
52
- }
53
- function y(e, n) {
54
- let r = t(e);
55
- return r ? new Intl.DateTimeFormat(void 0, {
56
- day: "numeric",
57
- month: "short",
58
- year: "numeric"
59
- }).format(r) : n;
60
- }
61
- function b({ amount: t, currency: n, fallback: r }) {
62
- return t == null || !n ? r : new Intl.NumberFormat(void 0, {
63
- currency: n,
64
- style: "currency"
65
- }).format(t / 10 ** e(n));
66
- }
67
- function x(t, n) {
68
- let r = Number(t);
69
- if (!Number.isFinite(r)) return;
70
- let i = n ? e(n) : 2;
71
- return Math.round(r * 10 ** i);
72
- }
73
- function S(e, t) {
74
- return e.document_id || t.untitledDocument;
75
- }
76
- function C(e, t) {
77
- return e === "quote" ? t.quoteType : e === "credit_note" ? t.creditNoteType : t.invoiceType;
78
- }
79
- function w(e) {
80
- 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";
81
- }
82
- function T(e) {
83
- let t = e.status === "draft", n = e.status === "issued", r = e.type === "invoice", i = e.type === "quote", a = e.type === "credit_note", o = r && [
84
- "issued",
85
- "overdue",
86
- "partially_paid"
87
- ].includes(e.status);
88
- return {
89
- edit: t && !a,
90
- accept: i && n,
91
- cancel: ![
92
- "paid",
93
- "canceled",
94
- "deleted",
95
- "uncollectible"
96
- ].includes(e.status) && !t,
97
- clone: !a && e.status !== "deleted",
98
- decline: i && n,
99
- delete: t,
100
- issue: t,
101
- markPaid: o,
102
- markUncollectible: o,
103
- recordPayment: o,
104
- send: [
105
- "issued",
106
- "accepted",
107
- "overdue",
108
- "partially_paid"
109
- ].includes(e.status) && !a
110
- };
111
- }
112
- function E({ receivables: e, messages: t }) {
113
- return e.map((e) => {
114
- let n = e.type === "invoice" ? e.amount_due : void 0;
115
- return {
116
- id: e.id,
117
- type: e.type,
118
- documentLabel: S(e, t),
119
- customerLabel: e.counterpart_name || t.unknownCustomer,
120
- status: e.status,
121
- statusTone: w(e.status),
122
- issueDateLabel: y(e.issue_date, t.notAvailable),
123
- dueDateLabel: y(e.type === "quote" ? e.expiry_date : e.due_date, t.notAvailable),
124
- totalLabel: b({
125
- amount: e.total_amount,
126
- currency: e.currency,
127
- fallback: t.notAvailable
128
- }),
129
- amountDueLabel: b({
130
- amount: n,
131
- currency: e.currency,
132
- fallback: t.notAvailable
133
- }),
134
- actions: T(e)
135
- };
5
+ var l = "MMM d, yyyy", u = "yyyy-MM-dd", d = 10, f = 5;
6
+ function p(e) {
7
+ let t = (e) => e ? {
8
+ number_of_days: e.number_of_days ?? null,
9
+ discount: e.discount ?? null
10
+ } : null;
11
+ return JSON.stringify({
12
+ name: e.name,
13
+ description: e.description ?? null,
14
+ term_final: { number_of_days: e.term_final?.number_of_days ?? null },
15
+ term_1: t(e.term_1),
16
+ term_2: t(e.term_2)
136
17
  });
137
18
  }
138
- function D({ receivable: e, history: t, mails: n, pdfUrl: r, messages: i }) {
139
- if (!e) return;
140
- let a = e.type === "invoice" ? e.amount_due : void 0, o = e.type === "quote" ? e.expiry_date : e.due_date;
141
- return {
142
- id: e.id,
143
- type: e.type,
144
- title: S(e, i),
145
- customerLabel: e.counterpart_name || i.unknownCustomer,
146
- status: e.status,
147
- statusTone: w(e.status),
148
- totalLabel: b({
149
- amount: e.total_amount,
150
- currency: e.currency,
151
- fallback: i.notAvailable
152
- }),
153
- amountDueLabel: b({
154
- amount: a,
155
- currency: e.currency,
156
- fallback: i.notAvailable
157
- }),
158
- pdfUrl: r || e.file_url || e.original_file_url || void 0,
159
- summaryItems: [
160
- {
161
- label: i.summaryDocumentType,
162
- value: C(e.type, i)
163
- },
164
- {
165
- label: i.summaryDocumentNumber,
166
- value: S(e, i)
167
- },
168
- {
169
- label: i.summaryCustomer,
170
- value: e.counterpart_name || i.unknownCustomer
171
- },
172
- {
173
- label: i.summaryIssued,
174
- value: y(e.issue_date, i.notAvailable)
175
- },
176
- {
177
- label: i.summaryDue,
178
- value: y(o, i.notAvailable)
179
- },
180
- {
181
- label: i.summaryCreated,
182
- value: y(e.created_at, i.notAvailable)
183
- },
184
- {
185
- label: i.summaryUpdated,
186
- value: y(e.updated_at, i.notAvailable)
187
- },
188
- {
189
- label: i.summaryTotal,
190
- value: b({
191
- amount: e.total_amount,
192
- currency: e.currency,
193
- fallback: i.notAvailable
194
- })
195
- },
196
- {
197
- label: i.summaryAmountDue,
198
- value: b({
199
- amount: a,
200
- currency: e.currency,
201
- fallback: i.notAvailable
202
- })
203
- }
204
- ],
205
- lineItems: e.line_items.map((t, n) => ({
206
- id: t.product.id || String(n),
207
- name: t.product.name,
208
- quantityLabel: String(t.quantity),
209
- unitPriceLabel: b({
210
- amount: t.product.price?.value,
211
- currency: t.product.price?.currency || e.currency,
212
- fallback: i.notAvailable
213
- }),
214
- totalLabel: b({
215
- amount: t.total_after_tax ?? t.total_before_tax,
216
- currency: e.currency,
217
- fallback: i.notAvailable
218
- })
219
- })),
220
- activityItems: t.map((e) => ({
221
- id: e.id,
222
- title: O(e.event_type, i),
223
- description: e.event_type,
224
- timestampLabel: y(e.timestamp, i.notAvailable)
225
- })),
226
- mailItems: n.map((e) => ({
227
- id: e.id,
228
- statusLabel: e.status,
229
- recipientsLabel: k(e, i),
230
- sentAtLabel: y(e.created_at, i.notAvailable)
231
- })),
232
- actions: T(e)
233
- };
234
- }
235
- function O(e, t) {
236
- return e === "status_changed" ? t.activityStatusChanged : e === "receivable_created" ? t.activityReceivableCreated : e === "receivable_updated" ? t.activityReceivableUpdated : e === "payment_received" ? t.activityPaymentReceived : e === "mail_sent" ? t.activityMailSent : t.activityUnknown;
237
- }
238
- function k(e, t) {
239
- let n = [
240
- ...e.recipients?.to ?? [],
241
- ...e.recipients?.cc ?? [],
242
- ...e.recipients?.bcc ?? []
243
- ].map((e) => e.email).filter(Boolean);
244
- return n.length > 0 ? n.join(", ") : t.recipientsNone;
245
- }
246
- function A({ values: e, billingAddressId: t, messages: n }) {
247
- let r = {};
248
- e.customerId ? t || (r.customerId = n.customerAddressRequired) : r.customerId = n.customerRequired, e.currency || (r.currency = n.currencyRequired);
249
- let i = l(e.lineItems, {
250
- currency: e.currency,
251
- messages: n
19
+ function m(e) {
20
+ let t = /* @__PURE__ */ new Set();
21
+ return e.filter((e) => {
22
+ let n = p(e);
23
+ return !t.has(n) && (t.add(n), !0);
252
24
  });
253
- return i && (r.lineItems = i, r.lineItemsSummary = s(i)), r;
254
25
  }
255
- function j(e) {
256
- return Object.keys(e).length > 0;
26
+ function h(e, t) {
27
+ let r = e.term_final?.number_of_days;
28
+ return r ? n(t, r) : void 0;
257
29
  }
258
- function M({ values: e, billingAddressId: t, unitNamesById: n }) {
259
- let a = e.lineItems.filter((e) => !r(e)).map((t) => i({
260
- lineItem: t,
261
- currency: e.currency,
262
- taxRate: e.taxRate,
263
- unitNamesById: n
264
- })), o = {
265
- counterpart_billing_address_id: t,
266
- counterpart_id: e.customerId,
267
- currency: e.currency,
268
- line_items: a,
269
- memo: e.openingNote,
270
- footer: e.closingNote
271
- };
272
- return e.type === "quote" ? {
273
- ...o,
274
- expiry_date: e.dueDate || void 0,
275
- type: "quote"
276
- } : {
277
- ...o,
278
- payment_terms_id: e.paymentTermsId || void 0,
279
- payment_terms: !e.paymentTermsId && e.dueDate ? { term_final: { end_date: e.dueDate } } : void 0,
280
- attachments: u(e.attachments),
281
- type: "invoice"
30
+ function g(e, t) {
31
+ let n = h(e, t);
32
+ return {
33
+ value: e.id,
34
+ label: e.name,
35
+ ...n ? { dueDateLabel: i(n, l) } : {}
282
36
  };
283
37
  }
284
- function N(e, t) {
285
- let r = e.type === "quote" ? "quote" : "invoice", i = e.type === "invoice" ? e.payment_terms?.id ?? "" : "", a = e.line_items.map((n) => o({
286
- lineItem: n,
287
- currency: e.currency,
288
- units: t
289
- }));
38
+ function _(e) {
39
+ return e ? s(e) : void 0;
40
+ }
41
+ function v({ terms: e, isLoading: t, fields: n, customDatePickerOpen: r, messages: a, today: o = /* @__PURE__ */ new Date() }) {
42
+ if (t) return { kind: "loading" };
43
+ let s = m(e ?? []).map((e) => g(e, o)), c = _(n.paymentTermsCustomDate), u;
44
+ if (n.paymentTermsId === "receipt_due") u = { kind: "receiptDue" };
45
+ else if (n.paymentTermsId === "custom") u = {
46
+ kind: "customDate",
47
+ hasDate: !!c,
48
+ dateLabel: c ? i(c, l) : a.paymentTermsCustomDatePlaceholder
49
+ };
50
+ else {
51
+ let e = s.find((e) => e.value === n.paymentTermsId);
52
+ e && (u = {
53
+ kind: "term",
54
+ option: e
55
+ });
56
+ }
290
57
  return {
291
- ...m(),
292
- type: r,
293
- customerId: e.counterpart_id,
294
- currency: e.currency,
295
- issueDate: I(e.issue_date),
296
- dueDate: I(e.type === "quote" ? e.expiry_date : e.due_date),
297
- openingNote: e.memo ?? "",
298
- closingNote: e.footer ?? "",
299
- paymentTermsId: i,
300
- taxRate: c(e.line_items),
301
- lineItems: a.length > 0 ? a : [n(e.currency)],
302
- attachments: d(e)
58
+ kind: "ready",
59
+ value: n.paymentTermsId,
60
+ options: s,
61
+ selection: u,
62
+ customDatePicker: { open: r }
303
63
  };
304
64
  }
305
- function P({ values: e, billingAddressId: t, lineItemChanges: n }) {
306
- let r = {
307
- counterpart_billing_address_id: t,
308
- counterpart_id: e.customerId,
309
- currency: e.currency,
310
- issue_date: e.issueDate || void 0,
311
- memo: e.openingNote,
312
- footer: e.closingNote
65
+ function y(e, t = /* @__PURE__ */ new Date()) {
66
+ let n = _(e), i = c(t, d), s = r(t, f);
67
+ return {
68
+ selected: n,
69
+ startMonth: n ? o([i, n]) : i,
70
+ endMonth: n ? a([s, n]) : s
313
71
  };
314
- return e.type === "quote" ? { quote: {
315
- ...r,
316
- ...n ? { line_items: n } : {},
317
- expiry_date: e.dueDate || void 0,
318
- payment_terms_id: e.paymentTermsId || void 0
319
- } } : { invoice: {
320
- ...r,
321
- ...n ? { line_items: n } : {},
322
- due_date: e.dueDate || void 0,
323
- payment_terms_id: e.paymentTermsId || void 0,
324
- payment_terms: !e.paymentTermsId && e.dueDate ? { term_final: { end_date: e.dueDate } } : void 0,
325
- attachments: u(e.attachments) ?? null
326
- } };
327
72
  }
328
- function F({ values: e, originalLineItems: t, originalCurrency: n, unitNamesById: i, units: s }) {
329
- let l = (e, t, n) => a({
330
- lineItem: e,
331
- currency: t,
332
- taxRate: n,
333
- unitNamesById: i
334
- }), u = c(t), d = new Map(t.map((e) => [e.id, JSON.stringify(l(o({
335
- lineItem: e,
336
- currency: n,
337
- units: s
338
- }), n, u))])), f = e.lineItems.filter((e) => !r(e)), p = new Set(f.map((e) => e.id)), m = f.filter((e) => !d.has(e.id)).map((t) => l(t, e.currency, e.taxRate)), h = f.flatMap((t) => {
339
- let n = d.get(t.id);
340
- if (n === void 0) return [];
341
- let r = l(t, e.currency, e.taxRate);
342
- return n === JSON.stringify(r) ? [] : [{
343
- id: t.id,
344
- data: r
345
- }];
346
- }), g = t.filter((e) => !p.has(e.id)).map((e) => e.id);
347
- if (m.length || h.length || g.length) return {
348
- ...m.length ? { add: m } : {},
349
- ...h.length ? { replace: h } : {},
350
- ...g.length ? { remove: g } : {}
73
+ function b(e, t) {
74
+ return t === "custom" ? {
75
+ paymentTermsId: t,
76
+ paymentTermsCustomDate: e.paymentTermsId === "custom" ? e.paymentTermsCustomDate : ""
77
+ } : {
78
+ paymentTermsId: t,
79
+ paymentTermsCustomDate: ""
351
80
  };
352
81
  }
353
- function I(e) {
354
- return e?.slice(0, 10) ?? "";
355
- }
356
- function L(e) {
357
- return (e ?? []).map((e) => ({
358
- value: e.id,
359
- label: e.name
360
- }));
361
- }
362
- function R(e, t) {
363
- let n = {};
364
- return e.to.trim() || (n.to = t.sendToRequired), e.subject.trim() || (n.subject = t.sendSubjectRequired), e.body.trim() || (n.body = t.sendBodyRequired), n;
365
- }
366
- function z(e) {
367
- return Object.keys(e).length > 0;
368
- }
369
- function B(e) {
370
- return e.split(",").map((e) => e.trim()).filter(Boolean);
82
+ function x(e) {
83
+ return e.paymentTermsId === "custom" && !e.paymentTermsCustomDate ? {
84
+ paymentTermsId: "",
85
+ paymentTermsCustomDate: ""
86
+ } : e;
371
87
  }
372
- function V(e, t, n) {
373
- let r = {};
374
- if (e.mode === "partial") {
375
- let i = x(e.amountPaid, n);
376
- (!i || i <= 0) && (r.amountPaid = t.paymentAmountInvalid);
377
- }
378
- return r;
88
+ function S(e) {
89
+ return e ? i(e, u) : "";
379
90
  }
380
- function H(e) {
381
- return Object.keys(e).length > 0;
91
+ function C(e) {
92
+ 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 } : {};
382
93
  }
383
- function U(e, t) {
384
- return {
385
- ...f,
386
- to: e?.counterpart_contact?.email ?? "",
387
- subject: e?.document_id ? `${t.sendSubjectDefault} ${e.document_id}` : t.sendSubjectDefault,
388
- body: t.sendBodyDefault
94
+ function w(e) {
95
+ return e.paymentTermsId ? C(e) : {
96
+ payment_terms_id: null,
97
+ payment_terms: null
389
98
  };
390
99
  }
391
- function W() {
392
- return {
393
- ...p,
394
- paidAt: (/* @__PURE__ */ new Date()).toISOString().slice(0, 10)
100
+ function T(n) {
101
+ if (n?.id) return {
102
+ paymentTermsId: n.id,
103
+ paymentTermsCustomDate: ""
104
+ };
105
+ let r = n?.term_final?.end_date;
106
+ return r ? {
107
+ paymentTermsId: e,
108
+ paymentTermsCustomDate: r.slice(0, 10)
109
+ } : n?.term_final?.number_of_days === 0 ? {
110
+ paymentTermsId: t,
111
+ paymentTermsCustomDate: ""
112
+ } : {
113
+ paymentTermsId: "",
114
+ paymentTermsCustomDate: ""
395
115
  };
396
- }
397
- function G() {
398
- return [
399
- "draft",
400
- "issued",
401
- "failed",
402
- "accepted",
403
- "expired",
404
- "declined",
405
- "recurring",
406
- "partially_paid",
407
- "paid",
408
- "overdue",
409
- "uncollectible",
410
- "canceled"
411
- ].map((e) => ({
412
- value: e,
413
- label: e.split("_").map((e) => `${e.slice(0, 1).toUpperCase()}${e.slice(1)}`).join(" ")
414
- }));
415
116
  }
416
117
  //#endregion
417
- export { p as EMPTY_RECEIVABLE_PAYMENT_VALUES, f as EMPTY_RECEIVABLE_SEND_VALUES, T as buildReceivableActions, D as buildReceivableDetailsView, E as buildReceivableRows, _ as coerceEnabledTabs, m as createEmptyReceivableFormValues, n as createLineItem, W as defaultPaymentValues, U as defaultSendValues, y as formatDate, b as formatMoney, x as fromMajorUnits, S as getDocumentTitle, C as getDocumentTypeLabel, L as getPaymentTermOptions, w as getStatusTone, H as hasPaymentErrors, j as hasReceivableFormErrors, z as hasSendErrors, M as receivableFormValuesToCreatePayload, F as receivableFormValuesToLineItemChanges, P as receivableFormValuesToUpdatePayload, N as receivableToFormValues, v as resolveInitialTab, B as splitEmailList, G as statusFilterOptions, g as tabForType, h as typeForTab, V as validatePaymentValues, A as validateReceivableForm, R as validateSendValues };
118
+ export { y as buildCustomDateCalendar, C as buildPaymentTermsPayload, w as buildPaymentTermsUpdatePayload, v as buildPaymentTermsView, x as closeCustomDatePickerFields, m as dedupePaymentTerms, T as paymentTermsToFormFields, b as selectPaymentTermsFields, S as toCustomDateValue };