@fayz-ai/plugin-financial 0.29.2 → 0.29.3
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/components/ChartOfAccountsTree.d.ts.map +1 -1
- package/dist/index.js +249 -355
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -3,11 +3,11 @@ export { FINANCIAL_INVOICE_ZONES } from './chunk-IQHWMVUM.js';
|
|
|
3
3
|
import './chunk-7VKJLBYY.js';
|
|
4
4
|
import { FINANCIAL_MODULE_DEFAULTS } from './chunk-POYZFEAN.js';
|
|
5
5
|
import { FinancialContextProvider, useFinancialProvider, formatCurrency, useFinancialConfig, useFinancialStore } from './chunk-CNXAVGSW.js';
|
|
6
|
-
import * as
|
|
7
|
-
import
|
|
8
|
-
import { CircleDollarSign, FileText,
|
|
6
|
+
import * as React3 from 'react';
|
|
7
|
+
import React3__default, { useEffect } from 'react';
|
|
8
|
+
import { CircleDollarSign, FileText, Wallet, ArrowUpRight, ArrowDownRight, AlertTriangle, EyeOff, Eye, CreditCard } from 'lucide-react';
|
|
9
9
|
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,
|
|
10
|
+
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
11
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
12
12
|
import { createSafeFinancialProvider, createFinancialStore } from '@fayz-ai/financial/store';
|
|
13
13
|
export { createSafeFinancialProvider } from '@fayz-ai/financial/store';
|
|
@@ -15,7 +15,7 @@ import { FINANCIAL_ZONES } from '@fayz-ai/financial/views/zones';
|
|
|
15
15
|
import { draftAllProductsForPriceTable, addAllProductsToPriceTable, fayzConnectorOAuth, defineSettingsTab, RightRailPage, useConnectors, useConnectorsPanelAvailable, SettingsForm, ConnectorMark, StateChip, ConnectorDetail, usePermissionOptional, openConnectorsPanel, createCrudPage, PluginSettingsPanel, useTenantPluginSettings } from '@fayz-ai/admin';
|
|
16
16
|
import { invoiceOpensForEditing } from '@fayz-ai/financial/domain/invoice';
|
|
17
17
|
import { T } from '@fayz-ai/financial/data/tables';
|
|
18
|
-
import { buildChartTree,
|
|
18
|
+
import { buildChartTree, isGroupNode, compareCodes, suggestNextCode, accountLabel, descendantIds, childIds } from '@fayz-ai/financial/domain/chart-of-accounts';
|
|
19
19
|
import { useStore } from 'zustand';
|
|
20
20
|
import { MIGRATIONS } from '#migrations/main';
|
|
21
21
|
export { createMockFinancialProvider } from '@fayz-ai/financial/data/mock';
|
|
@@ -247,7 +247,7 @@ function RecentTransactions() {
|
|
|
247
247
|
const t = useTranslation();
|
|
248
248
|
const { currency } = useFinancialConfig();
|
|
249
249
|
const provider = useFinancialProvider();
|
|
250
|
-
const [invoices, setInvoices] =
|
|
250
|
+
const [invoices, setInvoices] = React3__default.useState([]);
|
|
251
251
|
useEffect(() => {
|
|
252
252
|
let alive = true;
|
|
253
253
|
void provider.getInvoices({ ...RECENT_TRANSACTIONS_QUERY, dateRange: recentWindow() }).then((res) => {
|
|
@@ -290,7 +290,7 @@ function BalanceHero() {
|
|
|
290
290
|
const summary = useFinancialStore((s) => s.summary);
|
|
291
291
|
const navigate = useDashboardNavigate();
|
|
292
292
|
useEnsureSummary();
|
|
293
|
-
const [hidden, setHidden] =
|
|
293
|
+
const [hidden, setHidden] = React3__default.useState(false);
|
|
294
294
|
const money = (v) => hidden ? "\u2022\u2022\u2022\u2022\u2022\u2022" : formatCurrency(v ?? 0, currency);
|
|
295
295
|
const inflow = summary?.monthlyInflow ?? 0;
|
|
296
296
|
const outflow = summary?.monthlyOutflow ?? 0;
|
|
@@ -369,7 +369,7 @@ function categorizeSpend(notes) {
|
|
|
369
369
|
function SpendByCategoryChart() {
|
|
370
370
|
const t = useTranslation();
|
|
371
371
|
const provider = useFinancialProvider();
|
|
372
|
-
const [rows, setRows] =
|
|
372
|
+
const [rows, setRows] = React3__default.useState([]);
|
|
373
373
|
useEffect(() => {
|
|
374
374
|
let alive = true;
|
|
375
375
|
void (async () => {
|
|
@@ -412,7 +412,7 @@ function UpcomingBills() {
|
|
|
412
412
|
const { currency } = useFinancialConfig();
|
|
413
413
|
const provider = useFinancialProvider();
|
|
414
414
|
const dueLabel = useDueLabel();
|
|
415
|
-
const [bills, setBills] =
|
|
415
|
+
const [bills, setBills] = React3__default.useState([]);
|
|
416
416
|
useEffect(() => {
|
|
417
417
|
let alive = true;
|
|
418
418
|
void (async () => {
|
|
@@ -2698,8 +2698,8 @@ function ReceivePaymentModal({
|
|
|
2698
2698
|
onClose,
|
|
2699
2699
|
onPaid
|
|
2700
2700
|
}) {
|
|
2701
|
-
const provider =
|
|
2702
|
-
const store6 =
|
|
2701
|
+
const provider = React3__default.useMemo(() => createSafeFinancialProvider(), []);
|
|
2702
|
+
const store6 = React3__default.useMemo(() => createFinancialStore(provider), [provider]);
|
|
2703
2703
|
return /* @__PURE__ */ jsx(FinancialContextProvider, { config: STANDALONE_CONFIG, provider, store: store6, children: /* @__PURE__ */ jsx(
|
|
2704
2704
|
PaymentModal,
|
|
2705
2705
|
{
|
|
@@ -2733,27 +2733,27 @@ function ClientAccountPanel({
|
|
|
2733
2733
|
currency = BRL
|
|
2734
2734
|
}) {
|
|
2735
2735
|
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 =
|
|
2736
|
+
const [account, setAccount] = React3__default.useState(null);
|
|
2737
|
+
const [busy, setBusy] = React3__default.useState(false);
|
|
2738
|
+
const [viewInvoiceId, setViewInvoiceId] = React3__default.useState(null);
|
|
2739
|
+
const [comprando, setComprando] = React3__default.useState(false);
|
|
2740
|
+
const [buscaServico, setBuscaServico] = React3__default.useState("");
|
|
2741
|
+
const [catalogo, setCatalogo] = React3__default.useState([]);
|
|
2742
|
+
const [escolhidos, setEscolhidos] = React3__default.useState([]);
|
|
2743
|
+
const [comprandoBusy, setComprandoBusy] = React3__default.useState(false);
|
|
2744
|
+
const [erroCompra, setErroCompra] = React3__default.useState(null);
|
|
2745
|
+
const load = React3__default.useCallback(async () => {
|
|
2746
2746
|
if (!personId) return;
|
|
2747
2747
|
setAccount(await provider.getClientAccount(personId));
|
|
2748
2748
|
}, [personId, provider]);
|
|
2749
|
-
|
|
2749
|
+
React3__default.useEffect(() => {
|
|
2750
2750
|
void load();
|
|
2751
2751
|
}, [load]);
|
|
2752
2752
|
const viewInvoice = account?.invoices.find((i) => i.id === viewInvoiceId) ?? null;
|
|
2753
2753
|
const viewEditable = invoiceOpensForEditing(viewInvoice?.status);
|
|
2754
2754
|
const forThis = account?.invoices.filter((i) => orderId && i.orderId === orderId) ?? [];
|
|
2755
2755
|
const hasForThis = forThis.length > 0;
|
|
2756
|
-
|
|
2756
|
+
React3__default.useEffect(() => {
|
|
2757
2757
|
if (!comprando) return;
|
|
2758
2758
|
let vivo = true;
|
|
2759
2759
|
const t = setTimeout(async () => {
|
|
@@ -3042,8 +3042,8 @@ function ClientAccountPanel({
|
|
|
3042
3042
|
] });
|
|
3043
3043
|
}
|
|
3044
3044
|
function ClientAccountInline(props) {
|
|
3045
|
-
const provider =
|
|
3046
|
-
const store6 =
|
|
3045
|
+
const provider = React3__default.useMemo(() => createSafeFinancialProvider(), []);
|
|
3046
|
+
const store6 = React3__default.useMemo(() => createFinancialStore(provider), [provider]);
|
|
3047
3047
|
return /* @__PURE__ */ jsx(FinancialContextProvider, { config: STANDALONE_CONFIG, provider, store: store6, children: /* @__PURE__ */ jsx(ClientAccountPanel, { ...props }) });
|
|
3048
3048
|
}
|
|
3049
3049
|
function ClientAccountModal({
|
|
@@ -3128,371 +3128,265 @@ function ChartOfAccountsTree({ entity, mockData, dataProvider, embedded }) {
|
|
|
3128
3128
|
const canCreate = can("financial", "create");
|
|
3129
3129
|
const canEdit = can("financial", "edit");
|
|
3130
3130
|
const canDelete = can("financial", "delete");
|
|
3131
|
-
const provider =
|
|
3131
|
+
const provider = React3__default.useMemo(
|
|
3132
3132
|
() => dataProvider ?? resolveDataProvider(entity, mockData ?? []),
|
|
3133
3133
|
[entity, mockData, dataProvider]
|
|
3134
3134
|
);
|
|
3135
3135
|
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 () => {
|
|
3136
|
+
const [nodes, setNodes] = React3__default.useState(null);
|
|
3137
|
+
const [loadError, setLoadError] = React3__default.useState(null);
|
|
3138
|
+
const [side, setSide] = React3__default.useState("in");
|
|
3139
|
+
const [editing, setEditing] = React3__default.useState(null);
|
|
3140
|
+
const [busy, setBusy] = React3__default.useState(false);
|
|
3141
|
+
const reload = React3__default.useCallback(async () => {
|
|
3147
3142
|
try {
|
|
3148
|
-
|
|
3149
|
-
setNodes(rows);
|
|
3143
|
+
setNodes(await loadAll(provider));
|
|
3150
3144
|
setLoadError(null);
|
|
3151
|
-
if (!initialized.current) {
|
|
3152
|
-
initialized.current = true;
|
|
3153
|
-
const tree2 = buildChartTree(rows);
|
|
3154
|
-
setExpanded(new Set(rootIds(tree2)));
|
|
3155
|
-
}
|
|
3156
3145
|
} catch (err) {
|
|
3157
3146
|
setLoadError(errorMessage(err));
|
|
3158
3147
|
setNodes((prev) => prev ?? []);
|
|
3159
3148
|
}
|
|
3160
3149
|
}, [provider]);
|
|
3161
|
-
|
|
3150
|
+
React3__default.useEffect(() => {
|
|
3162
3151
|
void reload();
|
|
3163
3152
|
}, [reload]);
|
|
3164
|
-
const shown =
|
|
3165
|
-
|
|
3166
|
-
|
|
3167
|
-
|
|
3168
|
-
|
|
3169
|
-
|
|
3170
|
-
|
|
3171
|
-
|
|
3172
|
-
|
|
3173
|
-
|
|
3174
|
-
|
|
3175
|
-
|
|
3176
|
-
|
|
3177
|
-
|
|
3178
|
-
|
|
3179
|
-
|
|
3180
|
-
return next;
|
|
3181
|
-
});
|
|
3153
|
+
const shown = React3__default.useMemo(() => nodes === null ? null : onSide(nodes, side), [nodes, side]);
|
|
3154
|
+
const fullTree = React3__default.useMemo(() => buildChartTree(nodes ?? []), [nodes]);
|
|
3155
|
+
async function run(action, success) {
|
|
3156
|
+
setBusy(true);
|
|
3157
|
+
try {
|
|
3158
|
+
await action();
|
|
3159
|
+
if (table) emitDataChanged({ table });
|
|
3160
|
+
toast.success(success);
|
|
3161
|
+
await reload();
|
|
3162
|
+
return true;
|
|
3163
|
+
} catch (err) {
|
|
3164
|
+
toast.error(t("financial.chartTree.error.save"), { description: errorMessage(err) });
|
|
3165
|
+
return false;
|
|
3166
|
+
} finally {
|
|
3167
|
+
setBusy(false);
|
|
3168
|
+
}
|
|
3182
3169
|
}
|
|
3183
|
-
|
|
3184
|
-
|
|
3185
|
-
|
|
3186
|
-
|
|
3187
|
-
|
|
3188
|
-
|
|
3189
|
-
|
|
3190
|
-
|
|
3191
|
-
|
|
3192
|
-
|
|
3193
|
-
|
|
3194
|
-
|
|
3170
|
+
const hasOther = (nodes ?? []).some((n) => sideOf(n.accountType) === "other");
|
|
3171
|
+
const plural = (one, many) => (n) => t(n === 1 ? one : many, { count: n });
|
|
3172
|
+
return /* @__PURE__ */ jsxs("div", { className: "space-y-3", children: [
|
|
3173
|
+
/* @__PURE__ */ jsx(
|
|
3174
|
+
SegmentedControl,
|
|
3175
|
+
{
|
|
3176
|
+
value: side,
|
|
3177
|
+
onChange: (v) => {
|
|
3178
|
+
setSide(v);
|
|
3179
|
+
setEditing(null);
|
|
3180
|
+
},
|
|
3181
|
+
options: [
|
|
3182
|
+
{ value: "in", label: tl("Income (in)", "Receitas (entradas)") },
|
|
3183
|
+
{ value: "out", label: tl("Expenses (out)", "Despesas (sa\xEDdas)") },
|
|
3184
|
+
...hasOther ? [{ value: "other", label: tl("Balance", "Patrimoniais") }] : []
|
|
3185
|
+
]
|
|
3195
3186
|
}
|
|
3196
|
-
|
|
3197
|
-
|
|
3198
|
-
|
|
3199
|
-
|
|
3200
|
-
|
|
3201
|
-
|
|
3202
|
-
|
|
3203
|
-
|
|
3204
|
-
|
|
3187
|
+
),
|
|
3188
|
+
/* @__PURE__ */ jsx(
|
|
3189
|
+
TreeManager,
|
|
3190
|
+
{
|
|
3191
|
+
nodes: shown,
|
|
3192
|
+
getId: (n) => n.id,
|
|
3193
|
+
getParentId: (n) => n.parentId,
|
|
3194
|
+
getName: (n) => n.name,
|
|
3195
|
+
getCode: (n) => n.code,
|
|
3196
|
+
isActive: (n) => n.isActive,
|
|
3197
|
+
compare: (a, b) => compareCodes(a.code, b.code),
|
|
3198
|
+
isGroup: (n, hasChildren) => n.nodeType === "group" || hasChildren,
|
|
3199
|
+
loadError: loadError ? `${t("financial.chartTree.error.load")} ${loadError}` : null,
|
|
3200
|
+
busy,
|
|
3201
|
+
embedded,
|
|
3202
|
+
canCreate,
|
|
3203
|
+
canEdit,
|
|
3204
|
+
canRemove: canDelete,
|
|
3205
|
+
canAddChild: (n) => n.isActive && isGroupNode(fullTree, n),
|
|
3206
|
+
canDeactivate: (_n, hasChildren) => !hasChildren,
|
|
3207
|
+
onSetActive: (node, isActive) => run(
|
|
3208
|
+
() => provider.update(node.id, { isActive }),
|
|
3209
|
+
t(isActive ? "financial.chartTree.reactivated" : "financial.chartTree.deactivated", { name: node.name })
|
|
3210
|
+
),
|
|
3211
|
+
onDelete: (node) => run(() => provider.remove(node.id), t("financial.chartTree.deleted", { name: node.name })),
|
|
3212
|
+
editing,
|
|
3213
|
+
onEditingChange: setEditing,
|
|
3214
|
+
renderBadges: (n) => n.accountType && /* @__PURE__ */ jsx(Badge, { variant: NATURE_VARIANT[n.accountType] ?? "default", dot: false, children: t(`financial.chartTree.nature.${n.accountType}`) }),
|
|
3215
|
+
renderEditor: (ctx) => /* @__PURE__ */ jsx(
|
|
3216
|
+
AccountEditor,
|
|
3217
|
+
{
|
|
3218
|
+
ctx,
|
|
3219
|
+
nodes: nodes ?? [],
|
|
3220
|
+
fullTree,
|
|
3221
|
+
side,
|
|
3222
|
+
busy,
|
|
3223
|
+
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 }))
|
|
3224
|
+
}
|
|
3225
|
+
),
|
|
3226
|
+
labels: {
|
|
3227
|
+
searchPlaceholder: t("financial.chartTree.searchPlaceholder"),
|
|
3228
|
+
clearSearch: t("financial.chartTree.clearSearch"),
|
|
3229
|
+
expandAll: t("financial.chartTree.expandAll"),
|
|
3230
|
+
collapseAll: t("financial.chartTree.collapseAll"),
|
|
3231
|
+
expand: t("financial.chartTree.expand"),
|
|
3232
|
+
collapse: t("financial.chartTree.collapse"),
|
|
3233
|
+
addRoot: t("financial.chartTree.addRoot"),
|
|
3234
|
+
addChild: t("financial.chartTree.addChild"),
|
|
3235
|
+
edit: t("financial.chartTree.edit"),
|
|
3236
|
+
deactivate: t("financial.chartTree.deactivate"),
|
|
3237
|
+
reactivate: t("financial.chartTree.reactivate"),
|
|
3238
|
+
delete: t("financial.chartTree.delete"),
|
|
3239
|
+
confirmDelete: t("financial.chartTree.confirmDelete"),
|
|
3240
|
+
cancel: t("financial.chartTree.cancel"),
|
|
3241
|
+
inactive: t("financial.chartTree.inactive"),
|
|
3242
|
+
empty: t("financial.chartTree.empty"),
|
|
3243
|
+
noMatches: t("financial.chartTree.noMatches"),
|
|
3244
|
+
tree: t("registry.chart-of-accounts"),
|
|
3245
|
+
count: plural("financial.chartTree.countOne", "financial.chartTree.count"),
|
|
3246
|
+
matches: plural("financial.chartTree.matchesOne", "financial.chartTree.matches"),
|
|
3247
|
+
showInactive: (n) => t("financial.chartTree.showInactive", { count: n })
|
|
3248
|
+
}
|
|
3249
|
+
}
|
|
3250
|
+
)
|
|
3251
|
+
] });
|
|
3252
|
+
}
|
|
3253
|
+
function AccountEditor({ ctx, nodes, fullTree, side, busy, onSave }) {
|
|
3254
|
+
const t = useTranslation();
|
|
3255
|
+
const selfId = ctx.editing.mode === "edit" ? ctx.editing.id : void 0;
|
|
3256
|
+
const [draft, setDraft] = React3__default.useState(() => {
|
|
3257
|
+
const node = ctx.node;
|
|
3258
|
+
if (node) {
|
|
3259
|
+
return {
|
|
3205
3260
|
code: node.code,
|
|
3206
3261
|
name: node.name,
|
|
3207
3262
|
nodeType: node.nodeType === "group" ? "group" : "leaf",
|
|
3208
3263
|
accountType: node.accountType ?? "",
|
|
3209
3264
|
parentId: node.parentId ?? null
|
|
3210
|
-
}
|
|
3211
|
-
}
|
|
3212
|
-
|
|
3213
|
-
|
|
3265
|
+
};
|
|
3266
|
+
}
|
|
3267
|
+
const parent2 = ctx.parentId ? fullTree.byId.get(ctx.parentId) : void 0;
|
|
3268
|
+
return {
|
|
3269
|
+
code: suggestNextCode(fullTree, ctx.parentId),
|
|
3270
|
+
name: "",
|
|
3271
|
+
nodeType: "leaf",
|
|
3272
|
+
accountType: parent2?.accountType ?? SIDE_TYPE[side],
|
|
3273
|
+
parentId: ctx.parentId
|
|
3274
|
+
};
|
|
3275
|
+
});
|
|
3276
|
+
const update = (patch) => setDraft((prev) => ({ ...prev, ...patch }));
|
|
3277
|
+
const parent = draft.parentId ? fullTree.byId.get(draft.parentId) : void 0;
|
|
3278
|
+
function validate() {
|
|
3214
3279
|
const code = draft.code.trim();
|
|
3215
3280
|
if (!code) return t("financial.chartTree.error.codeRequired");
|
|
3216
3281
|
if (!draft.name.trim()) return t("financial.chartTree.error.nameRequired");
|
|
3217
|
-
const clash =
|
|
3282
|
+
const clash = nodes.find((n) => n.code === code && n.id !== selfId);
|
|
3218
3283
|
if (clash) return t("financial.chartTree.error.codeTaken", { code, name: clash.name });
|
|
3219
3284
|
if (selfId && draft.nodeType === "leaf" && childIds(fullTree, selfId).length > 0) {
|
|
3220
3285
|
return t("financial.chartTree.error.leafWithChildren");
|
|
3221
3286
|
}
|
|
3222
3287
|
return null;
|
|
3223
3288
|
}
|
|
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
3289
|
async function submit() {
|
|
3240
|
-
|
|
3241
|
-
const { draft } = editing;
|
|
3242
|
-
const invalid = validate(draft, editing.mode === "edit" ? editing.id : void 0);
|
|
3290
|
+
const invalid = validate();
|
|
3243
3291
|
if (invalid) {
|
|
3244
3292
|
toast.error(invalid);
|
|
3245
3293
|
return;
|
|
3246
3294
|
}
|
|
3247
|
-
const
|
|
3295
|
+
const ok = await onSave(selfId ?? null, {
|
|
3248
3296
|
code: draft.code.trim(),
|
|
3249
3297
|
name: draft.name.trim(),
|
|
3250
3298
|
nodeType: draft.nodeType,
|
|
3251
3299
|
accountType: draft.accountType || null,
|
|
3252
3300
|
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);
|
|
3301
|
+
});
|
|
3302
|
+
if (ok) ctx.close();
|
|
3266
3303
|
}
|
|
3267
|
-
const parentOptions =
|
|
3304
|
+
const parentOptions = (q) => {
|
|
3268
3305
|
const blocked = selfId ? descendantIds(fullTree, selfId).add(selfId) : /* @__PURE__ */ new Set();
|
|
3269
3306
|
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
|
-
] })
|
|
3307
|
+
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) }));
|
|
3308
|
+
};
|
|
3309
|
+
return (
|
|
3310
|
+
// Not a <form>: Enter would "click" the first button inside SearchSelect
|
|
3311
|
+
// (its clear action) and wipe the parent instead of saving.
|
|
3312
|
+
/* @__PURE__ */ jsxs(
|
|
3313
|
+
"div",
|
|
3314
|
+
{
|
|
3315
|
+
role: "group",
|
|
3316
|
+
className: "rounded-md border border-border bg-muted/40 p-3 space-y-3",
|
|
3317
|
+
style: { marginLeft: Math.min(ctx.level, 8) * 16 },
|
|
3318
|
+
onKeyDown: (e) => {
|
|
3319
|
+
if (e.key === "Escape") ctx.close();
|
|
3320
|
+
if (e.key === "Enter" && e.target.dataset.submitOnEnter) {
|
|
3321
|
+
e.preventDefault();
|
|
3322
|
+
void submit();
|
|
3323
|
+
}
|
|
3324
|
+
},
|
|
3325
|
+
children: [
|
|
3326
|
+
/* @__PURE__ */ jsxs("div", { className: "grid gap-3 sm:grid-cols-[8rem_1fr]", children: [
|
|
3327
|
+
/* @__PURE__ */ jsxs("label", { className: "space-y-1 text-xs font-medium text-muted-foreground", children: [
|
|
3328
|
+
t("financial.chartTree.field.code"),
|
|
3329
|
+
/* @__PURE__ */ jsx(Input, { "data-submit-on-enter": "1", value: draft.code, onChange: (e) => update({ code: e.target.value }), required: true })
|
|
3306
3330
|
] }),
|
|
3307
|
-
/* @__PURE__ */ jsxs("
|
|
3308
|
-
|
|
3309
|
-
|
|
3310
|
-
|
|
3311
|
-
|
|
3312
|
-
|
|
3313
|
-
|
|
3314
|
-
|
|
3315
|
-
|
|
3331
|
+
/* @__PURE__ */ jsxs("label", { className: "space-y-1 text-xs font-medium text-muted-foreground", children: [
|
|
3332
|
+
t("financial.chartTree.field.name"),
|
|
3333
|
+
/* @__PURE__ */ jsx(Input, { "data-submit-on-enter": "1", autoFocus: true, value: draft.name, onChange: (e) => update({ name: e.target.value }), required: true })
|
|
3334
|
+
] })
|
|
3335
|
+
] }),
|
|
3336
|
+
/* @__PURE__ */ jsxs("div", { className: "grid gap-3 sm:grid-cols-3", children: [
|
|
3337
|
+
/* @__PURE__ */ jsxs("label", { className: "space-y-1 text-xs font-medium text-muted-foreground", children: [
|
|
3338
|
+
t("financial.chartTree.field.structure"),
|
|
3339
|
+
/* @__PURE__ */ jsxs(Select, { value: draft.nodeType, onValueChange: (v) => update({ nodeType: v }), children: [
|
|
3340
|
+
/* @__PURE__ */ jsx(SelectTrigger, { className: "px-2 font-normal text-foreground", children: /* @__PURE__ */ jsx(SelectValue, {}) }),
|
|
3341
|
+
/* @__PURE__ */ jsxs(SelectContent, { children: [
|
|
3342
|
+
/* @__PURE__ */ jsx(SelectItem, { value: "leaf", children: t("financial.chartTree.leaf") }),
|
|
3343
|
+
/* @__PURE__ */ jsx(SelectItem, { value: "group", children: t("financial.chartTree.group") })
|
|
3316
3344
|
] })
|
|
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
3345
|
] })
|
|
3352
3346
|
] }),
|
|
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") })
|
|
3347
|
+
/* @__PURE__ */ jsxs("label", { className: "space-y-1 text-xs font-medium text-muted-foreground", children: [
|
|
3348
|
+
t("financial.chartTree.field.nature"),
|
|
3349
|
+
/* @__PURE__ */ jsxs(
|
|
3350
|
+
Select,
|
|
3351
|
+
{
|
|
3352
|
+
value: draft.accountType || NO_NATURE,
|
|
3353
|
+
onValueChange: (v) => update({ accountType: v === NO_NATURE ? "" : v }),
|
|
3354
|
+
children: [
|
|
3355
|
+
/* @__PURE__ */ jsx(SelectTrigger, { className: "px-2 font-normal text-foreground", children: /* @__PURE__ */ jsx(SelectValue, {}) }),
|
|
3356
|
+
/* @__PURE__ */ jsxs(SelectContent, { children: [
|
|
3357
|
+
/* @__PURE__ */ jsx(SelectItem, { value: NO_NATURE, children: t("financial.chartTree.nature.none") }),
|
|
3358
|
+
NATURES.map((n) => /* @__PURE__ */ jsx(SelectItem, { value: n, children: t(`financial.chartTree.nature.${n}`) }, n))
|
|
3359
|
+
] })
|
|
3360
|
+
]
|
|
3361
|
+
}
|
|
3362
|
+
)
|
|
3398
3363
|
] }),
|
|
3399
|
-
|
|
3400
|
-
|
|
3401
|
-
/* @__PURE__ */ jsx(
|
|
3402
|
-
|
|
3403
|
-
|
|
3404
|
-
|
|
3405
|
-
|
|
3406
|
-
|
|
3407
|
-
|
|
3408
|
-
|
|
3409
|
-
|
|
3410
|
-
|
|
3411
|
-
|
|
3364
|
+
/* @__PURE__ */ jsxs("div", { className: "space-y-1 text-xs font-medium text-muted-foreground", children: [
|
|
3365
|
+
t("financial.chartTree.field.parent"),
|
|
3366
|
+
/* @__PURE__ */ jsx(
|
|
3367
|
+
SearchSelect,
|
|
3368
|
+
{
|
|
3369
|
+
value: draft.parentId ?? void 0,
|
|
3370
|
+
displayValue: parent ? accountLabel(parent) : void 0,
|
|
3371
|
+
onChange: (id) => update({ parentId: id || null }),
|
|
3372
|
+
onSearch: parentOptions,
|
|
3373
|
+
minChars: 0,
|
|
3374
|
+
placeholder: t("financial.chartTree.rootLevel"),
|
|
3375
|
+
noResultsLabel: t("financial.chartTree.noGroups"),
|
|
3376
|
+
searchingLabel: t("financial.chartTree.searching"),
|
|
3377
|
+
clearLabel: t("financial.chartTree.rootLevel")
|
|
3378
|
+
}
|
|
3379
|
+
)
|
|
3412
3380
|
] })
|
|
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") }] : []
|
|
3381
|
+
] }),
|
|
3382
|
+
/* @__PURE__ */ jsxs("div", { className: "flex flex-wrap justify-end gap-2", children: [
|
|
3383
|
+
/* @__PURE__ */ jsx(Button, { type: "button", variant: "ghost", size: "sm", onClick: ctx.close, disabled: busy, children: t("financial.chartTree.cancel") }),
|
|
3384
|
+
/* @__PURE__ */ jsx(Button, { type: "button", size: "sm", disabled: busy, onClick: () => void submit(), children: busy ? t("financial.chartTree.saving") : t("financial.chartTree.save") })
|
|
3385
|
+
] })
|
|
3436
3386
|
]
|
|
3437
3387
|
}
|
|
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
|
-
] });
|
|
3388
|
+
)
|
|
3389
|
+
);
|
|
3496
3390
|
}
|
|
3497
3391
|
|
|
3498
3392
|
// src/data/registries.ts
|
|
@@ -3584,7 +3478,7 @@ var chartOfAccountsSeed = [
|
|
|
3584
3478
|
{ id: "coa-4.2", code: "4.2", name: "Utilities", nodeType: "leaf", accountType: "expense", parentId: "coa-4", isActive: true },
|
|
3585
3479
|
{ id: "coa-4.3", code: "4.3", name: "Payroll", nodeType: "leaf", accountType: "expense", parentId: "coa-4", isActive: true }
|
|
3586
3480
|
];
|
|
3587
|
-
var ChartOfAccountsRegistryView = (props) =>
|
|
3481
|
+
var ChartOfAccountsRegistryView = (props) => React3__default.createElement(ChartOfAccountsTree, { ...props, entity: chartOfAccountsEntity, mockData: chartOfAccountsSeed });
|
|
3588
3482
|
ChartOfAccountsRegistryView.displayName = "ChartOfAccountsRegistryView";
|
|
3589
3483
|
var costCenterEntity = {
|
|
3590
3484
|
name: "Cost Center",
|
|
@@ -3682,7 +3576,7 @@ var bankAccountEntity = {
|
|
|
3682
3576
|
labelWhen: (v) => v.kind === "card_payable" ? "Banco emissor" : void 0,
|
|
3683
3577
|
visibleWhen: (v) => hasIssuer(v.kind),
|
|
3684
3578
|
group: "bank",
|
|
3685
|
-
renderInput: ({ value, values, onChange, setValue }) =>
|
|
3579
|
+
renderInput: ({ value, values, onChange, setValue }) => React3__default.createElement(BankPicker, {
|
|
3686
3580
|
code: values.bankCode ?? "",
|
|
3687
3581
|
name: value ?? "",
|
|
3688
3582
|
onChange: (next) => {
|
|
@@ -4689,10 +4583,10 @@ function CashSessionControl({ config, provider, store: store6 }) {
|
|
|
4689
4583
|
const fetchCashSessions = useStore(store6, (s) => s.fetchCashSessions);
|
|
4690
4584
|
const open = useStore(store6, (s) => s.cashSessionModalOpen);
|
|
4691
4585
|
const setOpen = useStore(store6, (s) => s.setCashSessionModalOpen);
|
|
4692
|
-
|
|
4586
|
+
React3__default.useEffect(() => {
|
|
4693
4587
|
void fetchCashSessions?.();
|
|
4694
4588
|
}, [fetchCashSessions]);
|
|
4695
|
-
|
|
4589
|
+
React3__default.useEffect(() => {
|
|
4696
4590
|
if (!open) return;
|
|
4697
4591
|
const close = () => setOpen(false);
|
|
4698
4592
|
return onAppPathChange(close);
|
|
@@ -5262,8 +5156,8 @@ var UPCOMING = [
|
|
|
5262
5156
|
function CardMachinesSettings() {
|
|
5263
5157
|
const { connectors } = useConnectors({ hostPluginId: "financial", includeGrants: false });
|
|
5264
5158
|
const panelAvailable = useConnectorsPanelAvailable();
|
|
5265
|
-
const [selected, setSelected] =
|
|
5266
|
-
const acquirers =
|
|
5159
|
+
const [selected, setSelected] = React3.useState(null);
|
|
5160
|
+
const acquirers = React3.useMemo(
|
|
5267
5161
|
() => (connectors ?? []).filter((c) => ACQUIRERS.includes(c.slug)).sort((a, b) => ACQUIRERS.indexOf(a.slug) - ACQUIRERS.indexOf(b.slug)),
|
|
5268
5162
|
[connectors]
|
|
5269
5163
|
);
|
|
@@ -5384,7 +5278,7 @@ function createFinancialSettingsPlugin(options) {
|
|
|
5384
5278
|
...financialRegistries.filter((r) => RECEIVING_REGISTRIES.includes(r.id)),
|
|
5385
5279
|
...options?.extraRegistries ?? []
|
|
5386
5280
|
];
|
|
5387
|
-
const SettingsTab = () =>
|
|
5281
|
+
const SettingsTab = () => React3__default.createElement(PluginSettingsPanel, {
|
|
5388
5282
|
title: "Pagamentos",
|
|
5389
5283
|
registries,
|
|
5390
5284
|
hostPluginId: "financial",
|
|
@@ -5440,11 +5334,11 @@ function createFinancialPlugin(options) {
|
|
|
5440
5334
|
const settingsRegistries = registries.filter((r) => r.id !== "bank-accounts" && r.id !== "commission-rules");
|
|
5441
5335
|
const AccountsRegistryPage = createCrudPage(financialAccountEntity, { feature: "financial" });
|
|
5442
5336
|
AccountsRegistryPage.displayName = "FinancialAccountsRegistryPage";
|
|
5443
|
-
const PersonStatementBound = (props) =>
|
|
5337
|
+
const PersonStatementBound = (props) => React3__default.createElement(PersonStatementWidget, { person: props.item, provider, config });
|
|
5444
5338
|
PersonStatementBound.displayName = "FinancialPersonStatement";
|
|
5445
|
-
const SupplierFinancialSettingsBound = (props) =>
|
|
5339
|
+
const SupplierFinancialSettingsBound = (props) => React3__default.createElement(SupplierFinancialSettings, { person: props.item, provider });
|
|
5446
5340
|
SupplierFinancialSettingsBound.displayName = "FinancialSupplierSettings";
|
|
5447
|
-
const PageComponent = () =>
|
|
5341
|
+
const PageComponent = () => React3__default.createElement(FinancialPage, { config, provider, store: store6, registries });
|
|
5448
5342
|
const AgentMount = lazyComponent(() => import('./payable-agent-TCKHUAQG.js').then((m) => m.createFinancialAgentMount({ config, provider })));
|
|
5449
5343
|
return {
|
|
5450
5344
|
id: "financial",
|
|
@@ -5502,7 +5396,7 @@ function createFinancialPlugin(options) {
|
|
|
5502
5396
|
// tem — lá é um ícone no cabeçalho, de qualquer tela.
|
|
5503
5397
|
headerControls: config.modules.cashRegisters ? [{
|
|
5504
5398
|
id: "financial.cash-session",
|
|
5505
|
-
component: (() =>
|
|
5399
|
+
component: (() => React3__default.createElement(CashSessionHeaderControl, { config, provider, store: store6 })),
|
|
5506
5400
|
order: 90,
|
|
5507
5401
|
permission: { feature: "financial", action: "read" }
|
|
5508
5402
|
}] : [],
|
|
@@ -5752,9 +5646,9 @@ function createFinancialPlugin(options) {
|
|
|
5752
5646
|
{ id: "card-brands", label: "Card brands", icon: "CreditCard" }
|
|
5753
5647
|
],
|
|
5754
5648
|
component: (() => {
|
|
5755
|
-
const FinancialSettingsTab = () =>
|
|
5649
|
+
const FinancialSettingsTab = () => React3__default.createElement(PluginSettingsPanel, {
|
|
5756
5650
|
title: "Financial Settings",
|
|
5757
|
-
generalSettings:
|
|
5651
|
+
generalSettings: React3__default.createElement(FinancialGeneralSettings, { config }),
|
|
5758
5652
|
registries: settingsRegistries,
|
|
5759
5653
|
hostPluginId: "financial",
|
|
5760
5654
|
routeBase: "/settings/financial"
|
|
@@ -5779,7 +5673,7 @@ function createFinancialPlugin(options) {
|
|
|
5779
5673
|
icon: "HandCoins",
|
|
5780
5674
|
group: "Financeiro",
|
|
5781
5675
|
component: (() => {
|
|
5782
|
-
const CommissionRulesTab = () =>
|
|
5676
|
+
const CommissionRulesTab = () => React3__default.createElement(CommissionRulesView, { provider });
|
|
5783
5677
|
CommissionRulesTab.displayName = "CommissionRulesTab";
|
|
5784
5678
|
return CommissionRulesTab;
|
|
5785
5679
|
})(),
|
|
@@ -5815,7 +5709,7 @@ function createFinancialPlugin(options) {
|
|
|
5815
5709
|
locales: financialLocales
|
|
5816
5710
|
};
|
|
5817
5711
|
}
|
|
5818
|
-
var FinancialPage =
|
|
5712
|
+
var FinancialPage = React3__default.lazy(() => import('./FinancialPage-LCKLEAM3.js').then((m) => ({ default: m.FinancialPage })));
|
|
5819
5713
|
var FinancialGeneralSettings = lazyComponent(() => import('./FinancialGeneralSettings-WXJOCJPZ.js').then((m) => m.FinancialGeneralSettings));
|
|
5820
5714
|
var CommissionRulesView = lazyComponent(() => import('./CommissionRulesView-2RW4ZCDT.js').then((m) => m.CommissionRulesView));
|
|
5821
5715
|
var PersonStatementWidget = lazyComponent(() => import('./PersonStatementWidget-ULXXXYZ4.js').then((m) => m.PersonStatementWidget));
|