feat: add API to search Invoices
Description
Added a new API endpoint to search invoices across all organisations. This endpoint enables administrators to search invoices with organisation details, offering advanced filtering capabilities.
Implementation Details
• Added new RPC endpoint with HTTP interface /v1beta1/admin/invoices/search
• Implemented RQL-based search functionality on invoice and organisation fields
• Added support for filtering, sorting and pagination parameters
• Invoices are fetched along with organisation information (ID, name, title)
• Query joins across billing_invoices, billing_customers and organizations tables
Database Query
The implementation uses an optimised SQL query that: • Joins billing_invoices with billing_customers and organizations tables • Supports full-text search across invoice and organisation fields • Filters invoices based on RQL query parameters • Provides sorting on invoice fields (amount, state, created_at) and org fields (name, title) • Includes pagination with offset and limit
Testing
• Added unit tests for repository query generation
Example Usage
curl --location 'localhost:8000/v1beta1/admin/invoices/search' \
--header 'Content-Type: application/json' \
--data '{
"query": {
"search": "test",
"filters": [
{"name": "state", "operator": "eq", "string_value": "paid"}
],
"sort": [
{"name": "created_at", "order": "desc"}
],
"offset": 0,
"limit": 10
}
}'
Response includes: • Invoice details (ID, amount, currency, state, created_at) • Organisation information (ID, name, title) • Pagination metadata
Related Issues
https://github.com/raystack/proton/pull/410
The latest updates on your projects. Learn more about Vercel for Git ↗︎
| Name | Status | Preview | Comments | Updated (UTC) |
|---|---|---|---|---|
| frontier | ✅ Ready (Inspect) | Visit Preview | 💬 Add feedback | Jun 24, 2025 7:53am |
Pull Request Test Coverage Report for Build 15844569670
Details
- 91 of 167 (54.49%) changed or added relevant lines in 4 files are covered.
- No unchanged relevant lines lost coverage.
- Overall coverage increased (+0.1%) to 33.456%
| Changes Missing Coverage | Covered Lines | Changed/Added Lines | % |
|---|---|---|---|
| billing/invoice/service.go | 0 | 3 | 0.0% |
| pkg/server/interceptors/authorization.go | 0 | 3 | 0.0% |
| internal/store/postgres/billing_invoice_repository.go | 91 | 121 | 75.21% |
| internal/api/v1beta1/billing_invoice.go | 0 | 40 | 0.0% |
| <!-- | Total: | 91 | 167 |
| Totals | |
|---|---|
| Change from base Build 15583085230: | 0.1% |
| Covered Lines: | 9962 |
| Relevant Lines: | 29776 |