/** * Reporting and Analytics Tools */ import { z } from 'zod'; import type { FieldEdgeClient } from '../clients/fieldedge.js'; export const reportingTools = [ { name: 'fieldedge_list_reports', description: 'List all available reports', inputSchema: { type: 'object', properties: { type: { type: 'string', enum: [ 'revenue', 'technician-productivity', 'job-completion', 'customer-satisfaction', 'inventory-valuation', 'aging-receivables', 'sales-by-category', 'equipment-maintenance', 'custom', ], description: 'Filter by report type', }, }, }, handler: async (args: any, client: FieldEdgeClient) => { const reports = await client.getReports(args.type); return { content: [{ type: 'text', text: JSON.stringify(reports, null, 2), }], }; }, }, { name: 'fieldedge_get_report', description: 'Get a specific report by ID', inputSchema: { type: 'object', properties: { reportId: { type: 'string', description: 'Report ID' }, }, required: ['reportId'], }, handler: async (args: any, client: FieldEdgeClient) => { const report = await client.getReport(args.reportId); return { content: [{ type: 'text', text: JSON.stringify(report, null, 2), }], }; }, }, { name: 'fieldedge_generate_report', description: 'Generate a new report', inputSchema: { type: 'object', properties: { type: { type: 'string', enum: [ 'revenue', 'technician-productivity', 'job-completion', 'customer-satisfaction', 'inventory-valuation', 'aging-receivables', 'sales-by-category', 'equipment-maintenance', ], description: 'Report type', }, parameters: { type: 'object', description: 'Report parameters (varies by type)', }, }, required: ['type'], }, handler: async (args: any, client: FieldEdgeClient) => { const report = await client.generateReport(args.type, args.parameters); return { content: [{ type: 'text', text: `Report generated:\n${JSON.stringify(report, null, 2)}`, }], }; }, }, { name: 'fieldedge_get_revenue_report', description: 'Get revenue report for a date range', inputSchema: { type: 'object', properties: { startDate: { type: 'string', description: 'Start date (YYYY-MM-DD)' }, endDate: { type: 'string', description: 'End date (YYYY-MM-DD)' }, }, required: ['startDate', 'endDate'], }, handler: async (args: any, client: FieldEdgeClient) => { const report = await client.getRevenueReport(args.startDate, args.endDate); return { content: [{ type: 'text', text: `Revenue Report (${args.startDate} to ${args.endDate}):\n${JSON.stringify(report, null, 2)}`, }], }; }, }, { name: 'fieldedge_get_technician_productivity_report', description: 'Get technician productivity report for a date range', inputSchema: { type: 'object', properties: { startDate: { type: 'string', description: 'Start date (YYYY-MM-DD)' }, endDate: { type: 'string', description: 'End date (YYYY-MM-DD)' }, }, required: ['startDate', 'endDate'], }, handler: async (args: any, client: FieldEdgeClient) => { const report = await client.getTechnicianProductivityReport(args.startDate, args.endDate); return { content: [{ type: 'text', text: `Technician Productivity Report:\n${JSON.stringify(report, null, 2)}`, }], }; }, }, { name: 'fieldedge_get_job_completion_report', description: 'Get job completion statistics for a date range', inputSchema: { type: 'object', properties: { startDate: { type: 'string', description: 'Start date (YYYY-MM-DD)' }, endDate: { type: 'string', description: 'End date (YYYY-MM-DD)' }, }, required: ['startDate', 'endDate'], }, handler: async (args: any, client: FieldEdgeClient) => { const report = await client.getJobCompletionReport(args.startDate, args.endDate); return { content: [{ type: 'text', text: `Job Completion Report:\n${JSON.stringify(report, null, 2)}`, }], }; }, }, { name: 'fieldedge_get_aging_receivables_report', description: 'Get aging receivables report showing outstanding invoices by age', inputSchema: { type: 'object', properties: {}, }, handler: async (args: any, client: FieldEdgeClient) => { const report = await client.getAgingReceivablesReport(); return { content: [{ type: 'text', text: `Aging Receivables Report:\n${JSON.stringify(report, null, 2)}`, }], }; }, }, { name: 'fieldedge_get_inventory_valuation_report', description: 'Get inventory valuation report showing current inventory value', inputSchema: { type: 'object', properties: {}, }, handler: async (args: any, client: FieldEdgeClient) => { const report = await client.getInventoryValuationReport(); return { content: [{ type: 'text', text: `Inventory Valuation Report:\n${JSON.stringify(report, null, 2)}`, }], }; }, }, { name: 'fieldedge_get_sales_by_category_report', description: 'Get sales breakdown by category for a date range', inputSchema: { type: 'object', properties: { startDate: { type: 'string', description: 'Start date (YYYY-MM-DD)' }, endDate: { type: 'string', description: 'End date (YYYY-MM-DD)' }, }, required: ['startDate', 'endDate'], }, handler: async (args: any, client: FieldEdgeClient) => { const report = await client.getSalesByCategoryReport(args.startDate, args.endDate); return { content: [{ type: 'text', text: `Sales by Category Report:\n${JSON.stringify(report, null, 2)}`, }], }; }, }, ];