@tesouro/embedded-components-react 0.2.326 → 0.2.328

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 (134) hide show
  1. package/dist/index.css +3 -0
  2. package/dist/index.d.ts +59 -59
  3. package/dist/index.js +1 -1
  4. package/dist/lib/BillPayWidget.js +1 -1
  5. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/data-access/dist/index.js +10 -10
  6. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/data-access/dist/index10.js +119 -33
  7. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/data-access/dist/index4.js +50 -21
  8. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/data-access/dist/index5.js +39 -17
  9. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/data-access/dist/index8.js +1 -1
  10. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/data-access/dist/index9.js +17 -12
  11. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index.js +10 -10
  12. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index10.js +2 -2
  13. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index12.js +45 -17
  14. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index13.js +4 -21
  15. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index14.js +9 -24
  16. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index15.js +42 -9
  17. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index16.js +25 -50
  18. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index17.js +49 -5
  19. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index18.js +91 -63
  20. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index19.js +20 -49
  21. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index20.js +52 -7
  22. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index21.js +5 -35
  23. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index22.js +67 -113
  24. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index23.js +46 -53
  25. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index24.js +80 -205
  26. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index25.js +32 -192
  27. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index26.js +117 -62
  28. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index27.js +54 -45
  29. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index28.js +205 -31
  30. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index29.js +184 -143
  31. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index30.js +63 -33
  32. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index31.js +46 -100
  33. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index32.js +32 -7
  34. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index33.js +146 -182
  35. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index34.js +38 -4
  36. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index35.js +102 -24
  37. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index36.js +10 -80
  38. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index37.js +200 -78
  39. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index38.js +2 -1
  40. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index39.js +27 -2
  41. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index40.js +78 -41
  42. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index41.js +132 -1
  43. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index42.js +3 -53
  44. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index43.js +2 -9
  45. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index44.js +43 -16
  46. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index45.js +1 -8
  47. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index46.js +50 -77
  48. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index47.js +8 -145
  49. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index48.js +18 -5
  50. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index49.js +6 -6
  51. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index50.js +78 -7
  52. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index51.js +138 -75
  53. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index52.js +2 -0
  54. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index53.js +6 -6
  55. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index54.js +7 -113
  56. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index55.js +85 -1
  57. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index56.js +2 -24
  58. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index57.js +8 -0
  59. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index58.js +115 -0
  60. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index59.js +1 -0
  61. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index60.js +25 -0
  62. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index7.js +2 -2
  63. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index.js +33 -25
  64. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index12.js +13 -12
  65. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index13.js +58 -13
  66. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index14.js +2 -24
  67. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index15.js +22 -2
  68. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index16.js +23 -31
  69. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index17.js +1 -262
  70. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index18.js +15 -2
  71. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index19.js +23 -6
  72. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index20.js +2 -49
  73. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index21.js +41 -1
  74. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index22.js +271 -20
  75. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index23.js +2 -286
  76. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index24.js +9 -2
  77. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index25.js +47 -14
  78. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index26.js +2 -120
  79. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index27.js +22 -2
  80. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index28.js +284 -8
  81. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index29.js +2 -96
  82. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index30.js +16 -2
  83. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index31.js +118 -11
  84. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index32.js +1 -57
  85. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index33.js +10 -2
  86. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index34.js +93 -51
  87. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index35.js +1 -138
  88. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index36.js +12 -1
  89. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index37.js +56 -5
  90. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index38.js +2 -44
  91. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index39.js +53 -1
  92. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index40.js +137 -2
  93. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index41.js +2 -16
  94. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index42.js +7 -2
  95. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index43.js +42 -59
  96. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index44.js +2 -238
  97. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index45.js +2 -202
  98. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index46.js +61 -8
  99. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index47.js +2 -8
  100. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index48.js +2 -91
  101. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index49.js +16 -0
  102. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index50.js +1 -1
  103. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index51.js +67 -4
  104. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index52.js +248 -25
  105. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index53.js +204 -2
  106. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index54.js +6 -3
  107. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index55.js +6 -32
  108. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index56.js +93 -2
  109. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index58.js +1 -105
  110. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index59.js +7 -2
  111. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index60.js +28 -16
  112. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index61.js +2 -10
  113. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index62.js +4 -167
  114. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index63.js +34 -2
  115. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index64.js +2 -14
  116. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index65.js +10 -87
  117. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index66.js +105 -1
  118. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index67.js +2 -0
  119. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index68.js +18 -0
  120. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index69.js +10 -0
  121. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index70.js +170 -0
  122. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index71.js +2 -0
  123. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index72.js +14 -0
  124. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index73.js +89 -0
  125. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index74.js +2 -0
  126. package/dist/libs/tesouro-embedded-components-react/shared/approval-policy/data-access/dist/lib/approvalPoliciesApi.js +20 -20
  127. package/dist/libs/tesouro-embedded-components-react/shared/approval-policy/feature/dist/index.js +4 -4
  128. package/dist/libs/tesouro-embedded-components-react/shared/data-access/dist/index.js +21 -21
  129. package/dist/libs/tesouro-embedded-components-react/shared/data-access/dist/lib/rest/sdk.gen.js +142 -102
  130. package/dist/libs/tesouro-embedded-components-react/shared/data-access/dist/lib/rest/zod.gen.js +8 -3
  131. package/dist/libs/tesouro-embedded-components-react/shared/feature/dist/lib/analytics/build-info.js +1 -1
  132. package/dist/libs/tesouro-embedded-components-react/widget-suite/feature/dist/index7.js +1 -1
  133. package/package.json +1 -1
  134. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index57.js +0 -12
