Skip to content

Fix Addie list_pending_invoices to query Stripe directly#503

Merged
bokelley merged 1 commit into
mainfrom
bokelley/addie-unpaid-invoices
Jan 3, 2026
Merged

Fix Addie list_pending_invoices to query Stripe directly#503
bokelley merged 1 commit into
mainfrom
bokelley/addie-unpaid-invoices

Conversation

@bokelley

@bokelley bokelley commented Jan 3, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Fixed bug where Addie's list_pending_invoices tool only checked organizations with stripe_customer_id in the database
  • Now queries Stripe directly for all open/draft invoices, finding invoices even for unlinked customers
  • Matches invoices to organizations where possible via workos_organization_id metadata or stripe_customer_id

Problem

When asked "Who has unpaid invoices?", Addie reported "No pending invoices found" even though there were open invoices in Stripe. This was because the tool only iterated over organizations in our database that had stripe_customer_id set, missing invoices for customers not yet linked.

Solution

  • Added getAllOpenInvoices() function that queries Stripe API directly for all open and draft invoices
  • Updated list_pending_invoices handler to use the new function
  • Extracts customer info including workos_organization_id from Stripe customer metadata
  • Falls back to showing customer name/email for invoices that can't be matched to an org

Test plan

  • TypeScript compiles successfully
  • All existing tests pass
  • Manual test: Ask Addie "Who has unpaid invoices?" and verify all open invoices are shown

🤖 Generated with Claude Code

Bug: Addie's list_pending_invoices tool only checked organizations with
stripe_customer_id in our database, missing invoices for customers not
yet linked (e.g., sent via send_invoice without saving customer ID back).

Fix: Query Stripe directly for all open/draft invoices instead of
iterating over database organizations. The tool now:
- Queries Stripe API for all open and draft invoices
- Extracts customer info including workos_organization_id from metadata
- Matches invoices to organizations where possible
- Falls back to showing customer name for unlinked invoices
- Shows total amount due across all invoices

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@bokelley bokelley merged commit 28b4a2d into main Jan 3, 2026
6 checks passed
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