@hed-hog/finance 0.0.274 → 0.0.276
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +228 -126
- package/dist/dto/create-bank-reconciliation.dto.d.ts +8 -0
- package/dist/dto/create-bank-reconciliation.dto.d.ts.map +1 -0
- package/dist/dto/create-bank-reconciliation.dto.js +43 -0
- package/dist/dto/create-bank-reconciliation.dto.js.map +1 -0
- package/dist/finance-data.controller.d.ts +2 -0
- package/dist/finance-data.controller.d.ts.map +1 -1
- package/dist/finance-statements.controller.d.ts +42 -0
- package/dist/finance-statements.controller.d.ts.map +1 -1
- package/dist/finance-statements.controller.js +13 -0
- package/dist/finance-statements.controller.js.map +1 -1
- package/dist/finance.service.d.ts +44 -0
- package/dist/finance.service.d.ts.map +1 -1
- package/dist/finance.service.js +98 -9
- package/dist/finance.service.js.map +1 -1
- package/hedhog/data/route.yaml +9 -0
- package/hedhog/frontend/app/_components/person-field-with-create.tsx.ejs +126 -126
- package/hedhog/frontend/app/accounts-payable/approvals/page.tsx.ejs +373 -373
- package/hedhog/frontend/app/accounts-payable/installments/[id]/page.tsx.ejs +1270 -1270
- package/hedhog/frontend/app/accounts-receivable/installments/[id]/page.tsx.ejs +982 -982
- package/hedhog/frontend/app/cash-and-banks/bank-accounts/page.tsx.ejs +686 -686
- package/hedhog/frontend/app/cash-and-banks/bank-reconciliation/page.tsx.ejs +152 -32
- package/hedhog/frontend/app/cash-and-banks/statements/page.tsx.ejs +986 -986
- package/hedhog/frontend/app/cash-and-banks/transfers/page.tsx.ejs +492 -492
- package/hedhog/frontend/app/page.tsx.ejs +372 -372
- package/hedhog/frontend/app/planning/cash-flow-forecast/page.tsx.ejs +329 -329
- package/hedhog/frontend/app/planning/receivables-calendar/page.tsx.ejs +227 -227
- package/hedhog/frontend/app/planning/scenarios/page.tsx.ejs +408 -408
- package/hedhog/frontend/messages/en.json +15 -5
- package/hedhog/frontend/messages/pt.json +15 -5
- package/package.json +7 -7
- package/src/dto/create-bank-reconciliation.dto.ts +24 -0
- package/src/finance-statements.controller.ts +14 -0
- package/src/finance.module.ts +43 -43
- package/src/finance.service.ts +118 -0
- package/src/index.ts +14 -14
- package/dist/finance.controller.d.ts +0 -276
- package/dist/finance.controller.d.ts.map +0 -1
- package/dist/finance.controller.js +0 -110
- package/dist/finance.controller.js.map +0 -1
|
@@ -1,329 +1,329 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
|
|
3
|
-
import { Page, PageHeader } from '@/components/entity-list';
|
|
4
|
-
import { Button } from '@/components/ui/button';
|
|
5
|
-
import {
|
|
6
|
-
Card,
|
|
7
|
-
CardContent,
|
|
8
|
-
CardDescription,
|
|
9
|
-
CardHeader,
|
|
10
|
-
CardTitle,
|
|
11
|
-
} from '@/components/ui/card';
|
|
12
|
-
import { Money } from '@/components/ui/money';
|
|
13
|
-
import {
|
|
14
|
-
Select,
|
|
15
|
-
SelectContent,
|
|
16
|
-
SelectItem,
|
|
17
|
-
SelectTrigger,
|
|
18
|
-
SelectValue,
|
|
19
|
-
} from '@/components/ui/select';
|
|
20
|
-
import {
|
|
21
|
-
Table,
|
|
22
|
-
TableBody,
|
|
23
|
-
TableCell,
|
|
24
|
-
TableHead,
|
|
25
|
-
TableHeader,
|
|
26
|
-
TableRow,
|
|
27
|
-
} from '@/components/ui/table';
|
|
28
|
-
import { Tabs, TabsContent, TabsList, TabsTrigger } from '@/components/ui/tabs';
|
|
29
|
-
import {
|
|
30
|
-
Download,
|
|
31
|
-
Loader2,
|
|
32
|
-
TrendingDown,
|
|
33
|
-
TrendingUp,
|
|
34
|
-
Wallet,
|
|
35
|
-
} from 'lucide-react';
|
|
36
|
-
import { useTranslations } from 'next-intl';
|
|
37
|
-
import { useState } from 'react';
|
|
38
|
-
import {
|
|
39
|
-
Area,
|
|
40
|
-
AreaChart,
|
|
41
|
-
CartesianGrid,
|
|
42
|
-
Legend,
|
|
43
|
-
ResponsiveContainer,
|
|
44
|
-
Tooltip,
|
|
45
|
-
XAxis,
|
|
46
|
-
YAxis,
|
|
47
|
-
} from 'recharts';
|
|
48
|
-
import { formatarData, formatarMoeda } from '../../_lib/formatters';
|
|
49
|
-
import { useFinanceData } from '../../_lib/use-finance-data';
|
|
50
|
-
|
|
51
|
-
export default function FluxoCaixaPage() {
|
|
52
|
-
const t = useTranslations('finance.CashFlowForecastPage');
|
|
53
|
-
|
|
54
|
-
const [horizonte, setHorizonte] = useState<string | null>(null);
|
|
55
|
-
const [cenario, setCenario] = useState<
|
|
56
|
-
'base' | 'pessimista' | 'otimista' | null
|
|
57
|
-
>(null);
|
|
58
|
-
|
|
59
|
-
const { data, isFetching } = useFinanceData({
|
|
60
|
-
horizonteDias: horizonte ? Number(horizonte) : undefined,
|
|
61
|
-
cenario: cenario || undefined,
|
|
62
|
-
});
|
|
63
|
-
|
|
64
|
-
const { fluxoCaixaPrevisto, kpis, entradasPrevistas, saidasPrevistas } = data;
|
|
65
|
-
const selectedHorizon = horizonte || String(data.defaultHorizonDays || 90);
|
|
66
|
-
const selectedScenario = cenario || data.defaultScenario || 'base';
|
|
67
|
-
|
|
68
|
-
const chartData = fluxoCaixaPrevisto.map((item) => ({
|
|
69
|
-
...item,
|
|
70
|
-
data: formatarData(item.data),
|
|
71
|
-
}));
|
|
72
|
-
|
|
73
|
-
const totalEntradas = entradasPrevistas.reduce((acc, e) => acc + e.valor, 0);
|
|
74
|
-
const totalSaidas = saidasPrevistas.reduce((acc, s) => acc + s.valor, 0);
|
|
75
|
-
const saldoFinal = kpis.saldoCaixa + totalEntradas - totalSaidas;
|
|
76
|
-
|
|
77
|
-
return (
|
|
78
|
-
<Page>
|
|
79
|
-
<PageHeader
|
|
80
|
-
title={t('header.title')}
|
|
81
|
-
description={t('header.description')}
|
|
82
|
-
breadcrumbs={[
|
|
83
|
-
{ label: t('breadcrumbs.home'), href: '/' },
|
|
84
|
-
{ label: t('breadcrumbs.finance'), href: '/finance' },
|
|
85
|
-
{ label: t('breadcrumbs.current') },
|
|
86
|
-
]}
|
|
87
|
-
actions={
|
|
88
|
-
<Button variant="outline">
|
|
89
|
-
<Download className="mr-2 h-4 w-4" />
|
|
90
|
-
{t('actions.export')}
|
|
91
|
-
</Button>
|
|
92
|
-
}
|
|
93
|
-
/>
|
|
94
|
-
|
|
95
|
-
<div className="flex flex-col gap-4 sm:flex-row sm:items-center">
|
|
96
|
-
<Select
|
|
97
|
-
value={selectedHorizon}
|
|
98
|
-
onValueChange={setHorizonte}
|
|
99
|
-
disabled={isFetching}
|
|
100
|
-
>
|
|
101
|
-
<SelectTrigger className="w-[180px]">
|
|
102
|
-
<SelectValue placeholder={t('filters.horizon')} />
|
|
103
|
-
</SelectTrigger>
|
|
104
|
-
<SelectContent>
|
|
105
|
-
<SelectItem value="30">{t('filters.days30')}</SelectItem>
|
|
106
|
-
<SelectItem value="60">{t('filters.days60')}</SelectItem>
|
|
107
|
-
<SelectItem value="90">{t('filters.days90')}</SelectItem>
|
|
108
|
-
<SelectItem value="180">{t('filters.days180')}</SelectItem>
|
|
109
|
-
<SelectItem value="365">{t('filters.days365')}</SelectItem>
|
|
110
|
-
</SelectContent>
|
|
111
|
-
</Select>
|
|
112
|
-
<Select
|
|
113
|
-
value={selectedScenario}
|
|
114
|
-
onValueChange={(value) =>
|
|
115
|
-
setCenario(value as 'base' | 'pessimista' | 'otimista')
|
|
116
|
-
}
|
|
117
|
-
disabled={isFetching}
|
|
118
|
-
>
|
|
119
|
-
<SelectTrigger className="w-[180px]">
|
|
120
|
-
<SelectValue placeholder={t('filters.scenario')} />
|
|
121
|
-
</SelectTrigger>
|
|
122
|
-
<SelectContent>
|
|
123
|
-
<SelectItem value="base">{t('scenarios.base')}</SelectItem>
|
|
124
|
-
<SelectItem value="pessimista">
|
|
125
|
-
{t('scenarios.pessimistic')}
|
|
126
|
-
</SelectItem>
|
|
127
|
-
<SelectItem value="otimista">
|
|
128
|
-
{t('scenarios.optimistic')}
|
|
129
|
-
</SelectItem>
|
|
130
|
-
</SelectContent>
|
|
131
|
-
</Select>
|
|
132
|
-
{isFetching ? (
|
|
133
|
-
<div className="text-muted-foreground flex items-center gap-2 text-sm">
|
|
134
|
-
<Loader2 className="h-4 w-4 animate-spin" />
|
|
135
|
-
Atualizando dados...
|
|
136
|
-
</div>
|
|
137
|
-
) : null}
|
|
138
|
-
</div>
|
|
139
|
-
|
|
140
|
-
<div className="grid gap-4 md:grid-cols-4">
|
|
141
|
-
<Card>
|
|
142
|
-
<CardHeader className="flex flex-row items-center justify-between space-y-0 pb-2">
|
|
143
|
-
<CardTitle className="text-sm font-medium">
|
|
144
|
-
{t('cards.currentBalance')}
|
|
145
|
-
</CardTitle>
|
|
146
|
-
<Wallet className="h-4 w-4 text-muted-foreground" />
|
|
147
|
-
</CardHeader>
|
|
148
|
-
<CardContent>
|
|
149
|
-
<div className="text-2xl font-bold">
|
|
150
|
-
<Money value={kpis.saldoCaixa} />
|
|
151
|
-
</div>
|
|
152
|
-
</CardContent>
|
|
153
|
-
</Card>
|
|
154
|
-
<Card>
|
|
155
|
-
<CardHeader className="flex flex-row items-center justify-between space-y-0 pb-2">
|
|
156
|
-
<CardTitle className="text-sm font-medium">
|
|
157
|
-
{t('cards.expectedInflows')}
|
|
158
|
-
</CardTitle>
|
|
159
|
-
<TrendingUp className="h-4 w-4 text-green-500" />
|
|
160
|
-
</CardHeader>
|
|
161
|
-
<CardContent>
|
|
162
|
-
<div className="text-2xl font-bold text-green-600">
|
|
163
|
-
<Money value={totalEntradas} />
|
|
164
|
-
</div>
|
|
165
|
-
</CardContent>
|
|
166
|
-
</Card>
|
|
167
|
-
<Card>
|
|
168
|
-
<CardHeader className="flex flex-row items-center justify-between space-y-0 pb-2">
|
|
169
|
-
<CardTitle className="text-sm font-medium">
|
|
170
|
-
{t('cards.expectedOutflows')}
|
|
171
|
-
</CardTitle>
|
|
172
|
-
<TrendingDown className="h-4 w-4 text-red-500" />
|
|
173
|
-
</CardHeader>
|
|
174
|
-
<CardContent>
|
|
175
|
-
<div className="text-2xl font-bold text-red-600">
|
|
176
|
-
<Money value={totalSaidas} />
|
|
177
|
-
</div>
|
|
178
|
-
</CardContent>
|
|
179
|
-
</Card>
|
|
180
|
-
<Card>
|
|
181
|
-
<CardHeader className="flex flex-row items-center justify-between space-y-0 pb-2">
|
|
182
|
-
<CardTitle className="text-sm font-medium">
|
|
183
|
-
{t('cards.projectedBalance')}
|
|
184
|
-
</CardTitle>
|
|
185
|
-
</CardHeader>
|
|
186
|
-
<CardContent>
|
|
187
|
-
<div
|
|
188
|
-
className={`text-2xl font-bold ${saldoFinal >= 0 ? 'text-green-600' : 'text-red-600'}`}
|
|
189
|
-
>
|
|
190
|
-
<Money value={saldoFinal} />
|
|
191
|
-
</div>
|
|
192
|
-
</CardContent>
|
|
193
|
-
</Card>
|
|
194
|
-
</div>
|
|
195
|
-
|
|
196
|
-
<Card>
|
|
197
|
-
<CardHeader>
|
|
198
|
-
<CardTitle>{t('projection.title')}</CardTitle>
|
|
199
|
-
<CardDescription>{t('projection.description')}</CardDescription>
|
|
200
|
-
</CardHeader>
|
|
201
|
-
<CardContent>
|
|
202
|
-
<ResponsiveContainer width="100%" height={350}>
|
|
203
|
-
<AreaChart data={chartData}>
|
|
204
|
-
<CartesianGrid strokeDasharray="3 3" className="stroke-muted" />
|
|
205
|
-
<XAxis dataKey="data" tick={{ fontSize: 12 }} />
|
|
206
|
-
<YAxis
|
|
207
|
-
tick={{ fontSize: 12 }}
|
|
208
|
-
tickFormatter={(value) => `${(value / 1000).toFixed(0)}k`}
|
|
209
|
-
/>
|
|
210
|
-
<Tooltip
|
|
211
|
-
formatter={(value: number) => formatarMoeda(value)}
|
|
212
|
-
contentStyle={{
|
|
213
|
-
backgroundColor: 'hsl(var(--background))',
|
|
214
|
-
border: '1px solid hsl(var(--border))',
|
|
215
|
-
borderRadius: '8px',
|
|
216
|
-
}}
|
|
217
|
-
/>
|
|
218
|
-
<Legend />
|
|
219
|
-
<Area
|
|
220
|
-
type="monotone"
|
|
221
|
-
dataKey="saldoPrevisto"
|
|
222
|
-
name={t('projection.predictedBalance')}
|
|
223
|
-
stroke="hsl(var(--primary))"
|
|
224
|
-
fill="hsl(var(--primary))"
|
|
225
|
-
fillOpacity={0.2}
|
|
226
|
-
/>
|
|
227
|
-
<Area
|
|
228
|
-
type="monotone"
|
|
229
|
-
dataKey="saldoRealizado"
|
|
230
|
-
name={t('projection.actualBalance')}
|
|
231
|
-
stroke="hsl(var(--chart-2))"
|
|
232
|
-
fill="hsl(var(--chart-2))"
|
|
233
|
-
fillOpacity={0.2}
|
|
234
|
-
connectNulls
|
|
235
|
-
/>
|
|
236
|
-
</AreaChart>
|
|
237
|
-
</ResponsiveContainer>
|
|
238
|
-
</CardContent>
|
|
239
|
-
</Card>
|
|
240
|
-
|
|
241
|
-
<Tabs defaultValue="entradas">
|
|
242
|
-
<TabsList>
|
|
243
|
-
<TabsTrigger value="entradas">
|
|
244
|
-
{t('tabs.expectedInflows')}
|
|
245
|
-
</TabsTrigger>
|
|
246
|
-
<TabsTrigger value="saidas">{t('tabs.expectedOutflows')}</TabsTrigger>
|
|
247
|
-
</TabsList>
|
|
248
|
-
|
|
249
|
-
<TabsContent value="entradas" className="mt-4">
|
|
250
|
-
<Card>
|
|
251
|
-
<CardContent className="pt-6">
|
|
252
|
-
<Table>
|
|
253
|
-
<TableHeader>
|
|
254
|
-
<TableRow>
|
|
255
|
-
<TableHead>{t('table.headers.category')}</TableHead>
|
|
256
|
-
<TableHead>{t('table.headers.dueDate')}</TableHead>
|
|
257
|
-
<TableHead className="text-right">
|
|
258
|
-
{t('table.headers.value')}
|
|
259
|
-
</TableHead>
|
|
260
|
-
</TableRow>
|
|
261
|
-
</TableHeader>
|
|
262
|
-
<TableBody>
|
|
263
|
-
{entradasPrevistas.map((entrada, i) => (
|
|
264
|
-
<TableRow key={i}>
|
|
265
|
-
<TableCell className="font-medium">
|
|
266
|
-
{entrada.categoria}
|
|
267
|
-
</TableCell>
|
|
268
|
-
<TableCell>{formatarData(entrada.vencimento)}</TableCell>
|
|
269
|
-
<TableCell className="text-right text-green-600 font-semibold">
|
|
270
|
-
<Money value={entrada.valor} />
|
|
271
|
-
</TableCell>
|
|
272
|
-
</TableRow>
|
|
273
|
-
))}
|
|
274
|
-
<TableRow className="bg-muted/50">
|
|
275
|
-
<TableCell className="font-bold" colSpan={2}>
|
|
276
|
-
{t('table.total')}
|
|
277
|
-
</TableCell>
|
|
278
|
-
<TableCell className="text-right font-bold text-green-600">
|
|
279
|
-
<Money value={totalEntradas} />
|
|
280
|
-
</TableCell>
|
|
281
|
-
</TableRow>
|
|
282
|
-
</TableBody>
|
|
283
|
-
</Table>
|
|
284
|
-
</CardContent>
|
|
285
|
-
</Card>
|
|
286
|
-
</TabsContent>
|
|
287
|
-
|
|
288
|
-
<TabsContent value="saidas" className="mt-4">
|
|
289
|
-
<Card>
|
|
290
|
-
<CardContent className="pt-6">
|
|
291
|
-
<Table>
|
|
292
|
-
<TableHeader>
|
|
293
|
-
<TableRow>
|
|
294
|
-
<TableHead>{t('table.headers.category')}</TableHead>
|
|
295
|
-
<TableHead>{t('table.headers.dueDate')}</TableHead>
|
|
296
|
-
<TableHead className="text-right">
|
|
297
|
-
{t('table.headers.value')}
|
|
298
|
-
</TableHead>
|
|
299
|
-
</TableRow>
|
|
300
|
-
</TableHeader>
|
|
301
|
-
<TableBody>
|
|
302
|
-
{saidasPrevistas.map((saida, i) => (
|
|
303
|
-
<TableRow key={i}>
|
|
304
|
-
<TableCell className="font-medium">
|
|
305
|
-
{saida.categoria}
|
|
306
|
-
</TableCell>
|
|
307
|
-
<TableCell>{formatarData(saida.vencimento)}</TableCell>
|
|
308
|
-
<TableCell className="text-right text-red-600 font-semibold">
|
|
309
|
-
<Money value={saida.valor} />
|
|
310
|
-
</TableCell>
|
|
311
|
-
</TableRow>
|
|
312
|
-
))}
|
|
313
|
-
<TableRow className="bg-muted/50">
|
|
314
|
-
<TableCell className="font-bold" colSpan={2}>
|
|
315
|
-
{t('table.total')}
|
|
316
|
-
</TableCell>
|
|
317
|
-
<TableCell className="text-right font-bold text-red-600">
|
|
318
|
-
<Money value={totalSaidas} />
|
|
319
|
-
</TableCell>
|
|
320
|
-
</TableRow>
|
|
321
|
-
</TableBody>
|
|
322
|
-
</Table>
|
|
323
|
-
</CardContent>
|
|
324
|
-
</Card>
|
|
325
|
-
</TabsContent>
|
|
326
|
-
</Tabs>
|
|
327
|
-
</Page>
|
|
328
|
-
);
|
|
329
|
-
}
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { Page, PageHeader } from '@/components/entity-list';
|
|
4
|
+
import { Button } from '@/components/ui/button';
|
|
5
|
+
import {
|
|
6
|
+
Card,
|
|
7
|
+
CardContent,
|
|
8
|
+
CardDescription,
|
|
9
|
+
CardHeader,
|
|
10
|
+
CardTitle,
|
|
11
|
+
} from '@/components/ui/card';
|
|
12
|
+
import { Money } from '@/components/ui/money';
|
|
13
|
+
import {
|
|
14
|
+
Select,
|
|
15
|
+
SelectContent,
|
|
16
|
+
SelectItem,
|
|
17
|
+
SelectTrigger,
|
|
18
|
+
SelectValue,
|
|
19
|
+
} from '@/components/ui/select';
|
|
20
|
+
import {
|
|
21
|
+
Table,
|
|
22
|
+
TableBody,
|
|
23
|
+
TableCell,
|
|
24
|
+
TableHead,
|
|
25
|
+
TableHeader,
|
|
26
|
+
TableRow,
|
|
27
|
+
} from '@/components/ui/table';
|
|
28
|
+
import { Tabs, TabsContent, TabsList, TabsTrigger } from '@/components/ui/tabs';
|
|
29
|
+
import {
|
|
30
|
+
Download,
|
|
31
|
+
Loader2,
|
|
32
|
+
TrendingDown,
|
|
33
|
+
TrendingUp,
|
|
34
|
+
Wallet,
|
|
35
|
+
} from 'lucide-react';
|
|
36
|
+
import { useTranslations } from 'next-intl';
|
|
37
|
+
import { useState } from 'react';
|
|
38
|
+
import {
|
|
39
|
+
Area,
|
|
40
|
+
AreaChart,
|
|
41
|
+
CartesianGrid,
|
|
42
|
+
Legend,
|
|
43
|
+
ResponsiveContainer,
|
|
44
|
+
Tooltip,
|
|
45
|
+
XAxis,
|
|
46
|
+
YAxis,
|
|
47
|
+
} from 'recharts';
|
|
48
|
+
import { formatarData, formatarMoeda } from '../../_lib/formatters';
|
|
49
|
+
import { useFinanceData } from '../../_lib/use-finance-data';
|
|
50
|
+
|
|
51
|
+
export default function FluxoCaixaPage() {
|
|
52
|
+
const t = useTranslations('finance.CashFlowForecastPage');
|
|
53
|
+
|
|
54
|
+
const [horizonte, setHorizonte] = useState<string | null>(null);
|
|
55
|
+
const [cenario, setCenario] = useState<
|
|
56
|
+
'base' | 'pessimista' | 'otimista' | null
|
|
57
|
+
>(null);
|
|
58
|
+
|
|
59
|
+
const { data, isFetching } = useFinanceData({
|
|
60
|
+
horizonteDias: horizonte ? Number(horizonte) : undefined,
|
|
61
|
+
cenario: cenario || undefined,
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
const { fluxoCaixaPrevisto, kpis, entradasPrevistas, saidasPrevistas } = data;
|
|
65
|
+
const selectedHorizon = horizonte || String(data.defaultHorizonDays || 90);
|
|
66
|
+
const selectedScenario = cenario || data.defaultScenario || 'base';
|
|
67
|
+
|
|
68
|
+
const chartData = fluxoCaixaPrevisto.map((item) => ({
|
|
69
|
+
...item,
|
|
70
|
+
data: formatarData(item.data),
|
|
71
|
+
}));
|
|
72
|
+
|
|
73
|
+
const totalEntradas = entradasPrevistas.reduce((acc, e) => acc + e.valor, 0);
|
|
74
|
+
const totalSaidas = saidasPrevistas.reduce((acc, s) => acc + s.valor, 0);
|
|
75
|
+
const saldoFinal = kpis.saldoCaixa + totalEntradas - totalSaidas;
|
|
76
|
+
|
|
77
|
+
return (
|
|
78
|
+
<Page>
|
|
79
|
+
<PageHeader
|
|
80
|
+
title={t('header.title')}
|
|
81
|
+
description={t('header.description')}
|
|
82
|
+
breadcrumbs={[
|
|
83
|
+
{ label: t('breadcrumbs.home'), href: '/' },
|
|
84
|
+
{ label: t('breadcrumbs.finance'), href: '/finance' },
|
|
85
|
+
{ label: t('breadcrumbs.current') },
|
|
86
|
+
]}
|
|
87
|
+
actions={
|
|
88
|
+
<Button variant="outline">
|
|
89
|
+
<Download className="mr-2 h-4 w-4" />
|
|
90
|
+
{t('actions.export')}
|
|
91
|
+
</Button>
|
|
92
|
+
}
|
|
93
|
+
/>
|
|
94
|
+
|
|
95
|
+
<div className="flex flex-col gap-4 sm:flex-row sm:items-center">
|
|
96
|
+
<Select
|
|
97
|
+
value={selectedHorizon}
|
|
98
|
+
onValueChange={setHorizonte}
|
|
99
|
+
disabled={isFetching}
|
|
100
|
+
>
|
|
101
|
+
<SelectTrigger className="w-[180px]">
|
|
102
|
+
<SelectValue placeholder={t('filters.horizon')} />
|
|
103
|
+
</SelectTrigger>
|
|
104
|
+
<SelectContent>
|
|
105
|
+
<SelectItem value="30">{t('filters.days30')}</SelectItem>
|
|
106
|
+
<SelectItem value="60">{t('filters.days60')}</SelectItem>
|
|
107
|
+
<SelectItem value="90">{t('filters.days90')}</SelectItem>
|
|
108
|
+
<SelectItem value="180">{t('filters.days180')}</SelectItem>
|
|
109
|
+
<SelectItem value="365">{t('filters.days365')}</SelectItem>
|
|
110
|
+
</SelectContent>
|
|
111
|
+
</Select>
|
|
112
|
+
<Select
|
|
113
|
+
value={selectedScenario}
|
|
114
|
+
onValueChange={(value) =>
|
|
115
|
+
setCenario(value as 'base' | 'pessimista' | 'otimista')
|
|
116
|
+
}
|
|
117
|
+
disabled={isFetching}
|
|
118
|
+
>
|
|
119
|
+
<SelectTrigger className="w-[180px]">
|
|
120
|
+
<SelectValue placeholder={t('filters.scenario')} />
|
|
121
|
+
</SelectTrigger>
|
|
122
|
+
<SelectContent>
|
|
123
|
+
<SelectItem value="base">{t('scenarios.base')}</SelectItem>
|
|
124
|
+
<SelectItem value="pessimista">
|
|
125
|
+
{t('scenarios.pessimistic')}
|
|
126
|
+
</SelectItem>
|
|
127
|
+
<SelectItem value="otimista">
|
|
128
|
+
{t('scenarios.optimistic')}
|
|
129
|
+
</SelectItem>
|
|
130
|
+
</SelectContent>
|
|
131
|
+
</Select>
|
|
132
|
+
{isFetching ? (
|
|
133
|
+
<div className="text-muted-foreground flex items-center gap-2 text-sm">
|
|
134
|
+
<Loader2 className="h-4 w-4 animate-spin" />
|
|
135
|
+
Atualizando dados...
|
|
136
|
+
</div>
|
|
137
|
+
) : null}
|
|
138
|
+
</div>
|
|
139
|
+
|
|
140
|
+
<div className="grid gap-4 md:grid-cols-4">
|
|
141
|
+
<Card>
|
|
142
|
+
<CardHeader className="flex flex-row items-center justify-between space-y-0 pb-2">
|
|
143
|
+
<CardTitle className="text-sm font-medium">
|
|
144
|
+
{t('cards.currentBalance')}
|
|
145
|
+
</CardTitle>
|
|
146
|
+
<Wallet className="h-4 w-4 text-muted-foreground" />
|
|
147
|
+
</CardHeader>
|
|
148
|
+
<CardContent>
|
|
149
|
+
<div className="text-2xl font-bold">
|
|
150
|
+
<Money value={kpis.saldoCaixa} />
|
|
151
|
+
</div>
|
|
152
|
+
</CardContent>
|
|
153
|
+
</Card>
|
|
154
|
+
<Card>
|
|
155
|
+
<CardHeader className="flex flex-row items-center justify-between space-y-0 pb-2">
|
|
156
|
+
<CardTitle className="text-sm font-medium">
|
|
157
|
+
{t('cards.expectedInflows')}
|
|
158
|
+
</CardTitle>
|
|
159
|
+
<TrendingUp className="h-4 w-4 text-green-500" />
|
|
160
|
+
</CardHeader>
|
|
161
|
+
<CardContent>
|
|
162
|
+
<div className="text-2xl font-bold text-green-600">
|
|
163
|
+
<Money value={totalEntradas} />
|
|
164
|
+
</div>
|
|
165
|
+
</CardContent>
|
|
166
|
+
</Card>
|
|
167
|
+
<Card>
|
|
168
|
+
<CardHeader className="flex flex-row items-center justify-between space-y-0 pb-2">
|
|
169
|
+
<CardTitle className="text-sm font-medium">
|
|
170
|
+
{t('cards.expectedOutflows')}
|
|
171
|
+
</CardTitle>
|
|
172
|
+
<TrendingDown className="h-4 w-4 text-red-500" />
|
|
173
|
+
</CardHeader>
|
|
174
|
+
<CardContent>
|
|
175
|
+
<div className="text-2xl font-bold text-red-600">
|
|
176
|
+
<Money value={totalSaidas} />
|
|
177
|
+
</div>
|
|
178
|
+
</CardContent>
|
|
179
|
+
</Card>
|
|
180
|
+
<Card>
|
|
181
|
+
<CardHeader className="flex flex-row items-center justify-between space-y-0 pb-2">
|
|
182
|
+
<CardTitle className="text-sm font-medium">
|
|
183
|
+
{t('cards.projectedBalance')}
|
|
184
|
+
</CardTitle>
|
|
185
|
+
</CardHeader>
|
|
186
|
+
<CardContent>
|
|
187
|
+
<div
|
|
188
|
+
className={`text-2xl font-bold ${saldoFinal >= 0 ? 'text-green-600' : 'text-red-600'}`}
|
|
189
|
+
>
|
|
190
|
+
<Money value={saldoFinal} />
|
|
191
|
+
</div>
|
|
192
|
+
</CardContent>
|
|
193
|
+
</Card>
|
|
194
|
+
</div>
|
|
195
|
+
|
|
196
|
+
<Card>
|
|
197
|
+
<CardHeader>
|
|
198
|
+
<CardTitle>{t('projection.title')}</CardTitle>
|
|
199
|
+
<CardDescription>{t('projection.description')}</CardDescription>
|
|
200
|
+
</CardHeader>
|
|
201
|
+
<CardContent>
|
|
202
|
+
<ResponsiveContainer width="100%" height={350}>
|
|
203
|
+
<AreaChart data={chartData}>
|
|
204
|
+
<CartesianGrid strokeDasharray="3 3" className="stroke-muted" />
|
|
205
|
+
<XAxis dataKey="data" tick={{ fontSize: 12 }} />
|
|
206
|
+
<YAxis
|
|
207
|
+
tick={{ fontSize: 12 }}
|
|
208
|
+
tickFormatter={(value) => `${(value / 1000).toFixed(0)}k`}
|
|
209
|
+
/>
|
|
210
|
+
<Tooltip
|
|
211
|
+
formatter={(value: number) => formatarMoeda(value)}
|
|
212
|
+
contentStyle={{
|
|
213
|
+
backgroundColor: 'hsl(var(--background))',
|
|
214
|
+
border: '1px solid hsl(var(--border))',
|
|
215
|
+
borderRadius: '8px',
|
|
216
|
+
}}
|
|
217
|
+
/>
|
|
218
|
+
<Legend />
|
|
219
|
+
<Area
|
|
220
|
+
type="monotone"
|
|
221
|
+
dataKey="saldoPrevisto"
|
|
222
|
+
name={t('projection.predictedBalance')}
|
|
223
|
+
stroke="hsl(var(--primary))"
|
|
224
|
+
fill="hsl(var(--primary))"
|
|
225
|
+
fillOpacity={0.2}
|
|
226
|
+
/>
|
|
227
|
+
<Area
|
|
228
|
+
type="monotone"
|
|
229
|
+
dataKey="saldoRealizado"
|
|
230
|
+
name={t('projection.actualBalance')}
|
|
231
|
+
stroke="hsl(var(--chart-2))"
|
|
232
|
+
fill="hsl(var(--chart-2))"
|
|
233
|
+
fillOpacity={0.2}
|
|
234
|
+
connectNulls
|
|
235
|
+
/>
|
|
236
|
+
</AreaChart>
|
|
237
|
+
</ResponsiveContainer>
|
|
238
|
+
</CardContent>
|
|
239
|
+
</Card>
|
|
240
|
+
|
|
241
|
+
<Tabs defaultValue="entradas">
|
|
242
|
+
<TabsList>
|
|
243
|
+
<TabsTrigger value="entradas">
|
|
244
|
+
{t('tabs.expectedInflows')}
|
|
245
|
+
</TabsTrigger>
|
|
246
|
+
<TabsTrigger value="saidas">{t('tabs.expectedOutflows')}</TabsTrigger>
|
|
247
|
+
</TabsList>
|
|
248
|
+
|
|
249
|
+
<TabsContent value="entradas" className="mt-4">
|
|
250
|
+
<Card>
|
|
251
|
+
<CardContent className="pt-6">
|
|
252
|
+
<Table>
|
|
253
|
+
<TableHeader>
|
|
254
|
+
<TableRow>
|
|
255
|
+
<TableHead>{t('table.headers.category')}</TableHead>
|
|
256
|
+
<TableHead>{t('table.headers.dueDate')}</TableHead>
|
|
257
|
+
<TableHead className="text-right">
|
|
258
|
+
{t('table.headers.value')}
|
|
259
|
+
</TableHead>
|
|
260
|
+
</TableRow>
|
|
261
|
+
</TableHeader>
|
|
262
|
+
<TableBody>
|
|
263
|
+
{entradasPrevistas.map((entrada, i) => (
|
|
264
|
+
<TableRow key={i}>
|
|
265
|
+
<TableCell className="font-medium">
|
|
266
|
+
{entrada.categoria}
|
|
267
|
+
</TableCell>
|
|
268
|
+
<TableCell>{formatarData(entrada.vencimento)}</TableCell>
|
|
269
|
+
<TableCell className="text-right text-green-600 font-semibold">
|
|
270
|
+
<Money value={entrada.valor} />
|
|
271
|
+
</TableCell>
|
|
272
|
+
</TableRow>
|
|
273
|
+
))}
|
|
274
|
+
<TableRow className="bg-muted/50">
|
|
275
|
+
<TableCell className="font-bold" colSpan={2}>
|
|
276
|
+
{t('table.total')}
|
|
277
|
+
</TableCell>
|
|
278
|
+
<TableCell className="text-right font-bold text-green-600">
|
|
279
|
+
<Money value={totalEntradas} />
|
|
280
|
+
</TableCell>
|
|
281
|
+
</TableRow>
|
|
282
|
+
</TableBody>
|
|
283
|
+
</Table>
|
|
284
|
+
</CardContent>
|
|
285
|
+
</Card>
|
|
286
|
+
</TabsContent>
|
|
287
|
+
|
|
288
|
+
<TabsContent value="saidas" className="mt-4">
|
|
289
|
+
<Card>
|
|
290
|
+
<CardContent className="pt-6">
|
|
291
|
+
<Table>
|
|
292
|
+
<TableHeader>
|
|
293
|
+
<TableRow>
|
|
294
|
+
<TableHead>{t('table.headers.category')}</TableHead>
|
|
295
|
+
<TableHead>{t('table.headers.dueDate')}</TableHead>
|
|
296
|
+
<TableHead className="text-right">
|
|
297
|
+
{t('table.headers.value')}
|
|
298
|
+
</TableHead>
|
|
299
|
+
</TableRow>
|
|
300
|
+
</TableHeader>
|
|
301
|
+
<TableBody>
|
|
302
|
+
{saidasPrevistas.map((saida, i) => (
|
|
303
|
+
<TableRow key={i}>
|
|
304
|
+
<TableCell className="font-medium">
|
|
305
|
+
{saida.categoria}
|
|
306
|
+
</TableCell>
|
|
307
|
+
<TableCell>{formatarData(saida.vencimento)}</TableCell>
|
|
308
|
+
<TableCell className="text-right text-red-600 font-semibold">
|
|
309
|
+
<Money value={saida.valor} />
|
|
310
|
+
</TableCell>
|
|
311
|
+
</TableRow>
|
|
312
|
+
))}
|
|
313
|
+
<TableRow className="bg-muted/50">
|
|
314
|
+
<TableCell className="font-bold" colSpan={2}>
|
|
315
|
+
{t('table.total')}
|
|
316
|
+
</TableCell>
|
|
317
|
+
<TableCell className="text-right font-bold text-red-600">
|
|
318
|
+
<Money value={totalSaidas} />
|
|
319
|
+
</TableCell>
|
|
320
|
+
</TableRow>
|
|
321
|
+
</TableBody>
|
|
322
|
+
</Table>
|
|
323
|
+
</CardContent>
|
|
324
|
+
</Card>
|
|
325
|
+
</TabsContent>
|
|
326
|
+
</Tabs>
|
|
327
|
+
</Page>
|
|
328
|
+
);
|
|
329
|
+
}
|