Skip to content

feat: add tracking-category/option filtering to list-profit-and-loss (supersedes #161)#186

Open
rathga wants to merge 1 commit into
XeroAPI:mainfrom
rathga:feat/pnl-tracking-filter
Open

feat: add tracking-category/option filtering to list-profit-and-loss (supersedes #161)#186
rathga wants to merge 1 commit into
XeroAPI:mainfrom
rathga:feat/pnl-tracking-filter

Conversation

@rathga

@rathga rathga commented Jun 7, 2026

Copy link
Copy Markdown

Summary

Adds tracking-category/option filtering to the list-profit-and-loss tool, exposing the tracking filters the Xero P&L report endpoint natively supports:

  • trackingCategoryID alone -> P&L with one column per option in that category (per-option breakdown).
  • trackingCategoryID + trackingOptionID -> P&L filtered to that single option.
  • trackingCategoryID2 (+ trackingOptionID2) -> cross-tab against a second category (not a second option of the same category).

The tool descriptions instruct the agent to obtain IDs from the list-tracking-categories tool and explain the breakdown-vs-filter and second-category behaviour.

Refactor to a params object

The handler (listXeroProfitAndLoss and its inner fetch) now takes a single typed ListProfitAndLossParams object instead of positional arguments, mirroring the sibling list-report-balance-sheet handler / ListReportBalanceSheetParams. This keeps the two report tools consistent and removes the fragile positional argument passing.

Supersedes #161 / fixes #138

This supersedes bug-fix PR #161 (issue #138) by fixing the underlying positional-argument bug structurally rather than with a one-line patch. Previously listXeroProfitAndLoss called fetchProfitAndLoss with only 5 positional args against a 6-arg signature, so paymentsOnly landed in the standardLayout slot and the real paymentsOnly was silently dropped -- both flags were broken. The params-object refactor eliminates the positional coupling entirely, and the new code also uses the correct SDK argument order (categoryID, categoryID2, optionID, optionID2).

Testing

  • npm run build passes.
  • npm run lint passes with no new warnings.

🤖 Generated with Claude Code

Add optional trackingCategoryID, trackingOptionID, trackingCategoryID2
and trackingOptionID2 params to the list-profit-and-loss tool, exposing
the tracking filters the Xero P&L report endpoint natively supports
(per-option breakdown, single-option filter, or cross-tab against a
second category).

Refactor listXeroProfitAndLoss and the inner fetch to take a single
ListProfitAndLossParams object, mirroring the sibling
list-report-balance-sheet handler. This removes the fragile positional
argument passing and structurally fixes a pre-existing bug: the handler
previously called fetchProfitAndLoss with only 5 positional args, so
paymentsOnly landed in the standardLayout slot and the real paymentsOnly
was dropped (both flags were broken). It also corrects the SDK argument
order to categoryID, categoryID2, optionID, optionID2.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

list-profit-and-loss: paymentsOnly parameter may not be reaching the Xero API

1 participant