update-timesheet-line
Modify an existing payroll timesheet line in Xero by updating details like earnings rate, units worked, and date for accurate time tracking.
Instructions
Update an existing timesheet line in a payroll timesheet in Xero.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| timesheetID | Yes | The ID of the timesheet to update. | |
| timesheetLineID | Yes | The ID of the timesheet line to update. | |
| timesheetLine | Yes | The details of the timesheet line to update. |
Implementation Reference
- The primary handler function that wraps the API call, handles errors, and returns a standardized response.export async function updateXeroPayrollTimesheetUpdateLine( timesheetID: string, timesheetLineID: string, timesheetLine: TimesheetLine ): Promise<XeroClientResponse<TimesheetLine | null>> { try { const updatedLine = await updateTimesheetLine(timesheetID, timesheetLineID, timesheetLine); return { result: updatedLine, isError: false, error: null, }; } catch (error) { return { result: null, isError: true, error: formatError(error), }; } }
- Helper function that authenticates the Xero client and performs the actual API call to update the timesheet line.async function updateTimesheetLine( timesheetID: string, timesheetLineID: string, timesheetLine: TimesheetLine ): Promise<TimesheetLine | null> { await xeroClient.authenticate(); // Call the updateTimesheetLine endpoint from the PayrollNZApi const updatedLine = await xeroClient.payrollNZApi.updateTimesheetLine( xeroClient.tenantId, timesheetID, timesheetLineID, timesheetLine, ); return updatedLine.body.timesheetLine ?? null; }
- Zod schema defining the input parameters: timesheetID, timesheetLineID, and timesheetLine object.timesheetID: z.string().describe("The ID of the timesheet to update."), timesheetLineID: z.string().describe("The ID of the timesheet line to update."), timesheetLine: z.object({ earningsRateID: z.string().describe("The ID of the earnings rate."), numberOfUnits: z.number().describe("The number of units for the timesheet line."), date: z.string().describe("The date for the timesheet line (YYYY-MM-DD)."), }).describe("The details of the timesheet line to update."), },
- src/tools/update/index.ts:16-30 (registration)Registers the tool by including UpdatePayrollTimesheetLineTool in the UpdateTools array, which is later registered to the MCP server.export const UpdateTools = [ UpdateContactTool, UpdateCreditNoteTool, UpdateInvoiceTool, UpdateManualJournalTool, UpdateQuoteTool, UpdateItemTool, UpdateBankTransactionTool, ApprovePayrollTimesheetTool, AddTimesheetLineTool, UpdatePayrollTimesheetLineTool, RevertPayrollTimesheetTool, UpdateTrackingCategoryTool, UpdateTrackingOptionsTool ];
- src/tools/tool-factory.ts:23-25 (registration)Final MCP server registration: calls server.tool for each tool in UpdateTools, including 'update-timesheet-line'.UpdateTools.map((tool) => tool()).forEach((tool) => server.tool(tool.name, tool.description, tool.schema, tool.handler), );