@hed-hog/finance 0.0.223 → 0.0.225
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/dto/create-financial-title.dto.d.ts +19 -0
- package/dist/dto/create-financial-title.dto.d.ts.map +1 -0
- package/dist/dto/create-financial-title.dto.js +128 -0
- package/dist/dto/create-financial-title.dto.js.map +1 -0
- package/dist/finance.controller.d.ts +276 -0
- package/dist/finance.controller.d.ts.map +1 -0
- package/dist/finance.controller.js +110 -0
- package/dist/finance.controller.js.map +1 -0
- package/dist/finance.module.d.ts.map +1 -1
- package/dist/finance.module.js +8 -3
- package/dist/finance.module.js.map +1 -1
- package/dist/finance.service.d.ts +295 -0
- package/dist/finance.service.d.ts.map +1 -0
- package/dist/finance.service.js +416 -0
- package/dist/finance.service.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -1
- package/hedhog/data/menu.yaml +72 -25
- package/hedhog/data/route.yaml +55 -1
- package/hedhog/frontend/app/_lib/formatters.ts.ejs +20 -0
- package/hedhog/frontend/app/_lib/use-finance-data.ts.ejs +87 -0
- package/hedhog/frontend/app/accounts-payable/approvals/page.tsx.ejs +290 -0
- package/hedhog/frontend/app/accounts-payable/installments/[id]/page.tsx.ejs +410 -0
- package/hedhog/frontend/app/accounts-payable/installments/page.tsx.ejs +388 -0
- package/hedhog/frontend/app/accounts-receivable/collections-default/page.tsx.ejs +423 -0
- package/hedhog/frontend/app/accounts-receivable/installments/[id]/page.tsx.ejs +411 -0
- package/hedhog/frontend/app/accounts-receivable/installments/page.tsx.ejs +385 -0
- package/hedhog/frontend/app/cash-and-banks/bank-accounts/page.tsx.ejs +296 -0
- package/hedhog/frontend/app/cash-and-banks/bank-reconciliation/page.tsx.ejs +427 -0
- package/hedhog/frontend/app/cash-and-banks/statements/page.tsx.ejs +273 -0
- package/hedhog/frontend/app/cash-and-banks/transfers/page.tsx.ejs +253 -0
- package/hedhog/frontend/app/page.tsx.ejs +338 -17
- package/hedhog/frontend/app/planning/cash-flow-forecast/page.tsx.ejs +298 -0
- package/hedhog/frontend/app/planning/receivables-calendar/page.tsx.ejs +225 -0
- package/hedhog/frontend/app/planning/scenarios/page.tsx.ejs +338 -0
- package/hedhog/frontend/messages/en.json +776 -0
- package/hedhog/frontend/messages/pt.json +776 -0
- package/hedhog/query/constraints.sql +169 -0
- package/package.json +3 -3
- package/src/dto/create-financial-title.dto.ts +142 -0
- package/src/finance.controller.ts +89 -0
- package/src/finance.module.ts +8 -3
- package/src/finance.service.ts +529 -0
- package/src/index.ts +4 -0
|
@@ -0,0 +1,253 @@
|
|
|
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 { Input } from '@/components/ui/input';
|
|
13
|
+
import { Label } from '@/components/ui/label';
|
|
14
|
+
import { Money } from '@/components/ui/money';
|
|
15
|
+
import {
|
|
16
|
+
Select,
|
|
17
|
+
SelectContent,
|
|
18
|
+
SelectItem,
|
|
19
|
+
SelectTrigger,
|
|
20
|
+
SelectValue,
|
|
21
|
+
} from '@/components/ui/select';
|
|
22
|
+
import {
|
|
23
|
+
Sheet,
|
|
24
|
+
SheetContent,
|
|
25
|
+
SheetDescription,
|
|
26
|
+
SheetHeader,
|
|
27
|
+
SheetTitle,
|
|
28
|
+
SheetTrigger,
|
|
29
|
+
} from '@/components/ui/sheet';
|
|
30
|
+
import {
|
|
31
|
+
Table,
|
|
32
|
+
TableBody,
|
|
33
|
+
TableCell,
|
|
34
|
+
TableHead,
|
|
35
|
+
TableHeader,
|
|
36
|
+
TableRow,
|
|
37
|
+
} from '@/components/ui/table';
|
|
38
|
+
import { Textarea } from '@/components/ui/textarea';
|
|
39
|
+
import { ArrowRight, Plus } from 'lucide-react';
|
|
40
|
+
import { useTranslations } from 'next-intl';
|
|
41
|
+
import { formatarData } from '../../_lib/formatters';
|
|
42
|
+
import { useFinanceData } from '../../_lib/use-finance-data';
|
|
43
|
+
|
|
44
|
+
function NovaTransferenciaSheet({
|
|
45
|
+
contasBancarias,
|
|
46
|
+
t,
|
|
47
|
+
}: {
|
|
48
|
+
contasBancarias: any[];
|
|
49
|
+
t: ReturnType<typeof useTranslations>;
|
|
50
|
+
}) {
|
|
51
|
+
return (
|
|
52
|
+
<Sheet>
|
|
53
|
+
<SheetTrigger asChild>
|
|
54
|
+
<Button>
|
|
55
|
+
<Plus className="mr-2 h-4 w-4" />
|
|
56
|
+
{t('newTransfer.action')}
|
|
57
|
+
</Button>
|
|
58
|
+
</SheetTrigger>
|
|
59
|
+
<SheetContent className="w-full sm:max-w-lg">
|
|
60
|
+
<SheetHeader>
|
|
61
|
+
<SheetTitle>{t('newTransfer.title')}</SheetTitle>
|
|
62
|
+
<SheetDescription>{t('newTransfer.description')}</SheetDescription>
|
|
63
|
+
</SheetHeader>
|
|
64
|
+
<form className="mt-6 space-y-4">
|
|
65
|
+
<div className="grid gap-4">
|
|
66
|
+
<div className="space-y-2">
|
|
67
|
+
<Label htmlFor="contaOrigem">{t('fields.sourceAccount')}</Label>
|
|
68
|
+
<Select>
|
|
69
|
+
<SelectTrigger>
|
|
70
|
+
<SelectValue placeholder={t('common.select')} />
|
|
71
|
+
</SelectTrigger>
|
|
72
|
+
<SelectContent>
|
|
73
|
+
{contasBancarias.map((conta) => (
|
|
74
|
+
<SelectItem key={conta.id} value={conta.id}>
|
|
75
|
+
{conta.banco} - {conta.descricao}
|
|
76
|
+
</SelectItem>
|
|
77
|
+
))}
|
|
78
|
+
</SelectContent>
|
|
79
|
+
</Select>
|
|
80
|
+
</div>
|
|
81
|
+
<div className="space-y-2">
|
|
82
|
+
<Label htmlFor="contaDestino">
|
|
83
|
+
{t('fields.destinationAccount')}
|
|
84
|
+
</Label>
|
|
85
|
+
<Select>
|
|
86
|
+
<SelectTrigger>
|
|
87
|
+
<SelectValue placeholder={t('common.select')} />
|
|
88
|
+
</SelectTrigger>
|
|
89
|
+
<SelectContent>
|
|
90
|
+
{contasBancarias.map((conta) => (
|
|
91
|
+
<SelectItem key={conta.id} value={conta.id}>
|
|
92
|
+
{conta.banco} - {conta.descricao}
|
|
93
|
+
</SelectItem>
|
|
94
|
+
))}
|
|
95
|
+
</SelectContent>
|
|
96
|
+
</Select>
|
|
97
|
+
</div>
|
|
98
|
+
<div className="grid grid-cols-2 gap-4">
|
|
99
|
+
<div className="space-y-2">
|
|
100
|
+
<Label htmlFor="data">{t('fields.date')}</Label>
|
|
101
|
+
<Input id="data" type="date" />
|
|
102
|
+
</div>
|
|
103
|
+
<div className="space-y-2">
|
|
104
|
+
<Label htmlFor="valor">{t('fields.value')}</Label>
|
|
105
|
+
<Input
|
|
106
|
+
id="valor"
|
|
107
|
+
type="number"
|
|
108
|
+
placeholder="0,00"
|
|
109
|
+
step="0.01"
|
|
110
|
+
/>
|
|
111
|
+
</div>
|
|
112
|
+
</div>
|
|
113
|
+
<div className="space-y-2">
|
|
114
|
+
<Label htmlFor="descricao">{t('fields.description')}</Label>
|
|
115
|
+
<Textarea
|
|
116
|
+
id="descricao"
|
|
117
|
+
placeholder={t('fields.descriptionPlaceholder')}
|
|
118
|
+
/>
|
|
119
|
+
</div>
|
|
120
|
+
</div>
|
|
121
|
+
<div className="flex justify-end gap-2 pt-4">
|
|
122
|
+
<Button type="button" variant="outline">
|
|
123
|
+
{t('common.cancel')}
|
|
124
|
+
</Button>
|
|
125
|
+
<Button type="submit">{t('newTransfer.submit')}</Button>
|
|
126
|
+
</div>
|
|
127
|
+
</form>
|
|
128
|
+
</SheetContent>
|
|
129
|
+
</Sheet>
|
|
130
|
+
);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
export default function TransferenciasPage() {
|
|
134
|
+
const t = useTranslations('finance.TransfersPage');
|
|
135
|
+
const { data } = useFinanceData();
|
|
136
|
+
const { transferencias, contasBancarias } = data;
|
|
137
|
+
|
|
138
|
+
const totalTransferido = transferencias.reduce((acc, t) => acc + t.valor, 0);
|
|
139
|
+
|
|
140
|
+
return (
|
|
141
|
+
<Page>
|
|
142
|
+
<PageHeader
|
|
143
|
+
title={t('header.title')}
|
|
144
|
+
description={t('header.description')}
|
|
145
|
+
breadcrumbs={[
|
|
146
|
+
{ label: t('breadcrumbs.home'), href: '/' },
|
|
147
|
+
{ label: t('breadcrumbs.finance'), href: '/finance' },
|
|
148
|
+
{ label: t('breadcrumbs.current') },
|
|
149
|
+
]}
|
|
150
|
+
actions={
|
|
151
|
+
<NovaTransferenciaSheet contasBancarias={contasBancarias} t={t} />
|
|
152
|
+
}
|
|
153
|
+
/>
|
|
154
|
+
|
|
155
|
+
<div className="grid gap-4 md:grid-cols-2">
|
|
156
|
+
<Card>
|
|
157
|
+
<CardHeader className="flex flex-row items-center justify-between space-y-0 pb-2">
|
|
158
|
+
<CardTitle className="text-sm font-medium">
|
|
159
|
+
{t('cards.totalTransferred')}
|
|
160
|
+
</CardTitle>
|
|
161
|
+
</CardHeader>
|
|
162
|
+
<CardContent>
|
|
163
|
+
<div className="text-2xl font-bold">
|
|
164
|
+
<Money value={totalTransferido} />
|
|
165
|
+
</div>
|
|
166
|
+
<p className="text-xs text-muted-foreground">
|
|
167
|
+
{t('cards.transferCount', { count: transferencias.length })}
|
|
168
|
+
</p>
|
|
169
|
+
</CardContent>
|
|
170
|
+
</Card>
|
|
171
|
+
<Card>
|
|
172
|
+
<CardHeader className="flex flex-row items-center justify-between space-y-0 pb-2">
|
|
173
|
+
<CardTitle className="text-sm font-medium">
|
|
174
|
+
{t('cards.activeAccounts')}
|
|
175
|
+
</CardTitle>
|
|
176
|
+
</CardHeader>
|
|
177
|
+
<CardContent>
|
|
178
|
+
<div className="text-2xl font-bold">
|
|
179
|
+
{contasBancarias.filter((c) => c.ativo).length}
|
|
180
|
+
</div>
|
|
181
|
+
<p className="text-xs text-muted-foreground">
|
|
182
|
+
{t('cards.available')}
|
|
183
|
+
</p>
|
|
184
|
+
</CardContent>
|
|
185
|
+
</Card>
|
|
186
|
+
</div>
|
|
187
|
+
|
|
188
|
+
<Card>
|
|
189
|
+
<CardHeader>
|
|
190
|
+
<CardTitle>{t('table.title')}</CardTitle>
|
|
191
|
+
<CardDescription>{t('table.description')}</CardDescription>
|
|
192
|
+
</CardHeader>
|
|
193
|
+
<CardContent>
|
|
194
|
+
<Table>
|
|
195
|
+
<TableHeader>
|
|
196
|
+
<TableRow>
|
|
197
|
+
<TableHead>{t('table.headers.date')}</TableHead>
|
|
198
|
+
<TableHead>{t('table.headers.source')}</TableHead>
|
|
199
|
+
<TableHead className="text-center">→</TableHead>
|
|
200
|
+
<TableHead>{t('table.headers.destination')}</TableHead>
|
|
201
|
+
<TableHead className="text-right">
|
|
202
|
+
{t('table.headers.value')}
|
|
203
|
+
</TableHead>
|
|
204
|
+
<TableHead>{t('table.headers.description')}</TableHead>
|
|
205
|
+
</TableRow>
|
|
206
|
+
</TableHeader>
|
|
207
|
+
<TableBody>
|
|
208
|
+
{transferencias.map((transferencia) => {
|
|
209
|
+
const contaOrigem = contasBancarias.find(
|
|
210
|
+
(conta) => conta.id === transferencia.contaOrigemId
|
|
211
|
+
);
|
|
212
|
+
const contaDestino = contasBancarias.find(
|
|
213
|
+
(conta) => conta.id === transferencia.contaDestinoId
|
|
214
|
+
);
|
|
215
|
+
|
|
216
|
+
return (
|
|
217
|
+
<TableRow key={transferencia.id}>
|
|
218
|
+
<TableCell>{formatarData(transferencia.data)}</TableCell>
|
|
219
|
+
<TableCell>
|
|
220
|
+
<div>
|
|
221
|
+
<p className="font-medium">{contaOrigem?.banco}</p>
|
|
222
|
+
<p className="text-xs text-muted-foreground">
|
|
223
|
+
{contaOrigem?.descricao}
|
|
224
|
+
</p>
|
|
225
|
+
</div>
|
|
226
|
+
</TableCell>
|
|
227
|
+
<TableCell className="text-center">
|
|
228
|
+
<ArrowRight className="h-4 w-4 text-muted-foreground mx-auto" />
|
|
229
|
+
</TableCell>
|
|
230
|
+
<TableCell>
|
|
231
|
+
<div>
|
|
232
|
+
<p className="font-medium">{contaDestino?.banco}</p>
|
|
233
|
+
<p className="text-xs text-muted-foreground">
|
|
234
|
+
{contaDestino?.descricao}
|
|
235
|
+
</p>
|
|
236
|
+
</div>
|
|
237
|
+
</TableCell>
|
|
238
|
+
<TableCell className="text-right font-semibold">
|
|
239
|
+
<Money value={transferencia.valor} />
|
|
240
|
+
</TableCell>
|
|
241
|
+
<TableCell className="text-muted-foreground">
|
|
242
|
+
{transferencia.descricao}
|
|
243
|
+
</TableCell>
|
|
244
|
+
</TableRow>
|
|
245
|
+
);
|
|
246
|
+
})}
|
|
247
|
+
</TableBody>
|
|
248
|
+
</Table>
|
|
249
|
+
</CardContent>
|
|
250
|
+
</Card>
|
|
251
|
+
</Page>
|
|
252
|
+
);
|
|
253
|
+
}
|
|
@@ -1,17 +1,338 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
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 { useTranslations } from 'next-intl';
|
|
24
|
+
import {
|
|
25
|
+
CartesianGrid,
|
|
26
|
+
Legend,
|
|
27
|
+
Line,
|
|
28
|
+
LineChart,
|
|
29
|
+
ResponsiveContainer,
|
|
30
|
+
Tooltip,
|
|
31
|
+
XAxis,
|
|
32
|
+
YAxis,
|
|
33
|
+
} from 'recharts';
|
|
34
|
+
import { formatarData, formatarMoeda } from './_lib/formatters';
|
|
35
|
+
import { useFinanceData } from './_lib/use-finance-data';
|
|
36
|
+
|
|
37
|
+
function DashboardChart({
|
|
38
|
+
fluxoCaixaPrevisto,
|
|
39
|
+
t,
|
|
40
|
+
}: {
|
|
41
|
+
fluxoCaixaPrevisto: any[];
|
|
42
|
+
t: ReturnType<typeof useTranslations>;
|
|
43
|
+
}) {
|
|
44
|
+
const chartData = fluxoCaixaPrevisto.map((item) => ({
|
|
45
|
+
...item,
|
|
46
|
+
data: formatarData(item.data),
|
|
47
|
+
}));
|
|
48
|
+
|
|
49
|
+
return (
|
|
50
|
+
<ResponsiveContainer width="100%" height={300}>
|
|
51
|
+
<LineChart data={chartData}>
|
|
52
|
+
<CartesianGrid strokeDasharray="3 3" className="stroke-muted" />
|
|
53
|
+
<XAxis
|
|
54
|
+
dataKey="data"
|
|
55
|
+
tick={{ fontSize: 12 }}
|
|
56
|
+
tickLine={false}
|
|
57
|
+
axisLine={false}
|
|
58
|
+
/>
|
|
59
|
+
<YAxis
|
|
60
|
+
tick={{ fontSize: 12 }}
|
|
61
|
+
tickLine={false}
|
|
62
|
+
axisLine={false}
|
|
63
|
+
tickFormatter={(value) => `${(value / 1000).toFixed(0)}k`}
|
|
64
|
+
/>
|
|
65
|
+
<Tooltip
|
|
66
|
+
formatter={(value: number) => formatarMoeda(value)}
|
|
67
|
+
contentStyle={{
|
|
68
|
+
backgroundColor: 'hsl(var(--background))',
|
|
69
|
+
border: '1px solid hsl(var(--border))',
|
|
70
|
+
borderRadius: '8px',
|
|
71
|
+
}}
|
|
72
|
+
/>
|
|
73
|
+
<Legend />
|
|
74
|
+
<Line
|
|
75
|
+
type="monotone"
|
|
76
|
+
dataKey="saldoPrevisto"
|
|
77
|
+
name={t('chart.predicted')}
|
|
78
|
+
stroke="hsl(var(--primary))"
|
|
79
|
+
strokeWidth={2}
|
|
80
|
+
dot={false}
|
|
81
|
+
/>
|
|
82
|
+
<Line
|
|
83
|
+
type="monotone"
|
|
84
|
+
dataKey="saldoRealizado"
|
|
85
|
+
name={t('chart.actual')}
|
|
86
|
+
stroke="hsl(var(--chart-2))"
|
|
87
|
+
strokeWidth={2}
|
|
88
|
+
dot={false}
|
|
89
|
+
connectNulls
|
|
90
|
+
/>
|
|
91
|
+
</LineChart>
|
|
92
|
+
</ResponsiveContainer>
|
|
93
|
+
);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
function ProximosVencimentos({
|
|
97
|
+
titulosPagar,
|
|
98
|
+
titulosReceber,
|
|
99
|
+
getPessoaById,
|
|
100
|
+
t,
|
|
101
|
+
}: {
|
|
102
|
+
titulosPagar: any[];
|
|
103
|
+
titulosReceber: any[];
|
|
104
|
+
getPessoaById: (id?: string) => any | undefined;
|
|
105
|
+
t: ReturnType<typeof useTranslations>;
|
|
106
|
+
}) {
|
|
107
|
+
const vencimentosPagar = titulosPagar
|
|
108
|
+
.flatMap((t: any) =>
|
|
109
|
+
t.parcelas
|
|
110
|
+
.filter((p: any) => p.status === 'aberto' || p.status === 'vencido')
|
|
111
|
+
.map((p: any) => ({
|
|
112
|
+
tipo: 'pagar' as const,
|
|
113
|
+
documento: t.documento,
|
|
114
|
+
pessoa: getPessoaById(t.fornecedorId)?.nome || '',
|
|
115
|
+
vencimento: p.vencimento,
|
|
116
|
+
valor: p.valor,
|
|
117
|
+
status: p.status,
|
|
118
|
+
}))
|
|
119
|
+
)
|
|
120
|
+
.slice(0, 3);
|
|
121
|
+
|
|
122
|
+
const vencimentosReceber = titulosReceber
|
|
123
|
+
.flatMap((t: any) =>
|
|
124
|
+
t.parcelas
|
|
125
|
+
.filter((p: any) => p.status === 'aberto' || p.status === 'vencido')
|
|
126
|
+
.map((p: any) => ({
|
|
127
|
+
tipo: 'receber' as const,
|
|
128
|
+
documento: t.documento,
|
|
129
|
+
pessoa: getPessoaById(t.clienteId)?.nome || '',
|
|
130
|
+
vencimento: p.vencimento,
|
|
131
|
+
valor: p.valor,
|
|
132
|
+
status: p.status,
|
|
133
|
+
}))
|
|
134
|
+
)
|
|
135
|
+
.slice(0, 3);
|
|
136
|
+
|
|
137
|
+
return (
|
|
138
|
+
<div className="grid gap-6 lg:grid-cols-2">
|
|
139
|
+
<Card>
|
|
140
|
+
<CardHeader>
|
|
141
|
+
<CardTitle className="flex items-center gap-2 text-base">
|
|
142
|
+
<ArrowDownRight className="h-4 w-4 text-red-500" />
|
|
143
|
+
{t('upcoming.payable')}
|
|
144
|
+
</CardTitle>
|
|
145
|
+
<CardDescription>{t('upcoming.nextDueDates')}</CardDescription>
|
|
146
|
+
</CardHeader>
|
|
147
|
+
<CardContent>
|
|
148
|
+
<div className="space-y-4">
|
|
149
|
+
{vencimentosPagar.map((item, i) => (
|
|
150
|
+
<div key={i} className="flex items-center justify-between">
|
|
151
|
+
<div className="space-y-1">
|
|
152
|
+
<p className="text-sm font-medium">{item.documento}</p>
|
|
153
|
+
<p className="text-xs text-muted-foreground">{item.pessoa}</p>
|
|
154
|
+
</div>
|
|
155
|
+
<div className="text-right">
|
|
156
|
+
<p className="text-sm font-medium">
|
|
157
|
+
<Money value={item.valor} />
|
|
158
|
+
</p>
|
|
159
|
+
<p className="text-xs text-muted-foreground">
|
|
160
|
+
{formatarData(item.vencimento)}
|
|
161
|
+
</p>
|
|
162
|
+
</div>
|
|
163
|
+
<StatusBadge status={item.status} />
|
|
164
|
+
</div>
|
|
165
|
+
))}
|
|
166
|
+
</div>
|
|
167
|
+
</CardContent>
|
|
168
|
+
</Card>
|
|
169
|
+
|
|
170
|
+
<Card>
|
|
171
|
+
<CardHeader>
|
|
172
|
+
<CardTitle className="flex items-center gap-2 text-base">
|
|
173
|
+
<ArrowUpRight className="h-4 w-4 text-green-500" />
|
|
174
|
+
{t('upcoming.receivable')}
|
|
175
|
+
</CardTitle>
|
|
176
|
+
<CardDescription>{t('upcoming.nextDueDates')}</CardDescription>
|
|
177
|
+
</CardHeader>
|
|
178
|
+
<CardContent>
|
|
179
|
+
<div className="space-y-4">
|
|
180
|
+
{vencimentosReceber.map((item, i) => (
|
|
181
|
+
<div key={i} className="flex items-center justify-between">
|
|
182
|
+
<div className="space-y-1">
|
|
183
|
+
<p className="text-sm font-medium">{item.documento}</p>
|
|
184
|
+
<p className="text-xs text-muted-foreground">{item.pessoa}</p>
|
|
185
|
+
</div>
|
|
186
|
+
<div className="text-right">
|
|
187
|
+
<p className="text-sm font-medium">
|
|
188
|
+
<Money value={item.valor} />
|
|
189
|
+
</p>
|
|
190
|
+
<p className="text-xs text-muted-foreground">
|
|
191
|
+
{formatarData(item.vencimento)}
|
|
192
|
+
</p>
|
|
193
|
+
</div>
|
|
194
|
+
<StatusBadge status={item.status} />
|
|
195
|
+
</div>
|
|
196
|
+
))}
|
|
197
|
+
</div>
|
|
198
|
+
</CardContent>
|
|
199
|
+
</Card>
|
|
200
|
+
</div>
|
|
201
|
+
);
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
function Alertas({
|
|
205
|
+
titulosPagar,
|
|
206
|
+
extratos,
|
|
207
|
+
t,
|
|
208
|
+
}: {
|
|
209
|
+
titulosPagar: any[];
|
|
210
|
+
extratos: any[];
|
|
211
|
+
t: ReturnType<typeof useTranslations>;
|
|
212
|
+
}) {
|
|
213
|
+
const vencidos = titulosPagar.filter((t) =>
|
|
214
|
+
t.parcelas.some((p: any) => p.status === 'vencido')
|
|
215
|
+
).length;
|
|
216
|
+
const pendenteConciliacao = extratos.filter(
|
|
217
|
+
(e) => e.statusConciliacao === 'pendente'
|
|
218
|
+
).length;
|
|
219
|
+
|
|
220
|
+
return (
|
|
221
|
+
<Card>
|
|
222
|
+
<CardHeader>
|
|
223
|
+
<CardTitle className="flex items-center gap-2 text-base">
|
|
224
|
+
<AlertTriangle className="h-4 w-4 text-yellow-500" />
|
|
225
|
+
{t('alerts.title')}
|
|
226
|
+
</CardTitle>
|
|
227
|
+
</CardHeader>
|
|
228
|
+
<CardContent>
|
|
229
|
+
<div className="space-y-3">
|
|
230
|
+
{vencidos > 0 && (
|
|
231
|
+
<div className="flex items-center justify-between rounded-lg bg-red-50 p-3">
|
|
232
|
+
<span className="text-sm">{t('alerts.overdueTitles')}</span>
|
|
233
|
+
<Badge variant="destructive">{vencidos}</Badge>
|
|
234
|
+
</div>
|
|
235
|
+
)}
|
|
236
|
+
{pendenteConciliacao > 0 && (
|
|
237
|
+
<div className="flex items-center justify-between rounded-lg bg-yellow-50 p-3">
|
|
238
|
+
<span className="text-sm">
|
|
239
|
+
{t('alerts.pendingReconciliation')}
|
|
240
|
+
</span>
|
|
241
|
+
<Badge
|
|
242
|
+
variant="outline"
|
|
243
|
+
className="border-yellow-500 text-yellow-700"
|
|
244
|
+
>
|
|
245
|
+
{pendenteConciliacao}
|
|
246
|
+
</Badge>
|
|
247
|
+
</div>
|
|
248
|
+
)}
|
|
249
|
+
<div className="flex items-center justify-between rounded-lg bg-blue-50 p-3">
|
|
250
|
+
<span className="text-sm">{t('alerts.openPeriod')}</span>
|
|
251
|
+
<Badge variant="outline" className="border-blue-500 text-blue-700">
|
|
252
|
+
{t('alerts.currentPeriod')}
|
|
253
|
+
</Badge>
|
|
254
|
+
</div>
|
|
255
|
+
</div>
|
|
256
|
+
</CardContent>
|
|
257
|
+
</Card>
|
|
258
|
+
);
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
export default function DashboardPage() {
|
|
262
|
+
const t = useTranslations('finance.DashboardPage');
|
|
263
|
+
const { data } = useFinanceData();
|
|
264
|
+
const {
|
|
265
|
+
kpis,
|
|
266
|
+
fluxoCaixaPrevisto,
|
|
267
|
+
titulosPagar,
|
|
268
|
+
titulosReceber,
|
|
269
|
+
extratos,
|
|
270
|
+
pessoas,
|
|
271
|
+
} = data;
|
|
272
|
+
|
|
273
|
+
const getPessoaById = (id?: string) => pessoas.find((p) => p.id === id);
|
|
274
|
+
|
|
275
|
+
return (
|
|
276
|
+
<Page>
|
|
277
|
+
<PageHeader
|
|
278
|
+
title={t('header.title')}
|
|
279
|
+
description={t('header.description')}
|
|
280
|
+
breadcrumbs={[
|
|
281
|
+
{ label: t('breadcrumbs.home'), href: '/' },
|
|
282
|
+
{ label: t('breadcrumbs.finance') },
|
|
283
|
+
]}
|
|
284
|
+
/>
|
|
285
|
+
|
|
286
|
+
<div className="grid gap-4 md:grid-cols-2 lg:grid-cols-4">
|
|
287
|
+
<KpiCard
|
|
288
|
+
title={t('kpis.cashBalance.title')}
|
|
289
|
+
value={formatarMoeda(kpis.saldoCaixa)}
|
|
290
|
+
icon={Wallet}
|
|
291
|
+
description={t('kpis.cashBalance.description')}
|
|
292
|
+
/>
|
|
293
|
+
<KpiCard
|
|
294
|
+
title={t('kpis.payable30.title')}
|
|
295
|
+
value={formatarMoeda(kpis.aPagar30dias)}
|
|
296
|
+
icon={TrendingDown}
|
|
297
|
+
description={t('kpis.payable30.sevenDays', {
|
|
298
|
+
value: formatarMoeda(kpis.aPagar7dias),
|
|
299
|
+
})}
|
|
300
|
+
/>
|
|
301
|
+
<KpiCard
|
|
302
|
+
title={t('kpis.receivable30.title')}
|
|
303
|
+
value={formatarMoeda(kpis.aReceber30dias)}
|
|
304
|
+
icon={TrendingUp}
|
|
305
|
+
description={t('kpis.receivable30.sevenDays', {
|
|
306
|
+
value: formatarMoeda(kpis.aReceber7dias),
|
|
307
|
+
})}
|
|
308
|
+
/>
|
|
309
|
+
<KpiCard
|
|
310
|
+
title={t('kpis.default.title')}
|
|
311
|
+
value={formatarMoeda(kpis.inadimplencia)}
|
|
312
|
+
icon={AlertTriangle}
|
|
313
|
+
description={t('kpis.default.description')}
|
|
314
|
+
/>
|
|
315
|
+
</div>
|
|
316
|
+
|
|
317
|
+
<div className="grid gap-6 lg:grid-cols-3">
|
|
318
|
+
<Card className="lg:col-span-2">
|
|
319
|
+
<CardHeader>
|
|
320
|
+
<CardTitle>{t('cashFlow.title')}</CardTitle>
|
|
321
|
+
<CardDescription>{t('cashFlow.description')}</CardDescription>
|
|
322
|
+
</CardHeader>
|
|
323
|
+
<CardContent>
|
|
324
|
+
<DashboardChart fluxoCaixaPrevisto={fluxoCaixaPrevisto} t={t} />
|
|
325
|
+
</CardContent>
|
|
326
|
+
</Card>
|
|
327
|
+
<Alertas titulosPagar={titulosPagar} extratos={extratos} t={t} />
|
|
328
|
+
</div>
|
|
329
|
+
|
|
330
|
+
<ProximosVencimentos
|
|
331
|
+
titulosPagar={titulosPagar}
|
|
332
|
+
titulosReceber={titulosReceber}
|
|
333
|
+
getPessoaById={getPessoaById}
|
|
334
|
+
t={t}
|
|
335
|
+
/>
|
|
336
|
+
</Page>
|
|
337
|
+
);
|
|
338
|
+
}
|