autotask_create_expense_item
Add an expense line item to an existing expense report with details like date, category, amount, and billability options.
Instructions
Create an expense item on an existing expense report
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| expenseReportId | Yes | The expense report ID to add the item to | |
| description | Yes | Line item description | |
| expenseDate | Yes | Date of expense (YYYY-MM-DD format) | |
| expenseCategory | Yes | Expense category picklist ID | |
| amount | Yes | Expense amount | |
| companyId | No | Associated company ID (0 for internal) | |
| haveReceipt | No | Whether a receipt is attached | |
| isBillableToCompany | No | Whether billable to company | |
| isReimbursable | No | Whether this expense is reimbursable | |
| paymentType | No | Payment type picklist ID |
Implementation Reference
- Schema definition for autotask_create_expense_item tool, defining input parameters (expenseReportId, description, expenseDate, expenseCategory, amount, companyId, etc.) with required fields.
// Expense Item tools { name: 'autotask_create_expense_item', description: 'Create an expense item on an existing expense report', inputSchema: { type: 'object', properties: { expenseReportId: { type: 'number', description: 'The expense report ID to add the item to' }, description: { type: 'string', description: 'Line item description' }, expenseDate: { type: 'string', description: 'Date of expense (YYYY-MM-DD format)' }, expenseCategory: { type: 'number', description: 'Expense category picklist ID' }, amount: { type: 'number', description: 'Expense amount' }, companyId: { type: 'number', description: 'Associated company ID (0 for internal)' }, haveReceipt: { type: 'boolean', description: 'Whether a receipt is attached' }, isBillableToCompany: { type: 'boolean', description: 'Whether billable to company' }, isReimbursable: { type: 'boolean', description: 'Whether this expense is reimbursable' }, paymentType: { type: 'number', description: 'Payment type picklist ID' } }, required: ['expenseReportId', 'description', 'expenseDate', 'expenseCategory', 'amount'] } }, - src/handlers/tool.handler.ts:1147-1151 (handler)Handler function that maps tool arguments to the Autotask API call for creating an expense item. Translates 'amount' to 'expenseCurrencyExpenseAmount', with defaults for companyId=0, haveReceipt=false, isBillableToCompany=false, isReimbursable=true, paymentType=10.
// Expense Items ['autotask_create_expense_item', async (a) => { const id = await s.createExpenseItem({ expenseReportID: a.expenseReportId, description: a.description, expenseDate: a.expenseDate, expenseCategory: a.expenseCategory, expenseCurrencyExpenseAmount: a.amount, companyID: a.companyId ?? 0, haveReceipt: a.haveReceipt ?? false, isBillableToCompany: a.isBillableToCompany ?? false, isReimbursable: a.isReimbursable ?? true, paymentType: a.paymentType ?? 10 }); return { result: id, message: `Successfully created expense item with ID: ${id}` }; }], - src/handlers/tool.definitions.ts:3013-3015 (registration)Registration of autotask_create_expense_item in the 'time_and_billing' category's tools list.
time_and_billing: { description: 'Time entries, billing items, and expense management', tools: ['autotask_create_time_entry', 'autotask_search_time_entries', 'autotask_search_billing_items', 'autotask_get_billing_item', 'autotask_search_billing_item_approval_levels', 'autotask_get_expense_report', 'autotask_search_expense_reports', 'autotask_create_expense_report', 'autotask_create_expense_item'] - Service layer helper that calls http.create('ExpenseItems', item) to create the expense item via the Autotask REST API.
async createExpenseItem(item: Partial<AutotaskExpenseItem>): Promise<number> { const http = await this.ensureClient(); try { this.logger.debug('Creating expense item:', item); const id = await http.create('ExpenseItems', item); this.logger.info(`Expense item created with ID: ${id}`); return id; } catch (error) { this.logger.error('Failed to create expense item:', error); throw error; } }