@hed-hog/finance 0.0.301 → 0.0.303

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.
@@ -3,7 +3,6 @@
3
3
  import { FinancePageSection } from '@/app/(app)/(libraries)/finance/_components/finance-layout';
4
4
  import { EmptyState, Page, PageHeader } from '@/components/entity-list';
5
5
  import { Button } from '@/components/ui/button';
6
- import { KpiCardsGrid } from '@/components/ui/kpi-cards-grid';
7
6
  import {
8
7
  Dialog,
9
8
  DialogContent,
@@ -23,6 +22,7 @@ import {
23
22
  } from '@/components/ui/form';
24
23
  import { Input } from '@/components/ui/input';
25
24
  import { InputMoney } from '@/components/ui/input-money';
25
+ import { KpiCardsGrid } from '@/components/ui/kpi-cards-grid';
26
26
  import { Money } from '@/components/ui/money';
27
27
  import {
28
28
  Select,
@@ -796,6 +796,7 @@ export default function ExtratosPage() {
796
796
  <KpiCardsGrid items={summaryCards} columns={3} />
797
797
 
798
798
  <FinancePageSection
799
+ variant="flat"
799
800
  title={t('table.title')}
800
801
  description={t('table.foundTransactions', { count: extratos.length })}
801
802
  contentClassName="p-4 sm:p-5"
@@ -875,15 +876,13 @@ export default function ExtratosPage() {
875
876
  </Table>
876
877
  </div>
877
878
  ) : (
878
- <div className="p-2 sm:p-4">
879
- <EmptyState
880
- icon={<Upload className="h-12 w-12" />}
881
- title={t('empty.title')}
882
- description={t('empty.description')}
883
- actionLabel={t('importDialog.action')}
884
- onAction={() => setIsImportSheetOpen(true)}
885
- />
886
- </div>
879
+ <EmptyState
880
+ icon={<Upload className="h-12 w-12" />}
881
+ title={t('empty.title')}
882
+ description={t('empty.description')}
883
+ actionLabel={t('importDialog.action')}
884
+ onAction={() => setIsImportSheetOpen(true)}
885
+ />
887
886
  )}
888
887
  </FinancePageSection>
889
888
 
@@ -3,7 +3,6 @@
3
3
  import { FinancePageSection } from '@/app/(app)/(libraries)/finance/_components/finance-layout';
4
4
  import { Page, PageHeader } from '@/components/entity-list';
5
5
  import { Button } from '@/components/ui/button';
6
- import { KpiCardsGrid } from '@/components/ui/kpi-cards-grid';
7
6
  import { FilterBar } from '@/components/ui/filter-bar';
8
7
  import {
9
8
  Form,
@@ -15,6 +14,7 @@ import {
15
14
  } from '@/components/ui/form';
16
15
  import { Input } from '@/components/ui/input';
17
16
  import { InputMoney } from '@/components/ui/input-money';
17
+ import { KpiCardsGrid } from '@/components/ui/kpi-cards-grid';
18
18
  import { Money } from '@/components/ui/money';
19
19
  import {
20
20
  Select,
@@ -407,11 +407,7 @@ export default function TransferenciasPage() {
407
407
 
408
408
  <KpiCardsGrid items={summaryCards} columns={2} />
409
409
 
410
- <FinancePageSection
411
- title={t('table.title')}
412
- description={t('table.description')}
413
- contentClassName="p-4 sm:p-5"
414
- >
410
+ <FinancePageSection variant="flat" contentClassName="p-0">
415
411
  <div className="overflow-x-auto">
416
412
  <Table>
417
413
  <TableHeader>
@@ -1,372 +1,5 @@
1
- 'use client';
1
+ import { redirect } from 'next/navigation';
2
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
- );
3
+ export default function FinancePage() {
4
+ redirect('/finance/reports/cash-position');
372
5
  }
@@ -222,82 +222,74 @@ export default function FluxoCaixaPage() {
222
222
  <TabsTrigger value="saidas">{t('tabs.expectedOutflows')}</TabsTrigger>
223
223
  </TabsList>
224
224
 
225
- <TabsContent value="entradas" className="mt-4">
226
- <Card>
227
- <CardContent className="pt-6">
228
- <Table>
229
- <TableHeader>
230
- <TableRow>
231
- <TableHead>{t('table.headers.category')}</TableHead>
232
- <TableHead>{t('table.headers.dueDate')}</TableHead>
233
- <TableHead className="text-right">
234
- {t('table.headers.value')}
235
- </TableHead>
236
- </TableRow>
237
- </TableHeader>
238
- <TableBody>
239
- {entradasPrevistas.map((entrada, i) => (
240
- <TableRow key={i}>
241
- <TableCell className="font-medium">
242
- {entrada.categoria}
243
- </TableCell>
244
- <TableCell>{formatarData(entrada.vencimento)}</TableCell>
245
- <TableCell className="text-right text-green-600 font-semibold">
246
- <Money value={entrada.valor} />
247
- </TableCell>
248
- </TableRow>
249
- ))}
250
- <TableRow className="bg-muted/50">
251
- <TableCell className="font-bold" colSpan={2}>
252
- {t('table.total')}
253
- </TableCell>
254
- <TableCell className="text-right font-bold text-green-600">
255
- <Money value={totalEntradas} />
256
- </TableCell>
257
- </TableRow>
258
- </TableBody>
259
- </Table>
260
- </CardContent>
261
- </Card>
225
+ <TabsContent value="entradas">
226
+ <Table>
227
+ <TableHeader>
228
+ <TableRow>
229
+ <TableHead>{t('table.headers.category')}</TableHead>
230
+ <TableHead>{t('table.headers.dueDate')}</TableHead>
231
+ <TableHead className="text-right">
232
+ {t('table.headers.value')}
233
+ </TableHead>
234
+ </TableRow>
235
+ </TableHeader>
236
+ <TableBody>
237
+ {entradasPrevistas.map((entrada, i) => (
238
+ <TableRow key={i}>
239
+ <TableCell className="font-medium">
240
+ {entrada.categoria}
241
+ </TableCell>
242
+ <TableCell>{formatarData(entrada.vencimento)}</TableCell>
243
+ <TableCell className="text-right text-green-600 font-semibold">
244
+ <Money value={entrada.valor} />
245
+ </TableCell>
246
+ </TableRow>
247
+ ))}
248
+ <TableRow className="bg-muted/50">
249
+ <TableCell className="font-bold" colSpan={2}>
250
+ {t('table.total')}
251
+ </TableCell>
252
+ <TableCell className="text-right font-bold text-green-600">
253
+ <Money value={totalEntradas} />
254
+ </TableCell>
255
+ </TableRow>
256
+ </TableBody>
257
+ </Table>
262
258
  </TabsContent>
263
259
 
264
- <TabsContent value="saidas" className="mt-4">
265
- <Card>
266
- <CardContent className="pt-6">
267
- <Table>
268
- <TableHeader>
269
- <TableRow>
270
- <TableHead>{t('table.headers.category')}</TableHead>
271
- <TableHead>{t('table.headers.dueDate')}</TableHead>
272
- <TableHead className="text-right">
273
- {t('table.headers.value')}
274
- </TableHead>
275
- </TableRow>
276
- </TableHeader>
277
- <TableBody>
278
- {saidasPrevistas.map((saida, i) => (
279
- <TableRow key={i}>
280
- <TableCell className="font-medium">
281
- {saida.categoria}
282
- </TableCell>
283
- <TableCell>{formatarData(saida.vencimento)}</TableCell>
284
- <TableCell className="text-right text-red-600 font-semibold">
285
- <Money value={saida.valor} />
286
- </TableCell>
287
- </TableRow>
288
- ))}
289
- <TableRow className="bg-muted/50">
290
- <TableCell className="font-bold" colSpan={2}>
291
- {t('table.total')}
292
- </TableCell>
293
- <TableCell className="text-right font-bold text-red-600">
294
- <Money value={totalSaidas} />
295
- </TableCell>
296
- </TableRow>
297
- </TableBody>
298
- </Table>
299
- </CardContent>
300
- </Card>
260
+ <TabsContent value="saidas">
261
+ <Table>
262
+ <TableHeader>
263
+ <TableRow>
264
+ <TableHead>{t('table.headers.category')}</TableHead>
265
+ <TableHead>{t('table.headers.dueDate')}</TableHead>
266
+ <TableHead className="text-right">
267
+ {t('table.headers.value')}
268
+ </TableHead>
269
+ </TableRow>
270
+ </TableHeader>
271
+ <TableBody>
272
+ {saidasPrevistas.map((saida, i) => (
273
+ <TableRow key={i}>
274
+ <TableCell className="font-medium">
275
+ {saida.categoria}
276
+ </TableCell>
277
+ <TableCell>{formatarData(saida.vencimento)}</TableCell>
278
+ <TableCell className="text-right text-red-600 font-semibold">
279
+ <Money value={saida.valor} />
280
+ </TableCell>
281
+ </TableRow>
282
+ ))}
283
+ <TableRow className="bg-muted/50">
284
+ <TableCell className="font-bold" colSpan={2}>
285
+ {t('table.total')}
286
+ </TableCell>
287
+ <TableCell className="text-right font-bold text-red-600">
288
+ <Money value={totalSaidas} />
289
+ </TableCell>
290
+ </TableRow>
291
+ </TableBody>
292
+ </Table>
301
293
  </TabsContent>
302
294
  </Tabs>
303
295
  </Page>
@@ -147,11 +147,7 @@ export default function RecebiveisPage() {
147
147
  })}
148
148
  </div>
149
149
 
150
- <FinancePageSection
151
- title={t('table.title')}
152
- description={t('table.description')}
153
- contentClassName="p-4 sm:p-5"
154
- >
150
+ <FinancePageSection variant="flat" contentClassName="p-0">
155
151
  <div className="overflow-x-auto">
156
152
  <Table>
157
153
  <TableHeader>
@@ -85,7 +85,7 @@ export default function CenariosPage() {
85
85
  ]}
86
86
  />
87
87
 
88
- <FinancePageSection contentClassName="p-4 sm:p-5">
88
+ <FinancePageSection variant="flat" contentClassName="p-0">
89
89
  <div className="grid gap-4 md:grid-cols-3">
90
90
  {cenarios.map((cenario) => {
91
91
  const isAtivo = cenario.id === cenarioAtivo;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hed-hog/finance",
3
- "version": "0.0.301",
3
+ "version": "0.0.303",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "dependencies": {
@@ -12,11 +12,11 @@
12
12
  "@hed-hog/api": "0.0.6",
13
13
  "@hed-hog/api-pagination": "0.0.7",
14
14
  "@hed-hog/api-locale": "0.0.14",
15
- "@hed-hog/core": "0.0.301",
15
+ "@hed-hog/tag": "0.0.303",
16
16
  "@hed-hog/api-prisma": "0.0.6",
17
- "@hed-hog/tag": "0.0.301",
18
- "@hed-hog/api-types": "0.0.1",
19
- "@hed-hog/contact": "0.0.301"
17
+ "@hed-hog/contact": "0.0.303",
18
+ "@hed-hog/core": "0.0.303",
19
+ "@hed-hog/api-types": "0.0.1"
20
20
  },
21
21
  "exports": {
22
22
  ".": {