Skip to content

feat: add delete-credit-note-allocation tool (+ show allocations in list-credit-notes)#194

Open
rathga wants to merge 1 commit into
XeroAPI:mainfrom
rathga:feat/delete-credit-note-allocation
Open

feat: add delete-credit-note-allocation tool (+ show allocations in list-credit-notes)#194
rathga wants to merge 1 commit into
XeroAPI:mainfrom
rathga:feat/delete-credit-note-allocation

Conversation

@rathga

@rathga rathga commented Jun 10, 2026

Copy link
Copy Markdown

What

Adds a delete-credit-note-allocation tool wrapping AccountingApi.deleteCreditNoteAllocations, and extends list-credit-notes output with each credit note's allocations (allocation ID, amount, date, target invoice) and remaining credit so allocation IDs are discoverable.

Why

create-credit-note-allocation can apply credit to an invoice, but there is currently no way to undo an allocation made in error — or to free up an allocated credit note so it can be corrected and re-applied. The common bookkeeping flow "de-allocate → fix → re-allocate" is impossible via the MCP today. Notably, once a credit note is fully allocated Xero flips its status to PAID, so nothing about it can be changed until the allocation is removed.

list-credit-notes previously didn't show allocations at all, so even with a delete tool there was no way to obtain an allocation ID; this PR surfaces them in the existing list output.

Changes

  • src/handlers/delete-xero-credit-note-allocation.handler.ts — thin wrapper around deleteCreditNoteAllocations(tenantId, creditNoteID, allocationID)
  • src/tools/delete/delete-credit-note-allocation.tool.ts — MCP tool (creditNoteId, allocationId)
  • src/tools/delete/index.ts — register the tool
  • src/tools/list/list-credit-notes.tool.ts — include remaining credit + allocations (with IDs) per credit note

Testing

  • npm run build, npm run lint, npm test all pass
  • Live-verified against a real Xero tenant: created a throwaway credit note + invoice, allocated the credit, confirmed the allocation (with its ID) appears in list-credit-notes, deleted the allocation via the new tool, and confirmed the allocation disappeared and the credit note's remaining credit returned to the full amount (status PAID → AUTHORISED). All fixtures voided/archived afterwards.

🤖 Generated with Claude Code

…in list-credit-notes

Co-Authored-By: Claude Fable 5 <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.

1 participant