@tesouro/embedded-components-react 0.5.110 → 0.5.111

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.
@@ -7,10 +7,10 @@ import { isLineItemTaxable as i } from "./index162.js";
7
7
  import { getTotalsRowVisibility as a } from "./index163.js";
8
8
  import { getDaysOverdue as ee } from "./index164.js";
9
9
  import { formatReminderSchedule as te } from "./index165.js";
10
- import { rateMinorToMajor as o } from "./index161.js";
11
- import { parseISO as s } from "date-fns";
10
+ import { rateMinorToMajor as ne } from "./index161.js";
11
+ import { parseISO as o } from "date-fns";
12
12
  //#region ../../libs/tesouro-embedded-components-react/monite-sdk/dist/index166.js
13
- var c = /^\d{4}-\d{2}-\d{2}$/, l = (e, t) => {
13
+ var s = /^\d{4}-\d{2}-\d{2}$/, c = (e, t) => {
14
14
  switch (t) {
15
15
  case "draft": return e._("Draft");
16
16
  case "issuing": return e._("Issuing");
@@ -27,7 +27,7 @@ var c = /^\d{4}-\d{2}-\d{2}$/, l = (e, t) => {
27
27
  case "deleted": return e._("Deleted");
28
28
  default: return e._("Unknown");
29
29
  }
30
- }, u = (e, t) => {
30
+ }, l = (e, t) => {
31
31
  switch (t) {
32
32
  case "day": return e._("Daily");
33
33
  case "week": return e._("Weekly");
@@ -36,7 +36,7 @@ var c = /^\d{4}-\d{2}-\d{2}$/, l = (e, t) => {
36
36
  case "year": return e._("Yearly");
37
37
  default: return "";
38
38
  }
39
- }, d = (e, t) => {
39
+ }, u = (e, t) => {
40
40
  switch (t) {
41
41
  case "day": return e._("each day");
42
42
  case "week": return e._("each week");
@@ -45,13 +45,13 @@ var c = /^\d{4}-\d{2}-\d{2}$/, l = (e, t) => {
45
45
  case "year": return e._("each year");
46
46
  default: return "";
47
47
  }
48
- }, f = [
48
+ }, d = [
49
49
  "issued",
50
50
  "overdue",
51
51
  "partially_paid",
52
52
  "paid",
53
53
  "uncollectible"
54
- ], p = {
54
+ ], f = {
55
55
  draft: {
56
56
  primary: [
57
57
  "edit",
@@ -93,147 +93,147 @@ var c = /^\d{4}-\d{2}-\d{2}$/, l = (e, t) => {
93
93
  overflow: []
94
94
  }
95
95
  };
96
- function m(m, h, ne, { i18n: g, formatCurrencyToDisplay: _, locale: v }, y = !1, b = {}, x) {
97
- let S = m.currency, C = (e) => _(e ?? 0, S) ?? "", w = (e) => _(e, S, !0, !0) ?? "", T = (e) => e ? g.date(c.test(e) ? s(e) : e, v.dateFormat) : "-", E = m.status, D = E === "canceled", O = E === "overdue", k = m.tax_mode === "inclusive", re = !!m.recurrence_id || E === "recurring", A = E === "recurring" && !!h, ie = !!m.recurrence_id && E !== "recurring", j = O ? ee(m.due_date) : 0, M = "default", N = [];
96
+ function p(p, m, re, { i18n: h, formatCurrencyToDisplay: g, locale: _ }, v = !1, y = {}, b) {
97
+ let x = p.currency, S = (e) => g(e ?? 0, x) ?? "", C = (e) => g(e, x, !0, !0) ?? "", w = (e) => e ? h.date(s.test(e) ? o(e) : e, _.dateFormat) : "-", T = (e) => e ? w(e) : h._("Pending"), E = p.status, D = E === "canceled", O = E === "overdue", k = p.tax_mode === "inclusive", ie = !!p.recurrence_id || E === "recurring", A = E === "recurring" && !!m, ae = !!p.recurrence_id && E !== "recurring", j = O ? ee(p.due_date) : 0, M = "default", N = [];
98
98
  switch (E) {
99
99
  case "draft":
100
100
  case "recurring":
101
101
  N.push({
102
- label: g._("Invoice amount"),
103
- value: C(m.total_amount),
102
+ label: h._("Invoice amount"),
103
+ value: S(p.total_amount),
104
104
  emphasis: !0
105
105
  });
106
106
  break;
107
107
  case "issued":
108
108
  case "overdue":
109
109
  M = O ? "danger" : "default", N.push({
110
- label: g._("Balance due"),
111
- value: C(m.amount_due),
110
+ label: h._("Balance due"),
111
+ value: S(p.amount_due),
112
112
  emphasis: !0
113
- }), (m.amount_paid ?? 0) > 0 && N.push({
114
- label: g._("Amount received"),
115
- value: C(m.amount_paid),
113
+ }), (p.amount_paid ?? 0) > 0 && N.push({
114
+ label: h._("Amount received"),
115
+ value: S(p.amount_paid),
116
116
  tone: "success"
117
117
  });
118
118
  break;
119
119
  case "partially_paid":
120
120
  N.push({
121
- label: g._("Balance due"),
122
- value: C(m.amount_due),
121
+ label: h._("Balance due"),
122
+ value: S(p.amount_due),
123
123
  emphasis: !0
124
124
  }, {
125
- label: g._("Amount received"),
126
- value: C(m.amount_paid),
125
+ label: h._("Amount received"),
126
+ value: S(p.amount_paid),
127
127
  tone: "success"
128
128
  });
129
129
  break;
130
130
  case "paid":
131
131
  M = "success", N.push({
132
- label: g._("Amount received"),
133
- value: C(m.amount_paid),
132
+ label: h._("Amount received"),
133
+ value: S(p.amount_paid),
134
134
  emphasis: !0
135
135
  });
136
136
  break;
137
137
  case "canceled":
138
138
  M = "muted", N.push({
139
- label: g._("Cancelled amount"),
140
- value: C(m.total_amount),
139
+ label: h._("Cancelled amount"),
140
+ value: S(p.total_amount),
141
141
  emphasis: !0
142
142
  });
143
143
  break;
144
144
  case "uncollectible":
145
145
  M = "muted", N.push({
146
- label: g._("Amount written off"),
147
- value: C(m.amount_due),
146
+ label: h._("Amount written off"),
147
+ value: S(p.amount_due),
148
148
  emphasis: !0
149
149
  });
150
150
  break;
151
151
  default: N.push({
152
- label: g._("Invoice amount"),
153
- value: C(m.total_amount),
152
+ label: h._("Invoice amount"),
153
+ value: S(p.total_amount),
154
154
  emphasis: !0
155
155
  });
156
156
  }
157
- let P = m.counterpart_contact, F = m.counterpart_billing_address, I = F?.country ? e(g)[F.country] : void 0, L = [F?.city, [F?.state, F?.postal_code].filter(Boolean).join(" ")].filter(Boolean).join(", "), R = F?.line1 ? [
157
+ let P = p.counterpart_contact, F = p.counterpart_billing_address, I = F?.country ? e(h)[F.country] : void 0, L = [F?.city, [F?.state, F?.postal_code].filter(Boolean).join(" ")].filter(Boolean).join(", "), R = F?.line1 ? [
158
158
  `${F.line1}${F.line2 ? ` ${F.line2}` : ""}`,
159
159
  L,
160
160
  I
161
161
  ].filter(Boolean).join(", ") : void 0, z = [];
162
162
  P?.email && z.push({
163
- label: g._("Email"),
163
+ label: h._("Email"),
164
164
  value: P.email
165
165
  }), P?.phone && z.push({
166
- label: g._("Phone"),
166
+ label: h._("Phone"),
167
167
  value: P.phone
168
168
  }), R && z.push({
169
- label: g._("Address"),
169
+ label: h._("Address"),
170
170
  value: R
171
171
  });
172
- let B = !!(m.payment_reminder_id || m.overdue_reminder_id), V = te(b.paymentReminder, b.overdueReminder, g, B), H = x?.account, U = x ? [{
173
- label: g._("Deposit account"),
174
- value: H ? r(H, g) : x.isListIncomplete && m.bank_account_id ? "-" : g._("Not provided")
172
+ let B = !!(p.payment_reminder_id || p.overdue_reminder_id), V = te(y.paymentReminder, y.overdueReminder, h, B), H = b?.account, U = b ? [{
173
+ label: h._("Deposit account"),
174
+ value: H ? r(H, h) : b.isListIncomplete && p.bank_account_id ? "-" : h._("Not provided")
175
175
  }] : [], W = A ? [
176
176
  {
177
- label: g._("Frequency"),
178
- value: h ? u(g, h.frequency) : "-"
177
+ label: h._("Frequency"),
178
+ value: m ? l(h, m.frequency) : "-"
179
179
  },
180
180
  {
181
- label: g._("Invoice amount"),
182
- value: C(m.total_amount)
181
+ label: h._("Invoice amount"),
182
+ value: S(p.total_amount)
183
183
  },
184
184
  {
185
- label: g._("Payment terms"),
186
- value: m.payment_terms?.name ?? "-"
185
+ label: h._("Payment terms"),
186
+ value: p.payment_terms?.name ?? h._("Pending")
187
187
  },
188
188
  {
189
- label: g._("Payment reminders"),
189
+ label: h._("Payment reminders"),
190
190
  value: V
191
191
  },
192
192
  {
193
- label: g._("PO number"),
194
- value: m.purchase_order || g._("Not provided")
193
+ label: h._("PO number"),
194
+ value: p.purchase_order || h._("Not provided")
195
195
  },
196
196
  ...U
197
197
  ] : [
198
- ...m.document_id ? [{
199
- label: g._("Invoice number"),
200
- value: m.document_id
198
+ ...p.document_id ? [{
199
+ label: h._("Invoice number"),
200
+ value: p.document_id
201
201
  }] : [],
202
202
  {
203
- label: g._("Invoice amount"),
204
- value: C(m.total_amount)
203
+ label: h._("Invoice amount"),
204
+ value: S(p.total_amount)
205
205
  },
206
206
  {
207
- label: g._("Invoice date"),
208
- value: T(m.issue_date ?? m.created_at)
207
+ label: h._("Invoice date"),
208
+ value: T(p.issue_date)
209
209
  },
210
210
  {
211
- label: g._("Due date"),
212
- value: T(m.due_date)
211
+ label: h._("Due date"),
212
+ value: T(p.due_date)
213
213
  },
214
214
  {
215
- label: g._("Payment terms"),
216
- value: m.payment_terms?.name ?? "-"
215
+ label: h._("Payment terms"),
216
+ value: p.payment_terms?.name ?? h._("Pending")
217
217
  },
218
218
  {
219
- label: g._("Payment reminders"),
219
+ label: h._("Payment reminders"),
220
220
  value: V
221
221
  },
222
- ...m.purchase_order ? [{
223
- label: g._("PO number"),
224
- value: m.purchase_order
222
+ ...p.purchase_order ? [{
223
+ label: h._("PO number"),
224
+ value: p.purchase_order
225
225
  }] : [],
226
226
  ...U
227
- ], G = (m.line_items ?? []).map((e, t) => {
227
+ ], G = (p.line_items ?? []).map((e, t) => {
228
228
  let n = k ? e?.product?.price_after_tax?.value : e?.product?.price?.value, r = k ? e?.total_after_tax : e?.total_before_tax ?? (e?.product?.price?.value ?? 0) * (e?.quantity ?? 0);
229
229
  return {
230
230
  id: `${e?.product?.id ?? "item"}-${t}`,
231
231
  name: e?.product?.name ?? "",
232
232
  quantityLabel: String(e?.quantity ?? 0),
233
- unitPriceLabel: C(n),
234
- totalLabel: C(r)
233
+ unitPriceLabel: S(n),
234
+ totalLabel: S(r)
235
235
  };
236
- }), K = (m.line_items ?? []).reduce((e, t) => {
236
+ }), K = (p.line_items ?? []).reduce((e, t) => {
237
237
  let n = t?.total_before_tax ?? 0, r = i(t?.tax_status);
238
238
  return {
239
239
  taxableItemsSubtotal: e.taxableItemsSubtotal + (r ? n : 0),
@@ -243,69 +243,69 @@ function m(m, h, ne, { i18n: g, formatCurrencyToDisplay: _, locale: v }, y = !1,
243
243
  taxableItemsSubtotal: 0,
244
244
  nonTaxableItemsSubtotal: 0
245
245
  }), q = n({
246
- discount: m.discount,
246
+ discount: p.discount,
247
247
  subtotal: K.taxableItemsSubtotal + K.nonTaxableItemsSubtotal
248
248
  }), J = a({
249
249
  ...K,
250
250
  discountAmount: q
251
- }), ae = J.showDiscounts ? [{
252
- label: g._("Discount"),
253
- value: w(-q)
254
- }] : [], { taxableSubtotal: oe, nonTaxableSubtotal: se } = t({
251
+ }), oe = J.showDiscounts ? [{
252
+ label: h._("Discount"),
253
+ value: C(-q)
254
+ }] : [], { taxableSubtotal: se, nonTaxableSubtotal: ce } = t({
255
255
  ...K,
256
256
  discountAmount: q
257
- }), ce = [...J.showNonTaxableSubtotal ? [{
258
- label: g._("Non-taxable subtotal"),
259
- value: C(se),
257
+ }), le = [...J.showNonTaxableSubtotal ? [{
258
+ label: h._("Non-taxable subtotal"),
259
+ value: S(ce),
260
260
  tone: "muted"
261
261
  }] : [], ...J.showTaxableSubtotal ? [{
262
- label: g._("Taxable subtotal"),
263
- value: C(oe),
262
+ label: h._("Taxable subtotal"),
263
+ value: S(se),
264
264
  tone: "muted"
265
- }] : []], le = [
265
+ }] : []], ue = [
266
266
  {
267
- label: g._("Subtotal"),
268
- value: C(m.subtotal)
267
+ label: h._("Subtotal"),
268
+ value: S(p.subtotal)
269
269
  },
270
- ...ae,
271
- ...ce,
272
- ...(m.total_tax_amounts ?? []).map((e) => ({
273
- label: g._("Tax ({rate}%)", { rate: o(e?.value ?? 0) }),
274
- value: C(e?.amount)
270
+ ...oe,
271
+ ...le,
272
+ ...(p.total_tax_amounts ?? []).map((e) => ({
273
+ label: h._("Tax ({rate}%)", { rate: ne(e?.value ?? 0) }),
274
+ value: S(e?.amount)
275
275
  })),
276
276
  {
277
- label: g._("Total"),
278
- value: C(m.total_amount),
277
+ label: h._("Total"),
278
+ value: S(p.total_amount),
279
279
  emphasis: !0
280
280
  }
281
- ], ue = f.includes(E) ? {
282
- rows: ne.map((e) => ({
281
+ ], Y = d.includes(E) ? {
282
+ rows: re.map((e) => ({
283
283
  id: e.id,
284
- dateLabel: T(e.paid_at),
285
- amountLabel: C(e.amount)
284
+ dateLabel: w(e.paid_at),
285
+ amountLabel: S(e.amount)
286
286
  })),
287
- totalLabel: C(m.amount_paid),
287
+ totalLabel: S(p.amount_paid),
288
288
  emptyTone: O ? "danger" : "default",
289
- loading: y
290
- } : void 0, Y = A && h ? {
291
- status: h.status,
292
- amountLabel: C(m.total_amount),
293
- amountPeriodLabel: d(g, h.frequency),
294
- startsOnLabel: T(h.start_date),
295
- endsOnLabel: h.end_date ? T(h.end_date) : "-",
296
- scheduleTitle: g._("{frequency} schedule", { frequency: u(g, h.frequency) })
297
- } : void 0, de = ie && h ? {
298
- title: g._("{name} - {frequency}", {
299
- name: m.counterpart_name ?? g._("Invoice"),
300
- frequency: u(g, h.frequency)
289
+ loading: v
290
+ } : void 0, de = A && m ? {
291
+ status: m.status,
292
+ amountLabel: S(p.total_amount),
293
+ amountPeriodLabel: u(h, m.frequency),
294
+ startsOnLabel: T(m.start_date),
295
+ endsOnLabel: m.end_date ? w(m.end_date) : "-",
296
+ scheduleTitle: h._("{frequency} schedule", { frequency: l(h, m.frequency) })
297
+ } : void 0, fe = ae && m ? {
298
+ title: h._("{name} - {frequency}", {
299
+ name: p.counterpart_name ?? h._("Invoice"),
300
+ frequency: l(h, m.frequency)
301
301
  }),
302
- invoiceId: h.invoice_id
303
- } : void 0, X = p[E] ?? {
302
+ invoiceId: m.invoice_id
303
+ } : void 0, X = f[E] ?? {
304
304
  primary: [],
305
305
  overflow: ["clone"]
306
306
  }, Z = X.overflow, Q = X.primary;
307
- if (A && h) {
308
- switch (h.status) {
307
+ if (A && m) {
308
+ switch (m.status) {
309
309
  case "active":
310
310
  Z = ["pauseRecurrence", "cancelRecurrence"];
311
311
  break;
@@ -314,38 +314,38 @@ function m(m, h, ne, { i18n: g, formatCurrencyToDisplay: _, locale: v }, y = !1,
314
314
  break;
315
315
  default: Z = [];
316
316
  }
317
- (h.status === "active" || h.status === "paused") && (Q = ["edit"]);
317
+ (m.status === "active" || m.status === "paused") && (Q = ["edit"]);
318
318
  }
319
- let $ = m.counterpart_name ?? g._("Invoice");
319
+ let $ = p.counterpart_name ?? h._("Invoice");
320
320
  return {
321
- title: A && h ? g._("{name} - {frequency}", {
321
+ title: A && m ? h._("{name} - {frequency}", {
322
322
  name: $,
323
- frequency: u(g, h.frequency)
323
+ frequency: l(h, m.frequency)
324
324
  }) : $,
325
325
  status: E,
326
- statusLabel: l(g, E),
327
- subtitle: A ? g._("Recurring series") : m.document_id ? g._("Invoice: {number}", { number: m.document_id }) : void 0,
328
- recurring: re,
329
- overdueLabel: O && j > 0 ? g._("{days} days overdue", { days: j }) : void 0,
326
+ statusLabel: c(h, E),
327
+ subtitle: A ? h._("Recurring series") : p.document_id ? h._("Invoice: {number}", { number: p.document_id }) : void 0,
328
+ recurring: ie,
329
+ overdueLabel: O && j > 0 ? h._("{days} days overdue", { days: j }) : void 0,
330
330
  amountTone: M,
331
331
  amountRows: N,
332
- invoiceDateLabel: T(m.issue_date ?? m.created_at),
333
- dueDateLabel: T(D ? m.updated_at : m.due_date),
334
- dueDateCaption: D ? g._("Cancelled on") : g._("Due date"),
335
- paymentHistory: ue,
332
+ invoiceDateLabel: T(p.issue_date),
333
+ dueDateLabel: D ? w(p.updated_at) : T(p.due_date),
334
+ dueDateCaption: D ? h._("Cancelled on") : h._("Due date"),
335
+ paymentHistory: Y,
336
336
  customerContact: z,
337
- recurringSeries: Y,
338
- seriesLink: de,
337
+ recurringSeries: de,
338
+ seriesLink: fe,
339
339
  billingItems: W,
340
340
  lineItems: G,
341
- lineItemTotals: le,
342
- notes: m.memo || m.footer ? {
343
- opening: m.memo || void 0,
344
- closing: m.footer || void 0
341
+ lineItemTotals: ue,
342
+ notes: p.memo || p.footer ? {
343
+ opening: p.memo || void 0,
344
+ closing: p.footer || void 0
345
345
  } : void 0,
346
346
  primaryActions: Q,
347
347
  overflowActions: Z
348
348
  };
349
349
  }
350
350
  //#endregion
351
- export { m as buildInvoiceDetailsView };
351
+ export { p as buildInvoiceDetailsView };