@tesouro/embedded-components-react 0.5.211 → 0.5.213

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 (33) hide show
  1. package/dist/index.d.ts +16 -0
  2. package/dist/index.js +1 -1
  3. package/dist/lib/ReceivablesWidget.d.ts +16 -0
  4. package/dist/lib/ReceivablesWidget.js +1 -1
  5. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index.js +1 -1
  6. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index10.js +113 -109
  7. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index11.js +416 -132
  8. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index12.js +113 -211
  9. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index13.js +154 -37
  10. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index14.js +193 -135
  11. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index15.js +32 -37
  12. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index16.js +150 -58
  13. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index17.js +35 -89
  14. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index18.js +58 -116
  15. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index19.js +96 -47
  16. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index20.js +103 -347
  17. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index21.js +364 -64
  18. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index22.js +66 -106
  19. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index23.js +105 -275
  20. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index24.js +288 -0
  21. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index6.js +76 -61
  22. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index9.js +48 -422
  23. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index.js +5 -5
  24. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index22.js +38 -62
  25. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index23.js +61 -391
  26. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index24.js +457 -89
  27. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index25.js +91 -234
  28. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index26.js +234 -78
  29. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index27.js +80 -331
  30. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index28.js +344 -0
  31. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index3.js +10 -0
  32. package/dist/libs/tesouro-embedded-components-react/shared/feature/dist/lib/analytics/build-info.js +1 -1
  33. package/package.json +1 -1
@@ -1,159 +1,443 @@
1
- import { hasAnyScope as e } from "../../../shared/data-access/dist/lib/hasAnyScope.js";
2
- import { Scope as t } from "../../../shared/data-access/dist/lib/scopes.js";
3
- import "../../../shared/data-access/dist/index.js";
4
- import { getCounterpartEmail as n } from "../../../shared/counterpart-management/feature/dist/lib/helpers.js";
5
- import "../../../shared/counterpart-management/feature/dist/index.js";
6
- import { RECEIVABLE_PAYMENT_TERMS_RECEIPT_DUE as r } from "../../ui/dist/index9.js";
7
- import "../../ui/dist/index.js";
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, keepsSavedTaxRates as i, lineItemToCreatePayload as a, lineItemToUpdatePayload as o, responseLineItemToFormValues as s, summarizeLineItemErrors as c, taxRateFromLineItems as l, validateLineItems as u } from "./index6.js";
4
+ import { attachmentFormValuesToPayload as d, receivableToAttachmentFormValues as f } from "./index7.js";
5
+ import { buildPaymentTermsPayload as p, buildPaymentTermsUpdatePayload as m, paymentTermsToFormFields as h } from "./index8.js";
6
+ import { createEmptyDiscount as g, discountFromDraft as _, discountToDraft as v } from "./index9.js";
7
+ import { validateDiscount as y, validateInvoiceTotals as b } from "./index10.js";
8
8
  //#region ../../libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index11.js
