@hed-hog/finance 0.0.298 → 0.0.300
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-bank-account.dto.d.ts +1 -0
- package/dist/dto/create-bank-account.dto.d.ts.map +1 -1
- package/dist/dto/create-bank-account.dto.js +7 -0
- package/dist/dto/create-bank-account.dto.js.map +1 -1
- package/dist/dto/update-bank-account.dto.d.ts +1 -0
- package/dist/dto/update-bank-account.dto.d.ts.map +1 -1
- package/dist/dto/update-bank-account.dto.js +7 -0
- package/dist/dto/update-bank-account.dto.js.map +1 -1
- package/dist/finance-bank-accounts.controller.d.ts +3 -0
- package/dist/finance-bank-accounts.controller.d.ts.map +1 -1
- package/dist/finance-data.controller.d.ts +1 -0
- package/dist/finance-data.controller.d.ts.map +1 -1
- package/dist/finance.service.d.ts +4 -0
- package/dist/finance.service.d.ts.map +1 -1
- package/dist/finance.service.js +5 -0
- package/dist/finance.service.js.map +1 -1
- package/hedhog/data/dashboard.yaml +6 -0
- package/hedhog/data/dashboard_component.yaml +142 -0
- package/hedhog/data/dashboard_component_role.yaml +78 -0
- package/hedhog/data/dashboard_item.yaml +155 -0
- package/hedhog/data/dashboard_role.yaml +6 -0
- package/hedhog/data/role_menu.yaml +6 -0
- package/hedhog/data/role_route.yaml +127 -0
- package/hedhog/frontend/app/cash-and-banks/bank-accounts/page.tsx.ejs +328 -12
- package/hedhog/frontend/messages/en.json +48 -2
- package/hedhog/frontend/messages/pt.json +48 -2
- package/hedhog/frontend/public/dashboard-previews/cash-balance-kpi.png +0 -0
- package/hedhog/frontend/public/dashboard-previews/cash-flow-chart.png +0 -0
- package/hedhog/frontend/public/dashboard-previews/default-kpi.png +0 -0
- package/hedhog/frontend/public/dashboard-previews/financial-alerts.png +0 -0
- package/hedhog/frontend/public/dashboard-previews/payable-30d-kpi.png +0 -0
- package/hedhog/frontend/public/dashboard-previews/receivable-30d-kpi.png +0 -0
- package/hedhog/frontend/public/dashboard-previews/upcoming-payable.png +0 -0
- package/hedhog/frontend/public/dashboard-previews/upcoming-receivable.png +0 -0
- package/hedhog/frontend/widgets/alerts.tsx.ejs +108 -0
- package/hedhog/frontend/widgets/bank-reconciliation-status.tsx.ejs +142 -0
- package/hedhog/frontend/widgets/cash-balance-kpi.tsx.ejs +66 -0
- package/hedhog/frontend/widgets/cash-flow-chart.tsx.ejs +122 -0
- package/hedhog/frontend/widgets/default-kpi.tsx.ejs +63 -0
- package/hedhog/frontend/widgets/payable-30d-kpi.tsx.ejs +73 -0
- package/hedhog/frontend/widgets/pending-approvals-kpi.tsx.ejs +78 -0
- package/hedhog/frontend/widgets/pending-approvals-list.tsx.ejs +147 -0
- package/hedhog/frontend/widgets/pending-reconciliation-kpi.tsx.ejs +84 -0
- package/hedhog/frontend/widgets/receivable-30d-kpi.tsx.ejs +73 -0
- package/hedhog/frontend/widgets/receivable-aging-analysis.tsx.ejs +163 -0
- package/hedhog/frontend/widgets/upcoming-payable.tsx.ejs +123 -0
- package/hedhog/frontend/widgets/upcoming-receivable.tsx.ejs +118 -0
- package/hedhog/table/bank_account.yaml +8 -0
- package/package.json +5 -5
- package/src/dto/create-bank-account.dto.ts +7 -1
- package/src/dto/update-bank-account.dto.ts +7 -1
- package/src/finance.service.ts +4 -0
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
Card,
|
|
5
|
+
CardContent,
|
|
6
|
+
CardDescription,
|
|
7
|
+
CardHeader,
|
|
8
|
+
CardTitle,
|
|
9
|
+
} from '@/components/ui/card';
|
|
10
|
+
import { Money } from '@/components/ui/money';
|
|
11
|
+
import { StatusBadge } from '@/components/ui/status-badge';
|
|
12
|
+
import { useWidgetData } from '@/hooks/use-widget-data';
|
|
13
|
+
import { ArrowUpRight } from 'lucide-react';
|
|
14
|
+
import { useTranslations } from 'next-intl';
|
|
15
|
+
import Link from 'next/link';
|
|
16
|
+
import { WidgetWrapper } from '@/app/(app)/(libraries)/core/dashboard/components';
|
|
17
|
+
|
|
18
|
+
interface FinanceData {
|
|
19
|
+
titulosReceber?: Array<{
|
|
20
|
+
id: string;
|
|
21
|
+
documento: string;
|
|
22
|
+
clienteId?: string;
|
|
23
|
+
parcelas: Array<{
|
|
24
|
+
status: string;
|
|
25
|
+
vencimento: string;
|
|
26
|
+
valor: number;
|
|
27
|
+
}>;
|
|
28
|
+
}>;
|
|
29
|
+
pessoas?: Array<{
|
|
30
|
+
id: string;
|
|
31
|
+
nome: string;
|
|
32
|
+
}>;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
interface UpcomingReceivableProps {
|
|
36
|
+
widget?: { name?: string };
|
|
37
|
+
onRemove?: () => void;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function formatDate(value: string) {
|
|
41
|
+
return new Date(value).toLocaleDateString('pt-BR');
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export default function UpcomingReceivable({
|
|
45
|
+
widget,
|
|
46
|
+
onRemove,
|
|
47
|
+
}: UpcomingReceivableProps) {
|
|
48
|
+
const t = useTranslations('finance.DashboardPage');
|
|
49
|
+
|
|
50
|
+
const { data, isLoading, isAccessDenied, isError } =
|
|
51
|
+
useWidgetData<FinanceData>({
|
|
52
|
+
endpoint: '/finance/data',
|
|
53
|
+
queryKey: 'finance-upcoming-receivable',
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
const getPersonById = (id?: string) =>
|
|
57
|
+
(data?.pessoas || []).find((p) => p.id === id);
|
|
58
|
+
|
|
59
|
+
const rows = (data?.titulosReceber || [])
|
|
60
|
+
.flatMap((titulo) =>
|
|
61
|
+
titulo.parcelas
|
|
62
|
+
.filter((p) => p.status === 'aberto' || p.status === 'vencido')
|
|
63
|
+
.map((parcela) => ({
|
|
64
|
+
tituloId: titulo.id,
|
|
65
|
+
documento: titulo.documento,
|
|
66
|
+
person: getPersonById(titulo.clienteId)?.nome || '',
|
|
67
|
+
dueDate: parcela.vencimento,
|
|
68
|
+
value: parcela.valor,
|
|
69
|
+
status: parcela.status,
|
|
70
|
+
}))
|
|
71
|
+
)
|
|
72
|
+
.slice(0, 3);
|
|
73
|
+
|
|
74
|
+
return (
|
|
75
|
+
<WidgetWrapper
|
|
76
|
+
isLoading={isLoading}
|
|
77
|
+
isAccessDenied={isAccessDenied}
|
|
78
|
+
isError={isError}
|
|
79
|
+
widgetName={widget?.name || t('upcoming.receivable')}
|
|
80
|
+
onRemove={onRemove}
|
|
81
|
+
>
|
|
82
|
+
<Card className="h-full">
|
|
83
|
+
<CardHeader>
|
|
84
|
+
<CardTitle className="flex items-center gap-2 text-base">
|
|
85
|
+
<ArrowUpRight className="h-4 w-4 text-green-500" />
|
|
86
|
+
{t('upcoming.receivable')}
|
|
87
|
+
</CardTitle>
|
|
88
|
+
<CardDescription>{t('upcoming.nextDueDates')}</CardDescription>
|
|
89
|
+
</CardHeader>
|
|
90
|
+
<CardContent>
|
|
91
|
+
<div className="space-y-4">
|
|
92
|
+
{rows.map((item, index) => (
|
|
93
|
+
<Link
|
|
94
|
+
key={index}
|
|
95
|
+
href={`/finance/accounts-receivable/installments/${item.tituloId}`}
|
|
96
|
+
className="-m-2 flex cursor-pointer items-center justify-between rounded-md p-2 transition-colors hover:bg-muted/50 active:bg-muted"
|
|
97
|
+
>
|
|
98
|
+
<div className="space-y-1">
|
|
99
|
+
<p className="text-sm font-medium">{item.documento}</p>
|
|
100
|
+
<p className="text-xs text-muted-foreground">{item.person}</p>
|
|
101
|
+
</div>
|
|
102
|
+
<div className="text-right">
|
|
103
|
+
<p className="text-sm font-medium">
|
|
104
|
+
<Money value={item.value} />
|
|
105
|
+
</p>
|
|
106
|
+
<p className="text-xs text-muted-foreground">
|
|
107
|
+
{formatDate(item.dueDate)}
|
|
108
|
+
</p>
|
|
109
|
+
</div>
|
|
110
|
+
<StatusBadge status={item.status as any} />
|
|
111
|
+
</Link>
|
|
112
|
+
))}
|
|
113
|
+
</div>
|
|
114
|
+
</CardContent>
|
|
115
|
+
</Card>
|
|
116
|
+
</WidgetWrapper>
|
|
117
|
+
);
|
|
118
|
+
}
|
|
@@ -25,6 +25,13 @@ columns:
|
|
|
25
25
|
- name: account_type
|
|
26
26
|
type: enum
|
|
27
27
|
values: [checking, savings, investment, cash, other]
|
|
28
|
+
- name: logo_file_id
|
|
29
|
+
type: fk
|
|
30
|
+
isNullable: true
|
|
31
|
+
references:
|
|
32
|
+
table: file
|
|
33
|
+
column: id
|
|
34
|
+
onDelete: SET NULL
|
|
28
35
|
- name: status
|
|
29
36
|
type: enum
|
|
30
37
|
values: [active, inactive]
|
|
@@ -34,4 +41,5 @@ columns:
|
|
|
34
41
|
indices:
|
|
35
42
|
- columns: [code]
|
|
36
43
|
isUnique: true
|
|
44
|
+
- columns: [logo_file_id]
|
|
37
45
|
- columns: [status]
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hed-hog/finance",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.300",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"dependencies": {
|
|
@@ -9,13 +9,13 @@
|
|
|
9
9
|
"@nestjs/core": "^11",
|
|
10
10
|
"@nestjs/jwt": "^11",
|
|
11
11
|
"@nestjs/mapped-types": "*",
|
|
12
|
-
"@hed-hog/contact": "0.0.298",
|
|
13
|
-
"@hed-hog/api-pagination": "0.0.7",
|
|
14
12
|
"@hed-hog/api": "0.0.6",
|
|
15
13
|
"@hed-hog/api-locale": "0.0.14",
|
|
14
|
+
"@hed-hog/tag": "0.0.300",
|
|
15
|
+
"@hed-hog/contact": "0.0.300",
|
|
16
16
|
"@hed-hog/api-prisma": "0.0.6",
|
|
17
|
-
"@hed-hog/
|
|
18
|
-
"@hed-hog/
|
|
17
|
+
"@hed-hog/api-pagination": "0.0.7",
|
|
18
|
+
"@hed-hog/core": "0.0.300",
|
|
19
19
|
"@hed-hog/api-types": "0.0.1"
|
|
20
20
|
},
|
|
21
21
|
"exports": {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { getLocaleText } from '@hed-hog/api-locale';
|
|
2
|
-
import { IsNumber, IsOptional, IsString, Min } from 'class-validator';
|
|
2
|
+
import { IsInt, IsNumber, IsOptional, IsString, Min } from 'class-validator';
|
|
3
3
|
|
|
4
4
|
export class CreateBankAccountDto {
|
|
5
5
|
@IsString({
|
|
@@ -34,6 +34,12 @@ export class CreateBankAccountDto {
|
|
|
34
34
|
})
|
|
35
35
|
description?: string;
|
|
36
36
|
|
|
37
|
+
@IsOptional()
|
|
38
|
+
@IsInt({
|
|
39
|
+
message: (args) => getLocaleText('validation.idMustBeInteger', args.value),
|
|
40
|
+
})
|
|
41
|
+
logo_file_id?: number | null;
|
|
42
|
+
|
|
37
43
|
@IsOptional()
|
|
38
44
|
@IsNumber(
|
|
39
45
|
{},
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { getLocaleText } from '@hed-hog/api-locale';
|
|
2
|
-
import { IsOptional, IsString } from 'class-validator';
|
|
2
|
+
import { IsInt, IsOptional, IsString } from 'class-validator';
|
|
3
3
|
|
|
4
4
|
export class UpdateBankAccountDto {
|
|
5
5
|
@IsOptional()
|
|
@@ -36,6 +36,12 @@ export class UpdateBankAccountDto {
|
|
|
36
36
|
})
|
|
37
37
|
description?: string;
|
|
38
38
|
|
|
39
|
+
@IsOptional()
|
|
40
|
+
@IsInt({
|
|
41
|
+
message: (args) => getLocaleText('validation.idMustBeInteger', args.value),
|
|
42
|
+
})
|
|
43
|
+
logo_file_id?: number | null;
|
|
44
|
+
|
|
39
45
|
@IsOptional()
|
|
40
46
|
@IsString({
|
|
41
47
|
message: (args) =>
|
package/src/finance.service.ts
CHANGED
|
@@ -4013,6 +4013,7 @@ export class FinanceService {
|
|
|
4013
4013
|
agency: data.branch || null,
|
|
4014
4014
|
account_number: data.account || null,
|
|
4015
4015
|
account_type: accountType,
|
|
4016
|
+
logo_file_id: data.logo_file_id ?? null,
|
|
4016
4017
|
status: 'active',
|
|
4017
4018
|
},
|
|
4018
4019
|
});
|
|
@@ -4166,6 +4167,8 @@ export class FinanceService {
|
|
|
4166
4167
|
account_number: data.account,
|
|
4167
4168
|
name: data.description,
|
|
4168
4169
|
account_type: data.type ? this.mapAccountTypeFromPt(data.type) : undefined,
|
|
4170
|
+
logo_file_id:
|
|
4171
|
+
data.logo_file_id === undefined ? undefined : data.logo_file_id,
|
|
4169
4172
|
status: data.status,
|
|
4170
4173
|
},
|
|
4171
4174
|
include: {
|
|
@@ -6447,6 +6450,7 @@ export class FinanceService {
|
|
|
6447
6450
|
agencia: bankAccount.agency || '-',
|
|
6448
6451
|
conta: bankAccount.account_number || '-',
|
|
6449
6452
|
tipo: this.mapAccountTypeToPt(bankAccount.account_type),
|
|
6453
|
+
logoFileId: bankAccount.logo_file_id ?? null,
|
|
6450
6454
|
saldoAtual: this.fromCents(currentCents),
|
|
6451
6455
|
saldoConciliado: this.fromCents(reconciledCents),
|
|
6452
6456
|
ativo: bankAccount.status === 'active',
|