get_monthly_summary
Retrieve monthly financial overview showing income, expenses, and savings for specified year and month.
Instructions
Get monthly financial summary including income, expenses, and savings
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| year | Yes | Year (e.g., 2024) | |
| month | Yes | Month (1-12) |
Implementation Reference
- src/tools.ts:496-552 (handler)The actual implementation of getMonthlySummary that fetches transactions for a given month/year and calculates total income, expenses, and net savingsprivate async getMonthlySummary(year: number, month: number): Promise<any> { try { const startDate = `${year}-${month.toString().padStart(2, '0')}-01`; const endDate = new Date(year, month, 0).toISOString().split('T')[0]; // Last day of month const transactions = await this.api.getTransactions({ startDate, endDate, limit: 5000, }); let totalIncome = 0; let totalExpenses = 0; const incomeTransactions: Transaction[] = []; const expenseTransactions: Transaction[] = []; transactions?.forEach((transaction: Transaction) => { if (transaction.amount > 0) { totalIncome += transaction.amount; incomeTransactions.push(transaction); } else { totalExpenses += Math.abs(transaction.amount); expenseTransactions.push(transaction); } }); const netSavings = totalIncome - totalExpenses; return { success: true, data: { month, year, totalIncome, totalExpenses, netSavings, transactionCount: transactions?.length || 0, incomeTransactionCount: incomeTransactions.length, expenseTransactionCount: expenseTransactions.length, }, summary: `${year}-${month .toString() .padStart(2, '0')}: Income $${totalIncome.toFixed( 2 )}, Expenses $${totalExpenses.toFixed(2)}, Net $${netSavings.toFixed( 2 )}`, }; } catch (error) { throw new Error( `Failed to get monthly summary: ${ error instanceof Error ? error.message : 'Unknown error' }` ); } }
- src/tools.ts:132-149 (schema)Tool definition with input schema requiring year and month parametersname: 'get_monthly_summary', description: 'Get monthly financial summary including income, expenses, and savings', inputSchema: { type: 'object', properties: { year: { type: 'number', description: 'Year (e.g., 2024)', }, month: { type: 'number', description: 'Month (1-12)', }, }, required: ['year', 'month'], }, },
- src/tools.ts:227-228 (registration)Tool registration case in executeTool switch statement that routes calls to getMonthlySummary implementationcase 'get_monthly_summary': return await this.getMonthlySummary(args.year, args.month);