@tesouro/embedded-components-react 0.2.266 → 0.2.269

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 (97) hide show
  1. package/README.md +15 -12
  2. package/dist/experimental/WidgetSuite.d.ts +25 -1
  3. package/dist/experimental/index.d.ts +25 -1
  4. package/dist/index.css +45 -9
  5. package/dist/index.d.ts +46 -22
  6. package/dist/index.js +1 -1
  7. package/dist/lib/AcceptDisclosuresWidget.d.ts +25 -1
  8. package/dist/lib/BalancesWidget.d.ts +24 -0
  9. package/dist/lib/BankAccountOnboardingWidget.d.ts +25 -1
  10. package/dist/lib/BankAccountsWidget.d.ts +25 -1
  11. package/dist/lib/BillPayWidget.d.ts +24 -0
  12. package/dist/lib/BillPayWidget.js +1 -1
  13. package/dist/lib/CardDetailsWidget.d.ts +25 -1
  14. package/dist/lib/CardsWidget.d.ts +25 -1
  15. package/dist/lib/ChartOfAccountsWidget.d.ts +25 -1
  16. package/dist/lib/CounterpartsWidget.d.ts +25 -1
  17. package/dist/lib/CreateCardWidget.d.ts +25 -1
  18. package/dist/lib/ExpenseApprovalPoliciesWidget.d.ts +25 -1
  19. package/dist/lib/ExpenseManagementWidget.d.ts +25 -1
  20. package/dist/lib/ExpenseRequirementsWidget.d.ts +25 -1
  21. package/dist/lib/HelpWidget.d.ts +25 -1
  22. package/dist/lib/InsightsWidget.d.ts +24 -0
  23. package/dist/lib/InvoicingWidget.d.ts +25 -1
  24. package/dist/lib/LinkedAccountsWidget.d.ts +25 -1
  25. package/dist/lib/ProductsWidget.d.ts +25 -1
  26. package/dist/lib/ProfileWidget.d.ts +25 -1
  27. package/dist/lib/ReceiptMatchWidget.d.ts +25 -1
  28. package/dist/lib/ReceivablesWidget.d.ts +25 -1
  29. package/dist/lib/SettingsWidget.d.ts +25 -1
  30. package/dist/lib/TagsWidget.d.ts +25 -1
  31. package/dist/lib/TeamWidget.d.ts +25 -1
  32. package/dist/lib/TransfersWidget.d.ts +24 -0
  33. package/dist/lib/WidgetProvider.d.ts +25 -1
  34. package/dist/lib/WidgetProviderPublic.d.ts +24 -0
  35. package/dist/libs/tesouro-embedded-components-react/accept-disclosures-widget/feature/dist/index4.js +9 -8
  36. package/dist/libs/tesouro-embedded-components-react/bank-account-onboarding-widget/feature/dist/index17.js +122 -121
  37. package/dist/libs/tesouro-embedded-components-react/bank-accounts-widget/feature/dist/index8.js +9 -8
  38. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index.js +6 -6
  39. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index10.js +99 -7
  40. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index11.js +7 -97
  41. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index12.js +99 -4
  42. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index13.js +4 -4
  43. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index14.js +2 -41
  44. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index15.js +44 -1
  45. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index16.js +1 -50
  46. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index17.js +48 -6
  47. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index18.js +9 -5
  48. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index19.js +8 -91
  49. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index2.js +6 -2
  50. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index20.js +7 -3
  51. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index21.js +100 -6
  52. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index22.js +3 -9
  53. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index23.js +6 -83
  54. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index24.js +9 -3
  55. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index25.js +83 -6
  56. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index26.js +2 -111
  57. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index27.js +8 -1
  58. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index28.js +104 -16
  59. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index29.js +1 -0
  60. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index30.js +25 -0
  61. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index6.js +37 -27
  62. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index7.js +15 -116
  63. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index8.js +126 -31
  64. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index9.js +32 -69
  65. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index12.js +0 -3
  66. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index13.js +34 -69
  67. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index15.js +4 -0
  68. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index16.js +261 -181
  69. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index28.js +32 -33
  70. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index7.js +2 -2
  71. package/dist/libs/tesouro-embedded-components-react/card-details-widget/feature/dist/index6.js +9 -8
  72. package/dist/libs/tesouro-embedded-components-react/cards-widget/feature/dist/index8.js +9 -8
  73. package/dist/libs/tesouro-embedded-components-react/counterparts-widget/feature/dist/index8.js +9 -8
  74. package/dist/libs/tesouro-embedded-components-react/create-card-widget/feature/dist/index7.js +94 -93
  75. package/dist/libs/tesouro-embedded-components-react/expense-approval-policies-widget/feature/dist/lib/ExpenseApprovalPoliciesWidgetFeature.js +7 -6
  76. package/dist/libs/tesouro-embedded-components-react/expense-management-widget/feature/dist/index3.js +9 -8
  77. package/dist/libs/tesouro-embedded-components-react/expense-receipt-match-widget/feature/dist/lib/ReceiptMatchWidget.js +12 -11
  78. package/dist/libs/tesouro-embedded-components-react/expense-requirements-widget/feature/dist/lib/ExpenseRequirementsWidget.js +7 -6
  79. package/dist/libs/tesouro-embedded-components-react/gl-code-table-widget/feature/dist/index8.js +9 -8
  80. package/dist/libs/tesouro-embedded-components-react/help-widget/feature/dist/index3.js +9 -8
  81. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index12.js +9 -8
  82. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index3.js +10 -9
  83. package/dist/libs/tesouro-embedded-components-react/linked-accounts-widget/feature/dist/index9.js +9 -8
  84. package/dist/libs/tesouro-embedded-components-react/products-widget/feature/dist/index8.js +9 -8
  85. package/dist/libs/tesouro-embedded-components-react/profile-widget/feature/dist/index4.js +9 -8
  86. package/dist/libs/tesouro-embedded-components-react/settings-widget/feature/dist/index6.js +10 -9
  87. package/dist/libs/tesouro-embedded-components-react/shared/data-access/dist/index.js +22 -21
  88. package/dist/libs/tesouro-embedded-components-react/shared/data-access/dist/lib/widgetGatewayHosts.js +14 -0
  89. package/dist/libs/tesouro-embedded-components-react/shared/feature/dist/lib/WidgetProvider/RootWidgetProvider.js +76 -67
  90. package/dist/libs/tesouro-embedded-components-react/shared/feature/dist/lib/WidgetProvider/WidgetProvider.js +107 -101
  91. package/dist/libs/tesouro-embedded-components-react/shared/feature/dist/lib/analytics/build-info.js +1 -1
  92. package/dist/libs/tesouro-embedded-components-react/shared/feature/dist/lib/analytics/client.js +12 -4
  93. package/dist/libs/tesouro-embedded-components-react/tags-widget/feature/dist/index11.js +9 -8
  94. package/dist/libs/tesouro-embedded-components-react/team-widget/feature/dist/index17.js +106 -105
  95. package/dist/libs/tesouro-embedded-components-react/widget-suite/feature/dist/index5.js +1 -1
  96. package/dist/libs/tesouro-embedded-components-react/widget-suite/feature/dist/index6.js +9 -8
  97. package/package.json +1 -1
