Skip to content

fix(expenses): add fetch_categories tool and category field to add-expense form - #9

Merged
theprogrammersingh merged 1 commit into
mainfrom
fix/expense-category-resolution
Sep 3, 2026
Merged

fix(expenses): add fetch_categories tool and category field to add-expense form#9
theprogrammersingh merged 1 commit into
mainfrom
fix/expense-category-resolution

Conversation

@theprogrammersingh

Copy link
Copy Markdown
Owner

Problem

  1. When calling submit_expense, its schema previously accepted a category property (name string like "Travel"), but the backend's CreateExpenseDto expects categoryId (UUID) with ValidationPipe({ whitelist: true, forbidNonWhitelisted: true }). This caused a 400 Bad Request error when category was passed, and recent entries lacked a category_id in the database.
  2. The Add Expense form had no category selector.

Solution

  1. fetch_categories Tool:
    • Added a new read-only WebMCP tool contract (FETCH_CATEGORIES) in @actuo/shared and implemented in ExpenseTools.
    • Returns the organization's categories (id, name, icon) so the model can resolve human-readable category names to valid categoryId UUIDs before filing.
    • Included in ALWAYS_ON_TOOLS.
  2. submit_expense Tool Contract:
    • Updated input schema to take categoryId UUID, aligned directly with backend CreateExpenseDto.
    • Updated description instructing the agent to invoke fetch_categories first when a user mentions a category.
  3. Add Expense Form:
    • Added a <select id="categoryId" name="categoryId"> dropdown populated asynchronously from GET /api/orgs/current/categories.
    • Annotated with declarative WebMCP attributes.
    • Forwards categoryId in the creation payload.
  4. Tests:
    • Added unit tests for fetch_categories and categoryId submission in expense-tools.spec.ts.
    • Added tests for category dropdown rendering and submission in add-expense.spec.ts.
    • Updated tool list assertions in gemini-schema.spec.ts and tool-session.spec.ts.

Verification

  • Frontend unit tests: 46/46 passed (821 tests)
  • Backend unit tests: 10/10 passed (142 tests)
  • Full monorepo build (pnpm build): passed

…pense form

- Add fetch_categories read-only WebMCP tool contract and implementation
- Update submit_expense tool contract to accept categoryId UUID instead of category name
- Add category dropdown selector to Add Expense form with declarative annotations
- Update unit tests and tool registration assertions
@theprogrammersingh
theprogrammersingh merged commit d65e5b6 into main Sep 3, 2026
1 check 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