feat: add memo filter and enhance description filter with regex matching

- Add new memo filter to transaction page (searches :transaction/memo)
- Enhance existing description filter to use case-insensitive regex
- Both filters support wildcard matching via .* pattern
- Add e2e tests for filter functionality
- Update test data with memo fields
This commit is contained in:
2026-05-26 16:34:56 -07:00
parent 712b2c0cb8
commit 200056098f
5 changed files with 367 additions and 4 deletions

View File

@@ -0,0 +1,66 @@
# Design: Memo and Description Filters for Transaction Page
## Overview
Add a new **Memo** filter to the transaction page and enhance the existing **Description** filter to support wildcard matching. Both filters should be case-insensitive.
## Changes
### 1. New Memo Filter
- Add a text input field in the filter sidebar
- Search against `:transaction/memo` attribute
- Convert user input to regex pattern `.*input.*` with `(?i)` flag
- Use Datomic `re-find` for matching
- **Place this filter towards the end of the filter list** since regex matching is expensive
### 2. Enhanced Description Filter
- Change from `.contains` substring matching to `re-find` with `(?i)` flag
- Wrap user input with `.*` on both ends: `.*input.*`
- Maintains existing UI placement
## Files Modified
- `src/clj/auto_ap/ssr/transaction/common.clj`
### Query Schema Changes
Add `:memo` key to the `query-schema` map:
```clojure
[:memo {:optional true} [:maybe [:string {:decode/string strip}]]]
```
### Filter UI Changes
Add memo filter input in the `filters` function, placed **after** the Amount filter and **before** the Linking filter.
### Query Logic Changes
In `fetch-ids`, add memo filter condition in the `cond->` chain (placed after other cheaper filters like description).
### Description Filter Update
Change the description filter from:
```clojure
'[(clojure.string/lower-case ?do) ?do2]
'[(.contains ?do2 ?description)]]
```
To:
```clojure
'[(re-find ?description-regex ?do)]]
```
with args: `[(re-pattern (str "(?i).*" description ".*"))]`
## Behavior
- Both filters are optional (only applied when user enters text)
- Both are case-insensitive
- Both support substring matching (e.g., "rent" matches "Monthly Rent Payment")
- Empty or whitespace-only input is ignored
## Performance Considerations
- Memo filter is placed towards the end of the filter chain since regex operations are more expensive than exact matches
- Description filter also uses regex, but since it's an existing filter being enhanced, it stays in its current position in the query