@tesouro/embedded-components-react 0.5.205 → 0.5.207

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 (59) hide show
  1. package/README.md +1 -1
  2. package/dist/index.d.ts +51 -4
  3. package/dist/index.js +1 -1
  4. package/dist/lib/ReceivablesWidget.d.ts +51 -4
  5. package/dist/lib/ReceivablesWidget.js +1 -1
  6. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index.js +2 -2
  7. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index10.js +84 -2
  8. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index2.js +31 -25
  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 +109 -193
  11. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index11.js +154 -37
  12. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index12.js +193 -135
  13. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index13.js +37 -58
  14. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index14.js +140 -86
  15. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index15.js +42 -47
  16. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index16.js +58 -313
  17. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index17.js +91 -65
  18. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index18.js +108 -102
  19. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index19.js +48 -249
  20. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index20.js +365 -0
  21. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index21.js +75 -0
  22. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index22.js +115 -0
  23. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index23.js +285 -0
  24. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index5.js +1 -1
  25. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index8.js +93 -407
  26. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index9.js +430 -86
  27. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index.js +17 -12
  28. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index10.js +92 -16
  29. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index11.js +3 -1
  30. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index12.js +24 -4
  31. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index13.js +0 -10
  32. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index14.js +2 -0
  33. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index15.js +3 -264
  34. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index16.js +16 -70
  35. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index17.js +1 -424
  36. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index18.js +4 -106
  37. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index19.js +12 -93
  38. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index2.js +5 -179
  39. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index20.js +1 -344
  40. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index21.js +264 -0
  41. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index22.js +72 -0
  42. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index23.js +402 -0
  43. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index24.js +106 -0
  44. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index25.js +249 -0
  45. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index26.js +93 -0
  46. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index27.js +344 -0
  47. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index3.js +195 -32
  48. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index4.js +29 -202
  49. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index5.js +183 -137
  50. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index6.js +157 -20
  51. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index7.js +16 -1
  52. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index8.js +25 -3
  53. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index9.js +4 -3
  54. package/dist/libs/tesouro-embedded-components-react/shared/counterpart-management/feature/dist/index.js +11 -11
  55. package/dist/libs/tesouro-embedded-components-react/shared/data-access/dist/index.js +38 -38
  56. package/dist/libs/tesouro-embedded-components-react/shared/data-access/dist/lib/rest/@tanstack/react-query.gen.js +220 -198
  57. package/dist/libs/tesouro-embedded-components-react/shared/data-access/dist/lib/rest/sdk.gen.js +124 -84
  58. package/dist/libs/tesouro-embedded-components-react/shared/feature/dist/lib/analytics/build-info.js +1 -1
  59. package/package.json +1 -1
@@ -1,89 +1,433 @@
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";
5
+ import { buildPaymentTermsPayload as f, buildPaymentTermsUpdatePayload as p, paymentTermsToFormFields as m } from "./index8.js";
1
6
  //#region ../../libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index9.js