@@ -1,122 +1,21 @@
1
- "use client";
2
- "use client";
3
- "use client";
4
- "use client";
5
- import { toast as e } from "../../../../../packages/shared-ui-shadcn/dist/index.js";
6
- import "../../../shared/ui/dist/index.js";
7
- import { BILL_CREATE_MESSAGE_LABELS_EN as t } from "./index2.js";
8
- import { useReplacePayableLineItemsMutation as n } from "../../data-access/dist/index6.js";
9
- import { useCreatePayableMutation as r, useSubmitPayableForApprovalMutation as i, useUpdatePayableMutation as a, useValidatePayableMutation as o } from "../../data-access/dist/index7.js";
10
- import "../../data-access/dist/index.js";
11
- import { mapBillFormToPayload as s, mapLineItemsToPayload as c } from "./index6.js";
12
- import { useCallback as l, useRef as u, useState as d } from "react";
1
+ import { BILL_CREATE_MESSAGE_LABELS_EN as e } from "./index2.js";
2
+ import { parseMoneyToMinorUnits as t, parseQuantity as n } from "./index6.js";
13
3
  //#region ../../libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index7.js
14
- var f = {
15
- document_id: "invoiceNumber",
16
- issued_at: "invoiceDate",
17
- due_date: "dueDate",
18
- payment_terms: "paymentTerms"
19
- };
20
- function p(e) {
21
- return e.type === "type_error.none.not_allowed" || e.msg === "none is not an allowed value";
4
+ var r = /^(?:\d{1,3}(?:,\d{3})+(?:\.\d+)?|\d+(?:\.\d+)?|\.\d+)$/;
5
+ function i(e) {
6
+ let n = e.trim();
7
+ return !n || t(n) !== null ? !0 : r.test(n) ? Number(n.replaceAll(",", "")) === 0 : !1;
22
8
  }
23
- function m(e, n = t) {
24
- let r = {}, i = [];
25
- for (let t of e) {
26
- let e = t.loc[0] ?? n.unknownValidationField, a = f[e], o = p(t) ? n.requiredField : t.msg;
27
- a ? r[a] = o : i.push(n.unmappedValidationError(e, o));
9
+ function a(r, i = e) {
10
+ let a = {};
11
+ for (let e of r) {
12
+ let r = t(e.price), o = t(e.amount), s = {};
13
+ e.price.trim() && r === null && (s.price = i.unreadableMoney), e.amount.trim() && o === null && (s.amount = i.unreadableMoney), (r !== null || o !== null) && n(e.quantity) === null && (s.quantity = i.unusableQuantity), Object.keys(s).length && (a[e.id] = s);
28
14
  }
29
- return i.length && (r.form = i.join(" ")), r;
15
+ return Object.keys(a).length ? a : void 0;
30
16
  }
31
- function h({ payableId: f, form: p, paymentTerm: h, counterpartId: g, onSaved: _, onPayableCreated: v, onDraftSaved: y, onFinalized: b, labels: x }) {
32
- let S = {
33
- ...t,
34
- ...x
35
- }, [C, w] = d(), T = f ?? C, [E, D] = d(), O = u(!1), k = r(), A = a(), j = n(), M = o(), N = i(), P = l(async () => {
36
- let e = s({
37
- values: p.values,
38
- paymentTerm: h,
39
- counterpartId: g
40
- }), t = T;
41
- if (t ? await A.mutateAsync({
42
- path: { payable_id: t },
43
- body: e
44
- }) : (t = (await k.mutateAsync({ body: e }))?.id, t && (w(t), v?.(t))), !t) throw Error("Payable was created without an id");
45
- return await j.mutateAsync({
46
- path: { payable_id: t },
47
- body: { data: c(p.lineItems) }
48
- }), t;
49
- }, [
50
- g,
51
- k,
52
- p.lineItems,
53
- p.values,
54
- v,
55
- h,
56
- T,
57
- j,
58
- A
59
- ]);
60
- return {
61
- saveDraft: l(async () => {
62
- if (!O.current) {
63
- O.current = !0, D("draft");
64
- try {
65
- let t = await P();
66
- p.setErrors(void 0), _?.(t), y?.(t), e.success(S.draftSaved);
67
- } catch {
68
- p.setErrors({ form: S.saveFailed });
69
- } finally {
70
- D(void 0), O.current = !1;
71
- }
72
- }
73
- }, [
74
- p,
75
- S.draftSaved,
76
- S.saveFailed,
77
- y,
78
- _,
79
- P
80
- ]),
81
- finalize: l(async () => {
82
- if (!O.current) {
83
- O.current = !0, D("finalize");
84
- try {
85
- let t;
86
- try {
87
- t = await P();
88
- } catch {
89
- p.setErrors({ form: S.saveFailed });
90
- return;
91
- }
92
- _?.(t);
93
- try {
94
- let n = await M.mutateAsync({ path: { payable_id: t } });
95
- if (n.validation_errors.length) {
96
- p.setErrors(m(n.validation_errors, S));
97
- return;
98
- }
99
- await N.mutateAsync({ path: { payable_id: t } }), p.setErrors(void 0), b?.(t), e.success(S.billFinalized);
100
- } catch {
101
- p.setErrors({ form: S.finalizeFailed });
102
- }
103
- } finally {
104
- D(void 0), O.current = !1;
105
- }
106
- }
107
- }, [
108
- p,
109
- S,
110
- b,
111
- _,
112
- P,
113
- N,
114
- M
115
- ]),
116
- payableId: T,
117
- isSavingDraft: E === "draft",
118
- isFinalizing: E === "finalize"
119
- };
17
+ function o(t, n, r, a = e) {
18
+ return !i(t) || !i(n) || r !== void 0 && (!r.trim() || !i(r)) ? { form: a.totalsNeedAttention } : void 0;
120
19
  }
121
20
  //#endregion
122
- export { m as mapValidationErrorsToForm, h as useBillCreateController };
21
+ export { o as validateBillTotals, a as validateLineItems };
@@ -1,39 +1,134 @@
1
- import { formatMoneyExact as e } from "../../../shared/util/dist/lib/formatMoneyExact.js";
1
+ "use client";
2
+ "use client";
3
+ "use client";
4
+ "use client";
5
+ import { toast as e } from "../../../../../packages/shared-ui-shadcn/dist/index.js";
6
+ import "../../../shared/ui/dist/index.js";
7
+ import { BILL_CREATE_MESSAGE_LABELS_EN as t } from "./index2.js";
8
+ import { useReplacePayableLineItemsMutation as n } from "../../data-access/dist/index6.js";
9
+ import { useCreatePayableMutation as r, useSubmitPayableForApprovalMutation as i, useUpdatePayableMutation as a, useValidatePayableMutation as o } from "../../data-access/dist/index7.js";
2
10
  import "../../data-access/dist/index.js";
11
+ import { mapBillFormToPayload as s, mapLineItemsToPayload as c } from "./index6.js";
12
+ import { validateBillTotals as l, validateLineItems as u } from "./index7.js";
13
+ import { useCallback as d, useRef as f, useState as p } from "react";
3
14
  //#region ../../libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index8.js
4
- var t = "USD";
5
- function n() {
6
- return {
7
- id: crypto.randomUUID(),
8
- description: "",
9
- glCode: "",
10
- quantity: "1",
11
- price: "",
12
- amount: ""
13
- };
15
+ var m = {
16
+ document_id: "invoiceNumber",
17
+ issued_at: "invoiceDate",
18
+ due_date: "dueDate"
19
+ };
20
+ function h(e) {
21
+ return e.type === "type_error.none.not_allowed" || e.msg === "none is not an allowed value";
14
22
  }
15
- function r(e) {
16
- return typeof e == "number" ? (e / 100).toFixed(2) : "";
23
+ function g(e, n = t) {
24
+ let r = {}, i = [];
25
+ for (let t of e) {
26
+ let e = t.loc[0] ?? n.unknownValidationField, a = m[e], o = h(t) ? n.requiredField : t.msg;
27
+ a ? r[a] = o : i.push(n.unmappedValidationError(e, o));
28
+ }
29
+ return i.length && (r.form = i.join(" ")), r;
17
30
  }
18
- function i({ payable: i, lineItems: a }) {
19
- let o = {
20
- invoiceNumber: i.document_id ?? "",
21
- invoiceDate: i.issued_at ?? "",
22
- dueDate: i.due_date ?? "",
23
- paymentTerms: "",
24
- poNumber: ""
25
- }, s = a.map((n) => ({
26
- id: n.id,
27
- description: n.name ?? "",
28
- glCode: n.ledger_account_id ?? "",
29
- quantity: n.quantity == null ? "" : String(n.quantity),
30
- price: r(n.unit_price),
31
- amount: typeof n.total == "number" ? e(n.total / 100, { currencyCode: t }) : ""
32
- }));
31
+ function _({ payableId: m, form: h, counterpartId: _, onSaved: v, onPayableCreated: y, onDraftSaved: b, onFinalized: x, labels: S }) {
32
+ let C = {
33
+ ...t,
34
+ ...S
35
+ }, [w, T] = p(), E = m ?? w, [D, O] = p(), k = f(!1), A = r(), j = a(), M = n(), N = o(), P = i(), F = d(() => {
36
+ let e = u(h.lineItems, C), t = l(h.discount, h.tax, h.totalOverride, C);
37
+ return h.setLineItemErrors(e), !e && !t || (h.setErrors(e ? { form: C.lineItemsNeedAttention } : t), !1);
38
+ }, [h, C]), I = d(async () => {
39
+ let e = s({
40
+ values: h.values,
41
+ counterpartId: _,
42
+ editedTotals: h.isTotalsDirty ? {
43
+ discount: h.discount,
44
+ tax: h.tax,
45
+ total: h.totalOverride
46
+ } : void 0
47
+ }), t = E;
48
+ if (t ? await j.mutateAsync({
49
+ path: { payable_id: t },
50
+ body: e
51
+ }) : (t = (await A.mutateAsync({ body: e }))?.id, t && (T(t), y?.(t))), !t) throw Error("Payable was created without an id");
52
+ return await M.mutateAsync({
53
+ path: { payable_id: t },
54
+ body: { data: c(h.lineItems) }
55
+ }), t;
56
+ }, [
57
+ _,
58
+ A,
59
+ h.discount,
60
+ h.isTotalsDirty,
61
+ h.lineItems,
62
+ h.tax,
63
+ h.totalOverride,
64
+ h.values,
65
+ y,
66
+ E,
67
+ M,
68
+ j
69
+ ]);
33
70
  return {
34
- values: o,
35
- lineItems: s.length ? s : [n()]
71
+ saveDraft: d(async () => {
72
+ if (!k.current && F()) {
73
+ k.current = !0, O("draft");
74
+ try {
75
+ let t = await I();
76
+ h.setErrors(void 0), v?.(t), b?.(t), e.success(C.draftSaved);
77
+ } catch {
78
+ h.setErrors({ form: C.saveFailed });
79
+ } finally {
80
+ O(void 0), k.current = !1;
81
+ }
82
+ }
83
+ }, [
84
+ h,
85
+ F,
86
+ C.draftSaved,
87
+ C.saveFailed,
88
+ b,
89
+ v,
90
+ I
91
+ ]),
92
+ finalize: d(async () => {
93
+ if (!k.current && F()) {
94
+ k.current = !0, O("finalize");
95
+ try {
96
+ let t;
97
+ try {
98
+ t = await I();
99
+ } catch {
100
+ h.setErrors({ form: C.saveFailed });
101
+ return;
102
+ }
103
+ v?.(t);
104
+ try {
105
+ let n = await N.mutateAsync({ path: { payable_id: t } });
106
+ if (n.validation_errors.length) {
107
+ h.setErrors(g(n.validation_errors, C));
108
+ return;
109
+ }
110
+ await P.mutateAsync({ path: { payable_id: t } }), h.setErrors(void 0), x?.(t), e.success(C.billFinalized);
111
+ } catch {
112
+ h.setErrors({ form: C.finalizeFailed });
113
+ }
114
+ } finally {
115
+ O(void 0), k.current = !1;
116
+ }
117
+ }
118
+ }, [
119
+ h,
120
+ F,
121
+ C,
122
+ x,
123
+ v,
124
+ I,
125
+ P,
126
+ N
127
+ ]),
128
+ payableId: E,
129
+ isSavingDraft: D === "draft",
130
+ isFinalizing: D === "finalize"
36
131
  };
37
132
  }
38
133
  //#endregion
39
- export { n as emptyLineItem, i as mapPayableToBillForm };
134
+ export { g as mapValidationErrorsToForm, _ as useBillCreateController };
@@ -1,74 +1,37 @@
1
- "use client";
2
- "use client";
3
- "use client";
4
- "use client";
5
- import { displayLineAmount as e, displayTotal as t } from "./index6.js";
6
- import { emptyLineItem as n, mapPayableToBillForm as r } from "./index8.js";
7
- import { useCallback as i, useEffect as a, useMemo as o, useState as s } from "react";
8
1
  //#region ../../libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index9.js
9
- function c({ payable: c, lineItems: l } = {}) {
10
- let u = o(() => r({
11
- payable: c ?? {},
12
- lineItems: l ?? []
13
- }), [c, l]), [d, f] = s(u.values), [p, m] = s(u.lineItems), [h, g] = s(), [_, v] = s(!1), [y, b] = s(!1);
14
- a(() => {
15
- _ || f(u.values);
16
- }, [u]), a(() => {
17
- y || m(u.lineItems);
18
- }, [u]);
19
- let x = i((e) => {
20
- f((t) => ({
21
- ...t,
22
- ...e
23
- })), v(!0);
24
- }, []), S = i((t, n) => {
25
- m((r) => r.map((r) => {
26
- if (r.id !== t) return r;
27
- let i = {
28
- ...r,
29
- ...n
30
- };
31
- return {
32
- ...i,
33
- amount: e(i.quantity, i.price)
34
- };
35
- })), b(!0);
36
- }, []), C = i((t, n) => {
37
- m((r) => r.map((r) => {
38
- if (r.id !== t) return r;
39
- let i = Number.parseFloat(r.quantity), a = String(Math.max(1, (Number.isFinite(i) ? i : 1) + n));
40
- return {
41
- ...r,
42
- quantity: a,
43
- amount: e(a, r.price)
44
- };
45
- })), b(!0);
46
- }, []), w = i((e) => {
47
- m((t) => t.length <= 1 ? t : t.filter((t) => t.id !== e)), b(!0);
48
- }, []), T = i(() => {
49
- m((e) => [...e, n()]), b(!0);
50
- }, []);
2
+ function e() {
51
3
  return {
52
- values: d,
53
- errors: h,
54
- setErrors: g,
55
- onChange: x,
56
- lineItems: p,
57
- lineItemRows: o(() => p.map((e) => ({
58
- ...e,
59
- onChange: (t) => S(e.id, t),
60
- onQuantityStep: (t) => C(e.id, t),
61
- onRemove: () => w(e.id)
62
- })), [
63
- p,
64
- S,
65
- w,
66
- C
67
- ]),
68
- totalAmountLabel: o(() => t(p), [p]),
69
- onAddLineItem: T,
70
- isDirty: _ || y
4
+ id: crypto.randomUUID(),
5
+ description: "",
6
+ glCode: "",
7
+ quantity: "1",
8
+ price: "",
9
+ amount: ""
10
+ };
11
+ }
12
+ function t(e) {
13
+ return typeof e == "number" ? (e / 100).toFixed(2) : "";
14
+ }
15
+ function n({ payable: n, lineItems: r }) {
16
+ let i = {
17
+ invoiceNumber: n.document_id ?? "",
18
+ invoiceDate: n.issued_at ?? "",
19
+ dueDate: n.due_date ?? "",
20
+ poNumber: ""
21
+ }, a = r.map((e) => ({
22
+ id: e.id,
23
+ description: e.name ?? "",
24
+ glCode: e.ledger_account_id ?? "",
25
+ quantity: e.quantity == null ? "" : String(e.quantity),
26
+ price: t(e.unit_price),
27
+ amount: t(e.subtotal)
28
+ }));
29
+ return {
30
+ values: i,
31
+ lineItems: a.length ? a : [e()],
32
+ discount: t(n.discount),
33
+ tax: t(n.tax_amount)
71
34
  };
72
35
  }
73
36
  //#endregion
74
- export { c as useBillForm };
37
+ export { e as emptyLineItem, n as mapPayableToBillForm };
@@ -3,9 +3,6 @@ var e = {
3
3
  invoiceNumber: "Invoice number",
4
4
  invoiceDate: "Invoice date",
5
5
  dueDate: "Due date",
6
- paymentTerms: "Payment terms (optional)",
7
- paymentTermsPlaceholder: "Select payment terms",
8
- paymentTermsNone: "No payment terms",
9
6
  poNumber: "PO number (optional)"
10
7
  };
11
8
  //#endregion
@@ -1,83 +1,48 @@
1
- import { Input as e, Label as t, Select as n, SelectContent as r, SelectItem as i, SelectTrigger as a, SelectValue as o } from "../../../../../packages/shared-ui-shadcn/dist/index.js";
2
- import { BILL_FORM_FIELDS_LABELS_EN as s } from "./index12.js";
3
- import { useId as c } from "react";
4
- import { jsx as l, jsxs as u } from "react/jsx-runtime";
1
+ import { Input as e, Label as t } from "../../../../../packages/shared-ui-shadcn/dist/index.js";
2
+ import { BILL_FORM_FIELDS_LABELS_EN as n } from "./index12.js";
3
+ import { useId as r } from "react";
4
+ import { jsx as i, jsxs as a } from "react/jsx-runtime";
5
5
  //#region ../../libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index13.js
6
- var d = "__tesouro_no_payment_terms__";
7
- function f({ values: f, errors: p, onChange: m, paymentTermOptions: h = [], testId: g, labels: _ }) {
8
- let v = {
9
- ...s,
10
- ..._
11
- }, y = c(), b = (n, r, i) => {
12
- let a = `${y}-${n}`, o = `${a}-error`, s = p?.[n];
13
- return /* @__PURE__ */ u("div", {
6
+ function o({ values: o, errors: s, onChange: c, testId: l, labels: u }) {
7
+ let d = {
8
+ ...n,
9
+ ...u
10
+ }, f = r(), p = (n, r, l) => {
11
+ let u = `${f}-${n}`, d = `${u}-error`, p = s?.[n];
12
+ return /* @__PURE__ */ a("div", {
14
13
  className: "ttw:flex ttw:flex-col ttw:gap-1.5",
15
14
  children: [
16
- /* @__PURE__ */ l(t, {
17
- htmlFor: a,
15
+ /* @__PURE__ */ i(t, {
16
+ htmlFor: u,
18
17
  children: r
19
18
  }),
20
- /* @__PURE__ */ l(e, {
21
- id: a,
22
- type: i,
23
- value: f[n],
24
- "aria-invalid": s ? !0 : void 0,
25
- "aria-describedby": s ? o : void 0,
26
- onChange: (e) => m({ [n]: e.target.value })
19
+ /* @__PURE__ */ i(e, {
20
+ id: u,
21
+ type: l,
22
+ value: o[n],
23
+ "aria-invalid": p ? !0 : void 0,
24
+ "aria-describedby": p ? d : void 0,
25
+ onChange: (e) => c({ [n]: e.target.value })
27
26
  }),
28
- s ? /* @__PURE__ */ l("p", {
29
- id: o,
27
+ p ? /* @__PURE__ */ i("p", {
28
+ id: d,
30
29
  className: "ttw:text-sm ttw:text-destructive",
31
- children: s
30
+ children: p
32
31
  }) : null
33
32
  ]
34
33
  });
35
- }, x = `${y}-paymentTerms`, S = `${x}-error`, C = p?.paymentTerms;
36
- return /* @__PURE__ */ u("div", {
34
+ };
35
+ return /* @__PURE__ */ a("div", {
37
36
  className: "ttw:flex ttw:flex-col ttw:gap-4",
38
- "data-testid": g,
39
- children: [
40
- b("invoiceNumber", v.invoiceNumber),
41
- /* @__PURE__ */ u("div", {
42
- className: "ttw:grid ttw:grid-cols-2 ttw:gap-4",
43
- children: [b("invoiceDate", v.invoiceDate, "date"), b("dueDate", v.dueDate, "date")]
44
- }),
45
- /* @__PURE__ */ u("div", {
46
- className: "ttw:grid ttw:grid-cols-2 ttw:gap-4",
47
- children: [/* @__PURE__ */ u("div", {
48
- className: "ttw:flex ttw:flex-col ttw:gap-1.5",
49
- children: [
50
- /* @__PURE__ */ l(t, {
51
- htmlFor: x,
52
- children: v.paymentTerms
53
- }),
54
- /* @__PURE__ */ u(n, {
55
- value: f.paymentTerms || d,
56
- onValueChange: (e) => m({ paymentTerms: e === d ? "" : e }),
57
- children: [/* @__PURE__ */ l(a, {
58
- id: x,
59
- className: "ttw:w-full",
60
- "aria-invalid": C ? !0 : void 0,
61
- "aria-describedby": C ? S : void 0,
62
- children: /* @__PURE__ */ l(o, { placeholder: v.paymentTermsPlaceholder })
63
- }), /* @__PURE__ */ u(r, { children: [/* @__PURE__ */ l(i, {
64
- value: d,
65
- children: v.paymentTermsNone
66
- }), h.map((e) => /* @__PURE__ */ l(i, {
67
- value: e.value,
68
- children: e.label
69
- }, e.value))] })]
70
- }),
71
- C ? /* @__PURE__ */ l("p", {
72
- id: S,
73
- className: "ttw:text-sm ttw:text-destructive",
74
- children: C
75
- }) : null
76
- ]
77
- }), b("poNumber", v.poNumber)]
78
- })
79
- ]
37
+ "data-testid": l,
38
+ children: [/* @__PURE__ */ a("div", {
39
+ className: "ttw:grid ttw:grid-cols-2 ttw:gap-4",
40
+ children: [p("invoiceDate", d.invoiceDate, "date"), p("dueDate", d.dueDate, "date")]
41
+ }), /* @__PURE__ */ a("div", {
42
+ className: "ttw:grid ttw:grid-cols-2 ttw:gap-4",
43
+ children: [p("invoiceNumber", d.invoiceNumber), p("poNumber", d.poNumber)]
44
+ })]
80
45
  });
81
46
  }
82
47
  //#endregion
83
- export { f as BillFormFields, f as default };
48
+ export { o as BillFormFields, o as default };
@@ -9,6 +9,10 @@ var e = {
9
9
  quantity: "Quantity",
10
10
  price: "Price",
11
11
  amount: "Amount",
12
+ currencySymbol: "$",
13
+ discount: "Discounts",
14
+ tax: "Tax",
15
+ totalAmount: "Total amount",
12
16
  addLineItem: "+ Add line item",
13
17
  increaseQuantity: (e) => `Increase quantity — line item ${e}`,
14
18
  decreaseQuantity: (e) => `Decrease quantity — line item ${e}`,