@tesouro/embedded-components-react 0.5.227 → 0.5.230

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 (90) hide show
  1. package/README.md +22 -21
  2. package/dist/index.d.ts +87 -34
  3. package/dist/index.js +1 -1
  4. package/dist/lib/ReceivablesWidget.d.ts +87 -34
  5. package/dist/lib/ReceivablesWidget.js +1 -1
  6. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index.js +5 -5
  7. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index10.js +29 -59
  8. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index11.js +1 -1
  9. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index5.js +32 -33
  10. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index6.js +34 -32
  11. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index7.js +1 -1
  12. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index.js +1 -1
  13. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index10.js +120 -52
  14. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index11.js +44 -100
  15. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index12.js +93 -442
  16. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index13.js +356 -201
  17. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index14.js +225 -157
  18. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index15.js +152 -21
  19. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index16.js +18 -221
  20. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index17.js +220 -31
  21. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index18.js +125 -124
  22. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index19.js +58 -150
  23. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index20.js +232 -46
  24. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index21.js +303 -122
  25. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index22.js +43 -58
  26. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index23.js +125 -98
  27. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index24.js +140 -106
  28. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index25.js +46 -232
  29. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index26.js +119 -29
  30. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index27.js +81 -613
  31. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index28.js +116 -39
  32. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index29.js +27 -33
  33. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index30.js +634 -72
  34. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index31.js +39 -119
  35. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index32.js +36 -317
  36. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index33.js +82 -0
  37. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index34.js +139 -0
  38. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index35.js +340 -0
  39. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index5.js +1 -1
  40. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index7.js +15 -2
  41. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index8.js +55 -468
  42. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index9.js +443 -97
  43. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index.js +24 -22
  44. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index10.js +32 -2
  45. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index11.js +205 -84
  46. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index12.js +161 -3
  47. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index13.js +12 -20
  48. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index14.js +25 -1
  49. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index15.js +4 -3
  50. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index16.js +95 -3
  51. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index17.js +3 -18
  52. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index18.js +24 -1
  53. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index19.js +42 -4
  54. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index2.js +14 -7
  55. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index20.js +19 -12
  56. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index21.js +73 -1
  57. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index22.js +17 -261
  58. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index23.js +12 -44
  59. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index24.js +28 -68
  60. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index25.js +288 -479
  61. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index26.js +1 -106
  62. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index27.js +48 -0
  63. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index28.js +72 -2
  64. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index29.js +496 -4
  65. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index3.js +121 -27
  66. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index30.js +106 -1
  67. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index32.js +2 -28
  68. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index33.js +4 -236
  69. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index34.js +0 -2
  70. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index35.js +90 -239
  71. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index36.js +24 -89
  72. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index37.js +231 -54
  73. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index38.js +3 -353
  74. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index39.js +249 -0
  75. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index4.js +100 -207
  76. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index40.js +93 -0
  77. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index41.js +59 -0
  78. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index42.js +353 -0
  79. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index5.js +35 -29
  80. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index6.js +2 -216
  81. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index7.js +9 -159
  82. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index8.js +27 -14
  83. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index9.js +216 -23
  84. package/dist/libs/tesouro-embedded-components-react/shared/data-access/dist/index.js +40 -40
  85. package/dist/libs/tesouro-embedded-components-react/shared/data-access/dist/lib/rest/@tanstack/react-query.gen.js +189 -211
  86. package/dist/libs/tesouro-embedded-components-react/shared/data-access/dist/lib/rest/sdk.gen.js +43 -59
  87. package/dist/libs/tesouro-embedded-components-react/shared/feature/dist/lib/analytics/build-info.js +1 -1
  88. package/dist/libs/tesouro-embedded-components-react/shared/product-catalog/feature/dist/index.js +12 -12
  89. package/package.json +1 -1
  90. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index31.js +0 -100
