feat: support tracking categories on manual journals#180
Open
rathga wants to merge 2 commits into
Open
Conversation
Manual journal lines could not carry Xero tracking categories: the write path discarded `tracking` and the read serializer never printed it, despite the SDK's `ManualJournalLine` type supporting it. This left placeholder `// TODO: tracking can be added here` comments on both paths. - Add a shared `trackingSchema` helper and reuse it across the invoice and manual-journal create/update tools (removing the duplicated invoice copy). - Add `tracking` (max 2 per line) to the create/update manual-journal line schemas and forward it through both handlers to the Xero API. - Add a `formatTracking` helper that renders a line's tracking as readable `category/option` text (omitting it cleanly when absent) and use it in the list serializer and the create success response. - Fix the create success response, which stringified its line array to `[object Object]`; it now joins lines to text like the list serializer. - Add Vitest coverage for `formatTracking`. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The tool description claimed manual-journal updates "Only works on draft manual journals", but nothing in the code enforced that and the Xero API accepts updates to posted journals too (verified live: created a posted journal, updated its tracking while posted, confirmed the change applied). The inaccurate text discouraged a valid and common operation (e.g. adding tracking to already-posted journals during reconciliation). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Manual journal lines cannot carry Xero tracking categories through this MCP server. The write path silently discards
tracking, and the read serializer never prints it — even though thexero-nodeManualJournalLinetype supports it and the API returns it. The original author left explicit placeholders:This matters for anyone who tracks journal lines by category (e.g. per-property or per-department) during reconciliation — the codes simply don't come through.
Changes
trackingSchema({ name, option, trackingCategoryID }) intosrc/helpers/tracking-schema.tsand reuse it acrosscreate-invoice,update-invoice, and both manual-journal tools — removing the existing duplicated copy in the two invoice tools.tracking(max 2 per line) to the create/update manual-journal line schemas and forward it through both handlers to the Xero API.formatTracking, which renders a line's tracking as readablecategory/optiontext (omitting cleanly when absent), and use it in thelist-manual-journalsserializer and the create success response. The raw array is never printed (avoids the[object Object]pitfall).[object Object],[object Object]— it never rendered line details at all. It now joins lines to text, matching the list serializer.formatTracking.Verification
Verified end-to-end against a real Xero tenant: created a draft manual journal with tracking on each line, read it back (codes appear), updated the tracking and re-read (new codes appear), and confirmed no
[object Object]leaks.npm run lintandnpm testpass.Notes
src/helpers/format-line-item.ts, so it does not collide with PR Format line item tracking values #178 (invoice/bank-tx tracking formatting).🤖 Generated with Claude Code