UNPKG

@baruchiro/actual-mcp

Version:

Actual Budget MCP server exposing API functionality

42 lines 1.96 kB
// Generates the markdown report for balance-history tool import { formatAmount } from '../../utils.js'; export class BalanceHistoryReportGenerator { generate(account, period, sortedMonths) { let markdown = `# Balance History\n\n`; if (account) { markdown += `Account: ${account.name}\n`; } markdown += `Period: ${period.start} to ${period.end}\n\n`; // Add balance history table if (account) { markdown += `| Month | End of Month Balance | Monthly Change | Transactions |\n`; markdown += `| ----- | -------------------- | -------------- | ------------ |\n`; } else { markdown += `| Account | End of Month Balance | Monthly Change | Transactions |\n`; markdown += `| ------- | -------------------- | -------------- | ------------ |\n`; } let previousMonth = ''; sortedMonths.forEach((month) => { const accountName = month.account; const monthName = new Date(month.year, month.month - 1, 1).toLocaleString('default', { month: 'long' }); const balance = formatAmount(month.balance); let change = ''; const changeFormatted = formatAmount(month.change); const direction = month.change > 0 ? '↑' : month.change < 0 ? '↓' : ''; change = `${direction} ${changeFormatted}`; if (account) { markdown += `| ${monthName} ${month.year} | ${balance} | ${change} | ${month.transactions} |\n`; } else { if (monthName != previousMonth) { previousMonth = monthName; markdown += `| ${monthName} ${month.year} |\n`; } markdown += `${accountName} | ${balance} | ${change} | ${month.transactions} |\n`; } }); return markdown; } } //# sourceMappingURL=report-generator.js.map