@fayz-ai/plugin-financial 0.29.8 → 0.29.9
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-YJUM62B7.js → FinancialPage-R5WZWICY.js} +93 -13
- package/dist/FinancialPage-R5WZWICY.js.map +1 -0
- package/dist/components/BatchClassify.d.ts +2 -4
- package/dist/components/BatchClassify.d.ts.map +1 -1
- package/dist/index.js +9 -1
- package/dist/index.js.map +1 -1
- package/dist/locales/en.d.ts.map +1 -1
- package/dist/locales/pt-BR.d.ts.map +1 -1
- package/dist/views/ReconciliationView.d.ts.map +1 -1
- package/package.json +2 -2
- package/dist/FinancialPage-YJUM62B7.js.map +0 -1
|
@@ -16,7 +16,7 @@ import { cnabPayeeGaps, inferPixKeyType, generateCnab240, splitAccountDigit, sug
|
|
|
16
16
|
import { invoiceOpensForEditing, availableInvoiceItemTypes } from '@fayz-ai/financial/domain/invoice';
|
|
17
17
|
import { createPortal } from 'react-dom';
|
|
18
18
|
import { newestStatementEntriesFirst } from '@fayz-ai/financial/domain/statement';
|
|
19
|
-
import { resolveCandidates, sumItems, itemsMismatch, adjustmentGap, adjustmentsMismatch, adjustmentDirection, reconciliationPaymentNote } from '@fayz-ai/financial/domain/reconciliation';
|
|
19
|
+
import { resolveCandidates, sumItems, itemsMismatch, adjustmentGap, adjustmentsMismatch, adjustmentDirection, reconciliationPaymentNote, descriptionShape, statementLineKey } from '@fayz-ai/financial/domain/reconciliation';
|
|
20
20
|
import { postableAccounts } from '@fayz-ai/financial/domain/chart-of-accounts';
|
|
21
21
|
import { round2 as round2$1 } from '@fayz-ai/financial/domain/money';
|
|
22
22
|
import { counterpartyAccountingPolicy, resolveCounterpartyAccountingPolicy } from '@fayz-ai/financial/domain/counterparty';
|
|
@@ -4634,15 +4634,12 @@ function ReconcileFlow({ line, initialIntent, initialTarget, initialStep = 0, on
|
|
|
4634
4634
|
}
|
|
4635
4635
|
);
|
|
4636
4636
|
}
|
|
4637
|
-
function descriptionShape(description) {
|
|
4638
|
-
return description.toUpperCase().normalize("NFKD").replace(/[̀-ͯ]/g, "").replace(/\d+([./-]\d+)*/g, " ").replace(/[^A-Z ]+/g, " ").replace(/\s+/g, " ").trim();
|
|
4639
|
-
}
|
|
4640
4637
|
function groupLines(lines) {
|
|
4641
4638
|
const groups = /* @__PURE__ */ new Map();
|
|
4642
4639
|
for (const line of lines) {
|
|
4643
4640
|
const doc = (line.counterpartyDocument ?? "").replace(/\D/g, "") || null;
|
|
4644
4641
|
const shape = descriptionShape(line.description || line.counterpartyName || "");
|
|
4645
|
-
const key =
|
|
4642
|
+
const key = statementLineKey(line);
|
|
4646
4643
|
const g = groups.get(key) ?? {
|
|
4647
4644
|
key,
|
|
4648
4645
|
direction: line.direction,
|
|
@@ -4690,6 +4687,7 @@ function BatchClassifyModal({ provider, bankAccountId, dateRange, onClose, onDon
|
|
|
4690
4687
|
counterAccountId: "",
|
|
4691
4688
|
excluded: /* @__PURE__ */ new Set()
|
|
4692
4689
|
}])));
|
|
4690
|
+
void prefill(lines, g).catch((e) => console.warn("[financial] batch suggestions unavailable", e));
|
|
4693
4691
|
}).catch((e) => {
|
|
4694
4692
|
toast.error("N\xE3o foi poss\xEDvel ler o extrato", { description: e instanceof Error ? e.message : String(e) });
|
|
4695
4693
|
setGroups([]);
|
|
@@ -4698,6 +4696,32 @@ function BatchClassifyModal({ provider, bankAccountId, dateRange, onClose, onDon
|
|
|
4698
4696
|
});
|
|
4699
4697
|
void provider.getBankAccounts().then((a) => alive && setAccounts(a.filter((x) => x.id !== bankAccountId))).catch(() => {
|
|
4700
4698
|
});
|
|
4699
|
+
async function prefill(lines, g) {
|
|
4700
|
+
if (!provider.suggestClassifications) return;
|
|
4701
|
+
const [memory, matches] = await Promise.all([
|
|
4702
|
+
provider.suggestClassifications(lines),
|
|
4703
|
+
provider.suggestReconciliationBatch ? provider.suggestReconciliationBatch(lines) : Promise.resolve({})
|
|
4704
|
+
]);
|
|
4705
|
+
if (!alive) return;
|
|
4706
|
+
setDecisions((prev) => {
|
|
4707
|
+
const next = { ...prev };
|
|
4708
|
+
for (const group of g) {
|
|
4709
|
+
const d = next[group.key];
|
|
4710
|
+
if (!d || d.action !== "skip") continue;
|
|
4711
|
+
if (group.lines.some((line) => (matches[line.id] ?? []).length > 0)) continue;
|
|
4712
|
+
const sug = group.lines.map((line) => memory[line.id]).find(Boolean);
|
|
4713
|
+
if (!sug) continue;
|
|
4714
|
+
next[group.key] = {
|
|
4715
|
+
...d,
|
|
4716
|
+
action: "bill",
|
|
4717
|
+
accountId: sug.accountId,
|
|
4718
|
+
contactName: d.contactName || sug.contactName || "",
|
|
4719
|
+
suggested: { accountId: sug.accountId, times: sug.times }
|
|
4720
|
+
};
|
|
4721
|
+
}
|
|
4722
|
+
return next;
|
|
4723
|
+
});
|
|
4724
|
+
}
|
|
4701
4725
|
return () => {
|
|
4702
4726
|
alive = false;
|
|
4703
4727
|
};
|
|
@@ -4858,6 +4882,11 @@ var GroupRow = memo(function GroupRow2({ g, d, expanded, chart, compare, account
|
|
|
4858
4882
|
"Documento ",
|
|
4859
4883
|
g.document
|
|
4860
4884
|
] }),
|
|
4885
|
+
d.suggested && d.action === "bill" && d.accountId === d.suggested.accountId && /* @__PURE__ */ jsxs("p", { className: "ml-6 text-xs text-magic-soft-foreground", children: [
|
|
4886
|
+
"Sugerido: lan\xE7ado assim nas \xFAltimas ",
|
|
4887
|
+
d.suggested.times,
|
|
4888
|
+
" vez(es)"
|
|
4889
|
+
] }),
|
|
4861
4890
|
/* @__PURE__ */ jsxs("div", { className: "ml-6 mt-2 grid gap-2 sm:grid-cols-[180px_1fr_1fr]", children: [
|
|
4862
4891
|
/* @__PURE__ */ jsxs(Select, { value: d.action, onValueChange: (v) => onSet(g.key, { action: v }), children: [
|
|
4863
4892
|
/* @__PURE__ */ jsx(SelectTrigger, { children: /* @__PURE__ */ jsx(SelectValue, {}) }),
|
|
@@ -5077,6 +5106,7 @@ function ReconciliationView() {
|
|
|
5077
5106
|
const [result, setResult] = useState(null);
|
|
5078
5107
|
const [loading, setLoading] = useState(false);
|
|
5079
5108
|
const [candidatos, setCandidatos] = useState({});
|
|
5109
|
+
const [classificacoes, setClassificacoes] = useState({});
|
|
5080
5110
|
const [sugerindo, setSugerindo] = useState(null);
|
|
5081
5111
|
const [busy, setBusy] = useState(false);
|
|
5082
5112
|
const [flow, setFlow] = useState(null);
|
|
@@ -5140,6 +5170,34 @@ function ReconciliationView() {
|
|
|
5140
5170
|
vivo = false;
|
|
5141
5171
|
};
|
|
5142
5172
|
}, [provider, linhasAbertas]);
|
|
5173
|
+
useEffect(() => {
|
|
5174
|
+
if (!provider.suggestClassifications || linhasAbertas.length === 0) return;
|
|
5175
|
+
let vivo = true;
|
|
5176
|
+
provider.suggestClassifications(linhasAbertas).then((achados) => {
|
|
5177
|
+
if (vivo) setClassificacoes((prev) => ({ ...prev, ...achados }));
|
|
5178
|
+
}).catch((error) => console.warn("[financial] classification suggestions unavailable", error));
|
|
5179
|
+
return () => {
|
|
5180
|
+
vivo = false;
|
|
5181
|
+
};
|
|
5182
|
+
}, [provider, linhasAbertas]);
|
|
5183
|
+
async function lancarSugerido(line, sugestao) {
|
|
5184
|
+
if (!provider.reconcileAsBill) return;
|
|
5185
|
+
setBusy(true);
|
|
5186
|
+
try {
|
|
5187
|
+
await provider.reconcileAsBill({
|
|
5188
|
+
bankMovementId: line.id,
|
|
5189
|
+
accountId: sugestao.accountId,
|
|
5190
|
+
contactName: line.counterpartyName || sugestao.contactName || void 0,
|
|
5191
|
+
description: line.description || void 0
|
|
5192
|
+
});
|
|
5193
|
+
toast.success(t("financial.reconciliation.classifiedAs", { account: sugestao.accountName ?? "" }));
|
|
5194
|
+
await load();
|
|
5195
|
+
} catch (e) {
|
|
5196
|
+
toast.error(e instanceof Error ? e.message : t("common.error"));
|
|
5197
|
+
} finally {
|
|
5198
|
+
setBusy(false);
|
|
5199
|
+
}
|
|
5200
|
+
}
|
|
5143
5201
|
const filtrar = filtros.apply;
|
|
5144
5202
|
async function sugerir(line) {
|
|
5145
5203
|
if (!provider.suggestReconciliation) return;
|
|
@@ -5429,6 +5487,8 @@ function ReconciliationView() {
|
|
|
5429
5487
|
{
|
|
5430
5488
|
line,
|
|
5431
5489
|
candidatos: candidatos[line.id],
|
|
5490
|
+
classificacao: classificacoes[line.id],
|
|
5491
|
+
onLancarSugerido: (sug) => void lancarSugerido(line, sug),
|
|
5432
5492
|
sugerindo: sugerindo === line.id,
|
|
5433
5493
|
busy,
|
|
5434
5494
|
fmt,
|
|
@@ -5524,10 +5584,12 @@ function CardSkeleton() {
|
|
|
5524
5584
|
function StatementCard({
|
|
5525
5585
|
line,
|
|
5526
5586
|
candidatos,
|
|
5587
|
+
classificacao,
|
|
5527
5588
|
sugerindo,
|
|
5528
5589
|
busy,
|
|
5529
5590
|
fmt,
|
|
5530
5591
|
t,
|
|
5592
|
+
onLancarSugerido,
|
|
5531
5593
|
onSugerir,
|
|
5532
5594
|
onTransferir,
|
|
5533
5595
|
onVincular,
|
|
@@ -5540,13 +5602,14 @@ function StatementCard({
|
|
|
5540
5602
|
const isCredit = line.direction === "credit";
|
|
5541
5603
|
const conciliada = !!line.reconciledAt;
|
|
5542
5604
|
const sugestao = candidatos?.[0];
|
|
5605
|
+
const classificar = !conciliada && !sugestao ? classificacao : void 0;
|
|
5543
5606
|
const delta = sugestao ? round2$1(sugestao.movement.amount - line.amount) : 0;
|
|
5544
5607
|
return (
|
|
5545
5608
|
// O cartão inteiro ganha um fundo de leve: a fita diz o estado a dois
|
|
5546
5609
|
// metros, mas é o fundo que separa as linhas que pedem decisão das que já
|
|
5547
5610
|
// não pedem, quando se rola cinquenta de uma vez.
|
|
5548
|
-
/* @__PURE__ */ jsxs(Card, { className: `relative space-y-3 overflow-hidden p-4 ${conciliada ? "border-2 border-success/50 bg-success-soft/25" : sugestao ? "border-2 border-magic/60 bg-magic-soft/40" : ""}`, children: [
|
|
5549
|
-
(conciliada || sugestao) && /* @__PURE__ */ jsx("div", { className: "pointer-events-none absolute right-0 top-0 z-10 h-24 w-24 overflow-hidden", "aria-hidden": true, children: /* @__PURE__ */ jsx(
|
|
5611
|
+
/* @__PURE__ */ jsxs(Card, { className: `relative space-y-3 overflow-hidden p-4 ${conciliada ? "border-2 border-success/50 bg-success-soft/25" : sugestao || classificar ? "border-2 border-magic/60 bg-magic-soft/40" : ""}`, children: [
|
|
5612
|
+
(conciliada || sugestao || classificar) && /* @__PURE__ */ jsx("div", { className: "pointer-events-none absolute right-0 top-0 z-10 h-24 w-24 overflow-hidden", "aria-hidden": true, children: /* @__PURE__ */ jsx(
|
|
5550
5613
|
"div",
|
|
5551
5614
|
{
|
|
5552
5615
|
className: `absolute py-1 text-center text-[10px] font-bold uppercase tracking-wide text-white shadow-md ${conciliada ? "bg-success" : "bg-magic"}`,
|
|
@@ -5554,7 +5617,7 @@ function StatementCard({
|
|
|
5554
5617
|
children: conciliada ? t("financial.reconciliation.reconciled") : t("financial.reconciliation.suggestion")
|
|
5555
5618
|
}
|
|
5556
5619
|
) }),
|
|
5557
|
-
/* @__PURE__ */ jsxs("div", { className: `flex flex-wrap items-start justify-between gap-4 ${conciliada || sugestao ? "pr-24" : ""}`, children: [
|
|
5620
|
+
/* @__PURE__ */ jsxs("div", { className: `flex flex-wrap items-start justify-between gap-4 ${conciliada || sugestao || classificar ? "pr-24" : ""}`, children: [
|
|
5558
5621
|
/* @__PURE__ */ jsxs("div", { className: "flex min-w-0 flex-wrap items-center gap-2", children: [
|
|
5559
5622
|
/* @__PURE__ */ jsx("span", { className: "text-sm font-semibold tabular-nums", children: line.date ? shortDate3(line.date) : "\u2014" }),
|
|
5560
5623
|
/* @__PURE__ */ jsx("span", { className: `rounded border px-1.5 py-px text-[11px] font-medium ${isCredit ? "border-success/60 text-success" : "border-destructive/60 text-destructive"}`, children: isCredit ? t("financial.reconciliation.credit") : t("financial.reconciliation.debit") }),
|
|
@@ -5636,7 +5699,24 @@ function StatementCard({
|
|
|
5636
5699
|
t("financial.reconciliation.match")
|
|
5637
5700
|
] })
|
|
5638
5701
|
] }),
|
|
5639
|
-
|
|
5702
|
+
classificar && /* @__PURE__ */ jsxs("div", { className: "flex flex-wrap items-start gap-3 rounded-md border border-magic/40 bg-card/70 p-3", children: [
|
|
5703
|
+
/* @__PURE__ */ jsxs("div", { className: "min-w-0 flex-1 text-sm", children: [
|
|
5704
|
+
/* @__PURE__ */ jsxs("span", { className: "inline-flex items-center gap-1 font-medium text-magic-soft-foreground", children: [
|
|
5705
|
+
/* @__PURE__ */ jsx(Sparkles, { className: "h-3.5 w-3.5 shrink-0", "aria-hidden": true }),
|
|
5706
|
+
t("financial.reconciliation.suggestionLabel")
|
|
5707
|
+
] }),
|
|
5708
|
+
" ",
|
|
5709
|
+
t("financial.reconciliation.classifyAs"),
|
|
5710
|
+
" ",
|
|
5711
|
+
/* @__PURE__ */ jsx("span", { className: "font-semibold", children: classificar.accountName }),
|
|
5712
|
+
/* @__PURE__ */ jsx("span", { className: "ml-2 text-xs text-muted-foreground", children: t("financial.reconciliation.classifiedBefore", { count: classificar.times }) })
|
|
5713
|
+
] }),
|
|
5714
|
+
/* @__PURE__ */ jsxs(Button, { size: "sm", className: "shrink-0", disabled: busy, onClick: () => onLancarSugerido(classificar), children: [
|
|
5715
|
+
/* @__PURE__ */ jsx(Receipt, { className: "h-3 w-3" }),
|
|
5716
|
+
t("financial.reconciliation.classifyAction")
|
|
5717
|
+
] })
|
|
5718
|
+
] }),
|
|
5719
|
+
!conciliada && !classificar && candidatos && candidatos.length === 0 && /* @__PURE__ */ jsx("p", { className: "rounded-md border border-dashed px-3 py-2 text-xs text-muted-foreground", children: t("financial.reconciliation.noCandidates") }),
|
|
5640
5720
|
/* @__PURE__ */ jsxs("div", { className: "flex flex-wrap items-center gap-2 border-t pt-2", children: [
|
|
5641
5721
|
!conciliada && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
5642
5722
|
/* @__PURE__ */ jsxs(Button, { variant: "ghost", size: "sm", disabled: busy, onClick: onTransferir, children: [
|
|
@@ -5671,13 +5751,13 @@ function StatementCard({
|
|
|
5671
5751
|
t("financial.reconciliation.undo")
|
|
5672
5752
|
] })
|
|
5673
5753
|
] }),
|
|
5674
|
-
!conciliada && !sugestao && /* @__PURE__ */ jsx(AiActionButton, { size: "sm", className: "ml-auto", busy: sugerindo, disabled: busy, onClick: onSugerir, children: t("financial.reconciliation.suggest") }),
|
|
5754
|
+
!conciliada && !sugestao && !classificar && /* @__PURE__ */ jsx(AiActionButton, { size: "sm", className: "ml-auto", busy: sugerindo, disabled: busy, onClick: onSugerir, children: t("financial.reconciliation.suggest") }),
|
|
5675
5755
|
/* @__PURE__ */ jsxs(
|
|
5676
5756
|
Button,
|
|
5677
5757
|
{
|
|
5678
5758
|
variant: "ghost",
|
|
5679
5759
|
size: "sm",
|
|
5680
|
-
className: conciliada || sugestao ? "ml-auto" : "",
|
|
5760
|
+
className: conciliada || sugestao || classificar ? "ml-auto" : "",
|
|
5681
5761
|
onClick: onDetalhes,
|
|
5682
5762
|
children: [
|
|
5683
5763
|
/* @__PURE__ */ jsx(Eye, { className: "h-3 w-3" }),
|
|
@@ -6662,5 +6742,5 @@ function FinancialPage({ config: appConfig, provider, store, registries }) {
|
|
|
6662
6742
|
}
|
|
6663
6743
|
|
|
6664
6744
|
export { FinancialPage };
|
|
6665
|
-
//# sourceMappingURL=FinancialPage-
|
|
6666
|
-
//# sourceMappingURL=FinancialPage-
|
|
6745
|
+
//# sourceMappingURL=FinancialPage-R5WZWICY.js.map
|
|
6746
|
+
//# sourceMappingURL=FinancialPage-R5WZWICY.js.map
|