@hed-hog/finance 0.0.350 → 0.0.353
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 +6 -0
- package/dist/dto/create-financial-title.dto.d.ts.map +1 -1
- package/dist/dto/create-financial-title.dto.js +27 -1
- package/dist/dto/create-financial-title.dto.js.map +1 -1
- package/dist/finance-data.controller.d.ts +12 -0
- package/dist/finance-data.controller.d.ts.map +1 -1
- package/dist/finance-installments.controller.d.ts +120 -0
- package/dist/finance-installments.controller.d.ts.map +1 -1
- package/dist/finance-realtime.controller.d.ts +7 -0
- package/dist/finance-realtime.controller.d.ts.map +1 -0
- package/dist/finance-realtime.controller.js +34 -0
- package/dist/finance-realtime.controller.js.map +1 -0
- package/dist/finance-realtime.service.d.ts +36 -0
- package/dist/finance-realtime.service.d.ts.map +1 -0
- package/dist/finance-realtime.service.js +59 -0
- package/dist/finance-realtime.service.js.map +1 -0
- package/dist/finance-statements.controller.d.ts +6 -0
- package/dist/finance-statements.controller.d.ts.map +1 -1
- package/dist/finance.module.d.ts.map +1 -1
- package/dist/finance.module.js +28 -0
- package/dist/finance.module.js.map +1 -1
- package/dist/finance.service.d.ts +142 -1
- package/dist/finance.service.d.ts.map +1 -1
- package/dist/finance.service.js +134 -19
- package/dist/finance.service.js.map +1 -1
- package/dist/mcp-tools/finance-audit-logs.mcp-tools.d.ts +8 -0
- package/dist/mcp-tools/finance-audit-logs.mcp-tools.d.ts.map +1 -0
- package/dist/mcp-tools/finance-audit-logs.mcp-tools.js +60 -0
- package/dist/mcp-tools/finance-audit-logs.mcp-tools.js.map +1 -0
- package/dist/mcp-tools/finance-bank-accounts.mcp-tools.d.ts +16 -0
- package/dist/mcp-tools/finance-bank-accounts.mcp-tools.d.ts.map +1 -0
- package/dist/mcp-tools/finance-bank-accounts.mcp-tools.js +121 -0
- package/dist/mcp-tools/finance-bank-accounts.mcp-tools.js.map +1 -0
- package/dist/mcp-tools/finance-categories.mcp-tools.d.ts +20 -0
- package/dist/mcp-tools/finance-categories.mcp-tools.d.ts.map +1 -0
- package/dist/mcp-tools/finance-categories.mcp-tools.js +135 -0
- package/dist/mcp-tools/finance-categories.mcp-tools.js.map +1 -0
- package/dist/mcp-tools/finance-collections.mcp-tools.d.ts +16 -0
- package/dist/mcp-tools/finance-collections.mcp-tools.d.ts.map +1 -0
- package/dist/mcp-tools/finance-collections.mcp-tools.js +91 -0
- package/dist/mcp-tools/finance-collections.mcp-tools.js.map +1 -0
- package/dist/mcp-tools/finance-cost-centers.mcp-tools.d.ts +16 -0
- package/dist/mcp-tools/finance-cost-centers.mcp-tools.d.ts.map +1 -0
- package/dist/mcp-tools/finance-cost-centers.mcp-tools.js +114 -0
- package/dist/mcp-tools/finance-cost-centers.mcp-tools.js.map +1 -0
- package/dist/mcp-tools/finance-currencies.mcp-tools.d.ts +16 -0
- package/dist/mcp-tools/finance-currencies.mcp-tools.d.ts.map +1 -0
- package/dist/mcp-tools/finance-currencies.mcp-tools.js +120 -0
- package/dist/mcp-tools/finance-currencies.mcp-tools.js.map +1 -0
- package/dist/mcp-tools/finance-data.mcp-tools.d.ts +15 -0
- package/dist/mcp-tools/finance-data.mcp-tools.d.ts.map +1 -0
- package/dist/mcp-tools/finance-data.mcp-tools.js +80 -0
- package/dist/mcp-tools/finance-data.mcp-tools.js.map +1 -0
- package/dist/mcp-tools/finance-installments.mcp-tools.d.ts +93 -0
- package/dist/mcp-tools/finance-installments.mcp-tools.d.ts.map +1 -0
- package/dist/mcp-tools/finance-installments.mcp-tools.js +646 -0
- package/dist/mcp-tools/finance-installments.mcp-tools.js.map +1 -0
- package/dist/mcp-tools/finance-period-close.mcp-tools.d.ts +9 -0
- package/dist/mcp-tools/finance-period-close.mcp-tools.d.ts.map +1 -0
- package/dist/mcp-tools/finance-period-close.mcp-tools.js +79 -0
- package/dist/mcp-tools/finance-period-close.mcp-tools.js.map +1 -0
- package/dist/mcp-tools/finance-reports.mcp-tools.d.ts +10 -0
- package/dist/mcp-tools/finance-reports.mcp-tools.d.ts.map +1 -0
- package/dist/mcp-tools/finance-reports.mcp-tools.js +89 -0
- package/dist/mcp-tools/finance-reports.mcp-tools.js.map +1 -0
- package/dist/mcp-tools/finance-statements.mcp-tools.d.ts +34 -0
- package/dist/mcp-tools/finance-statements.mcp-tools.d.ts.map +1 -0
- package/dist/mcp-tools/finance-statements.mcp-tools.js +253 -0
- package/dist/mcp-tools/finance-statements.mcp-tools.js.map +1 -0
- package/dist/mcp-tools/finance-transfers.mcp-tools.d.ts +9 -0
- package/dist/mcp-tools/finance-transfers.mcp-tools.d.ts.map +1 -0
- package/dist/mcp-tools/finance-transfers.mcp-tools.js +79 -0
- package/dist/mcp-tools/finance-transfers.mcp-tools.js.map +1 -0
- package/hedhog/data/route.yaml +659 -1
- package/hedhog/frontend/app/_components/finance-title-actions-menu.tsx.ejs +9 -3
- package/hedhog/frontend/app/_lib/http-error.ts.ejs +105 -0
- package/hedhog/frontend/app/_lib/use-finance-realtime-refresh.ts.ejs +62 -0
- package/hedhog/frontend/app/accounts-payable/approvals/page.tsx.ejs +3 -0
- package/hedhog/frontend/app/accounts-payable/installments/[id]/page.tsx.ejs +5 -5
- package/hedhog/frontend/app/accounts-payable/installments/page.tsx.ejs +776 -344
- package/hedhog/frontend/app/accounts-receivable/collections-default/page.tsx.ejs +7 -13
- package/hedhog/frontend/app/accounts-receivable/installments/[id]/page.tsx.ejs +5 -5
- package/hedhog/frontend/app/accounts-receivable/installments/page.tsx.ejs +802 -355
- package/hedhog/frontend/app/administration/categories/page.tsx.ejs +9 -3
- package/hedhog/frontend/app/administration/cost-centers/page.tsx.ejs +9 -3
- package/hedhog/frontend/app/administration/currencies/page.tsx.ejs +9 -3
- package/hedhog/frontend/app/administration/period-close/page.tsx.ejs +9 -3
- package/hedhog/frontend/app/cash-and-banks/bank-accounts/page.tsx.ejs +7 -3
- package/hedhog/frontend/app/cash-and-banks/bank-reconciliation/page.tsx.ejs +3 -3
- package/hedhog/frontend/app/cash-and-banks/statements/page.tsx.ejs +28 -7
- package/hedhog/frontend/app/cash-and-banks/transfers/page.tsx.ejs +12 -3
- package/hedhog/frontend/messages/en.json +63 -3
- package/hedhog/frontend/messages/pt.json +63 -3
- package/hedhog/table/financial_title.yaml +10 -0
- package/package.json +5 -5
- package/src/dto/create-financial-title.dto.ts +23 -0
- package/src/finance-realtime.controller.ts +12 -0
- package/src/finance-realtime.service.ts +106 -0
- package/src/finance.module.ts +28 -0
- package/src/finance.service.ts +184 -45
- package/src/mcp-tools/finance-audit-logs.mcp-tools.ts +38 -0
- package/src/mcp-tools/finance-bank-accounts.mcp-tools.ts +76 -0
- package/src/mcp-tools/finance-categories.mcp-tools.ts +86 -0
- package/src/mcp-tools/finance-collections.mcp-tools.ts +50 -0
- package/src/mcp-tools/finance-cost-centers.mcp-tools.ts +69 -0
- package/src/mcp-tools/finance-currencies.mcp-tools.ts +75 -0
- package/src/mcp-tools/finance-data.mcp-tools.ts +43 -0
- package/src/mcp-tools/finance-installments.mcp-tools.ts +560 -0
- package/src/mcp-tools/finance-period-close.mcp-tools.ts +53 -0
- package/src/mcp-tools/finance-reports.mcp-tools.ts +59 -0
- package/src/mcp-tools/finance-statements.mcp-tools.ts +202 -0
- package/src/mcp-tools/finance-transfers.mcp-tools.ts +53 -0
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
import { McpContext, McpTool } from '@hed-hog/core';
|
|
2
|
+
import { BadRequestException, Injectable } from '@nestjs/common';
|
|
3
|
+
import { FinanceService } from '../finance.service';
|
|
4
|
+
|
|
5
|
+
@Injectable()
|
|
6
|
+
export class FinanceStatementsMcpTools {
|
|
7
|
+
constructor(private readonly financeService: FinanceService) {}
|
|
8
|
+
|
|
9
|
+
@McpTool({
|
|
10
|
+
name: 'finance.statements.list',
|
|
11
|
+
description: 'Lists bank statements with filters and pagination.',
|
|
12
|
+
inputSchema: {
|
|
13
|
+
type: 'object',
|
|
14
|
+
properties: {
|
|
15
|
+
page: { type: 'number', description: 'Page number (default: 1)' },
|
|
16
|
+
pageSize: { type: 'number', description: 'Items per page (default: 20)' },
|
|
17
|
+
bank_account_id: { type: 'number', description: 'Bank account ID filter' },
|
|
18
|
+
search: { type: 'string', description: 'Search term' },
|
|
19
|
+
from: { type: 'string', description: 'Start date (YYYY-MM-DD)' },
|
|
20
|
+
to: { type: 'string', description: 'End date (YYYY-MM-DD)' },
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
readOnly: true,
|
|
24
|
+
})
|
|
25
|
+
async list(args: Record<string, any>, _context: McpContext): Promise<any> {
|
|
26
|
+
const { page, pageSize, bank_account_id, search, from, to } = args;
|
|
27
|
+
return this.financeService.listBankStatements(
|
|
28
|
+
{ page, pageSize } as any,
|
|
29
|
+
bank_account_id,
|
|
30
|
+
search,
|
|
31
|
+
{ from, to },
|
|
32
|
+
);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
@McpTool({
|
|
36
|
+
name: 'finance.bank-reconciliation.summary',
|
|
37
|
+
description: 'Returns bank reconciliation summary for a bank account.',
|
|
38
|
+
inputSchema: {
|
|
39
|
+
type: 'object',
|
|
40
|
+
properties: {
|
|
41
|
+
bank_account_id: { type: 'number', description: 'Bank account ID' },
|
|
42
|
+
},
|
|
43
|
+
required: ['bank_account_id'],
|
|
44
|
+
},
|
|
45
|
+
readOnly: true,
|
|
46
|
+
})
|
|
47
|
+
async summary(args: { bank_account_id: number }, _context: McpContext): Promise<any> {
|
|
48
|
+
return this.financeService.getBankReconciliationSummary(args.bank_account_id);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
@McpTool({
|
|
52
|
+
name: 'finance.bank-reconciliations.create',
|
|
53
|
+
description: 'Creates a bank reconciliation.',
|
|
54
|
+
inputSchema: {
|
|
55
|
+
type: 'object',
|
|
56
|
+
properties: {
|
|
57
|
+
bank_account_id: { type: 'number', description: 'Bank account ID' },
|
|
58
|
+
reconciliation_date: { type: 'string', description: 'Reconciliation date (YYYY-MM-DD)' },
|
|
59
|
+
},
|
|
60
|
+
required: ['bank_account_id'],
|
|
61
|
+
},
|
|
62
|
+
})
|
|
63
|
+
async createBankReconciliation(args: Record<string, any>, context: McpContext): Promise<any> {
|
|
64
|
+
return this.financeService.createBankReconciliation(args as any, context.locale, context.userId);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
@McpTool({
|
|
68
|
+
name: 'finance.statements.export',
|
|
69
|
+
description: 'Exports bank statements in CSV content.',
|
|
70
|
+
inputSchema: {
|
|
71
|
+
type: 'object',
|
|
72
|
+
properties: {
|
|
73
|
+
bank_account_id: { type: 'number', description: 'Bank account ID' },
|
|
74
|
+
search: { type: 'string', description: 'Search term' },
|
|
75
|
+
from: { type: 'string', description: 'Start date (YYYY-MM-DD)' },
|
|
76
|
+
to: { type: 'string', description: 'End date (YYYY-MM-DD)' },
|
|
77
|
+
},
|
|
78
|
+
required: ['bank_account_id'],
|
|
79
|
+
},
|
|
80
|
+
readOnly: true,
|
|
81
|
+
})
|
|
82
|
+
async export(args: { bank_account_id: number; search?: string; from?: string; to?: string }, _context: McpContext): Promise<any> {
|
|
83
|
+
return this.financeService.exportBankStatementsCsv(args.bank_account_id, args.search, {
|
|
84
|
+
from: args.from,
|
|
85
|
+
to: args.to,
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
@McpTool({
|
|
90
|
+
name: 'finance.statements.import',
|
|
91
|
+
description: 'Imports bank statements from a base64 file payload.',
|
|
92
|
+
inputSchema: {
|
|
93
|
+
type: 'object',
|
|
94
|
+
properties: {
|
|
95
|
+
bank_account_id: { type: 'number', description: 'Bank account ID' },
|
|
96
|
+
fileBase64: { type: 'string', description: 'Base64-encoded file content' },
|
|
97
|
+
fileName: { type: 'string', description: 'Original file name' },
|
|
98
|
+
mimeType: { type: 'string', description: 'File MIME type' },
|
|
99
|
+
},
|
|
100
|
+
required: ['bank_account_id', 'fileBase64', 'fileName', 'mimeType'],
|
|
101
|
+
},
|
|
102
|
+
})
|
|
103
|
+
async import(args: { bank_account_id: number; fileBase64: string; fileName: string; mimeType: string }, context: McpContext): Promise<any> {
|
|
104
|
+
const file = this.toMulterFile(args.fileBase64, args.fileName, args.mimeType);
|
|
105
|
+
return this.financeService.importBankStatements(
|
|
106
|
+
args.bank_account_id,
|
|
107
|
+
file,
|
|
108
|
+
context.locale,
|
|
109
|
+
context.userId,
|
|
110
|
+
);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
@McpTool({
|
|
114
|
+
name: 'finance.statements.adjustments.create',
|
|
115
|
+
description: 'Creates a bank statement adjustment.',
|
|
116
|
+
inputSchema: {
|
|
117
|
+
type: 'object',
|
|
118
|
+
properties: {
|
|
119
|
+
bank_statement_entry_id: { type: 'number', description: 'Statement entry ID' },
|
|
120
|
+
adjustment_type: { type: 'string', description: 'Adjustment type' },
|
|
121
|
+
amount: { type: 'number', description: 'Adjustment amount' },
|
|
122
|
+
},
|
|
123
|
+
required: ['bank_statement_entry_id', 'adjustment_type', 'amount'],
|
|
124
|
+
},
|
|
125
|
+
})
|
|
126
|
+
async createAdjustment(args: Record<string, any>, context: McpContext): Promise<any> {
|
|
127
|
+
return this.financeService.createBankStatementAdjustment(args as any, context.userId);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
@McpTool({
|
|
131
|
+
name: 'finance.statements.create',
|
|
132
|
+
description: 'Creates a bank statement entry.',
|
|
133
|
+
inputSchema: {
|
|
134
|
+
type: 'object',
|
|
135
|
+
properties: {
|
|
136
|
+
bank_account_id: { type: 'number', description: 'Bank account ID' },
|
|
137
|
+
date: { type: 'string', description: 'Entry date (YYYY-MM-DD)' },
|
|
138
|
+
amount: { type: 'number', description: 'Entry amount' },
|
|
139
|
+
kind: { type: 'string', description: 'Entry kind' },
|
|
140
|
+
},
|
|
141
|
+
required: ['bank_account_id', 'date', 'amount', 'kind'],
|
|
142
|
+
},
|
|
143
|
+
})
|
|
144
|
+
async create(args: Record<string, any>, context: McpContext): Promise<any> {
|
|
145
|
+
return this.financeService.createBankStatementEntry(args as any, context.userId);
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
@McpTool({
|
|
149
|
+
name: 'finance.statements.update',
|
|
150
|
+
description: 'Updates a bank statement entry.',
|
|
151
|
+
inputSchema: {
|
|
152
|
+
type: 'object',
|
|
153
|
+
properties: {
|
|
154
|
+
id: { type: 'number', description: 'Statement entry ID' },
|
|
155
|
+
},
|
|
156
|
+
required: ['id'],
|
|
157
|
+
},
|
|
158
|
+
})
|
|
159
|
+
async update(args: { id: number; [key: string]: any }, context: McpContext): Promise<any> {
|
|
160
|
+
const { id, ...data } = args;
|
|
161
|
+
return this.financeService.updateBankStatementEntry(id, data as any, context.userId);
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
@McpTool({
|
|
165
|
+
name: 'finance.statements.delete',
|
|
166
|
+
description: 'Deletes a bank statement entry.',
|
|
167
|
+
inputSchema: {
|
|
168
|
+
type: 'object',
|
|
169
|
+
properties: {
|
|
170
|
+
id: { type: 'number', description: 'Statement entry ID' },
|
|
171
|
+
},
|
|
172
|
+
required: ['id'],
|
|
173
|
+
},
|
|
174
|
+
})
|
|
175
|
+
async delete(args: { id: number }, context: McpContext): Promise<any> {
|
|
176
|
+
return this.financeService.deleteBankStatementEntry(args.id, context.userId);
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
private toMulterFile(fileBase64: string, fileName: string, mimeType: string): MulterFile {
|
|
180
|
+
if (!fileBase64 || !fileName || !mimeType) {
|
|
181
|
+
throw new BadRequestException('bank_account_id, fileBase64, fileName and mimeType are required');
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
const buffer = Buffer.from(fileBase64, 'base64');
|
|
185
|
+
|
|
186
|
+
if (!buffer.length) {
|
|
187
|
+
throw new BadRequestException('Invalid fileBase64 payload');
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
return {
|
|
191
|
+
fieldname: 'file',
|
|
192
|
+
originalname: fileName,
|
|
193
|
+
encoding: '7bit',
|
|
194
|
+
mimetype: mimeType,
|
|
195
|
+
size: buffer.length,
|
|
196
|
+
destination: '',
|
|
197
|
+
filename: fileName,
|
|
198
|
+
path: '',
|
|
199
|
+
buffer,
|
|
200
|
+
};
|
|
201
|
+
}
|
|
202
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { McpContext, McpTool } from '@hed-hog/core';
|
|
2
|
+
import { Injectable } from '@nestjs/common';
|
|
3
|
+
import { FinanceService } from '../finance.service';
|
|
4
|
+
|
|
5
|
+
@Injectable()
|
|
6
|
+
export class FinanceTransfersMcpTools {
|
|
7
|
+
constructor(private readonly financeService: FinanceService) {}
|
|
8
|
+
|
|
9
|
+
@McpTool({
|
|
10
|
+
name: 'finance.transfers.list',
|
|
11
|
+
description: 'Lists transfers with filters and pagination.',
|
|
12
|
+
inputSchema: {
|
|
13
|
+
type: 'object',
|
|
14
|
+
properties: {
|
|
15
|
+
page: { type: 'number', description: 'Page number (default: 1)' },
|
|
16
|
+
pageSize: { type: 'number', description: 'Items per page (default: 20)' },
|
|
17
|
+
search: { type: 'string', description: 'Search term' },
|
|
18
|
+
bank_account_id: { type: 'string', description: 'Bank account ID filter' },
|
|
19
|
+
from: { type: 'string', description: 'Start date (YYYY-MM-DD)' },
|
|
20
|
+
to: { type: 'string', description: 'End date (YYYY-MM-DD)' },
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
readOnly: true,
|
|
24
|
+
})
|
|
25
|
+
async list(args: Record<string, any>, _context: McpContext): Promise<any> {
|
|
26
|
+
const { page, pageSize, search, bank_account_id, from, to } = args;
|
|
27
|
+
return this.financeService.listTransfers({ page, pageSize } as any, {
|
|
28
|
+
search,
|
|
29
|
+
bank_account_id,
|
|
30
|
+
from,
|
|
31
|
+
to,
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
@McpTool({
|
|
36
|
+
name: 'finance.transfers.create',
|
|
37
|
+
description: 'Creates a transfer between bank accounts.',
|
|
38
|
+
inputSchema: {
|
|
39
|
+
type: 'object',
|
|
40
|
+
properties: {
|
|
41
|
+
source_account_id: { type: 'number', description: 'Source account ID' },
|
|
42
|
+
destination_account_id: { type: 'number', description: 'Destination account ID' },
|
|
43
|
+
date: { type: 'string', description: 'Transfer date (YYYY-MM-DD)' },
|
|
44
|
+
amount: { type: 'number', description: 'Amount' },
|
|
45
|
+
description: { type: 'string', description: 'Optional description' },
|
|
46
|
+
},
|
|
47
|
+
required: ['source_account_id', 'destination_account_id', 'date', 'amount'],
|
|
48
|
+
},
|
|
49
|
+
})
|
|
50
|
+
async create(args: Record<string, any>, context: McpContext): Promise<any> {
|
|
51
|
+
return this.financeService.createTransfer(args as any, context.userId);
|
|
52
|
+
}
|
|
53
|
+
}
|