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:
@@ -40,6 +40,7 @@
|
||||
:else
|
||||
(boolean %))}}]]]
|
||||
[:description {:optional true} [:maybe [:string {:decode/string strip}]]]
|
||||
[:memo {:optional true} [:maybe [:string {:decode/string strip}]]]
|
||||
[:vendor {:optional true :default nil} [:maybe [:entity-map {:pull [:db/id :vendor/name]}]]]
|
||||
[:bank-account {:optional true :default nil} [:maybe [:entity-map {:pull [:db/id :bank-account/numeric-code]}]]]
|
||||
[:account {:optional true :default nil} [:maybe [:entity-map {:pull [:db/id :account/name]}]]]
|
||||
@@ -138,11 +139,16 @@
|
||||
(some-> (:end-date query-params) coerce/to-date)]]}
|
||||
|
||||
(seq (:description args))
|
||||
(merge-query {:query {:in ['?description]
|
||||
(merge-query {:query {:in ['?description-regex]
|
||||
:where ['[?e :transaction/description-original ?do]
|
||||
'[(clojure.string/lower-case ?do) ?do2]
|
||||
'[(.contains ?do2 ?description)]]}
|
||||
:args [(str/lower-case (:description args))]})
|
||||
'[(re-find ?description-regex ?do)]]}
|
||||
:args [(re-pattern (str "(?i).*" (str/lower-case (:description args)) ".*"))]})
|
||||
|
||||
(seq (:memo args))
|
||||
(merge-query {:query {:in ['?memo-regex]
|
||||
:where ['[?e :transaction/memo ?memo]
|
||||
'[(re-find ?memo-regex ?memo)]]}
|
||||
:args [(re-pattern (str "(?i).*" (str/lower-case (:memo args)) ".*"))]})
|
||||
|
||||
(:amount-gte args)
|
||||
(merge-query {:query {:in ['?amount-gte]
|
||||
@@ -345,6 +351,14 @@
|
||||
:placeholder "e.g., Groceries"
|
||||
:size :small}))
|
||||
|
||||
(com/field {:label "Memo"}
|
||||
(com/text-input {:name "memo"
|
||||
:id "memo"
|
||||
:class "hot-filter"
|
||||
:value (:memo (:query-params request))
|
||||
:placeholder "e.g., Rent"
|
||||
:size :small}))
|
||||
|
||||
(com/field {:label "Location"}
|
||||
(com/text-input {:name "location"
|
||||
:id "location"
|
||||
|
||||
Reference in New Issue
Block a user