@@ -1,127 +1,308 @@
1
- "use client";
2
- "use client";
3
- "use client";
4
- "use client";
5
- import { getCounterpartEmail as e } from "../../../shared/counterpart-management/feature/dist/lib/helpers.js";
6
- import { useCounterpartQuery as t } from "../../../shared/counterpart-management/data-access/dist/index3.js";
7
- import "../../../shared/counterpart-management/feature/dist/index.js";
8
- import { applyRecurrenceEmailDraft as n, buildRecurrenceEmailView as r, buildRecurrenceView as i, clearRecurrenceRecipients as a, createRecurrenceEmailDraft as o, selectRecurrenceDate as s, selectRecurrenceDayOfWeek as c, selectRecurrenceEndMode as l, selectRecurrenceFrequency as u, selectRecurrenceIssueMode as d, shouldOpenRecurrenceEmail as f } from "./index8.js";
9
- import { useCallback as p, useEffect as m, useMemo as h, useRef as g, useState as _ } from "react";
1
+ import { isLineItemTaxable as e } from "./index6.js";
2
+ import { buildReceivableAttachmentDetailsView as t } from "./index7.js";
3
+ import { allocateDiscount as n, resolveDiscountAmount as r } from "./index12.js";
4
+ import { buildReceivableNotesView as i, formatDate as a, formatMoney as o } from "./index13.js";
5
+ import { getPaymentAccountLineLabel as s } from "./index19.js";
6
+ import { formatCountryName as c, formatDeduction as l } from "./index20.js";
10
7
  //#region ../../libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index21.js
