create_expense_report
Create and submit expense reports in Autotask PSA by specifying submitter details, report name, description, and week ending date.
Instructions
Create a new expense report
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| name | No | Expense report name | |
| description | No | Expense report description | |
| submitterId | Yes | The resource ID of the submitter | |
| weekEndingDate | No | Week ending date (YYYY-MM-DD format) |
Implementation Reference
- src/handlers/tool.handler.ts:769-794 (registration)Tool registration in listTools() method, defining the name, description, and input schema for create_expense_report{ name: 'create_expense_report', description: 'Create a new expense report', inputSchema: { type: 'object', properties: { name: { type: 'string', description: 'Expense report name' }, description: { type: 'string', description: 'Expense report description' }, submitterId: { type: 'number', description: 'The resource ID of the submitter' }, weekEndingDate: { type: 'string', description: 'Week ending date (YYYY-MM-DD format)' } }, required: ['submitterId'] } },
- src/handlers/tool.handler.ts:1260-1268 (handler)Handler dispatch in callTool() switch statement that maps arguments and calls autotaskService.createExpenseReportcase 'create_expense_report': result = await this.autotaskService.createExpenseReport({ name: args.name, description: args.description, submitterID: args.submitterId, weekEndingDate: args.weekEndingDate }); message = `Successfully created expense report with ID: ${result}`; break;
- Core implementation of createExpenseReport that initializes the Autotask client and calls the autotask-node library's expenses.create method to perform the API operation.async createExpenseReport(report: Partial<AutotaskExpenseReport>): Promise<number> { const client = await this.ensureClient(); try { this.logger.debug('Creating expense report:', report); const result = await client.expenses.create(report as any); const reportId = (result.data as any)?.id; this.logger.info(`Expense report created with ID: ${reportId}`); return reportId; } catch (error) { this.logger.error('Failed to create expense report:', error); throw error; } }