@tesouro/embedded-components-react 0.5.204 → 0.5.206
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.
- package/README.md +15 -14
- package/dist/index.d.ts +49 -4
- package/dist/index.js +1 -1
- package/dist/lib/ReceivablesWidget.d.ts +49 -4
- package/dist/lib/ReceivablesWidget.js +1 -1
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index.js +7 -7
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index2.js +26 -23
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index3.js +79 -2
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index.js +1 -1
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index10.js +88 -193
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index11.js +184 -31
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index12.js +32 -145
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index13.js +150 -47
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index14.js +37 -293
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index15.js +58 -70
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index16.js +86 -99
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index17.js +48 -233
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index18.js +336 -0
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index19.js +75 -0
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index20.js +115 -0
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index21.js +270 -0
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index5.js +1 -1
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index8.js +95 -394
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index9.js +422 -72
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index.js +15 -10
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index10.js +94 -1
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index11.js +3 -4
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index12.js +24 -11
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index13.js +1 -1
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index14.js +3 -264
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index15.js +3 -72
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index16.js +16 -421
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index17.js +1 -106
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index18.js +4 -93
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index19.js +11 -343
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index2.js +5 -159
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index20.js +1 -0
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index21.js +264 -0
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index22.js +72 -0
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index23.js +401 -0
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index24.js +106 -0
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index25.js +93 -0
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index26.js +344 -0
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index3.js +182 -32
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index4.js +27 -154
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index5.js +203 -20
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index6.js +161 -1
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index7.js +16 -3
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index8.js +25 -3
- package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index9.js +3 -17
- package/dist/libs/tesouro-embedded-components-react/shared/data-access/dist/index.js +38 -38
- package/dist/libs/tesouro-embedded-components-react/shared/data-access/dist/lib/rest/@tanstack/react-query.gen.js +213 -202
- package/dist/libs/tesouro-embedded-components-react/shared/data-access/dist/lib/rest/sdk.gen.js +136 -116
- package/dist/libs/tesouro-embedded-components-react/shared/feature/dist/lib/analytics/build-info.js +1 -1
- package/dist/packages/shared-ui-shadcn/dist/index.js +1763 -1749
- package/package.json +1 -1
package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index17.js
CHANGED
|
@@ -1,237 +1,52 @@
|
|
|
1
|
-
|
|
2
|
-
"use client";
|
|
3
|
-
"use client";
|
|
4
|
-
"use client";
|
|
5
|
-
import { useAnalyticsTrack as e } from "../../../shared/feature/dist/lib/analytics/hooks.js";
|
|
6
|
-
import { WidgetProvider as t } from "../../../shared/feature/dist/lib/WidgetProvider/WidgetProvider.js";
|
|
7
|
-
import "../../../shared/feature/dist/index.js";
|
|
8
|
-
import { CounterpartFormSheet as n } from "../../../shared/counterpart-management/ui/dist/index9.js";
|
|
9
|
-
import { CounterpartSelector as r } from "../../../shared/counterpart-management/feature/dist/lib/CounterpartSelector.js";
|
|
10
|
-
import "../../../shared/counterpart-management/feature/dist/index.js";
|
|
11
|
-
import { ReceivablesWidgetAnalyticsEvent as i, WIDGET_NAME as a } from "./index2.js";
|
|
12
|
-
import { PAGE_SIZE_OPTIONS as o } from "./index4.js";
|
|
13
|
-
import { ReceivableActionDialog as s } from "../../ui/dist/index3.js";
|
|
14
|
-
import { ReceivableDetailsSheet as c } from "../../ui/dist/index14.js";
|
|
15
|
-
import { ReceivableFormSheet as l } from "../../ui/dist/index16.js";
|
|
16
|
-
import { ReceivablePaymentDialog as u } from "../../ui/dist/index17.js";
|
|
17
|
-
import { ReceivableSendDialog as d } from "../../ui/dist/index18.js";
|
|
18
|
-
import { ReceivablesScreen as f } from "../../ui/dist/index19.js";
|
|
19
|
-
import "../../ui/dist/index.js";
|
|
20
|
-
import { ReceivableAttachmentsSection as p } from "./index5.js";
|
|
21
|
-
import { MeasureUnitsManagerContainer as m } from "../../../shared/product-catalog/feature/dist/lib/MeasureUnitsManagerContainer.js";
|
|
22
|
-
import { ProductSelector as h } from "../../../shared/product-catalog/feature/dist/lib/ProductSelector.js";
|
|
23
|
-
import "../../../shared/product-catalog/feature/dist/index.js";
|
|
24
|
-
import { useReceivablesWidget as g } from "./index16.js";
|
|
25
|
-
import { useEffect as _, useState as v } from "react";
|
|
26
|
-
import { Fragment as y, jsx as b, jsxs as x } from "react/jsx-runtime";
|
|
1
|
+
import { parseQuantity as e, priceInputToMinorUnits as t } from "./index6.js";
|
|
27
2
|
//#region ../../libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index17.js
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
}
|
|
41
|
-
return /* @__PURE__ */ x(y, { children: [
|
|
42
|
-
/* @__PURE__ */ b(f, {
|
|
43
|
-
rows: z.table.rows,
|
|
44
|
-
activeTab: z.activeTab,
|
|
45
|
-
enabledTabs: z.enabledTabs,
|
|
46
|
-
onTabChange: z.setActiveTab,
|
|
47
|
-
isLoading: z.table.isLoading,
|
|
48
|
-
isError: z.table.isError,
|
|
49
|
-
sorting: z.table.sorting,
|
|
50
|
-
onSortingChange: z.table.onSortingChange,
|
|
51
|
-
pageSize: z.table.pageSize,
|
|
52
|
-
onPageSizeChange: z.table.onPageSizeChange,
|
|
53
|
-
pageSizeOptions: M,
|
|
54
|
-
hasNextPage: z.table.hasNextPage,
|
|
55
|
-
hasPrevPage: z.table.hasPrevPage,
|
|
56
|
-
onNextPage: z.table.onNextPage,
|
|
57
|
-
onPrevPage: z.table.onPrevPage,
|
|
58
|
-
searchValue: z.table.searchValue,
|
|
59
|
-
onSearchChange: z.table.onSearchChange,
|
|
60
|
-
statusFilter: z.table.statusFilter,
|
|
61
|
-
statusOptions: z.table.statusOptions,
|
|
62
|
-
onStatusFilterChange: z.table.onStatusFilterChange,
|
|
63
|
-
isFiltering: z.table.isFiltering,
|
|
64
|
-
onCreateClick: z.openCreate,
|
|
65
|
-
onTemplateSettingsClick: j,
|
|
66
|
-
onRowClick: z.handleRowClick,
|
|
67
|
-
onActionClick: z.handleActionClick,
|
|
68
|
-
onRetry: z.table.onRetry,
|
|
69
|
-
labels: F
|
|
70
|
-
}),
|
|
71
|
-
/* @__PURE__ */ b(l, {
|
|
72
|
-
open: z.form.open,
|
|
73
|
-
onOpenChange: (e) => {
|
|
74
|
-
e || z.form.close();
|
|
75
|
-
},
|
|
76
|
-
mode: z.form.mode,
|
|
77
|
-
values: z.form.sheetValues,
|
|
78
|
-
errors: z.form.errors,
|
|
79
|
-
currencyOptions: z.form.currencyOptions,
|
|
80
|
-
paymentTermsOptions: z.form.paymentTermsOptions,
|
|
81
|
-
unitOptions: z.form.lineItemUnitOptions,
|
|
82
|
-
currencySymbol: z.form.currencySymbol,
|
|
83
|
-
lineItemControls: z.form.lineItemControls,
|
|
84
|
-
autoFocusLineItemId: z.form.autoFocusLineItemId,
|
|
85
|
-
lineItemsLoading: z.form.lineItemsLoading,
|
|
86
|
-
inProgress: z.form.isSubmitting,
|
|
87
|
-
customerSelector: /* @__PURE__ */ b(r, {
|
|
88
|
-
mode: "customer",
|
|
89
|
-
value: z.form.values.customerId || void 0,
|
|
90
|
-
onValueChange: (e) => z.form.updateValues({ customerId: e }),
|
|
91
|
-
onCreateClick: z.form.openCounterpartCreate
|
|
92
|
-
}),
|
|
93
|
-
renderProductSelector: (e, t) => /* @__PURE__ */ b(h, {
|
|
94
|
-
...t,
|
|
95
|
-
inputValue: e.name,
|
|
96
|
-
selectedProductId: z.form.values.lineItems.find((t) => t.id === e.id)?.productId || void 0,
|
|
97
|
-
currency: z.form.values.currency,
|
|
98
|
-
maxLength: 100,
|
|
99
|
-
onInputValueChange: (t) => z.form.updateLineItem(e.id, { name: t }),
|
|
100
|
-
onProductSelect: (t) => z.form.selectProduct(e.id, t)
|
|
101
|
-
}),
|
|
102
|
-
onChange: z.form.updateValues,
|
|
103
|
-
onLineItemChange: z.form.updateLineItem,
|
|
104
|
-
onLineItemCommit: z.form.commitLineItem,
|
|
105
|
-
onLineItemQuantityStep: z.form.stepLineItem,
|
|
106
|
-
onTaxRateCommit: z.form.commitTaxRate,
|
|
107
|
-
onManageUnits: () => V(!0),
|
|
108
|
-
onAddLineItem: z.form.addLineItem,
|
|
109
|
-
onRemoveLineItem: z.form.removeLineItem,
|
|
110
|
-
attachmentsSection: z.form.attachmentsView && /* @__PURE__ */ b(p, {
|
|
111
|
-
view: z.form.attachmentsView,
|
|
112
|
-
disabled: z.form.isSubmitting,
|
|
113
|
-
onFilesSelect: z.form.selectAttachmentFiles,
|
|
114
|
-
onIncludeInEmailChange: z.form.setAttachmentIncludeInEmail,
|
|
115
|
-
onRemove: z.form.removeAttachment,
|
|
116
|
-
labels: T
|
|
117
|
-
}),
|
|
118
|
-
cancelDisabled: z.form.attachmentsUploading,
|
|
119
|
-
saveDisabled: z.form.saveDisabled,
|
|
120
|
-
onSubmit: z.form.submit,
|
|
121
|
-
onCancel: z.form.close,
|
|
122
|
-
labels: T
|
|
123
|
-
}),
|
|
124
|
-
/* @__PURE__ */ b(c, {
|
|
125
|
-
open: z.detailsOpen,
|
|
126
|
-
onOpenChange: (e) => {
|
|
127
|
-
e || z.closeDetails();
|
|
128
|
-
},
|
|
129
|
-
details: z.details.detailsView,
|
|
130
|
-
isLoading: z.details.isLoading,
|
|
131
|
-
isError: z.details.isError,
|
|
132
|
-
onActionClick: z.handleDetailsActionClick,
|
|
133
|
-
onClose: z.closeDetails,
|
|
134
|
-
labels: C
|
|
135
|
-
}),
|
|
136
|
-
/* @__PURE__ */ b(d, {
|
|
137
|
-
open: z.actions.sendOpen,
|
|
138
|
-
onOpenChange: (e) => {
|
|
139
|
-
e || z.actions.closeSend();
|
|
140
|
-
},
|
|
141
|
-
values: z.actions.sendValues,
|
|
142
|
-
errors: z.actions.sendErrors,
|
|
143
|
-
inProgress: z.actions.sendInProgress,
|
|
144
|
-
onChange: (e) => z.actions.setSendValues((t) => ({
|
|
145
|
-
...t,
|
|
146
|
-
...e
|
|
147
|
-
})),
|
|
148
|
-
onSubmit: z.actions.submitSend,
|
|
149
|
-
onCancel: z.actions.closeSend,
|
|
150
|
-
labels: I
|
|
151
|
-
}),
|
|
152
|
-
/* @__PURE__ */ b(u, {
|
|
153
|
-
open: z.actions.paymentOpen,
|
|
154
|
-
onOpenChange: (e) => {
|
|
155
|
-
e || z.actions.closePayment();
|
|
156
|
-
},
|
|
157
|
-
values: z.actions.paymentValues,
|
|
158
|
-
errors: z.actions.paymentErrors,
|
|
159
|
-
inProgress: z.actions.paymentInProgress,
|
|
160
|
-
onChange: (e) => z.actions.setPaymentValues((t) => ({
|
|
161
|
-
...t,
|
|
162
|
-
...e
|
|
163
|
-
})),
|
|
164
|
-
onSubmit: z.actions.submitPayment,
|
|
165
|
-
onCancel: z.actions.closePayment,
|
|
166
|
-
labels: N
|
|
167
|
-
}),
|
|
168
|
-
z.actions.actionDialog && /* @__PURE__ */ b(s, {
|
|
169
|
-
open: !!z.actions.actionTarget,
|
|
170
|
-
onOpenChange: (e) => {
|
|
171
|
-
e || z.actions.closeAction();
|
|
172
|
-
},
|
|
173
|
-
title: z.actions.actionDialog.title,
|
|
174
|
-
description: z.actions.actionDialog.description,
|
|
175
|
-
confirmLabel: z.actions.actionDialog.confirmLabel,
|
|
176
|
-
destructive: z.actions.actionDialog.destructive,
|
|
177
|
-
error: z.actions.actionError,
|
|
178
|
-
inProgress: z.actions.actionInProgress,
|
|
179
|
-
onConfirm: z.actions.confirmAction,
|
|
180
|
-
onCancel: z.actions.closeAction,
|
|
181
|
-
labels: L
|
|
182
|
-
}),
|
|
183
|
-
/* @__PURE__ */ b(n, {
|
|
184
|
-
open: z.form.counterpartView === "create",
|
|
185
|
-
onOpenChange: (e) => {
|
|
186
|
-
e || z.form.counterpartForm.close();
|
|
187
|
-
},
|
|
188
|
-
mode: "create",
|
|
189
|
-
values: z.form.counterpartForm.values,
|
|
190
|
-
errors: z.form.counterpartForm.errors,
|
|
191
|
-
stateOptions: z.form.stateOptions,
|
|
192
|
-
inProgress: z.form.counterpartForm.isSubmitting,
|
|
193
|
-
onChange: (e) => z.form.counterpartForm.setValues((t) => ({
|
|
194
|
-
...t,
|
|
195
|
-
...e
|
|
196
|
-
})),
|
|
197
|
-
onAddressChange: (e) => z.form.counterpartForm.setValues((t) => ({
|
|
198
|
-
...t,
|
|
199
|
-
address: {
|
|
200
|
-
...t.address,
|
|
201
|
-
...e
|
|
202
|
-
}
|
|
203
|
-
})),
|
|
204
|
-
onSubmit: z.form.counterpartForm.submit,
|
|
205
|
-
onCancel: z.form.counterpartForm.close,
|
|
206
|
-
labels: t
|
|
207
|
-
}),
|
|
208
|
-
/* @__PURE__ */ b(m, {
|
|
209
|
-
open: B,
|
|
210
|
-
onClose: () => V(!1),
|
|
211
|
-
managerLabels: D,
|
|
212
|
-
deleteLabels: E,
|
|
213
|
-
messageLabels: P
|
|
214
|
-
})
|
|
215
|
-
] });
|
|
3
|
+
var n = 1e4;
|
|
4
|
+
function r({ lineItems: n, currency: r, taxRate: i }) {
|
|
5
|
+
let a = i ? i / 100 : 0, o = 0, s = 0;
|
|
6
|
+
for (let i of n) {
|
|
7
|
+
let n = Math.round(t(i.price, r) * e(i.quantity));
|
|
8
|
+
i.taxable ? o += n : s += n;
|
|
9
|
+
}
|
|
10
|
+
return {
|
|
11
|
+
taxableItemsSubtotal: o,
|
|
12
|
+
nonTaxableItemsSubtotal: s,
|
|
13
|
+
subtotal: o + s,
|
|
14
|
+
rate: a
|
|
15
|
+
};
|
|
216
16
|
}
|
|
217
|
-
function
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
})
|
|
17
|
+
function i({ discount: e, subtotal: t }) {
|
|
18
|
+
if (!e) return 0;
|
|
19
|
+
let r = e.value ?? (e.type === "amount" ? e.amount : Math.round(t * e.amount / n));
|
|
20
|
+
return Math.min(Math.max(r, 0), t);
|
|
21
|
+
}
|
|
22
|
+
function a({ taxableItemsSubtotal: e, nonTaxableItemsSubtotal: t, discountAmount: n }) {
|
|
23
|
+
let r = e + t, i = r > 0 ? Math.round(e / r * n) : 0;
|
|
24
|
+
return {
|
|
25
|
+
taxableSubtotal: e - i,
|
|
26
|
+
nonTaxableSubtotal: t - (n - i)
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
function o({ lineItems: e, currency: t, taxRate: n, discount: o }) {
|
|
30
|
+
let s = r({
|
|
31
|
+
lineItems: e,
|
|
32
|
+
currency: t,
|
|
33
|
+
taxRate: n
|
|
34
|
+
}), c = i({
|
|
35
|
+
discount: o,
|
|
36
|
+
subtotal: s.subtotal
|
|
37
|
+
}), { taxableSubtotal: l, nonTaxableSubtotal: u } = a({
|
|
38
|
+
...s,
|
|
39
|
+
discountAmount: c
|
|
40
|
+
}), d = s.rate ? Math.round(l * s.rate) : 0, f = s.subtotal - c;
|
|
41
|
+
return {
|
|
42
|
+
...s,
|
|
43
|
+
discountAmount: c,
|
|
44
|
+
discountedSubtotal: f,
|
|
45
|
+
taxableSubtotal: l,
|
|
46
|
+
nonTaxableSubtotal: u,
|
|
47
|
+
totalTaxes: d,
|
|
48
|
+
total: f + d
|
|
49
|
+
};
|
|
235
50
|
}
|
|
236
51
|
//#endregion
|
|
237
|
-
export {
|
|
52
|
+
export { a as allocateDiscount, o as calculateInvoiceTotals, r as calculateItemsSubtotals, i as resolveDiscountAmount };
|
|
@@ -0,0 +1,336 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
"use client";
|
|
3
|
+
"use client";
|
|
4
|
+
"use client";
|
|
5
|
+
import { getStateOptions as e } from "../../../shared/util/dist/lib/usStates.js";
|
|
6
|
+
import { extractApiErrorMessage as t } from "../../../shared/util/dist/lib/apiErrors.js";
|
|
7
|
+
import { COUNTERPART_MESSAGE_LABELS_EN as n } from "../../../shared/counterpart-management/feature/dist/lib/labels.js";
|
|
8
|
+
import { useCounterpartAddressesQuery as r } from "../../../shared/counterpart-management/data-access/dist/index7.js";
|
|
9
|
+
import { useCounterpartForm as i } from "../../../shared/counterpart-management/feature/dist/lib/useCounterpartForm.js";
|
|
10
|
+
import "../../../shared/counterpart-management/feature/dist/index.js";
|
|
11
|
+
import { buildLineItemControls as ee, commitLineItemField as te, commitTaxRateInput as a, convertPriceInput as ne, createLineItem as re, getCurrencySymbol as ie, isBlankLineItem as ae, lineItemFromProduct as oe, reconcileMeasureUnits as se, sanitizeLineItemPatch as ce, sanitizeTaxRateInput as le, stepLineItemQuantity as ue, stripBlankLineItems as de, summarizeLineItemErrors as fe, toSheetLineItem as pe, validateLineItems as me } from "./index6.js";
|
|
12
|
+
import { buildReceivableAttachmentsView as he } from "./index7.js";
|
|
13
|
+
import { createEmptyReceivableFormValues as o, hasReceivableFormErrors as ge, receivableFormValuesToCreatePayload as _e, receivableFormValuesToLineItemChanges as ve, receivableFormValuesToUpdatePayload as ye, receivableToFormValues as be, validateReceivableForm as xe } from "./index9.js";
|
|
14
|
+
import { useCreateReceivableMutation as Se, useUpdateReceivableMutation as Ce } from "../../data-access/dist/index6.js";
|
|
15
|
+
import "../../data-access/dist/index.js";
|
|
16
|
+
import { useReceivableAttachmentUploads as we } from "./index13.js";
|
|
17
|
+
import { useReceivablePaymentTerms as Te } from "./index14.js";
|
|
18
|
+
import { useReceivableBankAccount as Ee } from "./index16.js";
|
|
19
|
+
import { calculateInvoiceTotals as De } from "./index17.js";
|
|
20
|
+
import { getCurrencyOptions as Oe } from "../../../shared/product-catalog/feature/dist/lib/helpers.js";
|
|
21
|
+
import { useMeasureUnitsQuery as ke } from "../../../shared/product-catalog/data-access/dist/index9.js";
|
|
22
|
+
import { useMeasureUnits as Ae } from "../../../shared/product-catalog/feature/dist/lib/useMeasureUnits.js";
|
|
23
|
+
import "../../../shared/product-catalog/feature/dist/index.js";
|
|
24
|
+
import { useCallback as s, useEffect as c, useMemo as l, useRef as u, useState as d } from "react";
|
|
25
|
+
//#region ../../libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index18.js
|
|
26
|
+
function f({ messages: f, counterpartMessageLabels: p, embeddedBankName: je, onCreated: m }) {
|
|
27
|
+
let h = Se(), g = Ce(), _ = u([]), v = u(""), [y, b] = d(!1), [x, S] = d("create"), [C, w] = d(), [T, E] = d(() => o()), [Me, D] = d({}), [O, Ne] = d("none"), k = Ae(), A = ke(), j = A.data?.data, { unitNamesById: M } = k, [Pe, N] = d(), [P, F] = d(!1), I = u(!1), L = l(() => e(), []), Fe = l(() => ({
|
|
28
|
+
...n,
|
|
29
|
+
...p
|
|
30
|
+
}), [p]), R = r(T.customerId), Ie = R.data?.data?.[0], z = R.data?.data?.[0]?.id, Le = s((e) => {
|
|
31
|
+
E((t) => ({
|
|
32
|
+
...t,
|
|
33
|
+
attachments: e(t.attachments)
|
|
34
|
+
}));
|
|
35
|
+
}, []), B = we({
|
|
36
|
+
attachments: T.attachments,
|
|
37
|
+
setAttachments: Le,
|
|
38
|
+
receivableId: C
|
|
39
|
+
}), { reset: V, discardUploads: H, commitRemovals: U } = B, Re = T.type === "invoice" ? he({
|
|
40
|
+
attachments: T.attachments,
|
|
41
|
+
pendingUploads: B.pendingUploads,
|
|
42
|
+
isCountLimitReached: B.isCountLimitReached,
|
|
43
|
+
isRecurring: !1,
|
|
44
|
+
messages: f
|
|
45
|
+
}) : void 0, ze = s((e) => {
|
|
46
|
+
E((t) => ({
|
|
47
|
+
...t,
|
|
48
|
+
customerId: e ?? ""
|
|
49
|
+
}));
|
|
50
|
+
}, []), W = i({
|
|
51
|
+
view: O,
|
|
52
|
+
setView: Ne,
|
|
53
|
+
selectedId: T.customerId || void 0,
|
|
54
|
+
setSelectedId: ze,
|
|
55
|
+
messages: Fe,
|
|
56
|
+
counterpartType: "customer",
|
|
57
|
+
counterpart: void 0,
|
|
58
|
+
primaryAddress: Ie
|
|
59
|
+
}), Be = s((e) => E((t) => ({
|
|
60
|
+
...t,
|
|
61
|
+
...e({
|
|
62
|
+
paymentTermsId: t.paymentTermsId,
|
|
63
|
+
paymentTermsCustomDate: t.paymentTermsCustomDate
|
|
64
|
+
})
|
|
65
|
+
})), []), G = Te({
|
|
66
|
+
paymentTermsId: T.paymentTermsId,
|
|
67
|
+
paymentTermsCustomDate: T.paymentTermsCustomDate,
|
|
68
|
+
messages: f,
|
|
69
|
+
onChange: Be
|
|
70
|
+
}), K = G.reset, Ve = s((e) => E((t) => ({
|
|
71
|
+
...t,
|
|
72
|
+
...e
|
|
73
|
+
})), []), q = Ee({
|
|
74
|
+
open: y,
|
|
75
|
+
bankAccountId: T.bankAccountId,
|
|
76
|
+
embeddedBankName: je,
|
|
77
|
+
messages: f,
|
|
78
|
+
onSelect: Ve
|
|
79
|
+
}), J = q.reset, Y = s(() => {
|
|
80
|
+
_.current = [], N(void 0), S("create"), w(void 0), E(o()), D({}), F(!1), V();
|
|
81
|
+
}, [V]), He = s((e = "invoice") => {
|
|
82
|
+
K(), J(), _.current = [], N(void 0), S("create"), w(void 0), E({
|
|
83
|
+
...o(),
|
|
84
|
+
type: e
|
|
85
|
+
}), D({}), V(), F(!1), b(!0);
|
|
86
|
+
}, [
|
|
87
|
+
V,
|
|
88
|
+
K,
|
|
89
|
+
J
|
|
90
|
+
]), Ue = s((e) => {
|
|
91
|
+
e.type !== "credit_note" && (K(), J(), _.current = e.line_items, v.current = e.currency, N(void 0), S("edit"), w(e.id), E(be(e, j)), D({}), F(!1), V(), b(!0));
|
|
92
|
+
}, [
|
|
93
|
+
V,
|
|
94
|
+
K,
|
|
95
|
+
J,
|
|
96
|
+
j
|
|
97
|
+
]);
|
|
98
|
+
c(() => {
|
|
99
|
+
j?.length && E((e) => {
|
|
100
|
+
let t = se(e.lineItems, j);
|
|
101
|
+
return t === e.lineItems ? e : {
|
|
102
|
+
...e,
|
|
103
|
+
lineItems: t
|
|
104
|
+
};
|
|
105
|
+
});
|
|
106
|
+
}, [j]);
|
|
107
|
+
let X = B.isUploading, We = s(() => {
|
|
108
|
+
X || (H(), b(!1), D({}));
|
|
109
|
+
}, [H, X]), Ge = s((e) => {
|
|
110
|
+
let t = e.taxRate === void 0 ? e : {
|
|
111
|
+
...e,
|
|
112
|
+
taxRate: le(e.taxRate)
|
|
113
|
+
}, { currency: n, type: r } = t;
|
|
114
|
+
if (r !== void 0 && r !== "invoice" && H(), n === void 0) {
|
|
115
|
+
E((e) => ({
|
|
116
|
+
...e,
|
|
117
|
+
...t
|
|
118
|
+
}));
|
|
119
|
+
return;
|
|
120
|
+
}
|
|
121
|
+
I.current = !0, E((e) => e.currency === n ? {
|
|
122
|
+
...e,
|
|
123
|
+
...t
|
|
124
|
+
} : {
|
|
125
|
+
...e,
|
|
126
|
+
...t,
|
|
127
|
+
lineItems: e.lineItems.map((t) => ({
|
|
128
|
+
...t,
|
|
129
|
+
price: ne(t.price, e.currency, n)
|
|
130
|
+
}))
|
|
131
|
+
});
|
|
132
|
+
}, [H]), Ke = s(() => {
|
|
133
|
+
E((e) => {
|
|
134
|
+
let t = a(e.taxRate);
|
|
135
|
+
return t === e.taxRate ? e : {
|
|
136
|
+
...e,
|
|
137
|
+
taxRate: t
|
|
138
|
+
};
|
|
139
|
+
});
|
|
140
|
+
}, []), Z = s((e, t) => {
|
|
141
|
+
let n = me(e, {
|
|
142
|
+
currency: t,
|
|
143
|
+
messages: f
|
|
144
|
+
});
|
|
145
|
+
D((e) => ({
|
|
146
|
+
...e,
|
|
147
|
+
lineItems: n,
|
|
148
|
+
lineItemsSummary: fe(n)
|
|
149
|
+
}));
|
|
150
|
+
}, [f]), Q = s((e, { validate: t }) => {
|
|
151
|
+
t && (I.current = !0), E((t) => ({
|
|
152
|
+
...t,
|
|
153
|
+
lineItems: e(t.lineItems)
|
|
154
|
+
}));
|
|
155
|
+
}, []);
|
|
156
|
+
c(() => {
|
|
157
|
+
I.current && (I.current = !1, Z(T.lineItems, T.currency));
|
|
158
|
+
}, [
|
|
159
|
+
Z,
|
|
160
|
+
T.currency,
|
|
161
|
+
T.lineItems
|
|
162
|
+
]);
|
|
163
|
+
let qe = s((e, t) => {
|
|
164
|
+
let { unit: n, ...r } = t, i = ce(r);
|
|
165
|
+
i.name !== void 0 && (i.productId = ""), n !== void 0 && (i.measureUnitId = n, i.measureUnitName = ""), Q((t) => t.map((t) => t.id === e ? {
|
|
166
|
+
...t,
|
|
167
|
+
...i
|
|
168
|
+
} : t), { validate: P });
|
|
169
|
+
}, [Q, P]), Je = s((e, t) => {
|
|
170
|
+
Q((n) => n.map((n) => n.id === e ? {
|
|
171
|
+
...n,
|
|
172
|
+
...oe({
|
|
173
|
+
product: t,
|
|
174
|
+
currency: T.currency,
|
|
175
|
+
unitNamesById: M
|
|
176
|
+
})
|
|
177
|
+
} : n), { validate: !0 });
|
|
178
|
+
}, [
|
|
179
|
+
Q,
|
|
180
|
+
M,
|
|
181
|
+
T.currency
|
|
182
|
+
]), $ = s((e, t) => {
|
|
183
|
+
t && Q((n) => t.kind === "remove" ? n.filter((t) => t.id !== e) : n.map((n) => n.id === e ? {
|
|
184
|
+
...n,
|
|
185
|
+
...t.patch
|
|
186
|
+
} : n), { validate: !0 });
|
|
187
|
+
}, [Q]), Ye = s((e, t) => {
|
|
188
|
+
let n = T.lineItems.find((t) => t.id === e);
|
|
189
|
+
n && $(e, te({
|
|
190
|
+
lineItem: n,
|
|
191
|
+
field: t,
|
|
192
|
+
rowCount: T.lineItems.length,
|
|
193
|
+
currency: T.currency
|
|
194
|
+
}));
|
|
195
|
+
}, [
|
|
196
|
+
$,
|
|
197
|
+
T.currency,
|
|
198
|
+
T.lineItems
|
|
199
|
+
]), Xe = s((e, t) => {
|
|
200
|
+
let n = T.lineItems.find((t) => t.id === e);
|
|
201
|
+
n && $(e, ue({
|
|
202
|
+
lineItem: n,
|
|
203
|
+
step: t,
|
|
204
|
+
rowCount: T.lineItems.length
|
|
205
|
+
}));
|
|
206
|
+
}, [$, T.lineItems]), Ze = s(() => {
|
|
207
|
+
let e = re(T.currency);
|
|
208
|
+
N(e.id), E((t) => ({
|
|
209
|
+
...t,
|
|
210
|
+
lineItems: [...t.lineItems, e]
|
|
211
|
+
}));
|
|
212
|
+
}, [T.currency]), Qe = s((e) => {
|
|
213
|
+
Q((t) => t.length <= 1 ? t : t.filter((t) => t.id !== e), { validate: !0 });
|
|
214
|
+
}, [Q]), $e = s(async () => {
|
|
215
|
+
if (X) return;
|
|
216
|
+
if (A.isLoading) {
|
|
217
|
+
D({ form: f.lineItemsLoading });
|
|
218
|
+
return;
|
|
219
|
+
}
|
|
220
|
+
let e = de(T.lineItems), n = e.length === T.lineItems.length ? T : {
|
|
221
|
+
...T,
|
|
222
|
+
lineItems: e
|
|
223
|
+
};
|
|
224
|
+
n !== T && E(n);
|
|
225
|
+
let r = xe({
|
|
226
|
+
values: n,
|
|
227
|
+
billingAddressId: z,
|
|
228
|
+
messages: f
|
|
229
|
+
});
|
|
230
|
+
if (ge(r)) {
|
|
231
|
+
D(r), F(!0);
|
|
232
|
+
return;
|
|
233
|
+
}
|
|
234
|
+
D({});
|
|
235
|
+
try {
|
|
236
|
+
if (x === "edit" && C) {
|
|
237
|
+
let e = { receivable_id: C };
|
|
238
|
+
await g.mutateAsync({
|
|
239
|
+
path: e,
|
|
240
|
+
body: ye({
|
|
241
|
+
values: n,
|
|
242
|
+
billingAddressId: z ?? "",
|
|
243
|
+
lineItemChanges: ve({
|
|
244
|
+
values: n,
|
|
245
|
+
originalLineItems: _.current,
|
|
246
|
+
originalCurrency: v.current,
|
|
247
|
+
unitNamesById: M,
|
|
248
|
+
units: j
|
|
249
|
+
})
|
|
250
|
+
})
|
|
251
|
+
}), U(), b(!1), Y();
|
|
252
|
+
return;
|
|
253
|
+
}
|
|
254
|
+
let e = await h.mutateAsync({ body: _e({
|
|
255
|
+
values: n,
|
|
256
|
+
billingAddressId: z ?? "",
|
|
257
|
+
unitNamesById: M
|
|
258
|
+
}) });
|
|
259
|
+
b(!1), Y(), e?.id && m?.(e.id, e.type);
|
|
260
|
+
} catch (e) {
|
|
261
|
+
D({ form: t(e) ?? f.genericError });
|
|
262
|
+
}
|
|
263
|
+
}, [
|
|
264
|
+
z,
|
|
265
|
+
U,
|
|
266
|
+
h,
|
|
267
|
+
C,
|
|
268
|
+
X,
|
|
269
|
+
f,
|
|
270
|
+
x,
|
|
271
|
+
m,
|
|
272
|
+
Y,
|
|
273
|
+
j,
|
|
274
|
+
M,
|
|
275
|
+
A.isLoading,
|
|
276
|
+
g,
|
|
277
|
+
T
|
|
278
|
+
]), et = l(() => ({
|
|
279
|
+
...T,
|
|
280
|
+
lineItems: T.lineItems.map(pe)
|
|
281
|
+
}), [T]), tt = l(() => ee(T.lineItems), [T.lineItems]), nt = l(() => De({
|
|
282
|
+
lineItems: T.lineItems.filter((e) => !ae(e)),
|
|
283
|
+
currency: T.currency,
|
|
284
|
+
taxRate: Number(T.taxRate) || void 0
|
|
285
|
+
}), [
|
|
286
|
+
T.currency,
|
|
287
|
+
T.lineItems,
|
|
288
|
+
T.taxRate
|
|
289
|
+
]);
|
|
290
|
+
return {
|
|
291
|
+
open: y,
|
|
292
|
+
setOpen: b,
|
|
293
|
+
mode: x,
|
|
294
|
+
values: T,
|
|
295
|
+
sheetValues: et,
|
|
296
|
+
errors: Me,
|
|
297
|
+
setValues: E,
|
|
298
|
+
updateValues: Ge,
|
|
299
|
+
commitTaxRate: Ke,
|
|
300
|
+
updateLineItem: qe,
|
|
301
|
+
selectProduct: Je,
|
|
302
|
+
commitLineItem: Ye,
|
|
303
|
+
stepLineItem: Xe,
|
|
304
|
+
addLineItem: Ze,
|
|
305
|
+
removeLineItem: Qe,
|
|
306
|
+
attachmentsView: Re,
|
|
307
|
+
attachmentsUploading: B.isUploading,
|
|
308
|
+
saveDisabled: A.isLoading || B.isUploading,
|
|
309
|
+
selectAttachmentFiles: B.selectFiles,
|
|
310
|
+
setAttachmentIncludeInEmail: B.setIncludeInEmail,
|
|
311
|
+
removeAttachment: B.remove,
|
|
312
|
+
autoFocusLineItemId: Pe,
|
|
313
|
+
lineItemUnitOptions: k.unitOptions,
|
|
314
|
+
lineItemsLoading: A.isLoading,
|
|
315
|
+
lineItemControls: tt,
|
|
316
|
+
totals: nt,
|
|
317
|
+
currencySymbol: ie(T.currency),
|
|
318
|
+
isSubmitting: h.isPending || g.isPending,
|
|
319
|
+
currencyOptions: Oe(T.currency),
|
|
320
|
+
paymentTerms: G,
|
|
321
|
+
showBillingSection: T.type === "invoice" || x === "edit",
|
|
322
|
+
showDueDateField: T.type === "quote",
|
|
323
|
+
openCreate: He,
|
|
324
|
+
openEdit: Ue,
|
|
325
|
+
close: We,
|
|
326
|
+
submit: $e,
|
|
327
|
+
units: k,
|
|
328
|
+
counterpartView: O,
|
|
329
|
+
counterpartForm: W,
|
|
330
|
+
stateOptions: L,
|
|
331
|
+
openCounterpartCreate: W.openCreate,
|
|
332
|
+
bankAccount: q
|
|
333
|
+
};
|
|
334
|
+
}
|
|
335
|
+
//#endregion
|
|
336
|
+
export { f as useReceivableForm };
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
"use client";
|
|
3
|
+
"use client";
|
|
4
|
+
"use client";
|
|
5
|
+
import { buildReceivableRows as e, statusFilterOptions as t, typeForTab as n } from "./index9.js";
|
|
6
|
+
import { useReceivablesQuery as r } from "../../data-access/dist/index9.js";
|
|
7
|
+
import "../../data-access/dist/index.js";
|
|
8
|
+
import { useCallback as i, useEffect as a, useMemo as o, useState as s } from "react";
|
|
9
|
+
//#region ../../libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index19.js
|
|
10
|
+
var c = [];
|
|
11
|
+
function l({ activeTab: l, messages: d }) {
|
|
12
|
+
let [f, p] = s([]), [m, h] = s(10), [g, _] = s(), [v, y] = s(""), [b, x] = s(""), [S, C] = s("all");
|
|
13
|
+
a(() => {
|
|
14
|
+
_(void 0), C("all");
|
|
15
|
+
}, [l]), a(() => {
|
|
16
|
+
let e = setTimeout(() => {
|
|
17
|
+
x(v), _(void 0);
|
|
18
|
+
}, 300);
|
|
19
|
+
return () => clearTimeout(e);
|
|
20
|
+
}, [v]);
|
|
21
|
+
let w = f[0]?.id, T = w ? u[w] : void 0, E = f[0] ? f[0].desc ? "desc" : "asc" : void 0, D = r({
|
|
22
|
+
type: n(l),
|
|
23
|
+
limit: m,
|
|
24
|
+
pagination_token: g,
|
|
25
|
+
search_text: b || void 0,
|
|
26
|
+
status: S === "all" ? void 0 : S,
|
|
27
|
+
...T ? {
|
|
28
|
+
sort: T,
|
|
29
|
+
order: E
|
|
30
|
+
} : {}
|
|
31
|
+
}), O = D.data?.data ?? c, k = o(() => new Map(O.map((e) => [e.id, e])), [O]), A = i((e) => k.get(e), [k]), j = o(() => e({
|
|
32
|
+
receivables: O,
|
|
33
|
+
messages: d
|
|
34
|
+
}), [d, O]), M = !!b || S !== "all", N = i((e) => {
|
|
35
|
+
let t = typeof e == "function" ? e(f) : e;
|
|
36
|
+
p(t), _(void 0);
|
|
37
|
+
}, [f]), P = i((e) => {
|
|
38
|
+
h(e), _(void 0);
|
|
39
|
+
}, []), F = i((e) => {
|
|
40
|
+
C(e), _(void 0);
|
|
41
|
+
}, []), I = i(() => _(D.data?.next_pagination_token ?? void 0), [D.data?.next_pagination_token]), L = i(() => _(D.data?.prev_pagination_token ?? void 0), [D.data?.prev_pagination_token]), R = i(() => {
|
|
42
|
+
D.refetch();
|
|
43
|
+
}, [D]);
|
|
44
|
+
return {
|
|
45
|
+
rows: j,
|
|
46
|
+
isLoading: D.isLoading,
|
|
47
|
+
isError: D.isError,
|
|
48
|
+
sorting: f,
|
|
49
|
+
onSortingChange: N,
|
|
50
|
+
pageSize: m,
|
|
51
|
+
onPageSizeChange: P,
|
|
52
|
+
hasNextPage: !!D.data?.next_pagination_token,
|
|
53
|
+
hasPrevPage: !!D.data?.prev_pagination_token,
|
|
54
|
+
onNextPage: I,
|
|
55
|
+
onPrevPage: L,
|
|
56
|
+
searchValue: v,
|
|
57
|
+
onSearchChange: y,
|
|
58
|
+
statusFilter: S,
|
|
59
|
+
statusOptions: t(),
|
|
60
|
+
onStatusFilterChange: F,
|
|
61
|
+
isFiltering: M,
|
|
62
|
+
onRetry: R,
|
|
63
|
+
getReceivableById: A
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
var u = {
|
|
67
|
+
documentLabel: "document_id",
|
|
68
|
+
customerLabel: "counterpart_name",
|
|
69
|
+
status: "status",
|
|
70
|
+
issueDateLabel: "issue_date",
|
|
71
|
+
dueDateLabel: "due_date",
|
|
72
|
+
totalLabel: "total_amount"
|
|
73
|
+
};
|
|
74
|
+
//#endregion
|
|
75
|
+
export { l as useReceivablesTable };
|