2
- var e = {
3
- customerRequired: "Customer is required",
4
- customerAddressRequired: "The selected customer needs a billing address before a receivable can be created.",
5
- currencyRequired: "Currency is required",
6
- lineItemNameTooLong: "Product name must be 100 characters or less",
7
- lineItemPriceTooHigh: "Price must be {maxAmount} or less",
8
- sendToRequired: "Enter at least one recipient",
9
- sendSubjectRequired: "Subject is required",
10
- sendBodyRequired: "Message is required",
11
- paymentAmountInvalid: "Amount paid must be greater than 0",
12
- genericError: "Something went wrong. Please try again.",
13
- lineItemsLoading: "Please wait for invoice details to finish loading.",
14
- bankAccountFallbackName: "Bank Account",
15
- bankAccountPoweredBy: "Powered by {embeddedBankName}",
16
- bankAccountLinked: "Linked account",
17
- bankAccountHolderNameRequired: "Account holder name is required",
18
- bankAccountHolderNameTooLong: "Account holder name must be 255 characters or less",
19
- bankAccountNumberRequired: "Account number is required",
20
- bankAccountNumberDigitsOnly: "Account number must contain only digits",
21
- bankAccountNumberTooShort: "Account number must be at least 4 digits",
22
- bankAccountNumberTooLong: "Account number must be at most 17 digits",
23
- bankAccountRoutingNumberRequired: "Routing number is required",
24
- bankAccountRoutingNumberInvalid: "Routing number must be 9 digits",
25
- bankAccountNicknameTooLong: "Display name must be 200 characters or less",
26
- bankAccountCreated: "Bank Account \"{name}\" has been created.",
27
- bankAccountCreateFailed: "Failed to create Bank Account.",
28
- untitledDocument: "Untitled document",
29
- unknownCustomer: "Unknown customer",
30
- notAvailable: "Not available",
31
- invoiceType: "Invoice",
32
- quoteType: "Quote",
33
- creditNoteType: "Credit note",
34
- summaryDocumentType: "Document type",
35
- summaryDocumentNumber: "Document number",
36
- summaryCustomer: "Customer",
37
- summaryIssued: "Issued",
38
- summaryDue: "Due",
39
- summaryCreated: "Created",
40
- summaryUpdated: "Updated",
41
- summaryTotal: "Total",
42
- summaryAmountDue: "Amount due",
43
- activityStatusChanged: "Status changed",
44
- activityReceivableCreated: "Receivable created",
45
- activityReceivableUpdated: "Receivable updated",
46
- activityPaymentReceived: "Payment received",
47
- activityMailSent: "Email sent",
48
- activityUnknown: "Activity",
49
- recipientsNone: "No recipients",
50
- sendSubjectDefault: "Your receivable document",
51
- sendBodyDefault: "Please find the receivable document attached.",
52
- issueTitle: "Issue receivable?",
53
- issueDescription: "Issuing locks the document and makes it ready to send to the customer.",
54
- issueConfirm: "Issue",
55
- acceptTitle: "Accept quote?",
56
- acceptDescription: "This marks the quote as accepted.",
57
- acceptConfirm: "Accept",
58
- declineTitle: "Decline quote?",
59
- declineDescription: "This marks the quote as declined.",
60
- declineConfirm: "Decline",
61
- cancelTitle: "Cancel receivable?",
62
- cancelDescription: "This cancels the document. You cannot undo this action.",
63
- cancelConfirm: "Cancel document",
64
- cloneTitle: "Clone receivable?",
65
- cloneDescription: "This creates a new draft based on the selected document.",
66
- cloneConfirm: "Clone",
67
- deleteTitle: "Delete draft?",
68
- deleteDescription: "This permanently deletes the draft document. You cannot undo this action.",
69
- deleteConfirm: "Delete",
70
- markPaidTitle: "Mark invoice as paid?",
71
- markPaidDescription: "This records the invoice as fully paid.",
72
- markPaidConfirm: "Mark paid",
73
- markUncollectibleTitle: "Mark invoice uncollectible?",
74
- markUncollectibleDescription: "This records the invoice as uncollectible. You cannot undo this action.",
75
- markUncollectibleConfirm: "Mark uncollectible",
76
- attachmentsEmailCaption: "Selected files will be attached to the invoice email sent to the customer.",
77
- attachmentsRecurringEmailCaption: "Selected files will be attached to every invoice email in the recurring series.",
78
- attachmentIncludeInEmail: "Include in email:",
79
- attachmentRemove: "Remove",
80
- attachmentUploading: "Uploading…",
81
- attachmentUploadFailed: "Upload failed. Please try again.",
82
- attachmentTooLarge: "File too large (max 3 MB)",
83
- attachmentUnsupportedType: "File type not supported. Use PDF, DOC, JPG or PNG",
84
- attachmentsCountLimit: "You can attach up to 10 files.",
85
- attachmentIncludedInEmail: "Included in email",
86
- attachmentNotIncludedInEmail: "Not included in email"
7
+ var h = {
8
+ to: "",
9
+ cc: "",
10
+ bcc: "",
11
+ subject: "",
12
+ body: ""
13
+ }, g = {
14
+ mode: "full",
15
+ amountPaid: "",
16
+ paidAt: "",
17
+ comment: ""
87
18
  };
19
+ function _() {
20
+ return {
21
+ type: "invoice",
22
+ customerId: "",
23
+ currency: "USD",
24
+ issueDate: (/* @__PURE__ */ new Date()).toISOString().slice(0, 10),
25
+ dueDate: "",
26
+ openingNote: "",
27
+ closingNote: "",
28
+ paymentTermsId: "",
29
+ paymentTermsCustomDate: "",
30
+ taxRate: "",
31
+ lineItems: [n()],
32
+ bankAccountId: "",
33
+ bankAccountType: "",
34
+ paymentReminderId: "",
35
+ overdueReminderId: "",
36
+ attachments: []
37
+ };
38
+ }
39
+ function v(e) {
40
+ return e === "quotes" ? "quote" : e === "credit_notes" ? "credit_note" : "invoice";
41
+ }
42
+ function y(e) {
43
+ return e === "quote" ? "quotes" : e === "credit_note" ? "credit_notes" : "invoices";
44
+ }
45
+ function b(e) {
46
+ return (e?.length ? e : [
47
+ "invoices",
48
+ "quotes",
49
+ "credit_notes"
50
+ ]).filter((e, t, n) => [
51
+ "invoices",
52
+ "quotes",
53
+ "credit_notes"
54
+ ].includes(e) && n.indexOf(e) === t);
55
+ }
56
+ function x({ defaultTab: e, enabledTabs: t }) {
57
+ return e && t.includes(e) ? e : t[0] ?? "invoices";
58
+ }
59
+ function S(e, n) {
60
+ let r = t(e);
61
+ return r ? new Intl.DateTimeFormat(void 0, {
62
+ day: "numeric",
63
+ month: "short",
64
+ year: "numeric"
65
+ }).format(r) : n;
66
+ }
67
+ function C({ amount: t, currency: n, fallback: r }) {
68
+ return t == null || !n ? r : new Intl.NumberFormat(void 0, {
69
+ currency: n,
70
+ style: "currency"
71
+ }).format(t / 10 ** e(n));
72
+ }
73
+ function w(t, n) {
74
+ let r = Number(t);
75
+ if (!Number.isFinite(r)) return;
76
+ let i = n ? e(n) : 2;
77
+ return Math.round(r * 10 ** i);
78
+ }
79
+ function T(e, t) {
80
+ return e.document_id || t.untitledDocument;
81
+ }
82
+ function E(e, t) {
83
+ return e === "quote" ? t.quoteType : e === "credit_note" ? t.creditNoteType : t.invoiceType;
84
+ }
85
+ function D(e) {
86
+ 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";
87
+ }
88
+ function O(e) {
89
+ let t = e.status === "draft", n = e.status === "issued", r = e.type === "invoice", i = e.type === "quote", a = e.type === "credit_note", o = r && [
90
+ "issued",
91
+ "overdue",
92
+ "partially_paid"
93
+ ].includes(e.status);
94
+ return {
95
+ edit: t && !a,
96
+ accept: i && n,
97
+ cancel: ![
98
+ "paid",
99
+ "canceled",
100
+ "deleted",
101
+ "uncollectible"
102
+ ].includes(e.status) && !t,
103
+ clone: !a && e.status !== "deleted",
104
+ decline: i && n,
105
+ delete: t,
106
+ issue: t,
107
+ markPaid: o,
108
+ markUncollectible: o,
109
+ recordPayment: o,
110
+ send: [
111
+ "issued",
112
+ "accepted",
113
+ "overdue",
114
+ "partially_paid"
115
+ ].includes(e.status) && !a
116
+ };
117
+ }
118
+ function k({ receivables: e, messages: t }) {
119
+ return e.map((e) => {
120
+ let n = e.type === "invoice" ? e.amount_due : void 0;
121
+ return {
122
+ id: e.id,
123
+ type: e.type,
124
+ documentLabel: T(e, t),
125
+ customerLabel: e.counterpart_name || t.unknownCustomer,
126
+ status: e.status,
127
+ statusTone: D(e.status),
128
+ issueDateLabel: S(e.issue_date, t.notAvailable),
129
+ dueDateLabel: S(e.type === "quote" ? e.expiry_date : e.due_date, t.notAvailable),
130
+ totalLabel: C({
131
+ amount: e.total_amount,
132
+ currency: e.currency,
133
+ fallback: t.notAvailable
134
+ }),
135
+ amountDueLabel: C({
136
+ amount: n,
137
+ currency: e.currency,
138
+ fallback: t.notAvailable
139
+ }),
140
+ actions: O(e)
141
+ };
142
+ });
143
+ }
144
+ function A({ receivable: e, history: t, mails: n, pdfUrl: r, messages: i }) {
145
+ if (!e) return;
146
+ let a = e.type === "invoice" ? e.amount_due : void 0, o = e.type === "quote" ? e.expiry_date : e.due_date;
147
+ return {
148
+ id: e.id,
149
+ type: e.type,
150
+ title: T(e, i),
151
+ customerLabel: e.counterpart_name || i.unknownCustomer,
152
+ status: e.status,
153
+ statusTone: D(e.status),
154
+ totalLabel: C({
155
+ amount: e.total_amount,
156
+ currency: e.currency,
157
+ fallback: i.notAvailable
158
+ }),
159
+ amountDueLabel: C({
160
+ amount: a,
161
+ currency: e.currency,
162
+ fallback: i.notAvailable
163
+ }),
164
+ pdfUrl: r || e.file_url || e.original_file_url || void 0,
165
+ summaryItems: [
166
+ {
167
+ label: i.summaryDocumentType,
168
+ value: E(e.type, i)
169
+ },
170
+ {
171
+ label: i.summaryDocumentNumber,
172
+ value: T(e, i)
173
+ },
174
+ {
175
+ label: i.summaryCustomer,
176
+ value: e.counterpart_name || i.unknownCustomer
177
+ },
178
+ {
179
+ label: i.summaryIssued,
180
+ value: S(e.issue_date, i.notAvailable)
181
+ },
182
+ {
183
+ label: i.summaryDue,
184
+ value: S(o, i.notAvailable)
185
+ },
186
+ {
187
+ label: i.summaryCreated,
188
+ value: S(e.created_at, i.notAvailable)
189
+ },
190
+ {
191
+ label: i.summaryUpdated,
192
+ value: S(e.updated_at, i.notAvailable)
193
+ },
194
+ {
195
+ label: i.summaryTotal,
196
+ value: C({
197
+ amount: e.total_amount,
198
+ currency: e.currency,
199
+ fallback: i.notAvailable
200
+ })
201
+ },
202
+ {
203
+ label: i.summaryAmountDue,
204
+ value: C({
205
+ amount: a,
206
+ currency: e.currency,
207
+ fallback: i.notAvailable
208
+ })
209
+ }
210
+ ],
211
+ lineItems: e.line_items.map((t, n) => ({
212
+ id: t.product.id || String(n),
213
+ name: t.product.name,
214
+ quantityLabel: String(t.quantity),
215
+ unitPriceLabel: C({
216
+ amount: t.product.price?.value,
217
+ currency: t.product.price?.currency || e.currency,
218
+ fallback: i.notAvailable
219
+ }),
220
+ totalLabel: C({
221
+ amount: t.total_after_tax ?? t.total_before_tax,
222
+ currency: e.currency,
223
+ fallback: i.notAvailable
224
+ })
225
+ })),
226
+ activityItems: t.map((e) => ({
227
+ id: e.id,
228
+ title: j(e.event_type, i),
229
+ description: e.event_type,
230
+ timestampLabel: S(e.timestamp, i.notAvailable)
231
+ })),
232
+ mailItems: n.map((e) => ({
233
+ id: e.id,
234
+ statusLabel: e.status,
235
+ recipientsLabel: M(e, i),
236
+ sentAtLabel: S(e.created_at, i.notAvailable)
237
+ })),
238
+ actions: O(e)
239
+ };
240
+ }
241
+ function j(e, t) {
242
+ 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;
243
+ }
244
+ function M(e, t) {
245
+ let n = [
246
+ ...e.recipients?.to ?? [],
247
+ ...e.recipients?.cc ?? [],
248
+ ...e.recipients?.bcc ?? []
249
+ ].map((e) => e.email).filter(Boolean);
250
+ return n.length > 0 ? n.join(", ") : t.recipientsNone;
251
+ }
252
+ function N({ values: e, billingAddressId: t, messages: n }) {
253
+ let r = {};
254
+ e.customerId ? t || (r.customerId = n.customerAddressRequired) : r.customerId = n.customerRequired, e.currency || (r.currency = n.currencyRequired);
255
+ let i = l(e.lineItems, {
256
+ currency: e.currency,
257
+ messages: n
258
+ });
259
+ return i && (r.lineItems = i, r.lineItemsSummary = s(i)), r;
260
+ }
261
+ function P(e) {
262
+ return Object.keys(e).length > 0;
263
+ }
264
+ function F({ bankAccountId: e, bankAccountType: t }) {
265
+ return {
266
+ bank_account_id: e || void 0,
267
+ bank_account_type: e && t || void 0
268
+ };
269
+ }
270
+ function I({ values: e, billingAddressId: t, unitNamesById: n }) {
271
+ let a = e.lineItems.filter((e) => !r(e)).map((t) => i({
272
+ lineItem: t,
273
+ currency: e.currency,
274
+ taxRate: e.taxRate,
275
+ unitNamesById: n
276
+ })), o = {
277
+ counterpart_billing_address_id: t,
278
+ counterpart_id: e.customerId,
279
+ currency: e.currency,
280
+ line_items: a,
281
+ memo: e.openingNote,
282
+ footer: e.closingNote,
283
+ ...F(e)
284
+ };
285
+ return e.type === "quote" ? {
286
+ ...o,
287
+ expiry_date: e.dueDate || void 0,
288
+ type: "quote"
289
+ } : {
290
+ ...o,
291
+ ...f(e),
292
+ payment_reminder_id: e.paymentReminderId || void 0,
293
+ overdue_reminder_id: e.overdueReminderId || void 0,
294
+ attachments: u(e.attachments),
295
+ type: "invoice"
296
+ };
297
+ }
298
+ function L(e, t) {
299
+ let r = e.type === "quote" ? "quote" : "invoice", i = e.type === "invoice" ? e : void 0, a = e.line_items.map((n) => o({
300
+ lineItem: n,
301
+ currency: e.currency,
302
+ units: t
303
+ }));
304
+ return {
305
+ ..._(),
306
+ type: r,
307
+ customerId: e.counterpart_id,
308
+ currency: e.currency,
309
+ issueDate: V(e.issue_date),
310
+ dueDate: e.type === "quote" ? V(e.expiry_date) : "",
311
+ openingNote: e.memo ?? "",
312
+ closingNote: e.footer ?? "",
313
+ ...e.type === "invoice" ? m(e.payment_terms) : {},
314
+ taxRate: c(e.line_items),
315
+ lineItems: a.length > 0 ? a : [n(e.currency)],
316
+ bankAccountId: e.bank_account_id ?? "",
317
+ bankAccountType: R(e.bank_account_type),
318
+ paymentReminderId: i?.payment_reminder_id ?? "",
319
+ overdueReminderId: i?.overdue_reminder_id ?? "",
320
+ attachments: d(e)
321
+ };
322
+ }
323
+ function R(e) {
324
+ return e === "BANK_DETAILS" || e === "INTERNAL" || e === "EXTERNAL" ? e : "";
325
+ }
326
+ function z({ values: e, billingAddressId: t, lineItemChanges: n }) {
327
+ let r = {
328
+ counterpart_billing_address_id: t,
329
+ counterpart_id: e.customerId,
330
+ currency: e.currency,
331
+ issue_date: e.issueDate || void 0,
332
+ memo: e.openingNote,
333
+ footer: e.closingNote,
334
+ ...F(e)
335
+ };
336
+ return e.type === "quote" ? { quote: {
337
+ ...r,
338
+ ...n ? { line_items: n } : {},
339
+ expiry_date: e.dueDate || void 0,
340
+ ...p(e)
341
+ } } : { invoice: {
342
+ ...r,
343
+ ...n ? { line_items: n } : {},
344
+ ...p(e),
345
+ payment_reminder_id: e.paymentReminderId || null,
346
+ overdue_reminder_id: e.overdueReminderId || null,
347
+ attachments: u(e.attachments) ?? null
348
+ } };
349
+ }
350
+ function B({ values: e, originalLineItems: t, originalCurrency: n, unitNamesById: i, units: s }) {
351
+ let l = (e, t, n) => a({
352
+ lineItem: e,
353
+ currency: t,
354
+ taxRate: n,
355
+ unitNamesById: i
356
+ }), u = c(t), d = new Map(t.map((e) => [e.id, JSON.stringify(l(o({
357
+ lineItem: e,
358
+ currency: n,
359
+ units: s
360
+ }), 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) => {
361
+ let n = d.get(t.id);
362
+ if (n === void 0) return [];
363
+ let r = l(t, e.currency, e.taxRate);
364
+ return n === JSON.stringify(r) ? [] : [{
365
+ id: t.id,
366
+ data: r
367
+ }];
368
+ }), g = t.filter((e) => !p.has(e.id)).map((e) => e.id);
369
+ if (m.length || h.length || g.length) return {
370
+ ...m.length ? { add: m } : {},
371
+ ...h.length ? { replace: h } : {},
372
+ ...g.length ? { remove: g } : {}
373
+ };
374
+ }
375
+ function V(e) {
376
+ return e?.slice(0, 10) ?? "";
377
+ }
378
+ function H(e, t) {
379
+ let n = {};
380
+ return e.to.trim() || (n.to = t.sendToRequired), e.subject.trim() || (n.subject = t.sendSubjectRequired), e.body.trim() || (n.body = t.sendBodyRequired), n;
381
+ }
382
+ function U(e) {
383
+ return Object.keys(e).length > 0;
384
+ }
385
+ function W(e) {
386
+ return e.split(",").map((e) => e.trim()).filter(Boolean);
387
+ }
388
+ function G(e, t, n) {
389
+ let r = {};
390
+ if (e.mode === "partial") {
391
+ let i = w(e.amountPaid, n);
392
+ (!i || i <= 0) && (r.amountPaid = t.paymentAmountInvalid);
393
+ }
394
+ return r;
395
+ }
396
+ function K(e) {
397
+ return Object.keys(e).length > 0;
398
+ }
399
+ function q(e, t) {
400
+ return {
401
+ ...h,
402
+ to: e?.counterpart_contact?.email ?? "",
403
+ subject: e?.document_id ? `${t.sendSubjectDefault} ${e.document_id}` : t.sendSubjectDefault,
404
+ body: t.sendBodyDefault
405
+ };
406
+ }
407
+ function J() {
408
+ return {
409
+ ...g,
410
+ paidAt: (/* @__PURE__ */ new Date()).toISOString().slice(0, 10)
411
+ };
412
+ }
413
+ function Y() {
414
+ return [
415
+ "draft",
416
+ "issued",
417
+ "failed",
418
+ "accepted",
419
+ "expired",
420
+ "declined",
421
+ "recurring",
422
+ "partially_paid",
423
+ "paid",
424
+ "overdue",
425
+ "uncollectible",
426
+ "canceled"
427
+ ].map((e) => ({
428
+ value: e,
429
+ label: e.split("_").map((e) => `${e.slice(0, 1).toUpperCase()}${e.slice(1)}`).join(" ")
430
+ }));
431
+ }
88
432
  //#endregion
89
- export { e as RECEIVABLE_MESSAGE_LABELS_EN };
433
+ export { g as EMPTY_RECEIVABLE_PAYMENT_VALUES, h as EMPTY_RECEIVABLE_SEND_VALUES, O as buildReceivableActions, A as buildReceivableDetailsView, k as buildReceivableRows, b as coerceEnabledTabs, _ as createEmptyReceivableFormValues, n as createLineItem, J as defaultPaymentValues, q as defaultSendValues, S as formatDate, C as formatMoney, w as fromMajorUnits, T as getDocumentTitle, E as getDocumentTypeLabel, D as getStatusTone, K as hasPaymentErrors, P as hasReceivableFormErrors, U as hasSendErrors, I as receivableFormValuesToCreatePayload, B as receivableFormValuesToLineItemChanges, z as receivableFormValuesToUpdatePayload, L as receivableToFormValues, x as resolveInitialTab, W as splitEmailList, Y as statusFilterOptions, y as tabForType, v as typeForTab, G as validatePaymentValues, N as validateReceivableForm, H as validateSendValues };
@@ -1,13 +1,18 @@
1
1
  import "./index2.js";
2
- import { ReceivableActionDialog as e } from "./index3.js";
3
- import { ReceivableBankAccountSection as t } from "./index4.js";
4
- import { ReceivableAttachmentsSection as n } from "./index5.js";
5
- import "./index6.js";
6
- import "./index13.js";
7
- import "./index14.js";
8
- import { ReceivableDetailsSheet as r } from "./index15.js";
9
- import { ReceivableFormSheet as i } from "./index17.js";
10
- import { ReceivablePaymentDialog as a } from "./index18.js";
11
- import { ReceivableSendDialog as o } from "./index19.js";
12
- import { ReceivablesScreen as s } from "./index20.js";
13
- export { e as ReceivableActionDialog, n as ReceivableAttachmentsSection, t as ReceivableBankAccountSection, r as ReceivableDetailsSheet, i as ReceivableFormSheet, a as ReceivablePaymentDialog, o as ReceivableSendDialog, s as ReceivablesScreen };
2
+ import "./index3.js";
3
+ import { ReceivableActionDialog as e } from "./index4.js";
4
+ import { ReceivableBankAccountSection as t } from "./index5.js";
5
+ import { ReceivableAttachmentsSection as n } from "./index6.js";
6
+ import { RECEIVABLE_PAYMENT_TERMS_CUSTOM_DATE as r, RECEIVABLE_PAYMENT_TERMS_RECEIPT_DUE as i } from "./index9.js";
7
+ import { ReceivableBillingSection as a } from "./index10.js";
8
+ import "./index11.js";
9
+ import "./index12.js";
10
+ import "./index19.js";
11
+ import "./index20.js";
12
+ import { ReceivableDetailsSheet as o } from "./index21.js";
13
+ import { ReceivableFormSheet as s } from "./index23.js";
14
+ import { ReceivablePaymentDialog as c } from "./index24.js";
15
+ import { ReceivableRemindersSection as l } from "./index25.js";
16
+ import { ReceivableSendDialog as u } from "./index26.js";
17
+ import { ReceivablesScreen as d } from "./index27.js";
18
+ export { r as RECEIVABLE_PAYMENT_TERMS_CUSTOM_DATE, i as RECEIVABLE_PAYMENT_TERMS_RECEIPT_DUE, e as ReceivableActionDialog, n as ReceivableAttachmentsSection, t as ReceivableBankAccountSection, a as ReceivableBillingSection, o as ReceivableDetailsSheet, s as ReceivableFormSheet, c as ReceivablePaymentDialog, l as ReceivableRemindersSection, u as ReceivableSendDialog, d as ReceivablesScreen };
@@ -1,18 +1,94 @@
1
- import { Button as e } from "../../../../../packages/shared-ui-shadcn/dist/index.js";
2
- import { forwardRef as t } from "react";
3
- import { jsx as n } from "react/jsx-runtime";
4
- import { XIcon as r } from "lucide-react";
5
- t(function({ label: t, onClose: i, variant: a = "ghost", size: o = "icon", onClick: s, ...c }, l) {
6
- return /* @__PURE__ */ n(e, {
7
- ref: l,
8
- variant: a,
9
- size: o,
10
- ...c,
11
- "aria-label": t,
12
- onClick: (e) => {
13
- s?.(e), i();
14
- },
15
- children: /* @__PURE__ */ n(r, { className: "ttw:size-4" })
1
+ import { Field as e, FieldContent as t, FieldError as n, FieldLabel as r, Popover as i, PopoverAnchor as a, PopoverContent as o, Select as s, SelectContent as c, SelectItem as l, SelectSeparator as u, SelectTrigger as d, SelectValue as f, Skeleton as p, Typography as m } from "../../../../../packages/shared-ui-shadcn/dist/index.js";
2
+ import { RECEIVABLE_BILLING_SECTION_LABELS_EN as h } from "./index2.js";
3
+ import { RECEIVABLE_PAYMENT_TERMS_CUSTOM_DATE as g, RECEIVABLE_PAYMENT_TERMS_RECEIPT_DUE as _ } from "./index9.js";
4
+ import { OptionRow as v } from "./index7.js";
5
+ import { SelectionValue as y } from "./index8.js";
6
+ import { jsx as b, jsxs as x } from "react/jsx-runtime";
7
+ //#region ../../libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index10.js
8
+ function S({ idPrefix: S, paymentTerms: C, paymentTermsError: w, disabled: T, onPaymentTermsChange: E, onCustomDatePickerOpenChange: D, customDateCalendar: O, labels: k }) {
9
+ let A = {
10
+ ...h,
11
+ ...k
12
+ }, j = `${S}-payment-terms`, M = () => {
13
+ window.setTimeout(() => D(!0), 0);
14
+ };
15
+ return /* @__PURE__ */ x("div", {
16
+ className: "ttw:flex ttw:flex-col ttw:gap-2.5 ttw:rounded-xl ttw:border ttw:border-border ttw:p-6",
17
+ children: [/* @__PURE__ */ x("div", {
18
+ className: "ttw:flex ttw:flex-col ttw:gap-2.5 ttw:pb-4",
19
+ children: [/* @__PURE__ */ b(m, {
20
+ variant: "h4",
21
+ children: A.billingHeading
22
+ }), /* @__PURE__ */ b(m, {
23
+ variant: "body2",
24
+ color: "muted",
25
+ className: "ttw:font-medium",
26
+ children: A.billingDescription
27
+ })]
28
+ }), /* @__PURE__ */ b("div", {
29
+ className: "ttw:flex ttw:flex-col ttw:gap-6",
30
+ children: /* @__PURE__ */ b("div", {
31
+ className: "ttw:flex ttw:w-full ttw:items-start ttw:gap-2.5",
32
+ children: C.kind === "loading" ? /* @__PURE__ */ b(p, { className: "ttw:h-9 ttw:w-full" }) : /* @__PURE__ */ b(e, { children: /* @__PURE__ */ x(t, { children: [
33
+ /* @__PURE__ */ b(r, {
34
+ htmlFor: j,
35
+ children: A.paymentTermsLabel
36
+ }),
37
+ /* @__PURE__ */ x(i, {
38
+ open: C.customDatePicker.open,
39
+ onOpenChange: D,
40
+ children: [/* @__PURE__ */ x(s, {
41
+ disabled: T,
42
+ value: C.value,
43
+ onValueChange: (e) => {
44
+ E(e), e === "custom" && M();
45
+ },
46
+ children: [/* @__PURE__ */ b(a, {
47
+ className: "ttw:w-full",
48
+ children: /* @__PURE__ */ b(d, {
49
+ id: j,
50
+ className: "ttw:w-full",
51
+ "aria-invalid": !!w,
52
+ children: /* @__PURE__ */ b(f, {
53
+ placeholder: A.paymentTermsPlaceholder,
54
+ children: /* @__PURE__ */ b(y, {
55
+ selection: C.selection,
56
+ labels: A
57
+ })
58
+ })
59
+ })
60
+ }), /* @__PURE__ */ x(c, { children: [
61
+ /* @__PURE__ */ b(l, {
62
+ value: _,
63
+ children: A.paymentTermsReceiptDue
64
+ }),
65
+ /* @__PURE__ */ b(l, {
66
+ value: g,
67
+ onPointerUp: M,
68
+ onClick: M,
69
+ onKeyDown: (e) => {
70
+ (e.key === "Enter" || e.key === " ") && M();
71
+ },
72
+ children: A.paymentTermsCustomDate
73
+ }),
74
+ /* @__PURE__ */ b(u, {}),
75
+ C.options.map((e) => /* @__PURE__ */ b(l, {
76
+ value: e.value,
77
+ children: /* @__PURE__ */ b(v, { option: e })
78
+ }, e.value))
79
+ ] })]
80
+ }), /* @__PURE__ */ b(o, {
81
+ className: "ttw:w-auto ttw:overflow-hidden ttw:p-0",
82
+ align: "start",
83
+ onFocusOutside: (e) => e.preventDefault(),
84
+ children: O
85
+ })]
86
+ }),
87
+ /* @__PURE__ */ b(n, { errors: w ? [{ message: w }] : [] })
88
+ ] }) })
89
+ })
90
+ })]
16
91
  });
17
- });
92
+ }
18
93
  //#endregion
94
+ export { S as ReceivableBillingSection, S as default };
@@ -1 +1,3 @@
1
- import "react/jsx-runtime";
1
+ import "./index2.js";
2
+ import "./index9.js";
3
+ import "./index10.js";