Skip to content

closing #485#493

Closed
aabxtract wants to merge 1 commit into
SafeVault:mainfrom
aabxtract:feat/transaction-history-filter-sort
Closed

closing #485#493
aabxtract wants to merge 1 commit into
SafeVault:mainfrom
aabxtract:feat/transaction-history-filter-sort

Conversation

@aabxtract
Copy link
Copy Markdown

Approach

The transaction history endpoint (GET /api/v1/finance/transactions) already filtered by status, type, and asset, but sorting was hardcoded to date-descending. I extended the validated query schema with two new params — sortBy (date | status | type) and order (asc | desc) — and replaced the fixed sort with a dynamic comparator driven by those params. Filters and sort are composed from the presence and value of the validated query params, so the frontend can natively filter out failed transactions or view a specific type in any order without client-side post-processing.

What changed

  • src/server/validations/finance.schema.ts — added sortBy (enum date|status|type, default date) and order (enum asc|desc, default desc) to ListTransactionsSchema. Invalid values are rejected with a 400.
  • src/server/services/transaction.service.ts — replaced the hardcoded timestamp desc sort with a dynamic comparator: date sorts by timestamp, status/type sort alphabetically, and order flips the direction.
  • src/app/api/v1/finance/transactions/route.ts — read sortBy and order from the query string and documented both params in the Swagger block.
  • src/app/api/v1/finance/transactions/route.test.ts — new tests covering default sort, status/type filtering, combined filters, ascending/descending sorts by each field, and 400s on invalid sortBy/order.

Example

GET /api/v1/finance/transactions?status=Pending&type=deposit&sortBy=date&order=desc
GET /api/v1/finance/transactions?sortBy=status&order=asc

Testing

  • vitest run src/app/api/v1/finance/transactions/route.test.ts → 9 passed
  • vitest run src/app/api/v1/finance/ → 17 passed (no regressions)
  • eslint on all changed files → clean

Notes

  • Backwards compatible: with no sortBy/order supplied, behavior is unchanged (date descending).
  • The contribution guide says PRs target the dev branch, but no dev branch currently exists on origin (only main). Please confirm the target branch / create dev if needed.

Closes #485

Extend GET /api/v1/finance/transactions to support sortBy (date,
status, type) and order (asc, desc) query params on top of the
existing status/type/asset filters. Sorting is built dynamically
from the validated params so the frontend can natively filter and
order the transaction table.

- Add sortBy/order to ListTransactionsSchema (validated, defaulted)
- Replace hardcoded date-desc sort with dynamic comparator
- Document new params in Swagger
- Add route tests covering filtering, sorting and validation

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@vercel
Copy link
Copy Markdown

vercel Bot commented May 29, 2026

@aabxtract is attempting to deploy a commit to the vestroll's projects Team on Vercel.

A member of the Team first needs to authorize it.

Copy link
Copy Markdown
Contributor

@codeZe-us codeZe-us left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@aabxtract PR should point to dev branch not main branch

@aabxtract
Copy link
Copy Markdown
Author

which branch?

@aabxtract aabxtract closed this May 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FIX] Transaction History Filtering API

2 participants