@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,51 +1,237 @@
1
- "use client";
2
- "use client";
3
- "use client";
4
- "use client";
5
- import { usePaymentTermsQuery as e } from "../../../shared/data-access/dist/lib/reference-data/usePaymentTermsQuery.js";
6
- import { buildCustomDateCalendar as t, buildPaymentTermsView as n, closeCustomDatePickerFields as r, resolveIssueDate as i, selectPaymentTermsFields as a, toCustomDateValue as o } from "./index9.js";
7
- import "../../data-access/dist/index.js";
8
- import { useCallback as s, useMemo as c, useState as l } from "react";
1
+ import { minorExponentForCurrency as e } from "../../../shared/util/dist/lib/amountOutputToMajorUnits.js";
2
+ import "../../ui/dist/index15.js";
3
+ import "../../ui/dist/index.js";
4
+ import { isBlankLineItem as t, keepsSavedTaxRates as n, lineItemTaxRateMinorUnits as r, parseQuantity as i, priceInputToMinorUnits as a, taxRateToMinorUnits as o } from "./index6.js";
5
+ import { formatTermDate as s, resolveIssueDate as c, termDueDate as l } from "./index10.js";
6
+ import { formatMoney as u } from "./index13.js";
7
+ import { differenceInCalendarDays as d, parseISO as f } from "date-fns";
9
8
  //#region ../../libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index20.js