11
- var v = [
12
- "recurrenceStartDate",
13
- "recurrenceEndDate",
14
- "recurrenceIssueMode",
15
- "recurrenceDayOfWeek",
16
- "recurrenceEndMode",
17
- "recurrenceMaxOccurrences"
18
- ], y = [
19
- "recurrenceSubject",
20
- "recurrenceBody",
21
- "recurrenceRecipientsTo",
22
- "recurrenceRecipientsCc",
23
- "recurrenceRecipientsBcc"
24
- ];
25
- function b({ values: b, errors: x, lockSchedule: S, messages: C, onChange: w, onClearErrors: T, onRevalidateErrors: E }) {
26
- let D = t(b.customerId || void 0), O = D.data ? e(D.data).trim() : "", [k, A] = _(!1), [j, M] = _(b), [N, P] = _(null), F = h(() => N ?? o(j, O), [
27
- O,
28
- N,
29
- j
30
- ]), I = g(O);
31
- m(() => {
32
- let e = I.current;
33
- I.current = O, e && e !== O && w(a);
34
- }, [O, w]);
35
- let L = p((e) => {
36
- M(e), P(null), A(!0);
37
- }, []);
8
+ var u = {
9
+ draft: {
10
+ primary: ["edit", "issue"],
11
+ overflow: ["clone", "delete"]
12
+ },
13
+ issued: {
14
+ primary: ["send", "recordPayment"],
15
+ overflow: ["clone", "cancel"]
16
+ },
17
+ overdue: {
18
+ primary: ["send", "recordPayment"],
19
+ overflow: [
20
+ "clone",
21
+ "cancel",
22
+ "markUncollectible"
23
+ ]
24
+ },
25
+ partially_paid: {
26
+ primary: ["send", "recordPayment"],
27
+ overflow: ["clone"]
28
+ },
29
+ paid: {
30
+ primary: [],
31
+ overflow: ["clone"]
32
+ },
33
+ canceled: {
34
+ primary: [],
35
+ overflow: ["clone"]
36
+ },
37
+ uncollectible: {
38
+ primary: [],
39
+ overflow: ["clone"]
40
+ },
41
+ recurring: {
42
+ primary: [],
43
+ overflow: []
44
+ }
45
+ }, d = {
46
+ draft: "neutral",
47
+ issuing: "info",
48
+ issued: "info",
49
+ partially_paid: "info",
50
+ accepted: "success",
51
+ paid: "success",
52
+ failed: "danger",
53
+ expired: "danger",
54
+ declined: "danger",
55
+ overdue: "danger",
56
+ canceled: "neutral",
57
+ uncollectible: "neutral",
58
+ recurring: "neutral",
59
+ deleted: "neutral"
60
+ };
61
+ function f(e, t = /* @__PURE__ */ new Date()) {
62
+ if (!e) return 0;
63
+ let n = new Date(e);
64
+ if (Number.isNaN(n.getTime())) return 0;
65
+ let r = Date.UTC(t.getUTCFullYear(), t.getUTCMonth(), t.getUTCDate()), i = Date.UTC(n.getUTCFullYear(), n.getUTCMonth(), n.getUTCDate()), a = Math.floor((r - i) / 864e5);
66
+ return a > 0 ? a : 0;
67
+ }
68
+ function p(e, t) {
69
+ let n = e.map((e) => `${e} ${e === 1 ? t.reminderUnitDay : t.reminderUnitDays}`);
70
+ if (n.length <= 1) return n[0] ?? "";
71
+ let r = t.reminderNameAnd;
72
+ return n.length === 2 ? `${n[0]} ${r} ${n[1]}` : `${n.slice(0, -1).join(", ")}, ${r} ${n[n.length - 1]}`;
73
+ }
74
+ function m({ paymentReminder: e, overdueReminder: t, remindersConfigured: n, messages: r }) {
75
+ let i = [
76
+ e?.term_1_reminder?.days_before,
77
+ e?.term_2_reminder?.days_before,
78
+ e?.term_final_reminder?.days_before
79
+ ].filter((e) => typeof e == "number"), a = (t?.terms ?? []).map((e) => e.days_after).filter((e) => typeof e == "number"), o = [];
80
+ return i.length > 0 && o.push(`${p(i, r)} ${r.detailsRemindersBefore}`), a.length > 0 && o.push(`${p(a, r)} ${r.detailsRemindersAfter}`), o.length > 0 ? o.join("\n") : n ? "-" : r.detailsRemindersNone;
81
+ }
82
+ function h(e) {
83
+ if (!e?.line1) return;
84
+ let t = [e.city, [e.state, e.postal_code].filter(Boolean).join(" ")].filter(Boolean).join(", ");
85
+ return [
86
+ e.line2 ? `${e.line1} ${e.line2}` : e.line1,
87
+ t,
88
+ e.country ? c(e.country) : void 0
89
+ ].filter(Boolean).join(", ");
90
+ }
91
+ function g(e, t, n) {
92
+ let r = {
93
+ label: n.detailsAmountReceived,
94
+ value: t(e.amount_paid)
95
+ };
96
+ switch (e.status) {
97
+ case "issued":
98
+ case "overdue": return {
99
+ amountTone: e.status === "overdue" ? "danger" : "default",
100
+ amountRows: [{
101
+ label: n.detailsBalanceDue,
102
+ value: t(e.amount_due),
103
+ emphasis: !0
104
+ }, ...e.amount_paid > 0 ? [{
105
+ ...r,
106
+ tone: "success"
107
+ }] : []]
108
+ };
109
+ case "partially_paid": return {
110
+ amountTone: "default",
111
+ amountRows: [{
112
+ label: n.detailsBalanceDue,
113
+ value: t(e.amount_due),
114
+ emphasis: !0
115
+ }, {
116
+ ...r,
117
+ tone: "success"
118
+ }]
119
+ };
120
+ case "paid": return {
121
+ amountTone: "success",
122
+ amountRows: [{
123
+ ...r,
124
+ emphasis: !0
125
+ }]
126
+ };
127
+ case "canceled": return {
128
+ amountTone: "muted",
129
+ amountRows: [{
130
+ label: n.detailsCancelledAmount,
131
+ value: t(e.total_amount),
132
+ emphasis: !0
133
+ }]
134
+ };
135
+ case "uncollectible": return {
136
+ amountTone: "muted",
137
+ amountRows: [{
138
+ label: n.detailsAmountWrittenOff,
139
+ value: t(e.amount_due),
140
+ emphasis: !0
141
+ }]
142
+ };
143
+ default: return {
144
+ amountTone: "default",
145
+ amountRows: [{
146
+ label: n.detailsInvoiceAmount,
147
+ value: t(e.total_amount),
148
+ emphasis: !0
149
+ }]
150
+ };
151
+ }
152
+ }
153
+ function _(t, i, a) {
154
+ let o = t.line_items.reduce((t, n) => {
155
+ let r = n.total_before_tax ?? 0;
156
+ return e(n.tax_status) ? {
157
+ ...t,
158
+ taxableItemsSubtotal: t.taxableItemsSubtotal + r
159
+ } : {
160
+ ...t,
161
+ nonTaxableItemsSubtotal: t.nonTaxableItemsSubtotal + r
162
+ };
163
+ }, {
164
+ taxableItemsSubtotal: 0,
165
+ nonTaxableItemsSubtotal: 0
166
+ }), s = r({
167
+ discount: t.discount,
168
+ subtotal: o.taxableItemsSubtotal + o.nonTaxableItemsSubtotal
169
+ }), { taxableSubtotal: c, nonTaxableSubtotal: u } = n({
170
+ ...o,
171
+ discountAmount: s
172
+ }), d = s > 0, f = o.taxableItemsSubtotal > 0, p = o.nonTaxableItemsSubtotal > 0, m = [{
173
+ label: a.previewSubtotal,
174
+ value: i(t.subtotal)
175
+ }];
176
+ d && m.push({
177
+ label: a.previewDiscount,
178
+ value: l(s, t.currency)
179
+ }), p && (f || d) && m.push({
180
+ label: a.previewNonTaxableSubtotal,
181
+ value: i(u),
182
+ tone: "muted"
183
+ }), f && (p || d) && m.push({
184
+ label: a.previewTaxableSubtotal,
185
+ value: i(c),
186
+ tone: "muted"
187
+ });
188
+ for (let e of t.total_tax_amounts ?? []) m.push({
189
+ label: a.previewTaxWithRate.replace("{rate}", String((e.value ?? 0) / 100)),
190
+ value: i(e.amount)
191
+ });
192
+ return m.push({
193
+ label: a.previewTotal,
194
+ value: i(t.total_amount),
195
+ emphasis: !0
196
+ }), m;
197
+ }
198
+ function v({ receivable: e, pdfUrl: n, paymentReminder: r, overdueReminder: c, depositAccount: l, isAccountListIncomplete: p, statusLabels: v, messages: y, now: b }) {
199
+ if (!e || e.type !== "invoice") return;
200
+ let x = e, S = (e) => o({
201
+ amount: e ?? 0,
202
+ currency: x.currency,
203
+ fallback: ""
204
+ }), C = (e) => a(e, "-"), w = (e) => e ? C(e) : y.detailsPending, { status: T } = x, E = T === "canceled", D = T === "overdue" ? f(x.due_date, b) : 0, { amountTone: O, amountRows: k } = g(x, S, y), A = x.counterpart_contact, j = h(x.counterpart_billing_address), M = [
205
+ ...x.counterpart_name ? [{
206
+ label: y.detailsCustomerName,
207
+ value: x.counterpart_name
208
+ }] : [],
209
+ ...A?.email ? [{
210
+ label: y.detailsCustomerEmail,
211
+ value: A.email
212
+ }] : [],
213
+ ...A?.phone ? [{
214
+ label: y.detailsCustomerPhone,
215
+ value: A.phone
216
+ }] : [],
217
+ ...j ? [{
218
+ label: y.detailsCustomerAddress,
219
+ value: j
220
+ }] : []
221
+ ], N = [
222
+ ...x.document_id ? [{
223
+ label: y.detailsInvoiceNumber,
224
+ value: x.document_id
225
+ }] : [],
226
+ {
227
+ label: y.detailsInvoiceAmount,
228
+ value: S(x.total_amount)
229
+ },
230
+ {
231
+ label: y.detailsInvoiceDate,
232
+ value: w(x.issue_date)
233
+ },
234
+ {
235
+ label: y.detailsDueDate,
236
+ value: w(x.due_date)
237
+ },
238
+ {
239
+ label: y.detailsPaymentTerms,
240
+ value: x.payment_terms?.name ?? y.detailsPending
241
+ },
242
+ {
243
+ label: y.detailsPaymentReminders,
244
+ value: m({
245
+ paymentReminder: r,
246
+ overdueReminder: c,
247
+ remindersConfigured: !!(x.payment_reminder_id || x.overdue_reminder_id),
248
+ messages: y
249
+ })
250
+ },
251
+ ...x.purchase_order ? [{
252
+ label: y.detailsPoNumber,
253
+ value: x.purchase_order
254
+ }] : [],
255
+ {
256
+ label: y.detailsDepositAccount,
257
+ value: l ? s(l, y) : p && x.bank_account_id ? "-" : y.detailsNotProvided
258
+ }
259
+ ], P = i(x), F = u[T] ?? {
260
+ primary: [],
261
+ overflow: ["clone"]
262
+ };
38
263
  return {
39
- view: h(() => i({
40
- fields: b,
41
- errors: x,
42
- lockSchedule: S,
43
- messages: C
44
- }), [
45
- x,
46
- S,
47
- C,
48
- b
49
- ]),
50
- emailView: h(() => r({
51
- open: k,
52
- ready: !D.isLoading,
53
- draft: F,
54
- messages: C
55
- }), [
56
- D.isLoading,
57
- F,
58
- k,
59
- C
60
- ]),
61
- changeFrequency: p((e) => {
62
- T(v), w((t) => u(t, e));
63
- }, [w, T]),
64
- changeMonthDay: p((e) => {
65
- E(["recurrenceIssueMode"]), w((t) => d(t, e, { lockSchedule: S }));
66
- }, [
67
- S,
68
- w,
69
- E
70
- ]),
71
- changeWeekday: p((e) => {
72
- S || (T(["recurrenceStartDate"]), E(["recurrenceDayOfWeek"]), w((t) => c(t, e, { lockSchedule: S })));
73
- }, [
74
- S,
75
- w,
76
- T,
77
- E
78
- ]),
79
- changeStartDate: p((e) => {
80
- E(["recurrenceStartDate"]), w((t) => s(t, "recurrenceStartDate", e));
81
- }, [w, E]),
82
- changeEndDate: p((e) => {
83
- E(["recurrenceEndDate"]), w((t) => s(t, "recurrenceEndDate", e));
84
- }, [w, E]),
85
- changeEndMode: p((e) => {
86
- E(["recurrenceEndMode"]), w((t) => l(t, e));
87
- }, [w, E]),
88
- changeMaxOccurrences: p((e) => {
89
- E(["recurrenceMaxOccurrences"]), w((t) => ({
90
- ...t,
91
- recurrenceMaxOccurrences: e
92
- }));
93
- }, [w, E]),
94
- changeCreationMode: p((e) => {
95
- let t = {
96
- ...b,
97
- recurrenceAutomationLevel: e
98
- };
99
- w((t) => ({
100
- ...t,
101
- recurrenceAutomationLevel: e
102
- })), f(t, e) && L(t);
103
- }, [
104
- w,
105
- L,
106
- b
107
- ]),
108
- setUpEmail: p(() => L(b), [L, b]),
109
- changeEmailOpen: A,
110
- changeEmail: p((e, t) => P((n) => ({
111
- ...n ?? F,
112
- [e]: t
113
- })), [F]),
114
- saveEmail: p(() => {
115
- w((e) => n(e, F)), T(y), A(!1);
116
- }, [
117
- F,
118
- w,
119
- T
120
- ]),
121
- reset: p(() => {
122
- A(!1), I.current = "";
123
- }, [])
264
+ id: x.id,
265
+ type: x.type,
266
+ title: x.counterpart_name ?? y.invoiceType,
267
+ status: T,
268
+ statusTone: d[T] ?? "neutral",
269
+ pdfUrl: n || x.file_url || x.original_file_url || void 0,
270
+ lineItems: x.line_items.map((e, t) => ({
271
+ id: `${e.product.id ?? "item"}-${t}`,
272
+ name: e.product.name,
273
+ quantityLabel: String(e.quantity),
274
+ unitPriceLabel: S(e.product.price?.value),
275
+ totalLabel: S(e.total_before_tax ?? (e.product.price?.value ?? 0) * e.quantity)
276
+ })),
277
+ panel: {
278
+ subtitle: x.document_id ? y.detailsInvoiceSubtitle.replace("{number}", x.document_id) : void 0,
279
+ statusLabel: T === "partially_paid" ? v.issued : v[T] ?? v.unknown,
280
+ recurring: !!x.recurrence_id || T === "recurring",
281
+ overdueLabel: D > 0 ? y.detailsDaysOverdue.replace("{days}", String(D)) : void 0,
282
+ amountTone: O,
283
+ amountRows: k,
284
+ issueDateLabel: w(x.issue_date),
285
+ dueDateLabel: E ? C(x.updated_at) : w(x.due_date),
286
+ dueDateCaption: E ? y.detailsCancelledOnCaption : y.detailsDueDate,
287
+ customerContact: M,
288
+ billingItems: N,
289
+ lineItemsCountLabel: String(x.line_items.length),
290
+ lineItemTotals: _(x, S, y),
291
+ notes: P && {
292
+ ...P,
293
+ countLabel: String([P.opening, P.closing].filter(Boolean).length)
294
+ },
295
+ attachments: t(x, y),
296
+ primaryActions: F.primary,
297
+ overflowActions: F.overflow
298
+ }
299
+ };
300
+ }
301
+ function y(e, t) {
302
+ if (e && e.type !== "invoice") return {
303
+ title: t.detailsUnsupportedTitle,
304
+ description: t.detailsUnsupportedDescription.replace("{type}", e.type)
124
305
  };
125
306
  }
126
307
  //#endregion
127
- export { b as useReceivableRecurrence };
308
+ export { v as buildReceivableDetailsView, y as buildUnsupportedDetailsView, m as formatReminderSchedule, f as getDaysOverdue };
@@ -1,63 +1,48 @@
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";
1
+ "use client";
2
+ "use client";
3
+ "use client";
4
+ "use client";
5
+ import { useWidgetConfig as e } from "../../../shared/feature/dist/lib/WidgetProvider/hooks.js";
6
+ import "../../../shared/feature/dist/index.js";
7
+ import { usePaymentAccountsQuery as t } from "../../data-access/dist/index3.js";
8
+ import { useReceivablePdfLinkQuery as n, useReceivableQuery as r } from "../../data-access/dist/index10.js";
9
+ import { useOverdueRemindersQuery as i, usePaymentRemindersQuery as a } from "../../data-access/dist/index11.js";
10
+ import "../../data-access/dist/index.js";
11
+ import { getBankAccountPermissions as o } from "./index19.js";
12
+ import { buildReceivableDetailsView as s, buildUnsupportedDetailsView as c } from "./index21.js";
13
+ import { useMemo as l } from "react";
4
14
  //#region ../../libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index22.js
5
- var n = {
6
- routingNumber: "",
7
- accountNumber: "",
8
- accountHolderName: "",
9
- displayName: ""
10
- };
11
- function r(n) {
12
- let r = new Set(n ?? []);
15
+ function u({ selectedReceivableId: u, enabled: d = !0, messages: f, statusLabels: p }) {
16
+ let { initResponse: m } = e(), h = l(() => o(m?.scopes), [m?.scopes]), g = r(u, { enabled: d }), _ = g.data, v = _?.type === "invoice" ? _ : void 0, y = n(u, { enabled: d && !!_ }), b = a({ enabled: d && !!v?.payment_reminder_id }), x = i({ enabled: d && !!v?.overdue_reminder_id }), S = t({
17
+ enabled: d && !!v,
18
+ canReadEmbedded: h.canReadEmbedded,
19
+ canReadExternal: h.canReadExternal
20
+ }), C = b.data?.data.find((e) => e.id === v?.payment_reminder_id), w = x.data?.data.find((e) => e.id === v?.overdue_reminder_id), T = S.paymentAccounts.find((e) => e.id === v?.bank_account_id), E = y.data?.file_url || y.data?.original_file_url || void 0;
13
21
  return {
14
- canReadEmbedded: e(r, [t.BankAccountReadOrg]),
15
- canReadExternal: e(r, [t.ExternalBankAccountReadOrg]),
16
- canAddAccount: e(r, [t.BankAccountWriteOrg])
17
- };
18
- }
19
- function i(e, t) {
20
- return [e.displayName || t.bankAccountFallbackName, e.accountNumberLast4].filter(Boolean).join(" - ");
21
- }
22
- function a(e, t, n) {
23
- switch (e) {
24
- case "INTERNAL": return t ? n.bankAccountPoweredBy.replace("{embeddedBankName}", t) : void 0;
25
- case "EXTERNAL": return n.bankAccountLinked;
26
- default: return;
27
- }
28
- }
29
- function o({ accounts: e, embeddedBankName: t, messages: n }) {
30
- return e.map((e) => ({
31
- value: e.id,
32
- label: i(e, n),
33
- sourceLabel: a(e.type, t, n)
34
- })).sort((e, t) => e.label.localeCompare(t.label));
35
- }
36
- function s({ options: e, isLoading: t, selectedId: n, isAddingAccount: r, canAddAccount: i, formValues: a, formErrors: o, isSaving: s }) {
37
- return t ? { kind: "loading" } : e.length > 0 && !r ? {
38
- kind: "picker",
39
- options: e,
40
- selected: e.find((e) => e.value === n),
41
- canAddAccount: i
42
- } : i ? {
43
- kind: "form",
44
- values: a,
45
- errors: o,
46
- canCancel: e.length > 0,
47
- isSaving: s
48
- } : { kind: "restricted" };
49
- }
50
- function c(e, t) {
51
- let n = {}, r = e.accountHolderName.trim(), i = e.accountNumber.trim(), a = e.routingNumber.trim();
52
- return r ? r.length > 255 && (n.accountHolderName = t.bankAccountHolderNameTooLong) : n.accountHolderName = t.bankAccountHolderNameRequired, i ? /^\d+$/.test(i) ? i.length < 4 ? n.accountNumber = t.bankAccountNumberTooShort : i.length > 17 && (n.accountNumber = t.bankAccountNumberTooLong) : n.accountNumber = t.bankAccountNumberDigitsOnly : n.accountNumber = t.bankAccountNumberRequired, a ? /^\d{9}$/.test(a) || (n.routingNumber = t.bankAccountRoutingNumberInvalid) : n.routingNumber = t.bankAccountRoutingNumberRequired, e.displayName.length > 200 && (n.displayName = t.bankAccountNicknameTooLong), n;
53
- }
54
- function l(e) {
55
- return {
56
- display_name: e.displayName || void 0,
57
- account_holder_name: e.accountHolderName.trim() || void 0,
58
- account_number: e.accountNumber.trim() || void 0,
59
- routing_number: e.routingNumber.trim() || void 0
22
+ receivable: _,
23
+ detailsView: l(() => s({
24
+ receivable: _,
25
+ pdfUrl: E,
26
+ paymentReminder: C,
27
+ overdueReminder: w,
28
+ depositAccount: T,
29
+ isAccountListIncomplete: S.isIncomplete,
30
+ statusLabels: p,
31
+ messages: f
32
+ }), [
33
+ _,
34
+ E,
35
+ C,
36
+ w,
37
+ T,
38
+ S.isIncomplete,
39
+ p,
40
+ f
41
+ ]),
42
+ unsupportedView: l(() => c(_, f), [_, f]),
43
+ isLoading: g.isLoading || y.isLoading,
44
+ isError: g.isError
60
45
  };
61
46
  }
62
47
  //#endregion
63
- export { n as EMPTY_BANK_ACCOUNT_FORM_VALUES, l as bankAccountFormToPayload, s as buildBankAccountSectionView, o as buildPaymentAccountOptions, r as getBankAccountPermissions, i as getPaymentAccountLineLabel, a as getPaymentAccountSourceLabel, c as validateBankAccountForm };
48
+ export { u as useReceivableDetails };