@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,560 @@
|
|
|
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 FinanceInstallmentsMcpTools {
|
|
7
|
+
constructor(private readonly financeService: FinanceService) {}
|
|
8
|
+
|
|
9
|
+
@McpTool({
|
|
10
|
+
name: 'finance.accounts-payable.installments.list',
|
|
11
|
+
description: 'Lists accounts payable installments.',
|
|
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
|
+
status: { type: 'string', description: 'Status filter' },
|
|
18
|
+
from: { type: 'string', description: 'Start date (YYYY-MM-DD)' },
|
|
19
|
+
to: { type: 'string', description: 'End date (YYYY-MM-DD)' },
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
readOnly: true,
|
|
23
|
+
})
|
|
24
|
+
async listAccountsPayableInstallments(args: Record<string, any>, _context: McpContext): Promise<any> {
|
|
25
|
+
const { page, pageSize, status, from, to } = args;
|
|
26
|
+
return this.financeService.listAccountsPayableInstallments(
|
|
27
|
+
{ page, pageSize } as any,
|
|
28
|
+
status,
|
|
29
|
+
{ from, to },
|
|
30
|
+
);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
@McpTool({
|
|
34
|
+
name: 'finance.accounts-payable.installments.get',
|
|
35
|
+
description: 'Returns accounts payable installment details.',
|
|
36
|
+
inputSchema: {
|
|
37
|
+
type: 'object',
|
|
38
|
+
properties: {
|
|
39
|
+
id: { type: 'number', description: 'Installment ID' },
|
|
40
|
+
},
|
|
41
|
+
required: ['id'],
|
|
42
|
+
},
|
|
43
|
+
readOnly: true,
|
|
44
|
+
})
|
|
45
|
+
async getAccountsPayableInstallment(args: { id: number }, context: McpContext): Promise<any> {
|
|
46
|
+
return this.financeService.getAccountsPayableInstallment(args.id, context.locale);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
@McpTool({
|
|
50
|
+
name: 'finance.titles.settlements-history.get',
|
|
51
|
+
description: 'Returns settlement history for a financial title.',
|
|
52
|
+
inputSchema: {
|
|
53
|
+
type: 'object',
|
|
54
|
+
properties: {
|
|
55
|
+
id: { type: 'number', description: 'Title ID' },
|
|
56
|
+
},
|
|
57
|
+
required: ['id'],
|
|
58
|
+
},
|
|
59
|
+
readOnly: true,
|
|
60
|
+
})
|
|
61
|
+
async getTitleSettlementsHistory(args: { id: number }, context: McpContext): Promise<any> {
|
|
62
|
+
return this.financeService.getTitleSettlementsHistory(args.id, context.locale);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
@McpTool({
|
|
66
|
+
name: 'finance.accounts-payable.installments.create',
|
|
67
|
+
description: 'Creates an accounts payable title/installment. For recurring titles, use recurrence_rule instead of installments array.',
|
|
68
|
+
inputSchema: {
|
|
69
|
+
type: 'object',
|
|
70
|
+
properties: {
|
|
71
|
+
person_id: { type: 'number', description: 'Supplier/person ID' },
|
|
72
|
+
document_number: { type: 'string', description: 'Document/invoice number' },
|
|
73
|
+
total_amount: { type: 'number', description: 'Total amount (or amount per period for recurring titles)' },
|
|
74
|
+
due_date: { type: 'string', description: 'Due date / first occurrence date (YYYY-MM-DD)' },
|
|
75
|
+
finance_category_id: { type: 'number', description: 'Category ID' },
|
|
76
|
+
cost_center_id: { type: 'number', description: 'Cost center ID' },
|
|
77
|
+
payment_channel: { type: 'string', description: 'Payment channel' },
|
|
78
|
+
description: { type: 'string', description: 'Description' },
|
|
79
|
+
competence_date: { type: 'string', description: 'Competence date (YYYY-MM-DD)' },
|
|
80
|
+
installments: {
|
|
81
|
+
type: 'array',
|
|
82
|
+
description: 'Installments array (for non-recurring split titles)',
|
|
83
|
+
items: {
|
|
84
|
+
type: 'object',
|
|
85
|
+
properties: {
|
|
86
|
+
due_date: { type: 'string' },
|
|
87
|
+
amount: { type: 'number' },
|
|
88
|
+
},
|
|
89
|
+
},
|
|
90
|
+
},
|
|
91
|
+
recurrence_rule: {
|
|
92
|
+
type: 'object',
|
|
93
|
+
description: 'Recurrence rule. When provided, creates a recurring title (same amount each period) instead of a split installment title.',
|
|
94
|
+
properties: {
|
|
95
|
+
frequency: {
|
|
96
|
+
type: 'string',
|
|
97
|
+
enum: ['weekly', 'biweekly', 'monthly', 'bimonthly', 'quarterly', 'semiannual', 'annual'],
|
|
98
|
+
description: 'Repetition frequency (default: monthly)',
|
|
99
|
+
},
|
|
100
|
+
end_date: { type: 'string', description: 'End date (YYYY-MM-DD) — stop generating after this date' },
|
|
101
|
+
max_occurrences: { type: 'number', description: 'Maximum number of repetitions' },
|
|
102
|
+
},
|
|
103
|
+
required: ['frequency'],
|
|
104
|
+
},
|
|
105
|
+
},
|
|
106
|
+
required: ['person_id', 'document_number', 'total_amount', 'due_date'],
|
|
107
|
+
},
|
|
108
|
+
})
|
|
109
|
+
async createAccountsPayableTitle(args: Record<string, any>, context: McpContext): Promise<any> {
|
|
110
|
+
return this.financeService.createAccountsPayableTitle(args as any, context.locale, context.userId);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
@McpTool({
|
|
114
|
+
name: 'finance.accounts-payable.installments.update',
|
|
115
|
+
description: 'Updates an accounts payable title/installment.',
|
|
116
|
+
inputSchema: {
|
|
117
|
+
type: 'object',
|
|
118
|
+
properties: {
|
|
119
|
+
id: { type: 'number', description: 'Installment ID' },
|
|
120
|
+
},
|
|
121
|
+
required: ['id'],
|
|
122
|
+
},
|
|
123
|
+
})
|
|
124
|
+
async updateAccountsPayableTitle(args: { id: number; [key: string]: any }, context: McpContext): Promise<any> {
|
|
125
|
+
const { id, ...data } = args;
|
|
126
|
+
return this.financeService.updateAccountsPayableTitle(id, data as any, context.locale, context.userId);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
@McpTool({
|
|
130
|
+
name: 'finance.accounts-payable.installments.approve',
|
|
131
|
+
description: 'Approves an accounts payable title/installment.',
|
|
132
|
+
inputSchema: {
|
|
133
|
+
type: 'object',
|
|
134
|
+
properties: {
|
|
135
|
+
id: { type: 'number', description: 'Installment ID' },
|
|
136
|
+
},
|
|
137
|
+
required: ['id'],
|
|
138
|
+
},
|
|
139
|
+
})
|
|
140
|
+
async approveAccountsPayableTitle(args: { id: number }, context: McpContext): Promise<any> {
|
|
141
|
+
return this.financeService.approveAccountsPayableTitle(args.id, context.locale, context.userId);
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
@McpTool({
|
|
145
|
+
name: 'finance.accounts-payable.installments.reject',
|
|
146
|
+
description: 'Rejects an accounts payable title/installment.',
|
|
147
|
+
inputSchema: {
|
|
148
|
+
type: 'object',
|
|
149
|
+
properties: {
|
|
150
|
+
id: { type: 'number', description: 'Installment ID' },
|
|
151
|
+
reason: { type: 'string', description: 'Rejection reason' },
|
|
152
|
+
},
|
|
153
|
+
required: ['id'],
|
|
154
|
+
},
|
|
155
|
+
})
|
|
156
|
+
async rejectAccountsPayableTitle(args: { id: number; [key: string]: any }, context: McpContext): Promise<any> {
|
|
157
|
+
const { id, ...data } = args;
|
|
158
|
+
return this.financeService.rejectAccountsPayableTitle(id, data as any, context.locale, context.userId);
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
@McpTool({
|
|
162
|
+
name: 'finance.accounts-payable.installments.cancel',
|
|
163
|
+
description: 'Cancels an accounts payable title/installment.',
|
|
164
|
+
inputSchema: {
|
|
165
|
+
type: 'object',
|
|
166
|
+
properties: {
|
|
167
|
+
id: { type: 'number', description: 'Installment ID' },
|
|
168
|
+
reason: { type: 'string', description: 'Cancellation reason' },
|
|
169
|
+
},
|
|
170
|
+
required: ['id'],
|
|
171
|
+
},
|
|
172
|
+
})
|
|
173
|
+
async cancelAccountsPayableTitle(args: { id: number; [key: string]: any }, context: McpContext): Promise<any> {
|
|
174
|
+
const { id, ...data } = args;
|
|
175
|
+
return this.financeService.cancelAccountsPayableTitle(id, data as any, context.locale, context.userId);
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
@McpTool({
|
|
179
|
+
name: 'finance.accounts-payable.installments.settle',
|
|
180
|
+
description: 'Settles an accounts payable installment.',
|
|
181
|
+
inputSchema: {
|
|
182
|
+
type: 'object',
|
|
183
|
+
properties: {
|
|
184
|
+
id: { type: 'number', description: 'Installment ID' },
|
|
185
|
+
},
|
|
186
|
+
required: ['id'],
|
|
187
|
+
},
|
|
188
|
+
})
|
|
189
|
+
async settleAccountsPayableInstallment(args: { id: number; [key: string]: any }, context: McpContext): Promise<any> {
|
|
190
|
+
const { id, ...data } = args;
|
|
191
|
+
return this.financeService.settleAccountsPayableInstallment(id, data as any, context.locale, context.userId);
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
@McpTool({
|
|
195
|
+
name: 'finance.accounts-payable.installments.settlements.reverse',
|
|
196
|
+
description: 'Reverses a settlement for accounts payable installment.',
|
|
197
|
+
inputSchema: {
|
|
198
|
+
type: 'object',
|
|
199
|
+
properties: {
|
|
200
|
+
id: { type: 'number', description: 'Installment ID' },
|
|
201
|
+
settlementId: { type: 'number', description: 'Settlement ID' },
|
|
202
|
+
},
|
|
203
|
+
required: ['id', 'settlementId'],
|
|
204
|
+
},
|
|
205
|
+
})
|
|
206
|
+
async reverseAccountsPayableSettlement(
|
|
207
|
+
args: { id: number; settlementId: number; [key: string]: any },
|
|
208
|
+
context: McpContext,
|
|
209
|
+
): Promise<any> {
|
|
210
|
+
const { id, settlementId, ...data } = args;
|
|
211
|
+
return this.financeService.reverseAccountsPayableSettlement(id, settlementId, data as any, context.locale, context.userId);
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
@McpTool({
|
|
215
|
+
name: 'finance.settlements.reverse',
|
|
216
|
+
description: 'Reverses settlement by settlement ID.',
|
|
217
|
+
inputSchema: {
|
|
218
|
+
type: 'object',
|
|
219
|
+
properties: {
|
|
220
|
+
id: { type: 'number', description: 'Settlement ID' },
|
|
221
|
+
},
|
|
222
|
+
required: ['id'],
|
|
223
|
+
},
|
|
224
|
+
})
|
|
225
|
+
async reverseSettlement(args: { id: number; [key: string]: any }, context: McpContext): Promise<any> {
|
|
226
|
+
const { id, ...data } = args;
|
|
227
|
+
return this.financeService.reverseSettlementById(id, data as any, context.locale, context.userId);
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
@McpTool({
|
|
231
|
+
name: 'finance.bank-reconciliations.delete',
|
|
232
|
+
description: 'Unreconciles a bank reconciliation by ID.',
|
|
233
|
+
inputSchema: {
|
|
234
|
+
type: 'object',
|
|
235
|
+
properties: {
|
|
236
|
+
id: { type: 'number', description: 'Bank reconciliation ID' },
|
|
237
|
+
},
|
|
238
|
+
required: ['id'],
|
|
239
|
+
},
|
|
240
|
+
})
|
|
241
|
+
async unreconcileBankReconciliation(args: { id: number }, context: McpContext): Promise<any> {
|
|
242
|
+
return this.financeService.unreconcileBankReconciliation(args.id, context.userId);
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
@McpTool({
|
|
246
|
+
name: 'finance.accounts-payable.installments.tags.update',
|
|
247
|
+
description: 'Updates tags for an accounts payable installment.',
|
|
248
|
+
inputSchema: {
|
|
249
|
+
type: 'object',
|
|
250
|
+
properties: {
|
|
251
|
+
id: { type: 'number', description: 'Installment ID' },
|
|
252
|
+
tag_ids: {
|
|
253
|
+
type: 'array',
|
|
254
|
+
items: { type: 'number' },
|
|
255
|
+
description: 'Tag IDs',
|
|
256
|
+
},
|
|
257
|
+
},
|
|
258
|
+
required: ['id'],
|
|
259
|
+
},
|
|
260
|
+
})
|
|
261
|
+
async updateAccountsPayableInstallmentTags(
|
|
262
|
+
args: { id: number; tag_ids?: number[] },
|
|
263
|
+
context: McpContext,
|
|
264
|
+
): Promise<any> {
|
|
265
|
+
return this.financeService.updateAccountsPayableInstallmentTags(
|
|
266
|
+
args.id,
|
|
267
|
+
args.tag_ids || [],
|
|
268
|
+
context.locale,
|
|
269
|
+
);
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
@McpTool({
|
|
273
|
+
name: 'finance.accounts-payable.installments.extract-from-file',
|
|
274
|
+
description: 'Extracts payable title data from a base64 file payload using AI.',
|
|
275
|
+
inputSchema: {
|
|
276
|
+
type: 'object',
|
|
277
|
+
properties: {
|
|
278
|
+
fileBase64: { type: 'string', description: 'Base64-encoded file content' },
|
|
279
|
+
fileName: { type: 'string', description: 'Original file name' },
|
|
280
|
+
mimeType: { type: 'string', description: 'File MIME type' },
|
|
281
|
+
file_id: { type: 'number', description: 'Existing file ID (optional)' },
|
|
282
|
+
},
|
|
283
|
+
},
|
|
284
|
+
})
|
|
285
|
+
async extractAccountsPayableInfoFromFile(
|
|
286
|
+
args: { fileBase64?: string; fileName?: string; mimeType?: string; file_id?: number },
|
|
287
|
+
_context: McpContext,
|
|
288
|
+
): Promise<any> {
|
|
289
|
+
const file = this.tryToMulterFile(args.fileBase64, args.fileName, args.mimeType);
|
|
290
|
+
return this.financeService.getAgentExtractInfoFromFile(file, args.file_id);
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
@McpTool({
|
|
294
|
+
name: 'finance.accounts-receivable.installments.list',
|
|
295
|
+
description: 'Lists accounts receivable installments.',
|
|
296
|
+
inputSchema: {
|
|
297
|
+
type: 'object',
|
|
298
|
+
properties: {
|
|
299
|
+
page: { type: 'number', description: 'Page number (default: 1)' },
|
|
300
|
+
pageSize: { type: 'number', description: 'Items per page (default: 20)' },
|
|
301
|
+
status: { type: 'string', description: 'Status filter' },
|
|
302
|
+
from: { type: 'string', description: 'Start date (YYYY-MM-DD)' },
|
|
303
|
+
to: { type: 'string', description: 'End date (YYYY-MM-DD)' },
|
|
304
|
+
},
|
|
305
|
+
},
|
|
306
|
+
readOnly: true,
|
|
307
|
+
})
|
|
308
|
+
async listAccountsReceivableInstallments(args: Record<string, any>, _context: McpContext): Promise<any> {
|
|
309
|
+
const { page, pageSize, status, from, to } = args;
|
|
310
|
+
return this.financeService.listAccountsReceivableInstallments(
|
|
311
|
+
{ page, pageSize } as any,
|
|
312
|
+
status,
|
|
313
|
+
{ from, to },
|
|
314
|
+
);
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
@McpTool({
|
|
318
|
+
name: 'finance.accounts-receivable.installments.get',
|
|
319
|
+
description: 'Returns accounts receivable installment details.',
|
|
320
|
+
inputSchema: {
|
|
321
|
+
type: 'object',
|
|
322
|
+
properties: {
|
|
323
|
+
id: { type: 'number', description: 'Installment ID' },
|
|
324
|
+
},
|
|
325
|
+
required: ['id'],
|
|
326
|
+
},
|
|
327
|
+
readOnly: true,
|
|
328
|
+
})
|
|
329
|
+
async getAccountsReceivableInstallment(args: { id: number }, context: McpContext): Promise<any> {
|
|
330
|
+
return this.financeService.getAccountsReceivableInstallment(args.id, context.locale);
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
@McpTool({
|
|
334
|
+
name: 'finance.accounts-receivable.installments.create',
|
|
335
|
+
description: 'Creates an accounts receivable title/installment. For recurring titles, use recurrence_rule instead of installments array.',
|
|
336
|
+
inputSchema: {
|
|
337
|
+
type: 'object',
|
|
338
|
+
properties: {
|
|
339
|
+
person_id: { type: 'number', description: 'Client/person ID' },
|
|
340
|
+
document_number: { type: 'string', description: 'Document/invoice number' },
|
|
341
|
+
total_amount: { type: 'number', description: 'Total amount (or amount per period for recurring titles)' },
|
|
342
|
+
due_date: { type: 'string', description: 'Due date / first occurrence date (YYYY-MM-DD)' },
|
|
343
|
+
finance_category_id: { type: 'number', description: 'Category ID' },
|
|
344
|
+
cost_center_id: { type: 'number', description: 'Cost center ID' },
|
|
345
|
+
payment_channel: { type: 'string', description: 'Payment channel' },
|
|
346
|
+
description: { type: 'string', description: 'Description' },
|
|
347
|
+
competence_date: { type: 'string', description: 'Competence date (YYYY-MM-DD)' },
|
|
348
|
+
installments: {
|
|
349
|
+
type: 'array',
|
|
350
|
+
description: 'Installments array (for non-recurring split titles)',
|
|
351
|
+
items: {
|
|
352
|
+
type: 'object',
|
|
353
|
+
properties: {
|
|
354
|
+
due_date: { type: 'string' },
|
|
355
|
+
amount: { type: 'number' },
|
|
356
|
+
},
|
|
357
|
+
},
|
|
358
|
+
},
|
|
359
|
+
recurrence_rule: {
|
|
360
|
+
type: 'object',
|
|
361
|
+
description: 'Recurrence rule. When provided, creates a recurring title (same amount each period) instead of a split installment title.',
|
|
362
|
+
properties: {
|
|
363
|
+
frequency: {
|
|
364
|
+
type: 'string',
|
|
365
|
+
enum: ['weekly', 'biweekly', 'monthly', 'bimonthly', 'quarterly', 'semiannual', 'annual'],
|
|
366
|
+
description: 'Repetition frequency (default: monthly)',
|
|
367
|
+
},
|
|
368
|
+
end_date: { type: 'string', description: 'End date (YYYY-MM-DD) — stop generating after this date' },
|
|
369
|
+
max_occurrences: { type: 'number', description: 'Maximum number of repetitions' },
|
|
370
|
+
},
|
|
371
|
+
required: ['frequency'],
|
|
372
|
+
},
|
|
373
|
+
},
|
|
374
|
+
required: ['person_id', 'document_number', 'total_amount', 'due_date'],
|
|
375
|
+
},
|
|
376
|
+
})
|
|
377
|
+
async createAccountsReceivableTitle(args: Record<string, any>, context: McpContext): Promise<any> {
|
|
378
|
+
return this.financeService.createAccountsReceivableTitle(args as any, context.locale, context.userId);
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
@McpTool({
|
|
382
|
+
name: 'finance.accounts-receivable.installments.update',
|
|
383
|
+
description: 'Updates an accounts receivable title/installment.',
|
|
384
|
+
inputSchema: {
|
|
385
|
+
type: 'object',
|
|
386
|
+
properties: {
|
|
387
|
+
id: { type: 'number', description: 'Installment ID' },
|
|
388
|
+
},
|
|
389
|
+
required: ['id'],
|
|
390
|
+
},
|
|
391
|
+
})
|
|
392
|
+
async updateAccountsReceivableTitle(args: { id: number; [key: string]: any }, context: McpContext): Promise<any> {
|
|
393
|
+
const { id, ...data } = args;
|
|
394
|
+
return this.financeService.updateAccountsReceivableTitle(id, data as any, context.locale, context.userId);
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
@McpTool({
|
|
398
|
+
name: 'finance.accounts-receivable.installments.approve',
|
|
399
|
+
description: 'Approves an accounts receivable title/installment.',
|
|
400
|
+
inputSchema: {
|
|
401
|
+
type: 'object',
|
|
402
|
+
properties: {
|
|
403
|
+
id: { type: 'number', description: 'Installment ID' },
|
|
404
|
+
},
|
|
405
|
+
required: ['id'],
|
|
406
|
+
},
|
|
407
|
+
})
|
|
408
|
+
async approveAccountsReceivableTitle(args: { id: number }, context: McpContext): Promise<any> {
|
|
409
|
+
return this.financeService.approveAccountsReceivableTitle(args.id, context.locale, context.userId);
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
@McpTool({
|
|
413
|
+
name: 'finance.accounts-receivable.installments.cancel',
|
|
414
|
+
description: 'Cancels an accounts receivable title/installment.',
|
|
415
|
+
inputSchema: {
|
|
416
|
+
type: 'object',
|
|
417
|
+
properties: {
|
|
418
|
+
id: { type: 'number', description: 'Installment ID' },
|
|
419
|
+
reason: { type: 'string', description: 'Cancellation reason' },
|
|
420
|
+
},
|
|
421
|
+
required: ['id'],
|
|
422
|
+
},
|
|
423
|
+
})
|
|
424
|
+
async cancelAccountsReceivableTitle(args: { id: number; [key: string]: any }, context: McpContext): Promise<any> {
|
|
425
|
+
const { id, ...data } = args;
|
|
426
|
+
return this.financeService.cancelAccountsReceivableTitle(id, data as any, context.locale, context.userId);
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
@McpTool({
|
|
430
|
+
name: 'finance.accounts-receivable.installments.settle',
|
|
431
|
+
description: 'Settles an accounts receivable installment.',
|
|
432
|
+
inputSchema: {
|
|
433
|
+
type: 'object',
|
|
434
|
+
properties: {
|
|
435
|
+
id: { type: 'number', description: 'Installment ID' },
|
|
436
|
+
},
|
|
437
|
+
required: ['id'],
|
|
438
|
+
},
|
|
439
|
+
})
|
|
440
|
+
async settleAccountsReceivableInstallment(args: { id: number; [key: string]: any }, context: McpContext): Promise<any> {
|
|
441
|
+
const { id, ...data } = args;
|
|
442
|
+
return this.financeService.settleAccountsReceivableInstallment(id, data as any, context.locale, context.userId);
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
@McpTool({
|
|
446
|
+
name: 'finance.accounts-receivable.installments.settlements.reverse',
|
|
447
|
+
description: 'Reverses a settlement for accounts receivable installment.',
|
|
448
|
+
inputSchema: {
|
|
449
|
+
type: 'object',
|
|
450
|
+
properties: {
|
|
451
|
+
id: { type: 'number', description: 'Installment ID' },
|
|
452
|
+
settlementId: { type: 'number', description: 'Settlement ID' },
|
|
453
|
+
},
|
|
454
|
+
required: ['id', 'settlementId'],
|
|
455
|
+
},
|
|
456
|
+
})
|
|
457
|
+
async reverseAccountsReceivableSettlement(
|
|
458
|
+
args: { id: number; settlementId: number; [key: string]: any },
|
|
459
|
+
context: McpContext,
|
|
460
|
+
): Promise<any> {
|
|
461
|
+
const { id, settlementId, ...data } = args;
|
|
462
|
+
return this.financeService.reverseAccountsReceivableSettlement(id, settlementId, data as any, context.locale, context.userId);
|
|
463
|
+
}
|
|
464
|
+
|
|
465
|
+
@McpTool({
|
|
466
|
+
name: 'finance.accounts-receivable.installments.tags.update',
|
|
467
|
+
description: 'Updates tags for an accounts receivable installment.',
|
|
468
|
+
inputSchema: {
|
|
469
|
+
type: 'object',
|
|
470
|
+
properties: {
|
|
471
|
+
id: { type: 'number', description: 'Installment ID' },
|
|
472
|
+
tag_ids: {
|
|
473
|
+
type: 'array',
|
|
474
|
+
items: { type: 'number' },
|
|
475
|
+
description: 'Tag IDs',
|
|
476
|
+
},
|
|
477
|
+
},
|
|
478
|
+
required: ['id'],
|
|
479
|
+
},
|
|
480
|
+
})
|
|
481
|
+
async updateAccountsReceivableInstallmentTags(
|
|
482
|
+
args: { id: number; tag_ids?: number[] },
|
|
483
|
+
context: McpContext,
|
|
484
|
+
): Promise<any> {
|
|
485
|
+
return this.financeService.updateAccountsReceivableInstallmentTags(
|
|
486
|
+
args.id,
|
|
487
|
+
args.tag_ids || [],
|
|
488
|
+
context.locale,
|
|
489
|
+
);
|
|
490
|
+
}
|
|
491
|
+
|
|
492
|
+
@McpTool({
|
|
493
|
+
name: 'finance.tags.create',
|
|
494
|
+
description: 'Creates a finance tag.',
|
|
495
|
+
inputSchema: {
|
|
496
|
+
type: 'object',
|
|
497
|
+
properties: {
|
|
498
|
+
name: { type: 'string', description: 'Tag name' },
|
|
499
|
+
color: { type: 'string', description: 'Tag color' },
|
|
500
|
+
},
|
|
501
|
+
required: ['name'],
|
|
502
|
+
},
|
|
503
|
+
})
|
|
504
|
+
async createTag(args: Record<string, any>, _context: McpContext): Promise<any> {
|
|
505
|
+
return this.financeService.createTag(args as any);
|
|
506
|
+
}
|
|
507
|
+
|
|
508
|
+
@McpTool({
|
|
509
|
+
name: 'finance.accounts-receivable.installments.extract-from-file',
|
|
510
|
+
description: 'Extracts receivable title data from a base64 file payload using AI.',
|
|
511
|
+
inputSchema: {
|
|
512
|
+
type: 'object',
|
|
513
|
+
properties: {
|
|
514
|
+
fileBase64: { type: 'string', description: 'Base64-encoded file content' },
|
|
515
|
+
fileName: { type: 'string', description: 'Original file name' },
|
|
516
|
+
mimeType: { type: 'string', description: 'File MIME type' },
|
|
517
|
+
file_id: { type: 'number', description: 'Existing file ID (optional)' },
|
|
518
|
+
},
|
|
519
|
+
},
|
|
520
|
+
})
|
|
521
|
+
async extractAccountsReceivableInfoFromFile(
|
|
522
|
+
args: { fileBase64?: string; fileName?: string; mimeType?: string; file_id?: number },
|
|
523
|
+
_context: McpContext,
|
|
524
|
+
): Promise<any> {
|
|
525
|
+
const file = this.tryToMulterFile(args.fileBase64, args.fileName, args.mimeType);
|
|
526
|
+
return this.financeService.getAgentExtractInfoFromFile(file, args.file_id, 'receivable');
|
|
527
|
+
}
|
|
528
|
+
|
|
529
|
+
private tryToMulterFile(
|
|
530
|
+
fileBase64?: string,
|
|
531
|
+
fileName?: string,
|
|
532
|
+
mimeType?: string,
|
|
533
|
+
): MulterFile | undefined {
|
|
534
|
+
if (!fileBase64 && !fileName && !mimeType) {
|
|
535
|
+
return undefined;
|
|
536
|
+
}
|
|
537
|
+
|
|
538
|
+
if (!fileBase64 || !fileName || !mimeType) {
|
|
539
|
+
throw new BadRequestException('fileBase64, fileName and mimeType must be provided together');
|
|
540
|
+
}
|
|
541
|
+
|
|
542
|
+
const buffer = Buffer.from(fileBase64, 'base64');
|
|
543
|
+
|
|
544
|
+
if (!buffer.length) {
|
|
545
|
+
throw new BadRequestException('Invalid fileBase64 payload');
|
|
546
|
+
}
|
|
547
|
+
|
|
548
|
+
return {
|
|
549
|
+
fieldname: 'file',
|
|
550
|
+
originalname: fileName,
|
|
551
|
+
encoding: '7bit',
|
|
552
|
+
mimetype: mimeType,
|
|
553
|
+
size: buffer.length,
|
|
554
|
+
destination: '',
|
|
555
|
+
filename: fileName,
|
|
556
|
+
path: '',
|
|
557
|
+
buffer,
|
|
558
|
+
};
|
|
559
|
+
}
|
|
560
|
+
}
|
|
@@ -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 FinancePeriodCloseMcpTools {
|
|
7
|
+
constructor(private readonly financeService: FinanceService) {}
|
|
8
|
+
|
|
9
|
+
@McpTool({
|
|
10
|
+
name: 'finance.period-close.list',
|
|
11
|
+
description: 'Lists period close records 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
|
+
status: { type: 'string', description: 'Status filter' },
|
|
19
|
+
user: { type: 'string', description: 'User filter' },
|
|
20
|
+
from: { type: 'string', description: 'Start date (YYYY-MM-DD)' },
|
|
21
|
+
to: { type: 'string', description: 'End date (YYYY-MM-DD)' },
|
|
22
|
+
},
|
|
23
|
+
},
|
|
24
|
+
readOnly: true,
|
|
25
|
+
})
|
|
26
|
+
async list(args: Record<string, any>, _context: McpContext): Promise<any> {
|
|
27
|
+
const { page, pageSize, search, status, user, from, to } = args;
|
|
28
|
+
return this.financeService.listPeriodClose({ page, pageSize } as any, {
|
|
29
|
+
search,
|
|
30
|
+
status,
|
|
31
|
+
user,
|
|
32
|
+
from,
|
|
33
|
+
to,
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
@McpTool({
|
|
38
|
+
name: 'finance.period-close.create',
|
|
39
|
+
description: 'Creates a period close record.',
|
|
40
|
+
inputSchema: {
|
|
41
|
+
type: 'object',
|
|
42
|
+
properties: {
|
|
43
|
+
period_start: { type: 'string', description: 'Period start date (YYYY-MM-DD)' },
|
|
44
|
+
period_end: { type: 'string', description: 'Period end date (YYYY-MM-DD)' },
|
|
45
|
+
notes: { type: 'string', description: 'Optional notes' },
|
|
46
|
+
},
|
|
47
|
+
required: ['period_start', 'period_end'],
|
|
48
|
+
},
|
|
49
|
+
})
|
|
50
|
+
async create(args: Record<string, any>, context: McpContext): Promise<any> {
|
|
51
|
+
return this.financeService.createPeriodClose(args as any, context.userId);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
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 FinanceReportsMcpTools {
|
|
7
|
+
constructor(private readonly financeService: FinanceService) {}
|
|
8
|
+
|
|
9
|
+
@McpTool({
|
|
10
|
+
name: 'finance.reports.overview-results',
|
|
11
|
+
description: 'Returns the finance overview results report.',
|
|
12
|
+
inputSchema: {
|
|
13
|
+
type: 'object',
|
|
14
|
+
properties: {
|
|
15
|
+
period_start: { type: 'string', description: 'Start date (YYYY-MM-DD)' },
|
|
16
|
+
period_end: { type: 'string', description: 'End date (YYYY-MM-DD)' },
|
|
17
|
+
groupBy: { type: 'string', description: 'Grouping (day|week|month|year)' },
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
readOnly: true,
|
|
21
|
+
})
|
|
22
|
+
async overviewResults(args: Record<string, any>, _context: McpContext): Promise<any> {
|
|
23
|
+
return this.financeService.getOverviewResultsReport(args as any);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
@McpTool({
|
|
27
|
+
name: 'finance.reports.top-customers',
|
|
28
|
+
description: 'Returns top customers report.',
|
|
29
|
+
inputSchema: {
|
|
30
|
+
type: 'object',
|
|
31
|
+
properties: {
|
|
32
|
+
period_start: { type: 'string', description: 'Start date (YYYY-MM-DD)' },
|
|
33
|
+
period_end: { type: 'string', description: 'End date (YYYY-MM-DD)' },
|
|
34
|
+
limit: { type: 'number', description: 'Top ranking limit' },
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
readOnly: true,
|
|
38
|
+
})
|
|
39
|
+
async topCustomers(args: Record<string, any>, _context: McpContext): Promise<any> {
|
|
40
|
+
return this.financeService.getTopCustomersReport(args as any);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
@McpTool({
|
|
44
|
+
name: 'finance.reports.top-operational-expenses',
|
|
45
|
+
description: 'Returns top operational expenses report.',
|
|
46
|
+
inputSchema: {
|
|
47
|
+
type: 'object',
|
|
48
|
+
properties: {
|
|
49
|
+
period_start: { type: 'string', description: 'Start date (YYYY-MM-DD)' },
|
|
50
|
+
period_end: { type: 'string', description: 'End date (YYYY-MM-DD)' },
|
|
51
|
+
limit: { type: 'number', description: 'Top ranking limit' },
|
|
52
|
+
},
|
|
53
|
+
},
|
|
54
|
+
readOnly: true,
|
|
55
|
+
})
|
|
56
|
+
async topOperationalExpenses(args: Record<string, any>, _context: McpContext): Promise<any> {
|
|
57
|
+
return this.financeService.getTopOperationalExpensesReport(args as any);
|
|
58
|
+
}
|
|
59
|
+
}
|