@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.
Files changed (40) hide show
  1. package/README.md +228 -126
  2. package/dist/dto/create-bank-reconciliation.dto.d.ts +8 -0
  3. package/dist/dto/create-bank-reconciliation.dto.d.ts.map +1 -0
  4. package/dist/dto/create-bank-reconciliation.dto.js +43 -0
  5. package/dist/dto/create-bank-reconciliation.dto.js.map +1 -0
  6. package/dist/finance-data.controller.d.ts +2 -0
  7. package/dist/finance-data.controller.d.ts.map +1 -1
  8. package/dist/finance-statements.controller.d.ts +42 -0
  9. package/dist/finance-statements.controller.d.ts.map +1 -1
  10. package/dist/finance-statements.controller.js +13 -0
  11. package/dist/finance-statements.controller.js.map +1 -1
  12. package/dist/finance.service.d.ts +44 -0
  13. package/dist/finance.service.d.ts.map +1 -1
  14. package/dist/finance.service.js +98 -9
  15. package/dist/finance.service.js.map +1 -1
  16. package/hedhog/data/route.yaml +9 -0
  17. package/hedhog/frontend/app/_components/person-field-with-create.tsx.ejs +126 -126
  18. package/hedhog/frontend/app/accounts-payable/approvals/page.tsx.ejs +373 -373
  19. package/hedhog/frontend/app/accounts-payable/installments/[id]/page.tsx.ejs +1270 -1270
  20. package/hedhog/frontend/app/accounts-receivable/installments/[id]/page.tsx.ejs +982 -982
  21. package/hedhog/frontend/app/cash-and-banks/bank-accounts/page.tsx.ejs +686 -686
  22. package/hedhog/frontend/app/cash-and-banks/bank-reconciliation/page.tsx.ejs +152 -32
  23. package/hedhog/frontend/app/cash-and-banks/statements/page.tsx.ejs +986 -986
  24. package/hedhog/frontend/app/cash-and-banks/transfers/page.tsx.ejs +492 -492
  25. package/hedhog/frontend/app/page.tsx.ejs +372 -372
  26. package/hedhog/frontend/app/planning/cash-flow-forecast/page.tsx.ejs +329 -329
  27. package/hedhog/frontend/app/planning/receivables-calendar/page.tsx.ejs +227 -227
  28. package/hedhog/frontend/app/planning/scenarios/page.tsx.ejs +408 -408
  29. package/hedhog/frontend/messages/en.json +15 -5
  30. package/hedhog/frontend/messages/pt.json +15 -5
  31. package/package.json +7 -7
  32. package/src/dto/create-bank-reconciliation.dto.ts +24 -0
  33. package/src/finance-statements.controller.ts +14 -0
  34. package/src/finance.module.ts +43 -43
  35. package/src/finance.service.ts +118 -0
  36. package/src/index.ts +14 -14
  37. package/dist/finance.controller.d.ts +0 -276
  38. package/dist/finance.controller.d.ts.map +0 -1
  39. package/dist/finance.controller.js +0 -110
  40. package/dist/finance.controller.js.map +0 -1