9
- var i = 1e4, a = 864e5;
10
- function o(n) {
11
- return e(new Set(n ?? []), [t.InvoiceWriteOrg]);
12
- }
13
- function s(e) {
14
- return e.replace(/\D/g, "");
15
- }
16
- var c = (e) => e.length > 0 ? Math.min(...e) : Infinity;
17
- function l(e) {
18
- return c([
19
- e.term_1_reminder,
20
- e.term_2_reminder,
21
- e.term_final_reminder
22
- ].flatMap((e) => e ? [e.days_before] : []));
23
- }
24
- function u(e) {
25
- return c((e.terms ?? []).map((e) => e.days_after));
26
- }
27
- function d(e) {
28
- return [...e ?? []].sort((e, t) => l(e) - l(t)).map(({ id: e, name: t }) => ({
29
- value: e,
30
- label: t
31
- }));
32
- }
33
- function f(e) {
34
- return [...e ?? []].sort((e, t) => u(e) - u(t)).map(({ id: e, name: t }) => ({
35
- value: e,
36
- label: t
37
- }));
9
+ var x = {
10
+ to: "",
11
+ cc: "",
12
+ bcc: "",
13
+ subject: "",
14
+ body: ""
15
+ }, S = {
16
+ mode: "full",
17
+ amountPaid: "",
18
+ paidAt: "",
19
+ comment: ""
20
+ };
21
+ function C() {
22
+ return {
23
+ type: "invoice",
24
+ customerId: "",
25
+ currency: "USD",
26
+ issueDate: (/* @__PURE__ */ new Date()).toISOString().slice(0, 10),
27
+ dueDate: "",
28
+ openingNote: "",
29
+ closingNote: "",
30
+ paymentTermsId: "",
31
+ paymentTermsCustomDate: "",
32
+ taxRate: "",
33
+ ...g("USD"),
34
+ lineItems: [n()],
35
+ bankAccountId: "",
36
+ bankAccountType: "",
37
+ paymentReminderId: "",
38
+ overdueReminderId: "",
39
+ attachments: []
40
+ };
38
41
  }
39
- function p(e) {
40
- let [t, n, r] = e.split("-").map(Number);
41
- if (t && n && r) return new Date(t, n - 1, r);
42
+ function w(e) {
43
+ return e === "quotes" ? "quote" : e === "credit_notes" ? "credit_note" : "invoice";
42
44
  }
43
- function m(e, t) {
44
- return Math.round((Date.UTC(t.getFullYear(), t.getMonth(), t.getDate()) - Date.UTC(e.getFullYear(), e.getMonth(), e.getDate())) / a);
45
+ function T(e) {
46
+ return e === "quote" ? "quotes" : e === "credit_note" ? "credit_notes" : "invoices";
45
47
  }
46
- function h({ paymentTermsId: e, paymentTermsCustomDate: t }) {
47
- return e === "custom" ? p(t) : void 0;
48
+ function E(e) {
49
+ return (e?.length ? e : [
50
+ "invoices",
51
+ "quotes",
52
+ "credit_notes"
53
+ ]).filter((e, t, n) => [
54
+ "invoices",
55
+ "quotes",
56
+ "credit_notes"
57
+ ].includes(e) && n.indexOf(e) === t);
48
58
  }
49
- function g({ paymentTermsId: e, paymentTermsCustomDate: t, paymentTerms: n, today: r }) {
50
- if (e === "custom") return p(t);
51
- let i = e === "receipt_due" ? 0 : n?.find((t) => t.id === e)?.term_final.number_of_days;
52
- if (i !== void 0) return new Date(r.getFullYear(), r.getMonth(), r.getDate() + i);
59
+ function D({ defaultTab: e, enabledTabs: t }) {
60
+ return e && t.includes(e) ? e : t[0] ?? "invoices";
53
61
  }
54
- function _(e) {
55
- return new Intl.DateTimeFormat("en-US", {
56
- month: "short",
62
+ function O(e, n) {
63
+ let r = t(e);
64
+ return r ? new Intl.DateTimeFormat(void 0, {
57
65
  day: "numeric",
66
+ month: "short",
58
67
  year: "numeric"
59
- }).format(e);
68
+ }).format(r) : n;
60
69
  }
61
- function v(e, t) {
62
- return (e === 1 ? t.reminderNameDay : t.reminderNameDays).replace("{days}", String(e));
70
+ function k({ amount: t, currency: n, fallback: r }) {
71
+ return t == null || !n ? r : new Intl.NumberFormat(void 0, {
72
+ currency: n,
73
+ style: "currency"
74
+ }).format(t / 10 ** e(n));
63
75
  }
64
- function y(e, t) {
65
- return Number(e) === 1 ? t.reminderUnitDay : t.reminderUnitDays;
76
+ function A(t, n) {
77
+ let r = Number(t);
78
+ if (!Number.isFinite(r)) return;
79
+ let i = n ? e(n) : 2;
80
+ return Math.round(r * 10 ** i);
66
81
  }
67
- function b(e) {
68
- let t = Number(e);
69
- return e !== "" && t >= 1 && t <= 1e4;
82
+ function j(e, t) {
83
+ return e.document_id || t.untitledDocument;
70
84
  }
71
- function x(e) {
72
- return e.every((e) => Number(e) >= 1);
85
+ function M(e, t) {
86
+ return e === "quote" ? t.quoteType : e === "credit_note" ? t.creditNoteType : t.invoiceType;
73
87
  }
74
- function S({ daysBefore: e, dueDate: t, messages: n }) {
88
+ function N(e) {
89
+ 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";
90
+ }
91
+ function P(e) {
92
+ let t = e.status === "draft", n = e.status === "issued", r = e.type === "invoice", i = e.type === "quote", a = e.type === "credit_note", o = r && [
93
+ "issued",
94
+ "overdue",
95
+ "partially_paid"
96
+ ].includes(e.status);
75
97
  return {
76
- name: v(e, n),
77
- term_final_reminder: {
78
- days_before: e,
79
- subject: n.reminderBeforeDueSubject,
80
- body: t ? n.reminderBeforeDueBody.replace("{dueDate}", _(t)) : n.reminderBeforeDueBodyNoDate
81
- }
98
+ edit: t && !a,
99
+ accept: i && n,
100
+ cancel: ![
101
+ "paid",
102
+ "canceled",
103
+ "deleted",
104
+ "uncollectible"
105
+ ].includes(e.status) && !t,
106
+ clone: !a && e.status !== "deleted",
107
+ decline: i && n,
108
+ delete: t,
109
+ issue: t,
110
+ markPaid: o,
111
+ markUncollectible: o,
112
+ recordPayment: o,
113
+ send: [
114
+ "issued",
115
+ "accepted",
116
+ "overdue",
117
+ "partially_paid"
118
+ ].includes(e.status) && !a
82
119
  };
83
120
  }
84
- function C({ terms: e, dueDate: t, messages: n }) {
85
- let r = e.map(Number).sort((e, t) => e - t), i = r.map((e) => v(e, n)), a = i.length === 1 ? i[0] : `${i.slice(0, -1).join(", ")} ${n.reminderNameAnd} ${i[i.length - 1]}`, o = t ? n.reminderOverdueBody.replace("{dueDate}", _(t)) : n.reminderOverdueBodyNoDate;
121
+ function F({ receivables: e, messages: t }) {
122
+ return e.map((e) => {
123
+ let n = e.type === "invoice" ? e.amount_due : void 0;
124
+ return {
125
+ id: e.id,
126
+ type: e.type,
127
+ documentLabel: j(e, t),
128
+ customerLabel: e.counterpart_name || t.unknownCustomer,
129
+ status: e.status,
130
+ statusTone: N(e.status),
131
+ issueDateLabel: O(e.issue_date, t.notAvailable),
132
+ dueDateLabel: O(e.type === "quote" ? e.expiry_date : e.due_date, t.notAvailable),
133
+ totalLabel: k({
134
+ amount: e.total_amount,
135
+ currency: e.currency,
136
+ fallback: t.notAvailable
137
+ }),
138
+ amountDueLabel: k({
139
+ amount: n,
140
+ currency: e.currency,
141
+ fallback: t.notAvailable
142
+ }),
143
+ actions: P(e)
144
+ };
145
+ });
146
+ }
147
+ function I({ receivable: e, history: t, mails: n, pdfUrl: r, messages: i }) {
148
+ if (!e) return;
149
+ let a = e.type === "invoice" ? e.amount_due : void 0, o = e.type === "quote" ? e.expiry_date : e.due_date;
86
150
  return {
87
- name: a,
88
- terms: r.map((e) => ({
89
- days_after: e,
90
- subject: n.reminderOverdueSubject,
91
- body: o
92
- }))
151
+ id: e.id,
152
+ type: e.type,
153
+ title: j(e, i),
154
+ customerLabel: e.counterpart_name || i.unknownCustomer,
155
+ status: e.status,
156
+ statusTone: N(e.status),
157
+ totalLabel: k({
158
+ amount: e.total_amount,
159
+ currency: e.currency,
160
+ fallback: i.notAvailable
161
+ }),
162
+ amountDueLabel: k({
163
+ amount: a,
164
+ currency: e.currency,
165
+ fallback: i.notAvailable
166
+ }),
167
+ pdfUrl: r || e.file_url || e.original_file_url || void 0,
168
+ summaryItems: [
169
+ {
170
+ label: i.summaryDocumentType,
171
+ value: M(e.type, i)
172
+ },
173
+ {
174
+ label: i.summaryDocumentNumber,
175
+ value: j(e, i)
176
+ },
177
+ {
178
+ label: i.summaryCustomer,
179
+ value: e.counterpart_name || i.unknownCustomer
180
+ },
181
+ {
182
+ label: i.summaryIssued,
183
+ value: O(e.issue_date, i.notAvailable)
184
+ },
185
+ {
186
+ label: i.summaryDue,
187
+ value: O(o, i.notAvailable)
188
+ },
189
+ {
190
+ label: i.summaryCreated,
191
+ value: O(e.created_at, i.notAvailable)
192
+ },
193
+ {
194
+ label: i.summaryUpdated,
195
+ value: O(e.updated_at, i.notAvailable)
196
+ },
197
+ {
198
+ label: i.summaryTotal,
199
+ value: k({
200
+ amount: e.total_amount,
201
+ currency: e.currency,
202
+ fallback: i.notAvailable
203
+ })
204
+ },
205
+ {
206
+ label: i.summaryAmountDue,
207
+ value: k({
208
+ amount: a,
209
+ currency: e.currency,
210
+ fallback: i.notAvailable
211
+ })
212
+ }
213
+ ],
214
+ lineItems: e.line_items.map((t, n) => ({
215
+ id: t.product.id || String(n),
216
+ name: t.product.name,
217
+ quantityLabel: String(t.quantity),
218
+ unitPriceLabel: k({
219
+ amount: t.product.price?.value,
220
+ currency: t.product.price?.currency || e.currency,
221
+ fallback: i.notAvailable
222
+ }),
223
+ totalLabel: k({
224
+ amount: t.total_after_tax ?? t.total_before_tax,
225
+ currency: e.currency,
226
+ fallback: i.notAvailable
227
+ })
228
+ })),
229
+ activityItems: t.map((e) => ({
230
+ id: e.id,
231
+ title: L(e.event_type, i),
232
+ description: e.event_type,
233
+ timestampLabel: O(e.timestamp, i.notAvailable)
234
+ })),
235
+ mailItems: n.map((e) => ({
236
+ id: e.id,
237
+ statusLabel: e.status,
238
+ recipientsLabel: R(e, i),
239
+ sentAtLabel: O(e.created_at, i.notAvailable)
240
+ })),
241
+ actions: P(e)
93
242
  };
94
243
  }
95
- function w(e) {
96
- return !!(e.paymentTermsId || e.paymentReminderId || e.overdueReminderId);
244
+ function L(e, t) {
245
+ 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;
246
+ }
247
+ function R(e, t) {
248
+ let n = [
249
+ ...e.recipients?.to ?? [],
250
+ ...e.recipients?.cc ?? [],
251
+ ...e.recipients?.bcc ?? []
252
+ ].map((e) => e.email).filter(Boolean);
253
+ return n.length > 0 ? n.join(", ") : t.recipientsNone;
97
254
  }
98
- function T({ showReminders: e, paymentTermsId: t, paymentTermsCustomDate: n, paymentReminderId: a, overdueReminderId: o, paymentReminders: s, overdueReminders: c, canCreate: l, disabled: u, beforeDueInput: p, overdueTerms: g, isCreatingPaymentReminder: _, isCreatingOverdueReminder: v, today: S, messages: C }) {
99
- let w = {
100
- checked: e,
101
- toggleDisabled: !t
255
+ function z({ values: e, billingAddressId: t, messages: n }) {
256
+ let r = {};
257
+ e.customerId ? t || (r.customerId = n.customerAddressRequired) : r.customerId = n.customerRequired, e.currency || (r.currency = n.currencyRequired);
258
+ let i = u(e.lineItems, {
259
+ currency: e.currency,
260
+ messages: n
261
+ }), a = c(i, b(e, n));
262
+ i && (r.lineItems = i), a && (r.lineItemsSummary = a);
263
+ let o = y(e, n);
264
+ return o && (r.discount = o), r;
265
+ }
266
+ function B(e) {
267
+ return Object.keys(e).length > 0;
268
+ }
269
+ function V({ bankAccountId: e, bankAccountType: t }) {
270
+ return {
271
+ bank_account_id: e || void 0,
272
+ bank_account_type: e && t || void 0
102
273
  };
103
- if (!e) return w;
104
- let T = p !== "", E = b(p), D = h({
105
- paymentTermsId: t,
106
- paymentTermsCustomDate: n
107
- }), O = D ? m(S, D) : void 0, k = s?.find((e) => e.id === a), A = k ? [
108
- k.term_1_reminder,
109
- k.term_2_reminder,
110
- k.term_final_reminder
111
- ].flatMap((e) => e ? [e.days_before] : []) : [], j = O !== void 0 && (T && Number(p) > O || A.some((e) => e > O)), M = t === r, N = d(s), P = f(c);
274
+ }
275
+ function H({ values: e, billingAddressId: t, unitNamesById: n }) {
276
+ let i = e.lineItems.filter((e) => !r(e)).map((t) => a({
277
+ lineItem: t,
278
+ currency: e.currency,
279
+ taxRate: e.taxRate,
280
+ unitNamesById: n
281
+ })), o = {
282
+ counterpart_billing_address_id: t,
283
+ counterpart_id: e.customerId,
284
+ currency: e.currency,
285
+ line_items: i,
286
+ memo: e.openingNote,
287
+ footer: e.closingNote,
288
+ discount: _(e) ?? void 0,
289
+ ...V(e)
290
+ };
291
+ return e.type === "quote" ? {
292
+ ...o,
293
+ expiry_date: e.dueDate || void 0,
294
+ type: "quote"
295
+ } : {
296
+ ...o,
297
+ ...p(e),
298
+ payment_reminder_id: e.paymentReminderId || void 0,
299
+ overdue_reminder_id: e.overdueReminderId || void 0,
300
+ attachments: d(e.attachments),
301
+ type: "invoice"
302
+ };
303
+ }
304
+ function U(e, t) {
305
+ 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({
306
+ lineItem: n,
307
+ currency: e.currency,
308
+ units: t
309
+ }));
112
310
  return {
113
- ...w,
114
- cards: {
115
- beforeDue: M ? void 0 : {
116
- options: N,
117
- selectedId: a,
118
- create: l ? {
119
- value: p,
120
- unitLabel: y(p, C),
121
- caption: N.length > 0 ? C.reminderBeforeDueCaption : void 0,
122
- error: T && !E ? C.reminderDaysRange.replace("{min}", "1").replace("{max}", String(i)) : void 0,
123
- inputDisabled: u || _,
124
- saveDisabled: !E || _,
125
- isSaving: _
126
- } : void 0,
127
- warning: j ? C.reminderPastDueWarning : void 0
128
- },
129
- overdue: {
130
- options: P,
131
- selectedId: o,
132
- create: l ? {
133
- caption: P.length > 0 ? C.reminderOverdueCaption : C.reminderOverdueEmptyCaption,
134
- terms: g.map((e, t) => ({
135
- value: e,
136
- unitLabel: y(e, C),
137
- ariaLabel: C.reminderOverdueTermLabel.replace("{index}", String(t + 1)),
138
- showPlaceholder: g.length === 1
139
- })),
140
- showAddTerm: g.length < 3,
141
- addTermDisabled: u || v || !g[g.length - 1],
142
- inputsDisabled: u || v,
143
- clearDisabled: u || v,
144
- saveDisabled: u || v || !x(g),
145
- isSaving: v
146
- } : void 0
147
- }
148
- }
311
+ ...C(),
312
+ type: r,
313
+ customerId: e.counterpart_id,
314
+ currency: e.currency,
315
+ issueDate: q(e.issue_date),
316
+ dueDate: e.type === "quote" ? q(e.expiry_date) : "",
317
+ openingNote: e.memo ?? "",
318
+ closingNote: e.footer ?? "",
319
+ ...e.type === "invoice" ? h(e.payment_terms) : {},
320
+ taxRate: i,
321
+ savedTaxRate: i,
322
+ ...v(e.discount, e.currency),
323
+ lineItems: o.length > 0 ? o : [n(e.currency)],
324
+ bankAccountId: e.bank_account_id ?? "",
325
+ bankAccountType: W(e.bank_account_type),
326
+ paymentReminderId: a?.payment_reminder_id ?? "",
327
+ overdueReminderId: a?.overdue_reminder_id ?? "",
328
+ attachments: f(e)
149
329
  };
150
330
  }
151
- function E(e) {
152
- return e.type === "invoice" && !!(e.payment_reminder_id || e.overdue_reminder_id);
331
+ function W(e) {
332
+ return e === "BANK_DETAILS" || e === "INTERNAL" || e === "EXTERNAL" ? e : "";
333
+ }
334
+ function G({ values: e, billingAddressId: t, lineItemChanges: n }) {
335
+ let r = {
336
+ counterpart_billing_address_id: t,
337
+ counterpart_id: e.customerId,
338
+ currency: e.currency,
339
+ issue_date: e.issueDate || void 0,
340
+ memo: e.openingNote,
341
+ footer: e.closingNote,
342
+ discount: _(e),
343
+ ...V(e)
344
+ };
345
+ return e.type === "quote" ? { quote: {
346
+ ...r,
347
+ ...n ? { line_items: n } : {},
348
+ expiry_date: e.dueDate || void 0,
349
+ ...m(e)
350
+ } } : { invoice: {
351
+ ...r,
352
+ ...n ? { line_items: n } : {},
353
+ ...m(e),
354
+ payment_reminder_id: e.paymentReminderId || null,
355
+ overdue_reminder_id: e.overdueReminderId || null,
356
+ attachments: d(e.attachments) ?? null
357
+ } };
358
+ }
359
+ function K({ values: e, originalLineItems: t, originalCurrency: n, unitNamesById: a, units: c }) {
360
+ let u = l(t), d = i(e.taxRate, u), f = (e, t, n) => o({
361
+ lineItem: e,
362
+ currency: t,
363
+ taxRate: n,
364
+ keepSavedRate: d,
365
+ unitNamesById: a
366
+ }), p = new Map(t.map((e) => [e.id, JSON.stringify(f(s({
367
+ lineItem: e,
368
+ currency: n,
369
+ units: c
370
+ }), 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) => {
371
+ let n = p.get(t.id);
372
+ if (n === void 0) return [];
373
+ let r = f(t, e.currency, e.taxRate);
374
+ return n === JSON.stringify(r) ? [] : [{
375
+ id: t.id,
376
+ data: r
377
+ }];
378
+ }), v = t.filter((e) => !h.has(e.id)).map((e) => e.id);
379
+ if (g.length || _.length || v.length) return {
380
+ ...g.length ? { add: g } : {},
381
+ ..._.length ? { replace: _ } : {},
382
+ ...v.length ? { remove: v } : {}
383
+ };
384
+ }
385
+ function q(e) {
386
+ return e?.slice(0, 10) ?? "";
153
387
  }
154
- function D(e, t) {
155
- let r = !!(e && n(e)), i = !!e?.reminders_enabled;
156
- if (!(i && r)) return r ? t.issueRemindersDisabled : i ? t.issueRemindersNoEmail : t.issueRemindersDisabledNoEmail;
388
+ function J(e, t) {
389
+ let n = {};
390
+ return e.to.trim() || (n.to = t.sendToRequired), e.subject.trim() || (n.subject = t.sendSubjectRequired), e.body.trim() || (n.body = t.sendBodyRequired), n;
391
+ }
392
+ function Y(e) {
393
+ return Object.keys(e).length > 0;
394
+ }
395
+ function X(e) {
396
+ return e.split(",").map((e) => e.trim()).filter(Boolean);
397
+ }
398
+ function Z(e, t, n) {
399
+ let r = {};
400
+ if (e.mode === "partial") {
401
+ let i = A(e.amountPaid, n);
402
+ (!i || i <= 0) && (r.amountPaid = t.paymentAmountInvalid);
403
+ }
404
+ return r;
405
+ }
406
+ function Q(e) {
407
+ return Object.keys(e).length > 0;
408
+ }
409
+ function $(e, t) {
410
+ return {
411
+ ...x,
412
+ to: e?.counterpart_contact?.email ?? "",
413
+ subject: e?.document_id ? `${t.sendSubjectDefault} ${e.document_id}` : t.sendSubjectDefault,
414
+ body: t.sendBodyDefault
415
+ };
416
+ }
417
+ function ee() {
418
+ return {
419
+ ...S,
420
+ paidAt: (/* @__PURE__ */ new Date()).toISOString().slice(0, 10)
421
+ };
422
+ }
423
+ function te() {
424
+ return [
425
+ "draft",
426
+ "issued",
427
+ "failed",
428
+ "accepted",
429
+ "expired",
430
+ "declined",
431
+ "recurring",
432
+ "partially_paid",
433
+ "paid",
434
+ "overdue",
435
+ "uncollectible",
436
+ "canceled"
437
+ ].map((e) => ({
438
+ value: e,
439
+ label: e.split("_").map((e) => `${e.slice(0, 1).toUpperCase()}${e.slice(1)}`).join(" ")
440
+ }));
157
441
  }
158
442
  //#endregion
159
- export { i as MAX_REMINDER_DAYS, x as areOverdueTermsValid, f as buildOverdueReminderOptions, C as buildOverdueReminderPayload, d as buildPaymentReminderOptions, S as buildPaymentReminderPayload, T as buildRemindersView, o as canCreateReminders, h as getCustomDueDate, g as getImpliedDueDate, D as getIssueReminderBlocker, E as hasSelectedReminder, b as isBeforeDueDaysValid, s as sanitizeReminderDays, w as shouldShowRemindersInitially };
443
+ export { S as EMPTY_RECEIVABLE_PAYMENT_VALUES, x as EMPTY_RECEIVABLE_SEND_VALUES, P as buildReceivableActions, I as buildReceivableDetailsView, F as buildReceivableRows, E as coerceEnabledTabs, C as createEmptyReceivableFormValues, n as createLineItem, ee as defaultPaymentValues, $ as defaultSendValues, O as formatDate, k as formatMoney, A as fromMajorUnits, j as getDocumentTitle, M as getDocumentTypeLabel, N as getStatusTone, Q as hasPaymentErrors, B as hasReceivableFormErrors, Y as hasSendErrors, H as receivableFormValuesToCreatePayload, K as receivableFormValuesToLineItemChanges, G as receivableFormValuesToUpdatePayload, U as receivableToFormValues, D as resolveInitialTab, X as splitEmailList, te as statusFilterOptions, T as tabForType, w as typeForTab, Z as validatePaymentValues, z as validateReceivableForm, J as validateSendValues };