@fayz-ai/plugin-financial 0.29.2 → 0.29.4
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/dist/{FinancialPage-LCKLEAM3.js → FinancialPage-S2EBQVIA.js} +84 -62
- package/dist/FinancialPage-S2EBQVIA.js.map +1 -0
- package/dist/{PersonStatementWidget-ULXXXYZ4.js → PersonStatementWidget-JD6FHD4G.js} +23 -12
- package/dist/PersonStatementWidget-JD6FHD4G.js.map +1 -0
- package/dist/{chunk-IQHWMVUM.js → chunk-W7T7RTC4.js} +19 -21
- package/dist/chunk-W7T7RTC4.js.map +1 -0
- package/dist/chunk-XGBGRXZ3.js +28 -0
- package/dist/chunk-XGBGRXZ3.js.map +1 -0
- package/dist/components/BatchClassify.d.ts.map +1 -1
- package/dist/components/ChartOfAccountsTree.d.ts.map +1 -1
- package/dist/components/PersonStatementWidget.d.ts.map +1 -1
- package/dist/components/ReconcileFlow.d.ts.map +1 -1
- package/dist/data/registries.d.ts.map +1 -1
- package/dist/index.js +264 -360
- package/dist/index.js.map +1 -1
- package/dist/lib/chart-tree.d.ts +18 -0
- package/dist/lib/chart-tree.d.ts.map +1 -0
- package/dist/locales/en.d.ts.map +1 -1
- package/dist/locales/pt-BR.d.ts.map +1 -1
- package/dist/views/InvoiceFormView.d.ts.map +1 -1
- package/dist/views/InvoiceListView.d.ts.map +1 -1
- package/dist/views/RecurringBillsView.d.ts.map +1 -1
- package/package.json +5 -5
- package/dist/FinancialPage-LCKLEAM3.js.map +0 -1
- package/dist/PersonStatementWidget-ULXXXYZ4.js.map +0 -1
- package/dist/chunk-IQHWMVUM.js.map +0 -1
package/dist/index.js
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
import { renderCardChip, BankPicker, renderAccountAvatar, PaymentModal, InvoiceFormView, InvoiceDetailView, ACCOUNTS_ROUTE } from './chunk-
|
|
2
|
-
export { FINANCIAL_INVOICE_ZONES } from './chunk-
|
|
1
|
+
import { renderCardChip, BankPicker, renderAccountAvatar, PaymentModal, InvoiceFormView, InvoiceDetailView, ACCOUNTS_ROUTE } from './chunk-W7T7RTC4.js';
|
|
2
|
+
export { FINANCIAL_INVOICE_ZONES } from './chunk-W7T7RTC4.js';
|
|
3
|
+
import './chunk-XGBGRXZ3.js';
|
|
3
4
|
import './chunk-7VKJLBYY.js';
|
|
4
5
|
import { FINANCIAL_MODULE_DEFAULTS } from './chunk-POYZFEAN.js';
|
|
5
6
|
import { FinancialContextProvider, useFinancialProvider, formatCurrency, useFinancialConfig, useFinancialStore } from './chunk-CNXAVGSW.js';
|
|
6
|
-
import * as
|
|
7
|
-
import
|
|
8
|
-
import { CircleDollarSign, FileText,
|
|
7
|
+
import * as React3 from 'react';
|
|
8
|
+
import React3__default, { useEffect } from 'react';
|
|
9
|
+
import { CircleDollarSign, FileText, Wallet, ArrowUpRight, ArrowDownRight, AlertTriangle, EyeOff, Eye, CreditCard } from 'lucide-react';
|
|
9
10
|
import { registerTranslations, tl, recordRailFields, RECORD_GROUP, activeFacet, lazyComponent, createConnectionStore, connectionSettings, connectionStatus, settingsStatus, connectionRuns, useTranslation, resolveDataProvider, emitDataChanged, registerMessageDefaults, countByTenant, onAppPathChange, resolveCurrency } from '@fayz-ai/core';
|
|
10
|
-
import { Button, Badge, Input, ModalTask,
|
|
11
|
+
import { Button, Badge, Input, ModalTask, SegmentedControl, TreeManager, Select, SelectTrigger, SelectValue, SelectContent, SelectItem, SearchSelect, toast, defineKpiWidget, defineChartWidget, defineCustomWidget, defineTableWidget, Modal, ModalContent, ModalHeader, ModalTitle, ModalDescription, ModalBody, KpiCard, ChartWidget, Card, CardHeader, CardTitle, CardContent, TableWidget, useDashboardNavigate, GoldCard } from '@fayz-ai/ui';
|
|
11
12
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
12
13
|
import { createSafeFinancialProvider, createFinancialStore } from '@fayz-ai/financial/store';
|
|
13
14
|
export { createSafeFinancialProvider } from '@fayz-ai/financial/store';
|
|
@@ -15,7 +16,7 @@ import { FINANCIAL_ZONES } from '@fayz-ai/financial/views/zones';
|
|
|
15
16
|
import { draftAllProductsForPriceTable, addAllProductsToPriceTable, fayzConnectorOAuth, defineSettingsTab, RightRailPage, useConnectors, useConnectorsPanelAvailable, SettingsForm, ConnectorMark, StateChip, ConnectorDetail, usePermissionOptional, openConnectorsPanel, createCrudPage, PluginSettingsPanel, useTenantPluginSettings } from '@fayz-ai/admin';
|
|
16
17
|
import { invoiceOpensForEditing } from '@fayz-ai/financial/domain/invoice';
|
|
17
18
|
import { T } from '@fayz-ai/financial/data/tables';
|
|
18
|
-
import { buildChartTree,
|
|
19
|
+
import { buildChartTree, isGroupNode, compareCodes, suggestNextCode, accountLabel, descendantIds, childIds } from '@fayz-ai/financial/domain/chart-of-accounts';
|
|
19
20
|
import { useStore } from 'zustand';
|
|
20
21
|
import { MIGRATIONS } from '#migrations/main';
|
|
21
22
|
export { createMockFinancialProvider } from '@fayz-ai/financial/data/mock';
|
|
@@ -247,7 +248,7 @@ function RecentTransactions() {
|
|
|
247
248
|
const t = useTranslation();
|
|
248
249
|
const { currency } = useFinancialConfig();
|
|
249
250
|
const provider = useFinancialProvider();
|
|
250
|
-
const [invoices, setInvoices] =
|
|
251
|
+
const [invoices, setInvoices] = React3__default.useState([]);
|
|
251
252
|
useEffect(() => {
|
|
252
253
|
let alive = true;
|
|
253
254
|
void provider.getInvoices({ ...RECENT_TRANSACTIONS_QUERY, dateRange: recentWindow() }).then((res) => {
|
|
@@ -290,7 +291,7 @@ function BalanceHero() {
|
|
|
290
291
|
const summary = useFinancialStore((s) => s.summary);
|
|
291
292
|
const navigate = useDashboardNavigate();
|
|
292
293
|
useEnsureSummary();
|
|
293
|
-
const [hidden, setHidden] =
|
|
294
|
+
const [hidden, setHidden] = React3__default.useState(false);
|
|
294
295
|
const money = (v) => hidden ? "\u2022\u2022\u2022\u2022\u2022\u2022" : formatCurrency(v ?? 0, currency);
|
|
295
296
|
const inflow = summary?.monthlyInflow ?? 0;
|
|
296
297
|
const outflow = summary?.monthlyOutflow ?? 0;
|
|
@@ -369,7 +370,7 @@ function categorizeSpend(notes) {
|
|
|
369
370
|
function SpendByCategoryChart() {
|
|
370
371
|
const t = useTranslation();
|
|
371
372
|
const provider = useFinancialProvider();
|
|
372
|
-
const [rows, setRows] =
|
|
373
|
+
const [rows, setRows] = React3__default.useState([]);
|
|
373
374
|
useEffect(() => {
|
|
374
375
|
let alive = true;
|
|
375
376
|
void (async () => {
|
|
@@ -412,7 +413,7 @@ function UpcomingBills() {
|
|
|
412
413
|
const { currency } = useFinancialConfig();
|
|
413
414
|
const provider = useFinancialProvider();
|
|
414
415
|
const dueLabel = useDueLabel();
|
|
415
|
-
const [bills, setBills] =
|
|
416
|
+
const [bills, setBills] = React3__default.useState([]);
|
|
416
417
|
useEffect(() => {
|
|
417
418
|
let alive = true;
|
|
418
419
|
void (async () => {
|
|
@@ -876,6 +877,8 @@ var en = {
|
|
|
876
877
|
"financial.nav.summary": "Summary",
|
|
877
878
|
"financial.invoice.filterAccount": "Chart account",
|
|
878
879
|
"financial.invoice.filterAllAccounts": "All accounts",
|
|
880
|
+
"financial.invoice.filterSearchAccount": "Search account\u2026",
|
|
881
|
+
"financial.invoice.filterNoAccountFound": "No account found",
|
|
879
882
|
"financial.invoice.filterCostCenter": "Cost center",
|
|
880
883
|
"financial.invoice.filterAllCostCenters": "All cost centers",
|
|
881
884
|
"financial.invoice.filterPeriod": "Period",
|
|
@@ -1899,6 +1902,8 @@ var ptBR = {
|
|
|
1899
1902
|
"financial.nav.summary": "Resumo",
|
|
1900
1903
|
"financial.invoice.filterAccount": "Plano de contas",
|
|
1901
1904
|
"financial.invoice.filterAllAccounts": "Todos os planos",
|
|
1905
|
+
"financial.invoice.filterSearchAccount": "Buscar conta\u2026",
|
|
1906
|
+
"financial.invoice.filterNoAccountFound": "Nenhuma conta encontrada",
|
|
1902
1907
|
"financial.invoice.filterCostCenter": "Centro de custo",
|
|
1903
1908
|
"financial.invoice.filterAllCostCenters": "Todos os centros",
|
|
1904
1909
|
"financial.invoice.filterPeriod": "Per\xEDodo",
|
|
@@ -2698,8 +2703,8 @@ function ReceivePaymentModal({
|
|
|
2698
2703
|
onClose,
|
|
2699
2704
|
onPaid
|
|
2700
2705
|
}) {
|
|
2701
|
-
const provider =
|
|
2702
|
-
const store6 =
|
|
2706
|
+
const provider = React3__default.useMemo(() => createSafeFinancialProvider(), []);
|
|
2707
|
+
const store6 = React3__default.useMemo(() => createFinancialStore(provider), [provider]);
|
|
2703
2708
|
return /* @__PURE__ */ jsx(FinancialContextProvider, { config: STANDALONE_CONFIG, provider, store: store6, children: /* @__PURE__ */ jsx(
|
|
2704
2709
|
PaymentModal,
|
|
2705
2710
|
{
|
|
@@ -2733,27 +2738,27 @@ function ClientAccountPanel({
|
|
|
2733
2738
|
currency = BRL
|
|
2734
2739
|
}) {
|
|
2735
2740
|
const provider = useFinancialProvider();
|
|
2736
|
-
const [account, setAccount] =
|
|
2737
|
-
const [busy, setBusy] =
|
|
2738
|
-
const [viewInvoiceId, setViewInvoiceId] =
|
|
2739
|
-
const [comprando, setComprando] =
|
|
2740
|
-
const [buscaServico, setBuscaServico] =
|
|
2741
|
-
const [catalogo, setCatalogo] =
|
|
2742
|
-
const [escolhidos, setEscolhidos] =
|
|
2743
|
-
const [comprandoBusy, setComprandoBusy] =
|
|
2744
|
-
const [erroCompra, setErroCompra] =
|
|
2745
|
-
const load =
|
|
2741
|
+
const [account, setAccount] = React3__default.useState(null);
|
|
2742
|
+
const [busy, setBusy] = React3__default.useState(false);
|
|
2743
|
+
const [viewInvoiceId, setViewInvoiceId] = React3__default.useState(null);
|
|
2744
|
+
const [comprando, setComprando] = React3__default.useState(false);
|
|
2745
|
+
const [buscaServico, setBuscaServico] = React3__default.useState("");
|
|
2746
|
+
const [catalogo, setCatalogo] = React3__default.useState([]);
|
|
2747
|
+
const [escolhidos, setEscolhidos] = React3__default.useState([]);
|
|
2748
|
+
const [comprandoBusy, setComprandoBusy] = React3__default.useState(false);
|
|
2749
|
+
const [erroCompra, setErroCompra] = React3__default.useState(null);
|
|
2750
|
+
const load = React3__default.useCallback(async () => {
|
|
2746
2751
|
if (!personId) return;
|
|
2747
2752
|
setAccount(await provider.getClientAccount(personId));
|
|
2748
2753
|
}, [personId, provider]);
|
|
2749
|
-
|
|
2754
|
+
React3__default.useEffect(() => {
|
|
2750
2755
|
void load();
|
|
2751
2756
|
}, [load]);
|
|
2752
2757
|
const viewInvoice = account?.invoices.find((i) => i.id === viewInvoiceId) ?? null;
|
|
2753
2758
|
const viewEditable = invoiceOpensForEditing(viewInvoice?.status);
|
|
2754
2759
|
const forThis = account?.invoices.filter((i) => orderId && i.orderId === orderId) ?? [];
|
|
2755
2760
|
const hasForThis = forThis.length > 0;
|
|
2756
|
-
|
|
2761
|
+
React3__default.useEffect(() => {
|
|
2757
2762
|
if (!comprando) return;
|
|
2758
2763
|
let vivo = true;
|
|
2759
2764
|
const t = setTimeout(async () => {
|
|
@@ -3042,8 +3047,8 @@ function ClientAccountPanel({
|
|
|
3042
3047
|
] });
|
|
3043
3048
|
}
|
|
3044
3049
|
function ClientAccountInline(props) {
|
|
3045
|
-
const provider =
|
|
3046
|
-
const store6 =
|
|
3050
|
+
const provider = React3__default.useMemo(() => createSafeFinancialProvider(), []);
|
|
3051
|
+
const store6 = React3__default.useMemo(() => createFinancialStore(provider), [provider]);
|
|
3047
3052
|
return /* @__PURE__ */ jsx(FinancialContextProvider, { config: STANDALONE_CONFIG, provider, store: store6, children: /* @__PURE__ */ jsx(ClientAccountPanel, { ...props }) });
|
|
3048
3053
|
}
|
|
3049
3054
|
function ClientAccountModal({
|
|
@@ -3128,371 +3133,265 @@ function ChartOfAccountsTree({ entity, mockData, dataProvider, embedded }) {
|
|
|
3128
3133
|
const canCreate = can("financial", "create");
|
|
3129
3134
|
const canEdit = can("financial", "edit");
|
|
3130
3135
|
const canDelete = can("financial", "delete");
|
|
3131
|
-
const provider =
|
|
3136
|
+
const provider = React3__default.useMemo(
|
|
3132
3137
|
() => dataProvider ?? resolveDataProvider(entity, mockData ?? []),
|
|
3133
3138
|
[entity, mockData, dataProvider]
|
|
3134
3139
|
);
|
|
3135
3140
|
const table = entity.data?.table;
|
|
3136
|
-
const [nodes, setNodes] =
|
|
3137
|
-
const [loadError, setLoadError] =
|
|
3138
|
-
const [
|
|
3139
|
-
const [
|
|
3140
|
-
const [
|
|
3141
|
-
const
|
|
3142
|
-
const [editing, setEditing] = React5__default.useState(null);
|
|
3143
|
-
const [confirmDelete, setConfirmDelete] = React5__default.useState(null);
|
|
3144
|
-
const [busy, setBusy] = React5__default.useState(false);
|
|
3145
|
-
const initialized = React5__default.useRef(false);
|
|
3146
|
-
const reload = React5__default.useCallback(async () => {
|
|
3141
|
+
const [nodes, setNodes] = React3__default.useState(null);
|
|
3142
|
+
const [loadError, setLoadError] = React3__default.useState(null);
|
|
3143
|
+
const [side, setSide] = React3__default.useState("in");
|
|
3144
|
+
const [editing, setEditing] = React3__default.useState(null);
|
|
3145
|
+
const [busy, setBusy] = React3__default.useState(false);
|
|
3146
|
+
const reload = React3__default.useCallback(async () => {
|
|
3147
3147
|
try {
|
|
3148
|
-
|
|
3149
|
-
setNodes(rows);
|
|
3148
|
+
setNodes(await loadAll(provider));
|
|
3150
3149
|
setLoadError(null);
|
|
3151
|
-
if (!initialized.current) {
|
|
3152
|
-
initialized.current = true;
|
|
3153
|
-
const tree2 = buildChartTree(rows);
|
|
3154
|
-
setExpanded(new Set(rootIds(tree2)));
|
|
3155
|
-
}
|
|
3156
3150
|
} catch (err) {
|
|
3157
3151
|
setLoadError(errorMessage(err));
|
|
3158
3152
|
setNodes((prev) => prev ?? []);
|
|
3159
3153
|
}
|
|
3160
3154
|
}, [provider]);
|
|
3161
|
-
|
|
3155
|
+
React3__default.useEffect(() => {
|
|
3162
3156
|
void reload();
|
|
3163
3157
|
}, [reload]);
|
|
3164
|
-
const shown =
|
|
3165
|
-
|
|
3166
|
-
|
|
3167
|
-
|
|
3168
|
-
|
|
3169
|
-
|
|
3170
|
-
|
|
3171
|
-
|
|
3172
|
-
|
|
3173
|
-
|
|
3174
|
-
|
|
3175
|
-
|
|
3176
|
-
|
|
3177
|
-
|
|
3178
|
-
|
|
3179
|
-
|
|
3180
|
-
return next;
|
|
3181
|
-
});
|
|
3158
|
+
const shown = React3__default.useMemo(() => nodes === null ? null : onSide(nodes, side), [nodes, side]);
|
|
3159
|
+
const fullTree = React3__default.useMemo(() => buildChartTree(nodes ?? []), [nodes]);
|
|
3160
|
+
async function run(action, success) {
|
|
3161
|
+
setBusy(true);
|
|
3162
|
+
try {
|
|
3163
|
+
await action();
|
|
3164
|
+
if (table) emitDataChanged({ table });
|
|
3165
|
+
toast.success(success);
|
|
3166
|
+
await reload();
|
|
3167
|
+
return true;
|
|
3168
|
+
} catch (err) {
|
|
3169
|
+
toast.error(t("financial.chartTree.error.save"), { description: errorMessage(err) });
|
|
3170
|
+
return false;
|
|
3171
|
+
} finally {
|
|
3172
|
+
setBusy(false);
|
|
3173
|
+
}
|
|
3182
3174
|
}
|
|
3183
|
-
|
|
3184
|
-
|
|
3185
|
-
|
|
3186
|
-
|
|
3187
|
-
|
|
3188
|
-
|
|
3189
|
-
|
|
3190
|
-
|
|
3191
|
-
|
|
3192
|
-
|
|
3193
|
-
|
|
3194
|
-
|
|
3175
|
+
const hasOther = (nodes ?? []).some((n) => sideOf(n.accountType) === "other");
|
|
3176
|
+
const plural = (one, many) => (n) => t(n === 1 ? one : many, { count: n });
|
|
3177
|
+
return /* @__PURE__ */ jsxs("div", { className: "space-y-3", children: [
|
|
3178
|
+
/* @__PURE__ */ jsx(
|
|
3179
|
+
SegmentedControl,
|
|
3180
|
+
{
|
|
3181
|
+
value: side,
|
|
3182
|
+
onChange: (v) => {
|
|
3183
|
+
setSide(v);
|
|
3184
|
+
setEditing(null);
|
|
3185
|
+
},
|
|
3186
|
+
options: [
|
|
3187
|
+
{ value: "in", label: tl("Income (in)", "Receitas (entradas)") },
|
|
3188
|
+
{ value: "out", label: tl("Expenses (out)", "Despesas (sa\xEDdas)") },
|
|
3189
|
+
...hasOther ? [{ value: "other", label: tl("Balance", "Patrimoniais") }] : []
|
|
3190
|
+
]
|
|
3195
3191
|
}
|
|
3196
|
-
|
|
3197
|
-
|
|
3198
|
-
|
|
3199
|
-
|
|
3200
|
-
|
|
3201
|
-
|
|
3202
|
-
|
|
3203
|
-
|
|
3204
|
-
|
|
3192
|
+
),
|
|
3193
|
+
/* @__PURE__ */ jsx(
|
|
3194
|
+
TreeManager,
|
|
3195
|
+
{
|
|
3196
|
+
nodes: shown,
|
|
3197
|
+
getId: (n) => n.id,
|
|
3198
|
+
getParentId: (n) => n.parentId,
|
|
3199
|
+
getName: (n) => n.name,
|
|
3200
|
+
getCode: (n) => n.code,
|
|
3201
|
+
isActive: (n) => n.isActive,
|
|
3202
|
+
compare: (a, b) => compareCodes(a.code, b.code),
|
|
3203
|
+
isGroup: (n, hasChildren) => n.nodeType === "group" || hasChildren,
|
|
3204
|
+
loadError: loadError ? `${t("financial.chartTree.error.load")} ${loadError}` : null,
|
|
3205
|
+
busy,
|
|
3206
|
+
embedded,
|
|
3207
|
+
canCreate,
|
|
3208
|
+
canEdit,
|
|
3209
|
+
canRemove: canDelete,
|
|
3210
|
+
canAddChild: (n) => n.isActive && isGroupNode(fullTree, n),
|
|
3211
|
+
canDeactivate: (_n, hasChildren) => !hasChildren,
|
|
3212
|
+
onSetActive: (node, isActive) => run(
|
|
3213
|
+
() => provider.update(node.id, { isActive }),
|
|
3214
|
+
t(isActive ? "financial.chartTree.reactivated" : "financial.chartTree.deactivated", { name: node.name })
|
|
3215
|
+
),
|
|
3216
|
+
onDelete: (node) => run(() => provider.remove(node.id), t("financial.chartTree.deleted", { name: node.name })),
|
|
3217
|
+
editing,
|
|
3218
|
+
onEditingChange: setEditing,
|
|
3219
|
+
renderBadges: (n) => n.accountType && /* @__PURE__ */ jsx(Badge, { variant: NATURE_VARIANT[n.accountType] ?? "default", dot: false, children: t(`financial.chartTree.nature.${n.accountType}`) }),
|
|
3220
|
+
renderEditor: (ctx) => /* @__PURE__ */ jsx(
|
|
3221
|
+
AccountEditor,
|
|
3222
|
+
{
|
|
3223
|
+
ctx,
|
|
3224
|
+
nodes: nodes ?? [],
|
|
3225
|
+
fullTree,
|
|
3226
|
+
side,
|
|
3227
|
+
busy,
|
|
3228
|
+
onSave: (id, payload) => id ? run(() => provider.update(id, payload), t("financial.chartTree.updated", { name: payload.name })) : run(() => provider.create({ ...payload, isActive: true }), t("financial.chartTree.created", { name: payload.name }))
|
|
3229
|
+
}
|
|
3230
|
+
),
|
|
3231
|
+
labels: {
|
|
3232
|
+
searchPlaceholder: t("financial.chartTree.searchPlaceholder"),
|
|
3233
|
+
clearSearch: t("financial.chartTree.clearSearch"),
|
|
3234
|
+
expandAll: t("financial.chartTree.expandAll"),
|
|
3235
|
+
collapseAll: t("financial.chartTree.collapseAll"),
|
|
3236
|
+
expand: t("financial.chartTree.expand"),
|
|
3237
|
+
collapse: t("financial.chartTree.collapse"),
|
|
3238
|
+
addRoot: t("financial.chartTree.addRoot"),
|
|
3239
|
+
addChild: t("financial.chartTree.addChild"),
|
|
3240
|
+
edit: t("financial.chartTree.edit"),
|
|
3241
|
+
deactivate: t("financial.chartTree.deactivate"),
|
|
3242
|
+
reactivate: t("financial.chartTree.reactivate"),
|
|
3243
|
+
delete: t("financial.chartTree.delete"),
|
|
3244
|
+
confirmDelete: t("financial.chartTree.confirmDelete"),
|
|
3245
|
+
cancel: t("financial.chartTree.cancel"),
|
|
3246
|
+
inactive: t("financial.chartTree.inactive"),
|
|
3247
|
+
empty: t("financial.chartTree.empty"),
|
|
3248
|
+
noMatches: t("financial.chartTree.noMatches"),
|
|
3249
|
+
tree: t("registry.chart-of-accounts"),
|
|
3250
|
+
count: plural("financial.chartTree.countOne", "financial.chartTree.count"),
|
|
3251
|
+
matches: plural("financial.chartTree.matchesOne", "financial.chartTree.matches"),
|
|
3252
|
+
showInactive: (n) => t("financial.chartTree.showInactive", { count: n })
|
|
3253
|
+
}
|
|
3254
|
+
}
|
|
3255
|
+
)
|
|
3256
|
+
] });
|
|
3257
|
+
}
|
|
3258
|
+
function AccountEditor({ ctx, nodes, fullTree, side, busy, onSave }) {
|
|
3259
|
+
const t = useTranslation();
|
|
3260
|
+
const selfId = ctx.editing.mode === "edit" ? ctx.editing.id : void 0;
|
|
3261
|
+
const [draft, setDraft] = React3__default.useState(() => {
|
|
3262
|
+
const node = ctx.node;
|
|
3263
|
+
if (node) {
|
|
3264
|
+
return {
|
|
3205
3265
|
code: node.code,
|
|
3206
3266
|
name: node.name,
|
|
3207
3267
|
nodeType: node.nodeType === "group" ? "group" : "leaf",
|
|
3208
3268
|
accountType: node.accountType ?? "",
|
|
3209
3269
|
parentId: node.parentId ?? null
|
|
3210
|
-
}
|
|
3211
|
-
}
|
|
3212
|
-
|
|
3213
|
-
|
|
3270
|
+
};
|
|
3271
|
+
}
|
|
3272
|
+
const parent2 = ctx.parentId ? fullTree.byId.get(ctx.parentId) : void 0;
|
|
3273
|
+
return {
|
|
3274
|
+
code: suggestNextCode(fullTree, ctx.parentId),
|
|
3275
|
+
name: "",
|
|
3276
|
+
nodeType: "leaf",
|
|
3277
|
+
accountType: parent2?.accountType ?? SIDE_TYPE[side],
|
|
3278
|
+
parentId: ctx.parentId
|
|
3279
|
+
};
|
|
3280
|
+
});
|
|
3281
|
+
const update = (patch) => setDraft((prev) => ({ ...prev, ...patch }));
|
|
3282
|
+
const parent = draft.parentId ? fullTree.byId.get(draft.parentId) : void 0;
|
|
3283
|
+
function validate() {
|
|
3214
3284
|
const code = draft.code.trim();
|
|
3215
3285
|
if (!code) return t("financial.chartTree.error.codeRequired");
|
|
3216
3286
|
if (!draft.name.trim()) return t("financial.chartTree.error.nameRequired");
|
|
3217
|
-
const clash =
|
|
3287
|
+
const clash = nodes.find((n) => n.code === code && n.id !== selfId);
|
|
3218
3288
|
if (clash) return t("financial.chartTree.error.codeTaken", { code, name: clash.name });
|
|
3219
3289
|
if (selfId && draft.nodeType === "leaf" && childIds(fullTree, selfId).length > 0) {
|
|
3220
3290
|
return t("financial.chartTree.error.leafWithChildren");
|
|
3221
3291
|
}
|
|
3222
3292
|
return null;
|
|
3223
3293
|
}
|
|
3224
|
-
async function run(action, success) {
|
|
3225
|
-
setBusy(true);
|
|
3226
|
-
try {
|
|
3227
|
-
await action();
|
|
3228
|
-
if (table) emitDataChanged({ table });
|
|
3229
|
-
toast.success(success);
|
|
3230
|
-
await reload();
|
|
3231
|
-
return true;
|
|
3232
|
-
} catch (err) {
|
|
3233
|
-
toast.error(t("financial.chartTree.error.save"), { description: errorMessage(err) });
|
|
3234
|
-
return false;
|
|
3235
|
-
} finally {
|
|
3236
|
-
setBusy(false);
|
|
3237
|
-
}
|
|
3238
|
-
}
|
|
3239
3294
|
async function submit() {
|
|
3240
|
-
|
|
3241
|
-
const { draft } = editing;
|
|
3242
|
-
const invalid = validate(draft, editing.mode === "edit" ? editing.id : void 0);
|
|
3295
|
+
const invalid = validate();
|
|
3243
3296
|
if (invalid) {
|
|
3244
3297
|
toast.error(invalid);
|
|
3245
3298
|
return;
|
|
3246
3299
|
}
|
|
3247
|
-
const
|
|
3300
|
+
const ok = await onSave(selfId ?? null, {
|
|
3248
3301
|
code: draft.code.trim(),
|
|
3249
3302
|
name: draft.name.trim(),
|
|
3250
3303
|
nodeType: draft.nodeType,
|
|
3251
3304
|
accountType: draft.accountType || null,
|
|
3252
3305
|
parentId: draft.parentId
|
|
3253
|
-
};
|
|
3254
|
-
|
|
3255
|
-
if (ok) setEditing(null);
|
|
3256
|
-
}
|
|
3257
|
-
async function setActive(node, isActive) {
|
|
3258
|
-
await run(
|
|
3259
|
-
() => provider.update(node.id, { isActive }),
|
|
3260
|
-
t(isActive ? "financial.chartTree.reactivated" : "financial.chartTree.deactivated", { name: node.name })
|
|
3261
|
-
);
|
|
3262
|
-
}
|
|
3263
|
-
async function remove(node) {
|
|
3264
|
-
const ok = await run(() => provider.remove(node.id), t("financial.chartTree.deleted", { name: node.name }));
|
|
3265
|
-
if (ok) setConfirmDelete(null);
|
|
3306
|
+
});
|
|
3307
|
+
if (ok) ctx.close();
|
|
3266
3308
|
}
|
|
3267
|
-
const parentOptions =
|
|
3309
|
+
const parentOptions = (q) => {
|
|
3268
3310
|
const blocked = selfId ? descendantIds(fullTree, selfId).add(selfId) : /* @__PURE__ */ new Set();
|
|
3269
3311
|
const needle = q.trim().toLowerCase();
|
|
3270
|
-
return [...fullTree.byId.values()].filter((n) => !blocked.has(n.id) && isGroupNode(fullTree, n)).filter((n) => !needle || accountLabel(n).toLowerCase().includes(needle)).sort((a, b) => a.code
|
|
3271
|
-
}
|
|
3272
|
-
|
|
3273
|
-
|
|
3274
|
-
|
|
3275
|
-
|
|
3276
|
-
|
|
3277
|
-
|
|
3278
|
-
|
|
3279
|
-
|
|
3280
|
-
|
|
3281
|
-
|
|
3282
|
-
|
|
3283
|
-
|
|
3284
|
-
|
|
3285
|
-
|
|
3286
|
-
|
|
3287
|
-
|
|
3288
|
-
|
|
3289
|
-
|
|
3290
|
-
|
|
3291
|
-
|
|
3292
|
-
|
|
3293
|
-
void submit();
|
|
3294
|
-
}
|
|
3295
|
-
},
|
|
3296
|
-
children: [
|
|
3297
|
-
/* @__PURE__ */ jsxs("div", { className: "grid gap-3 sm:grid-cols-[8rem_1fr]", children: [
|
|
3298
|
-
/* @__PURE__ */ jsxs("label", { className: "space-y-1 text-xs font-medium text-muted-foreground", children: [
|
|
3299
|
-
t("financial.chartTree.field.code"),
|
|
3300
|
-
/* @__PURE__ */ jsx(Input, { "data-submit-on-enter": "1", value: draft.code, onChange: (e) => update({ code: e.target.value }), required: true })
|
|
3301
|
-
] }),
|
|
3302
|
-
/* @__PURE__ */ jsxs("label", { className: "space-y-1 text-xs font-medium text-muted-foreground", children: [
|
|
3303
|
-
t("financial.chartTree.field.name"),
|
|
3304
|
-
/* @__PURE__ */ jsx(Input, { "data-submit-on-enter": "1", autoFocus: true, value: draft.name, onChange: (e) => update({ name: e.target.value }), required: true })
|
|
3305
|
-
] })
|
|
3312
|
+
return [...fullTree.byId.values()].filter((n) => !blocked.has(n.id) && isGroupNode(fullTree, n)).filter((n) => !needle || accountLabel(n).toLowerCase().includes(needle)).sort((a, b) => compareCodes(a.code, b.code)).slice(0, 50).map((n) => ({ id: n.id, label: accountLabel(n) }));
|
|
3313
|
+
};
|
|
3314
|
+
return (
|
|
3315
|
+
// Not a <form>: Enter would "click" the first button inside SearchSelect
|
|
3316
|
+
// (its clear action) and wipe the parent instead of saving.
|
|
3317
|
+
/* @__PURE__ */ jsxs(
|
|
3318
|
+
"div",
|
|
3319
|
+
{
|
|
3320
|
+
role: "group",
|
|
3321
|
+
className: "rounded-md border border-border bg-muted/40 p-3 space-y-3",
|
|
3322
|
+
style: { marginLeft: Math.min(ctx.level, 8) * 16 },
|
|
3323
|
+
onKeyDown: (e) => {
|
|
3324
|
+
if (e.key === "Escape") ctx.close();
|
|
3325
|
+
if (e.key === "Enter" && e.target.dataset.submitOnEnter) {
|
|
3326
|
+
e.preventDefault();
|
|
3327
|
+
void submit();
|
|
3328
|
+
}
|
|
3329
|
+
},
|
|
3330
|
+
children: [
|
|
3331
|
+
/* @__PURE__ */ jsxs("div", { className: "grid gap-3 sm:grid-cols-[8rem_1fr]", children: [
|
|
3332
|
+
/* @__PURE__ */ jsxs("label", { className: "space-y-1 text-xs font-medium text-muted-foreground", children: [
|
|
3333
|
+
t("financial.chartTree.field.code"),
|
|
3334
|
+
/* @__PURE__ */ jsx(Input, { "data-submit-on-enter": "1", value: draft.code, onChange: (e) => update({ code: e.target.value }), required: true })
|
|
3306
3335
|
] }),
|
|
3307
|
-
/* @__PURE__ */ jsxs("
|
|
3308
|
-
|
|
3309
|
-
|
|
3310
|
-
|
|
3311
|
-
|
|
3312
|
-
|
|
3313
|
-
|
|
3314
|
-
|
|
3315
|
-
|
|
3336
|
+
/* @__PURE__ */ jsxs("label", { className: "space-y-1 text-xs font-medium text-muted-foreground", children: [
|
|
3337
|
+
t("financial.chartTree.field.name"),
|
|
3338
|
+
/* @__PURE__ */ jsx(Input, { "data-submit-on-enter": "1", autoFocus: true, value: draft.name, onChange: (e) => update({ name: e.target.value }), required: true })
|
|
3339
|
+
] })
|
|
3340
|
+
] }),
|
|
3341
|
+
/* @__PURE__ */ jsxs("div", { className: "grid gap-3 sm:grid-cols-3", children: [
|
|
3342
|
+
/* @__PURE__ */ jsxs("label", { className: "space-y-1 text-xs font-medium text-muted-foreground", children: [
|
|
3343
|
+
t("financial.chartTree.field.structure"),
|
|
3344
|
+
/* @__PURE__ */ jsxs(Select, { value: draft.nodeType, onValueChange: (v) => update({ nodeType: v }), children: [
|
|
3345
|
+
/* @__PURE__ */ jsx(SelectTrigger, { className: "px-2 font-normal text-foreground", children: /* @__PURE__ */ jsx(SelectValue, {}) }),
|
|
3346
|
+
/* @__PURE__ */ jsxs(SelectContent, { children: [
|
|
3347
|
+
/* @__PURE__ */ jsx(SelectItem, { value: "leaf", children: t("financial.chartTree.leaf") }),
|
|
3348
|
+
/* @__PURE__ */ jsx(SelectItem, { value: "group", children: t("financial.chartTree.group") })
|
|
3316
3349
|
] })
|
|
3317
|
-
] }),
|
|
3318
|
-
/* @__PURE__ */ jsxs("label", { className: "space-y-1 text-xs font-medium text-muted-foreground", children: [
|
|
3319
|
-
t("financial.chartTree.field.nature"),
|
|
3320
|
-
/* @__PURE__ */ jsxs(
|
|
3321
|
-
Select,
|
|
3322
|
-
{
|
|
3323
|
-
value: draft.accountType || NO_NATURE,
|
|
3324
|
-
onValueChange: (v) => update({ accountType: v === NO_NATURE ? "" : v }),
|
|
3325
|
-
children: [
|
|
3326
|
-
/* @__PURE__ */ jsx(SelectTrigger, { className: "px-2 font-normal text-foreground", children: /* @__PURE__ */ jsx(SelectValue, {}) }),
|
|
3327
|
-
/* @__PURE__ */ jsxs(SelectContent, { children: [
|
|
3328
|
-
/* @__PURE__ */ jsx(SelectItem, { value: NO_NATURE, children: t("financial.chartTree.nature.none") }),
|
|
3329
|
-
NATURES.map((n) => /* @__PURE__ */ jsx(SelectItem, { value: n, children: t(`financial.chartTree.nature.${n}`) }, n))
|
|
3330
|
-
] })
|
|
3331
|
-
]
|
|
3332
|
-
}
|
|
3333
|
-
)
|
|
3334
|
-
] }),
|
|
3335
|
-
/* @__PURE__ */ jsxs("div", { className: "space-y-1 text-xs font-medium text-muted-foreground", children: [
|
|
3336
|
-
t("financial.chartTree.field.parent"),
|
|
3337
|
-
/* @__PURE__ */ jsx(
|
|
3338
|
-
SearchSelect,
|
|
3339
|
-
{
|
|
3340
|
-
value: draft.parentId ?? void 0,
|
|
3341
|
-
displayValue: parent ? accountLabel(parent) : void 0,
|
|
3342
|
-
onChange: (id) => update({ parentId: id || null }),
|
|
3343
|
-
onSearch: (q) => parentOptions(q, selfId),
|
|
3344
|
-
minChars: 0,
|
|
3345
|
-
placeholder: t("financial.chartTree.rootLevel"),
|
|
3346
|
-
noResultsLabel: t("financial.chartTree.noGroups"),
|
|
3347
|
-
searchingLabel: t("financial.chartTree.searching"),
|
|
3348
|
-
clearLabel: t("financial.chartTree.rootLevel")
|
|
3349
|
-
}
|
|
3350
|
-
)
|
|
3351
3350
|
] })
|
|
3352
3351
|
] }),
|
|
3353
|
-
/* @__PURE__ */ jsxs("
|
|
3354
|
-
|
|
3355
|
-
/* @__PURE__ */
|
|
3356
|
-
|
|
3357
|
-
|
|
3358
|
-
|
|
3359
|
-
|
|
3360
|
-
|
|
3361
|
-
|
|
3362
|
-
|
|
3363
|
-
|
|
3364
|
-
|
|
3365
|
-
|
|
3366
|
-
|
|
3367
|
-
|
|
3368
|
-
|
|
3369
|
-
const isMatch = search?.matches.has(id);
|
|
3370
|
-
const hasAnyChildren = childIds(fullTree, id).length > 0;
|
|
3371
|
-
const FolderIcon = open ? FolderOpen : Folder;
|
|
3372
|
-
return /* @__PURE__ */ jsxs("li", { role: "treeitem", "aria-level": level + 1, "aria-expanded": group ? open : void 0, children: [
|
|
3373
|
-
isEditingThis && editing ? renderForm(editing.draft, level, id) : /* @__PURE__ */ jsxs(
|
|
3374
|
-
"div",
|
|
3375
|
-
{
|
|
3376
|
-
className: "group/row flex min-h-10 items-center gap-2 rounded-md px-2 py-1 hover:bg-muted/60 " + (node.isActive ? "" : "opacity-60"),
|
|
3377
|
-
style: { paddingLeft: 8 + Math.min(level, 8) * 16 },
|
|
3378
|
-
children: [
|
|
3379
|
-
/* @__PURE__ */ jsx(
|
|
3380
|
-
Button,
|
|
3381
|
-
{
|
|
3382
|
-
variant: "bare",
|
|
3383
|
-
size: "bare",
|
|
3384
|
-
type: "button",
|
|
3385
|
-
className: "flex h-6 w-6 shrink-0 items-center justify-center rounded text-muted-foreground hover:bg-muted " + (kids.length ? "" : "invisible"),
|
|
3386
|
-
onClick: () => toggle(id),
|
|
3387
|
-
"aria-label": open ? t("financial.chartTree.collapse") : t("financial.chartTree.expand"),
|
|
3388
|
-
disabled: !!search,
|
|
3389
|
-
children: /* @__PURE__ */ jsx(ChevronRight, { className: "h-4 w-4 transition-transform " + (open ? "rotate-90" : "") })
|
|
3390
|
-
}
|
|
3391
|
-
),
|
|
3392
|
-
group ? /* @__PURE__ */ jsx(FolderIcon, { className: "h-4 w-4 shrink-0 text-muted-foreground" }) : /* @__PURE__ */ jsx(FileText, { className: "h-4 w-4 shrink-0 text-muted-foreground" }),
|
|
3393
|
-
/* @__PURE__ */ jsx("span", { className: "shrink-0 font-mono text-xs tabular-nums text-muted-foreground", children: node.code }),
|
|
3394
|
-
/* @__PURE__ */ jsx("span", { className: "min-w-0 flex-1 truncate text-sm " + (group ? "font-semibold" : "") + (isMatch ? " text-primary" : ""), children: node.name }),
|
|
3395
|
-
/* @__PURE__ */ jsxs("span", { className: "hidden shrink-0 items-center gap-1 sm:flex", children: [
|
|
3396
|
-
node.accountType && /* @__PURE__ */ jsx(Badge, { variant: NATURE_VARIANT[node.accountType] ?? "default", dot: false, children: t(`financial.chartTree.nature.${node.accountType}`) }),
|
|
3397
|
-
!node.isActive && /* @__PURE__ */ jsx(Badge, { variant: "outline", children: t("financial.chartTree.inactive") })
|
|
3352
|
+
/* @__PURE__ */ jsxs("label", { className: "space-y-1 text-xs font-medium text-muted-foreground", children: [
|
|
3353
|
+
t("financial.chartTree.field.nature"),
|
|
3354
|
+
/* @__PURE__ */ jsxs(
|
|
3355
|
+
Select,
|
|
3356
|
+
{
|
|
3357
|
+
value: draft.accountType || NO_NATURE,
|
|
3358
|
+
onValueChange: (v) => update({ accountType: v === NO_NATURE ? "" : v }),
|
|
3359
|
+
children: [
|
|
3360
|
+
/* @__PURE__ */ jsx(SelectTrigger, { className: "px-2 font-normal text-foreground", children: /* @__PURE__ */ jsx(SelectValue, {}) }),
|
|
3361
|
+
/* @__PURE__ */ jsxs(SelectContent, { children: [
|
|
3362
|
+
/* @__PURE__ */ jsx(SelectItem, { value: NO_NATURE, children: t("financial.chartTree.nature.none") }),
|
|
3363
|
+
NATURES.map((n) => /* @__PURE__ */ jsx(SelectItem, { value: n, children: t(`financial.chartTree.nature.${n}`) }, n))
|
|
3364
|
+
] })
|
|
3365
|
+
]
|
|
3366
|
+
}
|
|
3367
|
+
)
|
|
3398
3368
|
] }),
|
|
3399
|
-
|
|
3400
|
-
|
|
3401
|
-
/* @__PURE__ */ jsx(
|
|
3402
|
-
|
|
3403
|
-
|
|
3404
|
-
|
|
3405
|
-
|
|
3406
|
-
|
|
3407
|
-
|
|
3408
|
-
|
|
3409
|
-
|
|
3410
|
-
|
|
3411
|
-
|
|
3369
|
+
/* @__PURE__ */ jsxs("div", { className: "space-y-1 text-xs font-medium text-muted-foreground", children: [
|
|
3370
|
+
t("financial.chartTree.field.parent"),
|
|
3371
|
+
/* @__PURE__ */ jsx(
|
|
3372
|
+
SearchSelect,
|
|
3373
|
+
{
|
|
3374
|
+
value: draft.parentId ?? void 0,
|
|
3375
|
+
displayValue: parent ? accountLabel(parent) : void 0,
|
|
3376
|
+
onChange: (id) => update({ parentId: id || null }),
|
|
3377
|
+
onSearch: parentOptions,
|
|
3378
|
+
minChars: 0,
|
|
3379
|
+
placeholder: t("financial.chartTree.rootLevel"),
|
|
3380
|
+
noResultsLabel: t("financial.chartTree.noGroups"),
|
|
3381
|
+
searchingLabel: t("financial.chartTree.searching"),
|
|
3382
|
+
clearLabel: t("financial.chartTree.rootLevel")
|
|
3383
|
+
}
|
|
3384
|
+
)
|
|
3412
3385
|
] })
|
|
3413
|
-
]
|
|
3414
|
-
|
|
3415
|
-
|
|
3416
|
-
|
|
3417
|
-
|
|
3418
|
-
kids.map((c) => renderNode(c, level + 1))
|
|
3419
|
-
] })
|
|
3420
|
-
] }, id);
|
|
3421
|
-
}
|
|
3422
|
-
const hasOther = (nodes ?? []).some((n) => sideOf(n.accountType) === "other");
|
|
3423
|
-
return /* @__PURE__ */ jsxs("div", { className: "space-y-3", children: [
|
|
3424
|
-
/* @__PURE__ */ jsx(
|
|
3425
|
-
SegmentedControl,
|
|
3426
|
-
{
|
|
3427
|
-
value: side,
|
|
3428
|
-
onChange: (v) => {
|
|
3429
|
-
setSide(v);
|
|
3430
|
-
setEditing(null);
|
|
3431
|
-
},
|
|
3432
|
-
options: [
|
|
3433
|
-
{ value: "in", label: tl("Income (in)", "Receitas (entradas)") },
|
|
3434
|
-
{ value: "out", label: tl("Expenses (out)", "Despesas (sa\xEDdas)") },
|
|
3435
|
-
...hasOther ? [{ value: "other", label: tl("Balance", "Patrimoniais") }] : []
|
|
3386
|
+
] }),
|
|
3387
|
+
/* @__PURE__ */ jsxs("div", { className: "flex flex-wrap justify-end gap-2", children: [
|
|
3388
|
+
/* @__PURE__ */ jsx(Button, { type: "button", variant: "ghost", size: "sm", onClick: ctx.close, disabled: busy, children: t("financial.chartTree.cancel") }),
|
|
3389
|
+
/* @__PURE__ */ jsx(Button, { type: "button", size: "sm", disabled: busy, onClick: () => void submit(), children: busy ? t("financial.chartTree.saving") : t("financial.chartTree.save") })
|
|
3390
|
+
] })
|
|
3436
3391
|
]
|
|
3437
3392
|
}
|
|
3438
|
-
)
|
|
3439
|
-
|
|
3440
|
-
/* @__PURE__ */ jsxs("div", { className: "relative min-w-[12rem] flex-1", children: [
|
|
3441
|
-
/* @__PURE__ */ jsx(Search, { className: "pointer-events-none absolute left-2.5 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground" }),
|
|
3442
|
-
/* @__PURE__ */ jsx(
|
|
3443
|
-
Input,
|
|
3444
|
-
{
|
|
3445
|
-
value: query,
|
|
3446
|
-
onChange: (e) => setQuery(e.target.value),
|
|
3447
|
-
placeholder: t("financial.chartTree.searchPlaceholder"),
|
|
3448
|
-
className: "pl-8 pr-8",
|
|
3449
|
-
"aria-label": t("financial.chartTree.searchPlaceholder")
|
|
3450
|
-
}
|
|
3451
|
-
),
|
|
3452
|
-
query && /* @__PURE__ */ jsx(
|
|
3453
|
-
Button,
|
|
3454
|
-
{
|
|
3455
|
-
variant: "bare",
|
|
3456
|
-
size: "bare",
|
|
3457
|
-
type: "button",
|
|
3458
|
-
className: "absolute right-2 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground",
|
|
3459
|
-
onClick: () => setQuery(""),
|
|
3460
|
-
"aria-label": t("financial.chartTree.clearSearch"),
|
|
3461
|
-
children: /* @__PURE__ */ jsx(X, { className: "h-4 w-4" })
|
|
3462
|
-
}
|
|
3463
|
-
)
|
|
3464
|
-
] }),
|
|
3465
|
-
/* @__PURE__ */ jsxs(Button, { variant: "outline", size: "sm", onClick: () => setExpanded(new Set(groupIds)), disabled: !!search, title: t("financial.chartTree.expandAll"), "aria-label": t("financial.chartTree.expandAll"), children: [
|
|
3466
|
-
/* @__PURE__ */ jsx(ChevronsUpDown, { className: "h-4 w-4" }),
|
|
3467
|
-
/* @__PURE__ */ jsx("span", { className: "hidden sm:inline", children: t("financial.chartTree.expandAll") })
|
|
3468
|
-
] }),
|
|
3469
|
-
/* @__PURE__ */ jsxs(Button, { variant: "outline", size: "sm", onClick: () => setExpanded(/* @__PURE__ */ new Set()), disabled: !!search, title: t("financial.chartTree.collapseAll"), "aria-label": t("financial.chartTree.collapseAll"), children: [
|
|
3470
|
-
/* @__PURE__ */ jsx(ChevronsDownUp, { className: "h-4 w-4" }),
|
|
3471
|
-
/* @__PURE__ */ jsx("span", { className: "hidden sm:inline", children: t("financial.chartTree.collapseAll") })
|
|
3472
|
-
] })
|
|
3473
|
-
] }),
|
|
3474
|
-
canCreate && (embedded ? /* @__PURE__ */ jsxs(Button, { size: "sm", onClick: () => startCreate(null), disabled: busy, children: [
|
|
3475
|
-
/* @__PURE__ */ jsx(Plus, { className: "h-4 w-4" }),
|
|
3476
|
-
t("financial.chartTree.addRoot")
|
|
3477
|
-
] }) : /* @__PURE__ */ jsx(PageHeaderActions, { children: /* @__PURE__ */ jsxs(Button, { size: "sm", onClick: () => startCreate(null), disabled: busy, children: [
|
|
3478
|
-
/* @__PURE__ */ jsx(Plus, { className: "h-4 w-4" }),
|
|
3479
|
-
t("financial.chartTree.addRoot")
|
|
3480
|
-
] }) })),
|
|
3481
|
-
/* @__PURE__ */ jsxs("div", { className: "flex flex-wrap items-center justify-between gap-2 text-xs text-muted-foreground", children: [
|
|
3482
|
-
/* @__PURE__ */ jsx("span", { children: search ? t(search.matches.size === 1 ? "financial.chartTree.matchesOne" : "financial.chartTree.matches", { count: search.matches.size }) : t(tree.byId.size === 1 ? "financial.chartTree.countOne" : "financial.chartTree.count", { count: tree.byId.size }) }),
|
|
3483
|
-
inactiveCount > 0 && /* @__PURE__ */ jsxs("label", { className: "inline-flex cursor-pointer items-center gap-1.5", children: [
|
|
3484
|
-
/* @__PURE__ */ jsx(Checkbox, { checked: showInactive, onChange: setShowInactive }),
|
|
3485
|
-
t("financial.chartTree.showInactive", { count: inactiveCount })
|
|
3486
|
-
] })
|
|
3487
|
-
] }),
|
|
3488
|
-
loadError && /* @__PURE__ */ jsxs("p", { className: "rounded-md border border-destructive/40 bg-destructive/5 p-3 text-sm text-destructive", children: [
|
|
3489
|
-
t("financial.chartTree.error.load"),
|
|
3490
|
-
" ",
|
|
3491
|
-
loadError
|
|
3492
|
-
] }),
|
|
3493
|
-
editing?.mode === "create" && editing.parentId === null && renderForm(editing.draft, 0),
|
|
3494
|
-
roots.length === 0 && !(editing?.mode === "create" && editing.parentId === null) ? /* @__PURE__ */ jsx("div", { className: "rounded-md border border-dashed border-border p-8 text-center text-sm text-muted-foreground", children: search ? t("financial.chartTree.noMatches") : t("financial.chartTree.empty") }) : /* @__PURE__ */ jsx("ul", { role: "tree", "aria-label": t("registry.chart-of-accounts"), className: "space-y-0.5", children: roots.map((id) => renderNode(id, 0)) })
|
|
3495
|
-
] });
|
|
3393
|
+
)
|
|
3394
|
+
);
|
|
3496
3395
|
}
|
|
3497
3396
|
|
|
3498
3397
|
// src/data/registries.ts
|
|
@@ -3562,7 +3461,12 @@ var chartOfAccountsEntity = {
|
|
|
3562
3461
|
label: tl("Parent", "Conta pai"),
|
|
3563
3462
|
type: "relation",
|
|
3564
3463
|
showInTable: false,
|
|
3565
|
-
relation: {
|
|
3464
|
+
relation: {
|
|
3465
|
+
table: T.chartOfAccounts,
|
|
3466
|
+
labelFields: ["code", "name"],
|
|
3467
|
+
filter: { node_type: "group" },
|
|
3468
|
+
tree: { parentField: "parent_id", codeField: "code", groupField: "node_type", groupValue: "group" }
|
|
3469
|
+
}
|
|
3566
3470
|
},
|
|
3567
3471
|
...recordRailFields({ tagsTable: "plg_financial_chart_of_accounts", activeLabel: "Ativo", unit: true })
|
|
3568
3472
|
],
|
|
@@ -3584,7 +3488,7 @@ var chartOfAccountsSeed = [
|
|
|
3584
3488
|
{ id: "coa-4.2", code: "4.2", name: "Utilities", nodeType: "leaf", accountType: "expense", parentId: "coa-4", isActive: true },
|
|
3585
3489
|
{ id: "coa-4.3", code: "4.3", name: "Payroll", nodeType: "leaf", accountType: "expense", parentId: "coa-4", isActive: true }
|
|
3586
3490
|
];
|
|
3587
|
-
var ChartOfAccountsRegistryView = (props) =>
|
|
3491
|
+
var ChartOfAccountsRegistryView = (props) => React3__default.createElement(ChartOfAccountsTree, { ...props, entity: chartOfAccountsEntity, mockData: chartOfAccountsSeed });
|
|
3588
3492
|
ChartOfAccountsRegistryView.displayName = "ChartOfAccountsRegistryView";
|
|
3589
3493
|
var costCenterEntity = {
|
|
3590
3494
|
name: "Cost Center",
|
|
@@ -3682,7 +3586,7 @@ var bankAccountEntity = {
|
|
|
3682
3586
|
labelWhen: (v) => v.kind === "card_payable" ? "Banco emissor" : void 0,
|
|
3683
3587
|
visibleWhen: (v) => hasIssuer(v.kind),
|
|
3684
3588
|
group: "bank",
|
|
3685
|
-
renderInput: ({ value, values, onChange, setValue }) =>
|
|
3589
|
+
renderInput: ({ value, values, onChange, setValue }) => React3__default.createElement(BankPicker, {
|
|
3686
3590
|
code: values.bankCode ?? "",
|
|
3687
3591
|
name: value ?? "",
|
|
3688
3592
|
onChange: (next) => {
|
|
@@ -4689,10 +4593,10 @@ function CashSessionControl({ config, provider, store: store6 }) {
|
|
|
4689
4593
|
const fetchCashSessions = useStore(store6, (s) => s.fetchCashSessions);
|
|
4690
4594
|
const open = useStore(store6, (s) => s.cashSessionModalOpen);
|
|
4691
4595
|
const setOpen = useStore(store6, (s) => s.setCashSessionModalOpen);
|
|
4692
|
-
|
|
4596
|
+
React3__default.useEffect(() => {
|
|
4693
4597
|
void fetchCashSessions?.();
|
|
4694
4598
|
}, [fetchCashSessions]);
|
|
4695
|
-
|
|
4599
|
+
React3__default.useEffect(() => {
|
|
4696
4600
|
if (!open) return;
|
|
4697
4601
|
const close = () => setOpen(false);
|
|
4698
4602
|
return onAppPathChange(close);
|
|
@@ -5262,8 +5166,8 @@ var UPCOMING = [
|
|
|
5262
5166
|
function CardMachinesSettings() {
|
|
5263
5167
|
const { connectors } = useConnectors({ hostPluginId: "financial", includeGrants: false });
|
|
5264
5168
|
const panelAvailable = useConnectorsPanelAvailable();
|
|
5265
|
-
const [selected, setSelected] =
|
|
5266
|
-
const acquirers =
|
|
5169
|
+
const [selected, setSelected] = React3.useState(null);
|
|
5170
|
+
const acquirers = React3.useMemo(
|
|
5267
5171
|
() => (connectors ?? []).filter((c) => ACQUIRERS.includes(c.slug)).sort((a, b) => ACQUIRERS.indexOf(a.slug) - ACQUIRERS.indexOf(b.slug)),
|
|
5268
5172
|
[connectors]
|
|
5269
5173
|
);
|
|
@@ -5384,7 +5288,7 @@ function createFinancialSettingsPlugin(options) {
|
|
|
5384
5288
|
...financialRegistries.filter((r) => RECEIVING_REGISTRIES.includes(r.id)),
|
|
5385
5289
|
...options?.extraRegistries ?? []
|
|
5386
5290
|
];
|
|
5387
|
-
const SettingsTab = () =>
|
|
5291
|
+
const SettingsTab = () => React3__default.createElement(PluginSettingsPanel, {
|
|
5388
5292
|
title: "Pagamentos",
|
|
5389
5293
|
registries,
|
|
5390
5294
|
hostPluginId: "financial",
|
|
@@ -5440,11 +5344,11 @@ function createFinancialPlugin(options) {
|
|
|
5440
5344
|
const settingsRegistries = registries.filter((r) => r.id !== "bank-accounts" && r.id !== "commission-rules");
|
|
5441
5345
|
const AccountsRegistryPage = createCrudPage(financialAccountEntity, { feature: "financial" });
|
|
5442
5346
|
AccountsRegistryPage.displayName = "FinancialAccountsRegistryPage";
|
|
5443
|
-
const PersonStatementBound = (props) =>
|
|
5347
|
+
const PersonStatementBound = (props) => React3__default.createElement(PersonStatementWidget, { person: props.item, provider, config });
|
|
5444
5348
|
PersonStatementBound.displayName = "FinancialPersonStatement";
|
|
5445
|
-
const SupplierFinancialSettingsBound = (props) =>
|
|
5349
|
+
const SupplierFinancialSettingsBound = (props) => React3__default.createElement(SupplierFinancialSettings, { person: props.item, provider });
|
|
5446
5350
|
SupplierFinancialSettingsBound.displayName = "FinancialSupplierSettings";
|
|
5447
|
-
const PageComponent = () =>
|
|
5351
|
+
const PageComponent = () => React3__default.createElement(FinancialPage, { config, provider, store: store6, registries });
|
|
5448
5352
|
const AgentMount = lazyComponent(() => import('./payable-agent-TCKHUAQG.js').then((m) => m.createFinancialAgentMount({ config, provider })));
|
|
5449
5353
|
return {
|
|
5450
5354
|
id: "financial",
|
|
@@ -5502,7 +5406,7 @@ function createFinancialPlugin(options) {
|
|
|
5502
5406
|
// tem — lá é um ícone no cabeçalho, de qualquer tela.
|
|
5503
5407
|
headerControls: config.modules.cashRegisters ? [{
|
|
5504
5408
|
id: "financial.cash-session",
|
|
5505
|
-
component: (() =>
|
|
5409
|
+
component: (() => React3__default.createElement(CashSessionHeaderControl, { config, provider, store: store6 })),
|
|
5506
5410
|
order: 90,
|
|
5507
5411
|
permission: { feature: "financial", action: "read" }
|
|
5508
5412
|
}] : [],
|
|
@@ -5752,9 +5656,9 @@ function createFinancialPlugin(options) {
|
|
|
5752
5656
|
{ id: "card-brands", label: "Card brands", icon: "CreditCard" }
|
|
5753
5657
|
],
|
|
5754
5658
|
component: (() => {
|
|
5755
|
-
const FinancialSettingsTab = () =>
|
|
5659
|
+
const FinancialSettingsTab = () => React3__default.createElement(PluginSettingsPanel, {
|
|
5756
5660
|
title: "Financial Settings",
|
|
5757
|
-
generalSettings:
|
|
5661
|
+
generalSettings: React3__default.createElement(FinancialGeneralSettings, { config }),
|
|
5758
5662
|
registries: settingsRegistries,
|
|
5759
5663
|
hostPluginId: "financial",
|
|
5760
5664
|
routeBase: "/settings/financial"
|
|
@@ -5779,7 +5683,7 @@ function createFinancialPlugin(options) {
|
|
|
5779
5683
|
icon: "HandCoins",
|
|
5780
5684
|
group: "Financeiro",
|
|
5781
5685
|
component: (() => {
|
|
5782
|
-
const CommissionRulesTab = () =>
|
|
5686
|
+
const CommissionRulesTab = () => React3__default.createElement(CommissionRulesView, { provider });
|
|
5783
5687
|
CommissionRulesTab.displayName = "CommissionRulesTab";
|
|
5784
5688
|
return CommissionRulesTab;
|
|
5785
5689
|
})(),
|
|
@@ -5815,11 +5719,11 @@ function createFinancialPlugin(options) {
|
|
|
5815
5719
|
locales: financialLocales
|
|
5816
5720
|
};
|
|
5817
5721
|
}
|
|
5818
|
-
var FinancialPage =
|
|
5722
|
+
var FinancialPage = React3__default.lazy(() => import('./FinancialPage-S2EBQVIA.js').then((m) => ({ default: m.FinancialPage })));
|
|
5819
5723
|
var FinancialGeneralSettings = lazyComponent(() => import('./FinancialGeneralSettings-WXJOCJPZ.js').then((m) => m.FinancialGeneralSettings));
|
|
5820
5724
|
var CommissionRulesView = lazyComponent(() => import('./CommissionRulesView-2RW4ZCDT.js').then((m) => m.CommissionRulesView));
|
|
5821
|
-
var PersonStatementWidget = lazyComponent(() => import('./PersonStatementWidget-
|
|
5822
|
-
var SupplierFinancialSettings = lazyComponent(() => import('./PersonStatementWidget-
|
|
5725
|
+
var PersonStatementWidget = lazyComponent(() => import('./PersonStatementWidget-JD6FHD4G.js').then((m) => m.PersonStatementWidget));
|
|
5726
|
+
var SupplierFinancialSettings = lazyComponent(() => import('./PersonStatementWidget-JD6FHD4G.js').then((m) => m.SupplierFinancialSettings));
|
|
5823
5727
|
var ProductPriceTablesTabView = lazyComponent(() => import('./ProductPriceTablesTab-FKYRGSBI.js').then((m) => m.ProductPriceTablesTab));
|
|
5824
5728
|
function priceTablesProductTab(options = {}) {
|
|
5825
5729
|
return {
|