@@ -1,372 +1,372 @@
1
- 'use client';
2
-
3
- import { Page, PageHeader } from '@/components/entity-list';
4
- import { Badge } from '@/components/ui/badge';
5
- import {
6
- Card,
7
- CardContent,
8
- CardDescription,
9
- CardHeader,
10
- CardTitle,
11
- } from '@/components/ui/card';
12
- import { KpiCard } from '@/components/ui/kpi-card';
13
- import { Money } from '@/components/ui/money';
14
- import { StatusBadge } from '@/components/ui/status-badge';
15
- import {
16
- AlertTriangle,
17
- ArrowDownRight,
18
- ArrowUpRight,
19
- TrendingDown,
20
- TrendingUp,
21
- Wallet,
22
- } from 'lucide-react';
23
- import { useLocale, useTranslations } from 'next-intl';
24
- import Link from 'next/link';
25
- import {
26
- CartesianGrid,
27
- Legend,
28
- Line,
29
- LineChart,
30
- ResponsiveContainer,
31
- Tooltip,
32
- XAxis,
33
- YAxis,
34
- } from 'recharts';
35
- import { formatarData, formatarMoeda } from './_lib/formatters';
36
- import { useFinanceData } from './_lib/use-finance-data';
37
-
38
- function DashboardChart({
39
- fluxoCaixaPrevisto,
40
- t,
41
- }: {
42
- fluxoCaixaPrevisto: any[];
43
- t: ReturnType<typeof useTranslations>;
44
- }) {
45
- const chartData = fluxoCaixaPrevisto.map((item) => ({
46
- ...item,
47
- data: formatarData(item.data),
48
- }));
49
-
50
- return (
51
- <ResponsiveContainer width="100%" height={300}>
52
- <LineChart data={chartData}>
53
- <CartesianGrid strokeDasharray="3 3" className="stroke-muted" />
54
- <XAxis
55
- dataKey="data"
56
- tick={{ fontSize: 12 }}
57
- tickLine={false}
58
- axisLine={false}
59
- />
60
- <YAxis
61
- tick={{ fontSize: 12 }}
62
- tickLine={false}
63
- axisLine={false}
64
- tickFormatter={(value) => `${(value / 1000).toFixed(0)}k`}
65
- />
66
- <Tooltip
67
- formatter={(value: number) => formatarMoeda(value)}
68
- contentStyle={{
69
- backgroundColor: 'hsl(var(--background))',
70
- border: '1px solid hsl(var(--border))',
71
- borderRadius: '8px',
72
- }}
73
- />
74
- <Legend />
75
- <Line
76
- type="monotone"
77
- dataKey="saldoPrevisto"
78
- name={t('chart.predicted')}
79
- stroke="hsl(var(--primary))"
80
- strokeWidth={2}
81
- dot={false}
82
- />
83
- <Line
84
- type="monotone"
85
- dataKey="saldoRealizado"
86
- name={t('chart.actual')}
87
- stroke="hsl(var(--chart-2))"
88
- strokeWidth={2}
89
- dot={false}
90
- connectNulls
91
- />
92
- </LineChart>
93
- </ResponsiveContainer>
94
- );
95
- }
96
-
97
- function ProximosVencimentos({
98
- titulosPagar,
99
- titulosReceber,
100
- getPessoaById,
101
- t,
102
- }: {
103
- titulosPagar: any[];
104
- titulosReceber: any[];
105
- getPessoaById: (id?: string) => any | undefined;
106
- t: ReturnType<typeof useTranslations>;
107
- }) {
108
- const vencimentosPagar = titulosPagar
109
- .flatMap((t: any) =>
110
- t.parcelas
111
- .filter((p: any) => p.status === 'aberto' || p.status === 'vencido')
112
- .map((p: any) => ({
113
- tipo: 'pagar' as const,
114
- tituloId: t.id,
115
- documento: t.documento,
116
- pessoa: getPessoaById(t.fornecedorId)?.nome || '',
117
- vencimento: p.vencimento,
118
- valor: p.valor,
119
- status: p.status,
120
- }))
121
- )
122
- .slice(0, 3);
123
-
124
- const vencimentosReceber = titulosReceber
125
- .flatMap((t: any) =>
126
- t.parcelas
127
- .filter((p: any) => p.status === 'aberto' || p.status === 'vencido')
128
- .map((p: any) => ({
129
- tipo: 'receber' as const,
130
- tituloId: t.id,
131
- documento: t.documento,
132
- pessoa: getPessoaById(t.clienteId)?.nome || '',
133
- vencimento: p.vencimento,
134
- valor: p.valor,
135
- status: p.status,
136
- }))
137
- )
138
- .slice(0, 3);
139
-
140
- return (
141
- <div className="grid gap-6 lg:grid-cols-2">
142
- <Card>
143
- <CardHeader>
144
- <CardTitle className="flex items-center gap-2 text-base">
145
- <ArrowDownRight className="h-4 w-4 text-red-500" />
146
- {t('upcoming.payable')}
147
- </CardTitle>
148
- <CardDescription>{t('upcoming.nextDueDates')}</CardDescription>
149
- </CardHeader>
150
- <CardContent>
151
- <div className="space-y-4">
152
- {vencimentosPagar.map((item, i) => (
153
- <Link
154
- key={i}
155
- href={`/finance/accounts-payable/installments/${item.tituloId}`}
156
- className="flex items-center justify-between rounded-md p-2 -m-2 transition-colors hover:bg-muted/50 active:bg-muted"
157
- >
158
- <div className="space-y-1">
159
- <p className="text-sm font-medium">{item.documento}</p>
160
- <p className="text-xs text-muted-foreground">{item.pessoa}</p>
161
- </div>
162
- <div className="text-right">
163
- <p className="text-sm font-medium">
164
- <Money value={item.valor} />
165
- </p>
166
- <p className="text-xs text-muted-foreground">
167
- {formatarData(item.vencimento)}
168
- </p>
169
- </div>
170
- <StatusBadge status={item.status} />
171
- </Link>
172
- ))}
173
- </div>
174
- </CardContent>
175
- </Card>
176
-
177
- <Card>
178
- <CardHeader>
179
- <CardTitle className="flex items-center gap-2 text-base">
180
- <ArrowUpRight className="h-4 w-4 text-green-500" />
181
- {t('upcoming.receivable')}
182
- </CardTitle>
183
- <CardDescription>{t('upcoming.nextDueDates')}</CardDescription>
184
- </CardHeader>
185
- <CardContent>
186
- <div className="space-y-4">
187
- {vencimentosReceber.map((item, i) => (
188
- <Link
189
- key={i}
190
- href={`/finance/accounts-receivable/installments/${item.tituloId}`}
191
- className="flex items-center justify-between rounded-md p-2 -m-2 transition-colors hover:bg-muted/50 active:bg-muted"
192
- >
193
- <div className="space-y-1">
194
- <p className="text-sm font-medium">{item.documento}</p>
195
- <p className="text-xs text-muted-foreground">{item.pessoa}</p>
196
- </div>
197
- <div className="text-right">
198
- <p className="text-sm font-medium">
199
- <Money value={item.valor} />
200
- </p>
201
- <p className="text-xs text-muted-foreground">
202
- {formatarData(item.vencimento)}
203
- </p>
204
- </div>
205
- <StatusBadge status={item.status} />
206
- </Link>
207
- ))}
208
- </div>
209
- </CardContent>
210
- </Card>
211
- </div>
212
- );
213
- }
214
-
215
- function Alertas({
216
- titulosPagar,
217
- extratos,
218
- periodoAberto,
219
- locale,
220
- t,
221
- }: {
222
- titulosPagar: any[];
223
- extratos: any[];
224
- periodoAberto?: { inicio?: string | null } | null;
225
- locale: string;
226
- t: ReturnType<typeof useTranslations>;
227
- }) {
228
- const vencidos = titulosPagar.filter((t) =>
229
- t.parcelas.some((p: any) => p.status === 'vencido')
230
- ).length;
231
- const pendenteConciliacao = extratos.filter(
232
- (e) => e.statusConciliacao === 'pendente'
233
- ).length;
234
-
235
- const periodoBase = periodoAberto?.inicio
236
- ? new Date(periodoAberto.inicio)
237
- : new Date();
238
- const mes = new Intl.DateTimeFormat(locale, { month: 'long' }).format(
239
- periodoBase
240
- );
241
- const periodoAtual = `${mes.charAt(0).toUpperCase()}${mes.slice(1)}/${periodoBase.getFullYear()}`;
242
-
243
- return (
244
- <Card>
245
- <CardHeader>
246
- <CardTitle className="flex items-center gap-2 text-base">
247
- <AlertTriangle className="h-4 w-4 text-yellow-500" />
248
- {t('alerts.title')}
249
- </CardTitle>
250
- </CardHeader>
251
- <CardContent>
252
- <div className="space-y-3">
253
- {vencidos > 0 && (
254
- <div className="flex items-center justify-between rounded-lg bg-red-50 p-3">
255
- <span className="text-sm">{t('alerts.overdueTitles')}</span>
256
- <Badge variant="destructive">{vencidos}</Badge>
257
- </div>
258
- )}
259
- {pendenteConciliacao > 0 && (
260
- <div className="flex items-center justify-between rounded-lg bg-yellow-50 p-3">
261
- <span className="text-sm">
262
- {t('alerts.pendingReconciliation')}
263
- </span>
264
- <Badge
265
- variant="outline"
266
- className="border-yellow-500 text-yellow-700"
267
- >
268
- {pendenteConciliacao}
269
- </Badge>
270
- </div>
271
- )}
272
- <div className="flex items-center justify-between rounded-lg bg-blue-50 p-3">
273
- <span className="text-sm">{t('alerts.openPeriod')}</span>
274
- <Badge variant="outline" className="border-blue-500 text-blue-700">
275
- {periodoAtual}
276
- </Badge>
277
- </div>
278
- </div>
279
- </CardContent>
280
- </Card>
281
- );
282
- }
283
-
284
- export default function DashboardPage() {
285
- const t = useTranslations('finance.DashboardPage');
286
- const locale = useLocale();
287
- const { data } = useFinanceData();
288
- const {
289
- kpis,
290
- fluxoCaixaPrevisto,
291
- titulosPagar,
292
- titulosReceber,
293
- extratos,
294
- pessoas,
295
- periodoAberto,
296
- } = data;
297
-
298
- const getPessoaById = (id?: string) => pessoas.find((p) => p.id === id);
299
- const titulosPagarAprovados = titulosPagar.filter(
300
- (titulo) => titulo.status !== 'rascunho' && titulo.status !== 'cancelado'
301
- );
302
-
303
- return (
304
- <Page>
305
- <PageHeader
306
- title={t('header.title')}
307
- description={t('header.description')}
308
- breadcrumbs={[
309
- { label: t('breadcrumbs.home'), href: '/' },
310
- { label: t('breadcrumbs.finance') },
311
- ]}
312
- />
313
-
314
- <div className="grid gap-4 md:grid-cols-2 lg:grid-cols-4">
315
- <KpiCard
316
- title={t('kpis.cashBalance.title')}
317
- value={formatarMoeda(kpis.saldoCaixa)}
318
- icon={Wallet}
319
- description={t('kpis.cashBalance.description')}
320
- />
321
- <KpiCard
322
- title={t('kpis.payable30.title')}
323
- value={formatarMoeda(kpis.aPagar30dias)}
324
- icon={TrendingDown}
325
- description={t('kpis.payable30.sevenDays', {
326
- value: formatarMoeda(kpis.aPagar7dias),
327
- })}
328
- />
329
- <KpiCard
330
- title={t('kpis.receivable30.title')}
331
- value={formatarMoeda(kpis.aReceber30dias)}
332
- icon={TrendingUp}
333
- description={t('kpis.receivable30.sevenDays', {
334
- value: formatarMoeda(kpis.aReceber7dias),
335
- })}
336
- />
337
- <KpiCard
338
- title={t('kpis.default.title')}
339
- value={formatarMoeda(kpis.inadimplencia)}
340
- icon={AlertTriangle}
341
- description={t('kpis.default.description')}
342
- />
343
- </div>
344
-
345
- <div className="grid gap-6 lg:grid-cols-3">
346
- <Card className="lg:col-span-2">
347
- <CardHeader>
348
- <CardTitle>{t('cashFlow.title')}</CardTitle>
349
- <CardDescription>{t('cashFlow.description')}</CardDescription>
350
- </CardHeader>
351
- <CardContent>
352
- <DashboardChart fluxoCaixaPrevisto={fluxoCaixaPrevisto} t={t} />
353
- </CardContent>
354
- </Card>
355
- <Alertas
356
- titulosPagar={titulosPagarAprovados}
357
- extratos={extratos}
358
- periodoAberto={periodoAberto}
359
- locale={locale}
360
- t={t}
361
- />
362
- </div>
363
-
364
- <ProximosVencimentos
365
- titulosPagar={titulosPagarAprovados}
366
- titulosReceber={titulosReceber}
367
- getPessoaById={getPessoaById}
368
- t={t}
369
- />
370
- </Page>
371
- );
372
- }
1
+ 'use client';
2
+
3
+ import { Page, PageHeader } from '@/components/entity-list';
4
+ import { Badge } from '@/components/ui/badge';
5
+ import {
6
+ Card,
7
+ CardContent,
8
+ CardDescription,
9
+ CardHeader,
10
+ CardTitle,
11
+ } from '@/components/ui/card';
12
+ import { KpiCard } from '@/components/ui/kpi-card';
13
+ import { Money } from '@/components/ui/money';
14
+ import { StatusBadge } from '@/components/ui/status-badge';
15
+ import {
16
+ AlertTriangle,
17
+ ArrowDownRight,
18
+ ArrowUpRight,
19
+ TrendingDown,
20
+ TrendingUp,
21
+ Wallet,
22
+ } from 'lucide-react';
23
+ import { useLocale, useTranslations } from 'next-intl';
24
+ import Link from 'next/link';
25
+ import {
26
+ CartesianGrid,
27
+ Legend,
28
+ Line,
29
+ LineChart,
30
+ ResponsiveContainer,
31
+ Tooltip,
32
+ XAxis,
33
+ YAxis,
34
+ } from 'recharts';
35
+ import { formatarData, formatarMoeda } from './_lib/formatters';
36
+ import { useFinanceData } from './_lib/use-finance-data';
37
+
38
+ function DashboardChart({
39
+ fluxoCaixaPrevisto,
40
+ t,
41
+ }: {
42
+ fluxoCaixaPrevisto: any[];
43
+ t: ReturnType<typeof useTranslations>;
44
+ }) {
45
+ const chartData = fluxoCaixaPrevisto.map((item) => ({
46
+ ...item,
47
+ data: formatarData(item.data),
48
+ }));
49
+
50
+ return (
51
+ <ResponsiveContainer width="100%" height={300}>
52
+ <LineChart data={chartData}>
53
+ <CartesianGrid strokeDasharray="3 3" className="stroke-muted" />
54
+ <XAxis
55
+ dataKey="data"
56
+ tick={{ fontSize: 12 }}
57
+ tickLine={false}
58
+ axisLine={false}
59
+ />
60
+ <YAxis
61
+ tick={{ fontSize: 12 }}
62
+ tickLine={false}
63
+ axisLine={false}
64
+ tickFormatter={(value) => `${(value / 1000).toFixed(0)}k`}
65
+ />
66
+ <Tooltip
67
+ formatter={(value: number) => formatarMoeda(value)}
68
+ contentStyle={{
69
+ backgroundColor: 'hsl(var(--background))',
70
+ border: '1px solid hsl(var(--border))',
71
+ borderRadius: '8px',
72
+ }}
73
+ />
74
+ <Legend />
75
+ <Line
76
+ type="monotone"
77
+ dataKey="saldoPrevisto"
78
+ name={t('chart.predicted')}
79
+ stroke="hsl(var(--primary))"
80
+ strokeWidth={2}
81
+ dot={false}
82
+ />
83
+ <Line
84
+ type="monotone"
85
+ dataKey="saldoRealizado"
86
+ name={t('chart.actual')}
87
+ stroke="hsl(var(--chart-2))"
88
+ strokeWidth={2}
89
+ dot={false}
90
+ connectNulls
91
+ />
92
+ </LineChart>
93
+ </ResponsiveContainer>
94
+ );
95
+ }
96
+
97
+ function ProximosVencimentos({
98
+ titulosPagar,
99
+ titulosReceber,
100
+ getPessoaById,
101
+ t,
102
+ }: {
103
+ titulosPagar: any[];
104
+ titulosReceber: any[];
105
+ getPessoaById: (id?: string) => any | undefined;
106
+ t: ReturnType<typeof useTranslations>;
107
+ }) {
108
+ const vencimentosPagar = titulosPagar
109
+ .flatMap((t: any) =>
110
+ t.parcelas
111
+ .filter((p: any) => p.status === 'aberto' || p.status === 'vencido')
112
+ .map((p: any) => ({
113
+ tipo: 'pagar' as const,
114
+ tituloId: t.id,
115
+ documento: t.documento,
116
+ pessoa: getPessoaById(t.fornecedorId)?.nome || '',
117
+ vencimento: p.vencimento,
118
+ valor: p.valor,
119
+ status: p.status,
120
+ }))
121
+ )
122
+ .slice(0, 3);
123
+
124
+ const vencimentosReceber = titulosReceber
125
+ .flatMap((t: any) =>
126
+ t.parcelas
127
+ .filter((p: any) => p.status === 'aberto' || p.status === 'vencido')
128
+ .map((p: any) => ({
129
+ tipo: 'receber' as const,
130
+ tituloId: t.id,
131
+ documento: t.documento,
132
+ pessoa: getPessoaById(t.clienteId)?.nome || '',
133
+ vencimento: p.vencimento,
134
+ valor: p.valor,
135
+ status: p.status,
136
+ }))
137
+ )
138
+ .slice(0, 3);
139
+
140
+ return (
141
+ <div className="grid gap-6 lg:grid-cols-2">
142
+ <Card>
143
+ <CardHeader>
144
+ <CardTitle className="flex items-center gap-2 text-base">
145
+ <ArrowDownRight className="h-4 w-4 text-red-500" />
146
+ {t('upcoming.payable')}
147
+ </CardTitle>
148
+ <CardDescription>{t('upcoming.nextDueDates')}</CardDescription>
149
+ </CardHeader>
150
+ <CardContent>
151
+ <div className="space-y-4">
152
+ {vencimentosPagar.map((item, i) => (
153
+ <Link
154
+ key={i}
155
+ href={`/finance/accounts-payable/installments/${item.tituloId}`}
156
+ className="flex items-center justify-between rounded-md p-2 -m-2 transition-colors hover:bg-muted/50 active:bg-muted"
157
+ >
158
+ <div className="space-y-1">
159
+ <p className="text-sm font-medium">{item.documento}</p>
160
+ <p className="text-xs text-muted-foreground">{item.pessoa}</p>
161
+ </div>
162
+ <div className="text-right">
163
+ <p className="text-sm font-medium">
164
+ <Money value={item.valor} />
165
+ </p>
166
+ <p className="text-xs text-muted-foreground">
167
+ {formatarData(item.vencimento)}
168
+ </p>
169
+ </div>
170
+ <StatusBadge status={item.status} />
171
+ </Link>
172
+ ))}
173
+ </div>
174
+ </CardContent>
175
+ </Card>
176
+
177
+ <Card>
178
+ <CardHeader>
179
+ <CardTitle className="flex items-center gap-2 text-base">
180
+ <ArrowUpRight className="h-4 w-4 text-green-500" />
181
+ {t('upcoming.receivable')}
182
+ </CardTitle>
183
+ <CardDescription>{t('upcoming.nextDueDates')}</CardDescription>
184
+ </CardHeader>
185
+ <CardContent>
186
+ <div className="space-y-4">
187
+ {vencimentosReceber.map((item, i) => (
188
+ <Link
189
+ key={i}
190
+ href={`/finance/accounts-receivable/installments/${item.tituloId}`}
191
+ className="flex items-center justify-between rounded-md p-2 -m-2 transition-colors hover:bg-muted/50 active:bg-muted"
192
+ >
193
+ <div className="space-y-1">
194
+ <p className="text-sm font-medium">{item.documento}</p>
195
+ <p className="text-xs text-muted-foreground">{item.pessoa}</p>
196
+ </div>
197
+ <div className="text-right">
198
+ <p className="text-sm font-medium">
199
+ <Money value={item.valor} />
200
+ </p>
201
+ <p className="text-xs text-muted-foreground">
202
+ {formatarData(item.vencimento)}
203
+ </p>
204
+ </div>
205
+ <StatusBadge status={item.status} />
206
+ </Link>
207
+ ))}
208
+ </div>
209
+ </CardContent>
210
+ </Card>
211
+ </div>
212
+ );
213
+ }
214
+
215
+ function Alertas({
216
+ titulosPagar,
217
+ extratos,
218
+ periodoAberto,
219
+ locale,
220
+ t,
221
+ }: {
222
+ titulosPagar: any[];
223
+ extratos: any[];
224
+ periodoAberto?: { inicio?: string | null } | null;
225
+ locale: string;
226
+ t: ReturnType<typeof useTranslations>;
227
+ }) {
228
+ const vencidos = titulosPagar.filter((t) =>
229
+ t.parcelas.some((p: any) => p.status === 'vencido')
230
+ ).length;
231
+ const pendenteConciliacao = extratos.filter(
232
+ (e) => e.statusConciliacao === 'pendente'
233
+ ).length;
234
+
235
+ const periodoBase = periodoAberto?.inicio
236
+ ? new Date(periodoAberto.inicio)
237
+ : new Date();
238
+ const mes = new Intl.DateTimeFormat(locale, { month: 'long' }).format(
239
+ periodoBase
240
+ );
241
+ const periodoAtual = `${mes.charAt(0).toUpperCase()}${mes.slice(1)}/${periodoBase.getFullYear()}`;
242
+
243
+ return (
244
+ <Card>
245
+ <CardHeader>
246
+ <CardTitle className="flex items-center gap-2 text-base">
247
+ <AlertTriangle className="h-4 w-4 text-yellow-500" />
248
+ {t('alerts.title')}
249
+ </CardTitle>
250
+ </CardHeader>
251
+ <CardContent>
252
+ <div className="space-y-3">
253
+ {vencidos > 0 && (
254
+ <div className="flex items-center justify-between rounded-lg bg-red-50 p-3">
255
+ <span className="text-sm">{t('alerts.overdueTitles')}</span>
256
+ <Badge variant="destructive">{vencidos}</Badge>
257
+ </div>
258
+ )}
259
+ {pendenteConciliacao > 0 && (
260
+ <div className="flex items-center justify-between rounded-lg bg-yellow-50 p-3">
261
+ <span className="text-sm">
262
+ {t('alerts.pendingReconciliation')}
263
+ </span>
264
+ <Badge
265
+ variant="outline"
266
+ className="border-yellow-500 text-yellow-700"
267
+ >
268
+ {pendenteConciliacao}
269
+ </Badge>
270
+ </div>
271
+ )}
272
+ <div className="flex items-center justify-between rounded-lg bg-blue-50 p-3">
273
+ <span className="text-sm">{t('alerts.openPeriod')}</span>
274
+ <Badge variant="outline" className="border-blue-500 text-blue-700">
275
+ {periodoAtual}
276
+ </Badge>
277
+ </div>
278
+ </div>
279
+ </CardContent>
280
+ </Card>
281
+ );
282
+ }
283
+
284
+ export default function DashboardPage() {
285
+ const t = useTranslations('finance.DashboardPage');
286
+ const locale = useLocale();
287
+ const { data } = useFinanceData();
288
+ const {
289
+ kpis,
290
+ fluxoCaixaPrevisto,
291
+ titulosPagar,
292
+ titulosReceber,
293
+ extratos,
294
+ pessoas,
295
+ periodoAberto,
296
+ } = data;
297
+
298
+ const getPessoaById = (id?: string) => pessoas.find((p) => p.id === id);
299
+ const titulosPagarAprovados = titulosPagar.filter(
300
+ (titulo) => titulo.status !== 'rascunho' && titulo.status !== 'cancelado'
301
+ );
302
+
303
+ return (
304
+ <Page>
305
+ <PageHeader
306
+ title={t('header.title')}
307
+ description={t('header.description')}
308
+ breadcrumbs={[
309
+ { label: t('breadcrumbs.home'), href: '/' },
310
+ { label: t('breadcrumbs.finance') },
311
+ ]}
312
+ />
313
+
314
+ <div className="grid gap-4 md:grid-cols-2 lg:grid-cols-4">
315
+ <KpiCard
316
+ title={t('kpis.cashBalance.title')}
317
+ value={formatarMoeda(kpis.saldoCaixa)}
318
+ icon={Wallet}
319
+ description={t('kpis.cashBalance.description')}
320
+ />
321
+ <KpiCard
322
+ title={t('kpis.payable30.title')}
323
+ value={formatarMoeda(kpis.aPagar30dias)}
324
+ icon={TrendingDown}
325
+ description={t('kpis.payable30.sevenDays', {
326
+ value: formatarMoeda(kpis.aPagar7dias),
327
+ })}
328
+ />
329
+ <KpiCard
330
+ title={t('kpis.receivable30.title')}
331
+ value={formatarMoeda(kpis.aReceber30dias)}
332
+ icon={TrendingUp}
333
+ description={t('kpis.receivable30.sevenDays', {
334
+ value: formatarMoeda(kpis.aReceber7dias),
335
+ })}
336
+ />
337
+ <KpiCard
338
+ title={t('kpis.default.title')}
339
+ value={formatarMoeda(kpis.inadimplencia)}
340
+ icon={AlertTriangle}
341
+ description={t('kpis.default.description')}
342
+ />
343
+ </div>
344
+
345
+ <div className="grid gap-6 lg:grid-cols-3">
346
+ <Card className="lg:col-span-2">
347
+ <CardHeader>
348
+ <CardTitle>{t('cashFlow.title')}</CardTitle>
349
+ <CardDescription>{t('cashFlow.description')}</CardDescription>
350
+ </CardHeader>
351
+ <CardContent>
352
+ <DashboardChart fluxoCaixaPrevisto={fluxoCaixaPrevisto} t={t} />
353
+ </CardContent>
354
+ </Card>
355
+ <Alertas
356
+ titulosPagar={titulosPagarAprovados}
357
+ extratos={extratos}
358
+ periodoAberto={periodoAberto}
359
+ locale={locale}
360
+ t={t}
361
+ />
362
+ </div>
363
+
364
+ <ProximosVencimentos
365
+ titulosPagar={titulosPagarAprovados}
366
+ titulosReceber={titulosReceber}
367
+ getPessoaById={getPessoaById}
368
+ t={t}
369
+ />
370
+ </Page>
371
+ );
372
+ }