@@ -1,68 +1,123 @@
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 { useUpdatePayableMutation as t } from "../../data-access/dist/index10.js";
8
- import "../../data-access/dist/index.js";
9
- import { counterpartFormBankAccountToCreatePayload as n, validateAchFormValues as r } from "../../../shared/counterpart-management/feature/dist/lib/helpers.js";
10
- import { useCreateCounterpartBankAccountMutation as i } from "../../../shared/counterpart-management/data-access/dist/index5.js";
11
- import "../../../shared/counterpart-management/feature/dist/index.js";
12
- import { useCallback as a, useRef as o, useState as s } from "react";
1
+ import { PAY_BILL_FLOW_LABELS_EN as e, mergePayBillFlowLabels as t } from "./index7.js";
2
+ import { APPROVAL_POLICY_RULE_COPY_EN as n } from "./index12.js";
3
+ import { BILL_DETAIL_ACTIONS_LABELS_EN as r, SCHEDULED_SUMMARY_LABEL_EN as i, mergeBillDetailActionsLabels as a } from "./index24.js";
4
+ import { SOURCE_DOCUMENT_PREVIEW_LABELS_EN as o } from "./index25.js";
13
5
  //#region ../../libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index26.js
14
- var c = {
15
- accountHolderName: "",
16
- routingNumber: "",
17
- accountNumber: ""
6
+ var s = {
7
+ unmappedValidationError: (e, t) => `${e}: ${t}`,
8
+ unknownValidationField: "(unknown field)",
9
+ requiredField: "This field is required.",
10
+ saveFailed: "We could not save this bill. Try again.",
11
+ finalizeFailed: "We could not submit this bill. Try again.",
12
+ draftSaved: "Bill saved as a draft.",
13
+ billFinalized: "Bill submitted for approval.",
14
+ unreadableMoney: "Enter a valid amount.",
15
+ unusableQuantity: "Enter a quantity greater than 0.",
16
+ lineItemsNeedAttention: "Check the highlighted line items before saving.",
17
+ totalsNeedAttention: "Enter valid amounts for discount, tax, and total."
18
+ }, c = {
19
+ achMethod: "via ACH bank transfer",
20
+ noMethod: "No payment method on file",
21
+ accountHolder: "Account holder",
22
+ routingNumber: "Routing number",
23
+ accountNumber: "Account number",
24
+ paymentMethodLoading: "Loading payment method...",
25
+ paymentMethodUnavailable: "We could not load payment methods. Try again.",
26
+ searchFailed: "We could not load vendors. Try again.",
27
+ vendorDetailsFailed: "We could not load this vendor. Try again."
28
+ }, l = {
29
+ attachFailed: "We could not attach that file. Try again.",
30
+ saveBeforeAttaching: "Save this bill before attaching a document.",
31
+ noDocument: "No document attached to this bill.",
32
+ preview: o
33
+ }, u = {
34
+ notProvided: "Not provided",
35
+ paymentInstructionsValue: (e) => `Account ending in ${e}`,
36
+ invoiceDateRow: "Invoice date",
37
+ dueDateRow: "Due date",
38
+ invoiceNumberRow: "Invoice number",
39
+ glCodeMissing: "GL code not specified",
40
+ qtyPriceValue: (e, t) => `${e} x ${t}`,
41
+ subtotalRow: "Subtotal",
42
+ taxRow: "Tax",
43
+ discountRow: "Discounts",
44
+ totalRow: "Total",
45
+ paymentInstructionsSaveError: "Couldn't save payment instructions. Try again."
46
+ }, d = {
47
+ dateLabel: (e) => new Date(e).toLocaleString("en-US", {
48
+ month: "short",
49
+ day: "numeric",
50
+ year: "numeric",
51
+ hour: "numeric",
52
+ minute: "2-digit"
53
+ }),
54
+ byActor: (e, t) => `${e} by ${t}`,
55
+ billAdded: "Bill added",
56
+ billUploaded: "Bill uploaded",
57
+ billUpdated: "Bill updated",
58
+ attachmentAdded: "Attachment added",
59
+ submittedForApproval: "Submitted for approval",
60
+ approvalRequested: "Approval requested",
61
+ approved: "Approved",
62
+ autoApproved: "Approved automatically",
63
+ rejected: "Rejected",
64
+ rejectedWithReason: (e) => `Rejected: ${e}`,
65
+ reopened: "Reopened",
66
+ markedAsPaid: "Marked as paid",
67
+ markedAsPartiallyPaid: "Marked as partially paid",
68
+ paymentReverted: "Payment reverted",
69
+ statusChanged: (e) => `Status changed to ${e}`
70
+ }, f = {
71
+ newTitle: "New bill",
72
+ extractedTitle: (e) => `Bill from ${e}`,
73
+ viewTitle: (e) => `Bill from ${e}`,
74
+ readOnlyTitle: "Bill details",
75
+ addedOn: (e) => `Added on ${e}`,
76
+ discardConfirm: "Discard your changes to this bill?",
77
+ scheduledSummary: i,
78
+ actions: r,
79
+ detail: u,
80
+ history: d,
81
+ payBill: e,
82
+ approvalPolicyCopy: n
18
83
  };
19
- function l({ payableId: l, counterpartId: u, saveErrorMessage: d }) {
20
- let [f, p] = s(!1), [m, h] = s(c), [g, _] = s(), v = i(), y = t(), b = o(void 0), x = a(() => {
21
- h(c), _(void 0), b.current = void 0, p(!0);
22
- }, []), S = a(() => {
23
- p(!1);
24
- }, []), C = a((e) => {
25
- h((t) => ({
26
- ...t,
27
- ...e
28
- }));
29
- }, []), w = a(async () => {
30
- if (!l || !u) return !1;
31
- let t = r(m);
32
- if (Object.keys(t).length > 0) return _(t), !1;
33
- try {
34
- if (!b.current) {
35
- let e = await v.mutateAsync({
36
- path: { counterpart_id: u },
37
- body: n(m)
38
- });
39
- b.current = e.id;
40
- }
41
- return await y.mutateAsync({
42
- path: { payable_id: l },
43
- body: { counterpart_bank_account_id: b.current }
44
- }), b.current = void 0, p(!1), !0;
45
- } catch {
46
- return e.error(d), !1;
47
- }
48
- }, [
49
- u,
50
- v,
51
- l,
52
- d,
53
- y,
54
- m
55
- ]);
84
+ function p(e) {
56
85
  return {
57
- isOpen: f,
58
- values: m,
59
- errors: g,
60
- isSaving: v.isPending || y.isPending,
61
- open: x,
62
- close: S,
63
- onChange: C,
64
- save: w
86
+ ...f,
87
+ ...e,
88
+ actions: a(e?.actions),
89
+ detail: {
90
+ ...f.detail,
91
+ ...e?.detail
92
+ },
93
+ history: {
94
+ ...f.history,
95
+ ...e?.history
96
+ },
97
+ payBill: t(e?.payBill),
98
+ approvalPolicyCopy: {
99
+ ...f.approvalPolicyCopy,
100
+ ...e?.approvalPolicyCopy
101
+ }
65
102
  };
66
103
  }
104
+ var m = {
105
+ createTitle: "New vendor",
106
+ editTitle: "Edit vendor",
107
+ close: "Close the vendor form",
108
+ nameLabel: "Name",
109
+ addAddress: "Add address (optional)",
110
+ paymentMethodsHeading: "Accepted payment methods",
111
+ paymentMethodsDescription: "How and where will the money be sent. Don't have these yet? No problem. You can save this vendor and add their payment details later — you just won't be able to send payments until you do.",
112
+ achTitle: "ACH bank transfer",
113
+ achDescription: "Fast, direct deposit to the vendor's bank. Arrives in 1–3 business days.",
114
+ addBankAccount: "Add bank account",
115
+ accountHolderNameLabel: "Account holder name",
116
+ routingNumberLabel: "Routing number",
117
+ accountNumberLabel: "Account number",
118
+ achHelp: "Ask your vendor for this — it's usually on their invoice, W-9, or a payment instructions email they send you.",
119
+ cancel: "Cancel",
120
+ save: "Save vendor"
121
+ };
67
122
  //#endregion
68
- export { l as usePaymentInstructionsForm };
123
+ export { s as BILL_CREATE_MESSAGE_LABELS_EN, f as BILL_CREATE_SCREEN_LABELS_EN, u as BILL_DETAIL_VIEW_LABELS_EN, d as BILL_HISTORY_LABELS_EN, l as SOURCE_DOCUMENT_CONTAINER_LABELS_EN, m as VENDOR_INLINE_FORM_LABELS_EN, c as VENDOR_SECTION_PROPS_LABELS_EN, p as mergeBillCreateScreenCopy };
@@ -1,50 +1,59 @@
1
- import { parseDecimalAmountToMinorUnits as e } from "../../../shared/util/dist/lib/parseDecimalAmountToMinorUnits.js";
1
+ "use client";
2
+ "use client";
3
+ "use client";
4
+ "use client";
5
+ import { SourceDocumentPanel as e } from "../../ui/dist/index73.js";
6
+ import "../../ui/dist/index.js";
7
+ import { useAttachPayableFileMutation as t, useDeletePayableFileMutation as n } from "../../data-access/dist/index10.js";
2
8
  import "../../data-access/dist/index.js";
9
+ import { createSourceDocumentPreview as r } from "./index25.js";
10
+ import { SOURCE_DOCUMENT_CONTAINER_LABELS_EN as i } from "./index26.js";
11
+ import { jsx as a } from "react/jsx-runtime";
3
12
  //#region ../../libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index27.js
4
- var t = "USD";
5
- function n(n) {
6
- return e(n, t);
7
- }
8
- function r(e) {
9
- let t = e.trim();
10
- if (!t) return null;
11
- let n = Number(t);
12
- return Number.isFinite(n) && n > 0 ? n : null;
13
- }
14
- function i(e) {
15
- return !!(e.description.trim() || e.glCode.trim() || n(e.price) !== null || n(e.amount) !== null);
16
- }
17
- function a(e) {
18
- return n(e) ?? 0;
19
- }
20
- function o(e) {
21
- let t = Number.parseFloat(e);
22
- return Number.isFinite(t) ? t : 0;
23
- }
24
- function s(e) {
25
- return (e / 100).toFixed(2);
26
- }
27
- function c({ values: e, counterpartId: r, clearCounterpart: i, editedTotals: a }) {
28
- let o = { currency: t };
29
- return r ? o.counterpart_id = r : i && (o.counterpart_id = null), e.invoiceNumber && (o.document_id = e.invoiceNumber), e.invoiceDate && (o.issued_at = e.invoiceDate), e.dueDate && (o.due_date = e.dueDate), a && (o.discount = n(a.discount) ?? 0, o.tax_amount = n(a.tax) ?? 0, a.total !== void 0 && (o.total_amount = n(a.total) ?? 0)), o;
30
- }
31
- function l(e) {
32
- return e.filter(i).map((e) => {
33
- let t = n(e.amount), i = r(e.quantity) ?? 1, a = n(e.price) ?? (t === null ? 0 : Math.round(t / i)), o = Math.round(i * a);
34
- return {
35
- name: e.description,
36
- quantity: i,
37
- unit_price: a,
38
- ...t !== null && t !== o ? { subtotal: t } : {},
39
- ...e.glCode ? { ledger_account_id: e.glCode } : {}
40
- };
13
+ function o({ payableId: o, file: s, isDocumentPending: c, pendingFileName: l, readOnly: u, labels: d }) {
14
+ let f = {
15
+ ...i,
16
+ ...d,
17
+ preview: {
18
+ ...i.preview,
19
+ ...d?.preview
20
+ }
21
+ }, p = t(), m = n();
22
+ if (!s && (c || p.isPending)) return /* @__PURE__ */ a(e, {
23
+ mode: "loading",
24
+ fileName: l
25
+ });
26
+ if (!s && u) return /* @__PURE__ */ a("div", {
27
+ className: "ttw:rounded-lg ttw:border ttw:border-border ttw:bg-card ttw:p-4 ttw:text-sm ttw:text-muted-foreground",
28
+ children: f.noDocument
29
+ });
30
+ if (!s && !o) return /* @__PURE__ */ a("div", {
31
+ className: "ttw:rounded-lg ttw:border ttw:border-border ttw:bg-card ttw:p-4 ttw:text-sm ttw:text-muted-foreground",
32
+ children: f.saveBeforeAttaching
33
+ });
34
+ if (!s) return /* @__PURE__ */ a(e, {
35
+ mode: "upload",
36
+ uploadStatus: p.isPending ? "uploading" : "idle",
37
+ uploadErrorMessage: p.isError ? f.attachFailed : void 0,
38
+ onFilesSelected: (e) => {
39
+ let [t] = e;
40
+ !t || !o || p.mutate({
41
+ path: { payable_id: o },
42
+ file: t
43
+ });
44
+ }
45
+ });
46
+ let h = r(s, f.preview);
47
+ return /* @__PURE__ */ a(e, {
48
+ mode: "document",
49
+ fileName: s.name,
50
+ preview: h,
51
+ onDownload: () => window.open(s.url, "_blank", "noopener,noreferrer"),
52
+ onDelete: o && !u ? () => m.mutate({
53
+ path: { file_id: s.id },
54
+ payableId: o
55
+ }) : void 0
41
56
  });
42
- }
43
- function u(e, t) {
44
- return s(Math.round(o(e) * a(t)));
45
- }
46
- function d(e, t, n) {
47
- return s(e.reduce((e, t) => e + a(t.amount), 0) + a(t) - a(n));
48
57
  }
49
58
  //#endregion
50
- export { d as calculateTotal, u as displayLineAmount, i as isPersistableLineItem, c as mapBillFormToPayload, l as mapLineItemsToPayload, n as parseMoneyToMinorUnits, r as parseQuantity };
59
+ export { o as SourceDocumentContainer, o as default };
@@ -1,34 +1,208 @@
1
- import { BILL_CREATE_MESSAGE_LABELS_EN as e } from "./index22.js";
2
- import { isPersistableLineItem as t, parseMoneyToMinorUnits as n, parseQuantity as r } from "./index27.js";
1
+ "use client";
2
+ "use client";
3
+ "use client";
4
+ "use client";
5
+ import { Button as e } from "../../../../../packages/shared-ui-shadcn/dist/index.js";
6
+ import { getStateOptions as t } from "../../../shared/util/dist/lib/usStates.js";
7
+ import { AchFieldGroup as n } from "../../../shared/counterpart-management/ui/dist/index5.js";
8
+ import { CounterpartFormFields as r, useFocusFirstInvalidField as i } from "../../../shared/counterpart-management/ui/dist/index9.js";
9
+ import { VENDOR_INLINE_FORM_LABELS_EN as a } from "./index26.js";
10
+ import { COUNTERPART_MESSAGE_LABELS_EN as o } from "../../../shared/counterpart-management/feature/dist/lib/labels.js";
11
+ import { useCounterpartForm as s } from "../../../shared/counterpart-management/feature/dist/lib/useCounterpartForm.js";
12
+ import "../../../shared/counterpart-management/feature/dist/index.js";
13
+ import { useCallback as c, useEffect as l, useMemo as u, useRef as d, useState as f } from "react";
14
+ import { Fragment as p, jsx as m, jsxs as h } from "react/jsx-runtime";
15
+ import { Landmark as g, Plus as _, X as v } from "lucide-react";
3
16
  //#region ../../libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index28.js
4
- var i = /^(?:\d{1,3}(?:,\d{3})+(?:\.\d+)?|\d+(?:\.\d+)?|\.\d+)$/;
5
- function a(e) {
6
- let t = e.trim();
7
- return !t || n(t) !== null ? !0 : i.test(t) ? Number(t.replaceAll(",", "")) === 0 : !1;
8
- }
9
- function o(t, i = e) {
10
- let a = {};
11
- for (let e of t) {
12
- let t = n(e.price), o = n(e.amount), s = {};
13
- e.price.trim() && t === null && (s.price = i.unreadableMoney), e.amount.trim() && o === null && (s.amount = i.unreadableMoney), (t !== null || o !== null) && r(e.quantity) === null && (s.quantity = i.unusableQuantity), Object.keys(s).length && (a[e.id] = s);
14
- }
15
- return Object.keys(a).length ? a : void 0;
16
- }
17
- function s(i, a, o, s = e) {
18
- let c = {};
19
- a || (c.vendor = s.requiredField), i.invoiceNumber.trim() || (c.invoiceNumber = s.requiredField), i.invoiceDate.trim() || (c.invoiceDate = s.requiredField), i.dueDate.trim() || (c.dueDate = s.requiredField);
20
- let l = {};
21
- return o.forEach((e, i) => {
22
- if (i > 0 && !t(e)) return;
23
- let a = {};
24
- e.description.trim() || (a.description = s.requiredField), r(e.quantity) === null && (a.quantity = s.requiredField), n(e.price) === null && n(e.amount) === null && (a.price = s.requiredField, a.amount = s.requiredField), Object.keys(a).length && (l[e.id] = a);
25
- }), {
26
- formErrors: Object.keys(c).length ? c : void 0,
27
- lineItemErrors: Object.keys(l).length ? l : void 0
28
- };
29
- }
30
- function c(t, r, i, o = e) {
31
- return !a(t) || !a(r) || i !== void 0 && n(i) === null ? { form: o.totalsNeedAttention } : void 0;
17
+ function y({ mode: y, counterpart: b, primaryAddress: x, bankAccounts: S, isBankAccountsLoading: C, isBankAccountsError: w, initialName: T, onSaved: E, onCancel: D, onDirtyChange: O, labels: k }) {
18
+ let A = {
19
+ ...a,
20
+ ...k
21
+ }, [j, M] = f("none"), [N, P] = f(b?.id), [F, I] = f(!1), [L, R] = f(!1);
22
+ l(() => {
23
+ O?.(L);
24
+ }, [L, O]);
25
+ let z = u(() => t(), []), B = d(j), V = d(!1), H = s({
26
+ view: j,
27
+ setView: M,
28
+ selectedId: N,
29
+ setSelectedId: P,
30
+ messages: o,
31
+ counterpartType: "vendor",
32
+ counterpart: b,
33
+ primaryAddress: x,
34
+ bankAccounts: S,
35
+ isBankAccountsLoading: C,
36
+ isBankAccountsError: w
37
+ }), { openCreate: U, openEdit: W, setValues: G } = H, K = i(H.errors);
38
+ l(() => {
39
+ y === "edit" ? W() : U();
40
+ }, [
41
+ y,
42
+ U,
43
+ W
44
+ ]), l(() => {
45
+ B.current !== "none" && j === "none" && N && E(N), B.current = j;
46
+ }, [
47
+ j,
48
+ N,
49
+ E
50
+ ]), l(() => {
51
+ y !== "create" || V.current || (V.current = !0, G((e) => ({
52
+ ...e,
53
+ entityType: "organization",
54
+ legalName: T?.trim() || e.legalName
55
+ })));
56
+ }, [
57
+ y,
58
+ T,
59
+ G
60
+ ]), l(() => {
61
+ y === "edit" && (H.values.bankAccount.routingNumber || H.values.bankAccount.accountNumber) && I(!0);
62
+ }, [
63
+ y,
64
+ H.values.bankAccount.accountNumber,
65
+ H.values.bankAccount.routingNumber
66
+ ]), l(() => {
67
+ H.sectionsToExpand.bankAccount && I(!0);
68
+ }, [H.sectionsToExpand.bankAccount]);
69
+ let q = c((e) => {
70
+ R(!0), G((t) => e.entityType === "individual" && t.entityType !== "individual" ? {
71
+ ...t,
72
+ ...e,
73
+ firstName: t.firstName || t.legalName,
74
+ legalName: t.legalName
75
+ } : e.entityType === "organization" && t.entityType !== "organization" ? {
76
+ ...t,
77
+ ...e,
78
+ legalName: t.legalName || [t.firstName, t.lastName].filter(Boolean).join(" ")
79
+ } : {
80
+ ...t,
81
+ ...e
82
+ });
83
+ }, [G]);
84
+ return /* @__PURE__ */ h("div", {
85
+ ref: K,
86
+ className: "ttw:flex ttw:flex-col ttw:gap-4 ttw:rounded-lg ttw:border ttw:border-border ttw:bg-card ttw:p-4",
87
+ children: [
88
+ /* @__PURE__ */ h("div", {
89
+ className: "ttw:flex ttw:items-start ttw:justify-between ttw:gap-2",
90
+ children: [/* @__PURE__ */ m("p", {
91
+ className: "ttw:text-base ttw:font-semibold ttw:text-foreground",
92
+ children: y === "edit" ? A.editTitle : A.createTitle
93
+ }), /* @__PURE__ */ m(e, {
94
+ type: "button",
95
+ variant: "ghost",
96
+ size: "icon",
97
+ "aria-label": A.close,
98
+ onClick: D,
99
+ children: /* @__PURE__ */ m(v, { className: "ttw:size-4" })
100
+ })]
101
+ }),
102
+ /* @__PURE__ */ m(r, {
103
+ mode: y,
104
+ counterpartMode: "vendor",
105
+ values: H.values,
106
+ errors: H.errors,
107
+ stateOptions: z,
108
+ onChange: q,
109
+ onAddressChange: (e) => {
110
+ R(!0), G((t) => ({
111
+ ...t,
112
+ address: {
113
+ ...t.address,
114
+ ...e
115
+ }
116
+ }));
117
+ },
118
+ sections: {
119
+ entityType: !0,
120
+ profileHeading: !1,
121
+ title: !1,
122
+ taxId: !1,
123
+ address: "collapsible",
124
+ bankAccount: !1
125
+ },
126
+ sectionsToExpand: H.sectionsToExpand,
127
+ onAddressExpand: H.expandAddress,
128
+ labels: { businessNameLabel: A.nameLabel }
129
+ }),
130
+ /* @__PURE__ */ h("div", {
131
+ className: "ttw:flex ttw:flex-col ttw:gap-1",
132
+ children: [/* @__PURE__ */ m("p", {
133
+ className: "ttw:text-sm ttw:font-semibold ttw:text-foreground",
134
+ children: A.paymentMethodsHeading
135
+ }), /* @__PURE__ */ m("p", {
136
+ className: "ttw:text-sm ttw:text-muted-foreground",
137
+ children: A.paymentMethodsDescription
138
+ })]
139
+ }),
140
+ /* @__PURE__ */ h("div", {
141
+ className: "ttw:flex ttw:gap-3 ttw:rounded-lg ttw:border ttw:border-border ttw:p-3",
142
+ children: [/* @__PURE__ */ m("span", {
143
+ className: "ttw:flex ttw:size-8 ttw:shrink-0 ttw:items-center ttw:justify-center ttw:rounded-md ttw:bg-primary",
144
+ children: /* @__PURE__ */ m(g, {
145
+ "aria-hidden": !0,
146
+ className: "ttw:size-4 ttw:text-white"
147
+ })
148
+ }), /* @__PURE__ */ h("div", {
149
+ className: "ttw:flex ttw:flex-1 ttw:flex-col ttw:gap-3",
150
+ children: [/* @__PURE__ */ h("div", {
151
+ className: "ttw:flex ttw:flex-col ttw:gap-0.5",
152
+ children: [/* @__PURE__ */ m("p", {
153
+ className: "ttw:text-sm ttw:font-medium ttw:text-foreground",
154
+ children: A.achTitle
155
+ }), /* @__PURE__ */ m("p", {
156
+ className: "ttw:text-sm ttw:text-muted-foreground",
157
+ children: A.achDescription
158
+ })]
159
+ }), F ? /* @__PURE__ */ h(p, { children: [/* @__PURE__ */ m(n, {
160
+ idPrefix: "vendor-inline-ach",
161
+ values: H.values.bankAccount,
162
+ errors: H.errors?.bankAccount,
163
+ onChange: (e) => {
164
+ R(!0), G((t) => ({
165
+ ...t,
166
+ bankAccount: {
167
+ ...t.bankAccount,
168
+ ...e
169
+ }
170
+ }));
171
+ },
172
+ labels: {
173
+ accountHolderName: A.accountHolderNameLabel,
174
+ routingNumber: A.routingNumberLabel,
175
+ accountNumber: A.accountNumberLabel
176
+ }
177
+ }), /* @__PURE__ */ m("p", {
178
+ className: "ttw:text-sm ttw:text-muted-foreground",
179
+ children: A.achHelp
180
+ })] }) : /* @__PURE__ */ h(e, {
181
+ type: "button",
182
+ variant: "link",
183
+ className: "ttw:w-fit ttw:px-0",
184
+ onClick: () => I(!0),
185
+ children: [/* @__PURE__ */ m(_, { className: "ttw:size-4" }), A.addBankAccount]
186
+ })]
187
+ })]
188
+ }),
189
+ /* @__PURE__ */ h("div", {
190
+ className: "ttw:flex ttw:justify-end ttw:gap-2",
191
+ children: [/* @__PURE__ */ m(e, {
192
+ type: "button",
193
+ variant: "outline",
194
+ onClick: D,
195
+ children: A.cancel
196
+ }), /* @__PURE__ */ m(e, {
197
+ type: "button",
198
+ onClick: H.submit,
199
+ loading: H.isSubmitting,
200
+ disabled: H.isSubmitting,
201
+ children: A.save
202
+ })]
203
+ })
204
+ ]
205
+ });
32
206
  }
33
207
  //#endregion
34
- export { s as validateBillCompleteness, c as validateBillTotals, o as validateLineItems };
208
+ export { y as VendorInlineForm, y as default };