10
- function u({ paymentTermsId: u, paymentTermsCustomDate: d, issueDate: f, isRecurring: p, messages: m, onChange: h }) {
11
- let g = e(), [_, v] = l(!1);
9
+ var p = "US", m = 100;
10
+ function h(e) {
11
+ try {
12
+ return new Intl.DisplayNames(void 0, { type: "region" }).of(e) ?? e;
13
+ } catch {
14
+ return e;
15
+ }
16
+ }
17
+ function g({ address: e, issuerCountry: t, formatCountry: n = h }) {
18
+ if (!e) return [];
19
+ let r = [e.city, e.state].filter(Boolean).join(", "), i = e.country === p && t === p;
20
+ return [
21
+ [e.line1, e.line2].filter(Boolean).join(" "),
22
+ [r, e.postal_code].filter(Boolean).join(" "),
23
+ e.country && !i ? n(e.country) : ""
24
+ ].filter(Boolean);
25
+ }
26
+ var _ = { kind: "pending" }, v = (e) => ({
27
+ kind: "text",
28
+ lines: e
29
+ });
30
+ function y(e, t) {
31
+ return e.previewNetDays.replace("{days}", String(t));
32
+ }
33
+ function b(e, t) {
34
+ let n = e.previewEarlyPaymentDays.replace("{days}", String(t.number_of_days));
35
+ return t.discount ? `${n}, ${e.previewEarlyPaymentDiscount.replace("{rate}", String(t.discount / m))}` : n;
36
+ }
37
+ function x({ paymentTermsId: e, paymentTermsCustomDate: t, paymentTerms: n, issueDate: r, messages: i }) {
38
+ let a = {
39
+ dueDate: _,
40
+ paymentTerms: _
41
+ };
42
+ if (e === "custom") {
43
+ if (!t) return a;
44
+ let e = f(t), n = Math.max(0, d(e, r));
45
+ return {
46
+ dueDate: v([s(e)]),
47
+ paymentTerms: v([y(i, n)])
48
+ };
49
+ }
50
+ if (e === "receipt_due") return {
51
+ dueDate: v([s(r)]),
52
+ paymentTerms: v([i.previewDueOnReceipt])
53
+ };
54
+ let o = n?.find((t) => t.id === e);
55
+ if (!o) return a;
56
+ let c = l(o, r), u = [
57
+ o.term_1 && b(i, o.term_1),
58
+ o.term_2 && b(i, o.term_2),
59
+ o.term_final && y(i, o.term_final.number_of_days)
60
+ ].filter((e) => !!e);
61
+ return {
62
+ dueDate: c ? v([s(c)]) : _,
63
+ paymentTerms: u.length > 0 ? v(u) : _
64
+ };
65
+ }
66
+ function S(e, t) {
67
+ return t ? e.previewTaxId.replace("{taxId}", t) : void 0;
68
+ }
69
+ function C(e) {
70
+ return e.length > 0 ? e : void 0;
71
+ }
72
+ function w(e, t) {
73
+ return e ? {
74
+ name: e.type === "organization" ? e.organization.legal_name : void 0,
75
+ addressLines: C(g({
76
+ address: e.address,
77
+ issuerCountry: e.address?.country
78
+ })),
79
+ taxIdLine: S(t, e.tax_id),
80
+ email: e.email ?? void 0,
81
+ phone: e.phone ?? void 0
82
+ } : {};
83
+ }
84
+ function T(e) {
85
+ let t = "organization" in e ? e.organization : e.individual;
86
+ return {
87
+ name: "organization" in e ? e.organization.legal_name : [e.individual.first_name, e.individual.last_name].filter(Boolean).join(" "),
88
+ email: t.email,
89
+ phone: t.phone
90
+ };
91
+ }
92
+ function E({ counterpart: e, billingAddress: t, issuerCountry: n, messages: r }) {
93
+ if (!e) return { kind: "pending" };
94
+ let { name: i, email: a, phone: o } = T(e);
95
+ return i ? {
96
+ kind: "party",
97
+ name: i,
98
+ addressLines: C(g({
99
+ address: t,
100
+ issuerCountry: n
101
+ })),
102
+ taxIdLine: S(r, e.tax_id),
103
+ email: a || void 0,
104
+ phone: o || void 0
105
+ } : { kind: "pending" };
106
+ }
107
+ function D({ lineItems: e, currency: n, unitNamesById: r, messages: o }) {
108
+ return e.filter((e) => !t(e)).map((e) => {
109
+ let t = a(e.price, n), s = i(e.quantity), c = r[e.measureUnitId] || e.measureUnitName;
110
+ return {
111
+ id: e.id,
112
+ name: e.name,
113
+ quantity: String(s),
114
+ price: u({
115
+ amount: t,
116
+ currency: n,
117
+ fallback: ""
118
+ }),
119
+ ...c ? { unit: c } : {},
120
+ taxable: e.taxable ? o.previewTaxableYes : o.previewTaxableNo,
121
+ amount: u({
122
+ amount: Math.round(t * s),
123
+ currency: n,
124
+ fallback: ""
125
+ })
126
+ };
127
+ });
128
+ }
129
+ function O(t, n) {
130
+ return n ? new Intl.NumberFormat(void 0, {
131
+ style: "currency",
132
+ currency: n,
133
+ currencySign: "accounting"
134
+ }).format(-t / 10 ** e(n)) : "";
135
+ }
136
+ function k(e, i) {
137
+ if (!e.taxRate) return i.previewTax;
138
+ let a = o(e.taxRate), s = n(e.taxRate, e.savedTaxRate);
139
+ return new Set(e.lineItems.filter((e) => e.taxable && !t(e)).map((e) => r(e, a, s))).size > 1 ? i.previewTax : i.previewTaxWithRate.replace("{rate}", String(a / m));
140
+ }
141
+ function A({ totals: e, currency: t, taxLabel: n, messages: r }) {
142
+ let i = (e) => u({
143
+ amount: e,
144
+ currency: t,
145
+ fallback: ""
146
+ }), a = e.discountAmount > 0, o = e.taxableItemsSubtotal > 0, s = e.nonTaxableItemsSubtotal > 0, c = [{
147
+ id: "subtotal",
148
+ label: r.previewSubtotal,
149
+ value: i(e.subtotal)
150
+ }];
151
+ return a && c.push({
152
+ id: "discount",
153
+ label: r.previewDiscount,
154
+ value: O(e.discountAmount, t)
155
+ }), s && (o || a) && c.push({
156
+ id: "nonTaxableSubtotal",
157
+ label: r.previewNonTaxableSubtotal,
158
+ value: i(e.nonTaxableSubtotal),
159
+ muted: !0
160
+ }), o && (s || a) && c.push({
161
+ id: "taxableSubtotal",
162
+ label: r.previewTaxableSubtotal,
163
+ value: i(e.taxableSubtotal),
164
+ muted: !0
165
+ }), c.push({
166
+ id: "tax",
167
+ label: n,
168
+ value: i(e.totalTaxes)
169
+ }), {
170
+ rows: c,
171
+ total: {
172
+ label: r.previewTotal,
173
+ value: i(e.total)
174
+ }
175
+ };
176
+ }
177
+ function j({ bankDetails: e, canReceivePayments: t, messages: n }) {
178
+ let r = e ? [
179
+ [n.previewAccountHolderName, e.accountHolderName],
180
+ [n.previewRoutingNumber, e.routingNumber],
181
+ [n.previewAccountNumber, e.accountNumber]
182
+ ].filter((e) => !!e[1]).map(([e, t]) => e.replace("{value}", t)) : [];
183
+ if (t || r.length !== 0) return {
184
+ showPayOnline: t,
185
+ bankLines: r
186
+ };
187
+ }
188
+ function M({ values: e, totals: t, entity: n, counterpart: r, billingAddress: i, paymentTerms: a, unitNamesById: o, bankDetails: l, canReceivePayments: u = !1, messages: d, today: f = /* @__PURE__ */ new Date() }) {
189
+ let p = D({
190
+ lineItems: e.lineItems,
191
+ currency: e.currency,
192
+ unitNamesById: o,
193
+ messages: d
194
+ }), m = n?.logo?.url, h = w(n, d), g = c(e.issueDate, f);
12
195
  return {
13
- view: c(() => n({
14
- terms: g.data?.data,
15
- isLoading: g.isLoading,
16
- fields: {
17
- paymentTermsId: u,
18
- paymentTermsCustomDate: d
19
- },
20
- customDatePickerOpen: _,
21
- isRecurring: p,
22
- messages: m,
23
- issueDate: i(f)
24
- }), [
25
- _,
26
- p,
27
- f,
28
- m,
29
- d,
30
- u,
31
- g.data?.data,
32
- g.isLoading
33
- ]),
34
- calendar: c(() => t(d), [d]),
35
- select: s((e) => {
36
- h((t) => a(t, e)), v(!1);
37
- }, [h]),
38
- changeCustomDatePickerOpen: s((e) => {
39
- v(e), e || h(r);
40
- }, [h]),
41
- selectCustomDate: s((e) => {
42
- h((t) => r({
43
- ...t,
44
- paymentTermsCustomDate: o(e)
45
- })), v(!1);
46
- }, [h]),
47
- reset: s(() => v(!1), [])
196
+ issuer: h,
197
+ logo: m ? {
198
+ kind: "image",
199
+ src: m,
200
+ alt: h.name ? d.previewLogoAlt.replace("{name}", h.name) : d.previewLogoAltNoName
201
+ } : { kind: "placeholder" },
202
+ billTo: E({
203
+ counterpart: r,
204
+ billingAddress: i,
205
+ issuerCountry: n?.address?.country,
206
+ messages: d
207
+ }),
208
+ invoiceNumber: _,
209
+ issueDate: s(g),
210
+ ...x({
211
+ paymentTermsId: e.paymentTermsId,
212
+ paymentTermsCustomDate: e.paymentTermsCustomDate,
213
+ paymentTerms: a,
214
+ issueDate: g,
215
+ messages: d
216
+ }),
217
+ openingNote: e.openingNote || void 0,
218
+ lineItems: p.length > 0 ? {
219
+ kind: "rows",
220
+ rows: p
221
+ } : { kind: "empty" },
222
+ totals: p.length > 0 ? A({
223
+ totals: t,
224
+ currency: e.currency,
225
+ taxLabel: k(e, d),
226
+ messages: d
227
+ }) : void 0,
228
+ closingNote: e.closingNote || void 0,
229
+ payment: j({
230
+ bankDetails: l,
231
+ canReceivePayments: u,
232
+ messages: d
233
+ })
48
234
  };
49
235
  }
50
236
  //#endregion
51
- export { u as useReceivablePaymentTerms };
237
+ export { g as buildPreviewAddressLines, x as buildPreviewPaymentTerms, M as buildReceivablePreviewView, h as formatCountryName, O as formatDeduction };